Skip to content

Commit fd9ecbd

Browse files
committed
SNMP-fetch now retrieves MAC addresses
1 parent 82f0475 commit fd9ecbd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Protest/Tasks/Fetch.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,19 @@ public static ConcurrentDictionary<string, string[]> SingleDevice(string target,
385385
data.TryAdd("snmp profile", new string[] { profile.guid.ToString(), "SNMP", string.Empty });
386386
}
387387

388+
IList<Variable> macAddressResult = Protocols.Snmp.Polling.SnmpQuery(ipAddress, profile, [Protocols.Snmp.Oid.INT_MAC], Polling.SnmpOperation.Walk);
389+
List<string> macAddresses = macAddressResult
390+
.Select(o => o.Data.ToBytes())
391+
.Where(o => o.Length == 8)
392+
.Where(o => o[2]>0 && o[3]>0 && o[4]>0 && o[4]>0 && o[6]>0 && o[7]>0)
393+
.Select(o => BitConverter.ToString(o, 2).Replace('-', ':'))
394+
.Distinct()
395+
.ToList();
396+
397+
if (macAddresses.Count > 0) {
398+
data.TryAdd("mac address", new string[] { String.Join("; ", macAddresses), "SNMP", string.Empty });
399+
}
400+
388401
if (!data.ContainsKey("type")) {
389402
IList<Variable> dot1dBaseBridgeAddress = Protocols.Snmp.Polling.SnmpQuery(ipAddress, profile, ["1.3.6.1.2.1.17.1.1.0"], Polling.SnmpOperation.Get);
390403
if (dot1dBaseBridgeAddress?.Count > 0) {

0 commit comments

Comments
 (0)