[Icescan-cvs] IceScan/dnet-exported/src Makefile, NONE, 1.1 Makefile.am, NONE, 1.1 Makefile.in, NON
Status: Alpha
Brought to you by:
darkkey
Update of /cvsroot/icescan/IceScan/dnet-exported/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31421/dnet-exported/src Added Files: Makefile Makefile.am Makefile.in addr-util.c addr.c arp-bsd.c arp-ioctl.c arp-none.c arp-win32.c err.c eth-bsd.c eth-dlpi.c eth-linux.c eth-ndd.c eth-none.c eth-pfilt.c eth-snoop.c eth-win32.c intf-win32.c intf.c ip-cooked.c ip-util.c ip-win32.c ip.c ip6.c memcmp.c route-bsd.c route-hpux.c route-linux.c route-none.c route-win32.c strlcat.c strlcpy.c strsep.c Log Message: Initial libDnet import to repository. --- NEW FILE: addr.c --- /* * addr.c * * Network address operations. * * Copyright (c) 2000 Dug Song <du...@mo...> * * $Id: addr.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #ifdef _WIN32 #include "winconfig.h" #else #include "config.h" #endif #include <sys/types.h> #ifdef HAVE_NET_IF_H # include <sys/socket.h> # include <net/if.h> #endif #ifdef HAVE_NET_IF_DL_H # include <net/if_dl.h> #endif #ifdef HAVE_NET_RAW_H # include <net/raw.h> #endif #include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "dnet.h" #ifndef MAXHOSTNAMELEN # define MAXHOSTNAMELEN 256 #endif union sockunion { #ifdef HAVE_NET_IF_DL_H struct sockaddr_dl sdl; #endif struct sockaddr_in sin; #ifdef HAVE_SOCKADDR_IN6 struct sockaddr_in6 sin6; #endif struct sockaddr sa; #ifdef AF_RAW struct sockaddr_raw sr; #endif }; int addr_cmp(const struct addr *a, const struct addr *b) { int i, j, k; /* XXX */ if ((i = a->addr_type - b->addr_type) != 0) return (i); /* XXX - 10.0.0.1 is "smaller" than 10.0.0.0/8? */ if ((i = a->addr_bits - b->addr_bits) != 0) return (i); j = b->addr_bits / 8; for (i = 0; i < j; i++) { if ((k = a->addr_data8[i] - b->addr_data8[i]) != 0) return (k); } if ((k = b->addr_bits % 8) == 0) return (0); k = ~0 << (8 - k); i = b->addr_data8[j] & k; j = a->addr_data8[j] & k; return (j - i); } int addr_net(const struct addr *a, struct addr *b) { uint32_t mask; int i, j; if (a->addr_type == ADDR_TYPE_IP) { addr_btom(a->addr_bits, &mask, IP_ADDR_LEN); b->addr_type = ADDR_TYPE_IP; b->addr_bits = IP_ADDR_BITS; b->addr_ip = a->addr_ip & mask; } else if (a->addr_type == ADDR_TYPE_ETH) { memcpy(b, a, sizeof(*b)); if (a->addr_data8[0] & 0x1) memset(b->addr_data8 + 3, 0, 3); b->addr_bits = ETH_ADDR_BITS; } else if (a->addr_type == ADDR_TYPE_IP6) { b->addr_type = ADDR_TYPE_IP6; b->addr_bits = IP6_ADDR_BITS; memset(&b->addr_ip6, 0, IP6_ADDR_LEN); switch ((i = a->addr_bits / 32)) { case 4: b->addr_data32[3] = a->addr_data32[3]; case 3: b->addr_data32[2] = a->addr_data32[2]; case 2: b->addr_data32[1] = a->addr_data32[1]; case 1: b->addr_data32[0] = a->addr_data32[0]; } if ((j = a->addr_bits % 32) > 0) { addr_btom(j, &mask, sizeof(mask)); b->addr_data32[i] = a->addr_data32[i] & mask; } } else return (-1); return (0); } int addr_bcast(const struct addr *a, struct addr *b) { struct addr mask; if (a->addr_type == ADDR_TYPE_IP) { addr_btom(a->addr_bits, &mask.addr_ip, IP_ADDR_LEN); b->addr_type = ADDR_TYPE_IP; b->addr_bits = IP_ADDR_BITS; b->addr_ip = (a->addr_ip & mask.addr_ip) | (~0L & ~mask.addr_ip); } else if (a->addr_type == ADDR_TYPE_ETH) { b->addr_type = ADDR_TYPE_ETH; b->addr_bits = ETH_ADDR_BITS; memcpy(&b->addr_eth, ETH_ADDR_BROADCAST, ETH_ADDR_LEN); } else { /* XXX - no broadcast addresses in IPv6 */ errno = EINVAL; return (-1); } return (0); } char * addr_ntop(const struct addr *src, char *dst, size_t size) { if (src->addr_type == ADDR_TYPE_IP && size >= 20) { if (ip_ntop(&src->addr_ip, dst, size) != NULL) { if (src->addr_bits != IP_ADDR_BITS) sprintf(dst + strlen(dst), "/%d", src->addr_bits); return (dst); } } else if (src->addr_type == ADDR_TYPE_IP6 && size >= 42) { if (ip6_ntop(&src->addr_ip6, dst, size) != NULL) { if (src->addr_bits != IP6_ADDR_BITS) sprintf(dst + strlen(dst), "/%d", src->addr_bits); return (dst); } } else if (src->addr_type == ADDR_TYPE_ETH && size >= 18) { if (src->addr_bits == ETH_ADDR_BITS) return (eth_ntop(&src->addr_eth, dst, size)); } errno = EINVAL; return (NULL); } int addr_pton(const char *src, struct addr *dst) { struct hostent *hp; char *ep, tmp[300]; long bits = -1; int i; for (i = 0; i < (int)sizeof(tmp) - 1; i++) { if (src[i] == '/') { tmp[i] = '\0'; if (strchr(&src[i + 1], '.')) { uint32_t m; uint16_t b; /* XXX - mask is specified like /255.0.0.0 */ if (ip_pton(&src[i + 1], &m) != 0) { errno = EINVAL; return (-1); } addr_mtob(&m, sizeof(m), &b); bits = b; } else { bits = strtol(&src[i + 1], &ep, 10); if (ep == src || *ep != '\0' || bits < 0) { errno = EINVAL; return (-1); } } break; } else if ((tmp[i] = src[i]) == '\0') break; } if (ip_pton(tmp, &dst->addr_ip) == 0) { dst->addr_type = ADDR_TYPE_IP; dst->addr_bits = IP_ADDR_BITS; } else if (eth_pton(tmp, &dst->addr_eth) == 0) { dst->addr_type = ADDR_TYPE_ETH; dst->addr_bits = ETH_ADDR_BITS; } else if (ip6_pton(tmp, &dst->addr_ip6) == 0) { dst->addr_type = ADDR_TYPE_IP6; dst->addr_bits = IP6_ADDR_BITS; } else if ((hp = gethostbyname(tmp)) != NULL) { memcpy(&dst->addr_ip, hp->h_addr, IP_ADDR_LEN); dst->addr_type = ADDR_TYPE_IP; dst->addr_bits = IP_ADDR_BITS; } else { errno = EINVAL; return (-1); } if (bits >= 0) { if (bits > dst->addr_bits) { errno = EINVAL; return (-1); } dst->addr_bits = (uint16_t)bits; } return (0); } char * addr_ntoa(const struct addr *a) { static char *p, buf[BUFSIZ]; char *q = NULL; if (p == NULL || p > buf + sizeof(buf) - 64 /* XXX */) p = buf; if (addr_ntop(a, p, (buf + sizeof(buf)) - p) != NULL) { q = p; p += strlen(p) + 1; } return (q); } int addr_ntos(const struct addr *a, struct sockaddr *sa) { union sockunion *so = (union sockunion *)sa; switch (a->addr_type) { case ADDR_TYPE_ETH: #ifdef HAVE_NET_IF_DL_H memset(&so->sdl, 0, sizeof(so->sdl)); # ifdef HAVE_SOCKADDR_SA_LEN so->sdl.sdl_len = sizeof(so->sdl); # endif so->sdl.sdl_family = AF_LINK; so->sdl.sdl_alen = ETH_ADDR_LEN; memcpy(LLADDR(&so->sdl), &a->addr_eth, ETH_ADDR_LEN); #else memset(sa, 0, sizeof(*sa)); # ifdef AF_LINK sa->sa_family = AF_LINK; # else sa->sa_family = AF_UNSPEC; # endif memcpy(sa->sa_data, &a->addr_eth, ETH_ADDR_LEN); #endif break; #ifdef HAVE_SOCKADDR_IN6 case ADDR_TYPE_IP6: memset(&so->sin6, 0, sizeof(so->sin6)); #ifdef HAVE_SOCKADDR_SA_LEN so->sin6.sin6_len = sizeof(so->sin6); #endif so->sin6.sin6_family = AF_INET6; memcpy(&so->sin6.sin6_addr, &a->addr_ip6, IP6_ADDR_LEN); break; #endif case ADDR_TYPE_IP: memset(&so->sin, 0, sizeof(so->sin)); #ifdef HAVE_SOCKADDR_SA_LEN so->sin.sin_len = sizeof(so->sin); #endif so->sin.sin_family = AF_INET; so->sin.sin_addr.s_addr = a->addr_ip; break; default: errno = EINVAL; return (-1); } return (0); } int addr_ston(const struct sockaddr *sa, struct addr *a) { union sockunion *so = (union sockunion *)sa; memset(a, 0, sizeof(*a)); switch (sa->sa_family) { #ifdef HAVE_NET_IF_DL_H case AF_LINK: if (so->sdl.sdl_alen != ETH_ADDR_LEN) { errno = EINVAL; return (-1); } a->addr_type = ADDR_TYPE_ETH; a->addr_bits = ETH_ADDR_BITS; memcpy(&a->addr_eth, LLADDR(&so->sdl), ETH_ADDR_LEN); break; #endif case AF_UNSPEC: case ARP_HRD_ETH: /* XXX- Linux arp(7) */ a->addr_type = ADDR_TYPE_ETH; a->addr_bits = ETH_ADDR_BITS; memcpy(&a->addr_eth, sa->sa_data, ETH_ADDR_LEN); break; #ifdef AF_RAW case AF_RAW: /* XXX - IRIX raw(7f) */ a->addr_type = ADDR_TYPE_ETH; a->addr_bits = ETH_ADDR_BITS; memcpy(&a->addr_eth, so->sr.sr_addr, ETH_ADDR_LEN); break; #endif #ifdef HAVE_SOCKADDR_IN6 case AF_INET6: a->addr_type = ADDR_TYPE_IP6; a->addr_bits = IP6_ADDR_BITS; memcpy(&a->addr_ip6, &so->sin6.sin6_addr, IP6_ADDR_LEN); break; #endif case AF_INET: a->addr_type = ADDR_TYPE_IP; a->addr_bits = IP_ADDR_BITS; a->addr_ip = so->sin.sin_addr.s_addr; break; default: errno = EINVAL; return (-1); } return (0); } int addr_btos(uint16_t bits, struct sockaddr *sa) { union sockunion *so = (union sockunion *)sa; #ifdef HAVE_SOCKADDR_IN6 if (bits > IP_ADDR_BITS && bits <= IP6_ADDR_BITS) { memset(&so->sin6, 0, sizeof(so->sin6)); #ifdef HAVE_SOCKADDR_SA_LEN so->sin6.sin6_len = IP6_ADDR_LEN + (bits / 8) + (bits % 8); #endif so->sin6.sin6_family = AF_INET6; return (addr_btom(bits, &so->sin6.sin6_addr, IP6_ADDR_LEN)); } else #endif if (bits <= IP_ADDR_BITS) { memset(&so->sin, 0, sizeof(so->sin)); #ifdef HAVE_SOCKADDR_SA_LEN so->sin.sin_len = IP_ADDR_LEN + (bits / 8) + (bits % 8); #endif so->sin.sin_family = AF_INET; return (addr_btom(bits, &so->sin.sin_addr, IP_ADDR_LEN)); } errno = EINVAL; return (-1); } int addr_stob(const struct sockaddr *sa, uint16_t *bits) { union sockunion *so = (union sockunion *)sa; int i, j, len; uint16_t n; u_char *p; #ifdef HAVE_SOCKADDR_IN6 if (sa->sa_family == AF_INET6) { len = IP6_ADDR_LEN; p = (u_char *)&so->sin6.sin6_addr; } else #endif { #ifdef HAVE_SOCKADDR_SA_LEN if ((len = sa->sa_len - IP_ADDR_LEN) > IP_ADDR_LEN) #endif len = IP_ADDR_LEN; p = (u_char *)&so->sin.sin_addr.s_addr; } for (n = i = 0; i < len; i++, n += 8) { if (p[i] != 0xff) break; } if (i != len && p[i]) { for (j = 7; j > 0; j--, n++) { if ((p[i] & (1 << j)) == 0) break; } } *bits = n; return (0); } int addr_btom(uint16_t bits, void *mask, size_t size) { int net, host; u_char *p; if (size == IP_ADDR_LEN) { if (bits > IP_ADDR_BITS) { errno = EINVAL; return (-1); } *(uint32_t *)mask = bits ? htonl(~0 << (IP_ADDR_BITS - bits)) : 0; } else { if (size * 8 < bits) { errno = EINVAL; return (-1); } p = (u_char *)mask; if ((net = bits / 8) > 0) memset(p, 0xff, net); if ((host = bits % 8) > 0) { p[net] = 0xff << (8 - host); memset(&p[net + 1], 0, size - net - 1); } else memset(&p[net], 0, size - net); } return (0); } int addr_mtob(const void *mask, size_t size, uint16_t *bits) { uint16_t n; u_char *p; int i, j; p = (u_char *)mask; for (n = i = 0; i < (int)size; i++, n += 8) { if (p[i] != 0xff) break; } if (i != (int)size && p[i]) { for (j = 7; j > 0; j--, n++) { if ((p[i] & (1 << j)) == 0) break; } } *bits = n; return (0); } --- NEW FILE: intf-win32.c --- /* * intf-win32.c * * Copyright (c) 2002 Dug Song <du...@mo...> * * $Id: intf-win32.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #ifdef _WIN32 #include "winconfig.h" #else #include "config.h" #endif #include <iphlpapi.h> #include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "dnet.h" struct ifcombo { DWORD *idx; int cnt; int max; }; #define MIB_IF_TYPE_MAX 32 /* XXX - ipifcons.h */ struct intf_handle { struct ifcombo ifcombo[MIB_IF_TYPE_MAX]; MIB_IFTABLE *iftable; MIB_IPADDRTABLE *iptable; }; static char * _ifcombo_name(int type) { char *name = "net"; /* XXX */ if (type == MIB_IF_TYPE_ETHERNET) { name = "eth"; } else if (type == MIB_IF_TYPE_TOKENRING) { name = "tr"; } else if (type == MIB_IF_TYPE_FDDI) { name = "fddi"; } else if (type == MIB_IF_TYPE_PPP) { name = "ppp"; } else if (type == MIB_IF_TYPE_LOOPBACK) { name = "lo"; } else if (type == MIB_IF_TYPE_SLIP) { name = "sl"; } return (name); } static int _ifcombo_type(const char *device) { int type = INTF_TYPE_OTHER; if (strncmp(device, "eth", 3) == 0) { type = INTF_TYPE_ETH; } else if (strncmp(device, "tr", 2) == 0) { type = INTF_TYPE_TOKENRING; } else if (strncmp(device, "fd", 2) == 0) { type = INTF_TYPE_FDDI; } else if (strncmp(device, "ppp", 3) == 0) { type = INTF_TYPE_PPP; } else if (strncmp(device, "lo", 2) == 0) { type = INTF_TYPE_LOOPBACK; } else if (strncmp(device, "sl", 2) == 0) { type = INTF_TYPE_SLIP; } return (type); } static void _ifcombo_add(struct ifcombo *ifc, DWORD idx) { if (ifc->cnt == ifc->max) { if (ifc->idx) { ifc->max *= 2; ifc->idx = realloc(ifc->idx, sizeof(ifc->idx[0] * ifc->max)); } else { ifc->max = 8; ifc->idx = malloc(sizeof(ifc->idx[0] * ifc->max)); } } ifc->idx[ifc->cnt++] = idx; } static void _ifrow_to_entry(intf_t *intf, MIB_IFROW *ifrow, struct intf_entry *entry) { struct addr *ap, *lap; int i; memset(entry, 0, sizeof(*entry)); for (i = 0; i < intf->ifcombo[ifrow->dwType].cnt; i++) { if (intf->ifcombo[ifrow->dwType].idx[i] == ifrow->dwIndex) break; } /* XXX - dwType matches MIB-II ifType. */ snprintf(entry->intf_name, sizeof(entry->intf_name), "%s%lu", _ifcombo_name(ifrow->dwType), i); entry->intf_type = (uint16_t)ifrow->dwType; /* Get interface flags. */ entry->intf_flags = 0; if (ifrow->dwAdminStatus == MIB_IF_ADMIN_STATUS_UP) entry->intf_flags |= INTF_FLAG_UP; if (ifrow->dwType == MIB_IF_TYPE_LOOPBACK) entry->intf_flags |= INTF_FLAG_LOOPBACK; else entry->intf_flags |= INTF_FLAG_MULTICAST; /* Get interface MTU. */ entry->intf_mtu = ifrow->dwMtu; /* Get hardware address. */ if (ifrow->dwPhysAddrLen == ETH_ADDR_LEN) { entry->intf_link_addr.addr_type = ADDR_TYPE_ETH; entry->intf_link_addr.addr_bits = ETH_ADDR_BITS; memcpy(&entry->intf_link_addr.addr_eth, ifrow->bPhysAddr, ETH_ADDR_LEN); } /* Get addresses. */ ap = entry->intf_alias_addrs; lap = ap + ((entry->intf_len - sizeof(*entry)) / sizeof(entry->intf_alias_addrs[0])); for (i = 0; i < (int)intf->iptable->dwNumEntries; i++) { if (intf->iptable->table[i].dwIndex == ifrow->dwIndex && intf->iptable->table[i].dwAddr != 0) { if (entry->intf_addr.addr_type == ADDR_TYPE_NONE) { /* Set primary address if unset. */ entry->intf_addr.addr_type = ADDR_TYPE_IP; entry->intf_addr.addr_ip = intf->iptable->table[i].dwAddr; addr_mtob(&intf->iptable->table[i].dwMask, IP_ADDR_LEN, &entry->intf_addr.addr_bits); } else if (ap < lap) { /* Set aliases. */ ap->addr_type = ADDR_TYPE_IP; ap->addr_ip = intf->iptable->table[i].dwAddr; addr_mtob(&intf->iptable->table[i].dwMask, IP_ADDR_LEN, &ap->addr_bits); ap++, entry->intf_alias_num++; } } } entry->intf_len = (u_char *)ap - (u_char *)entry; } static int _refresh_tables(intf_t *intf) { MIB_IFROW *ifrow; ULONG len; u_int i, ret; /* Get interface table. */ for (len = sizeof(intf->iftable[0]); ; ) { if (intf->iftable) free(intf->iftable); intf->iftable = malloc(len); ret = GetIfTable(intf->iftable, &len, FALSE); if (ret == NO_ERROR) break; else if (ret != ERROR_INSUFFICIENT_BUFFER) return (-1); } /* Get IP address table. */ for (len = sizeof(intf->iptable[0]); ; ) { if (intf->iptable) free(intf->iptable); intf->iptable = malloc(len); ret = GetIpAddrTable(intf->iptable, &len, FALSE); if (ret == NO_ERROR) break; else if (ret != ERROR_INSUFFICIENT_BUFFER) return (-1); } /* * Map "unfriendly" win32 interface indices to ours. * XXX - like IP_ADAPTER_INFO ComboIndex */ for (i = 0; i < intf->iftable->dwNumEntries; i++) { ifrow = &intf->iftable->table[i]; if (ifrow->dwType < MIB_IF_TYPE_MAX) { _ifcombo_add(&intf->ifcombo[ifrow->dwType], ifrow->dwIndex); } else return (-1); } return (0); } static int _find_ifindex(intf_t *intf, const char *device) { char *p = (char *)device; int n, type = _ifcombo_type(device); while (isalpha(*p)) p++; n = atoi(p); return (intf->ifcombo[type].idx[n]); } intf_t * intf_open(void) { return (calloc(1, sizeof(intf_t))); } int intf_get(intf_t *intf, struct intf_entry *entry) { MIB_IFROW ifrow; if (_refresh_tables(intf) < 0) return (-1); ifrow.dwIndex = _find_ifindex(intf, entry->intf_name); if (GetIfEntry(&ifrow) != NO_ERROR) return (-1); _ifrow_to_entry(intf, &ifrow, entry); return (0); } int intf_get_src(intf_t *intf, struct intf_entry *entry, struct addr *src) { MIB_IFROW ifrow; MIB_IPADDRROW *iprow; int i; if (src->addr_type != ADDR_TYPE_IP) { errno = EINVAL; return (-1); } if (_refresh_tables(intf) < 0) return (-1); for (i = 0; i < (int)intf->iptable->dwNumEntries; i++) { iprow = &intf->iptable->table[i]; if (iprow->dwAddr == src->addr_ip) { ifrow.dwIndex = iprow->dwIndex; if (GetIfEntry(&ifrow) != NO_ERROR) return (-1); _ifrow_to_entry(intf, &ifrow, entry); return (0); } } errno = ENXIO; return (-1); } int intf_get_dst(intf_t *intf, struct intf_entry *entry, struct addr *dst) { MIB_IFROW ifrow; if (dst->addr_type != ADDR_TYPE_IP) { errno = EINVAL; return (-1); } if (GetBestInterface(dst->addr_ip, &ifrow.dwIndex) != NO_ERROR) return (-1); if (GetIfEntry(&ifrow) != NO_ERROR) return (-1); if (_refresh_tables(intf) < 0) return (-1); _ifrow_to_entry(intf, &ifrow, entry); return (0); } int intf_set(intf_t *intf, const struct intf_entry *entry) { /* * XXX - could set interface up/down via SetIfEntry(), * but what about the rest of the configuration? :-( * {Add,Delete}IPAddress for 2000/XP only */ #if 0 /* Set interface address. XXX - 2000/XP only? */ if (entry->intf_addr.addr_type == ADDR_TYPE_IP) { ULONG ctx = 0, inst = 0; UINT ip, mask; memcpy(&ip, &entry->intf_addr.addr_ip, IP_ADDR_LEN); addr_btom(entry->intf_addr.addr_bits, &mask, IP_ADDR_LEN); if (AddIPAddress(ip, mask, _find_ifindex(intf, entry->intf_name), &ctx, &inst) != NO_ERROR) { return (-1); } return (0); } #endif errno = ENOSYS; SetLastError(ERROR_NOT_SUPPORTED); return (-1); } int intf_loop(intf_t *intf, intf_handler callback, void *arg) { struct intf_entry *entry; u_char ebuf[1024]; int i, ret = 0; if (_refresh_tables(intf) < 0) return (-1); entry = (struct intf_entry *)ebuf; for (i = 0; i < (int)intf->iftable->dwNumEntries; i++) { entry->intf_len = sizeof(ebuf); _ifrow_to_entry(intf, &intf->iftable->table[i], entry); if ((ret = (*callback)(entry, arg)) != 0) break; } return (ret); } intf_t * intf_close(intf_t *intf) { int i; if (intf != NULL) { for (i = 0; i < MIB_IF_TYPE_MAX; i++) { if (intf->ifcombo[i].idx) free(intf->ifcombo[i].idx); } if (intf->iftable) free(intf->iftable); if (intf->iptable) free(intf->iptable); free(intf); } return (NULL); } --- NEW FILE: Makefile.in --- # Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/Makefile.am.common arp-bsd.c arp-ioctl.c \ arp-none.c arp-win32.c err.c eth-bsd.c eth-dlpi.c eth-linux.c \ eth-ndd.c eth-none.c eth-pfilt.c eth-snoop.c eth-win32.c \ intf-win32.c intf.c ip-cooked.c ip-win32.c ip.c memcmp.c \ route-bsd.c route-hpux.c route-linux.c route-none.c \ route-win32.c strlcat.c strlcpy.c strsep.c subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libdnet_la_DEPENDENCIES = @LTLIBOBJS@ am_libdnet_la_OBJECTS = addr-util.lo addr.lo ip-util.lo ip6.lo libdnet_la_OBJECTS = $(am_libdnet_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include depcomp = am__depfiles_maybe = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libdnet_la_SOURCES) DIST_SOURCES = $(libdnet_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CHECKINC = @CHECKINC@ CHECKLIB = @CHECKLIB@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ GREP = @GREP@ HAVE_CHECK_FALSE = @HAVE_CHECK_FALSE@ HAVE_CHECK_TRUE = @HAVE_CHECK_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_aux_dir = @ac_aux_dir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AUTOMAKE_OPTIONS = foreign no-dependencies AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libdnet.la libdnet_la_SOURCES = addr-util.c addr.c ip-util.c ip6.c libdnet_la_LIBADD = @LTLIBOBJS@ libdnet_la_LDFLAGS = -version-info 1:1:0 all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ f=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ else :; fi; \ done uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ p=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libdnet.la: $(libdnet_la_OBJECTS) $(libdnet_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libdnet_la_LDFLAGS) $(libdnet_la_OBJECTS) $(libdnet_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .c.o: $(COMPILE) -c $< .c.obj: $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(mkdir_p) $(distdir)/.. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-libLTLIBRARIES install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-exec \ install-exec-am install-info install-info-am \ install-libLTLIBRARIES install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-info-am \ uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE: arp-none.c --- /* * arp-none.c * * Copyright (c) 2000 Dug Song <du...@mo...> * * $Id: arp-none.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "dnet.h" arp_t * arp_open(void) { errno = ENOSYS; return (NULL); } int arp_add(arp_t *a, const struct arp_entry *entry) { errno = ENOSYS; return (-1); } int arp_delete(arp_t *a, const struct arp_entry *entry) { errno = ENOSYS; return (-1); } int arp_get(arp_t *a, struct arp_entry *entry) { errno = ENOSYS; return (-1); } int arp_loop(arp_t *a, arp_handler callback, void *arg) { errno = ENOSYS; return (-1); } arp_t * arp_close(arp_t *a) { return (NULL); } --- NEW FILE: Makefile --- # Makefile.in generated by automake 1.9.6 from Makefile.am. # src/Makefile. Generated from Makefile.in by configure. # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. srcdir = . top_srcdir = .. pkgdatadir = $(datadir)/libdnet pkglibdir = $(libdir)/libdnet pkgincludedir = $(includedir)/libdnet top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = /usr/bin/install -c install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = i386-unknown-openbsd4.4 host_triplet = i386-unknown-openbsd4.4 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/Makefile.am.common arp-bsd.c arp-ioctl.c \ arp-none.c arp-win32.c err.c eth-bsd.c eth-dlpi.c eth-linux.c \ eth-ndd.c eth-none.c eth-pfilt.c eth-snoop.c eth-win32.c \ intf-win32.c intf.c ip-cooked.c ip-win32.c ip.c memcmp.c \ route-bsd.c route-hpux.c route-linux.c route-none.c \ route-win32.c strlcat.c strlcpy.c strsep.c subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libdnet_la_DEPENDENCIES = ${LIBOBJDIR}arp-bsd$U.lo ${LIBOBJDIR}eth-bsd$U.lo ${LIBOBJDIR}intf$U.lo ${LIBOBJDIR}ip$U.lo ${LIBOBJDIR}route-bsd$U.lo am_libdnet_la_OBJECTS = addr-util.lo addr.lo ip-util.lo ip6.lo libdnet_la_OBJECTS = $(am_libdnet_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include depcomp = am__depfiles_maybe = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libdnet_la_SOURCES) DIST_SOURCES = $(libdnet_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run aclocal-1.6 AMDEP_FALSE = # AMDEP_TRUE = AMTAR = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run tar AR = ar AUTOCONF = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run autoconf AUTOHEADER = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run autoheader AUTOMAKE = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run automake-1.6 AWK = nawk CC = gcc CCDEPMODE = depmode=none CFLAGS = -I/usr/local/include -Wall CHECKINC = CHECKLIB = CPP = gcc -E CPPFLAGS = CXX = g++ CXXCPP = g++ -E CXXDEPMODE = depmode=none CXXFLAGS = -I/usr/local/include CYGPATH_W = @CYGPATH_W@ DEFS = -DHAVE_CONFIG_H DEPDIR = .deps DSYMUTIL = @DSYMUTIL@ ECHO = /bin/echo ECHO_C = ECHO_N = -n ECHO_T = EGREP = /usr/bin/grep -E EXEEXT = F77 = g77 FFLAGS = -g -O2 GREP = /usr/bin/grep HAVE_CHECK_FALSE = HAVE_CHECK_TRUE = # INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s LDFLAGS = -L/usr/local/lib LIBOBJS = ${LIBOBJDIR}arp-bsd$U.o ${LIBOBJDIR}eth-bsd$U.o ${LIBOBJDIR}intf$U.o ${LIBOBJDIR}ip$U.o ${LIBOBJDIR}route-bsd$U.o LIBS = LIBTOOL = $(SHELL) $(top_builddir)/libtool LN_S = ln -s LTLIBOBJS = ${LIBOBJDIR}arp-bsd$U.lo ${LIBOBJDIR}eth-bsd$U.lo ${LIBOBJDIR}intf$U.lo ${LIBOBJDIR}ip$U.lo ${LIBOBJDIR}route-bsd$U.lo MAINT = # MAINTAINER_MODE_FALSE = MAINTAINER_MODE_TRUE = # MAKEINFO = ${SHELL} /home/key/IceScan/dnet-exported/config/missing --run makeinfo NMEDIT = @NMEDIT@ OBJEXT = o PACKAGE = libdnet PACKAGE_BUGREPORT = PACKAGE_NAME = PACKAGE_STRING = PACKAGE_TARNAME = PACKAGE_VERSION = PATH_SEPARATOR = : RANLIB = ranlib SED = @SED@ SET_MAKE = SHELL = /bin/sh STRIP = strip VERSION = 1.11 ac_aux_dir = config ac_ct_CC = gcc ac_ct_CXX = g++ ac_ct_F77 = g77 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = include am__leading_dot = @am__leading_dot@ am__quote = am__tar = @am__tar@ am__untar = @am__untar@ bindir = ${exec_prefix}/bin build = i386-unknown-openbsd4.4 build_alias = build_cpu = i386 build_os = openbsd4.4 build_vendor = unknown datadir = ${datarootdir} datarootdir = ${prefix}/share docdir = ${datarootdir}/doc/${PACKAGE} dvidir = ${docdir} exec_prefix = ${prefix} host = i386-unknown-openbsd4.4 host_alias = host_cpu = i386 host_os = openbsd4.4 host_vendor = unknown htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info install_sh = /home/key/IceScan/dnet-exported/config/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale localstatedir = ${prefix}/var mandir = ${datarootdir}/man mkdir_p = @mkdir_p@ oldincludedir = /usr/include pdfdir = ${docdir} prefix = /usr/local program_transform_name = s,x,x, psdir = ${docdir} sbindir = ${exec_prefix}/sbin sharedstatedir = ${prefix}/com sysconfdir = ${prefix}/etc target_alias = AUTOMAKE_OPTIONS = foreign no-dependencies AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libdnet.la libdnet_la_SOURCES = addr-util.c addr.c ip-util.c ip6.c libdnet_la_LIBADD = ${LIBOBJDIR}arp-bsd$U.lo ${LIBOBJDIR}eth-bsd$U.lo ${LIBOBJDIR}intf$U.lo ${LIBOBJDIR}ip$U.lo ${LIBOBJDIR}route-bsd$U.lo libdnet_la_LDFLAGS = -version-info 1:1:0 all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: # $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): # $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ f=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ else :; fi; \ done uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ p=$(am__strip_dir) \ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libdnet.la: $(libdnet_la_OBJECTS) $(libdnet_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libdnet_la_LDFLAGS) $(libdnet_la_OBJECTS) $(libdnet_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .c.o: $(COMPILE) -c $< .c.obj: $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(mkdir_p) $(distdir)/.. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-libLTLIBRARIES install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-exec \ install-exec-am install-info install-info-am \ install-libLTLIBRARIES install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-info-am \ uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE: ip-util.c --- /* * ip-util.c * * Copyright (c) 2002 Dug Song <du...@mo...> * * $Id: ip-util.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #ifdef _WIN32 #include "winconfig.h" #else #include "config.h" #endif #include <errno.h> #include <stdlib.h> #include <string.h> #include "dnet.h" ssize_t ip_add_option(void *buf, size_t len, int proto, const void *optbuf, size_t optlen) { struct ip_hdr *ip; struct tcp_hdr *tcp = NULL; u_char *p; int hl, datalen, padlen; if (proto != IP_PROTO_IP && proto != IP_PROTO_TCP) { errno = EINVAL; return (-1); } ip = (struct ip_hdr *)buf; hl = ip->ip_hl << 2; p = (u_char *)buf + hl; if (proto == IP_PROTO_TCP) { tcp = (struct tcp_hdr *)p; hl = tcp->th_off << 2; p = (u_char *)tcp + hl; } datalen = ntohs(ip->ip_len) - (p - (u_char *)buf); /* Compute padding to next word boundary. */ if ((padlen = 4 - (optlen % 4)) == 4) padlen = 0; /* XXX - IP_HDR_LEN_MAX == TCP_HDR_LEN_MAX */ if (hl + optlen + padlen > IP_HDR_LEN_MAX || ntohs(ip->ip_len) + optlen + padlen > len) { errno = EINVAL; return (-1); } /* XXX - IP_OPT_TYPEONLY() == TCP_OPT_TYPEONLY */ if (IP_OPT_TYPEONLY(((struct ip_opt *)optbuf)->opt_type)) optlen = 1; /* Shift any existing data. */ if (datalen) { memmove(p + optlen + padlen, p, datalen); } /* XXX - IP_OPT_NOP == TCP_OPT_NOP */ if (padlen) { memset(p, IP_OPT_NOP, padlen); p += padlen; } memmove(p, optbuf, optlen); p += optlen; optlen += padlen; if (proto == IP_PROTO_IP) ip->ip_hl = (p - (u_char *)ip) >> 2; else if (proto == IP_PROTO_TCP) tcp->th_off = (p - (u_char *)tcp) >> 2; ip->ip_len = htons(ntohs(ip->ip_len) + optlen); return (optlen); } void ip_checksum(void *buf, size_t len) { struct ip_hdr *ip; int hl, off, sum; if (len < IP_HDR_LEN) return; ip = (struct ip_hdr *)buf; hl = ip->ip_hl << 2; ip->ip_sum = 0; sum = ip_cksum_add(ip, hl, 0); ip->ip_sum = ip_cksum_carry(sum); off = htons(ip->ip_off); if ((off & IP_OFFMASK) != 0 || (off & IP_MF) != 0) return; len -= hl; if (ip->ip_p == IP_PROTO_TCP) { struct tcp_hdr *tcp = (struct tcp_hdr *)((u_char *)ip + hl); if (len >= TCP_HDR_LEN) { tcp->th_sum = 0; sum = ip_cksum_add(tcp, len, 0) + htons(ip->ip_p + len); sum = ip_cksum_add(&ip->ip_src, 8, sum); tcp->th_sum = ip_cksum_carry(sum); } } else if (ip->ip_p == IP_PROTO_UDP) { struct udp_hdr *udp = (struct udp_hdr *)((u_char *)ip + hl); if (len >= UDP_HDR_LEN) { udp->uh_sum = 0; sum = ip_cksum_add(udp, len, 0) + htons(ip->ip_p + len); sum = ip_cksum_add(&ip->ip_src, 8, sum); udp->uh_sum = ip_cksum_carry(sum); if (!udp->uh_sum) udp->uh_sum = 0xffff; /* RFC 768 */ } } else if (ip->ip_p == IP_PROTO_ICMP || ip->ip_p == IP_PROTO_IGMP) { struct icmp_hdr *icmp = (struct icmp_hdr *)((u_char *)ip + hl); if (len >= ICMP_HDR_LEN) { icmp->icmp_cksum = 0; sum = ip_cksum_add(icmp, len, 0); icmp->icmp_cksum = ip_cksum_carry(sum); } } } int ip_cksum_add(const void *buf, size_t len, int cksum) { uint16_t *sp = (uint16_t *)buf; int n, sn; sn = len / 2; n = (sn + 15) / 16; /* XXX - unroll loop using Duff's device. */ switch (sn % 16) { case 0: do { cksum += *sp++; case 15: cksum += *sp++; case 14: cksum += *sp++; case 13: cksum += *sp++; case 12: cksum += *sp++; case 11: cksum += *sp++; case 10: cksum += *sp++; case 9: cksum += *sp++; case 8: cksum += *sp++; case 7: cksum += *sp++; case 6: cksum += *sp++; case 5: cksum += *sp++; case 4: cksum += *sp++; case 3: cksum += *sp++; case 2: cksum += *sp++; case 1: cksum += *sp++; } while (--n > 0); } if (len & 1) cksum += htons(*(u_char *)sp << 8); return (cksum); } --- NEW FILE: eth-snoop.c --- /* * eth-snoop.c * * Copyright (c) 2000 Dug Song <du...@mo...> * * $Id: eth-snoop.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> #include <net/raw.h> #include <assert.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "dnet.h" struct eth_handle { int fd; struct ifreq ifr; }; eth_t * eth_open(const char *device) { struct sockaddr_raw sr; eth_t *e; int n; if ((e = calloc(1, sizeof(*e))) == NULL) return (NULL); if ((e->fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP)) < 0) return (eth_close(e)); memset(&sr, 0, sizeof(sr)); sr.sr_family = AF_RAW; strlcpy(sr.sr_ifname, device, sizeof(sr.sr_ifname)); if (bind(e->fd, (struct sockaddr *)&sr, sizeof(sr)) < 0) return (eth_close(e)); n = 60000; if (setsockopt(e->fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)) < 0) return (eth_close(e)); strlcpy(e->ifr.ifr_name, device, sizeof(e->ifr.ifr_name)); return (e); } int eth_get(eth_t *e, eth_addr_t *ea) { struct addr ha; if (ioctl(e->fd, SIOCGIFADDR, &e->ifr) < 0) return (-1); if (addr_ston(&e->ifr.ifr_addr, &ha) < 0) return (-1); if (ha.addr_type != ADDR_TYPE_ETH) { errno = EINVAL; return (-1); } memcpy(ea, &ha.addr_eth, sizeof(*ea)); return (0); } int eth_set(eth_t *e, const eth_addr_t *ea) { struct addr ha; ha.addr_type = ADDR_TYPE_ETH; ha.addr_bits = ETH_ADDR_BITS; memcpy(&ha.addr_eth, ea, ETH_ADDR_LEN); if (addr_ntos(&ha, &e->ifr.ifr_addr) < 0) return (-1); return (ioctl(e->fd, SIOCSIFADDR, &e->ifr)); } ssize_t eth_send(eth_t *e, const void *buf, size_t len) { return (write(e->fd, buf, len)); } eth_t * eth_close(eth_t *e) { if (e != NULL) { if (e->fd >= 0) close(e->fd); free(e); } return (NULL); } --- NEW FILE: eth-ndd.c --- /* * eth-ndd.c * * Copyright (c) 2001 Dug Song <du...@mo...> * * $Id: eth-ndd.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/types.h> #include <sys/socket.h> #include <sys/ndd_var.h> #include <sys/kinfo.h> #include <assert.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "dnet.h" struct eth_handle { char device[16]; int fd; }; eth_t * eth_open(const char *device) { struct sockaddr_ndd_8022 sa; eth_t *e; if ((e = calloc(1, sizeof(*e))) == NULL) return (NULL); if ((e->fd = socket(AF_NDD, SOCK_DGRAM, NDD_PROT_ETHER)) < 0) return (eth_close(e)); sa.sndd_8022_family = AF_NDD; sa.sndd_8022_len = sizeof(sa); sa.sndd_8022_filtertype = NS_ETHERTYPE; sa.sndd_8022_ethertype = ETH_TYPE_IP; sa.sndd_8022_filterlen = sizeof(struct ns_8022); strlcpy(sa.sndd_8022_nddname, device, sizeof(sa.sndd_8022_nddname)); if (bind(e->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) return (eth_close(e)); if (connect(e->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) return (eth_close(e)); /* XXX - SO_BROADCAST needed? */ return (e); } ssize_t eth_send(eth_t *e, const void *buf, size_t len) { return (write(e->fd, buf, len)); } eth_t * eth_close(eth_t *e) { if (e != NULL) { if (e->fd >= 0) close(e->fd); free(e); } return (NULL); } int eth_get(eth_t *e, eth_addr_t *ea) { struct kinfo_ndd *nddp; int size; void *end; if ((size = getkerninfo(KINFO_NDD, 0, 0, 0)) == 0) { errno = ENOENT; return (-1); } else if (size < 0) return (-1); if ((nddp = malloc(size)) == NULL) return (-1); if (getkerninfo(KINFO_NDD, nddp, &size, 0) < 0) { free(nddp); return (-1); } for (end = (void *)nddp + size; (void *)nddp < end; nddp++) { if (strcmp(nddp->ndd_alias, e->device) == 0 || strcmp(nddp->ndd_name, e->device) == 0) { memcpy(ea, nddp->ndd_addr, sizeof(*ea)); } } free(nddp); if ((void *)nddp >= end) { errno = ESRCH; return (-1); } return (0); } int eth_set(eth_t *e, const eth_addr_t *ea) { errno = ENOSYS; return (-1); } --- NEW FILE: eth-none.c --- /* * eth-none.c * * Copyright (c) 2000 Dug Song <du...@mo...> * * $Id: eth-none.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "dnet.h" eth_t * eth_open(const char *device) { errno = ENOSYS; return (NULL); } ssize_t eth_send(eth_t *e, const void *buf, size_t len) { errno = ENOSYS; return (-1); } eth_t * eth_close(eth_t *e) { return (NULL); } int eth_get(eth_t *e, eth_addr_t *ea) { errno = ENOSYS; return (-1); } int eth_set(eth_t *e, const eth_addr_t *ea) { errno = ENOSYS; return (-1); } --- NEW FILE: eth-bsd.c --- /* * eth-bsd.c * * Copyright (c) 2001 Dug Song <du...@mo...> * * $Id: eth-bsd.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/param.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_ROUTE_RT_MSGHDR) #include <sys/sysctl.h> #include <net/route.h> #include <net/if_dl.h> #endif #include <net/bpf.h> #include <net/if.h> #include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "dnet.h" struct eth_handle { int fd; char device[16]; }; eth_t * eth_open(const char *device) { struct ifreq ifr; char file[32]; eth_t *e; int i; if ((e = calloc(1, sizeof(*e))) != NULL) { for (i = 0; i < 32; i++) { snprintf(file, sizeof(file), "/dev/bpf%d", i); e->fd = open(file, O_WRONLY); if (e->fd != -1 || errno != EBUSY) break; } if (e->fd < 0) return (eth_close(e)); memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(e->fd, BIOCSETIF, (char *)&ifr) < 0) return (eth_close(e)); #ifdef BIOCSHDRCMPLT i = 1; if (ioctl(e->fd, BIOCSHDRCMPLT, &i) < 0) return (eth_close(e)); #endif strlcpy(e->device, device, sizeof(e->device)); } return (e); } ssize_t eth_send(eth_t *e, const void *buf, size_t len) { return (write(e->fd, buf, len)); } eth_t * eth_close(eth_t *e) { if (e != NULL) { if (e->fd >= 0) close(e->fd); free(e); } return (NULL); } #if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_ROUTE_RT_MSGHDR) int eth_get(eth_t *e, eth_addr_t *ea) { struct if_msghdr *ifm; struct sockaddr_dl *sdl; struct addr ha; u_char *p, *buf; size_t len; int mib[] = { CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0 }; if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) return (-1); if ((buf = malloc(len)) == NULL) return (-1); if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { free(buf); return (-1); } for (p = buf; p < buf + len; p += ifm->ifm_msglen) { ifm = (struct if_msghdr *)p; sdl = (struct sockaddr_dl *)(ifm + 1); if (ifm->ifm_type != RTM_IFINFO || (ifm->ifm_addrs & RTA_IFP) == 0) continue; if (sdl->sdl_family != AF_LINK || sdl->sdl_nlen == 0 || memcmp(sdl->sdl_data, e->device, sdl->sdl_nlen) != 0) continue; if (addr_ston((struct sockaddr *)sdl, &ha) == 0) break; } free(buf); if (p >= buf + len) { errno = ESRCH; return (-1); } memcpy(ea, &ha.addr_eth, sizeof(*ea)); return (0); } #else int eth_get(eth_t *e, eth_addr_t *ea) { errno = ENOSYS; return (-1); } #endif #if defined(SIOCSIFLLADDR) int eth_set(eth_t *e, const eth_addr_t *ea) { struct ifreq ifr; struct addr ha; ha.addr_type = ADDR_TYPE_ETH; ha.addr_bits = ETH_ADDR_BITS; memcpy(&ha.addr_eth, ea, ETH_ADDR_LEN); memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, e->device, sizeof(ifr.ifr_name)); addr_ntos(&ha, &ifr.ifr_addr); return (ioctl(e->fd, SIOCSIFLLADDR, &ifr)); } #else int eth_set(eth_t *e, const eth_addr_t *ea) { errno = ENOSYS; return (-1); } #endif --- NEW FILE: Makefile.am --- ## $Id: Makefile.am,v 1.1 2009/04/14 15:43:35 darkkey Exp $ include $(top_srcdir)/Makefile.am.common lib_LTLIBRARIES = libdnet.la libdnet_la_SOURCES = addr-util.c addr.c ip-util.c ip6.c libdnet_la_LIBADD = @LTLIBOBJS@ libdnet_la_LDFLAGS = -version-info 1:1:0 --- NEW FILE: eth-dlpi.c --- /* * eth-dlpi.c * * Based on Neal Nuckolls' 1992 "How to Use DLPI" paper. * * Copyright (c) 2001 Dug Song <du...@mo...> * * $Id: eth-dlpi.c,v 1.1 2009/04/14 15:43:35 darkkey Exp $ */ #include "config.h" #include <sys/types.h> #ifdef HAVE_SYS_BUFMOD_H #include <sys/bufmod.h> #endif #ifdef HAVE_SYS_DLPI_H #include <sys/dlpi.h> #elif defined(HAVE_SYS_DLPIHDR_H) #include <sys/dlpihdr.h> #endif #ifdef HAVE_SYS_DLPI_EXT_H #include <sys/dlpi_ext.h> #endif #include <sys/stream.h> #include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stropts.h> #include <unistd.h> #include "dnet.h" #ifndef INFTIM #define INFTIM -1 #endif struct eth_handle { int fd; int sap_len; }; static int dlpi_msg(int fd, union DL_primitives *dlp, int rlen, int flags, int ack, int alen, int size) { struct strbuf ctl; ctl.maxlen = 0; ctl.len = rlen; ctl.buf = (caddr_t)dlp; if (putmsg(fd, &ctl, NULL, flags) < 0) return (-1); ctl.maxlen = size; ctl.len = 0; flags = 0; if (getmsg(fd, &ctl, NULL, &flags) < 0) return (-1); if (dlp->dl_primitive != ack || ctl.len < alen) return (-1); return (0); } #if defined(DLIOCRAW) |... [truncated message content] |