# Path: pysnmp/carrier/asynsock/dgram/udp.py
# class UdpSocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/udp6.py
#     AF_INET6 = None
# class Udp6SocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/unix.py
#     AF_UNIX = None
# class UnixSocketTransport(DgramSocketTransport):
#     def openClientMode(self, iface=None):
#     def openServerMode(self, iface):
#     def closeTransport(self):
# 
# Path: pysnmp/smi/error.py
# class NoSuchInstanceError(MibOperationError): pass
# 
# Path: pysnmp/proto/errind.py
# class ErrorIndication:
# class ParseError(ErrorIndication): pass
# class UnsupportedMsgProcessingModel(ErrorIndication): pass
# class UnknownPDUHandler(ErrorIndication): pass
# class UnsupportedPDUtype(ErrorIndication): pass
# class RequestTimedOut(ErrorIndication): pass
# class EmptyResponse(ErrorIndication): pass
# class NonReportable(ErrorIndication): pass
# class DataMismatch(ErrorIndication): pass
# class EngineIDMismatch(ErrorIndication): pass
# class UnknownEngineID(ErrorIndication): pass
# class TooBig(ErrorIndication): pass
# class LoopTerminated(ErrorIndication):pass
# class InvalidMsg(ErrorIndication):pass
# class UnknownCommunityName(ErrorIndication): pass
# class NoEncryption(ErrorIndication): pass
# class EncryptionError(ErrorIndication): pass
# class DecryptionError(ErrorIndication): pass
# class NoAuthentication(ErrorIndication): pass
# class AuthenticationError(ErrorIndication): pass
# class AuthenticationFailure(ErrorIndication): pass
# class UnsupportedAuthProtocol(ErrorIndication): pass
# class UnsupportedPrivProtocol(ErrorIndication): pass
# class UnknownSecurityName(ErrorIndication): pass
# class UnsupportedSecurityModel(ErrorIndication): pass
# class UnsupportedSecurityLevel(ErrorIndication): pass
# class NotInTimeWindow(ErrorIndication): pass
# class NoSuchView(ErrorIndication): pass
# class NoAccessEntry(ErrorIndication): pass
# class NoGroupName(ErrorIndication): pass
# class NoSuchContext(ErrorIndication): pass
# class NotInView(ErrorIndication): pass
# class AccessAllowed(ErrorIndication): pass
# class OtherError(ErrorIndication): pass
# class OidNotIncreasing(ErrorIndication): pass
#     def __init__(self, descr=None):
#     def __eq__(self, other): return self.__value == other
#     def __ne__(self, other): return self.__value != other
#     def __lt__(self, other): return self.__value < other
#     def __le__(self, other): return self.__value <= other
#     def __gt__(self, other): return self.__value > other
#     def __ge__(self, other): return self.__value >= other
#     def __str__(self): return self.__descr
# 
# Path: pysnmp/debug.py
# class Debug:
#     def __init__(self, *flags):
#     def __str__(self):
#     def __call__(self, msg):
#     def __and__(self, flag):
#     def __rand__(self, flag):
# def setLogger(l):
# def hexdump(octets):


from pyasn1.codec.ber import encoder
from pysnmp.proto.secmod import base
from pysnmp.carrier.asynsock.dgram import udp, udp6, unix
from pysnmp.smi.error import NoSuchInstanceError
from pysnmp.proto import errind, error
from pysnmp import debug
# SNMP v1 & v2c security models implementation

class SnmpV1SecurityModel(base.AbstractSecurityModel):
    securityModelID = 1
    # According to rfc2576, community name <-> contextEngineId/contextName
    # mapping is up to MP module for notifications but belongs to secmod
    # responsibility for other PDU types. Since I do not yet understand
    # the reason for this de-coupling, I've moved this code from MP-scope
    # in here.

    def __init__(self):
        self.__transportBranchId = self.__paramsBranchId = self.__communityBranchId = self.__securityBranchId = -1
        base.AbstractSecurityModel.__init__(self)

    def _sec2com(self, snmpEngine, securityName, contextEngineId, contextName):
        snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName')
        if self.__paramsBranchId != snmpTargetParamsSecurityName.branchVersionId:
            snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel')

            self.__nameToModelMap = {}

            nextMibNode = snmpTargetParamsSecurityName

            while 1:
                try:
                    nextMibNode = snmpTargetParamsSecurityName.getNextNode(
                                      nextMibNode.name
                                  )

