summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2010-04-01 13:02:03 -0700
committerSam Roberts <vieuxtech@gmail.com>2010-04-01 13:02:03 -0700
commit8d65a712a8a9831b066c5d0fd8585360824d2bdf (patch)
tree5783056c37eb341c0601181dee1081c889bd8557
parent69f23b7b8cb4997d8a38d1d92dbb548aaff46eb9 (diff)
downloadlibnet-8d65a712a8a9831b066c5d0fd8585360824d2bdf.tar.gz
Removed dependency on net/bpf.h, and on pcap.h.
-rw-r--r--libnet/configure.in1
-rw-r--r--libnet/include/bpf.h5
-rw-r--r--libnet/include/libnet/libnet-structures.h13
-rw-r--r--libnet/src/libnet_build_link.c24
-rw-r--r--libnet/src/libnet_link_linux.c9
5 files changed, 32 insertions, 20 deletions
diff --git a/libnet/configure.in b/libnet/configure.in
index 1e5bb88..6d353e0 100644
--- a/libnet/configure.in
+++ b/libnet/configure.in
@@ -67,7 +67,6 @@ AC_ARG_WITH(
)
AC_CHECK_HEADERS([net/pfilt.h sys/net/nit.h net/raw.h sys/dlpi.h linux/socket.h])
-AC_CHECK_HEADERS([net/bpf.h])
AC_MSG_CHECKING(link-layer packet interface type)
diff --git a/libnet/include/bpf.h b/libnet/include/bpf.h
index 8648a9a..4ace5ae 100644
--- a/libnet/include/bpf.h
+++ b/libnet/include/bpf.h
@@ -1,3 +1,8 @@
+/*
+It's not clear what purpose including this file with libnet serves. Is it just
+for the DLT_ values? On systems with bpf, it should be present in the system
+headers! Also, it's definitions have conflicted with the system's on AIX.
+*/
/*-
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
diff --git a/libnet/include/libnet/libnet-structures.h b/libnet/include/libnet/libnet-structures.h
index a229db1..912c321 100644
--- a/libnet/include/libnet/libnet-structures.h
+++ b/libnet/include/libnet/libnet-structures.h
@@ -204,6 +204,19 @@ struct libnet_context
uint32_t n_pblocks; /* number of pblocks */
int link_type; /* link-layer type, a DLT_ value. */
+ /* These are the only values used by libnet (see libnet_build_arp and
+ * libnet_build_link). Other values are assigned by the various
+ * libnet_link_*.c OS support functions, but are not yet used or supported,
+ * they are effectively dead code. <pcap.h> claims these two are invariant
+ * across operating systems... hopefully it is correct!
+ */
+#ifndef DLT_EN10MB
+# define DLT_EN10MB 1 /* Ethernet (10Mb) */
+#endif
+#ifndef DLT_IEEE802
+# define DLT_IEEE802 6 /* IEEE 802 Networks */
+#endif
+
int link_offset; /* link-layer header size */
int aligner; /* used to align packets */
char *device; /* device name */
diff --git a/libnet/src/libnet_build_link.c b/libnet/src/libnet_build_link.c
index 0f52e07..4c2d0f3 100644
--- a/libnet/src/libnet_build_link.c
+++ b/libnet/src/libnet_build_link.c
@@ -41,12 +41,6 @@
#include "../include/win32/libnet.h"
#endif
-#ifdef HAVE_NET_BPF_H
-# include <net/bpf.h>
-#else
-# include <pcap.h>
-#endif
-
libnet_ptag_t
libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
@@ -57,25 +51,23 @@ const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
{
/* add FDDI */
case DLT_EN10MB:
- return (libnet_build_ethernet(dst, src, type, payload, payload_s, l,
- ptag));
+ return libnet_build_ethernet(dst, src, type, payload, payload_s, l,
+ ptag);
case DLT_IEEE802:
- return (libnet_build_token_ring(LIBNET_TOKEN_RING_FRAME,
+ return libnet_build_token_ring(LIBNET_TOKEN_RING_FRAME,
LIBNET_TOKEN_RING_LLC_FRAME, dst, src, LIBNET_SAP_SNAP,
LIBNET_SAP_SNAP, 0x03, org, type, payload, payload_s,
- l, ptag));
- default:
- break;
+ l, ptag);
}
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"%s(): linktype %d not supported\n", __func__, l->link_type);
- return (-1);
+ return -1;
}
libnet_ptag_t
libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type, libnet_t *l)
{
- uint8_t org[3] = {0x00, 0x00, 0x00};
+ uint8_t org[3] = {0x00, 0x00, 0x00};
switch (l->link_type)
{
/* add FDDI */
@@ -85,13 +77,9 @@ libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type, lib
return (libnet_autobuild_token_ring(LIBNET_TOKEN_RING_FRAME,
LIBNET_TOKEN_RING_LLC_FRAME, dst, LIBNET_SAP_SNAP,
LIBNET_SAP_SNAP, 0x03, org, TOKEN_RING_TYPE_IP, l));
- default:
- break;
}
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"%s(): linktype %d not supported\n", __func__, l->link_type);
return (-1);
}
-/* EOF */
-
diff --git a/libnet/src/libnet_link_linux.c b/libnet/src/libnet_link_linux.c
index 995db31..f87502d 100644
--- a/libnet/src/libnet_link_linux.c
+++ b/libnet/src/libnet_link_linux.c
@@ -54,7 +54,14 @@
#include "../include/libnet.h"
-#include <pcap.h>
+/* These should not vary across linux systems, and are only defined in
+ * <pcap-bpf.h>, included from <pcap.h>, but since we have no other dependency
+ * on libpcap right now, define locally. I'm not sure if this is a good idea,
+ * but we'll try.
+ */
+#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
+#define DLT_FDDI 10 /* FDDI */
+#define DLT_RAW 12 /* raw IP */
#include "../include/gnuc.h"
#ifdef HAVE_OS_PROTO_H