ln.snmp/endpoint/SnmpV1Endpoint.cs

42 lines
1.3 KiB
C#
Raw Permalink 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-11 15:07:34 +01:00
public class SnmpV1Endpoint : SnmpEndpoint
2019-03-11 08:57:19 +01:00
{
public OctetString CommunityString { get; set; }
public override SnmpVersion SnmpVersion => SnmpVersion.V1;
public SnmpV1Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint)
: base(snmpEngine, remoteEndpoint)
{
CommunityString = "public";
}
public SnmpV1Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint, OctetString communityString)
: base(snmpEngine, remoteEndpoint)
{
CommunityString = communityString;
}
public SnmpV1Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint, String communityString)
: base(snmpEngine, remoteEndpoint)
{
CommunityString = new OctetString(communityString);
}
2019-03-12 00:54:39 +01:00
public override PDU DispatchRequest(PDU pdu)
2019-03-11 08:57:19 +01:00
{
SnmpV1Message request = new SnmpV1Message();
request.snmpCommunity = CommunityString;
request.snmpPDU = pdu;
2019-03-12 00:54:39 +01:00
SnmpV1Message response = EnqueueRequest(request) as SnmpV1Message;
2019-03-11 08:57:19 +01:00
return response.snmpPDU;
}
}
}