diff --git a/SNMPEngine.cs b/SNMPEngine.cs index d481ea7..0b8fc55 100644 --- a/SNMPEngine.cs +++ b/SNMPEngine.cs @@ -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; diff --git a/endpoint/USMEndpoint.cs b/endpoint/USMEndpoint.cs index c46e35a..a162363 100644 --- a/endpoint/USMEndpoint.cs +++ b/endpoint/USMEndpoint.cs @@ -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(); diff --git a/ln.snmp.csproj b/ln.snmp.csproj index 64fbb35..7319c0f 100644 --- a/ln.snmp.csproj +++ b/ln.snmp.csproj @@ -72,6 +72,10 @@ {D471A566-9FB6-41B2-A777-3C32874ECD0E} ln.logging + + {8D9AB9A5-E513-4BA7-A450-534F6456BF28} + ln.types + \ No newline at end of file diff --git a/rfc1213/RFC1213.cs b/rfc1213/RFC1213.cs index e639899..0294355 100644 --- a/rfc1213/RFC1213.cs +++ b/rfc1213/RFC1213.cs @@ -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 _IPAddresses = new List(); + private List _IPAddresses = new List(); public Interface() { } - public void AddIPAddress(System.Net.IPAddress ip) + public void AddIPAddress(CIDR ip) { _IPAddresses.Add(ip); }