]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/ether_inet6_pr_module.c
xnu-3789.51.2.tar.gz
[apple/xnu.git] / bsd / net / ether_inet6_pr_module.c
index 78a2b3f079138a56caa469891625981acc378711..ee014a3dd8283e0a8054bc7fee71b784fb77f63f 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 2000-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- * 
+ *
  * 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
  * unlawful or unlicensed copies of an Apple operating system, or to
  * circumvent, violate, or enable the circumvention or violation of, any
  * terms of an Apple operating system software license agreement.
- * 
+ *
  * 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,
@@ -68,8 +68,8 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/socketvar.h>
-#include <kern/lock.h>
 
+#include <net/dlil.h>
 #include <net/if.h>
 #include <net/route.h>
 #include <net/if_llc.h>
 #if INET6
 #include <netinet6/nd6.h>
 #include <netinet6/in6_ifattach.h>
-#endif
-
-#if LLC && CCITT
-extern struct ifqueue pkintrq;
+#include <netinet6/ip6_var.h>
 #endif
 
 /* #include "vlan.h" */
@@ -101,6 +98,9 @@ extern struct ifqueue pkintrq;
 
 #include <net/ether_if_module.h>
 
+static const u_char etherip6allnodes[ETHER_ADDR_LEN] =
+       { 0x33, 0x33, 0, 0, 0, 1 };
+
 /*
  * Process a received Ethernet packet;
  * the packet is in the mbuf chain m without
@@ -134,6 +134,18 @@ ether_inet6_input(ifnet_t ifp, protocol_family_t protocol,
                            ETHER_ADDR_LEN);
                }
 
+               /* Save the Ethernet source address for all-nodes multicasts */
+               if (!bcmp(eh->ether_dhost, etherip6allnodes, ETHER_ADDR_LEN)) {
+                       struct ip6aux *ip6a;
+
+                       ip6a = ip6_addaux(packet);
+                       if (ip6a) {
+                               ip6a->ip6a_flags |= IP6A_HASEEN;
+                               bcopy(eh->ether_shost, ip6a->ip6a_ehsrc,
+                                   ETHER_ADDR_LEN);
+                       }
+               }
+
                if (proto_input(protocol, packet) != 0)
                        m_freem(packet);
        } else {
@@ -224,9 +236,8 @@ ether_inet6_prmod_ioctl(ifnet_t ifp, protocol_family_t protocol_family,
 
        case SIOCGIFADDR: {             /* struct ifreq */
                struct ifreq *ifr = (struct ifreq *)(void *)data;
-
-               (void) ifnet_lladdr_copy_bytes(ifp, ifr->ifr_addr.sa_data,
-                   ETHER_ADDR_LEN);
+               (void) ifnet_guarded_lladdr_copy_bytes(ifp,
+                   ifr->ifr_addr.sa_data, ETHER_ADDR_LEN);
                break;
        }
 
@@ -258,8 +269,8 @@ ether_attach_inet6(struct ifnet *ifp, protocol_family_t protocol_family)
        proto.resolve = ether_inet6_resolve_multi;
        error = ifnet_attach_protocol(ifp, protocol_family, &proto);
        if (error && error != EEXIST) {
-               printf("WARNING: %s can't attach ipv6 to %s%d\n", __func__,
-                   ifp->if_name, ifp->if_unit);
+               printf("WARNING: %s can't attach ipv6 to %s\n", __func__,
+                   if_name(ifp));
        }
 
        return (error);