Home | History | Annotate | Download | only in pyasn1_modules
      1 #
      2 # This file is part of pyasn1-modules software.
      3 #
      4 # Copyright (c) 2005-2017, Ilya Etingof <etingof (at] gmail.com>
      5 # License: http://pyasn1.sf.net/license.html
      6 #
      7 # SNMPv3 message syntax
      8 #
      9 # ASN.1 source from:
     10 # http://www.ietf.org/rfc/rfc3412.txt
     11 #
     12 from pyasn1.type import constraint
     13 from pyasn1.type import namedtype
     14 from pyasn1.type import univ
     15 
     16 from pyasn1_modules import rfc1905
     17 
     18 
     19 class ScopedPDU(univ.Sequence):
     20     componentType = namedtype.NamedTypes(
     21         namedtype.NamedType('contextEngineId', univ.OctetString()),
     22         namedtype.NamedType('contextName', univ.OctetString()),
     23         namedtype.NamedType('data', rfc1905.PDUs())
     24     )
     25 
     26 
     27 class ScopedPduData(univ.Choice):
     28     componentType = namedtype.NamedTypes(
     29         namedtype.NamedType('plaintext', ScopedPDU()),
     30         namedtype.NamedType('encryptedPDU', univ.OctetString()),
     31     )
     32 
     33 
     34 class HeaderData(univ.Sequence):
     35     componentType = namedtype.NamedTypes(
     36         namedtype.NamedType('msgID',
     37                             univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))),
     38         namedtype.NamedType('msgMaxSize',
     39                             univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(484, 2147483647))),
     40         namedtype.NamedType('msgFlags', univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 1))),
     41         namedtype.NamedType('msgSecurityModel',
     42                             univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 2147483647)))
     43     )
     44 
     45 
     46 class SNMPv3Message(univ.Sequence):
     47     componentType = namedtype.NamedTypes(
     48         namedtype.NamedType('msgVersion',
     49                             univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))),
     50         namedtype.NamedType('msgGlobalData', HeaderData()),
     51         namedtype.NamedType('msgSecurityParameters', univ.OctetString()),
     52         namedtype.NamedType('msgData', ScopedPduData())
     53     )
     54