home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / netinet6 / in6.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  24.3 KB  |  711 lines

  1. /*    $KAME: in6.h,v 1.40 2000/03/25 07:23:42 sumikawa Exp $    */
  2.  
  3. /*
  4.  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. Neither the name of the project nor the names of its contributors
  16.  *    may be used to endorse or promote products derived from this software
  17.  *    without specific prior written permission.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  20.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  23.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29.  * SUCH DAMAGE.
  30.  */
  31.  
  32. /*
  33.  * Copyright (c) 1982, 1986, 1990, 1993
  34.  *    The Regents of the University of California.  All rights reserved.
  35.  *
  36.  * Redistribution and use in source and binary forms, with or without
  37.  * modification, are permitted provided that the following conditions
  38.  * are met:
  39.  * 1. Redistributions of source code must retain the above copyright
  40.  *    notice, this list of conditions and the following disclaimer.
  41.  * 2. Redistributions in binary form must reproduce the above copyright
  42.  *    notice, this list of conditions and the following disclaimer in the
  43.  *    documentation and/or other materials provided with the distribution.
  44.  * 3. All advertising materials mentioning features or use of this software
  45.  *    must display the following acknowledgement:
  46.  *    This product includes software developed by the University of
  47.  *    California, Berkeley and its contributors.
  48.  * 4. Neither the name of the University nor the names of its contributors
  49.  *    may be used to endorse or promote products derived from this software
  50.  *    without specific prior written permission.
  51.  *
  52.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  53.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  54.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  55.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  56.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  57.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  58.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  59.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  60.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  61.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  62.  * SUCH DAMAGE.
  63.  *
  64.  *    @(#)in.h    8.3 (Berkeley) 1/3/94
  65.  */
  66.  
  67. #ifndef __KAME_NETINET_IN_H_INCLUDED_
  68. #error "do not include netinet6/in6.h directly, include netinet/in.h"
  69. #endif
  70.  
  71. #ifndef _NETINET6_IN6_H_
  72. #define _NETINET6_IN6_H_
  73.  
  74. #if !defined(_XOPEN_SOURCE)
  75. #include <sys/queue.h>
  76. #endif
  77.  
  78. /*
  79.  * Identification of the network protocol stack
  80.  */
  81. #define __KAME__
  82. #define __KAME_VERSION        "STABLE 20000425"
  83.  
  84. /*
  85.  * Local port number conventions:
  86.  *
  87.  * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
  88.  * unless a kernel is compiled with IPNOPRIVPORTS defined.
  89.  *
  90.  * When a user does a bind(2) or connect(2) with a port number of zero,
  91.  * a non-conflicting local port address is chosen.
  92.  *
  93.  * The default range is IPPORT_ANONMIX to IPPORT_ANONMAX, although
  94.  * that is settable by sysctl(3); net.inet.ip.anonportmin and
  95.  * net.inet.ip.anonportmax respectively.
  96.  *
  97.  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
  98.  * default assignment range.
  99.  *
  100.  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
  101.  *
  102.  * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
  103.  * and exists only for FreeBSD compatibility purposes.
  104.  *
  105.  * The value IP_PORTRANGE_LOW changes the range to the "low" are
  106.  * that is (by convention) restricted to privileged processes.
  107.  * This convention is based on "vouchsafe" principles only.
  108.  * It is only secure if you trust the remote host to restrict these ports.
  109.  * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
  110.  */
  111.  
  112. #define    IPV6PORT_RESERVED    1024
  113. #define    IPV6PORT_ANONMIN    49152
  114. #define    IPV6PORT_ANONMAX    65535
  115. #define    IPV6PORT_RESERVEDMIN    600
  116. #define    IPV6PORT_RESERVEDMAX    (IPV6PORT_RESERVED-1)
  117.  
  118. /*
  119.  * IPv6 address
  120.  */
  121. struct in6_addr {
  122.     union {
  123.         u_int8_t   __u6_addr8[16];
  124.         u_int16_t  __u6_addr16[8];
  125.         u_int32_t  __u6_addr32[4];
  126.     } __u6_addr;            /* 128-bit IP6 address */
  127. };
  128.  
  129. #define s6_addr   __u6_addr.__u6_addr8
  130. #ifdef KERNEL    /*XXX nonstandard*/
  131. #define s6_addr8  __u6_addr.__u6_addr8
  132. #define s6_addr16 __u6_addr.__u6_addr16
  133. #define s6_addr32 __u6_addr.__u6_addr32
  134. #endif
  135.  
  136. #define INET6_ADDRSTRLEN    46
  137.  
  138. /*
  139.  * Socket address for IPv6
  140.  */
  141. #if !defined(_XOPEN_SOURCE)
  142. #define SIN6_LEN
  143. #endif
  144. struct sockaddr_in6 {
  145.     u_int8_t    sin6_len;    /* length of this struct(sa_family_t)*/
  146.     u_int8_t    sin6_family;    /* AF_INET6 (sa_family_t) */
  147.     u_int16_t    sin6_port;    /* Transport layer port # (in_port_t)*/
  148.     u_int32_t    sin6_flowinfo;    /* IP6 flow information */
  149.     struct in6_addr    sin6_addr;    /* IP6 address */
  150.     u_int32_t    sin6_scope_id;    /* intface scope id */
  151. };
  152.  
  153. /*
  154.  * Local definition for masks
  155.  */
  156. #ifdef KERNEL    /*XXX nonstandard*/
  157. #define IN6MASK0    {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
  158. #define IN6MASK32    {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
  159.                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  160. #define IN6MASK64    {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  161.                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  162. #define IN6MASK96    {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  163.                 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
  164. #define IN6MASK128    {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
  165.                 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
  166. #endif
  167.  
  168. #ifdef KERNEL
  169. extern const struct in6_addr in6mask0;
  170. extern const struct in6_addr in6mask32;
  171. extern const struct in6_addr in6mask64;
  172. extern const struct in6_addr in6mask96;
  173. extern const struct in6_addr in6mask128;
  174. #endif /* KERNEL */
  175.  
  176. /*
  177.  * Macros started with IPV6_ADDR is KAME local
  178.  */
  179. #ifdef KERNEL    /*XXX nonstandard*/
  180. #if BYTE_ORDER == BIG_ENDIAN
  181. #define IPV6_ADDR_INT32_ONE    1
  182. #define IPV6_ADDR_INT32_TWO    2
  183. #define IPV6_ADDR_INT32_MNL    0xff010000
  184. #define IPV6_ADDR_INT32_MLL    0xff020000
  185. #define IPV6_ADDR_INT32_SMP    0x0000ffff
  186. #define IPV6_ADDR_INT16_ULL    0xfe80
  187. #define IPV6_ADDR_INT16_USL    0xfec0
  188. #define IPV6_ADDR_INT16_MLL    0xff02
  189. #elif BYTE_ORDER == LITTLE_ENDIAN
  190. #define IPV6_ADDR_INT32_ONE    0x01000000
  191. #define IPV6_ADDR_INT32_TWO    0x02000000
  192. #define IPV6_ADDR_INT32_MNL    0x000001ff
  193. #define IPV6_ADDR_INT32_MLL    0x000002ff
  194. #define IPV6_ADDR_INT32_SMP    0xffff0000
  195. #define IPV6_ADDR_INT16_ULL    0x80fe
  196. #define IPV6_ADDR_INT16_USL    0xc0fe
  197. #define IPV6_ADDR_INT16_MLL    0x02ff
  198. #endif
  199. #endif
  200.  
  201. /*
  202.  * Definition of some useful macros to handle IP6 addresses
  203.  */
  204. #define IN6ADDR_ANY_INIT \
  205.     {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  206.         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
  207. #define IN6ADDR_LOOPBACK_INIT \
  208.     {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  209.         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  210. #define IN6ADDR_NODELOCAL_ALLNODES_INIT \
  211.     {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  212.         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  213. #define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
  214.     {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  215.         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
  216. #define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
  217.     {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
  218.         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
  219.  
  220. #ifdef KERNEL
  221. extern const struct in6_addr in6addr_any;
  222. extern const struct in6_addr in6addr_loopback;
  223. extern const struct in6_addr in6addr_nodelocal_allnodes;
  224. extern const struct in6_addr in6addr_linklocal_allnodes;
  225. extern const struct in6_addr in6addr_linklocal_allrouters;
  226. #endif
  227.  
  228. /*
  229.  * Equality
  230.  * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
  231.  * does not supply memcmp().  For userland memcmp() is preferred as it is
  232.  * in ANSI standard.
  233.  */
  234. #ifdef KERNEL
  235. #define IN6_ARE_ADDR_EQUAL(a, b)            \
  236.     (bcmp((a), (b), sizeof(struct in6_addr)) == 0)
  237. #else
  238. #define IN6_ARE_ADDR_EQUAL(a, b)            \
  239.     (memcmp((a), (b), sizeof(struct in6_addr)) == 0)
  240. #endif
  241.  
  242. /*
  243.  * Unspecified
  244.  */
  245. #define IN6_IS_ADDR_UNSPECIFIED(a)    \
  246.     ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&    \
  247.      (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&    \
  248.      (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&    \
  249.      (*(u_int32_t *)(&(a)->s6_addr[12]) == 0))
  250.  
  251. /*
  252.  * Loopback
  253.  */
  254. #define IN6_IS_ADDR_LOOPBACK(a)        \
  255.     ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&    \
  256.      (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&    \
  257.      (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&    \
  258.      (*(u_int32_t *)(&(a)->s6_addr[12]) == ntohl(1)))
  259.  
  260. /*
  261.  * IPv4 compatible
  262.  */
  263. #define IN6_IS_ADDR_V4COMPAT(a)        \
  264.     ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&    \
  265.      (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&    \
  266.      (*(u_int32_t *)(&(a)->s6_addr[8]) == 0) &&    \
  267.      (*(u_int32_t *)(&(a)->s6_addr[12]) != 0) &&    \
  268.      (*(u_int32_t *)(&(a)->s6_addr[12]) != ntohl(1)))
  269.  
  270. /*
  271.  * Mapped
  272.  */
  273. #define IN6_IS_ADDR_V4MAPPED(a)              \
  274.     ((*(u_int32_t *)(&(a)->s6_addr[0]) == 0) &&    \
  275.      (*(u_int32_t *)(&(a)->s6_addr[4]) == 0) &&    \
  276.      (*(u_int32_t *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
  277.  
  278. /*
  279.  * KAME Scope Values
  280.  */
  281.  
  282. #ifdef KERNEL    /*XXX nonstandard*/
  283. #define IPV6_ADDR_SCOPE_NODELOCAL    0x01
  284. #define IPV6_ADDR_SCOPE_LINKLOCAL    0x02
  285. #define IPV6_ADDR_SCOPE_SITELOCAL    0x05
  286. #define IPV6_ADDR_SCOPE_ORGLOCAL    0x08    /* just used in this file */
  287. #define IPV6_ADDR_SCOPE_GLOBAL        0x0e
  288. #else
  289. #define __IPV6_ADDR_SCOPE_NODELOCAL    0x01
  290. #define __IPV6_ADDR_SCOPE_LINKLOCAL    0x02
  291. #define __IPV6_ADDR_SCOPE_SITELOCAL    0x05
  292. #define __IPV6_ADDR_SCOPE_ORGLOCAL    0x08    /* just used in this file */
  293. #define __IPV6_ADDR_SCOPE_GLOBAL    0x0e
  294. #endif
  295.  
  296. /*
  297.  * Unicast Scope
  298.  * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
  299.  */
  300. #define IN6_IS_ADDR_LINKLOCAL(a)    \
  301.     (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
  302. #define IN6_IS_ADDR_SITELOCAL(a)    \
  303.     (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
  304.  
  305. /*
  306.  * Multicast
  307.  */
  308. #define IN6_IS_ADDR_MULTICAST(a)    ((a)->s6_addr[0] == 0xff)
  309.  
  310. #ifdef KERNEL    /*XXX nonstandard*/
  311. #define IPV6_ADDR_MC_SCOPE(a)        ((a)->s6_addr[1] & 0x0f)
  312. #else
  313. #define __IPV6_ADDR_MC_SCOPE(a)        ((a)->s6_addr[1] & 0x0f)
  314. #endif
  315.  
  316. /*
  317.  * Multicast Scope
  318.  */
  319. #ifdef KERNEL    /*refers nonstandard items */
  320. #define IN6_IS_ADDR_MC_NODELOCAL(a)    \
  321.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  322.      (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
  323. #define IN6_IS_ADDR_MC_LINKLOCAL(a)    \
  324.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  325.      (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
  326. #define IN6_IS_ADDR_MC_SITELOCAL(a)    \
  327.     (IN6_IS_ADDR_MULTICAST(a) &&     \
  328.      (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
  329. #define IN6_IS_ADDR_MC_ORGLOCAL(a)    \
  330.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  331.      (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
  332. #define IN6_IS_ADDR_MC_GLOBAL(a)    \
  333.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  334.      (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
  335. #else
  336. #define IN6_IS_ADDR_MC_NODELOCAL(a)    \
  337.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  338.      (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
  339. #define IN6_IS_ADDR_MC_LINKLOCAL(a)    \
  340.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  341.      (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
  342. #define IN6_IS_ADDR_MC_SITELOCAL(a)    \
  343.     (IN6_IS_ADDR_MULTICAST(a) &&     \
  344.      (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
  345. #define IN6_IS_ADDR_MC_ORGLOCAL(a)    \
  346.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  347.      (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
  348. #define IN6_IS_ADDR_MC_GLOBAL(a)    \
  349.     (IN6_IS_ADDR_MULTICAST(a) &&    \
  350.      (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
  351. #endif
  352.  
  353. /*
  354.  * Wildcard Socket
  355.  */
  356. #if 0    /*pre-RFC2553*/
  357. #define IN6_IS_ADDR_ANY(a)    IN6_IS_ADDR_UNSPECIFIED(a)
  358. #endif
  359.  
  360. /*
  361.  * KAME Scope
  362.  */
  363. #ifdef KERNEL    /*nonstandard*/
  364. #define IN6_IS_SCOPE_LINKLOCAL(a)    \
  365.     ((IN6_IS_ADDR_LINKLOCAL(a)) ||    \
  366.      (IN6_IS_ADDR_MC_LINKLOCAL(a)))
  367. #endif
  368.  
  369. /*
  370.  * IP6 route structure
  371.  */
  372. #if !defined(_XOPEN_SOURCE)
  373. struct route_in6 {
  374.     struct    rtentry *ro_rt;
  375.     struct    sockaddr_in6 ro_dst;
  376. };
  377. #endif
  378.  
  379. /*
  380.  * Options for use with [gs]etsockopt at the IPV6 level.
  381.  * First word of comment is data type; bool is stored in int.
  382.  */
  383. /* no hdrincl */
  384. #if 0 /* the followings are relic in IPv4 and hence are disabled */
  385. #define IPV6_OPTIONS        1  /* buf/ip6_opts; set/get IP6 options */
  386. #define IPV6_RECVOPTS        5  /* bool; receive all IP6 opts w/dgram */
  387. #define IPV6_RECVRETOPTS    6  /* bool; receive IP6 opts for response */
  388. #define IPV6_RECVDSTADDR    7  /* bool; receive IP6 dst addr w/dgram */
  389. #define IPV6_RETOPTS        8  /* ip6_opts; set/get IP6 options */
  390. #endif
  391. #define IPV6_SOCKOPT_RESERVED1    3  /* reserved for future use */
  392. #define IPV6_UNICAST_HOPS    4  /* int; IP6 hops */
  393. #define IPV6_MULTICAST_IF    9  /* u_char; set/get IP6 multicast i/f  */
  394. #define IPV6_MULTICAST_HOPS    10 /* u_char; set/get IP6 multicast hops */
  395. #define IPV6_MULTICAST_LOOP    11 /* u_char; set/get IP6 multicast loopback */
  396. #define IPV6_JOIN_GROUP        12 /* ip6_mreq; join a group membership */
  397. #define IPV6_LEAVE_GROUP    13 /* ip6_mreq; leave a group membership */
  398. #define IPV6_PORTRANGE        14 /* int; range to choose for unspec port */
  399. #define ICMP6_FILTER        18 /* icmp6_filter; icmp6 filter */
  400. #define IPV6_PKTINFO        19 /* in6_pktinfo; send if, src addr */
  401. #define IPV6_HOPLIMIT        20 /* int; send hop limit */
  402. #define IPV6_NEXTHOP        21 /* sockaddr; next hop addr */
  403. #define IPV6_HOPOPTS        22 /* ip6_hbh; send hop-by-hop option */
  404. #define IPV6_DSTOPTS        23 /* ip6_dest; send dst option befor rthdr */
  405. #define IPV6_RTHDR        24 /* ip6_rthdr; send routing header */
  406. #define IPV6_PKTOPTIONS        25 /* buf/cmsghdr; set/get IPv6 options */
  407.                    /* obsoleted by 2292bis */
  408. #define IPV6_CHECKSUM        26 /* int; checksum offset for raw socket */
  409. #define IPV6_BINDV6ONLY        27 /* bool; only bind INET6 at null bind */
  410.  
  411. #if 1 /*IPSEC*/
  412. #define IPV6_IPSEC_POLICY    28 /* struct; get/set security policy */
  413. #endif
  414. #define IPV6_FAITH        29 /* bool; accept FAITH'ed connections */
  415.  
  416. #if 1 /*IPV6FIREWALL*/
  417. #define IPV6_FW_ADD        30 /* add a firewall rule to chain */
  418. #define IPV6_FW_DEL        31 /* delete a firewall rule from chain */
  419. #define IPV6_FW_FLUSH        32 /* flush firewall rule chain */
  420. #define IPV6_FW_ZERO        33 /* clear single/all firewall counter(s) */
  421. #define IPV6_FW_GET        34 /* get entire firewall rule chain */
  422. #endif
  423.  
  424. /* new socket options introduced in RFC2292bis */
  425. #define IPV6_RTHDRDSTOPTS    35 /* ip6_dest; send dst option before rthdr */
  426.  
  427. #define IPV6_RECVPKTINFO    36 /* bool; recv if, dst addr */
  428. #define IPV6_RECVHOPLIMIT    37 /* bool; recv hop limit */
  429. #define IPV6_RECVRTHDR        38 /* bool; recv routing header */
  430. #define IPV6_RECVHOPOPTS    39 /* bool; recv hop-by-hop option */
  431. #define IPV6_RECVDSTOPTS    40 /* bool; recv dst option after rthdr */
  432. #define IPV6_RECVRTHDRDSTOPTS    41 /* bool; recv dst option before rthdr */
  433.  
  434. #define IPV6_USE_MIN_MTU    42 /* bool; send packets at the minimum MTU */
  435. #define IPV6_RECVPATHMTU    43 /* bool; notify an according MTU */
  436.  
  437. /* the followings are used as cmsg type only */
  438. #define IPV6_PATHMTU        44 /* 4 bytes int; MTU notification */
  439. #define IPV6_REACHCONF        45 /* no data; ND reachability confirm */
  440.  
  441. #define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
  442. #define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
  443. #define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
  444.  
  445. /*
  446.  * Defaults and limits for options
  447.  */
  448. #define IPV6_DEFAULT_MULTICAST_HOPS 1    /* normally limit m'casts to 1 hop  */
  449. #define IPV6_DEFAULT_MULTICAST_LOOP 1    /* normally hear sends if a member  */
  450.  
  451. /*
  452.  * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
  453.  */
  454. struct ipv6_mreq {
  455.     struct in6_addr    ipv6mr_multiaddr;
  456.     u_int        ipv6mr_interface;
  457. };
  458.  
  459. /*
  460.  * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
  461.  */
  462. struct in6_pktinfo {
  463.     struct in6_addr ipi6_addr;    /* src/dst IPv6 address */
  464.     u_int ipi6_ifindex;        /* send/recv interface index */
  465. };
  466.  
  467. /*
  468.  * Argument for IPV6_PORTRANGE:
  469.  * - which range to search when port is unspecified at bind() or connect()
  470.  */
  471. #define    IPV6_PORTRANGE_DEFAULT    0    /* default range */
  472. #define    IPV6_PORTRANGE_HIGH    1    /* "high" - request firewall bypass */
  473. #define    IPV6_PORTRANGE_LOW    2    /* "low" - vouchsafe security */
  474.  
  475. #if !defined(_XOPEN_SOURCE)
  476. /*
  477.  * Definitions for inet6 sysctl operations.
  478.  *
  479.  * Third level is protocol number.
  480.  * Fourth level is desired variable within that protocol.
  481.  */
  482. #define IPV6PROTO_MAXID    (IPPROTO_PIM + 1)    /* don't list to IPV6PROTO_MAX */
  483.  
  484. #define CTL_IPV6PROTO_NAMES { \
  485.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  486.     { 0, 0 }, \
  487.     { "tcp6", CTLTYPE_NODE }, \
  488.     { 0, 0 }, \
  489.     { 0, 0 }, \
  490.     { 0, 0 }, \
  491.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  492.     { 0, 0 }, \
  493.     { 0, 0 }, \
  494.     { "udp6", CTLTYPE_NODE }, \
  495.     { 0, 0 }, \
  496.     { 0, 0 }, \
  497.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  498.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  499.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  500.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  501.     { 0, 0 }, \
  502.     { "ip6", CTLTYPE_NODE }, \
  503.     { 0, 0 }, \
  504.     { 0, 0 }, \
  505.     { 0, 0 }, \
  506.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  507.     { 0, 0 }, \
  508.     { "ipsec6", CTLTYPE_NODE }, \
  509.     { 0, 0 }, \
  510.     { 0, 0 }, \
  511.     { 0, 0 }, \
  512.     { 0, 0 }, \
  513.     { 0, 0 }, \
  514.     { 0, 0 }, \
  515.     { "icmp6", CTLTYPE_NODE }, \
  516.     { 0, 0 }, \
  517.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  518.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  519.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  520.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  521.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  522.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  523.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  524.     { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
  525.     { 0, 0 }, \
  526.     { 0, 0 }, \
  527.     { 0, 0 }, \
  528.     { "pim6", CTLTYPE_NODE }, \
  529. }
  530.  
  531. /*
  532.  * Names for IP sysctl objects
  533.  */
  534. #define IPV6CTL_FORWARDING    1    /* act as router */
  535. #define IPV6CTL_SENDREDIRECTS    2    /* may send redirects when forwarding*/
  536. #define IPV6CTL_DEFHLIM        3    /* default Hop-Limit */
  537. #ifdef notyet
  538. #define IPV6CTL_DEFMTU        4    /* default MTU */
  539. #endif
  540. #define IPV6CTL_FORWSRCRT    5    /* forward source-routed dgrams */
  541. #define IPV6CTL_STATS        6    /* stats */
  542. #define IPV6CTL_MRTSTATS    7    /* multicast forwarding stats */
  543. #define IPV6CTL_MRTPROTO    8    /* multicast routing protocol */
  544. #define IPV6CTL_MAXFRAGPACKETS    9    /* max packets reassembly queue */
  545. #define IPV6CTL_SOURCECHECK    10    /* verify source route and intf */
  546. #define IPV6CTL_SOURCECHECK_LOGINT 11    /* minimume logging interval */
  547. #define IPV6CTL_ACCEPT_RTADV    12
  548. #define IPV6CTL_KEEPFAITH    13
  549. #define IPV6CTL_LOG_INTERVAL    14
  550. #define IPV6CTL_HDRNESTLIMIT    15
  551. #define IPV6CTL_DAD_COUNT    16
  552. #define IPV6CTL_AUTO_FLOWLABEL    17
  553. #define IPV6CTL_DEFMCASTHLIM    18
  554. #define IPV6CTL_GIF_HLIM    19    /* default HLIM for gif encap packet */
  555. #define IPV6CTL_KAME_VERSION    20
  556. #define IPV6CTL_USE_DEPRECATED    21    /* use deprecated addr (RFC2462 5.5.4) */
  557. #define IPV6CTL_RR_PRUNE    22    /* walk timer for router renumbering */
  558. #if MAPPED_ADDR_ENABLED
  559. #define IPV6CTL_MAPPED_ADDR    23
  560. #endif /* MAPPED_ADDR_ENABLED */
  561. /* New entries should be added here from current IPV6CTL_MAXID value. */
  562. #define IPV6CTL_MAXID        24
  563.  
  564. #if MAPPED_ADDR_ENABLED
  565. #define IPV6CTL_NAMES_MAPPED_ADDR    "mapped_addr"
  566. #define IPV6CTL_TYPE_MAPPED_ADDR    CTLTYPE_INT
  567. #define IPV6CTL_VARS_MAPPED_ADDR    &ip6_mapped_addr_on
  568. #else  /* MAPPED_ADDR_ENABLED */
  569. #define IPV6CTL_NAMES_MAPPED_ADDR    0
  570. #define IPV6CTL_TYPE_MAPPED_ADDR    0
  571. #define IPV6CTL_VARS_MAPPED_ADDR    0
  572. #endif /* MAPPED_ADDR_ENABLED */
  573.  
  574. #if IPV6CTL_BINDV6ONLY
  575. #define IPV6CTL_NAMES_BINDV6ONLY    "bindv6only"
  576. #define IPV6CTL_TYPE_BINDV6ONLY        CTLTYPE_INT
  577. #define IPV6CTL_VARS_BINDV6ONLY        &ip6_bindv6only
  578. #else
  579. #define IPV6CTL_NAMES_BINDV6ONLY    0
  580. #define IPV6CTL_TYPE_BINDV6ONLY    0
  581. #define IPV6CTL_VARS_BINDV6ONLY    0
  582. #endif
  583.  
  584. #define IPV6CTL_NAMES { \
  585.     { 0, 0 }, \
  586.     { "forwarding", CTLTYPE_INT }, \
  587.     { "redirect", CTLTYPE_INT }, \
  588.     { "hlim", CTLTYPE_INT }, \
  589.     { "mtu", CTLTYPE_INT }, \
  590.     { "forwsrcrt", CTLTYPE_INT }, \
  591.     { 0, 0 }, \
  592.     { 0, 0 }, \
  593.     { "mrtproto", CTLTYPE_INT }, \
  594.     { "maxfragpackets", CTLTYPE_INT }, \
  595.     { "sourcecheck", CTLTYPE_INT }, \
  596.     { "sourcecheck_logint", CTLTYPE_INT }, \
  597.     { "accept_rtadv", CTLTYPE_INT }, \
  598.     { "keepfaith", CTLTYPE_INT }, \
  599.     { "log_interval", CTLTYPE_INT }, \
  600.     { "hdrnestlimit", CTLTYPE_INT }, \
  601.     { "dad_count", CTLTYPE_INT }, \
  602.     { "auto_flowlabel", CTLTYPE_INT }, \
  603.     { "defmcasthlim", CTLTYPE_INT }, \
  604.     { "gifhlim", CTLTYPE_INT }, \
  605.     { "kame_version", CTLTYPE_STRING }, \
  606.     { "use_deprecated", CTLTYPE_INT }, \
  607.     { "rr_prune", CTLTYPE_INT }, \
  608.     { IPV6CTL_NAMES_MAPPED_ADDR, IPV6CTL_TYPE_MAPPED_ADDR }, \
  609.     { IPV6CTL_NAMES_BINDV6ONLY, IPV6CTL_TYPE_BINDV6ONLY }, \
  610. }
  611.  
  612. #ifdef __bsdi__
  613. #define IPV6CTL_VARS { \
  614.     0, \
  615.     &ip6_forwarding, \
  616.     &ip6_sendredirects, \
  617.     &ip6_defhlim, \
  618.     0, \
  619.     &ip6_forward_srcrt, \
  620.     0, \
  621.     0, \
  622.     0, \
  623.     &ip6_maxfragpackets, \
  624.     &ip6_sourcecheck, \
  625.     &ip6_sourcecheck_interval, \
  626.     &ip6_accept_rtadv, \
  627.     &ip6_keepfaith, \
  628.     &ip6_log_interval, \
  629.     &ip6_hdrnestlimit, \
  630.     &ip6_dad_count, \
  631.     &ip6_auto_flowlabel, \
  632.     &ip6_defmcasthlim, \
  633.     &ip6_gif_hlim, \
  634.     0, \
  635.     &ip6_use_deprecated, \
  636.     &ip6_rr_prune, \
  637.     IPV6CTL_VARS_MAPPED_ADDR, \
  638.     IPV6CTL_VARS_BINDV6ONLY, \
  639. }
  640. #endif
  641. #endif /* !_XOPEN_SOURCE */
  642.  
  643. #ifdef KERNEL
  644. struct cmsghdr;
  645.  
  646. int    in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t));
  647. int    in6_localaddr __P((struct in6_addr *));
  648. int    in6_addrscope __P((struct in6_addr *));
  649. struct    in6_ifaddr *in6_ifawithscope __P((struct ifnet *, struct in6_addr *));
  650. struct    in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *));
  651. extern void in6_if_up __P((struct ifnet *));
  652. #if MAPPED_ADDR_ENABLED
  653. struct sockaddr;
  654.  
  655. void    in6_sin6_2_sin __P((struct sockaddr_in *sin,
  656.                 struct sockaddr_in6 *sin6));
  657. void    in6_sin_2_v4mapsin6 __P((struct sockaddr_in *sin,
  658.                  struct sockaddr_in6 *sin6));
  659. void    in6_sin6_2_sin_in_sock __P((struct sockaddr *nam));
  660. void    in6_sin_2_v4mapsin6_in_sock __P((struct sockaddr **nam));
  661. #endif /* MAPPED_ADDR_ENABLED */
  662.  
  663. #define    satosin6(sa)    ((struct sockaddr_in6 *)(sa))
  664. #define    sin6tosa(sin6)    ((struct sockaddr *)(sin6))
  665. #define    ifatoia6(ifa)    ((struct in6_ifaddr *)(ifa))
  666. #endif /* KERNEL */
  667.  
  668. __BEGIN_DECLS
  669. struct cmsghdr;
  670.  
  671. extern int inet6_option_space __P((int));
  672. extern int inet6_option_init __P((void *, struct cmsghdr **, int));
  673. extern int inet6_option_append __P((struct cmsghdr *, const u_int8_t *,
  674.     int, int));
  675. extern u_int8_t *inet6_option_alloc __P((struct cmsghdr *, int, int, int));
  676. extern int inet6_option_next __P((const struct cmsghdr *, u_int8_t **));
  677. extern int inet6_option_find __P((const struct cmsghdr *, u_int8_t **, int));
  678.  
  679. extern size_t inet6_rthdr_space __P((int, int));
  680. extern struct cmsghdr *inet6_rthdr_init __P((void *, int));
  681. extern int inet6_rthdr_add __P((struct cmsghdr *, const struct in6_addr *,
  682.         unsigned int));
  683. extern int inet6_rthdr_lasthop __P((struct cmsghdr *, unsigned int));
  684. #if 0 /* not implemented yet */
  685. extern int inet6_rthdr_reverse __P((const struct cmsghdr *, struct cmsghdr *));
  686. #endif
  687. extern int inet6_rthdr_segments __P((const struct cmsghdr *));
  688. extern struct in6_addr *inet6_rthdr_getaddr __P((struct cmsghdr *, int));
  689. extern int inet6_rthdr_getflags __P((const struct cmsghdr *, int));
  690.  
  691. extern int inet6_opt_init __P((void *, size_t));
  692. extern int inet6_opt_append __P((void *, size_t, int, u_int8_t,
  693.                  size_t, u_int8_t, void **));
  694. extern int inet6_opt_finish __P((void *, size_t, int));
  695. extern int inet6_opt_set_val __P((void *, size_t, void *, int));
  696.  
  697. extern int inet6_opt_next __P((void *, size_t, int, u_int8_t *,
  698.                    size_t *, void **));
  699. extern int inet6_opt_find __P((void *, size_t, int, u_int8_t,
  700.               size_t *, void **));
  701. extern int inet6_opt_get_val __P((void *, size_t, void *, int));
  702. extern size_t inet6_rth_space __P((int, int));
  703. extern void *inet6_rth_init __P((void *, int, int, int));
  704. extern int inet6_rth_add __P((void *, const struct in6_addr *));
  705. extern int inet6_rth_reverse __P((const void *, void *));
  706. extern int inet6_rth_segments __P((const void *));
  707. extern struct in6_addr *inet6_rth_getaddr __P((const void *, int));
  708. __END_DECLS
  709.  
  710. #endif /* !_NETINET6_IN6_H_ */
  711.