Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net * Add the ability to change the data link type on th...



details:   https://anonhg.NetBSD.org/src/rev/cef4a279a2e9
branches:  trunk
changeset: 472873:cef4a279a2e9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue May 11 02:11:08 1999 +0000

description:
* Add the ability to change the data link type on the fly.
* Define two more data link types: NetBSD PPP-over-serial and NetBSD
PPP-over-Ethernet.  (Different PPP encaps have different header formats!)

diffstat:

 sys/net/bpf.c |  30 +++++++++++++++++++++++++++++-
 sys/net/bpf.h |   7 ++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diffs (72 lines):

diff -r 659fba08919b -r cef4a279a2e9 sys/net/bpf.c
--- a/sys/net/bpf.c     Tue May 11 00:04:52 1999 +0000
+++ b/sys/net/bpf.c     Tue May 11 02:11:08 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.46 1998/12/04 11:04:37 bouyer Exp $  */
+/*     $NetBSD: bpf.c,v 1.47 1999/05/11 02:11:08 thorpej Exp $ */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -1339,6 +1339,34 @@
 #endif
 }
 
+/*
+ * Change the data link type of a BPF instance.
+ */
+void
+bpf_change_type(driverp, dlt, hdrlen)
+       caddr_t *driverp;
+       u_int dlt, hdrlen;
+{
+       struct bpf_if *bp;
+
+       for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) {
+               if (bp->bif_driverp == (struct bpf_if **)driverp)
+                       break;
+       }
+       if (bp == NULL)
+               panic("bpf_change_type");
+
+       bp->bif_dlt = dlt;
+
+       /*
+        * Compute the length of the bpf header.  This is not necessarily
+        * equal to SIZEOF_BPF_HDR because we want to insert spacing such
+        * that the network layer header begins on a longword boundary (for
+        * performance reasons and to alleviate alignment restrictions).
+        */
+       bp->bif_hdrlen = BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) - hdrlen;
+}
+
 #if BSD >= 199103
 /* XXX This routine belongs in net/if.c. */
 /*
diff -r 659fba08919b -r cef4a279a2e9 sys/net/bpf.h
--- a/sys/net/bpf.h     Tue May 11 00:04:52 1999 +0000
+++ b/sys/net/bpf.h     Tue May 11 02:11:08 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.h,v 1.22 1998/07/25 11:31:18 explorer Exp $        */
+/*     $NetBSD: bpf.h,v 1.23 1999/05/11 02:11:08 thorpej Exp $ */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -190,6 +190,10 @@
 #define DLT_HIPPI      15      /* HIPPI */
 #define DLT_HDLC       16      /* HDLC framing */
 
+/* NetBSD-specific types */
+#define        DLT_PPP_SERIAL  50      /* PPP over serial (async and sync) */
+#define        DLT_PPP_ETHER   51      /* PPP over Ethernet */
+
 /*
  * The instruction encondings.
  */
@@ -267,6 +271,7 @@
 void    bpf_tap __P((caddr_t, u_char *, u_int));
 void    bpf_mtap __P((caddr_t, struct mbuf *));
 void    bpfattach __P((caddr_t *, struct ifnet *, u_int, u_int));
+void    bpf_change_type __P((caddr_t *, u_int, u_int));
 void    bpfilterattach __P((int));
 #endif
 



Home | Main Index | Thread Index | Old Index