关于C#下基于SNMPSHARPNET的SNMP编程中IPV6的问题。
asp.net吧
全部回复
仅看楼主
level 1
ProteinTZ 楼主
在网上找到了一些获取主机信息的代码:
protected void Button1_Click(object sender, EventArgs e)
{
string public1 = TextBox1.Text.Trim().ToString();
string IP = TextBox2.Text.Trim().ToString();
// SNMP community name
OctetString community = new OctetString(public1);
AgentParameters param = new AgentParameters(community);
param.Version = SnmpVersion.Ver1;
IpAddress agent = new IpAddress(IP);
// Construct target
UdpTarget target = new UdpTarget((IPAddress)agent,161, 2000, 2);
// Pdu class used for all requests
Pdu pdu = new Pdu(PduType.Get);
pdu.VbList.Add("1.3.6.1.2.1.1.1.0"); //sysDescr
pdu.VbList.Add("1.3.6.1.2.1.1.2.0"); //sysObjectID
pdu.VbList.Add("1.3.6.1.2.1.1.3.0"); //sysUpTime
pdu.VbList.Add("1.3.6.1.2.1.1.4.0"); //sysContact
pdu.VbList.Add("1.3.6.1.2.1.1.5.0"); //sysName
// Make SNMP request
SnmpV1Packet result = (SnmpV1Packet)target.Request(pdu, param);
当在TextBox2获取的IP地址为IPV4地址时,可以获取到信息。而输入IPV6的地址会出现下面的情况:
2015年04月29日 07点04分 1
level 1
ProteinTZ 楼主
可以看到堆栈跟踪里
SnmpSharpNet.UdpTransport.Request(IPAddress peer, Int32 port, Byte[] buffer, Int32 bufferLength, Int32 timeout, Int32 retries)
这条。
例如我输入的IPV6地址为fe80::357b:bacf:e6b4:5910,而UDPTRANSPORT这个元数据返回的是INT32的数据类型,是否是元数据中无法解析IPV6的地址?如果是改什么修改?
2015年04月29日 07点04分 2
level 1
ProteinTZ 楼主
看来贴吧都被广告占领了 不适合技术讨论了
2015年04月29日 07点04分 3
level 1
哥们儿 你的问题解决了吗?应该是ipv6地址没有解析。
2015年06月02日 07点06分 4
对的,所以要添加一个IPv6的类和IPv4Address类似
2015年06月19日 04点06分
1