]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/icmp6.h
xnu-3789.31.2.tar.gz
[apple/xnu.git] / bsd / netinet / icmp6.h
index aab7c4ffd52b7047dc79d49bee2710f3e8042a95..52228f43c8c7bdd21ae014f123a1846b790c81b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000,2008-2010 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 #define _NETINET_ICMP6_H_
 #include <sys/appleapiopts.h>
 
-#ifdef XNU_KERNEL_PRIVATE
-#include <sys/mcache.h>
-#endif
-
 #define ICMPV6_PLD_MAXLEN      1232    /* IPV6_MMTU - sizeof(struct ip6_hdr)
                                           - sizeof(struct icmp6_hdr) */
 
@@ -332,7 +328,9 @@ struct nd_opt_hdr {         /* Neighbor discovery option header */
 #define ND_OPT_PREFIX_INFORMATION      3
 #define ND_OPT_REDIRECTED_HEADER       4
 #define ND_OPT_MTU                     5
+#define ND_OPT_NONCE                   14      /* RFC 3971 */
 #define ND_OPT_RDNSS                   25      /* RFC 5006 */
+#define ND_OPT_DNSSL                   31      /* RFC 6106 */
 
 #define ND_OPT_ROUTE_INFO              200     /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
 
@@ -350,6 +348,17 @@ struct nd_opt_prefix_info {        /* prefix information */
 #define ND_OPT_PI_FLAG_ONLINK          0x80
 #define ND_OPT_PI_FLAG_AUTO            0x40
 
+#define        ND_OPT_NONCE_LEN        ((1 * 8) - 2)
+#if ((ND_OPT_NONCE_LEN + 2) % 8) != 0
+#error "(ND_OPT_NONCE_LEN + 2) must be a multiple of 8."
+#endif
+
+struct nd_opt_nonce {          /* nonce option */
+       u_int8_t        nd_opt_nonce_type;
+       u_int8_t        nd_opt_nonce_len;
+       u_int8_t        nd_opt_nonce[ND_OPT_NONCE_LEN];
+} __attribute__((__packed__));
+
 struct nd_opt_rd_hdr {         /* redirected header */
        u_int8_t        nd_opt_rh_type;
        u_int8_t        nd_opt_rh_len;
@@ -382,6 +391,14 @@ struct nd_opt_rdnss {      /* recursive domain name system servers */
     struct in6_addr    nd_opt_rdnss_addr[1];
 } __attribute__((__packed__));
 
+struct nd_opt_dnssl {  /* domain name search list */
+    u_int8_t           nd_opt_dnssl_type;
+    u_int8_t           nd_opt_dnssl_len;
+    u_int16_t          nd_opt_dnssl_reserved;
+    u_int32_t          nd_opt_dnssl_lifetime;
+    u_int8_t           nd_opt_dnssl_domains[8];
+} __attribute__((__packed__));
+
 /*
  * icmp6 namelookup
  */
@@ -637,6 +654,7 @@ struct icmp6stat {
        u_quad_t icp6s_badrs;           /* bad router advertisement */
        u_quad_t icp6s_badra;           /* bad router advertisement */
        u_quad_t icp6s_badredirect;     /* bad redirect message */
+       u_quad_t icp6s_rfc6980_drop;    /* NDP packet dropped based on RFC 6980 */
 };
 
 /*
@@ -648,28 +666,29 @@ struct icmp6stat {
 #if 0  /*obsoleted*/
 #define ICMPV6CTL_ERRRATELIMIT         5       /* ICMPv6 error rate limitation */
 #endif
-#define ICMPV6CTL_ND6_PRUNE                    6
-#define ICMPV6CTL_ND6_DELAY                    8
+#define ICMPV6CTL_ND6_PRUNE            6
+#define ICMPV6CTL_ND6_DELAY            8
 #define ICMPV6CTL_ND6_UMAXTRIES                9
 #define ICMPV6CTL_ND6_MMAXTRIES                10
 #define ICMPV6CTL_ND6_USELOOPBACK      11
 /*#define ICMPV6CTL_ND6_PROXYALL       12      obsoleted, do not reuse here */
-#define ICMPV6CTL_NODEINFO                     13
+#define ICMPV6CTL_NODEINFO             13
 #define ICMPV6CTL_ERRPPSLIMIT          14      /* ICMPv6 error pps limitation */
 #define ICMPV6CTL_ND6_MAXNUDHINT       15
 #define ICMPV6CTL_MTUDISC_HIWAT                16
 #define ICMPV6CTL_MTUDISC_LOWAT                17
-#define ICMPV6CTL_ND6_DEBUG                    18
+#define ICMPV6CTL_ND6_DEBUG            18
 #define ICMPV6CTL_ND6_DRLIST           19
 #define ICMPV6CTL_ND6_PRLIST           20
 #define ICMPV6CTL_MLD_MAXSRCFILTER     21
 #define ICMPV6CTL_MLD_SOMAXSRC         22
 #define ICMPV6CTL_MLD_VERSION          23
 #define ICMPV6CTL_ND6_MAXQLEN          24
-#define        ICMPV6CTL_ND6_ACCEPT_6TO4       25
-#define ICMPV6CTL_MAXID                                26
+#define ICMPV6CTL_ND6_ACCEPT_6TO4      25
+#define ICMPV6CTL_ND6_OPTIMISTIC_DAD   26      /* RFC 4429 */
+#define ICMPV6CTL_MAXID                        27
 
-#ifdef KERNEL_PRIVATE
+#ifdef BSD_KERNEL_PRIVATE
 #define ICMPV6CTL_NAMES { \
        { 0, 0 }, \
        { 0, 0 }, \
@@ -697,17 +716,21 @@ struct icmp6stat {
        { 0, 0 }, \
        { 0, 0 }, \
        { "nd6_accept_6to4", CTLTYPE_INT }, \
+       { "nd6_optimistic_dad", CTLTYPE_INT }, \
 }
 
-#define RTF_PROBEMTU   RTF_PROTO1
-
 # ifdef __STDC__
 struct rtentry;
 struct rttimer;
 struct in6_multi;
 # endif
-void   icmp6_init(void);
+struct ip6protosw;
+void   icmp6_init(struct ip6protosw *, struct domain *);
 void   icmp6_paramerror(struct mbuf *, int);
+
+void   icmp6_error_flag(struct mbuf *, int, int, int, int);
+#define        ICMP6_ERROR_RST_MRCVIF  0x1
+
 void   icmp6_error(struct mbuf *, int, int, int);
 void   icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
 int    icmp6_input(struct mbuf **, int *, int);
@@ -721,68 +744,63 @@ void      icmp6_mtudisc_update(struct ip6ctlparam *, int);
 
 extern lck_rw_t icmp6_ifs_rwlock;
 /* XXX: is this the right place for these macros? */
-#define icmp6_ifstat_inc(ifp, tag) \
-do {                                                                   \
-       lck_rw_lock_shared(&icmp6_ifs_rwlock);                          \
-       if ((ifp) && (ifp)->if_index <= if_index                        \
-        && (ifp)->if_index < icmp6_ifstatmax                           \
-        && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) {            \
-               atomic_add_64(&icmp6_ifstat[(ifp)->if_index]->tag, 1);  \
-       }                                                               \
-       lck_rw_done(&icmp6_ifs_rwlock);                                 \
+/* N.B.: if_inet6data is never freed once set, so we don't need to lock */
+#define icmp6_ifstat_inc(_ifp, _tag) do {                      \
+       if (_ifp != NULL && IN6_IFEXTRA(_ifp) != NULL) {        \
+               IN6_IFEXTRA(_ifp)->icmp6_ifstat._tag++;         \
+       }                                                       \
 } while (0)
 
-#define icmp6_ifoutstat_inc(ifp, type, code) \
-do { \
-               icmp6_ifstat_inc(ifp, ifs6_out_msg); \
-               if (type < ICMP6_INFOMSG_MASK) \
-                       icmp6_ifstat_inc(ifp, ifs6_out_error); \
-               switch (type) { \
-                case ICMP6_DST_UNREACH: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
-                        if (code == ICMP6_DST_UNREACH_ADMIN) \
-                                icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
-                        break; \
-                case ICMP6_PACKET_TOO_BIG: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
-                        break; \
-                case ICMP6_TIME_EXCEEDED: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
-                        break; \
-                case ICMP6_PARAM_PROB: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
-                        break; \
-                case ICMP6_ECHO_REQUEST: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_echo); \
-                        break; \
-                case ICMP6_ECHO_REPLY: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
-                        break; \
-                case MLD_LISTENER_QUERY: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
-                        break; \
-                case MLD_LISTENER_REPORT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
-                        break; \
-                case MLD_LISTENER_DONE: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
-                        break; \
-                case ND_ROUTER_SOLICIT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
-                        break; \
-                case ND_ROUTER_ADVERT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
-                        break; \
-                case ND_NEIGHBOR_SOLICIT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
-                        break; \
-                case ND_NEIGHBOR_ADVERT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
-                        break; \
-                case ND_REDIRECT: \
-                        icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
-                        break; \
-               } \
+#define icmp6_ifoutstat_inc(ifp, type, code) do {              \
+       icmp6_ifstat_inc(ifp, ifs6_out_msg);                    \
+       if (type < ICMP6_INFOMSG_MASK)                          \
+               icmp6_ifstat_inc(ifp, ifs6_out_error);          \
+       switch (type) {                                         \
+       case ICMP6_DST_UNREACH:                                 \
+               icmp6_ifstat_inc(ifp, ifs6_out_dstunreach);     \
+               if (code == ICMP6_DST_UNREACH_ADMIN)            \
+                       icmp6_ifstat_inc(ifp, ifs6_out_adminprohib);\
+                break;                                         \
+       case ICMP6_PACKET_TOO_BIG:                              \
+               icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig);      \
+               break;                                          \
+       case ICMP6_TIME_EXCEEDED:                               \
+               icmp6_ifstat_inc(ifp, ifs6_out_timeexceed);     \
+               break;                                          \
+       case ICMP6_PARAM_PROB:                                  \
+               icmp6_ifstat_inc(ifp, ifs6_out_paramprob);      \
+               break;                                          \
+       case ICMP6_ECHO_REQUEST:                                \
+               icmp6_ifstat_inc(ifp, ifs6_out_echo);           \
+               break;                                          \
+       case ICMP6_ECHO_REPLY:                                  \
+               icmp6_ifstat_inc(ifp, ifs6_out_echoreply);      \
+               break;                                          \
+       case MLD_LISTENER_QUERY:                                \
+               icmp6_ifstat_inc(ifp, ifs6_out_mldquery);       \
+               break;                                          \
+       case MLD_LISTENER_REPORT:                               \
+               icmp6_ifstat_inc(ifp, ifs6_out_mldreport);      \
+               break;                                          \
+       case MLD_LISTENER_DONE:                                 \
+               icmp6_ifstat_inc(ifp, ifs6_out_mlddone);        \
+               break;                                          \
+       case ND_ROUTER_SOLICIT:                                 \
+               icmp6_ifstat_inc(ifp, ifs6_out_routersolicit);  \
+               break;                                          \
+       case ND_ROUTER_ADVERT:                                  \
+               icmp6_ifstat_inc(ifp, ifs6_out_routeradvert);   \
+               break;                                          \
+       case ND_NEIGHBOR_SOLICIT:                               \
+               icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);\
+               break;                                          \
+       case ND_NEIGHBOR_ADVERT:                                \
+               icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
+               break;                                          \
+       case ND_REDIRECT:                                       \
+               icmp6_ifstat_inc(ifp, ifs6_out_redirect);       \
+               break;                                          \
+       }                                                       \
 } while (0)
 
 extern int     icmp6_rediraccept;      /* accept/process redirects */
@@ -793,6 +811,6 @@ extern int  icmp6_redirtimeout;     /* cache time for redirect routes */
 #define ICMP6_NODEINFO_TMPADDROK       0x4
 #define ICMP6_NODEINFO_GLOBALOK                0x8
 
-#endif /* KERNEL_PRIVATE */
+#endif /* BSD_KERNEL_PRIVATE */
 
 #endif /* !_NETINET_ICMP6_H_ */