Stuart Henderson <st...@openbsd.org> writes: > On 2015/12/06 09:11, Antoine Jacoutot wrote: >> * net/ifstat >> * net/libdnet >> * net/nmap >> * net/ocserv >> * security/aircrack-ng > > From my test build: > > None of the above actually need things from if_var.h, they're ok with the > whole file wrapped in ifdef kernel. > >> * devel/libgtop2 > > mpi's already taking care of libgtop2
>> * security/antisniff Here's a diff that removes the need to look at if_var.h - use getifaddrs(3) instead; the diff is a bit unreadable, but the resulting intpr() function isn't. Untested, is antisniff still relevant these days? Index: Makefile =================================================================== RCS file: /cvs/ports/security/antisniff/Makefile,v retrieving revision 1.25 diff -u -p -r1.25 Makefile --- Makefile 30 Aug 2014 21:54:08 -0000 1.25 +++ Makefile 7 Dec 2015 12:11:10 -0000 @@ -3,6 +3,7 @@ COMMENT= promiscuous mode interface detector PKGNAME= antisniff-1.1.2 +REVISION= 0 CATEGORIES= security DISTNAME= anti_sniff_researchv1-1-2 Index: patches/patch-bpf_getetheraddr_c =================================================================== RCS file: patches/patch-bpf_getetheraddr_c diff -N patches/patch-bpf_getetheraddr_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-bpf_getetheraddr_c 7 Dec 2015 12:11:10 -0000 @@ -0,0 +1,112 @@ +$OpenBSD$ +--- bpf_getetheraddr.c.orig Sat Dec 12 21:40:00 1998 ++++ bpf_getetheraddr.c Sun Dec 6 16:34:36 2015 +@@ -90,7 +90,7 @@ struct nlist nl[] = { + + kvm_t *kvmd; + +-void intpr(u_long ifnetaddr, char *, struct ether_addr *); ++void intpr(char *, struct ether_addr *); + int kread(u_long addr, char *buf, int size); + + +@@ -130,83 +130,40 @@ int getetheraddr(HDEV fd, struct ether_addr *eaddr){ + + strncpy(intname, ifr.ifr_name, sizeof(intname)); + +- if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, +- buf)) == NULL) { +- fprintf(stderr, "kvm_open: %s\n", buf); +- exit(1); +- } +- +- if (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0) { +- if (nlistf) +- fprintf(stderr, "%s: no namelist\n", nlistf); +- else +- fprintf(stderr, "no namelist\n"); +- exit(1); +- } +- +- intpr(nl[N_IFNET].n_value, intname, eaddr); ++ intpr(intname, eaddr); + return(TRUE); + } + ++#include <ifaddrs.h> ++ + void +-intpr(u_long ifnetaddr, char *intname, struct ether_addr *eaddr){ +- struct ifnet ifnet; +- union { +- struct ifaddr ifa; +- struct in_ifaddr in; +- } ifaddr; +- u_long ifaddraddr; +- struct ifnet_head ifhead; /* TAILQ_HEAD */ +- char name[IFNAMSIZ]; ++intpr(char *intname, struct ether_addr *eaddr) { ++ struct ifaddrs *ifa0, *ifa; + struct sockaddr_dl *sdl; + struct sockaddr *sa; + +- if (ifnetaddr == 0) { +- printf("ifnet: symbol not defined\n"); +- return; +- } ++ if (getifaddrs(&ifa0) == -1) ++ return; + +- /* +- * Find the pointer to the first ifnet structure. Replace +- * the pointer to the TAILQ_HEAD with the actual pointer +- * to the first list element. +- */ +- if (kread(ifnetaddr, (char *)&ifhead, sizeof ifhead)) +- return; ++ for (ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next) { + +- ifnetaddr = (u_long)ifhead.tqh_first; +- ifaddraddr = 0; +- +- while (ifnetaddr){ +- register char *cp; +- +- if (kread(ifnetaddr, (char *)&ifnet, sizeof ifnet)) +- return; +- bcopy(ifnet.if_xname, name, IFNAMSIZ); +- name[IFNAMSIZ - 1] = '\0'; /* sanity */ +- ifnetaddr = (u_long)ifnet.if_list.tqe_next; +- ifaddraddr = (u_long)ifnet.if_addrlist.tqh_first; +- +- if (strcmp(name, intname) == 0) { +- if (ifaddraddr != 0){ +- if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { +- ifaddraddr = 0; ++ if (strcmp(ifa->ifa_name, intname) == 0) { ++ sa = (struct sockaddr *)ifa->ifa_addr; ++ if (sa == NULL) + continue; +- } +-#define CP(x) ((char *)(x)) +- cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + +- CP(&ifaddr); +- sa = (struct sockaddr *)cp; ++ if (sa->sa_family != AF_LINK) ++ continue; + sdl = (struct sockaddr_dl *)sa; + /* + if (sdl->sdl_type == IFT_ETHER || + sdl->sdl_type == IFT_FDDI) + */ + /* printf("%s\n", ether_ntoa((struct ether_addr *)LLADDR(sdl))); */ +- memcpy((char *)eaddr, (char *)LLADDR(sdl), sizeof(struct ether_addr)); +- } ++ memcpy((char *)eaddr, (char *)LLADDR(sdl), sizeof(struct ether_addr)); + } + } ++ ++ freeifaddrs(ifa0); + } + + Index: patches/patch-includes_h =================================================================== RCS file: /cvs/ports/security/antisniff/patches/patch-includes_h,v retrieving revision 1.4 diff -u -p -r1.4 patch-includes_h --- patches/patch-includes_h 6 Dec 2013 11:54:48 -0000 1.4 +++ patches/patch-includes_h 7 Dec 2015 12:11:10 -0000 @@ -1,13 +1,11 @@ $OpenBSD: patch-includes_h,v 1.4 2013/12/06 11:54:48 jca Exp $ --- includes.h.orig Tue Apr 11 05:21:13 2000 -+++ includes.h Fri Dec 6 12:53:55 2013 -@@ -30,7 +30,8 @@ - #include <errno.h> ++++ includes.h Mon Dec 7 13:10:10 2015 +@@ -31,6 +31,7 @@ #include <string.h> #include <stdlib.h> -- + +#include <net/if.h> -+#include <net/if_var.h> #include <netinet/if_ether.h> #ifdef _linux_ #include "linux_flood_net.h" @@ -27,14 +25,7 @@ $OpenBSD: patch-includes_h,v 1.4 2013/12 #if BSD < 199103 #include <sys/fcntlcom.h> #endif -@@ -67,11 +66,14 @@ - #include <sys/dirent.h> - #include <net/bpf.h> - #include <kvm.h> -+#define _KERNEL - #include <netinet/in_var.h> -+#undef _KERNEL - #include <net/if_dl.h> +@@ -72,6 +71,7 @@ #endif #include <arpa/nameser.h> -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE