ln.snmp/endpoint/SnmpV2Endpoint.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2019-03-11 08:57:19 +01:00
using System;
using ln.snmp.types;
using System.Net;
using System.Collections.Generic;
2019-03-11 15:07:34 +01:00
namespace ln.snmp.endpoint
2019-03-11 08:57:19 +01:00
{
2019-03-12 00:54:39 +01:00
public class SnmpV2Endpoint : SnmpV1Endpoint
2019-03-11 08:57:19 +01:00
{
public override SnmpVersion SnmpVersion => SnmpVersion.V2c;
public SnmpV2Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint)
: base(snmpEngine, remoteEndpoint)
{
CommunityString = "public";
}
public SnmpV2Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint, OctetString communityString)
2019-03-12 00:54:39 +01:00
: base(snmpEngine, remoteEndpoint, communityString)
{ }
2019-03-11 08:57:19 +01:00
public SnmpV2Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint, String communityString)
2019-03-12 00:54:39 +01:00
: base(snmpEngine, remoteEndpoint, communityString)
{ }
2019-03-11 08:57:19 +01:00
2019-03-12 00:54:39 +01:00
public override PDU DispatchRequest(PDU pdu)
2019-03-11 08:57:19 +01:00
{
SnmpV2Message request = new SnmpV2Message();
request.snmpCommunity = CommunityString;
request.snmpPDU = pdu;
2019-03-12 00:54:39 +01:00
SnmpV2Message response = EnqueueRequest(request) as SnmpV2Message;
2019-03-11 08:57:19 +01:00
return response.snmpPDU;
}
}
}