if_ethersubr.c (59562606b9d3a958fa83ee8eb41ebc8da8ac6f73) | if_ethersubr.c (1158dfb736ca295317a33b77498ec87f05b4c41f) |
---|---|
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 * $Id: if_ethersubr.c,v 1.28 1996/12/10 07:29:48 davidg Exp $ | 34 * $Id: if_ethersubr.c,v 1.29 1996/12/13 21:28:38 wollman Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> 42#include <sys/protosw.h> --- 53 unchanged lines hidden (view full) --- 96 97#define llc_snap_org_code llc_un.type_snap.org_code 98#define llc_snap_ether_type llc_un.type_snap.ether_type 99 100extern u_char at_org_code[ 3 ]; 101extern u_char aarp_org_code[ 3 ]; 102#endif NETATALK 103 | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/malloc.h> 41#include <sys/mbuf.h> 42#include <sys/protosw.h> --- 53 unchanged lines hidden (view full) --- 96 97#define llc_snap_org_code llc_un.type_snap.org_code 98#define llc_snap_ether_type llc_un.type_snap.ether_type 99 100extern u_char at_org_code[ 3 ]; 101extern u_char aarp_org_code[ 3 ]; 102#endif NETATALK 103 |
104static int ether_resolvemulti __P((struct ifnet *, struct sockaddr **, 105 struct sockaddr *)); |
|
104u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 105#define senderr(e) { error = (e); goto bad;} 106 107/* 108 * Ethernet output routine. 109 * Encapsulate a packet of type family for the local net. 110 * Use trailer local net encapsulation if enough data in first 111 * packet leaves a multiple of 512 bytes of data in remainder. --- 534 unchanged lines hidden (view full) --- 646{ 647 register struct ifaddr *ifa; 648 register struct sockaddr_dl *sdl; 649 650 ifp->if_type = IFT_ETHER; 651 ifp->if_addrlen = 6; 652 ifp->if_hdrlen = 14; 653 ifp->if_mtu = ETHERMTU; | 106u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 107#define senderr(e) { error = (e); goto bad;} 108 109/* 110 * Ethernet output routine. 111 * Encapsulate a packet of type family for the local net. 112 * Use trailer local net encapsulation if enough data in first 113 * packet leaves a multiple of 512 bytes of data in remainder. --- 534 unchanged lines hidden (view full) --- 648{ 649 register struct ifaddr *ifa; 650 register struct sockaddr_dl *sdl; 651 652 ifp->if_type = IFT_ETHER; 653 ifp->if_addrlen = 6; 654 ifp->if_hdrlen = 14; 655 ifp->if_mtu = ETHERMTU; |
656 ifp->if_resolvemulti = ether_resolvemulti; |
|
654 if (ifp->if_baudrate == 0) 655 ifp->if_baudrate = 10000000; 656 ifa = ifnet_addrs[ifp->if_index - 1]; 657 if (ifa == 0) { 658 printf("ether_ifattach: no lladdr!\n"); 659 return; 660 } 661 sdl = (struct sockaddr_dl *)ifa->ifa_addr; --- 279 unchanged lines hidden (view full) --- 941 error = EINVAL; 942 } else { 943 ifp->if_mtu = ifr->ifr_mtu; 944 } 945 break; 946 } 947 return (error); 948} | 657 if (ifp->if_baudrate == 0) 658 ifp->if_baudrate = 10000000; 659 ifa = ifnet_addrs[ifp->if_index - 1]; 660 if (ifa == 0) { 661 printf("ether_ifattach: no lladdr!\n"); 662 return; 663 } 664 sdl = (struct sockaddr_dl *)ifa->ifa_addr; --- 279 unchanged lines hidden (view full) --- 944 error = EINVAL; 945 } else { 946 ifp->if_mtu = ifr->ifr_mtu; 947 } 948 break; 949 } 950 return (error); 951} |
952 953int 954ether_resolvemulti(ifp, llsa, sa) 955 struct ifnet *ifp; 956 struct sockaddr **llsa; 957 struct sockaddr *sa; 958{ 959 struct sockaddr_dl *sdl; 960 struct sockaddr_in *sin; 961 u_char *e_addr; 962 963 switch(sa->sa_family) { 964 case AF_LINK: 965 sdl = (struct sockaddr_dl *)sa; 966 e_addr = LLADDR(sdl); 967 if ((e_addr[0] & 1) != 1) 968 return EADDRNOTAVAIL; 969 *llsa = 0; 970 return 0; 971 972#ifdef INET 973 case AF_INET: 974 sin = (struct sockaddr_in *)sa; 975 if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) 976 return EADDRNOTAVAIL; 977 MALLOC(sdl, struct sockaddr_dl *, sizeof *sdl, M_IFMADDR, 978 M_WAITOK); 979 sdl->sdl_len = sizeof *sdl; 980 sdl->sdl_family = AF_LINK; 981 sdl->sdl_index = ifp->if_index; 982 sdl->sdl_type = IFT_ETHER; 983 sdl->sdl_nlen = 0; 984 sdl->sdl_alen = ETHER_ADDR_LEN; 985 sdl->sdl_slen = 0; 986 e_addr = LLADDR(sdl); 987 ETHER_MAP_IP_MULTICAST(&sin->sin_addr, e_addr); 988 *llsa = (struct sockaddr *)sdl; 989 return 0; 990#endif 991 992 default: 993 /* 994 * Well, the text isn't quite right, but it's the name 995 * that counts... 996 */ 997 return EAFNOSUPPORT; 998 } 999} |
|