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 SnmpV1Endpoint : SNMPInterface
|
|||
|
{
|
|||
|
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 snmpRequest(PDU pdu)
|
|||
|
{
|
|||
|
SnmpV1Message request = new SnmpV1Message();
|
|||
|
request.MessageID = SNMPEngine.NextMessageID;
|
|||
|
request.snmpCommunity = CommunityString;
|
|||
|
request.snmpPDU = pdu;
|
|||
|
|
|||
|
SnmpV1Message response = SNMPEngine.SNMPRequest(RemoteEndpoint, request, SNMPEngine.Timeout) as SnmpV1Message;
|
|||
|
return response.snmpPDU;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|