$NetBSD: patch-ab,v 1.2 2003/04/07 15:01:22 bouyer Exp $ --- sdig.c.orig Tue Jul 23 05:03:20 2002 +++ sdig.c Thu Apr 3 12:22:07 2003 @@ -25,16 +25,21 @@ #include #include #include -#include -#include +#include #include +#include +#include +#include +#include +#include + #include "sdig.h" #include "common.h" #include "snmpget.h" #include "version.h" -#define CONFIGFILE "/etc/sdig.conf" +#define CONFIGFILE PREFIX "/etc/sdig.conf" stype *firstsw = NULL; rtype *firstrt = NULL; @@ -114,7 +119,7 @@ /* build the OID for the mapping of MAC addresses to port numbers */ - snprintf(query, sizeof(query), "17.4.3.1.2.%u.%u.%u.%u.%u.%u", + snprintf(query, sizeof(query), ".1.3.6.1.2.1.17.4.3.1.2.%u.%u.%u.%u.%u.%u", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); debug(5, "findport: query is [%s]\n", query); @@ -355,6 +360,7 @@ snprintf(macfind, sizeof(macfind), "%02x %02x %02x", inmac[0], inmac[1], inmac[2]); + debug("looking for MAC prefix [%s] in %s\n", macfind, mactable); while (fgets(buf, sizeof(buf), macdb)) { buf[strlen(buf) - 1] = '\0'; @@ -494,14 +500,13 @@ /* first get the switch's ifnum for the port */ - snprintf(query, sizeof(query), "17.1.4.1.2.%ld", port); + snprintf(query, sizeof(query), ".1.3.6.1.2.1.17.1.4.1.2.%ld", port); ifnum = snmpget_int(sw->ip, sw->pw, query); if (ifnum == -1) return; - snprintf(query, sizeof(query), "interfaces.ifTable.ifEntry.ifDescr.%ld", - ifnum); + snprintf(query, sizeof(query), ".1.3.6.1.2.1.2.2.1.2.%ld", ifnum); ifdescr = snmpget_str(sw->ip, sw->pw, query); @@ -728,6 +733,7 @@ { char *prog, *query, *conf = NULL, *mac = NULL; int i; + char macaddr[6]; printf("Switch Digger %s - http://www.exploits.org/sdig/\n\n", VERSION); @@ -791,7 +797,10 @@ mac, query); checkmac(mac); - switchscan(query, mac); + macaddr[0] = strtoul(strtok(mac, ":"), NULL, 16); + for (i = 1; i < 6; i++) + macaddr[i] = strtoul(strtok(NULL, ":"), NULL, 16); + switchscan(query, macaddr); /* NOTREACHED */ }