42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using ln.snmp.types;
|
|
using System.Net;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ln.snmp.endpoint
|
|
{
|
|
public class SnmpV1Endpoint : SnmpEndpoint
|
|
{
|
|
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);
|
|
}
|
|
|
|
public override PDU DispatchRequest(PDU pdu)
|
|
{
|
|
SnmpV1Message request = new SnmpV1Message();
|
|
request.snmpCommunity = CommunityString;
|
|
request.snmpPDU = pdu;
|
|
|
|
SnmpV1Message response = EnqueueRequest(request) as SnmpV1Message;
|
|
return response.snmpPDU;
|
|
}
|
|
|
|
}
|
|
}
|