]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/ip6.h
xnu-1699.22.81.tar.gz
[apple/xnu.git] / bsd / netinet / ip6.h
index 38060eb93a86799905908d3e43dbfd7ad1d1d859..a740ddc49e1a1d2b8d3e2b2e2dd7c90a37d8f086 100644 (file)
@@ -1,16 +1,19 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * Copyright (c) 1999-2003 Apple Computer, 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
- * 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.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * 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
@@ -20,7 +23,7 @@
  * Please see the License for the specific language governing rights and
  * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*     $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $*/
 
@@ -167,7 +170,10 @@ struct ip6_dest {
 #define IP6OPT_JUMBO           0xC2    /* 11 0 00010 = 194 */
 #define IP6OPT_NSAP_ADDR       0xC3    /* 11 0 00011 */
 #define IP6OPT_TUNNEL_LIMIT    0x04    /* 00 0 00100 */
+#ifndef KERNEL_PRIVATE
 #define IP6OPT_RTALERT         0x05    /* 00 0 00101 (KAME definition) */
+#endif
+#define IP6OPT_ROUTER_ALERT    0x05    /* 00 0 00101 (RFC3542, recommended) */
 
 #define IP6OPT_RTALERT_LEN     4
 #define IP6OPT_RTALERT_MLD     0       /* Datagram contains an MLD message */
@@ -175,10 +181,6 @@ struct ip6_dest {
 #define IP6OPT_RTALERT_ACTNET  2       /* contains an Active Networks msg */
 #define IP6OPT_MINLEN          2
 
-#define IP6OPT_BINDING_UPDATE  0xc6    /* 11 0 00110 */
-#define IP6OPT_BINDING_ACK     0x07    /* 00 0 00111 */
-#define IP6OPT_BINDING_REQ     0x08    /* 00 0 01000 */
-#define IP6OPT_HOME_ADDRESS    0xc9    /* 11 0 01001 */
 #define IP6OPT_EID             0x8a    /* 10 0 01010 */
 
 #define IP6OPT_TYPE(o)         ((o) & 0xC0)
@@ -189,8 +191,56 @@ struct ip6_dest {
 
 #define IP6OPT_MUTABLE         0x20
 
+/* IPv6 options: common part */
+struct ip6_opt {
+       u_int8_t ip6o_type;
+       u_int8_t ip6o_len;
+} __attribute__((__packed__));
+
+/* Jumbo Payload Option */
+struct ip6_opt_jumbo {
+       u_int8_t ip6oj_type;
+       u_int8_t ip6oj_len;
+       u_int8_t ip6oj_jumbo_len[4];
+} __attribute__((__packed__));
 #define IP6OPT_JUMBO_LEN       6
 
+/* NSAP Address Option */
+struct ip6_opt_nsap {
+       u_int8_t ip6on_type;
+       u_int8_t ip6on_len;
+       u_int8_t ip6on_src_nsap_len;
+       u_int8_t ip6on_dst_nsap_len;
+       /* followed by source NSAP */
+       /* followed by destination NSAP */
+}__attribute__((__packed__));
+
+/* Tunnel Limit Option */
+struct ip6_opt_tunnel {
+       u_int8_t ip6ot_type;
+       u_int8_t ip6ot_len;
+       u_int8_t ip6ot_encap_limit;
+}__attribute__((__packed__));
+
+/* Router Alert Option */
+struct ip6_opt_router {
+       u_int8_t ip6or_type;
+       u_int8_t ip6or_len;
+       u_int8_t ip6or_value[2];
+}__attribute__((__packed__));
+/* Router alert values (in network byte order) */
+#if BYTE_ORDER == BIG_ENDIAN
+#define IP6_ALERT_MLD  0x0000
+#define IP6_ALERT_RSVP 0x0001
+#define IP6_ALERT_AN   0x0002
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define IP6_ALERT_MLD  0x0000
+#define IP6_ALERT_RSVP 0x0100
+#define IP6_ALERT_AN   0x0200
+#endif /* LITTLE_ENDIAN */
+#endif
+
 /* Routing header */
 struct ip6_rthdr {
        u_int8_t  ip6r_nxt;     /* next header */
@@ -232,16 +282,16 @@ struct ip6_frag {
 /*
  * Internet implementation parameters.
  */
-#define IPV6_MAXHLIM   255     /* maximun hoplimit */
+#define IPV6_MAXHLIM   255     /* maximum hoplimit */
 #define IPV6_DEFHLIM   64      /* default hlim */
 #define IPV6_FRAGTTL   120     /* ttl for fragment packets, in slowtimo tick */
-#define IPV6_HLIMDEC   1       /* subtracted when forwaeding */
+#define IPV6_HLIMDEC   1       /* subtracted when forwarding */
 
 #define IPV6_MMTU      1280    /* minimal MTU and reassembly. 1024 + 256 */
 #define IPV6_MAXPACKET 65535   /* ip6 max packet size without Jumbo payload*/
+#define IPV6_MAXOPTHDR 2048    /* max option header size, 256 64-bit words */
 
-#ifdef KERNEL
-#ifdef __APPLE_API_PRIVATE
+#ifdef KERNEL_PRIVATE
 /*
  * IP6_EXTHDR_CHECK ensures that region between the IP6 header and the
  * target header (including IPv6 itself, extension headers and
@@ -251,25 +301,25 @@ struct ip6_frag {
  * supposed to never be matched but is prepared just in case.
  */
 
-#define IP6_EXTHDR_CHECK(m, off, hlen, ret)                            \
+#define IP6_EXTHDR_CHECK(m, off, hlen, action)                         \
 do {                                                                   \
     if ((m)->m_next != NULL) {                                         \
        if (((m)->m_flags & M_LOOP) &&                                  \
            ((m)->m_len < (off) + (hlen)) &&                            \
            (((m) = m_pullup((m), (off) + (hlen))) == NULL)) {          \
                ip6stat.ip6s_exthdrtoolong++;                           \
-               return ret;                                             \
+               action;                                                 \
        } else if ((m)->m_flags & M_EXT) {                              \
                if ((m)->m_len < (off) + (hlen)) {                      \
                        ip6stat.ip6s_exthdrtoolong++;                   \
                        m_freem(m);                                     \
-                       return ret;                                     \
+                       action;                                         \
                }                                                       \
        } else {                                                        \
                if ((m)->m_len < (off) + (hlen)) {                      \
                        ip6stat.ip6s_exthdrtoolong++;                   \
                        m_freem(m);                                     \
-                       return ret;                                     \
+                       action;                                         \
                }                                                       \
        }                                                               \
     } else {                                                           \
@@ -277,7 +327,7 @@ do {                                                                        \
                ip6stat.ip6s_tooshort++;                                \
                in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);   \
                m_freem(m);                                             \
-               return ret;                                             \
+               action;                                                 \
        }                                                               \
     }                                                                  \
 } while (0)
@@ -289,46 +339,12 @@ do {                                                                      \
  * with type "typ".
  * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
  * very top of mbuf.  GET0 is likely to make memory copy than GET.
- *
- * XXX we're now testing this, needs m_pulldown()
  */
-#define IP6_EXTHDR_GET(val, typ, m, off, len) \
-do {                                                                   \
-       struct mbuf *t;                                                 \
-       int tmp;                                                        \
-       if ((m)->m_len >= (off) + (len))                                \
-               (val) = (typ)(mtod((m), caddr_t) + (off));              \
-       else {                                                          \
-               t = m_pulldown((m), (off), (len), &tmp);                \
-               if (t) {                                                \
-                       if (t->m_len < tmp + (len))                     \
-                               panic("m_pulldown malfunction");        \
-                       (val) = (typ)(mtod(t, caddr_t) + tmp);          \
-               } else {                                                \
-                       (val) = (typ)NULL;                              \
-                       (m) = NULL;                                     \
-               }                                                       \
-       }                                                               \
-} while (0)
+#define IP6_EXTHDR_GET(val, typ, m, off, len)                          \
+       M_STRUCT_GET(val, typ, m, off, len)
 
-#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
-do {                                                                   \
-       struct mbuf *t;                                                 \
-       if ((off) == 0)                                                 \
-               (val) = (typ)mtod(m, caddr_t);                          \
-       else {                                                          \
-               t = m_pulldown((m), (off), (len), NULL);                \
-               if (t) {                                                \
-                       if (t->m_len < (len))                           \
-                               panic("m_pulldown malfunction");        \
-                       (val) = (typ)mtod(t, caddr_t);                  \
-               } else {                                                \
-                       (val) = (typ)NULL;                              \
-                       (m) = NULL;                                     \
-               }                                                       \
-       }                                                               \
-} while (0)
-#endif /* __APPLE_API_PRIVATE */
-#endif /*KERNEL*/
+#define IP6_EXTHDR_GET0(val, typ, m, off, len)                         \
+       M_STRUCT_GET0(val, typ, m, off, len)
 
-#endif /* not _NETINET_IP6_H_ */
+#endif /* KERNEL_PRIVATE */
+#endif /* !_NETINET_IP6_H_ */