RFC1213, USMEndpoint fixes
parent
59133a9c8f
commit
d513a244d7
|
@ -64,7 +64,7 @@ namespace ln.snmp
|
||||||
IPEndPoint remoteEndpoint = null;
|
IPEndPoint remoteEndpoint = null;
|
||||||
byte[] datagram = LocalEndpoint.Receive(ref remoteEndpoint);
|
byte[] datagram = LocalEndpoint.Receive(ref remoteEndpoint);
|
||||||
|
|
||||||
Logging.Log(LogLevel.DEBUG,"SNMPClient: Received: {0}", BitConverter.ToString(datagram));
|
Logging.Log(LogLevel.DEBUG,"SNMPClient: Received: {0}", BitConverter.ToString(datagram));
|
||||||
|
|
||||||
ASN1Value asn = new ASN1Value(datagram);
|
ASN1Value asn = new ASN1Value(datagram);
|
||||||
SnmpMessage snmpMessage = asn;
|
SnmpMessage snmpMessage = asn;
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace ln.snmp.endpoint
|
||||||
|
|
||||||
public override void DispatchReceived(SnmpMessage message)
|
public override void DispatchReceived(SnmpMessage message)
|
||||||
{
|
{
|
||||||
Logging.Log(LogLevel.DEBUG, "Received PDU: {0}",message.snmpPDU);
|
Logging.Log(LogLevel.DEBUGDETAIL, "Received PDU: {0}",message.snmpPDU);
|
||||||
|
|
||||||
USMMessage usm = message as USMMessage;
|
USMMessage usm = message as USMMessage;
|
||||||
|
|
||||||
|
@ -210,20 +210,20 @@ namespace ln.snmp.endpoint
|
||||||
byte[] mac = hash.ComputeHash(inter2);
|
byte[] mac = hash.ComputeHash(inter2);
|
||||||
|
|
||||||
|
|
||||||
Logging.Log(LogLevel.DEBUG, "Authentication of {0}", BitConverter.ToString(wholeMsg));
|
Logging.Log(LogLevel.DEBUGDETAIL, "Authentication of {0}", BitConverter.ToString(wholeMsg));
|
||||||
Logging.Log(LogLevel.DEBUG, "AuthKey: {0}", BitConverter.ToString(AuthKey));
|
Logging.Log(LogLevel.DEBUGDETAIL, "AuthKey: {0}", BitConverter.ToString(AuthKey));
|
||||||
Logging.Log(LogLevel.DEBUG, "LocalAuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
Logging.Log(LogLevel.DEBUGDETAIL, "LocalAuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
||||||
Logging.Log(LogLevel.DEBUG, "Extended AuthKey: {0}", BitConverter.ToString(extendedAuthKey));
|
Logging.Log(LogLevel.DEBUGDETAIL, "Extended AuthKey: {0}", BitConverter.ToString(extendedAuthKey));
|
||||||
Logging.Log(LogLevel.DEBUG, "");
|
Logging.Log(LogLevel.DEBUGDETAIL, "");
|
||||||
Logging.Log(LogLevel.DEBUG, "K1: {0}", BitConverter.ToString(K1));
|
Logging.Log(LogLevel.DEBUGDETAIL, "K1: {0}", BitConverter.ToString(K1));
|
||||||
Logging.Log(LogLevel.DEBUG, "K2: {0}", BitConverter.ToString(K2));
|
Logging.Log(LogLevel.DEBUGDETAIL, "K2: {0}", BitConverter.ToString(K2));
|
||||||
Logging.Log(LogLevel.DEBUG, "");
|
Logging.Log(LogLevel.DEBUGDETAIL, "");
|
||||||
Logging.Log(LogLevel.DEBUG, "AuthToken: {0}", BitConverter.ToString(mac.Take(12).ToArray()));
|
Logging.Log(LogLevel.DEBUGDETAIL, "AuthToken: {0}", BitConverter.ToString(mac.Take(12).ToArray()));
|
||||||
|
|
||||||
message.SecurityParameters.msgAuthenticationParameters.Bytes = mac.Take(12).ToArray();
|
message.SecurityParameters.msgAuthenticationParameters.Bytes = mac.Take(12).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging.Log(LogLevel.DEBUG, "Authenticating Message: {0}",BitConverter.ToString(wholeMsg));
|
Logging.Log(LogLevel.DEBUGDETAIL, "Authenticating Message: {0}",BitConverter.ToString(wholeMsg));
|
||||||
Logging.Log(LogLevel.DEBUG, "Authenticated Message: {0}", BitConverter.ToString(((ASN1Value)message).AsByteArray));
|
Logging.Log(LogLevel.DEBUG, "Authenticated Message: {0}", BitConverter.ToString(((ASN1Value)message).AsByteArray));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -273,7 +273,7 @@ namespace ln.snmp.endpoint
|
||||||
|
|
||||||
LocalAuthKey = hash.Hash;
|
LocalAuthKey = hash.Hash;
|
||||||
|
|
||||||
Logging.Log(LogLevel.DEBUG, "Derived LocalAuthKey from AuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
Logging.Log(LogLevel.DEBUGDETAIL, "Derived LocalAuthKey from AuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ namespace ln.snmp.endpoint
|
||||||
CreateAuthHashAlgorithm()
|
CreateAuthHashAlgorithm()
|
||||||
);
|
);
|
||||||
|
|
||||||
Logging.Log(LogLevel.DEBUG, "Derived AuthKey from Phrase: {0}",BitConverter.ToString(AuthKey));
|
Logging.Log(LogLevel.DEBUGDETAIL, "Derived AuthKey from Phrase: {0}",BitConverter.ToString(AuthKey));
|
||||||
|
|
||||||
if (RemoteEngineID != null)
|
if (RemoteEngineID != null)
|
||||||
LocalizeKeys();
|
LocalizeKeys();
|
||||||
|
|
|
@ -72,6 +72,10 @@
|
||||||
<Project>{D471A566-9FB6-41B2-A777-3C32874ECD0E}</Project>
|
<Project>{D471A566-9FB6-41B2-A777-3C32874ECD0E}</Project>
|
||||||
<Name>ln.logging</Name>
|
<Name>ln.logging</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\ln.types\ln.types.csproj">
|
||||||
|
<Project>{8D9AB9A5-E513-4BA7-A450-534F6456BF28}</Project>
|
||||||
|
<Name>ln.types</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||||
using ln.snmp.endpoint;
|
using ln.snmp.endpoint;
|
||||||
using ln.snmp.types;
|
using ln.snmp.types;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using ln.types;
|
||||||
namespace ln.snmp.rfc1213
|
namespace ln.snmp.rfc1213
|
||||||
{
|
{
|
||||||
public static class RFC1213
|
public static class RFC1213
|
||||||
|
@ -41,17 +42,19 @@ namespace ln.snmp.rfc1213
|
||||||
Sequence[][] ipTable = endpoint.snmpWalk(new String[]
|
Sequence[][] ipTable = endpoint.snmpWalk(new String[]
|
||||||
{
|
{
|
||||||
"1.3.6.1.2.1.4.20.1.1",
|
"1.3.6.1.2.1.4.20.1.1",
|
||||||
"1.3.6.1.2.1.4.20.1.2"
|
"1.3.6.1.2.1.4.20.1.2",
|
||||||
|
"1.3.6.1.2.1.4.20.1.3"
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (Sequence[] row in ipTable)
|
foreach (Sequence[] row in ipTable)
|
||||||
{
|
{
|
||||||
IPAddress ip = (row[0].Items[1] as IPAddr).IP;
|
IPAddress ip = (row[0].Items[1] as IPAddr).IP;
|
||||||
int ifIndex = (int)(row[1].Items[1] as Integer).LongValue;
|
int ifIndex = (int)(row[1].Items[1] as Integer).LongValue;
|
||||||
|
IPAddress mask = (row[2].Items[1] as IPAddr).IP;
|
||||||
|
|
||||||
if (interfaces.ContainsKey(ifIndex))
|
if (interfaces.ContainsKey(ifIndex))
|
||||||
{
|
{
|
||||||
interfaces[ifIndex].AddIPAddress(ip);
|
interfaces[ifIndex].AddIPAddress(new CIDR(ip,mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,17 +66,17 @@ namespace ln.snmp.rfc1213
|
||||||
public class Interface
|
public class Interface
|
||||||
{
|
{
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public System.Net.IPAddress[] IPAddresses => _IPAddresses.ToArray();
|
public CIDR[] IPAddresses => _IPAddresses.ToArray();
|
||||||
|
|
||||||
|
|
||||||
private List<System.Net.IPAddress> _IPAddresses = new List<System.Net.IPAddress>();
|
private List<CIDR> _IPAddresses = new List<CIDR>();
|
||||||
|
|
||||||
|
|
||||||
public Interface()
|
public Interface()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddIPAddress(System.Net.IPAddress ip)
|
public void AddIPAddress(CIDR ip)
|
||||||
{
|
{
|
||||||
_IPAddresses.Add(ip);
|
_IPAddresses.Add(ip);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue