Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rfc1155.py 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
  5. # License: http://snmplabs.com/pyasn1/license.html
  6. #
  7. # SNMPv1 message syntax
  8. #
  9. # ASN.1 source from:
  10. # http://www.ietf.org/rfc/rfc1155.txt
  11. #
  12. # Sample captures from:
  13. # http://wiki.wireshark.org/SampleCaptures/
  14. #
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import tag
  18. from pyasn1.type import univ
  19. class ObjectName(univ.ObjectIdentifier):
  20. pass
  21. class SimpleSyntax(univ.Choice):
  22. componentType = namedtype.NamedTypes(
  23. namedtype.NamedType('number', univ.Integer()),
  24. namedtype.NamedType('string', univ.OctetString()),
  25. namedtype.NamedType('object', univ.ObjectIdentifier()),
  26. namedtype.NamedType('empty', univ.Null())
  27. )
  28. class IpAddress(univ.OctetString):
  29. tagSet = univ.OctetString.tagSet.tagImplicitly(
  30. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0)
  31. )
  32. subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint(
  33. 4, 4
  34. )
  35. class NetworkAddress(univ.Choice):
  36. componentType = namedtype.NamedTypes(
  37. namedtype.NamedType('internet', IpAddress())
  38. )
  39. class Counter(univ.Integer):
  40. tagSet = univ.Integer.tagSet.tagImplicitly(
  41. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 1)
  42. )
  43. subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
  44. 0, 4294967295
  45. )
  46. class Gauge(univ.Integer):
  47. tagSet = univ.Integer.tagSet.tagImplicitly(
  48. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 2)
  49. )
  50. subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
  51. 0, 4294967295
  52. )
  53. class TimeTicks(univ.Integer):
  54. tagSet = univ.Integer.tagSet.tagImplicitly(
  55. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 3)
  56. )
  57. subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
  58. 0, 4294967295
  59. )
  60. class Opaque(univ.OctetString):
  61. tagSet = univ.OctetString.tagSet.tagImplicitly(
  62. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 4)
  63. )
  64. class ApplicationSyntax(univ.Choice):
  65. componentType = namedtype.NamedTypes(
  66. namedtype.NamedType('address', NetworkAddress()),
  67. namedtype.NamedType('counter', Counter()),
  68. namedtype.NamedType('gauge', Gauge()),
  69. namedtype.NamedType('ticks', TimeTicks()),
  70. namedtype.NamedType('arbitrary', Opaque())
  71. )
  72. class ObjectSyntax(univ.Choice):
  73. componentType = namedtype.NamedTypes(
  74. namedtype.NamedType('simple', SimpleSyntax()),
  75. namedtype.NamedType('application-wide', ApplicationSyntax())
  76. )