Header for Snmp Packet
Ejemplo n.º 1
3
        /// <summary>
        /// Initializes a new instance of the <see cref="SnmpTrapV2C"/> class.
        /// </summary>
        /// <param name="snmpDatagram">The snmp datagram.</param>
        public SnmpTrapV2C(SnmpDatagram snmpDatagram)
        {
            if (snmpDatagram.Header.Version != SnmpVersion.V2C || snmpDatagram.PduV2c.PduType == PduType.Trap)
            {
                throw new InvalidDataException("Not a Valid V2c Trap");
            }

            ObjectIdentifier trapOid      = new ObjectIdentifier("1.3.6.1.6.3.1.1.4.1.0");
            ObjectIdentifier sysUpTimeOid = new ObjectIdentifier("1.3.6.1.2.1.1.3.0");

            PduV2c    = snmpDatagram.PduV2c;
            Header    = snmpDatagram.Header;
            TrapOid   = default(ObjectIdentifier);
            SysUpTime = 0;
            VarBind varBind;

            if (PduV2c.VarBinds.SearchFirstSubOidWith(sysUpTimeOid, out varBind) && varBind.Asn1TypeInfo.Asn1SnmpTagType == Asn1SnmpTag.TimeTicks)
            {
                SysUpTime = (uint)varBind.Value;
            }

            if (PduV2c.VarBinds.SearchFirstSubOidWith(trapOid, out varBind) && varBind.Asn1TypeInfo.Asn1TagType == Asn1Tag.ObjectIdentifier)
            {
                TrapOid = (ObjectIdentifier)varBind.Value;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnmpTrapV2C"/> class.
        /// </summary>
        /// <param name="snmpDatagram">The snmp datagram.</param>
        public SnmpTrapV2C(SnmpDatagram snmpDatagram)
        {
            if(snmpDatagram.Header.Version != SnmpVersion.V2C || snmpDatagram.PduV2c.PduType == PduType.Trap)
            {
                throw new InvalidDataException("Not a Valid V2c Trap");
            }

            ObjectIdentifier trapOid = new ObjectIdentifier("1.3.6.1.6.3.1.1.4.1.0");
            ObjectIdentifier sysUpTimeOid = new ObjectIdentifier("1.3.6.1.2.1.1.3.0");

            PduV2c = snmpDatagram.PduV2c;
            Header = snmpDatagram.Header;
            TrapOid = default(ObjectIdentifier);
            SysUpTime = 0;
            VarBind varBind;
            if (PduV2c.VarBinds.SearchFirstSubOidWith(sysUpTimeOid, out varBind) && varBind.Asn1TypeInfo.Asn1SnmpTagType == Asn1SnmpTag.TimeTicks)
            {
                SysUpTime = (uint)varBind.Value;
            }

            if (PduV2c.VarBinds.SearchFirstSubOidWith(trapOid, out varBind) && varBind.Asn1TypeInfo.Asn1TagType == Asn1Tag.ObjectIdentifier)
            {
                TrapOid = (ObjectIdentifier)varBind.Value;
            }
        }
Ejemplo n.º 3
0
 public SnmpDatagram(DateTimeOffset receivedTime, string sourceIpAddress, SnmpHeader header, IReadOnlyList<VarBind> varBinds)
 {
     this.ReceivedTime = receivedTime;
     this.SourceIpAddress = sourceIpAddress;
     this.Header = header;
     this.VarBinds = varBinds;
 }
Ejemplo n.º 4
0
 public SnmpDatagram(DateTimeOffset receivedTime, string sourceIpAddress, SnmpHeader header, IReadOnlyList <VarBind> varBinds)
 {
     this.ReceivedTime    = receivedTime;
     this.SourceIpAddress = sourceIpAddress;
     this.Header          = header;
     this.VarBinds        = varBinds;
 }
Ejemplo n.º 5
0
 public SnmpDatagramV1(
     DateTimeOffset receivedTime,
     string sourceIpAddress,
     SnmpHeader header,
     IReadOnlyList <VarBind> varBinds)
     : base(receivedTime, sourceIpAddress, header, varBinds)
 {
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnmpTrapV1"/> class.
        /// </summary>
        /// <param name="snmpDatagram">The snmp datagram.</param>
        public SnmpTrapV1(SnmpDatagram snmpDatagram)
        {
            if (snmpDatagram.Header.Version != SnmpVersion.V1 && snmpDatagram.PduV1.PduType != PduType.Trap)
            {
                throw new InvalidDataException("Not a Valid V1 Trap");
            }

            PduV1 = snmpDatagram.PduV1;
            Header = snmpDatagram.Header;
            TrapOid = PduV1.Enterprise;
            SysUpTime = PduV1.TimeStamp;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnmpTrapV1"/> class.
        /// </summary>
        /// <param name="snmpDatagram">The snmp datagram.</param>
        public SnmpTrapV1(SnmpDatagram snmpDatagram)
        {
            if (snmpDatagram.Header.Version != SnmpVersion.V1 && snmpDatagram.PduV1.PduType != PduType.Trap)
            {
                throw new InvalidDataException("Not a Valid V1 Trap");
            }

            PduV1     = snmpDatagram.PduV1;
            Header    = snmpDatagram.Header;
            TrapOid   = PduV1.Enterprise;
            SysUpTime = PduV1.TimeStamp;
        }
Ejemplo n.º 8
0
 public SnmpDatagramV2C(
     DateTimeOffset receivedTime,
     string sourceIpAddress,
     SnmpHeader header,
     IReadOnlyList <VarBind> varBinds,
     PduType pduType,
     int requestId,
     SnmpErrorStatus errorStatus,
     int errorIndex)
     : base(receivedTime, sourceIpAddress, header, varBinds)
 {
     this.PduType     = pduType;
     this.RequestId   = requestId;
     this.ErrorStatus = errorStatus;
     this.ErrorIndex  = errorIndex;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="snmpHeader">The SNMP header.</param>
 /// <param name="snmpPDU">The SNMP pdu.</param>
 public SnmpDatagram(SnmpHeader snmpHeader, SnmpV1PDU snmpPDU)
 {
     Header = snmpHeader;
     PduV1  = snmpPDU;
     PduV2c = default(SnmpV2cPDU);
 }
Ejemplo n.º 10
0
 public SnmpDatagramV1(
     DateTimeOffset receivedTime,
     string sourceIpAddress,
     SnmpHeader header,
     IReadOnlyList<VarBind> varBinds)
     : base(receivedTime, sourceIpAddress, header, varBinds)
 {
 }
Ejemplo n.º 11
0
 public SnmpDatagramV2C(
     DateTimeOffset receivedTime,
     string sourceIpAddress,
     SnmpHeader header,
     IReadOnlyList<VarBind> varBinds,
     PduType pduType,
     int requestId,
     SnmpErrorStatus errorStatus,
     int errorIndex)
     : base(receivedTime, sourceIpAddress, header, varBinds)
 {
     this.PduType = pduType;
     this.RequestId = requestId;
     this.ErrorStatus = errorStatus;
     this.ErrorIndex = errorIndex;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="pduType">Type of the pdu.</param>
 /// <param name="snmpVersion">The SNMP version.</param>
 /// <param name="community">The community.</param>
 /// <param name="enterprise">The enterprise.</param>
 /// <param name="agentAddress">The agent address.</param>
 /// <param name="genericV1Trap">The generic v1 trap.</param>
 /// <param name="specificTrap">The specific trap.</param>
 /// <param name="timeStamp">The time stamp.</param>
 /// <param name="varBinds">The variable binds.</param>
 public SnmpDatagram(PduType pduType, SnmpVersion snmpVersion, string community, ObjectIdentifier enterprise, IPAddress agentAddress, GenericTrap genericV1Trap, int specificTrap, uint timeStamp, VarBind[] varBinds)
 {
     Header = new SnmpHeader(snmpVersion, community);
     PduV1 = new SnmpV1PDU(pduType, enterprise, agentAddress, genericV1Trap, specificTrap, timeStamp, varBinds);
     PduV2c = default(SnmpV2cPDU);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="pduType">Type of the pdu.</param>
 /// <param name="snmpVersion">The SNMP version.</param>
 /// <param name="community">The community.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="errorStatus">The error status.</param>
 /// <param name="errorIndex">Index of the error.</param>
 /// <param name="varBinds">The variable binds.</param>
 public SnmpDatagram(PduType pduType, SnmpVersion snmpVersion, string community, int requestId, SnmpErrorStatus errorStatus, int errorIndex, VarBind[] varBinds)
 {
     Header = new SnmpHeader(snmpVersion, community);
     PduV2c = new SnmpV2cPDU(pduType, requestId, errorStatus, errorIndex, varBinds);
     PduV1 = default(SnmpV1PDU);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// Copy construtor
 /// </summary>
 /// <param name="snmpPacket">The SNMP packet.</param>
 public SnmpDatagram(SnmpDatagram snmpPacket)
 {
     Header = snmpPacket.Header;
     PduV1  = snmpPacket.PduV1;
     PduV2c = snmpPacket.PduV2c;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="snmpHeader">The SNMP header.</param>
 /// <param name="snmpPDU">The SNMP pdu.</param>
 public SnmpDatagram(SnmpHeader snmpHeader, SnmpV1PDU snmpPDU)
 {
     Header = snmpHeader;
     PduV1 = snmpPDU;
     PduV2c = default(SnmpV2cPDU);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="pduType">Type of the pdu.</param>
 /// <param name="snmpVersion">The SNMP version.</param>
 /// <param name="community">The community.</param>
 /// <param name="enterprise">The enterprise.</param>
 /// <param name="agentAddress">The agent address.</param>
 /// <param name="genericV1Trap">The generic v1 trap.</param>
 /// <param name="specificTrap">The specific trap.</param>
 /// <param name="timeStamp">The time stamp.</param>
 /// <param name="varBinds">The variable binds.</param>
 public SnmpDatagram(PduType pduType, SnmpVersion snmpVersion, string community, ObjectIdentifier enterprise, IPAddress agentAddress, GenericTrap genericV1Trap, int specificTrap, uint timeStamp, VarBind[] varBinds)
 {
     Header = new SnmpHeader(snmpVersion, community);
     PduV1  = new SnmpV1PDU(pduType, enterprise, agentAddress, genericV1Trap, specificTrap, timeStamp, varBinds);
     PduV2c = default(SnmpV2cPDU);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// </summary>
 /// <param name="pduType">Type of the pdu.</param>
 /// <param name="snmpVersion">The SNMP version.</param>
 /// <param name="community">The community.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="errorStatus">The error status.</param>
 /// <param name="errorIndex">Index of the error.</param>
 /// <param name="varBinds">The variable binds.</param>
 public SnmpDatagram(PduType pduType, SnmpVersion snmpVersion, string community, int requestId, SnmpErrorStatus errorStatus, int errorIndex, VarBind[] varBinds)
 {
     Header = new SnmpHeader(snmpVersion, community);
     PduV2c = new SnmpV2cPDU(pduType, requestId, errorStatus, errorIndex, varBinds);
     PduV1  = default(SnmpV1PDU);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpDatagram"/> class.
 /// Copy construtor
 /// </summary>
 /// <param name="snmpPacket">The SNMP packet.</param>
 public SnmpDatagram(SnmpDatagram snmpPacket)
 {
     Header = snmpPacket.Header;
     PduV1 = snmpPacket.PduV1;
     PduV2c = snmpPacket.PduV2c;
 }