SnmpSharpNet.AgentParameters.InitializePacket C# (CSharp) Méthode

InitializePacket() public méthode

Initialize SNMP packet class with agent parameters. In this class, SNMP community name is set in SNMPv1 and SNMPv2 packets.
public InitializePacket ( SnmpPacket packet ) : void
packet SnmpPacket Packet class to initialize
Résultat void
        public void InitializePacket(SnmpPacket packet)
        {
            if (packet is SnmpV1Packet)
            {
                SnmpV1Packet pkt = (SnmpV1Packet)packet;
                pkt.Community.Set(_community);
            }
            else if (packet is SnmpV2Packet)
            {
                SnmpV2Packet pkt = (SnmpV2Packet)packet;
                pkt.Community.Set(_community);
            }
            else
                throw new SnmpInvalidVersionException("Invalid SNMP version.");
        }