RFC1213, USMEndpoint fixes
parent
59133a9c8f
commit
d513a244d7
|
@ -64,7 +64,7 @@ namespace ln.snmp
|
|||
IPEndPoint remoteEndpoint = null;
|
||||
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);
|
||||
SnmpMessage snmpMessage = asn;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace ln.snmp.endpoint
|
|||
|
||||
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;
|
||||
|
||||
|
@ -210,20 +210,20 @@ namespace ln.snmp.endpoint
|
|||
byte[] mac = hash.ComputeHash(inter2);
|
||||
|
||||
|
||||
Logging.Log(LogLevel.DEBUG, "Authentication of {0}", BitConverter.ToString(wholeMsg));
|
||||
Logging.Log(LogLevel.DEBUG, "AuthKey: {0}", BitConverter.ToString(AuthKey));
|
||||
Logging.Log(LogLevel.DEBUG, "LocalAuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
||||
Logging.Log(LogLevel.DEBUG, "Extended AuthKey: {0}", BitConverter.ToString(extendedAuthKey));
|
||||
Logging.Log(LogLevel.DEBUG, "");
|
||||
Logging.Log(LogLevel.DEBUG, "K1: {0}", BitConverter.ToString(K1));
|
||||
Logging.Log(LogLevel.DEBUG, "K2: {0}", BitConverter.ToString(K2));
|
||||
Logging.Log(LogLevel.DEBUG, "");
|
||||
Logging.Log(LogLevel.DEBUG, "AuthToken: {0}", BitConverter.ToString(mac.Take(12).ToArray()));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "Authentication of {0}", BitConverter.ToString(wholeMsg));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "AuthKey: {0}", BitConverter.ToString(AuthKey));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "LocalAuthKey: {0}", BitConverter.ToString(LocalAuthKey));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "Extended AuthKey: {0}", BitConverter.ToString(extendedAuthKey));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "");
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "K1: {0}", BitConverter.ToString(K1));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "K2: {0}", BitConverter.ToString(K2));
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "");
|
||||
Logging.Log(LogLevel.DEBUGDETAIL, "AuthToken: {0}", BitConverter.ToString(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));
|
||||
|
||||
return true;
|
||||
|
@ -273,7 +273,7 @@ namespace ln.snmp.endpoint
|
|||
|
||||
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()
|
||||
);
|
||||
|
||||
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)
|
||||
LocalizeKeys();
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
<Project>{D471A566-9FB6-41B2-A777-3C32874ECD0E}</Project>
|
||||
<Name>ln.logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ln.types\ln.types.csproj">
|
||||
<Project>{8D9AB9A5-E513-4BA7-A450-534F6456BF28}</Project>
|
||||
<Name>ln.types</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||
using ln.snmp.endpoint;
|
||||
using ln.snmp.types;
|
||||
using System.Linq;
|
||||
using ln.types;
|
||||
namespace ln.snmp.rfc1213
|
||||
{
|
||||
public static class RFC1213
|
||||
|
@ -41,17 +42,19 @@ namespace ln.snmp.rfc1213
|
|||
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.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)
|
||||
{
|
||||
IPAddress ip = (row[0].Items[1] as IPAddr).IP;
|
||||
int ifIndex = (int)(row[1].Items[1] as Integer).LongValue;
|
||||
IPAddress mask = (row[2].Items[1] as IPAddr).IP;
|
||||
|
||||
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 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 void AddIPAddress(System.Net.IPAddress ip)
|
||||
public void AddIPAddress(CIDR ip)
|
||||
{
|
||||
_IPAddresses.Add(ip);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue