diff options
author | bouyer <bouyer> | 2003-04-07 15:01:22 +0000 |
---|---|---|
committer | bouyer <bouyer> | 2003-04-07 15:01:22 +0000 |
commit | a804ca0397a6af4ef73f11bdc01fdd02e3c57e47 (patch) | |
tree | d402b08fe1c8d50da737898f64d1684c2d653afe /net/sdig | |
parent | bb14f01034a859b5b3e22978eb347fc1c3792811 (diff) | |
download | pkgsrc-a804ca0397a6af4ef73f11bdc01fdd02e3c57e47.tar.gz |
Update to 0.30. Major changes:
- rewrite of large parts of code. Now use net-snmp libraries instead of
calling an external program
- There are now a sdig(8) and sdig.conf(5) man pages
- the debug code now has multiple levels so using -d once
doesn't give you all the really messy unimportant stuff. To see
that, use several - the really ugly ones are hiding down at 5 and 6.
With some snmp fixes by myself, I can now successfully querry my 3com and
alliedtelesyn switches.
Diffstat (limited to 'net/sdig')
-rw-r--r-- | net/sdig/Makefile | 10 | ||||
-rw-r--r-- | net/sdig/PLIST | 4 | ||||
-rw-r--r-- | net/sdig/distinfo | 12 | ||||
-rw-r--r-- | net/sdig/patches/patch-aa | 34 | ||||
-rw-r--r-- | net/sdig/patches/patch-ab | 144 | ||||
-rw-r--r-- | net/sdig/patches/patch-ac | 20 |
6 files changed, 102 insertions, 122 deletions
diff --git a/net/sdig/Makefile b/net/sdig/Makefile index 53dcbc18a91..27cdbf8a196 100644 --- a/net/sdig/Makefile +++ b/net/sdig/Makefile @@ -1,7 +1,6 @@ -# $NetBSD: Makefile,v 1.3 2002/04/20 19:02:03 fredb Exp $ +# $NetBSD: Makefile,v 1.4 2003/04/07 15:01:22 bouyer Exp $ -DISTNAME= sdig-0.11 -PKGREVISION= 1 +DISTNAME= sdig-0.30 CATEGORIES= net MASTER_SITES= http://www.exploits.org/sdig/ DISTFILES= ${DISTNAME}${EXTRACT_SUFX} mactable.gz @@ -10,7 +9,7 @@ MAINTAINER= packages@netbsd.org HOMEPAGE= http://www.exploits.org/sdig/ COMMENT= Switch Digger finds port assignment for hosts on a switched Ethernet -DEPENDS= ucd-snmp-4.2.4*:../../net/ucd-snmp +USE_BUILDLINK2= yes EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} @@ -24,7 +23,10 @@ post-build: my-post-build post-install: ${INSTALL_DATA} ${WRKDIR}/sdig.conf ${PREFIX}/share/examples/ ${INSTALL_DATA} ${WRKDIR}/mactable ${PREFIX}/share/misc/ + ${INSTALL_DATA} ${WRKSRC}/sdig.8 ${PREFIX}/man/man8/ + ${INSTALL_DATA} ${WRKSRC}/sdig.conf.5 ${PREFIX}/man/man5/ +.include "../../net/net-snmp/buildlink2.mk" .include "../../mk/bsd.pkg.mk" # Note: this depends on having a MESSAGE file, which we do. diff --git a/net/sdig/PLIST b/net/sdig/PLIST index 896625bd5c5..c3ecb0fd02b 100644 --- a/net/sdig/PLIST +++ b/net/sdig/PLIST @@ -1,6 +1,8 @@ -@comment $NetBSD: PLIST,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +@comment $NetBSD: PLIST,v 1.2 2003/04/07 15:01:22 bouyer Exp $ bin/sdig bin/nbname share/doc/sdig.README share/examples/sdig.conf +man/man5/sdig.conf.5 +man/man8/sdig.8 share/misc/mactable diff --git a/net/sdig/distinfo b/net/sdig/distinfo index 0b8905a9884..a8b1f8ffca9 100644 --- a/net/sdig/distinfo +++ b/net/sdig/distinfo @@ -1,9 +1,9 @@ -$NetBSD: distinfo,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +$NetBSD: distinfo,v 1.2 2003/04/07 15:01:22 bouyer Exp $ -SHA1 (sdig-0.11.tar.gz) = 5e21c28a22c8ce4106b38b4490a6b10e870d06e2 -Size (sdig-0.11.tar.gz) = 21546 bytes +SHA1 (sdig-0.30.tar.gz) = 5af0f6adbadee33b91a45cffcfd13587ad5fa3a0 +Size (sdig-0.30.tar.gz) = 25301 bytes SHA1 (mactable.gz) = afe9c24c45c5472c9e78d2a8d72fcdc18d43563d Size (mactable.gz) = 36490 bytes -SHA1 (patch-aa) = 843620fd51fc2989713d14f652b8e39bd3018f4d -SHA1 (patch-ab) = d33b3547f0316232368900d776af106ea51b8500 -SHA1 (patch-ac) = d2c90173e3476976518b27526bd0de68e7317ae0 +SHA1 (patch-aa) = 88e2c8be232c2666eed66400b31bef59ff4eb8b2 +SHA1 (patch-ab) = 3b2d671d7d0ca66f8afe5c55bf075c6b62a9c95a +SHA1 (patch-ac) = 0e5304f2d774ae8932ba5694b511410d52314f85 diff --git a/net/sdig/patches/patch-aa b/net/sdig/patches/patch-aa index 2b44cdcbf7b..ab8af608807 100644 --- a/net/sdig/patches/patch-aa +++ b/net/sdig/patches/patch-aa @@ -1,28 +1,38 @@ -$NetBSD: patch-aa,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +$NetBSD: patch-aa,v 1.2 2003/04/07 15:01:22 bouyer Exp $ ---- Makefile.orig Fri May 18 14:52:00 2001 -+++ Makefile Sun Jan 6 18:34:14 2002 -@@ -1,22 +1,19 @@ +--- Makefile.orig Tue Jul 23 04:56:11 2002 ++++ Makefile Wed Apr 2 18:58:25 2003 +@@ -1,31 +1,27 @@ + # sdig/Makefile: non-autoconf hack, for now + # + -CC = gcc -CFLAGS = -O2 -Wall # -g -static --BINDIR = /usr/sbin -PROGS = sdig nbname swc +PREFIX ?= /usr/local -+CFLAGS = -g -O2 -Wall -DPREFIX="\"${PREFIX}\"" ++CFLAGS = -g -O2 -Wall -DPREFIX="\"${PREFIX}\"" +PROGS = sdig nbname # swc + # change this to whatever it takes to make these things link on your system + +-UCDSNMP_CFLAGS = -lsnmp +-OPENSSL_CFLAGS = -L/usr/local/ssl/lib -lcrypto ++UCDSNMP_CFLAGS = -L${PREFIX}/lib -Wl,-R${PREFIX}/lib -lsnmp ++OPENSSL_CFLAGS = -L${PREFIX}/lib -Wl,-R${PREFIX}/lib -lcrypto + all: $(PROGS) --sdig: sdig.c common.o +-sdig: sdig.c common.o snmpget.o +- $(CC) $(CFLAGS) -o sdig sdig.c common.o snmpget.o $(UCDSNMP_CFLAGS) $(OPENSSL_CFLAGS) ++sdig: sdig.o common.o snmpget.o ++ $(CC) $(LDFLAGS) -o $@ sdig.o common.o snmpget.o $(UCDSNMP_CFLAGS) $(OPENSSL_CFLAGS) + -swc: swc.c common.o -+sdig: sdig.o common.o -+ $(CC) $(LDFLAGS) -o $@ $@.o common.o -+ +#swc: swc.o common.o -+# $(CC) $(LDFLAGS) -o $@ $@.o common.o ++# $(CC) $(LDFLAGS) -o $@ swc.o common.o clean: - rm $(PROGS) *.o + rm -f $(PROGS) *.o install: all - cp sdig /usr/local/bin diff --git a/net/sdig/patches/patch-ab b/net/sdig/patches/patch-ab index 5dc213a04aa..a2b73800176 100644 --- a/net/sdig/patches/patch-ab +++ b/net/sdig/patches/patch-ab @@ -1,8 +1,8 @@ -$NetBSD: patch-ab,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +$NetBSD: patch-ab,v 1.2 2003/04/07 15:01:22 bouyer Exp $ ---- sdig.c.orig Fri May 18 15:02:55 2001 -+++ sdig.c Sun Jan 6 18:45:02 2002 -@@ -25,15 +25,19 @@ +--- sdig.c.orig Tue Jul 23 05:03:20 2002 ++++ sdig.c Thu Apr 3 12:22:07 2003 +@@ -25,16 +25,21 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -10,96 +10,74 @@ $NetBSD: patch-ab,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ -#include <netinet/in.h> +#include <sys/types.h> #include <sys/socket.h> -+#include <netinet/in.h> -+#include <arpa/inet.h> -+#include <netdb.h> -+#include <arpa/nameser.h> -+#include <resolv.h> ++#include <netinet/in.h> ++#include <arpa/inet.h> ++#include <netdb.h> ++#include <arpa/nameser.h> ++#include <resolv.h> ++ + #include "sdig.h" #include "common.h" + #include "snmpget.h" #include "version.h" - #define PPS 32 /* 32 ports per switch */ -#define CONFIGFILE "/etc/sdig.conf" +#define CONFIGFILE PREFIX "/etc/sdig.conf" - char *wins = NULL, *nbname = NULL, *nmblookup = NULL, - *snmpget = NULL, *mactable = NULL; -@@ -115,6 +119,7 @@ - char *findport (char *mac, char *swip, char *swpw) - { - char needle[64], oid[64], exec[256], *ptr, *ptr2, buf[256], *sp; -+ char sep = ':'; - char *tmp; - FILE *out; - int i; -@@ -125,13 +130,22 @@ - exit (1); - } + stype *firstsw = NULL; + rtype *firstrt = NULL; +@@ -114,7 +119,7 @@ -- snprintf (needle, sizeof(needle), "17.4.3.1.2"); -+ snprintf (needle, sizeof(needle), ".1.3.6.1.2.1.17.4.3.1.2"); - -- ptr = strdup(mac); -+ if (strncmp(mac, " Hex: ", 6) == 0) { -+ sep = ' '; -+ ptr = strdup(mac + 6); -+ debug("MAC ptr with sep = ' ' is [%s]\n", ptr); -+ } else { -+ ptr = strdup(mac); -+ debug("MAC ptr with sep = ':' is [%s]\n", ptr); -+ } - for (i = 0; i < 6; i++) { -- sp = strchr (ptr, ':'); -+ sp = strchr (ptr, sep); - if (sp) - *sp = '\0'; -+ else -+ break; - - val = strtoul (ptr, NULL, 16); - if (i == 5) -@@ -145,7 +159,7 @@ - - debug("needle is [%s]\n", needle); - -- snprintf (exec, sizeof(exec), "%s %s %s %s 2>/dev/null", snmpget, swip, swpw, needle); -+ snprintf (exec, sizeof(exec), "%s -On %s %s %s 2>/dev/null", snmpget, swip, swpw, needle); - - debug("popen: %s\n", exec); - out = popen (exec, "r"); -@@ -472,6 +486,7 @@ - { - FILE *macdb; - char buf[256], *mac, *tmp, *ptr, *cp, macfind[16]; -+ char sep = ':'; - int i, num[3]; - - macdb = fopen (mactable, "r"); -@@ -482,9 +497,16 @@ - - num[0] = num[1] = num[2] = 0; - -- ptr = mac = strdup(inmac); -+ if (strncmp(inmac, " Hex: ", 6) == 0) { -+ sep = ' '; -+ ptr = mac = strdup(inmac + 6); -+ debug("inMAC ptr with sep = ' ' is [%s]\n", ptr); -+ } else { -+ ptr = mac = strdup(inmac); -+ debug("inMAC ptr with sep = ':' is [%s]\n", ptr); -+ } - for (i = 0; i < 3; i++) { -- cp = strchr (ptr, ':'); -+ cp = strchr (ptr, sep); - - if (!cp) - continue; -@@ -498,6 +520,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", - num[0], num[1], num[2]); + 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 */ + } diff --git a/net/sdig/patches/patch-ac b/net/sdig/patches/patch-ac index a5380be2b65..1d13189c757 100644 --- a/net/sdig/patches/patch-ac +++ b/net/sdig/patches/patch-ac @@ -1,7 +1,7 @@ -$NetBSD: patch-ac,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +$NetBSD: patch-ac,v 1.2 2003/04/07 15:01:22 bouyer Exp $ ---- sdig.conf.orig Fri May 18 15:05:13 2001 -+++ sdig.conf Sun Jan 6 18:33:55 2002 +--- sdig.conf.orig Tue Jul 23 04:20:39 2002 ++++ sdig.conf Wed Apr 2 18:54:40 2003 @@ -49,12 +49,10 @@ # # Enter the pathname to the Samba nmblookup program. @@ -28,20 +28,8 @@ $NetBSD: patch-ac,v 1.1.1.1 2002/01/10 14:06:31 bouyer Exp $ +NBNAME ${PREFIX}/bin/nbname # --------------------------------------------------------------------------- - # SNMPGET <path to snmpget program> -@@ -76,10 +72,8 @@ - # Enter the pathname to the Net-SNMP snmpget program. - # - # This does all the dirty work for us, and therefore is required. --# --# It usually installs to /usr/local/bin, so this default is generally OK. - --SNMPGET /usr/local/bin/snmpget -+SNMPGET ${PREFIX}/bin/snmpget - - # --------------------------------------------------------------------------- # MACTABLE <path to MAC table file> -@@ -92,4 +86,4 @@ +@@ -81,4 +77,4 @@ # rarely changes. If you want to use this feature, get it from the # main web site: http://www.exploits.org/sdig/ |