summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-26 09:14:51 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-26 09:14:51 +0000
commitf0b182f9d9696e667725d437a0b5229ff27bbcda (patch)
tree9906833c64f6ccb692e2ee62b410b81ddbd5641f
parenta12e9c046bba20015516fbd9444e1a63f4e25ca9 (diff)
convert DLT_LOOP header to network-order u_int32_t
-rw-r--r--sys/net/if_loop.c10
-rw-r--r--sys/net/if_tun.c24
-rw-r--r--sys/net/if_tun.h6
-rw-r--r--usr.sbin/ppp/tun.h8
-rw-r--r--usr.sbin/tcpdump/print-null.c4
5 files changed, 24 insertions, 28 deletions
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 51e575b3cf4..5a5de07700a 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_loop.c,v 1.9 1998/06/04 23:11:38 deraadt Exp $ */
+/* $OpenBSD: if_loop.c,v 1.10 1998/06/26 09:14:37 deraadt Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
@@ -111,11 +111,11 @@ loopattach(n)
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
ifp->if_type = IFT_LOOP;
- ifp->if_hdrlen = 4;
+ ifp->if_hdrlen = sizeof(u_int32_t);
ifp->if_addrlen = 0;
if_attachhead(ifp);
#if NBPFILTER > 0
- bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(u_int));
+ bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(u_int32_t));
#endif
}
}
@@ -148,10 +148,10 @@ looutput(ifp, m, dst, rt)
* try to free it or keep a pointer to it).
*/
struct mbuf m0;
- u_int af = dst->sa_family;
+ u_int32_t af = htonl(dst->sa_family);
m0.m_next = m;
- m0.m_len = 4;
+ m0.m_len = sizeof(af);
m0.m_data = (char *)&af;
bpf_mtap(ifp->if_bpf, &m0);
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index d2252bc9489..bc2b30af73d 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.22 1997/12/31 06:30:30 deraadt Exp $ */
+/* $OpenBSD: if_tun.c,v 1.23 1998/06/26 09:14:39 deraadt Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -135,7 +135,7 @@ tunattach(unused)
ifp->if_flags = IFF_POINTOPOINT;
ifp->if_type = IFT_PROPVIRTUAL;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
- ifp->if_hdrlen = sizeof(struct tunnel_header);
+ ifp->if_hdrlen = sizeof(u_int32_t);
ifp->if_collisions = 0;
ifp->if_ierrors = 0;
ifp->if_oerrors = 0;
@@ -143,8 +143,7 @@ tunattach(unused)
ifp->if_opackets = 0;
if_attach(ifp);
#if NBPFILTER > 0
- bpfattach(&ifp->if_bpf, ifp, DLT_NULL,
- sizeof(struct tunnel_header));
+ bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int32_t));
#endif
}
}
@@ -332,8 +331,8 @@ tun_output(ifp, m0, dst, rt)
struct rtentry *rt;
{
struct tun_softc *tp = ifp->if_softc;
- struct tunnel_header *th;
int s;
+ u_int32_t *af;
TUNDEBUG(("%s: tun_output\n", ifp->if_xname));
@@ -345,9 +344,10 @@ tun_output(ifp, m0, dst, rt)
}
ifp->if_lastchange = time;
- M_PREPEND(m0, sizeof(struct tunnel_header), M_DONTWAIT);
- th = mtod(m0, struct tunnel_header *);
- th->tun_af = dst->sa_family;
+
+ M_PREPEND(m0, sizeof(*af), M_DONTWAIT);
+ af = mtod(m0, u_int32_t *);
+ *af = htonl(dst->sa_family);
#if NBPFILTER > 0
if (ifp->if_bpf)
@@ -366,7 +366,7 @@ tun_output(ifp, m0, dst, rt)
splx(s);
ifp->if_opackets++;
- ifp->if_obytes += m0->m_pkthdr.len + sizeof(struct tunnel_header);
+ ifp->if_obytes += m0->m_pkthdr.len + sizeof(*af);
if (tp->tun_flags & TUN_RWAIT) {
tp->tun_flags &= ~TUN_RWAIT;
@@ -544,7 +544,7 @@ tunwrite(dev, uio, ioflag)
int unit;
struct ifnet *ifp;
struct ifqueue *ifq;
- struct tunnel_header *th;
+ u_int32_t *th;
struct mbuf *top, **mp, *m;
int isr;
int error=0, s, tlen, mlen;
@@ -598,13 +598,13 @@ tunwrite(dev, uio, ioflag)
bpf_mtap(ifp->if_bpf, top);
#endif
- th = mtod(top, struct tunnel_header *);
+ th = mtod(top, u_int32_t *);
/* strip the tunnel header */
top->m_data += sizeof(*th);
top->m_len -= sizeof(*th);
top->m_pkthdr.len -= sizeof(*th);
- switch (th->tun_af) {
+ switch (ntohl(*th)) {
#ifdef INET
case AF_INET:
ifq = &ipintrq;
diff --git a/sys/net/if_tun.h b/sys/net/if_tun.h
index ca2bbb8c4f8..5ded0962bb9 100644
--- a/sys/net/if_tun.h
+++ b/sys/net/if_tun.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.h,v 1.6 1997/08/02 09:56:28 deraadt Exp $ */
+/* $OpenBSD: if_tun.h,v 1.7 1998/06/26 09:14:40 deraadt Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@@ -34,10 +34,6 @@
#define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET)
-struct tunnel_header {
- u_int32_t tun_af; /* adress family */
-};
-
/* Maximum packet size */
#define TUNMTU 3000
diff --git a/usr.sbin/ppp/tun.h b/usr.sbin/ppp/tun.h
index 5458f1f178e..6a9bcab1ceb 100644
--- a/usr.sbin/ppp/tun.h
+++ b/usr.sbin/ppp/tun.h
@@ -23,19 +23,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tun.h,v 1.2 1997/12/21 14:27:20 brian Exp $
+ * $Id: tun.h,v 1.3 1998/06/26 09:14:46 deraadt Exp $
*/
struct tun_data {
#ifdef __OpenBSD__
- struct tunnel_header head;
+ u_int32_t head;
#endif
u_char data[MAX_MRU];
};
#ifdef __OpenBSD__
-#define tun_fill_header(f,proto) do { (f).head.tun_af = (proto); } while (0)
-#define tun_check_header(f,proto) ((f).head.tun_af == (proto))
+#define tun_fill_header(f,proto) do { (f).head = htonl(proto); } while (0)
+#define tun_check_header(f,proto) ((f).head == htonl(proto))
#else
#define tun_fill_header(f,proto) do { } while (0)
#define tun_check_header(f,proto) (1)
diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c
index 3be3383b1d3..62340b73926 100644
--- a/usr.sbin/tcpdump/print-null.c
+++ b/usr.sbin/tcpdump/print-null.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.7 1997/07/25 20:12:26 mickey Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-null.c,v 1.8 1998/06/26 09:14:50 deraadt Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -109,7 +109,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
null_print(p, length, family);
- switch (family) {
+ switch (ntohl(family)) {
case AF_INET:
ip_print(pkt, length);
break;