Patch from dcjm@cs.ed.ac.uk (Dave Matthews)...
authorDavid Greenman <davidg@Root.COM>
Mon, 31 Jan 1994 07:34:36 +0000 (07:34 +0000)
committerDavid Greenman <davidg@Root.COM>
Mon, 31 Jan 1994 07:34:36 +0000 (07:34 +0000)
Yes, I know that IFADDR ioctl is supposed to be deprecated... Note
that the patch was modified by me to fit better into the driver. -DG

...

While porting CAP to 386bsd/pk0.2.4 and now to FreeBSD Release 1.0
I found a couple of bugs associated with the packet filter. Here
are the fixes.  I'm posting them here because they apply to
FreeBSD and 386bsd/pk0.2.4 and possibly to other *BSD.

The first occurs when using the packet filter to write raw
ethernet packets.  The header consisting of the sender and
destination addresses and the protocol is removed and later
added back on, but with the byte order of the protocol reversed.
The fix ensures that the byte order in the protocol field is
swapped when it is removed.

The second fix ensures that SIOCGIFADDR works for BPF as claimed
in the man pages, by adding it to the ed driver.  Similar fixes
will be needed for other ethernet drivers.
Dave Matthews.

sys/i386/isa/if_ed.c
sys/net/bpf.c

index c4ffdf8..d7c7a92 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /*
  */
 
 /*
- * $Id: if_ed.c,v 1.28 1994/01/11 23:28:21 ats Exp $
+ * $Id: if_ed.c,v 1.29 1994/01/25 22:52:06 ats Exp $
  */
 
 #include "ed.h"
  */
 
 #include "ed.h"
@@ -1945,6 +1945,15 @@ ed_ioctl(ifp, command, data)
                }
                break;
 
                }
                break;
 
+       case SIOCGIFADDR:
+               {
+                       struct sockaddr *sa;
+                       sa = (struct sockaddr *)&ifr->ifr_data;
+                       bcopy((caddr_t)sc->arpcom.ac_enaddr,
+                           (caddr_t) sa->sa_data, ETHER_ADDR_LEN);
+               }
+               break;
+
        case SIOCSIFFLAGS:
                /*
                 * If interface is marked down and it is running, then stop it
        case SIOCSIFFLAGS:
                /*
                 * If interface is marked down and it is running, then stop it
index 614452e..6b77591 100644 (file)
@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)bpf.c 7.5 (Berkeley) 7/15/91
  * SUCH DAMAGE.
  *
  *     from: @(#)bpf.c 7.5 (Berkeley) 7/15/91
- *     $Id: bpf.c,v 1.2 1993/10/16 17:43:03 rgrimes Exp $
+ *     $Id: bpf.c,v 1.3 1993/12/19 00:51:55 wollman Exp $
  */
 
 #include "bpfilter.h"
  */
 
 #include "bpfilter.h"
@@ -200,6 +200,14 @@ bpf_movein(uio, linktype, mp, sockp)
                error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);
                if (error)
                        goto bad;
                error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);
                if (error)
                        goto bad;
+
+               if (linktype == DLT_EN10MB) {
+                       /* Adjust the protocol field. */
+                       struct ether_header *eh;
+                       eh = (struct ether_header *)sockp->sa_data;
+                       eh->ether_type = ntohs(eh->ether_type);
+               }
+
        }
        error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);
        if (!error)
        }
        error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);
        if (!error)