Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

ip6_misc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1993, 1994, 1997
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that: (1) source code distributions
00007  * retain the above copyright notice and this paragraph in its entirety, (2)
00008  * distributions including binary code include the above copyright notice and
00009  * this paragraph in its entirety in the documentation or other materials
00010  * provided with the distribution, and (3) all advertising materials mentioning
00011  * features or use of this software display the following acknowledgement:
00012  * ``This product includes software developed by the University of California,
00013  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
00014  * the University nor the names of its contributors may be used to endorse
00015  * or promote products derived from this software without specific prior
00016  * written permission.
00017  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020  *
00021  * @(#) $Header$ (LBL)
00022  */
00023 
00024 /*
00025  * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
00026  */
00027 
00028 #include <winsock2.h>
00029 
00030 #ifndef __MINGW32__
00031 #include <ws2tcpip.h>
00032 #endif /* __MINGW32__ */
00033 
00034 #define IN_MULTICAST(a)         IN_CLASSD(a)
00035 
00036 #define IN_EXPERIMENTAL(a)      ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000)
00037 
00038 #define IN_LOOPBACKNET          127
00039 
00040 #ifdef __MINGW32__
00041 /* IPv6 address */
00042 struct in6_addr
00043   {
00044     union
00045       {
00046         u_int8_t                u6_addr8[16];
00047         u_int16_t       u6_addr16[8];
00048         u_int32_t       u6_addr32[4];
00049       } in6_u;
00050 #define s6_addr                 in6_u.u6_addr8
00051 #define s6_addr16               in6_u.u6_addr16
00052 #define s6_addr32               in6_u.u6_addr32
00053 #define s6_addr64               in6_u.u6_addr64
00054   };
00055 
00056 #define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
00057 #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
00058 #endif /* __MINGW32__ */
00059 
00060 
00061 #if (defined WIN32) || (defined __MINGW32__)
00062 typedef unsigned short  sa_family_t;
00063 #endif
00064 
00065 
00066 #ifdef __MINGW32__
00067 
00068 #define __SOCKADDR_COMMON(sa_prefix) \
00069   sa_family_t sa_prefix##family
00070 
00071 /* Ditto, for IPv6.  */
00072 struct sockaddr_in6
00073   {
00074     __SOCKADDR_COMMON (sin6_);
00075     u_int16_t sin6_port;                /* Transport layer port # */
00076     u_int32_t sin6_flowinfo;    /* IPv6 flow information */
00077     struct in6_addr sin6_addr;  /* IPv6 address */
00078   };
00079 
00080 #define IN6_IS_ADDR_V4MAPPED(a) \
00081         ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
00082          (((u_int32_t *) (a))[2] == htonl (0xffff)))
00083 
00084 #define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
00085 
00086 #define IN6_IS_ADDR_LINKLOCAL(a) \
00087         ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
00088 
00089 #define IN6_IS_ADDR_LOOPBACK(a) \
00090         (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
00091          ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
00092 #endif /* __MINGW32__ */
00093 
00094 #define ip6_vfc   ip6_ctlun.ip6_un2_vfc
00095 #define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
00096 #define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
00097 #define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
00098 #define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
00099 #define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
00100 
00101 #define nd_rd_type               nd_rd_hdr.icmp6_type
00102 #define nd_rd_code               nd_rd_hdr.icmp6_code
00103 #define nd_rd_cksum              nd_rd_hdr.icmp6_cksum
00104 #define nd_rd_reserved           nd_rd_hdr.icmp6_data32[0]
00105 
00106 /*
00107  *      IPV6 extension headers
00108  */
00109 #define IPPROTO_HOPOPTS         0       /* IPv6 hop-by-hop options      */
00110 #define IPPROTO_IPV6            41  /* IPv6 header.  */
00111 #define IPPROTO_ROUTING         43      /* IPv6 routing header          */
00112 #define IPPROTO_FRAGMENT        44      /* IPv6 fragmentation header    */
00113 #define IPPROTO_ESP             50      /* encapsulating security payload */
00114 #define IPPROTO_AH              51      /* authentication header        */
00115 #define IPPROTO_ICMPV6          58      /* ICMPv6                       */
00116 #define IPPROTO_NONE            59      /* IPv6 no next header          */
00117 #define IPPROTO_DSTOPTS         60      /* IPv6 destination options     */
00118 #define IPPROTO_PIM                     103 /* Protocol Independent Multicast.  */
00119 
00120 #define  IPV6_RTHDR_TYPE_0 0
00121 
00122 /* Option types and related macros */
00123 #define IP6OPT_PAD1             0x00    /* 00 0 00000 */
00124 #define IP6OPT_PADN             0x01    /* 00 0 00001 */
00125 #define IP6OPT_JUMBO            0xC2    /* 11 0 00010 = 194 */
00126 #define IP6OPT_JUMBO_LEN        6
00127 #define IP6OPT_ROUTER_ALERT     0x05    /* 00 0 00101 */
00128 
00129 #define IP6OPT_RTALERT_LEN      4
00130 #define IP6OPT_RTALERT_MLD      0       /* Datagram contains an MLD message */
00131 #define IP6OPT_RTALERT_RSVP     1       /* Datagram contains an RSVP message */
00132 #define IP6OPT_RTALERT_ACTNET   2       /* contains an Active Networks msg */
00133 #define IP6OPT_MINLEN           2
00134 
00135 #define IP6OPT_BINDING_UPDATE   0xc6    /* 11 0 00110 */
00136 #define IP6OPT_BINDING_ACK      0x07    /* 00 0 00111 */
00137 #define IP6OPT_BINDING_REQ      0x08    /* 00 0 01000 */
00138 #define IP6OPT_HOME_ADDRESS     0xc9    /* 11 0 01001 */
00139 #define IP6OPT_EID              0x8a    /* 10 0 01010 */
00140 
00141 #define IP6OPT_TYPE(o)          ((o) & 0xC0)
00142 #define IP6OPT_TYPE_SKIP        0x00
00143 #define IP6OPT_TYPE_DISCARD     0x40
00144 #define IP6OPT_TYPE_FORCEICMP   0x80
00145 #define IP6OPT_TYPE_ICMP        0xC0
00146 
00147 #define IP6OPT_MUTABLE          0x20
00148 
00149 
00150 #ifdef __MINGW32__
00151 #ifndef EAI_ADDRFAMILY
00152 struct addrinfo {
00153         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
00154         int     ai_family;      /* PF_xxx */
00155         int     ai_socktype;    /* SOCK_xxx */
00156         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
00157         size_t  ai_addrlen;     /* length of ai_addr */
00158         char    *ai_canonname;  /* canonical name for hostname */
00159         struct sockaddr *ai_addr;       /* binary address */
00160         struct addrinfo *ai_next;       /* next structure in linked list */
00161 };
00162 #endif
00163 #endif /* __MINGW32__ */

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2