summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-07-27 05:28:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-07-27 05:28:36 +0000
commit879a8e2c8278fd56f7c865eda7a0100c0f916f76 (patch)
treee49460f0b92fbaca7b96c4bd6d0ce22de7ac7f62 /sys/net
parentfa205f69eda4643845eaa7e2eb0f0fd0f526194d (diff)
for AF_UNSPEC sockets, do not whack the ethernet address; this is what bpf
uses when it sends packets out. blame tqbf@rdist.org for this fix.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_ethersubr.c21
-rw-r--r--sys/net/if_fddisubr.c43
2 files changed, 36 insertions, 28 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 4dcba984205..744941d4891 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.22 1997/07/24 22:59:29 deraadt Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.23 1997/07/27 05:28:34 deraadt Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -183,7 +183,7 @@ ether_output(ifp, m0, dst, rt0)
{
u_int16_t etype;
int s, error = 0;
- u_char edst[6];
+ u_char edst[6], esrc[6];
register struct mbuf *m = m0;
register struct rtentry *rt;
struct mbuf *mcopy = (struct mbuf *)0;
@@ -230,7 +230,7 @@ ether_output(ifp, m0, dst, rt0)
#ifdef NS
case AF_NS:
etype = htons(ETHERTYPE_NS);
- bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
+ bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
(caddr_t)edst, sizeof (edst));
if (!bcmp((caddr_t)edst, (caddr_t)&ns_thishost, sizeof(edst)))
return (looutput(ifp, m, dst, rt));
@@ -242,7 +242,7 @@ ether_output(ifp, m0, dst, rt0)
#ifdef IPX
case AF_IPX:
etype = ETHERTYPE_IPX;
- bcopy((caddr_t)&satosipx(dst)->sipx_addr.ipx_host,
+ bcopy((caddr_t)&satosipx(dst)->sipx_addr.ipx_host,
(caddr_t)edst, sizeof (edst));
if (!bcmp((caddr_t)edst, (caddr_t)&ipx_thishost, sizeof(edst)))
return (looutput(ifp, m, dst, rt));
@@ -387,7 +387,8 @@ ether_output(ifp, m0, dst, rt0)
case AF_UNSPEC:
eh = (struct ether_header *)dst->sa_data;
- bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
+ bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
+ bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, sizeof (esrc));
/* AF_UNSPEC doesn't swap the byte order of the ether_type. */
etype = eh->ether_type;
break;
@@ -411,9 +412,13 @@ ether_output(ifp, m0, dst, rt0)
eh = mtod(m, struct ether_header *);
bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type,
sizeof(eh->ether_type));
- bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
- sizeof(eh->ether_shost));
+ bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
+ if (dst->sa_family == AF_UNSPEC)
+ bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost,
+ sizeof(eh->ether_shost));
+ else
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
+ sizeof(eh->ether_shost));
s = splimp();
/*
* Queue message on interface, and start output if interface
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 537962103ae..cb67ed47f8f 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_fddisubr.c,v 1.12 1997/07/24 22:59:31 deraadt Exp $ */
+/* $OpenBSD: if_fddisubr.c,v 1.13 1997/07/27 05:28:35 deraadt Exp $ */
/* $NetBSD: if_fddisubr.c,v 1.5 1996/05/07 23:20:21 christos Exp $ */
/*
@@ -131,7 +131,7 @@ fddi_output(ifp, m0, dst, rt0)
{
u_int16_t type;
int s, error = 0;
- u_char edst[6];
+ u_char edst[6], esrc[6];
register struct mbuf *m = m0;
register struct rtentry *rt;
struct mbuf *mcopy = (struct mbuf *)0;
@@ -178,7 +178,7 @@ fddi_output(ifp, m0, dst, rt0)
#ifdef IPX
case AF_IPX:
type = htons(ETHERTYPE_IPX);
- bcopy((caddr_t)&(((struct sockaddr_ipx*)dst)->sipx_addr.x_host),
+ bcopy((caddr_t)&(((struct sockaddr_ipx*)dst)->sipx_addr.x_host),
(caddr_t)edst, sizeof (edst));
if (!bcmp((caddr_t)edst, (caddr_t)&ipx_thishost, sizeof(edst)))
return (looutput(ifp, m, dst, rt));
@@ -190,7 +190,7 @@ fddi_output(ifp, m0, dst, rt0)
#ifdef NS
case AF_NS:
type = htons(ETHERTYPE_NS);
- bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
+ bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
(caddr_t)edst, sizeof (edst));
if (!bcmp((caddr_t)edst, (caddr_t)&ns_thishost, sizeof(edst)))
return (looutput(ifp, m, dst, rt));
@@ -288,8 +288,10 @@ fddi_output(ifp, m0, dst, rt0)
case AF_UNSPEC:
{
struct ether_header *eh;
+
eh = (struct ether_header *)dst->sa_data;
- bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
+ bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
+ bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, sizeof (esrc));
if (*edst & 1)
m->m_flags |= (M_BCAST|M_MCAST);
type = TYPEHTONS(eh->ether_type);
@@ -302,28 +304,24 @@ fddi_output(ifp, m0, dst, rt0)
fh = mtod(m, struct fddi_header *);
error = EPROTONOSUPPORT;
switch (fh->fddi_fc & (FDDIFC_C|FDDIFC_L|FDDIFC_F)) {
- case FDDIFC_LLC_ASYNC: {
+ case FDDIFC_LLC_ASYNC:
/* legal priorities are 0 through 7 */
if ((fh->fddi_fc & FDDIFC_Z) > 7)
- goto bad;
+ goto bad;
break;
- }
- case FDDIFC_LLC_SYNC: {
+ case FDDIFC_LLC_SYNC:
/* FDDIFC_Z bits reserved, must be zero */
if (fh->fddi_fc & FDDIFC_Z)
goto bad;
break;
- }
- case FDDIFC_SMT: {
+ case FDDIFC_SMT:
/* FDDIFC_Z bits must be non zero */
if ((fh->fddi_fc & FDDIFC_Z) == 0)
goto bad;
break;
- }
- default: {
+ default:
/* anything else is too dangerous */
- goto bad;
- }
+ goto bad;
}
error = 0;
if (fh->fddi_dhost[0] & 1)
@@ -348,7 +346,8 @@ fddi_output(ifp, m0, dst, rt0)
l = mtod(m, struct llc *);
l->llc_control = LLC_UI;
l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
- l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0;
+ l->llc_snap.org_code[0] = l->llc_snap.org_code[1] =
+ l->llc_snap.org_code[2] = 0;
bcopy((caddr_t) &type, (caddr_t) &l->llc_snap.ether_type,
sizeof(u_short));
}
@@ -361,12 +360,16 @@ fddi_output(ifp, m0, dst, rt0)
senderr(ENOBUFS);
fh = mtod(m, struct fddi_header *);
fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
- bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, sizeof (edst));
+ bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, sizeof (edst));
+ if (dst->sa_family == AF_UNSPEC)
+ bcopy((caddr_t)esrc, (caddr_t)fh->fddi_shost,
+ sizeof(fh->fddi_shost));
+ else
+ bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
+ sizeof(fh->fddi_shost));
#if NBPFILTER > 0
- queue_it:
+queue_it:
#endif
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
- sizeof(fh->fddi_shost));
s = splimp();
/*
* Queue message on interface, and start output if interface