]> The Tcpdump Group git mirrors - libpcap/blob - Win32/Include/ip6_misc.h
From Krzysztof Halasa <[email protected]>:
[libpcap] / Win32 / Include / ip6_misc.h
1 /*
2 * Copyright (c) 1993, 1994, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * @(#) $Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.2 2002-08-02 13:59:03 risso Exp $ (LBL)
22 */
23
24 /*
25 * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
26 */
27
28 #include <winsock2.h>
29
30 #ifndef __MINGW32__
31 #include <ws2tcpip.h>
32 #endif /* __MINGW32__ */
33
34 #define IN_MULTICAST(a) IN_CLASSD(a)
35
36 #define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xe0000000) == 0xe0000000)
37
38 #define IN_LOOPBACKNET 127
39
40 #ifdef __MINGW32__
41 /* IPv6 address */
42 struct in6_addr
43 {
44 union
45 {
46 u_int8_t u6_addr8[16];
47 u_int16_t u6_addr16[8];
48 u_int32_t u6_addr32[4];
49 } in6_u;
50 #define s6_addr in6_u.u6_addr8
51 #define s6_addr16 in6_u.u6_addr16
52 #define s6_addr32 in6_u.u6_addr32
53 #define s6_addr64 in6_u.u6_addr64
54 };
55
56 #define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
57 #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
58 #endif /* __MINGW32__ */
59
60
61 #ifdef __MINGW32__
62 typedef unsigned short sa_family_t;
63
64 #define __SOCKADDR_COMMON(sa_prefix) \
65 sa_family_t sa_prefix##family
66
67 /* Ditto, for IPv6. */
68 struct sockaddr_in6
69 {
70 __SOCKADDR_COMMON (sin6_);
71 u_int16_t sin6_port; /* Transport layer port # */
72 u_int32_t sin6_flowinfo; /* IPv6 flow information */
73 struct in6_addr sin6_addr; /* IPv6 address */
74 };
75
76 #define IN6_IS_ADDR_V4MAPPED(a) \
77 ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
78 (((u_int32_t *) (a))[2] == htonl (0xffff)))
79
80 #define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
81
82 #define IN6_IS_ADDR_LINKLOCAL(a) \
83 ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
84
85 #define IN6_IS_ADDR_LOOPBACK(a) \
86 (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
87 ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
88 #endif /* __MINGW32__ */
89
90 #define ip6_vfc ip6_ctlun.ip6_un2_vfc
91 #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
92 #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
93 #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
94 #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
95 #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
96
97 #define nd_rd_type nd_rd_hdr.icmp6_type
98 #define nd_rd_code nd_rd_hdr.icmp6_code
99 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
100 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
101
102 /*
103 * IPV6 extension headers
104 */
105 #define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
106 #define IPPROTO_IPV6 41 /* IPv6 header. */
107 #define IPPROTO_ROUTING 43 /* IPv6 routing header */
108 #define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
109 #define IPPROTO_ESP 50 /* encapsulating security payload */
110 #define IPPROTO_AH 51 /* authentication header */
111 #define IPPROTO_ICMPV6 58 /* ICMPv6 */
112 #define IPPROTO_NONE 59 /* IPv6 no next header */
113 #define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
114 #define IPPROTO_PIM 103 /* Protocol Independent Multicast. */
115
116 #define IPV6_RTHDR_TYPE_0 0
117
118 /* Option types and related macros */
119 #define IP6OPT_PAD1 0x00 /* 00 0 00000 */
120 #define IP6OPT_PADN 0x01 /* 00 0 00001 */
121 #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
122 #define IP6OPT_JUMBO_LEN 6
123 #define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
124
125 #define IP6OPT_RTALERT_LEN 4
126 #define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
127 #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
128 #define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
129 #define IP6OPT_MINLEN 2
130
131 #define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
132 #define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
133 #define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
134 #define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
135 #define IP6OPT_EID 0x8a /* 10 0 01010 */
136
137 #define IP6OPT_TYPE(o) ((o) & 0xC0)
138 #define IP6OPT_TYPE_SKIP 0x00
139 #define IP6OPT_TYPE_DISCARD 0x40
140 #define IP6OPT_TYPE_FORCEICMP 0x80
141 #define IP6OPT_TYPE_ICMP 0xC0
142
143 #define IP6OPT_MUTABLE 0x20
144
145
146 #ifdef __MINGW32__
147 #ifndef EAI_ADDRFAMILY
148 struct addrinfo {
149 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
150 int ai_family; /* PF_xxx */
151 int ai_socktype; /* SOCK_xxx */
152 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
153 size_t ai_addrlen; /* length of ai_addr */
154 char *ai_canonname; /* canonical name for hostname */
155 struct sockaddr *ai_addr; /* binary address */
156 struct addrinfo *ai_next; /* next structure in linked list */
157 };
158 #endif
159 #endif /* __MINGW32__ */