Full support for Ginger Console
[linux-ginger.git] / drivers / staging / rt3090 / ipv6.h
blobc34a5f2569dd9d28fb4cf2026ad3968eee2dde68
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
27 Module Name:
28 ipv6.h
30 Abstract:
31 Miniport generic portion header file
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
38 #ifndef __IPV6_HDR_H_
39 #define __IPV6_HDR_H_
41 #define IPV6_ADDR_LEN 16
42 #define IPV6_HDR_LEN 40
44 // IPv6 address definition
45 #define IPV6_LINK_LOCAL_ADDR_PREFIX 0xFE8
46 #define IPV6_SITE_LOCAL_ADDR_PREFIX 0xFEC
47 #define IPV6_LOCAL_ADDR_PREFIX 0xFE8
48 #define IPV6_MULTICAST_ADDR_PREFIX 0xFF
49 #define IPV6_LOOPBACK_ADDR 0x1
50 #define IPV6_UNSPECIFIED_ADDR 0x0
52 // defined as sequence in IPv6 header
53 #define IPV6_NEXT_HEADER_HOP_BY_HOP 0x00 // 0
54 #define IPV6_NEXT_HEADER_DESTINATION 0x3c // 60
55 #define IPV6_NEXT_HEADER_ROUTING 0x2b // 43
56 #define IPV6_NEXT_HEADER_FRAGMENT 0x2c // 44
57 #define IPV6_NEXT_HEADER_AUTHENTICATION 0x33 // 51
58 #define IPV6_NEXT_HEADER_ENCAPSULATION 0x32 // 50, RFC-2406
59 #define IPV6_NEXT_HEADER_NONE 0x3b // 59
61 #define IPV6_NEXT_HEADER_TCP 0x06
62 #define IPV6_NEXT_HEADER_UDP 0x11
63 #define IPV6_NEXT_HEADER_ICMPV6 0x3a
65 // ICMPv6 msg type definition
66 #define ICMPV6_MSG_TYPE_ROUTER_SOLICITATION 0x85 // 133
67 #define ROUTER_SOLICITATION_FIXED_LEN 8
69 #define ICMPV6_MSG_TYPE_ROUTER_ADVERTISEMENT 0x86 // 134
70 #define ROUTER_ADVERTISEMENT_FIXED_LEN 16
72 #define ICMPV6_MSG_TYPE_NEIGHBOR_SOLICITATION 0x87 // 135
73 #define NEIGHBOR_SOLICITATION_FIXED_LEN 24
75 #define ICMPV6_MSG_TYPE_NEIGHBOR_ADVERTISEMENT 0x88 // 136
76 #define NEIGHBOR_ADVERTISEMENT_FIXED_LEN 24
78 #define ICMPV6_MSG_TYPE_REDIRECT 0x89 // 137
79 #define REDIRECT_FIXED_LEN 40
81 /* IPv6 Address related structures */
82 typedef struct rt_ipv6_addr_
84 union
86 UCHAR ipv6Addr8[16];
87 USHORT ipv6Addr16[8];
88 UINT32 ipv6Addr32[4];
89 }addr;
90 #define ipv6_addr addr.ipv6Addr8
91 #define ipv6_addr16 addr.ipv6Addr16
92 #define ipv6_addr32 addr.ipv6Addr32
93 }RT_IPV6_ADDR, *PRT_IPV6_ADDR;
96 #define PRINT_IPV6_ADDR(ipv6Addr) \
97 OS_NTOHS((ipv6Addr).ipv6_addr16[0]), \
98 OS_NTOHS((ipv6Addr).ipv6_addr16[1]), \
99 OS_NTOHS((ipv6Addr).ipv6_addr16[2]), \
100 OS_NTOHS((ipv6Addr).ipv6_addr16[3]), \
101 OS_NTOHS((ipv6Addr).ipv6_addr16[4]), \
102 OS_NTOHS((ipv6Addr).ipv6_addr16[5]), \
103 OS_NTOHS((ipv6Addr).ipv6_addr16[6]), \
104 OS_NTOHS((ipv6Addr).ipv6_addr16[7])
107 /*\x14\x14IPv6 Header related structures */
108 typedef struct PACKED _rt_ipv6_hdr_
110 UINT32 ver:4,
111 trafficClass:8,
112 flowLabel:20;
113 USHORT payload_len;
114 UCHAR nextHdr;
115 UCHAR hopLimit;
116 RT_IPV6_ADDR srcAddr;
117 RT_IPV6_ADDR dstAddr;
118 }RT_IPV6_HDR, *PRT_IPV6_HDR;
121 typedef struct PACKED _rt_ipv6_ext_hdr_
123 UCHAR nextProto; // Indicate the protocol type of next extension header.
124 UCHAR extHdrLen; // optional field for msg length of this extension header which didn't include the first "nextProto" field.
125 UCHAR octets[1]; // hook to extend header message body.
126 }RT_IPV6_EXT_HDR, *PRT_IPV6_EXT_HDR;
129 /* ICMPv6 related structures */
130 typedef struct PACKED _rt_ipv6_icmpv6_hdr_
132 UCHAR type;
133 UCHAR code;
134 USHORT chksum;
135 UCHAR octets[1]; //hook to extend header message body.
136 }RT_ICMPV6_HDR, *PRT_ICMPV6_HDR;
139 typedef struct PACKED _rt_icmp6_option_hdr_
141 UCHAR type;
142 UCHAR len;
143 UCHAR octet[1];
144 }RT_ICMPV6_OPTION_HDR, *PRT_ICMPV6_OPTION_HDR;
146 typedef enum{
147 // Defined ICMPv6 Option Types.
148 TYPE_SRC_LL_ADDR = 1,
149 TYPE_TGT_LL_ADDR = 2,
150 TYPE_PREFIX_INFO = 3,
151 TYPE_REDIRECTED_HDR = 4,
152 TYPE_MTU = 5,
153 }ICMPV6_OPTIONS_TYPE_DEF;
156 static inline BOOLEAN IPv6ExtHdrHandle(
157 RT_IPV6_EXT_HDR *pExtHdr,
158 UCHAR *pProto,
159 UINT32 *pOffset)
161 UCHAR nextProto = 0xff;
162 UINT32 extLen = 0;
163 BOOLEAN status = TRUE;
165 //printk("%s(): parsing the Extension Header with Protocol(0x%x):\n", __FUNCTION__, *pProto);
166 switch (*pProto)
168 case IPV6_NEXT_HEADER_HOP_BY_HOP:
169 // IPv6ExtHopByHopHandle();
170 nextProto = pExtHdr->nextProto;
171 extLen = (pExtHdr->extHdrLen + 1) * 8;
172 break;
174 case IPV6_NEXT_HEADER_DESTINATION:
175 // IPv6ExtDestHandle();
176 nextProto = pExtHdr->nextProto;
177 extLen = (pExtHdr->extHdrLen + 1) * 8;
178 break;
180 case IPV6_NEXT_HEADER_ROUTING:
181 // IPv6ExtRoutingHandle();
182 nextProto = pExtHdr->nextProto;
183 extLen = (pExtHdr->extHdrLen + 1) * 8;
184 break;
186 case IPV6_NEXT_HEADER_FRAGMENT:
187 // IPv6ExtFragmentHandle();
188 nextProto = pExtHdr->nextProto;
189 extLen = 8; // The Fragment header length is fixed to 8 bytes.
190 break;
192 case IPV6_NEXT_HEADER_AUTHENTICATION:
193 // IPV6_NEXT_HEADER_ENCAPSULATION:
195 TODO: Not support. For encryption issue.
197 nextProto = 0xFF;
198 status = FALSE;
199 break;
201 default:
202 nextProto = 0xFF;
203 status = FALSE;
204 break;
207 *pProto = nextProto;
208 *pOffset += extLen;
209 //printk("%s(): nextProto = 0x%x!, offset=0x%x!\n", __FUNCTION__, nextProto, offset);
211 return status;
215 #endif // __IPV6_HDR_H_ //