1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1989, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33df8bae1dSRodney W. Grimes * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 34d3628763SRodney W. Grimes * $Id: if_ethersubr.c,v 1.8.2.1 1995/06/03 04:46:21 davidg Exp $ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37df8bae1dSRodney W. Grimes #include <sys/param.h> 38df8bae1dSRodney W. Grimes #include <sys/systm.h> 39df8bae1dSRodney W. Grimes #include <sys/kernel.h> 40df8bae1dSRodney W. Grimes #include <sys/malloc.h> 41df8bae1dSRodney W. Grimes #include <sys/mbuf.h> 42df8bae1dSRodney W. Grimes #include <sys/protosw.h> 43df8bae1dSRodney W. Grimes #include <sys/socket.h> 44df8bae1dSRodney W. Grimes #include <sys/ioctl.h> 45df8bae1dSRodney W. Grimes #include <sys/errno.h> 46df8bae1dSRodney W. Grimes #include <sys/syslog.h> 47df8bae1dSRodney W. Grimes 48df8bae1dSRodney W. Grimes #include <machine/cpu.h> 49df8bae1dSRodney W. Grimes 50df8bae1dSRodney W. Grimes #include <net/if.h> 51df8bae1dSRodney W. Grimes #include <net/netisr.h> 52df8bae1dSRodney W. Grimes #include <net/route.h> 53df8bae1dSRodney W. Grimes #include <net/if_llc.h> 54df8bae1dSRodney W. Grimes #include <net/if_dl.h> 55df8bae1dSRodney W. Grimes #include <net/if_types.h> 56df8bae1dSRodney W. Grimes 57df8bae1dSRodney W. Grimes #ifdef INET 58df8bae1dSRodney W. Grimes #include <netinet/in.h> 59df8bae1dSRodney W. Grimes #include <netinet/in_var.h> 60df8bae1dSRodney W. Grimes #endif 61df8bae1dSRodney W. Grimes #include <netinet/if_ether.h> 62df8bae1dSRodney W. Grimes 63df8bae1dSRodney W. Grimes #ifdef NS 64df8bae1dSRodney W. Grimes #include <netns/ns.h> 65df8bae1dSRodney W. Grimes #include <netns/ns_if.h> 66df8bae1dSRodney W. Grimes #endif 67df8bae1dSRodney W. Grimes 68df8bae1dSRodney W. Grimes #ifdef ISO 69df8bae1dSRodney W. Grimes #include <netiso/argo_debug.h> 70df8bae1dSRodney W. Grimes #include <netiso/iso.h> 71df8bae1dSRodney W. Grimes #include <netiso/iso_var.h> 72df8bae1dSRodney W. Grimes #include <netiso/iso_snpac.h> 73df8bae1dSRodney W. Grimes #endif 74df8bae1dSRodney W. Grimes 75df8bae1dSRodney W. Grimes #ifdef LLC 76df8bae1dSRodney W. Grimes #include <netccitt/dll.h> 77df8bae1dSRodney W. Grimes #include <netccitt/llc_var.h> 78df8bae1dSRodney W. Grimes #endif 79df8bae1dSRodney W. Grimes 80df8bae1dSRodney W. Grimes #if defined(LLC) && defined(CCITT) 81df8bae1dSRodney W. Grimes extern struct ifqueue pkintrq; 82df8bae1dSRodney W. Grimes #endif 83df8bae1dSRodney W. Grimes 84df8bae1dSRodney W. Grimes u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 85df8bae1dSRodney W. Grimes #define senderr(e) { error = (e); goto bad;} 86df8bae1dSRodney W. Grimes 87df8bae1dSRodney W. Grimes /* 88df8bae1dSRodney W. Grimes * Ethernet output routine. 89df8bae1dSRodney W. Grimes * Encapsulate a packet of type family for the local net. 90df8bae1dSRodney W. Grimes * Use trailer local net encapsulation if enough data in first 91df8bae1dSRodney W. Grimes * packet leaves a multiple of 512 bytes of data in remainder. 92df8bae1dSRodney W. Grimes * Assumes that ifp is actually pointer to arpcom structure. 93df8bae1dSRodney W. Grimes */ 94df8bae1dSRodney W. Grimes int 95df8bae1dSRodney W. Grimes ether_output(ifp, m0, dst, rt0) 96df8bae1dSRodney W. Grimes register struct ifnet *ifp; 97df8bae1dSRodney W. Grimes struct mbuf *m0; 98df8bae1dSRodney W. Grimes struct sockaddr *dst; 99df8bae1dSRodney W. Grimes struct rtentry *rt0; 100df8bae1dSRodney W. Grimes { 101df8bae1dSRodney W. Grimes short type; 102df8bae1dSRodney W. Grimes int s, error = 0; 103df8bae1dSRodney W. Grimes u_char edst[6]; 104df8bae1dSRodney W. Grimes register struct mbuf *m = m0; 105df8bae1dSRodney W. Grimes register struct rtentry *rt; 106df8bae1dSRodney W. Grimes struct mbuf *mcopy = (struct mbuf *)0; 107df8bae1dSRodney W. Grimes register struct ether_header *eh; 108df8bae1dSRodney W. Grimes int off, len = m->m_pkthdr.len; 109df8bae1dSRodney W. Grimes struct arpcom *ac = (struct arpcom *)ifp; 110df8bae1dSRodney W. Grimes 111df8bae1dSRodney W. Grimes if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) 112df8bae1dSRodney W. Grimes senderr(ENETDOWN); 113df8bae1dSRodney W. Grimes ifp->if_lastchange = time; 114df8bae1dSRodney W. Grimes if (rt = rt0) { 115df8bae1dSRodney W. Grimes if ((rt->rt_flags & RTF_UP) == 0) { 116995add1aSGarrett Wollman if (rt0 = rt = rtalloc1(dst, 1, 0UL)) 117df8bae1dSRodney W. Grimes rt->rt_refcnt--; 118df8bae1dSRodney W. Grimes else 119df8bae1dSRodney W. Grimes senderr(EHOSTUNREACH); 120df8bae1dSRodney W. Grimes } 121df8bae1dSRodney W. Grimes if (rt->rt_flags & RTF_GATEWAY) { 122df8bae1dSRodney W. Grimes if (rt->rt_gwroute == 0) 123df8bae1dSRodney W. Grimes goto lookup; 124df8bae1dSRodney W. Grimes if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) { 125df8bae1dSRodney W. Grimes rtfree(rt); rt = rt0; 126995add1aSGarrett Wollman lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1, 127995add1aSGarrett Wollman 0UL); 128df8bae1dSRodney W. Grimes if ((rt = rt->rt_gwroute) == 0) 129df8bae1dSRodney W. Grimes senderr(EHOSTUNREACH); 130df8bae1dSRodney W. Grimes } 131df8bae1dSRodney W. Grimes } 132df8bae1dSRodney W. Grimes if (rt->rt_flags & RTF_REJECT) 133df8bae1dSRodney W. Grimes if (rt->rt_rmx.rmx_expire == 0 || 134df8bae1dSRodney W. Grimes time.tv_sec < rt->rt_rmx.rmx_expire) 135df8bae1dSRodney W. Grimes senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH); 136df8bae1dSRodney W. Grimes } 137df8bae1dSRodney W. Grimes switch (dst->sa_family) { 138df8bae1dSRodney W. Grimes 139df8bae1dSRodney W. Grimes #ifdef INET 140df8bae1dSRodney W. Grimes case AF_INET: 1415df72964SGarrett Wollman if (!arpresolve(ac, rt, m, dst, edst, rt0)) 142df8bae1dSRodney W. Grimes return (0); /* if not yet resolved */ 143df8bae1dSRodney W. Grimes /* If broadcasting on a simplex interface, loopback a copy */ 144df8bae1dSRodney W. Grimes if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) 145df8bae1dSRodney W. Grimes mcopy = m_copy(m, 0, (int)M_COPYALL); 146df8bae1dSRodney W. Grimes off = m->m_pkthdr.len - m->m_len; 147df8bae1dSRodney W. Grimes type = ETHERTYPE_IP; 148df8bae1dSRodney W. Grimes break; 149df8bae1dSRodney W. Grimes #endif 150df8bae1dSRodney W. Grimes #ifdef NS 151df8bae1dSRodney W. Grimes case AF_NS: 152df8bae1dSRodney W. Grimes type = ETHERTYPE_NS; 153df8bae1dSRodney W. Grimes bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host), 154df8bae1dSRodney W. Grimes (caddr_t)edst, sizeof (edst)); 155df8bae1dSRodney W. Grimes if (!bcmp((caddr_t)edst, (caddr_t)&ns_thishost, sizeof(edst))) 156df8bae1dSRodney W. Grimes return (looutput(ifp, m, dst, rt)); 157df8bae1dSRodney W. Grimes /* If broadcasting on a simplex interface, loopback a copy */ 158df8bae1dSRodney W. Grimes if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) 159df8bae1dSRodney W. Grimes mcopy = m_copy(m, 0, (int)M_COPYALL); 160df8bae1dSRodney W. Grimes break; 161df8bae1dSRodney W. Grimes #endif 162df8bae1dSRodney W. Grimes #ifdef ISO 163df8bae1dSRodney W. Grimes case AF_ISO: { 164df8bae1dSRodney W. Grimes int snpalen; 165df8bae1dSRodney W. Grimes struct llc *l; 166df8bae1dSRodney W. Grimes register struct sockaddr_dl *sdl; 167df8bae1dSRodney W. Grimes 168df8bae1dSRodney W. Grimes if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway) && 169df8bae1dSRodney W. Grimes sdl->sdl_family == AF_LINK && sdl->sdl_alen > 0) { 170df8bae1dSRodney W. Grimes bcopy(LLADDR(sdl), (caddr_t)edst, sizeof(edst)); 171df8bae1dSRodney W. Grimes } else if (error = 172df8bae1dSRodney W. Grimes iso_snparesolve(ifp, (struct sockaddr_iso *)dst, 173df8bae1dSRodney W. Grimes (char *)edst, &snpalen)) 174df8bae1dSRodney W. Grimes goto bad; /* Not Resolved */ 175df8bae1dSRodney W. Grimes /* If broadcasting on a simplex interface, loopback a copy */ 176df8bae1dSRodney W. Grimes if (*edst & 1) 177df8bae1dSRodney W. Grimes m->m_flags |= (M_BCAST|M_MCAST); 178df8bae1dSRodney W. Grimes if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX) && 179df8bae1dSRodney W. Grimes (mcopy = m_copy(m, 0, (int)M_COPYALL))) { 180df8bae1dSRodney W. Grimes M_PREPEND(mcopy, sizeof (*eh), M_DONTWAIT); 181df8bae1dSRodney W. Grimes if (mcopy) { 182df8bae1dSRodney W. Grimes eh = mtod(mcopy, struct ether_header *); 183df8bae1dSRodney W. Grimes bcopy((caddr_t)edst, 184df8bae1dSRodney W. Grimes (caddr_t)eh->ether_dhost, sizeof (edst)); 185df8bae1dSRodney W. Grimes bcopy((caddr_t)ac->ac_enaddr, 186df8bae1dSRodney W. Grimes (caddr_t)eh->ether_shost, sizeof (edst)); 187df8bae1dSRodney W. Grimes } 188df8bae1dSRodney W. Grimes } 189df8bae1dSRodney W. Grimes M_PREPEND(m, 3, M_DONTWAIT); 190df8bae1dSRodney W. Grimes if (m == NULL) 191df8bae1dSRodney W. Grimes return (0); 192df8bae1dSRodney W. Grimes type = m->m_pkthdr.len; 193df8bae1dSRodney W. Grimes l = mtod(m, struct llc *); 194df8bae1dSRodney W. Grimes l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP; 195df8bae1dSRodney W. Grimes l->llc_control = LLC_UI; 196df8bae1dSRodney W. Grimes len += 3; 197df8bae1dSRodney W. Grimes IFDEBUG(D_ETHER) 198df8bae1dSRodney W. Grimes int i; 199df8bae1dSRodney W. Grimes printf("unoutput: sending pkt to: "); 200df8bae1dSRodney W. Grimes for (i=0; i<6; i++) 201df8bae1dSRodney W. Grimes printf("%x ", edst[i] & 0xff); 202df8bae1dSRodney W. Grimes printf("\n"); 203df8bae1dSRodney W. Grimes ENDDEBUG 204df8bae1dSRodney W. Grimes } break; 205df8bae1dSRodney W. Grimes #endif /* ISO */ 206df8bae1dSRodney W. Grimes #ifdef LLC 207df8bae1dSRodney W. Grimes /* case AF_NSAP: */ 208df8bae1dSRodney W. Grimes case AF_CCITT: { 209df8bae1dSRodney W. Grimes register struct sockaddr_dl *sdl = 210df8bae1dSRodney W. Grimes (struct sockaddr_dl *) rt -> rt_gateway; 211df8bae1dSRodney W. Grimes 212df8bae1dSRodney W. Grimes if (sdl && sdl->sdl_family == AF_LINK 213df8bae1dSRodney W. Grimes && sdl->sdl_alen > 0) { 214df8bae1dSRodney W. Grimes bcopy(LLADDR(sdl), (char *)edst, 215df8bae1dSRodney W. Grimes sizeof(edst)); 216df8bae1dSRodney W. Grimes } else goto bad; /* Not a link interface ? Funny ... */ 217df8bae1dSRodney W. Grimes if ((ifp->if_flags & IFF_SIMPLEX) && (*edst & 1) && 218df8bae1dSRodney W. Grimes (mcopy = m_copy(m, 0, (int)M_COPYALL))) { 219df8bae1dSRodney W. Grimes M_PREPEND(mcopy, sizeof (*eh), M_DONTWAIT); 220df8bae1dSRodney W. Grimes if (mcopy) { 221df8bae1dSRodney W. Grimes eh = mtod(mcopy, struct ether_header *); 222df8bae1dSRodney W. Grimes bcopy((caddr_t)edst, 223df8bae1dSRodney W. Grimes (caddr_t)eh->ether_dhost, sizeof (edst)); 224df8bae1dSRodney W. Grimes bcopy((caddr_t)ac->ac_enaddr, 225df8bae1dSRodney W. Grimes (caddr_t)eh->ether_shost, sizeof (edst)); 226df8bae1dSRodney W. Grimes } 227df8bae1dSRodney W. Grimes } 228df8bae1dSRodney W. Grimes type = m->m_pkthdr.len; 229df8bae1dSRodney W. Grimes #ifdef LLC_DEBUG 230df8bae1dSRodney W. Grimes { 231df8bae1dSRodney W. Grimes int i; 232df8bae1dSRodney W. Grimes register struct llc *l = mtod(m, struct llc *); 233df8bae1dSRodney W. Grimes 234df8bae1dSRodney W. Grimes printf("ether_output: sending LLC2 pkt to: "); 235df8bae1dSRodney W. Grimes for (i=0; i<6; i++) 236df8bae1dSRodney W. Grimes printf("%x ", edst[i] & 0xff); 237df8bae1dSRodney W. Grimes printf(" len 0x%x dsap 0x%x ssap 0x%x control 0x%x\n", 238df8bae1dSRodney W. Grimes type & 0xff, l->llc_dsap & 0xff, l->llc_ssap &0xff, 239df8bae1dSRodney W. Grimes l->llc_control & 0xff); 240df8bae1dSRodney W. Grimes 241df8bae1dSRodney W. Grimes } 242df8bae1dSRodney W. Grimes #endif /* LLC_DEBUG */ 243df8bae1dSRodney W. Grimes } break; 244df8bae1dSRodney W. Grimes #endif /* LLC */ 245df8bae1dSRodney W. Grimes 246df8bae1dSRodney W. Grimes case AF_UNSPEC: 247df8bae1dSRodney W. Grimes eh = (struct ether_header *)dst->sa_data; 24894a5d9b6SDavid Greenman (void)memcpy(edst, eh->ether_dhost, sizeof (edst)); 249df8bae1dSRodney W. Grimes type = eh->ether_type; 250df8bae1dSRodney W. Grimes break; 251df8bae1dSRodney W. Grimes 252df8bae1dSRodney W. Grimes default: 253df8bae1dSRodney W. Grimes printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, 254df8bae1dSRodney W. Grimes dst->sa_family); 255df8bae1dSRodney W. Grimes senderr(EAFNOSUPPORT); 256df8bae1dSRodney W. Grimes } 257df8bae1dSRodney W. Grimes 258df8bae1dSRodney W. Grimes 259df8bae1dSRodney W. Grimes if (mcopy) 260df8bae1dSRodney W. Grimes (void) looutput(ifp, mcopy, dst, rt); 261df8bae1dSRodney W. Grimes /* 262df8bae1dSRodney W. Grimes * Add local net header. If no space in first mbuf, 263df8bae1dSRodney W. Grimes * allocate another. 264df8bae1dSRodney W. Grimes */ 265df8bae1dSRodney W. Grimes M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); 266df8bae1dSRodney W. Grimes if (m == 0) 267df8bae1dSRodney W. Grimes senderr(ENOBUFS); 268df8bae1dSRodney W. Grimes eh = mtod(m, struct ether_header *); 269df8bae1dSRodney W. Grimes type = htons((u_short)type); 27094a5d9b6SDavid Greenman (void)memcpy(&eh->ether_type, &type, 271df8bae1dSRodney W. Grimes sizeof(eh->ether_type)); 27294a5d9b6SDavid Greenman (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); 27394a5d9b6SDavid Greenman (void)memcpy(eh->ether_shost, ac->ac_enaddr, 274df8bae1dSRodney W. Grimes sizeof(eh->ether_shost)); 275df8bae1dSRodney W. Grimes s = splimp(); 276df8bae1dSRodney W. Grimes /* 277df8bae1dSRodney W. Grimes * Queue message on interface, and start output if interface 278df8bae1dSRodney W. Grimes * not yet active. 279df8bae1dSRodney W. Grimes */ 280df8bae1dSRodney W. Grimes if (IF_QFULL(&ifp->if_snd)) { 281df8bae1dSRodney W. Grimes IF_DROP(&ifp->if_snd); 282df8bae1dSRodney W. Grimes splx(s); 283df8bae1dSRodney W. Grimes senderr(ENOBUFS); 284df8bae1dSRodney W. Grimes } 285df8bae1dSRodney W. Grimes IF_ENQUEUE(&ifp->if_snd, m); 286df8bae1dSRodney W. Grimes if ((ifp->if_flags & IFF_OACTIVE) == 0) 287df8bae1dSRodney W. Grimes (*ifp->if_start)(ifp); 288df8bae1dSRodney W. Grimes splx(s); 289df8bae1dSRodney W. Grimes ifp->if_obytes += len + sizeof (struct ether_header); 290df8bae1dSRodney W. Grimes if (m->m_flags & M_MCAST) 291df8bae1dSRodney W. Grimes ifp->if_omcasts++; 292df8bae1dSRodney W. Grimes return (error); 293df8bae1dSRodney W. Grimes 294df8bae1dSRodney W. Grimes bad: 295df8bae1dSRodney W. Grimes if (m) 296df8bae1dSRodney W. Grimes m_freem(m); 297df8bae1dSRodney W. Grimes return (error); 298df8bae1dSRodney W. Grimes } 299df8bae1dSRodney W. Grimes 300df8bae1dSRodney W. Grimes /* 301df8bae1dSRodney W. Grimes * Process a received Ethernet packet; 302df8bae1dSRodney W. Grimes * the packet is in the mbuf chain m without 303df8bae1dSRodney W. Grimes * the ether header, which is provided separately. 304df8bae1dSRodney W. Grimes */ 305df8bae1dSRodney W. Grimes void 306df8bae1dSRodney W. Grimes ether_input(ifp, eh, m) 307df8bae1dSRodney W. Grimes struct ifnet *ifp; 308df8bae1dSRodney W. Grimes register struct ether_header *eh; 309df8bae1dSRodney W. Grimes struct mbuf *m; 310df8bae1dSRodney W. Grimes { 311df8bae1dSRodney W. Grimes register struct ifqueue *inq; 312df8bae1dSRodney W. Grimes register struct llc *l; 313df8bae1dSRodney W. Grimes struct arpcom *ac = (struct arpcom *)ifp; 314307d80beSDavid Greenman u_short ether_type; 315df8bae1dSRodney W. Grimes int s; 316df8bae1dSRodney W. Grimes 317df8bae1dSRodney W. Grimes if ((ifp->if_flags & IFF_UP) == 0) { 318df8bae1dSRodney W. Grimes m_freem(m); 319df8bae1dSRodney W. Grimes return; 320df8bae1dSRodney W. Grimes } 321df8bae1dSRodney W. Grimes ifp->if_lastchange = time; 322df8bae1dSRodney W. Grimes ifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh); 323df8bae1dSRodney W. Grimes if (bcmp((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost, 324df8bae1dSRodney W. Grimes sizeof(etherbroadcastaddr)) == 0) 325df8bae1dSRodney W. Grimes m->m_flags |= M_BCAST; 326df8bae1dSRodney W. Grimes else if (eh->ether_dhost[0] & 1) 327df8bae1dSRodney W. Grimes m->m_flags |= M_MCAST; 328df8bae1dSRodney W. Grimes if (m->m_flags & (M_BCAST|M_MCAST)) 329df8bae1dSRodney W. Grimes ifp->if_imcasts++; 330df8bae1dSRodney W. Grimes 331307d80beSDavid Greenman ether_type = ntohs(eh->ether_type); 332307d80beSDavid Greenman 333307d80beSDavid Greenman switch (ether_type) { 334df8bae1dSRodney W. Grimes #ifdef INET 335df8bae1dSRodney W. Grimes case ETHERTYPE_IP: 336df8bae1dSRodney W. Grimes schednetisr(NETISR_IP); 337df8bae1dSRodney W. Grimes inq = &ipintrq; 338df8bae1dSRodney W. Grimes break; 339df8bae1dSRodney W. Grimes 340df8bae1dSRodney W. Grimes case ETHERTYPE_ARP: 341df8bae1dSRodney W. Grimes schednetisr(NETISR_ARP); 342df8bae1dSRodney W. Grimes inq = &arpintrq; 343df8bae1dSRodney W. Grimes break; 344df8bae1dSRodney W. Grimes #endif 345df8bae1dSRodney W. Grimes #ifdef NS 346df8bae1dSRodney W. Grimes case ETHERTYPE_NS: 347df8bae1dSRodney W. Grimes schednetisr(NETISR_NS); 348df8bae1dSRodney W. Grimes inq = &nsintrq; 349df8bae1dSRodney W. Grimes break; 350df8bae1dSRodney W. Grimes 351df8bae1dSRodney W. Grimes #endif 352df8bae1dSRodney W. Grimes default: 353df8bae1dSRodney W. Grimes #if defined (ISO) || defined (LLC) 354307d80beSDavid Greenman if (ether_type > ETHERMTU) 355df8bae1dSRodney W. Grimes goto dropanyway; 356df8bae1dSRodney W. Grimes l = mtod(m, struct llc *); 357df8bae1dSRodney W. Grimes switch (l->llc_dsap) { 358df8bae1dSRodney W. Grimes #ifdef ISO 359df8bae1dSRodney W. Grimes case LLC_ISO_LSAP: 360df8bae1dSRodney W. Grimes switch (l->llc_control) { 361df8bae1dSRodney W. Grimes case LLC_UI: 362df8bae1dSRodney W. Grimes /* LLC_UI_P forbidden in class 1 service */ 363df8bae1dSRodney W. Grimes if ((l->llc_dsap == LLC_ISO_LSAP) && 364df8bae1dSRodney W. Grimes (l->llc_ssap == LLC_ISO_LSAP)) { 365df8bae1dSRodney W. Grimes /* LSAP for ISO */ 366307d80beSDavid Greenman if (m->m_pkthdr.len > ether_type) 367307d80beSDavid Greenman m_adj(m, ether_type - m->m_pkthdr.len); 368df8bae1dSRodney W. Grimes m->m_data += 3; /* XXX */ 369df8bae1dSRodney W. Grimes m->m_len -= 3; /* XXX */ 370df8bae1dSRodney W. Grimes m->m_pkthdr.len -= 3; /* XXX */ 371df8bae1dSRodney W. Grimes M_PREPEND(m, sizeof *eh, M_DONTWAIT); 372df8bae1dSRodney W. Grimes if (m == 0) 373df8bae1dSRodney W. Grimes return; 374df8bae1dSRodney W. Grimes *mtod(m, struct ether_header *) = *eh; 375df8bae1dSRodney W. Grimes IFDEBUG(D_ETHER) 376df8bae1dSRodney W. Grimes printf("clnp packet"); 377df8bae1dSRodney W. Grimes ENDDEBUG 378df8bae1dSRodney W. Grimes schednetisr(NETISR_ISO); 379df8bae1dSRodney W. Grimes inq = &clnlintrq; 380df8bae1dSRodney W. Grimes break; 381df8bae1dSRodney W. Grimes } 382df8bae1dSRodney W. Grimes goto dropanyway; 383df8bae1dSRodney W. Grimes 384df8bae1dSRodney W. Grimes case LLC_XID: 385df8bae1dSRodney W. Grimes case LLC_XID_P: 386df8bae1dSRodney W. Grimes if(m->m_len < 6) 387df8bae1dSRodney W. Grimes goto dropanyway; 388df8bae1dSRodney W. Grimes l->llc_window = 0; 389df8bae1dSRodney W. Grimes l->llc_fid = 9; 390df8bae1dSRodney W. Grimes l->llc_class = 1; 391df8bae1dSRodney W. Grimes l->llc_dsap = l->llc_ssap = 0; 392df8bae1dSRodney W. Grimes /* Fall through to */ 393df8bae1dSRodney W. Grimes case LLC_TEST: 394df8bae1dSRodney W. Grimes case LLC_TEST_P: 395df8bae1dSRodney W. Grimes { 396df8bae1dSRodney W. Grimes struct sockaddr sa; 397df8bae1dSRodney W. Grimes register struct ether_header *eh2; 398df8bae1dSRodney W. Grimes int i; 399df8bae1dSRodney W. Grimes u_char c = l->llc_dsap; 400df8bae1dSRodney W. Grimes 401df8bae1dSRodney W. Grimes l->llc_dsap = l->llc_ssap; 402df8bae1dSRodney W. Grimes l->llc_ssap = c; 403df8bae1dSRodney W. Grimes if (m->m_flags & (M_BCAST | M_MCAST)) 404df8bae1dSRodney W. Grimes bcopy((caddr_t)ac->ac_enaddr, 405df8bae1dSRodney W. Grimes (caddr_t)eh->ether_dhost, 6); 406df8bae1dSRodney W. Grimes sa.sa_family = AF_UNSPEC; 407df8bae1dSRodney W. Grimes sa.sa_len = sizeof(sa); 408df8bae1dSRodney W. Grimes eh2 = (struct ether_header *)sa.sa_data; 409df8bae1dSRodney W. Grimes for (i = 0; i < 6; i++) { 410df8bae1dSRodney W. Grimes eh2->ether_shost[i] = c = eh->ether_dhost[i]; 411df8bae1dSRodney W. Grimes eh2->ether_dhost[i] = 412df8bae1dSRodney W. Grimes eh->ether_dhost[i] = eh->ether_shost[i]; 413df8bae1dSRodney W. Grimes eh->ether_shost[i] = c; 414df8bae1dSRodney W. Grimes } 415df8bae1dSRodney W. Grimes ifp->if_output(ifp, m, &sa, NULL); 416df8bae1dSRodney W. Grimes return; 417df8bae1dSRodney W. Grimes } 418df8bae1dSRodney W. Grimes default: 419df8bae1dSRodney W. Grimes m_freem(m); 420df8bae1dSRodney W. Grimes return; 421df8bae1dSRodney W. Grimes } 422df8bae1dSRodney W. Grimes break; 423df8bae1dSRodney W. Grimes #endif /* ISO */ 424df8bae1dSRodney W. Grimes #ifdef LLC 425df8bae1dSRodney W. Grimes case LLC_X25_LSAP: 426df8bae1dSRodney W. Grimes { 427307d80beSDavid Greenman if (m->m_pkthdr.len > ether_type) 428307d80beSDavid Greenman m_adj(m, ether_type - m->m_pkthdr.len); 429df8bae1dSRodney W. Grimes M_PREPEND(m, sizeof(struct sdl_hdr) , M_DONTWAIT); 430df8bae1dSRodney W. Grimes if (m == 0) 431df8bae1dSRodney W. Grimes return; 432df8bae1dSRodney W. Grimes if ( !sdl_sethdrif(ifp, eh->ether_shost, LLC_X25_LSAP, 433df8bae1dSRodney W. Grimes eh->ether_dhost, LLC_X25_LSAP, 6, 434df8bae1dSRodney W. Grimes mtod(m, struct sdl_hdr *))) 435df8bae1dSRodney W. Grimes panic("ETHER cons addr failure"); 436307d80beSDavid Greenman mtod(m, struct sdl_hdr *)->sdlhdr_len = ether_type; 437df8bae1dSRodney W. Grimes #ifdef LLC_DEBUG 438df8bae1dSRodney W. Grimes printf("llc packet\n"); 439df8bae1dSRodney W. Grimes #endif /* LLC_DEBUG */ 440df8bae1dSRodney W. Grimes schednetisr(NETISR_CCITT); 441df8bae1dSRodney W. Grimes inq = &llcintrq; 442df8bae1dSRodney W. Grimes break; 443df8bae1dSRodney W. Grimes } 444df8bae1dSRodney W. Grimes #endif /* LLC */ 445df8bae1dSRodney W. Grimes dropanyway: 446df8bae1dSRodney W. Grimes default: 447df8bae1dSRodney W. Grimes m_freem(m); 448df8bae1dSRodney W. Grimes return; 449df8bae1dSRodney W. Grimes } 450df8bae1dSRodney W. Grimes #else /* ISO || LLC */ 451df8bae1dSRodney W. Grimes m_freem(m); 452df8bae1dSRodney W. Grimes return; 453df8bae1dSRodney W. Grimes #endif /* ISO || LLC */ 454df8bae1dSRodney W. Grimes } 455df8bae1dSRodney W. Grimes 456df8bae1dSRodney W. Grimes s = splimp(); 457df8bae1dSRodney W. Grimes if (IF_QFULL(inq)) { 458df8bae1dSRodney W. Grimes IF_DROP(inq); 459df8bae1dSRodney W. Grimes m_freem(m); 460df8bae1dSRodney W. Grimes } else 461df8bae1dSRodney W. Grimes IF_ENQUEUE(inq, m); 462df8bae1dSRodney W. Grimes splx(s); 463df8bae1dSRodney W. Grimes } 464df8bae1dSRodney W. Grimes 465df8bae1dSRodney W. Grimes /* 466df8bae1dSRodney W. Grimes * Convert Ethernet address to printable (loggable) representation. 467df8bae1dSRodney W. Grimes */ 468df8bae1dSRodney W. Grimes static char digits[] = "0123456789abcdef"; 469df8bae1dSRodney W. Grimes char * 470df8bae1dSRodney W. Grimes ether_sprintf(ap) 471df8bae1dSRodney W. Grimes register u_char *ap; 472df8bae1dSRodney W. Grimes { 473df8bae1dSRodney W. Grimes register i; 474df8bae1dSRodney W. Grimes static char etherbuf[18]; 475df8bae1dSRodney W. Grimes register char *cp = etherbuf; 476df8bae1dSRodney W. Grimes 477df8bae1dSRodney W. Grimes for (i = 0; i < 6; i++) { 478df8bae1dSRodney W. Grimes *cp++ = digits[*ap >> 4]; 479df8bae1dSRodney W. Grimes *cp++ = digits[*ap++ & 0xf]; 480df8bae1dSRodney W. Grimes *cp++ = ':'; 481df8bae1dSRodney W. Grimes } 482df8bae1dSRodney W. Grimes *--cp = 0; 483df8bae1dSRodney W. Grimes return (etherbuf); 484df8bae1dSRodney W. Grimes } 485df8bae1dSRodney W. Grimes 486df8bae1dSRodney W. Grimes /* 487df8bae1dSRodney W. Grimes * Perform common duties while attaching to interface list 488df8bae1dSRodney W. Grimes */ 489df8bae1dSRodney W. Grimes void 490df8bae1dSRodney W. Grimes ether_ifattach(ifp) 491df8bae1dSRodney W. Grimes register struct ifnet *ifp; 492df8bae1dSRodney W. Grimes { 493df8bae1dSRodney W. Grimes register struct ifaddr *ifa; 494df8bae1dSRodney W. Grimes register struct sockaddr_dl *sdl; 495df8bae1dSRodney W. Grimes 496df8bae1dSRodney W. Grimes ifp->if_type = IFT_ETHER; 497df8bae1dSRodney W. Grimes ifp->if_addrlen = 6; 498df8bae1dSRodney W. Grimes ifp->if_hdrlen = 14; 499df8bae1dSRodney W. Grimes ifp->if_mtu = ETHERMTU; 500df8bae1dSRodney W. Grimes for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) 501df8bae1dSRodney W. Grimes if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && 502df8bae1dSRodney W. Grimes sdl->sdl_family == AF_LINK) { 503df8bae1dSRodney W. Grimes sdl->sdl_type = IFT_ETHER; 504df8bae1dSRodney W. Grimes sdl->sdl_alen = ifp->if_addrlen; 505df8bae1dSRodney W. Grimes bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr, 506df8bae1dSRodney W. Grimes LLADDR(sdl), ifp->if_addrlen); 507df8bae1dSRodney W. Grimes break; 508df8bae1dSRodney W. Grimes } 509df8bae1dSRodney W. Grimes } 510df8bae1dSRodney W. Grimes 511df8bae1dSRodney W. Grimes u_char ether_ipmulticast_min[6] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 }; 512df8bae1dSRodney W. Grimes u_char ether_ipmulticast_max[6] = { 0x01, 0x00, 0x5e, 0x7f, 0xff, 0xff }; 513df8bae1dSRodney W. Grimes /* 514df8bae1dSRodney W. Grimes * Add an Ethernet multicast address or range of addresses to the list for a 515df8bae1dSRodney W. Grimes * given interface. 516df8bae1dSRodney W. Grimes */ 517df8bae1dSRodney W. Grimes int 518df8bae1dSRodney W. Grimes ether_addmulti(ifr, ac) 519df8bae1dSRodney W. Grimes struct ifreq *ifr; 520df8bae1dSRodney W. Grimes register struct arpcom *ac; 521df8bae1dSRodney W. Grimes { 522df8bae1dSRodney W. Grimes register struct ether_multi *enm; 523df8bae1dSRodney W. Grimes struct sockaddr_in *sin; 524df8bae1dSRodney W. Grimes u_char addrlo[6]; 525df8bae1dSRodney W. Grimes u_char addrhi[6]; 526d3628763SRodney W. Grimes int set_allmulti = 0; 527df8bae1dSRodney W. Grimes int s = splimp(); 528df8bae1dSRodney W. Grimes 529df8bae1dSRodney W. Grimes switch (ifr->ifr_addr.sa_family) { 530df8bae1dSRodney W. Grimes 531df8bae1dSRodney W. Grimes case AF_UNSPEC: 532df8bae1dSRodney W. Grimes bcopy(ifr->ifr_addr.sa_data, addrlo, 6); 533df8bae1dSRodney W. Grimes bcopy(addrlo, addrhi, 6); 534df8bae1dSRodney W. Grimes break; 535df8bae1dSRodney W. Grimes 536df8bae1dSRodney W. Grimes #ifdef INET 537df8bae1dSRodney W. Grimes case AF_INET: 538df8bae1dSRodney W. Grimes sin = (struct sockaddr_in *)&(ifr->ifr_addr); 539df8bae1dSRodney W. Grimes if (sin->sin_addr.s_addr == INADDR_ANY) { 540df8bae1dSRodney W. Grimes /* 541df8bae1dSRodney W. Grimes * An IP address of INADDR_ANY means listen to all 542df8bae1dSRodney W. Grimes * of the Ethernet multicast addresses used for IP. 543df8bae1dSRodney W. Grimes * (This is for the sake of IP multicast routers.) 544df8bae1dSRodney W. Grimes */ 545df8bae1dSRodney W. Grimes bcopy(ether_ipmulticast_min, addrlo, 6); 546df8bae1dSRodney W. Grimes bcopy(ether_ipmulticast_max, addrhi, 6); 547d3628763SRodney W. Grimes set_allmulti = 1; 548df8bae1dSRodney W. Grimes } 549df8bae1dSRodney W. Grimes else { 550df8bae1dSRodney W. Grimes ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo); 551df8bae1dSRodney W. Grimes bcopy(addrlo, addrhi, 6); 552df8bae1dSRodney W. Grimes } 553df8bae1dSRodney W. Grimes break; 554df8bae1dSRodney W. Grimes #endif 555df8bae1dSRodney W. Grimes 556df8bae1dSRodney W. Grimes default: 557df8bae1dSRodney W. Grimes splx(s); 558df8bae1dSRodney W. Grimes return (EAFNOSUPPORT); 559df8bae1dSRodney W. Grimes } 560df8bae1dSRodney W. Grimes 561df8bae1dSRodney W. Grimes /* 562df8bae1dSRodney W. Grimes * Verify that we have valid Ethernet multicast addresses. 563df8bae1dSRodney W. Grimes */ 564df8bae1dSRodney W. Grimes if ((addrlo[0] & 0x01) != 1 || (addrhi[0] & 0x01) != 1) { 565df8bae1dSRodney W. Grimes splx(s); 566df8bae1dSRodney W. Grimes return (EINVAL); 567df8bae1dSRodney W. Grimes } 568df8bae1dSRodney W. Grimes /* 569df8bae1dSRodney W. Grimes * See if the address range is already in the list. 570df8bae1dSRodney W. Grimes */ 571df8bae1dSRodney W. Grimes ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm); 572df8bae1dSRodney W. Grimes if (enm != NULL) { 573df8bae1dSRodney W. Grimes /* 574df8bae1dSRodney W. Grimes * Found it; just increment the reference count. 575df8bae1dSRodney W. Grimes */ 576df8bae1dSRodney W. Grimes ++enm->enm_refcount; 577df8bae1dSRodney W. Grimes splx(s); 578df8bae1dSRodney W. Grimes return (0); 579df8bae1dSRodney W. Grimes } 580df8bae1dSRodney W. Grimes /* 581df8bae1dSRodney W. Grimes * New address or range; malloc a new multicast record 582df8bae1dSRodney W. Grimes * and link it into the interface's multicast list. 583df8bae1dSRodney W. Grimes */ 584df8bae1dSRodney W. Grimes enm = (struct ether_multi *)malloc(sizeof(*enm), M_IFMADDR, M_NOWAIT); 585df8bae1dSRodney W. Grimes if (enm == NULL) { 586df8bae1dSRodney W. Grimes splx(s); 587df8bae1dSRodney W. Grimes return (ENOBUFS); 588df8bae1dSRodney W. Grimes } 589df8bae1dSRodney W. Grimes bcopy(addrlo, enm->enm_addrlo, 6); 590df8bae1dSRodney W. Grimes bcopy(addrhi, enm->enm_addrhi, 6); 591df8bae1dSRodney W. Grimes enm->enm_ac = ac; 592df8bae1dSRodney W. Grimes enm->enm_refcount = 1; 593df8bae1dSRodney W. Grimes enm->enm_next = ac->ac_multiaddrs; 594df8bae1dSRodney W. Grimes ac->ac_multiaddrs = enm; 595df8bae1dSRodney W. Grimes ac->ac_multicnt++; 596df8bae1dSRodney W. Grimes splx(s); 597d3628763SRodney W. Grimes if (set_allmulti) 598d3628763SRodney W. Grimes ac->ac_if.if_flags |= IFF_ALLMULTI; 599d3628763SRodney W. Grimes 600df8bae1dSRodney W. Grimes /* 601df8bae1dSRodney W. Grimes * Return ENETRESET to inform the driver that the list has changed 602df8bae1dSRodney W. Grimes * and its reception filter should be adjusted accordingly. 603df8bae1dSRodney W. Grimes */ 604df8bae1dSRodney W. Grimes return (ENETRESET); 605df8bae1dSRodney W. Grimes } 606df8bae1dSRodney W. Grimes 607df8bae1dSRodney W. Grimes /* 608df8bae1dSRodney W. Grimes * Delete a multicast address record. 609df8bae1dSRodney W. Grimes */ 610df8bae1dSRodney W. Grimes int 611df8bae1dSRodney W. Grimes ether_delmulti(ifr, ac) 612df8bae1dSRodney W. Grimes struct ifreq *ifr; 613df8bae1dSRodney W. Grimes register struct arpcom *ac; 614df8bae1dSRodney W. Grimes { 615df8bae1dSRodney W. Grimes register struct ether_multi *enm; 616df8bae1dSRodney W. Grimes register struct ether_multi **p; 617df8bae1dSRodney W. Grimes struct sockaddr_in *sin; 618df8bae1dSRodney W. Grimes u_char addrlo[6]; 619df8bae1dSRodney W. Grimes u_char addrhi[6]; 620d3628763SRodney W. Grimes int unset_allmulti = 0; 621df8bae1dSRodney W. Grimes int s = splimp(); 622df8bae1dSRodney W. Grimes 623df8bae1dSRodney W. Grimes switch (ifr->ifr_addr.sa_family) { 624df8bae1dSRodney W. Grimes 625df8bae1dSRodney W. Grimes case AF_UNSPEC: 626df8bae1dSRodney W. Grimes bcopy(ifr->ifr_addr.sa_data, addrlo, 6); 627df8bae1dSRodney W. Grimes bcopy(addrlo, addrhi, 6); 628df8bae1dSRodney W. Grimes break; 629df8bae1dSRodney W. Grimes 630df8bae1dSRodney W. Grimes #ifdef INET 631df8bae1dSRodney W. Grimes case AF_INET: 632df8bae1dSRodney W. Grimes sin = (struct sockaddr_in *)&(ifr->ifr_addr); 633df8bae1dSRodney W. Grimes if (sin->sin_addr.s_addr == INADDR_ANY) { 634df8bae1dSRodney W. Grimes /* 635df8bae1dSRodney W. Grimes * An IP address of INADDR_ANY means stop listening 636df8bae1dSRodney W. Grimes * to the range of Ethernet multicast addresses used 637df8bae1dSRodney W. Grimes * for IP. 638df8bae1dSRodney W. Grimes */ 639df8bae1dSRodney W. Grimes bcopy(ether_ipmulticast_min, addrlo, 6); 640df8bae1dSRodney W. Grimes bcopy(ether_ipmulticast_max, addrhi, 6); 641d3628763SRodney W. Grimes unset_allmulti = 1; 642df8bae1dSRodney W. Grimes } 643df8bae1dSRodney W. Grimes else { 644df8bae1dSRodney W. Grimes ETHER_MAP_IP_MULTICAST(&sin->sin_addr, addrlo); 645df8bae1dSRodney W. Grimes bcopy(addrlo, addrhi, 6); 646df8bae1dSRodney W. Grimes } 647df8bae1dSRodney W. Grimes break; 648df8bae1dSRodney W. Grimes #endif 649df8bae1dSRodney W. Grimes 650df8bae1dSRodney W. Grimes default: 651df8bae1dSRodney W. Grimes splx(s); 652df8bae1dSRodney W. Grimes return (EAFNOSUPPORT); 653df8bae1dSRodney W. Grimes } 654df8bae1dSRodney W. Grimes 655df8bae1dSRodney W. Grimes /* 656df8bae1dSRodney W. Grimes * Look up the address in our list. 657df8bae1dSRodney W. Grimes */ 658df8bae1dSRodney W. Grimes ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm); 659df8bae1dSRodney W. Grimes if (enm == NULL) { 660df8bae1dSRodney W. Grimes splx(s); 661df8bae1dSRodney W. Grimes return (ENXIO); 662df8bae1dSRodney W. Grimes } 663df8bae1dSRodney W. Grimes if (--enm->enm_refcount != 0) { 664df8bae1dSRodney W. Grimes /* 665df8bae1dSRodney W. Grimes * Still some claims to this record. 666df8bae1dSRodney W. Grimes */ 667df8bae1dSRodney W. Grimes splx(s); 668df8bae1dSRodney W. Grimes return (0); 669df8bae1dSRodney W. Grimes } 670df8bae1dSRodney W. Grimes /* 671df8bae1dSRodney W. Grimes * No remaining claims to this record; unlink and free it. 672df8bae1dSRodney W. Grimes */ 673df8bae1dSRodney W. Grimes for (p = &enm->enm_ac->ac_multiaddrs; 674df8bae1dSRodney W. Grimes *p != enm; 675df8bae1dSRodney W. Grimes p = &(*p)->enm_next) 676df8bae1dSRodney W. Grimes continue; 677df8bae1dSRodney W. Grimes *p = (*p)->enm_next; 678df8bae1dSRodney W. Grimes free(enm, M_IFMADDR); 679df8bae1dSRodney W. Grimes ac->ac_multicnt--; 680df8bae1dSRodney W. Grimes splx(s); 681d3628763SRodney W. Grimes if (unset_allmulti) 682d3628763SRodney W. Grimes ac->ac_if.if_flags &= ~IFF_ALLMULTI; 683d3628763SRodney W. Grimes 684df8bae1dSRodney W. Grimes /* 685df8bae1dSRodney W. Grimes * Return ENETRESET to inform the driver that the list has changed 686df8bae1dSRodney W. Grimes * and its reception filter should be adjusted accordingly. 687df8bae1dSRodney W. Grimes */ 688df8bae1dSRodney W. Grimes return (ENETRESET); 689df8bae1dSRodney W. Grimes } 690