Package: hping2 Version: 2.rc3-4 Severity: normal Tags: patch Hello,
When using hping2 on my system I get [main] physical layer header size unknown This is because my interfaces are named ETH0 and WLAN0 instead of eth0/wlan0. I'm a fan of ifrename and this allows you to use any interface name you want but usually not the "usual" ones (because with eth0+eth1 you cannot rename e.g. eth0 to eth1 so you choose new names) ifrename is originally part of wireless-tools but is distributed alone on Debian because this is more that just for wireless interfaces. I saw in hping2 code that on linux hw type is "detected" from the ifname. I think this is quite unreliable and of course it fails when I use ifrename. Here is a small example patch to show you that better detection is possible but my patch is not "production" quality because you should review all other hw types you want to support and I take the info from /sys/class/net which is only available on 2.6 kernels. Kernel structure net_device contains the field hard_header_len but I think this is not available through /proc or /sys. Anyway, if not perfect, the patch doesn't break stuff for people where hping2 worked and it can help people having trouble because of their ifname. Phil --- getlhs.c.orig2007-01-11 00:52:26.000000000 +0100 +++ getlhs.c2007-01-11 00:55:57.000000000 +0100 @@ -11,6 +11,8 @@ /* $Id: getlhs.c,v 1.10 2003/07/25 12:11:24 njombart Exp $ */ #include <string.h> +#include <net/if_arp.h> +#include <stdio.h> #include "hping2.h" #include "globals.h" @@ -120,8 +122,46 @@ } else if ( strstr(ifname, "tr") ) { linkhdr_size = TRHDR_SIZE; return 0; -} -else +} else { + + /* Second chance: guess hardware type from /sys/class/net/<ifname> */ + int hwtype=0; + FILE *fh; + char path[256]; + strcpy(path,"/sys/class/net/"); + strncat(path, ifname, 20); + strcat(path, "/type"); + fh = fopen(path, "r"); + if (!fh) { + return -1; + } + if (fscanf(fh, "%d\n", &hwtype) != 1) { + return -1; + } + if (opt_debug) + printf("DEBUG: hwtype is %d\n", hwtype); + + switch(hwtype) { + case ARPHRD_ETHER: + linkhdr_size = ETHHDR_SIZE; + break; + case ARPHRD_LOOPBACK: + linkhdr_size = LOHDR_SIZE; + break; + case ARPHRD_IEEE80211: + linkhdr_size = WLANHDR_SIZE; + break; + case ARPHRD_PPP: + linkhdr_size = PPPHDR_SIZE_LINUX; + break; + case ARPHRD_ATM: + linkhdr_size = 0; + break; + default: return -1; + break; + } + return 0; +} } #endif /* (!defined OSTYPE_LINUX) || (defined FORCE_LIBPCAP) */ -- System Information: Debian Release: 4.0 APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.18-1-686 Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15) Versions of packages hping2 depends on: ii libc6 2.3.6.ds1-8 GNU C Library: Shared libraries hping2 recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]