summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.pp.se>2000-09-28 20:45:19 +0000
committerThomas Habets <thomas@habets.pp.se>2000-09-28 20:45:19 +0000
commit32a943cf55fcff10363c886385a16a68fc60c59f (patch)
tree26cd3cae36e0ce6747e2276f62f8673c6b4f05cb
parent9b69d920a6a3e1083f9e197e35eb4e17167d5330 (diff)
downloadarping-32a943cf55fcff10363c886385a16a68fc60c59f.tar.gz
freebsd added
-rw-r--r--Makefile15
-rw-r--r--README8
-rw-r--r--arping.c23
-rw-r--r--freebsd.h50
4 files changed, 81 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 2dfd47e..d39fa09 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,38 @@
-# $Id: Makefile 138 2000-09-15 17:22:30Z marvin $
+# $Id: Makefile 143 2000-09-28 20:45:19Z marvin $
TARGETS=arping
USE_NETIF=0
OPENBSD=0
LINUX=0
SOLARIS=0
+FREEBSD=0
# explicit pcap include dir is for redhat which is fux0red
-CFLAGS=-g -I/usr/local/include -L/usr/local/lib -DUSE_NETIF=$(USE_NETIF) -DOPENBSD=$(OPENBSD) -DLINUX=$(LINUX) -DSOLARIS=$(SOLARIS) -I/usr/include/pcap
+CFLAGS=-g -I/usr/local/include -L/usr/local/lib -DUSE_NETIF=$(USE_NETIF) -DOPENBSD=$(OPENBSD) -DLINUX=$(LINUX) -DSOLARIS=$(SOLARIS) -DFREEBSD=$(FREEBSD) -I/usr/include/pcap
usage:
@echo
@echo "usage: make [ target ]"
- @echo "Target can be openbsd, linux or solaris"
+ @echo "Target can be freebsd, openbsd, linux or solaris"
+ @echo
+ @echo "You may use make install after"
@echo
linux:
make USE_NETIF=1 LINUX=1 all
+freebsd:
+ make USE_NETIF=1 FREEBSD=1 all
+
openbsd:
make OPENBSD=1 all
solaris:
make USE_NETIF=0 SOLARIS=1 all
+install:
+ install -c arping /usr/local/bin/arping
+
all: $(TARGETS)
arping.o: arping.c
diff --git a/README b/README
index 379eb0a..886cd9c 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Id: README 138 2000-09-15 17:22:30Z marvin $
+$Id: README 143 2000-09-28 20:45:19Z marvin $
ARP Ping
@@ -33,9 +33,11 @@ call on his cellphone about 15 secs after he accidentally 'stole' an IP, oops).
Compiling
---------
-Type make linux to compile under linux and make openbsd to compile under
-openbsd. Follow this pattern for compilation under solaris.
+Type 'make linux' to compile under linux and 'make openbsd' to compile under
+openbsd. Follow this pattern for compilation under solaris and freebsd.
If you have some other OS, try all before mailing me.
+
+'make install' will copy arping to /usr/local/bin.
How it does it
--------------
diff --git a/arping.c b/arping.c
index 7f09efc..4c21e1b 100644
--- a/arping.c
+++ b/arping.c
@@ -12,7 +12,7 @@
*
* Also finds out IP of specified MAC
*
- * $Id: arping.c 139 2000-09-18 19:12:17Z marvin $
+ * $Id: arping.c 143 2000-09-28 20:45:19Z marvin $
*/
/*
* Copyright (C) 2000 Marvin (marvin@nss.nu)
@@ -34,14 +34,6 @@
#include <stdlib.h>
#include <unistd.h>
-#if USE_NETIF
-#include <net/if.h>
-#include <net/if_arp.h>
-#endif
-
-#include <libnet.h>
-#include <pcap.h>
-
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif
@@ -50,6 +42,19 @@
#define ETH_P_IP 0x0800
#endif
+#if FREEBSD
+#include <sys/socket.h>
+#include "freebsd.h"
+#endif
+
+#if USE_NETIF
+#include <net/if.h>
+#include <net/if_arp.h>
+#endif
+
+#include <libnet.h>
+#include <pcap.h>
+
#if OPENBSD
#include "openbsd.h"
#endif
diff --git a/freebsd.h b/freebsd.h
new file mode 100644
index 0000000..cd4b803
--- /dev/null
+++ b/freebsd.h
@@ -0,0 +1,50 @@
+/* $Id: freebsd.h 143 2000-09-28 20:45:19Z marvin $ */
+
+#define __u8 u_int8_t
+#define __u16 u_int16_t
+#define __u32 u_int32_t
+
+struct ethhdr
+{
+ __u8 h_dest[ETH_ALEN];/* destination eth addr*/
+ __u8 h_source[ETH_ALEN];/* source ether addr*/
+ __u16 h_proto;/* packet type ID field*/
+};
+
+struct icmphdr {
+ __u8 type;
+ __u8 code;
+ __u16 checksum;
+ union {
+ struct {
+ __u16 id;
+ __u16 sequence;
+ } echo;
+ __u32 gateway;
+ struct {
+ __u16 unused;
+ __u16 mtu;
+ } frag;
+ } un;
+};
+
+struct iphdr
+{
+#ifdef LIBNET_LIL_ENDIAN
+ unsigned int ihl:4;
+ unsigned int version:4;
+#else
+ unsigned int version:4;
+ unsigned int ihl:4;
+#endif
+ u_int8_t tos;
+ u_int16_t tot_len;
+ u_int16_t id;
+ u_int16_t frag_off;
+ u_int8_t ttl;
+ u_int8_t protocol;
+ u_int16_t check;
+ u_int32_t saddr;
+ u_int32_t daddr;
+ /*The options start here. */
+};