43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System;
|
|
using ln.snmp.types;
|
|
using System.Net;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ln.snmp.channel
|
|
{
|
|
public class SnmpV2Endpoint : SNMPInterface
|
|
{
|
|
public OctetString CommunityString { get; set; }
|
|
|
|
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)
|
|
: base(snmpEngine, remoteEndpoint)
|
|
{
|
|
CommunityString = communityString;
|
|
}
|
|
public SnmpV2Endpoint(SNMPEngine snmpEngine, IPEndPoint remoteEndpoint, String communityString)
|
|
: base(snmpEngine, remoteEndpoint)
|
|
{
|
|
CommunityString = new OctetString(communityString);
|
|
}
|
|
|
|
public override PDU snmpRequest(PDU pdu)
|
|
{
|
|
SnmpV2Message request = new SnmpV2Message();
|
|
request.MessageID = SNMPEngine.NextMessageID;
|
|
request.snmpCommunity = CommunityString;
|
|
request.snmpPDU = pdu;
|
|
|
|
SnmpV2Message response = SNMPEngine.SNMPRequest(RemoteEndpoint, request, SNMPEngine.Timeout) as SnmpV2Message;
|
|
return response.snmpPDU;
|
|
}
|
|
|
|
}
|
|
}
|