Source-Changes-HG archive

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

[src/trunk]: src/sys/net Using DLT_APPLE_IP_OVER_IEEE1394.



details:   https://anonhg.NetBSD.org/src/rev/27ba45028169
branches:  trunk
changeset: 583431:27ba45028169
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Sat Aug 06 14:09:54 2005 +0000

description:
Using DLT_APPLE_IP_OVER_IEEE1394.

diffstat:

 sys/net/if_ieee1394.h     |  11 +++++++++-
 sys/net/if_ieee1394subr.c |  49 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 49 insertions(+), 11 deletions(-)

diffs (111 lines):

diff -r c60d11060387 -r 27ba45028169 sys/net/if_ieee1394.h
--- a/sys/net/if_ieee1394.h     Sat Aug 06 11:23:32 2005 +0000
+++ b/sys/net/if_ieee1394.h     Sat Aug 06 14:09:54 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394.h,v 1.4 2005/07/11 15:37:04 kiyohara Exp $ */
+/*     $NetBSD: if_ieee1394.h,v 1.5 2005/08/06 14:09:54 kiyohara Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -47,6 +47,15 @@
        u_int8_t        iha_offset[6];          /* unicast FIFO address */
 };
 
+/*
+ * BPF wants to see one of these.
+ */
+struct ieee1394_bpfhdr {
+       uint8_t         ibh_dhost[8];
+       uint8_t         ibh_shost[8];
+       uint16_t        ibh_type;
+};
+
 #ifdef _KERNEL
 
 /* pseudo header */
diff -r c60d11060387 -r 27ba45028169 sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Sat Aug 06 11:23:32 2005 +0000
+++ b/sys/net/if_ieee1394subr.c Sat Aug 06 14:09:54 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394subr.c,v 1.29 2005/07/11 15:37:05 kiyohara Exp $    */
+/*     $NetBSD: if_ieee1394subr.c,v 1.30 2005/08/06 14:09:54 kiyohara Exp $    */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.29 2005/07/11 15:37:05 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.30 2005/08/06 14:09:54 kiyohara Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -215,12 +215,21 @@
 
        if (mcopy)
                looutput(ifp, mcopy, dst, rt);
+       myaddr = (struct ieee1394_hwaddr *)LLADDR(ifp->if_sadl);
 #if NBPFILTER > 0
-       /* XXX: emulate DLT_EN10MB */
-       if (ifp->if_bpf)
-               bpf_mtap_et(ifp->if_bpf, etype, m0);
+       if (ifp->if_bpf) {
+               struct ieee1394_bpfhdr h;
+               if (unicast)
+                       memcpy(h.ibh_dhost, hwdst->iha_uid, 8);
+               else
+                       memcpy(h.ibh_dhost,
+                           ((const struct ieee1394_hwaddr *)
+                           ifp->if_broadcastaddr)->iha_uid, 8);
+               memcpy(h.ibh_shost, myaddr->iha_uid, 8);
+               h.ibh_type = etype;
+               bpf_mtap2(ifp->if_bpf, &h, sizeof(h), m0);
+       }
 #endif
-       myaddr = (struct ieee1394_hwaddr *)LLADDR(ifp->if_sadl);
        if ((ifp->if_flags & IFF_SIMPLEX) &&
            unicast &&
            memcmp(hwdst, myaddr, IEEE1394_ADDR_LEN) == 0)
@@ -383,9 +392,28 @@
        /* strip off the ieee1394 header */
        m_adj(m, sizeof(*iuh));
 #if NBPFILTER > 0
-       /* XXX: emulate DLT_EN10MB */
-       if (ifp->if_bpf)
-               bpf_mtap_et(ifp->if_bpf, iuh->iuh_etype, m);
+       if (ifp->if_bpf) {
+               struct ieee1394_bpfhdr h;
+               struct m_tag *mtag;
+               struct ieee1394_hwaddr *myaddr;
+
+               mtag = m_tag_locate(m,
+                   MTAG_FIREWIRE, MTAG_FIREWIRE_SENDER_EUID, 0);
+               if (mtag)
+                       memcpy(h.ibh_shost, mtag + 1, 8);
+               else
+                       memset(h.ibh_shost, 0, 8);
+               if (m->m_flags & M_BCAST)
+                       memcpy(h.ibh_dhost,
+                           ((const struct ieee1394_hwaddr *)
+                           ifp->if_broadcastaddr)->iha_uid, 8);
+               else {
+                       myaddr = (struct ieee1394_hwaddr *)LLADDR(ifp->if_sadl);
+                       memcpy(h.ibh_dhost, myaddr->iha_uid, 8);
+               }
+               h.ibh_type = htons(etype);
+               bpf_mtap2(ifp->if_bpf, &h, sizeof(h), m);
+       }
 #endif
 
        switch (etype) {
@@ -674,7 +702,8 @@
        ifp->if_broadcastaddr = (uint8_t *)baddr;
        LIST_INIT(&ic->ic_reassq);
 #if NBPFILTER > 0
-       bpfattach(ifp, DLT_EN10MB, 14); /* XXX */
+       bpfattach(ifp,
+           DLT_APPLE_IP_OVER_IEEE1394, sizeof(struct ieee1394_hwaddr));
 #endif
 }
 



Home | Main Index | Thread Index | Old Index