diff --git a/Program.cs b/Program.cs
index aebf582..ca44504 100644
--- a/Program.cs
+++ b/Program.cs
@@ -20,6 +20,11 @@ using System.Diagnostics;
using ln.perfdb.storage;
using ln.logging;
using System.Security.Cryptography;
+using ln.snmp.asn1;
+using System.Linq;
+using ln.types;
+using System.Runtime.InteropServices;
+using ln.snmp.rfc1213;
namespace ln.skyscanner
{
@@ -43,6 +48,13 @@ namespace ln.skyscanner
public static void Main(string[] args)
{
+ //CIDR cidr = CIDR.Parse("255.255.255.255/28");
+ //Logging.Log(LogLevel.INFO, "{0} {1}",cidr,cidr.ToNetwork());
+
+
+ //return;
+
+
//PerfFile perfFile = new PerfFile("test.lnpv");
//perfFile.Open();
@@ -78,40 +90,53 @@ namespace ln.skyscanner
SNMPEngine.DEBUG = true;
SNMPEngine engine = new SNMPEngine();
- engine.Timeout = 4000;
+ engine.Timeout = 2000;
- SnmpV1Endpoint v1endpoint = new SnmpV1Endpoint(engine, new IPEndPoint(IPAddress.Parse("10.113.254.4"), 161), "ghE7wUmFPoPpkRno");
+ SnmpV1Endpoint v1endpoint = new SnmpV1Endpoint(engine, new IPEndPoint(IPAddress.Parse("10.75.1.10"), 161), "ByFR4oW98hap");
SnmpV2Endpoint v2endpoint = new SnmpV2Endpoint(engine, new IPEndPoint(IPAddress.Parse("10.113.254.4"), 161), "ghE7wUmFPoPpkRno");
- USMEndpoint v3endpoint = new USMEndpoint(engine, new IPEndPoint(IPAddress.Parse("10.255.3.41"), 161));
+ USMEndpoint v3endpoint = new USMEndpoint(engine, new IPEndPoint(IPAddress.Parse("10.10.10.1"), 161));
v3endpoint.AuthMethod = SnmpV3AuthMethod.SHA;
v3endpoint.AuthKeyPhrase = "qVy3hnZJ2fov";
//v3endpoint.AuthKeyPhrase = "maplesyrup";
v3endpoint.Username = "skytron";
+
+
SnmpEndpoint intf = v3endpoint;
- Stopwatch stopWatch = Stopwatch.StartNew();
- Sequence[][] ifTable = intf.snmpWalk(new String[] {
- "1.3.6.1.2.1.2.2.1.2",
- "1.3.6.1.2.1.2.2.1.10",
- "1.3.6.1.2.1.2.2.1.16",
- "1.3.6.1.2.1.2.2.1.14",
- "1.3.6.1.2.1.2.2.1.20"
- });
- stopWatch.Stop();
- Console.WriteLine("Time for table walk: {0}ms", stopWatch.ElapsedMilliseconds);
+ RFC1213.Interface[] interfaces = RFC1213.GetInterfaces(v3endpoint);
- foreach (Sequence[] sequences in ifTable)
+ foreach (RFC1213.Interface netIf in interfaces)
{
- foreach (Sequence sequence in sequences)
- {
- Console.Write("{0}\t", sequence?.Items[1].Value);
- }
- Console.WriteLine("");
+ Logging.Log(LogLevel.INFO, "Interface: {0}",netIf);
}
+
+
+ //Stopwatch stopWatch = Stopwatch.StartNew();
+ //Sequence[][] ifTable = intf.snmpWalk(new String[] {
+ // "1.3.6.1.2.1.2.2.1.2",
+ // "1.3.6.1.2.1.2.2.1.10",
+ // "1.3.6.1.2.1.2.2.1.16",
+ // "1.3.6.1.2.1.2.2.1.14",
+ // "1.3.6.1.2.1.2.2.1.20"
+ // });
+ //stopWatch.Stop();
+
+ //Console.WriteLine("Time for table walk: {0}ms", stopWatch.ElapsedMilliseconds);
+
+ //foreach (Sequence[] sequences in ifTable)
+ //{
+ // Console.Write("{0,24} ", sequences);
+ // foreach (Sequence sequence in sequences)
+ // {
+ // Console.Write("{0}\t", sequence?.Items?[1].Value);
+ // }
+ // Console.WriteLine("");
+ //}
+
engine.Close();
//NodeIdentifier identifier = new NodeIdentifier(IPAddress.Parse("10.10.10.1"));
@@ -123,5 +148,78 @@ namespace ln.skyscanner
//}
}
+
+ public static void TestAuthKey(String filename,USMEndpoint v3endpoint)
+ {
+ FileStream fileStream = new FileStream(filename, FileMode.Open);
+ byte[] source = new byte[fileStream.Length];
+
+ int nread = fileStream.Read(source, 0, source.Length);
+
+ fileStream.Close();
+ fileStream.Dispose();
+
+ ASN1Value asn = new ASN1Value(source);
+ USMMessage usm = new USMMessage(asn);
+
+ byte[] repro1 = asn.AsByteArray;
+ byte[] repro2 = ((ASN1Value)usm).AsByteArray;
+
+ Logging.Log(LogLevel.DEBUG, "Source: {0}", BitConverter.ToString(source));
+ Logging.Log(LogLevel.DEBUG, "Repro1: {0}", BitConverter.ToString(repro1));
+ Logging.Log(LogLevel.DEBUG, "Repro2: {0}", BitConverter.ToString(repro2));
+
+ if (!source.SequenceEqual(repro1))
+ Logging.Log(LogLevel.ERROR, "Repro1 does not match!");
+ else
+ Logging.Log(LogLevel.ERROR, "Repro1 matches!");
+
+ if (!source.SequenceEqual(repro2))
+ Logging.Log(LogLevel.ERROR, "Repro2 does not match!");
+ else
+ Logging.Log(LogLevel.ERROR, "Repro2 matches!");
+
+ if (!repro1.SequenceEqual(repro2))
+ Logging.Log(LogLevel.ERROR, "Repro1 != Repro2!");
+ else
+ Logging.Log(LogLevel.ERROR, "Repro1/2 match!");
+
+
+
+ usm.Dump();
+ usm.SecurityParameters.Dump();
+
+ byte[] auth1 = usm.SecurityParameters.msgAuthenticationParameters.Bytes;
+
+ usm.SecurityParameters.msgAuthenticationParameters.Bytes = new byte[12];
+
+ Logging.Log(LogLevel.DEBUG, "Source: {0}", BitConverter.ToString(source));
+
+ v3endpoint.RemoteEngineID = usm.SecurityParameters.msgAuthoritativeEngineID;
+ v3endpoint.CacheAuthoritativeEngineTime = usm.SecurityParameters.msgAuthoritativeEngineTime;
+ v3endpoint.CacheAuthoritativeEngineBoots = usm.SecurityParameters.msgAuthoritativeEngineBoots;
+
+ v3endpoint.LocalizeKeys();
+
+ v3endpoint.AuthenticateMessage(usm);
+
+ byte[] auth2 = usm.SecurityParameters.msgAuthenticationParameters.Bytes;
+
+ Logging.Log(LogLevel.DEBUG, "Authenticated: {0}", BitConverter.ToString(((ASN1Value)usm).AsByteArray));
+
+ Logging.Log(LogLevel.DEBUG, "Original Auth Token: {0}", BitConverter.ToString(auth1));
+ Logging.Log(LogLevel.DEBUG, "Calculated Auth Token: {0}", BitConverter.ToString(auth2));
+
+ if (auth1.SequenceEqual(auth2))
+ {
+ Logging.Log(LogLevel.DEBUG, "MATCH");
+ }
+ else
+ {
+ Logging.Log(LogLevel.DEBUG, "NO MATCH");
+ }
+
+ }
+
}
}
diff --git a/ln.skyscanner.csproj b/ln.skyscanner.csproj
index dba5a58..7809d13 100644
--- a/ln.skyscanner.csproj
+++ b/ln.skyscanner.csproj
@@ -63,6 +63,10 @@
{D471A566-9FB6-41B2-A777-3C32874ECD0E}
ln.logging
+
+ {8D9AB9A5-E513-4BA7-A450-534F6456BF28}
+ ln.types
+
\ No newline at end of file