if_ethersubr.c (50477) | if_ethersubr.c (52248) |
---|---|
1/* 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 | 1/* 2 * Copyright (c) 1982, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 |
34 * $FreeBSD: head/sys/net/if_ethersubr.c 50477 1999-08-28 01:08:13Z peter $ | 34 * $FreeBSD: head/sys/net/if_ethersubr.c 52248 1999-10-15 05:07:00Z msmith $ |
35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" 39#include "opt_ipx.h" 40#include "opt_bdg.h" 41 42#include <sys/param.h> --- 84 unchanged lines hidden (view full) --- 127int 128ether_output(ifp, m0, dst, rt0) 129 register struct ifnet *ifp; 130 struct mbuf *m0; 131 struct sockaddr *dst; 132 struct rtentry *rt0; 133{ 134 short type; | 35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" 39#include "opt_ipx.h" 40#include "opt_bdg.h" 41 42#include <sys/param.h> --- 84 unchanged lines hidden (view full) --- 127int 128ether_output(ifp, m0, dst, rt0) 129 register struct ifnet *ifp; 130 struct mbuf *m0; 131 struct sockaddr *dst; 132 struct rtentry *rt0; 133{ 134 short type; |
135 int s, error = 0; 136 u_char edst[6]; | 135 int s, error = 0, hdrcmplt = 0; 136 u_char esrc[6], edst[6]; |
137 register struct mbuf *m = m0; 138 register struct rtentry *rt; 139 register struct ether_header *eh; 140 int off, len = m->m_pkthdr.len, loop_copy = 0; 141 int hlen; /* link layer header lenght */ 142 struct arpcom *ac = IFP2AC(ifp); 143 144 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) --- 176 unchanged lines hidden (view full) --- 321 type & 0xff, l->llc_dsap & 0xff, l->llc_ssap &0xff, 322 l->llc_control & 0xff); 323 324 } 325#endif /* LLC_DEBUG */ 326 } break; 327#endif /* LLC */ 328 | 137 register struct mbuf *m = m0; 138 register struct rtentry *rt; 139 register struct ether_header *eh; 140 int off, len = m->m_pkthdr.len, loop_copy = 0; 141 int hlen; /* link layer header lenght */ 142 struct arpcom *ac = IFP2AC(ifp); 143 144 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) --- 176 unchanged lines hidden (view full) --- 321 type & 0xff, l->llc_dsap & 0xff, l->llc_ssap &0xff, 322 l->llc_control & 0xff); 323 324 } 325#endif /* LLC_DEBUG */ 326 } break; 327#endif /* LLC */ 328 |
329 case pseudo_AF_HDRCMPLT: 330 hdrcmplt = 1; 331 eh = (struct ether_header *)dst->sa_data; 332 (void)memcpy(esrc, eh->ether_shost, sizeof (esrc)); 333 /* FALLTHROUGH */ 334 |
|
329 case AF_UNSPEC: 330 loop_copy = -1; /* if this is for us, don't do it */ 331 eh = (struct ether_header *)dst->sa_data; 332 (void)memcpy(edst, eh->ether_dhost, sizeof (edst)); 333 type = eh->ether_type; 334 break; 335 336 default: --- 8 unchanged lines hidden (view full) --- 345 */ 346 M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); 347 if (m == 0) 348 senderr(ENOBUFS); 349 eh = mtod(m, struct ether_header *); 350 (void)memcpy(&eh->ether_type, &type, 351 sizeof(eh->ether_type)); 352 (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); | 335 case AF_UNSPEC: 336 loop_copy = -1; /* if this is for us, don't do it */ 337 eh = (struct ether_header *)dst->sa_data; 338 (void)memcpy(edst, eh->ether_dhost, sizeof (edst)); 339 type = eh->ether_type; 340 break; 341 342 default: --- 8 unchanged lines hidden (view full) --- 351 */ 352 M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); 353 if (m == 0) 354 senderr(ENOBUFS); 355 eh = mtod(m, struct ether_header *); 356 (void)memcpy(&eh->ether_type, &type, 357 sizeof(eh->ether_type)); 358 (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); |
353 (void)memcpy(eh->ether_shost, ac->ac_enaddr, 354 sizeof(eh->ether_shost)); | 359 if (hdrcmplt) 360 (void)memcpy(eh->ether_shost, esrc, 361 sizeof(eh->ether_shost)); 362 else 363 (void)memcpy(eh->ether_shost, ac->ac_enaddr, 364 sizeof(eh->ether_shost)); |
355 356 /* 357 * If a simplex interface, and the packet is being sent to our 358 * Ethernet address or a broadcast address, loopback a copy. 359 * XXX To make a simplex device behave exactly like a duplex 360 * device, we should copy in the case of sending to our own 361 * ethernet address (thus letting the original actually appear 362 * on the wire). However, we don't do that here for security --- 474 unchanged lines hidden --- | 365 366 /* 367 * If a simplex interface, and the packet is being sent to our 368 * Ethernet address or a broadcast address, loopback a copy. 369 * XXX To make a simplex device behave exactly like a duplex 370 * device, we should copy in the case of sending to our own 371 * ethernet address (thus letting the original actually appear 372 * on the wire). However, we don't do that here for security --- 474 unchanged lines hidden --- |