# Path: pysnmp/carrier/asynsock/dgram/udp.py
# class UdpSocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/udp6.py
#     AF_INET6 = None
# class Udp6SocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/unix.py
#     AF_UNIX = None
# class UnixSocketTransport(DgramSocketTransport):
#     def openClientMode(self, iface=None):
#     def openServerMode(self, iface):
#     def closeTransport(self):
# 
# Path: pysnmp/smi/error.py
# class NoSuchInstanceError(MibOperationError): pass
# 
# Path: pysnmp/proto/errind.py
# class ErrorIndication:
# class ParseError(ErrorIndication): pass
# class UnsupportedMsgProcessingModel(ErrorIndication): pass
# class UnknownPDUHandler(ErrorIndication): pass
# class UnsupportedPDUtype(ErrorIndication): pass
# class RequestTimedOut(ErrorIndication): pass
# class EmptyResponse(ErrorIndication): pass
# class NonReportable(ErrorIndication): pass
# class DataMismatch(ErrorIndication): pass
# class EngineIDMismatch(ErrorIndication): pass
# class UnknownEngineID(ErrorIndication): pass
# class TooBig(ErrorIndication): pass
# class LoopTerminated(ErrorIndication):pass
# class InvalidMsg(ErrorIndication):pass
# class UnknownCommunityName(ErrorIndication): pass
# class NoEncryption(ErrorIndication): pass
# class EncryptionError(ErrorIndication): pass
# class DecryptionError(ErrorIndication): pass
# class NoAuthentication(ErrorIndication): pass
# class AuthenticationError(ErrorIndication): pass
# class AuthenticationFailure(ErrorIndication): pass
# class UnsupportedAuthProtocol(ErrorIndication): pass
# class UnsupportedPrivProtocol(ErrorIndication): pass
# class UnknownSecurityName(ErrorIndication): pass
# class UnsupportedSecurityModel(ErrorIndication): pass
# class UnsupportedSecurityLevel(ErrorIndication): pass
# class NotInTimeWindow(ErrorIndication): pass
# class NoSuchView(ErrorIndication): pass
# class NoAccessEntry(ErrorIndication): pass
# class NoGroupName(ErrorIndication): pass
# class NoSuchContext(ErrorIndication): pass
# class NotInView(ErrorIndication): pass
# class AccessAllowed(ErrorIndication): pass
# class OtherError(ErrorIndication): pass
# class OidNotIncreasing(ErrorIndication): pass
#     def __init__(self, descr=None):
#     def __eq__(self, other): return self.__value == other
#     def __ne__(self, other): return self.__value != other
#     def __lt__(self, other): return self.__value < other
#     def __le__(self, other): return self.__value <= other
#     def __gt__(self, other): return self.__value > other
#     def __ge__(self, other): return self.__value >= other
#     def __str__(self): return self.__descr
# 
# Path: pysnmp/debug.py
# class Debug:
#     def __init__(self, *flags):
#     def __str__(self):
#     def __call__(self, msg):
#     def __and__(self, flag):
#     def __rand__(self, flag):
# def setLogger(l):
# def hexdump(octets):


# Path: pysnmp/proto/secmod/rfc2576.py
from pyasn1.codec.ber import encoder
from pysnmp.proto.secmod import base
from pysnmp.carrier.asynsock.dgram import udp, udp6, unix
from pysnmp.smi.error import NoSuchInstanceError
from pysnmp.proto import errind, error
from pysnmp import debug

# SNMP v1 & v2c security models implementation

class SnmpV1SecurityModel(base.AbstractSecurityModel):
    securityModelID = 1
    # According to rfc2576, community name <-> contextEngineId/contextName
    # mapping is up to MP module for notifications but belongs to secmod
    # responsibility for other PDU types. Since I do not yet understand
    # the reason for this de-coupling, I've moved this code from MP-scope
    # in here.

    def __init__(self):
        self.__transportBranchId = self.__paramsBranchId = self.__communityBranchId = self.__securityBranchId = -1
        base.AbstractSecurityModel.__init__(self)

    def _sec2com(self, snmpEngine, securityName, contextEngineId, contextName):
        snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName')
        if self.__paramsBranchId != snmpTargetParamsSecurityName.branchVersionId:
            snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel')

            self.__nameToModelMap = {}

            nextMibNode = snmpTargetParamsSecurityName

            while 1:
                try:
                    nextMibNode = snmpTargetParamsSecurityName.getNextNode(
                                      nextMibNode.name
                                  )

                except NoSuchInstanceError: