master
Harald Wolff 2019-03-21 07:43:35 +01:00
parent 8e17a1bb6b
commit 0c1ea61a23
4 changed files with 20 additions and 6 deletions

View File

@ -23,6 +23,20 @@ namespace ln.snmp
{
public static bool DEBUG = false;
private static SNMPEngine __default = null;
public static SNMPEngine DefaultEngine
{
get
{
if (__default == null)
__default = new SNMPEngine();
return __default;
}
set => __default = value;
}
public UdpClient LocalEndpoint { get; private set; }
public int Timeout { get; set; } = 1000;

View File

@ -134,7 +134,7 @@ namespace ln.snmp
ObjectIdentifier oid = v.Items[0] as ObjectIdentifier;
if (OIDs[c].Contains(oid))
{
row[c] = new Sequence(new Variable[] { oid.IndexTo(OIDs[c]), v.Items[1] });
row[c] = new Sequence(new Variable[] { OIDs[c].IndexTo(oid), v.Items[1] });
inTree = true;
}
}
@ -174,7 +174,7 @@ namespace ln.snmp
ObjectIdentifier oid = ps.Items[0] as ObjectIdentifier;
if (objectIdentifier.Contains(oid))
{
results.Add(new Sequence(new Variable[] { oid.IndexTo(objectIdentifier), ps.Items[1] }));
results.Add(new Sequence(new Variable[] { objectIdentifier.IndexTo(oid), ps.Items[1] }));
}
else
return results;

View File

@ -20,7 +20,7 @@ namespace ln.snmp.rfc1213
public static class RFC1213
{
public static Interface[] GetInterfaces(SnmpEndpoint endpoint)
public static Interface[] GetInterfaces(SnmpInterface endpoint)
{
Dictionary<int,Interface> interfaces = new Dictionary<int,Interface>();
ObjectIdentifier baseOID = new ObjectIdentifier("1.3.6.1.2.1.2.2.1.2");

View File

@ -54,14 +54,14 @@ namespace ln.snmp.types
public ObjectIdentifier IndexTo(ObjectIdentifier b)
{
if (!b.Contains(this))
if (!Contains(b))
throw new FormatException("OID is not below base OID");
int[] me = OIDValue;
int[] you = b.OIDValue;
int[] result = new int[me.Length - you.Length];
Array.Copy(me, you.Length, result, 0, result.Length);
int[] result = new int[you.Length - me.Length];
Array.Copy(you, me.Length, result, 0, result.Length);
return new ObjectIdentifier(result);
}