X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/7b1edb791d9ca667b95988cb5638c4c88416cd17..4a2492630c73add3c3aa8a805ba4ff343d4a58ea:/bsd/net/ether_inet_pr_module.c diff --git a/bsd/net/ether_inet_pr_module.c b/bsd/net/ether_inet_pr_module.c index b206d8f73..5e9cc8f74 100644 --- a/bsd/net/ether_inet_pr_module.c +++ b/bsd/net/ether_inet_pr_module.c @@ -3,19 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -103,6 +106,7 @@ static u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +extern void * kdp_get_interface(); /* * Process a received Ethernet packet; @@ -224,7 +228,7 @@ inet_ether_pre_output(ifp, m0, dst_netaddr, route, type, edst, dl_tag ) register struct rtentry *rt; register struct ether_header *eh; int off, len = m->m_pkthdr.len; - int hlen; /* link layer header lenght */ + int hlen; /* link layer header length */ struct arpcom *ac = IFP2AC(ifp); @@ -237,7 +241,7 @@ inet_ether_pre_output(ifp, m0, dst_netaddr, route, type, edst, dl_tag ) if ((rt->rt_flags & RTF_UP) == 0) { rt0 = rt = rtalloc1(dst_netaddr, 1, 0UL); if (rt0) - rt->rt_refcnt--; + rtunref(rt); else return EHOSTUNREACH; } @@ -362,20 +366,15 @@ ether_inet_prmod_ioctl(dl_tag, ifp, command, data) if (ifp->if_init) ifp->if_init(ifp->if_softc); /* before arpwhohas */ - // - // See if another station has *our* IP address. - // i.e.: There is an address conflict! If a - // conflict exists, a message is sent to the - // console. - // - if (IA_SIN(ifa)->sin_addr.s_addr != 0) - { - /* don't bother for 0.0.0.0 */ - ac->ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(ac, &IA_SIN(ifa)->sin_addr); - } - arp_ifinit(IFP2AC(ifp), ifa); + /* + * Register new IP and MAC addresses with the kernel debugger + * if the interface is the same as was registered by IOKernelDebugger. If + * no interface was registered, fall back and just match against en0 interface. + */ + if ((kdp_get_interface() != 0 && kdp_get_interface() == ifp->if_private) + || (kdp_get_interface() == 0 && ifp->if_unit == 0)) + kdp_set_ip_and_mac_addresses(&(IA_SIN(ifa)->sin_addr), &(IFP2AC(ifp)->ac_enaddr)); break; @@ -397,14 +396,10 @@ ether_inet_prmod_ioctl(dl_tag, ifp, command, data) case SIOCSIFMTU: /* - * Set the interface MTU. + * IOKit IONetworkFamily will set the right MTU according to the driver */ - if (ifr->ifr_mtu > ETHERMTU) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - } - break; + + return (0); default: return EOPNOTSUPP; @@ -419,22 +414,21 @@ ether_inet_prmod_ioctl(dl_tag, ifp, command, data) -u_long -ether_attach_inet(struct ifnet *ifp) +int +ether_attach_inet(struct ifnet *ifp, u_long *dl_tag) { struct dlil_proto_reg_str reg; struct dlil_demux_desc desc; struct dlil_demux_desc desc2; - u_long ip_dl_tag=0; u_short en_native=ETHERTYPE_IP; u_short arp_native=ETHERTYPE_ARP; int stat; int i; - stat = dlil_find_dltag(ifp->if_family, ifp->if_unit, PF_INET, &ip_dl_tag); + stat = dlil_find_dltag(ifp->if_family, ifp->if_unit, PF_INET, dl_tag); if (stat == 0) - return ip_dl_tag; + return (stat); TAILQ_INIT(®.demux_desc_head); desc.type = DLIL_DESC_RAW; @@ -457,24 +451,21 @@ ether_attach_inet(struct ifnet *ifp) desc2.native_type = (char *) &arp_native; TAILQ_INSERT_TAIL(®.demux_desc_head, &desc2, next); - stat = dlil_attach_protocol(®, &ip_dl_tag); + stat = dlil_attach_protocol(®, dl_tag); if (stat) { printf("WARNING: ether_attach_inet can't attach ip to interface\n"); return stat; } - /* XXX avoid free'ing the interface */ - ifp->if_eflags |= IFEF_DETACH_DISABLED; - return ip_dl_tag; + return (0); } -int ether_detach_inet(struct ifnet *ifp) +int ether_detach_inet(struct ifnet *ifp, u_long dl_tag) { - u_long ip_dl_tag = 0; int stat; - stat = dlil_find_dltag(ifp->if_family, ifp->if_unit, PF_INET, &ip_dl_tag); + stat = dlil_find_dltag(ifp->if_family, ifp->if_unit, PF_INET, &dl_tag); if (stat == 0) { - stat = dlil_detach_protocol(ip_dl_tag); + stat = dlil_detach_protocol(dl_tag); if (stat) { printf("WARNING: ether_detach_inet can't detach ip from interface\n"); }