diff options
author | Thomas Habets <thomas@habets.pp.se> | 2002-11-03 19:47:58 +0000 |
---|---|---|
committer | Thomas Habets <thomas@habets.pp.se> | 2002-11-03 19:47:58 +0000 |
commit | a524fe5e882c62e343b15248d5622c0ade8ad472 (patch) | |
tree | 907ee448d3a9016e271ed1d673adf8de319bce39 | |
parent | 5f6ee8c6c87558820184524db385e789abd7a924 (diff) | |
download | arping-a524fe5e882c62e343b15248d5622c0ade8ad472.tar.gz |
.
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | README | 24 | ||||
-rw-r--r-- | arping-2/arping.c (renamed from arping2.c) | 17 | ||||
-rw-r--r-- | arping-2/configure.in (renamed from configure.in) | 7 | ||||
-rwxr-xr-x | arping-2/install-sh (renamed from install-sh) | 0 | ||||
-rw-r--r-- | arping.c | 16 |
6 files changed, 66 insertions, 19 deletions
@@ -1,4 +1,4 @@ -# $Id: Makefile 713 2002-08-31 12:31:43Z marvin $ +# $Id: Makefile 737 2002-11-03 19:47:58Z marvin $ TARGETS=arping USE_NETIF=0 @@ -20,6 +20,17 @@ usage: @echo "Make doc will re-create the manpage" @echo "You may use make install after" @echo + @echo "Important note!" + @echo + @echo " Arping will only work with libnet 1.0.x, not 1.1.x" + @echo " BUT, arping2 will work with 1.1.x." + @echo + @echo " Create the BETA arping2 by typing 'make arping2'" + @echo " Arping2 has been known to work on linux, I'm still working" + @echo " on BSD and other support." + @echo + @echo " Read README for more details." + @echo doc: arping.yodl yodl2man -o arping.8 arping.yodl @@ -54,10 +65,10 @@ O_arping=arping.o arping: $(O_arping) gcc $(CFLAGS) -g -o $@ $(O_arping) `libnet-config --libs` -lpcap -O_arping2=arping2.c -arping2: $(O_arping2) - gcc -I/home/thompa/src/Libnet-1.1.0/include -L/home/thompa/src/Libnet-1.1.0/src -o arping2 arping2.c -lnet -lpcap -# gcc -I/home/thompa/src/Libnet-1.1.0/include -L/home/thompa/src/Libnet-1.1.0rc -o arping2 arping2.c -lnet -lpcap -lresolv -lnsl -lsocket +O_arping2=arping-2/arping.c +arping2: arping-2/arping +arping-2/arping: $(O_arping2) + gcc -I/usr/src/Libnet-1.1.0/include -L/usr/src/Libnet-1.1.0/src -o arping arping-2/arping.c -lnet -lpcap clean: rm -f *.o $(TARGETS) @@ -1,4 +1,4 @@ -$Id: README 699 2002-08-19 23:28:46Z marvin $ +$Id: README 737 2002-11-03 19:47:58Z marvin $ ARP Ping @@ -47,6 +47,23 @@ See 'Technical' at the bottom of this file. FAQ --- +Q: It doesn't compile! + +A: Arping won't work with libnet 1.1.x. This is due to a libnet 1.1.x + being completely different from 1.0.x. There is no real way to + write code that works on both 1.0.x and 1.1.x. + + Since I wanted to do some other things a bit differently, I wrote + arping 2.x. It doesn't support as many architectures yet, but I'm + working on it. + + Arping 2.x (BETA) is included in this release and can be created + with "make arping2". If it doesn't compile, check the Makefile and + adjust paths. + + Once I get Arping2 working on all architectures I'll setup so that + the right version is compiled automatically. +--- Q: After compiling arping without any problem, i test it first with localhost... but it doesn't respond. Isn't that strange? @@ -56,6 +73,11 @@ A: Not really, as you can see by typing 'ifconfig' the lo (local) interface and since packets to localhost does not go over any wire there is no need to identify which box is talking to which. There is only one. --- +Q: Arping can't ping anything! + +A: Check which interface is active with -v. If it's the wrong one, use -i + to set it right. +--- Q: Arping finds some hosts, but not others. why? BTW, I have several NICs. A: You have to choose interface with the -i switch if the default is wrong for diff --git a/arping2.c b/arping-2/arping.c index 7c66f3b..1699c5c 100644 --- a/arping2.c +++ b/arping-2/arping.c @@ -12,7 +12,7 @@ * * Also finds out IP of specified MAC * - * $Id: arping2.c 713 2002-08-31 12:31:43Z marvin $ + * $Id: arping.c 737 2002-11-03 19:47:58Z marvin $ */ /* * Copyright (C) 2000-2002 Thomas Habets <thomas@habets.pp.se> @@ -103,7 +103,7 @@ static void sigint(int i) */ static void usage(int ret) { - printf("ARPing %1.2f, by Thomas Habets <thomas@habets.pp.se>\n", + printf("ARPing %1.2f BETA, by Thomas Habets <thomas@habets.pp.se>\n", version); printf("usage: arping [ -qvrRd0bp ] [ -w <us> ] [ -S <host/ip> ] " "[ -T <host/ip ]\n" @@ -298,7 +298,6 @@ static void pingip_recv(const char *unused, struct pcap_pkthdr *h, strerror(errno)); sigint(0); } - heth = (void*)packet; harp = (void*)((char*)heth + LIBNET_ETH_H); @@ -691,6 +690,7 @@ int main(int argc, char **argv) } + parm = argv[optind]; /* @@ -733,7 +733,7 @@ int main(int argc, char **argv) * parse parm into dstmac */ if (mode == PINGMAC) { - u_int32_t n[6]; // 32bit because of alignment + unsigned char n[6]; if (optind + 1 != argc) { usage(1); } @@ -773,6 +773,13 @@ int main(int argc, char **argv) fprintf(stderr, "arping: pcap_lookupdev(): %s\n",ebuf); exit(1); } + // FIXME: check for other probably-not interfaces + if (!strncmp(ifname, "ipsec", 5)) { + fprintf(stderr, "arping: Um.. %s looks like the wrong " + "interface to use. Is it? " + "(-i switch)\n", ifname); + fprintf(stderr, "arping: using it anyway this time\n"); + } } /* @@ -782,7 +789,7 @@ int main(int argc, char **argv) fprintf(stderr, "arping: pcap_open_live(): %s\n",ebuf); exit(1); } -#ifdef HAVE_WEIRD_BSD +#ifdef HAVE_NET_BPF_H { u_int32_t on = 1; if (0 < (ioctl(pcap_fileno(pcap), BIOCIMMEDIATE, diff --git a/configure.in b/arping-2/configure.in index 3079a1d..e083609 100644 --- a/configure.in +++ b/arping-2/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in 713 2002-08-31 12:31:43Z marvin $ +dnl $Id: configure.in 737 2002-11-03 19:47:58Z marvin $ AC_INIT(arping2.c) AC_CONFIG_HEADER(config.h) @@ -24,12 +24,11 @@ case `uname -s` in ;; esac -AC_MSG_CHECKING(for my kind of explicit size type support) +AC_MSG_CHECKING(for explicit size type support) AC_TRY_COMPILE( [#include <sys/types.h>], [u_int32_t foo;], - AC_DEFINE(HAVE_ESIZE_TYPES, 1, - [Define this if your system has u_int32_t and such]) + AC_DEFINE(HAVE_ESIZE_TYPES, 1, [Define this if your system has u_int32_t and such]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) diff --git a/install-sh b/arping-2/install-sh index cbf15ed..cbf15ed 100755 --- a/install-sh +++ b/arping-2/install-sh @@ -12,7 +12,7 @@ * * Also finds out IP of specified MAC * - * $Id: arping.c 704 2002-08-27 00:57:19Z marvin $ + * $Id: arping.c 737 2002-11-03 19:47:58Z marvin $ */ /* * Copyright (C) 2000-2002 Thomas Habets <thomas@habets.pp.se> @@ -90,8 +90,8 @@ static struct timeval lastpacketsent; static const u_int ip_xmas = 0xffffffff; static pcap_t *pcap; -static struct bpf_program bpf_prog; -static struct in_addr net,mask; +//static struct bpf_program bpf_prog; +//static struct in_addr net,mask; #if 0 // Use this if you want to hard-code a default interface static char *ifname = "eth0"; @@ -298,7 +298,8 @@ static void handlepacket(const char *unused, struct pcap_pkthdr *h, } } else { /* ping ip */ - harp = (struct arphdr*)((char*)eth + sizeof(struct libnet_ethernet_hdr)); + harp = (struct arphdr*)((char*)eth + + sizeof(struct libnet_ethernet_hdr)); if ((htons(harp->ar_op) == ARPOP_REPLY) && (htons(harp->ar_pro) == ETH_P_IP) && (htons(harp->ar_hrd) == ARPHRD_ETHER)) { @@ -546,6 +547,13 @@ int main(int argc, char **argv) fprintf(stderr, "pcap_lookupdev(): %s\n", ebuf); exit(1); } + // FIXME: check for other probably-not interfaces + if (!strncmp(ifname, "ipsec", 5)) { + fprintf(stderr, "arping: Um.. %s looks like the wrong " + "interface to use. Is it? " + "(-i switch)\n", ifname); + fprintf(stderr, "arping: using it anyway this time\n"); + } } if (!(linkint = libnet_open_link_interface(ifname, ebuf))) { |