summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.pp.se>2000-09-09 22:20:30 +0000
committerThomas Habets <thomas@habets.pp.se>2000-09-09 22:20:30 +0000
commit979fec70742a70bb87cd64d49484de1cf0058505 (patch)
treed693815d995b20fac1b30a1389f1941af42e429a
parent11388bdc3cee74cd390d62851e486427b275991e (diff)
downloadarping-979fec70742a70bb87cd64d49484de1cf0058505.tar.gz
now compiles without gmake also picks a nice (existing) interface as
default
-rw-r--r--Makefile10
-rw-r--r--README8
-rw-r--r--arping.c16
3 files changed, 23 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 8446f29..87abdc4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile 97 2000-08-13 16:06:31Z marvin $
+# $Id: Makefile 120 2000-09-09 22:20:30Z marvin $
TARGETS=arping
USE_NETIF=0
@@ -9,7 +9,7 @@ CFLAGS=-g -I/usr/local/include -L/usr/local/lib -DUSE_NETIF=$(USE_NETIF) -DOPENB
usage:
@echo
- @echo "usage: (g)make [ target ]"
+ @echo "usage: make [ target ]"
@echo "Target can be openbsd or linux"
@echo
@@ -17,13 +17,13 @@ linux:
make USE_NETIF=1 LINUX=1 all
openbsd:
- gmake OPENBSD=1 all
+ make OPENBSD=1 all
all: $(TARGETS)
-%.o: %.c
- gcc -Wall $(CFLAGS) -c `libnet-config --defines` `libnet-config --cflags` $<
+arping.o: arping.c
+ gcc -Wall $(CFLAGS) -c `libnet-config --defines` `libnet-config --cflags` arping.c
O_arping=arping.o
arping: $(O_arping)
diff --git a/README b/README
index 427fab7..9ec27d1 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Id: README 97 2000-08-13 16:06:31Z marvin $
+$Id: README 120 2000-09-09 22:20:30Z marvin $
ARP Ping
@@ -86,8 +86,12 @@ A: Arping depends on libnet and libpcap, get libnet at:
---
Q: I get bus error on my bigendian box
-A: Damn, I thought I fixed those. Tell me how you got it and I'll try to fix it.
+A: Damn, I thought I fixed those. Tell me how you got it and I'll try to fix
+ it.
+---
+Q: I get "libnet_get_ipaddr(): no error" when I run arping with ip 0.0.0.0.
+A: Use the -0 switch.
License
-------
diff --git a/arping.c b/arping.c
index b53a68c..1e3cc2a 100644
--- a/arping.c
+++ b/arping.c
@@ -12,7 +12,7 @@
*
* Also finds out IP of specified MAC
*
- * $Id: arping.c 97 2000-08-13 16:06:31Z marvin $
+ * $Id: arping.c 120 2000-09-09 22:20:30Z marvin $
*/
/*
* Copyright (C) 2000 Marvin (marvin@nss.nu)
@@ -72,10 +72,11 @@ u_int ip_xmas = 0xffffffff;
pcap_t *pcap;
struct bpf_program bpf_prog;
struct in_addr net,mask;
-#if OPENBSD
-char *ifname = "le0";
-#else
+#if 0
+// Use this if you want to hard-code a default interface
char *ifname = "eth0";
+#else
+char *ifname = NULL;
#endif
u_long dip = 0;
u_char *packet;
@@ -324,6 +325,13 @@ int main(int argc, char **argv)
/*
* libnet init
*/
+ if (!ifname) {
+ if (!(ifname = pcap_lookupdev(ebuf))) {
+ fprintf(stderr, "pcap_lookupdev(): %s\n", ebuf);
+ exit(1);
+ }
+ }
+
if (!(linkint = libnet_open_link_interface(ifname, ebuf))) {
fprintf(stderr, "libnet_get_hwaddr(): %s\n", ebuf);
exit(1);