]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Ip6Dxe/Ip6Option.h
Update for NetworkPkg.
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6Option.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Definition of IP6 option process routines.\r
3\r
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_IP6_OPTION_H__\r
17#define __EFI_IP6_OPTION_H__\r
18\r
19#define IP6_FRAGMENT_OFFSET_MASK (~0x3)\r
20\r
21typedef struct _IP6_FRAGMENT_HEADER {\r
22 UINT8 NextHeader;\r
23 UINT8 Reserved;\r
24 UINT16 FragmentOffset;\r
25 UINT32 Identification;\r
26} IP6_FRAGMENT_HEADER;\r
27\r
28typedef struct _IP6_ROUTING_HEADER {\r
29 UINT8 NextHeader;\r
30 UINT8 HeaderLen;\r
31 UINT8 RoutingType;\r
32 UINT8 SegmentsLeft;\r
33} IP6_ROUTING_HEADER;\r
34\r
35typedef enum {\r
36 Ip6OptionPad1 = 0,\r
37 Ip6OptionPadN = 1,\r
38 Ip6OptionRouterAlert = 5,\r
39 Ip6OptionSkip = 0,\r
40 Ip6OptionDiscard = 0x40,\r
41 Ip6OptionParameterProblem = 0x80,\r
42 Ip6OptionMask = 0xc0,\r
43\r
44 Ip6OptionEtherSource = 1,\r
45 Ip6OptionEtherTarget = 2,\r
46 Ip6OptionPrefixInfo = 3,\r
47 Ip6OptionRedirected = 4,\r
48 Ip6OptionMtu = 5\r
49} IP6_OPTION_TYPE;\r
50\r
51/**\r
52 Validate the IP6 extension header format for both the packets we received\r
53 and that we will transmit. It will compute the ICMPv6 error message fields\r
54 if the option is mal-formated.\r
55\r
56 @param[in] IpSb The IP6 service instance. This is an optional parameter.\r
57 @param[in] Packet The data of the packet. Ignored if NULL.\r
58 @param[in] NextHeader The next header field in IPv6 basic header.\r
59 @param[in] ExtHdrs The first byte of the option.\r
60 @param[in] ExtHdrsLen The length of the whole option.\r
61 @param[in] Rcvd The option is from the packet we received if TRUE,\r
62 otherwise, the option we want to transmit.\r
63 @param[out] FormerHeader The offset of NextHeader which points to Fragment\r
64 Header when we received, of the ExtHdrs.\r
65 Ignored if we transmit.\r
66 @param[out] LastHeader The pointer of NextHeader of the last extension\r
67 header processed by IP6.\r
68 @param[out] RealExtsLen The length of extension headers processed by IP6 layer.\r
69 This is an optional parameter that may be NULL.\r
70 @param[out] UnFragmentLen The length of unfragmented length of extension headers.\r
71 This is an optional parameter that may be NULL.\r
72 @param[out] Fragmented Indicate whether the packet is fragmented.\r
73 This is an optional parameter that may be NULL.\r
74\r
75 @retval TRUE The option is properly formated.\r
76 @retval FALSE The option is malformated.\r
77\r
78**/\r
79BOOLEAN\r
80Ip6IsExtsValid (\r
81 IN IP6_SERVICE *IpSb OPTIONAL,\r
82 IN NET_BUF *Packet OPTIONAL,\r
83 IN UINT8 *NextHeader,\r
84 IN UINT8 *ExtHdrs,\r
85 IN UINT32 ExtHdrsLen,\r
86 IN BOOLEAN Rcvd,\r
87 OUT UINT32 *FormerHeader OPTIONAL,\r
88 OUT UINT8 **LastHeader,\r
89 OUT UINT32 *RealExtsLen OPTIONAL,\r
90 OUT UINT32 *UnFragmentLen OPTIONAL,\r
91 OUT BOOLEAN *Fragmented OPTIONAL\r
92 );\r
93\r
94/**\r
95 Generate an IPv6 router alert option in network order and output it through Buffer.\r
96\r
97 @param[out] Buffer Points to a buffer to record the generated option.\r
98 @param[in, out] BufferLen The length of Buffer, in bytes.\r
99 @param[in] NextHeader The 8-bit selector indicates the type of header\r
100 immediately following the Hop-by-Hop Options header.\r
101\r
102 @retval EFI_BUFFER_TOO_SMALL The Buffer is too small to contain the generated\r
103 option. BufferLen is updated for the required size.\r
104\r
105 @retval EFI_SUCCESS The option is generated and filled in to Buffer.\r
106\r
107**/\r
108EFI_STATUS\r
109Ip6FillHopByHop (\r
110 OUT UINT8 *Buffer,\r
111 IN OUT UINTN *BufferLen,\r
112 IN UINT8 NextHeader\r
113 );\r
114\r
115/**\r
116 Insert a Fragment Header to the Extension headers and output it in UpdatedExtHdrs.\r
117\r
118 @param[in] IpSb The IP6 service instance to transmit the packet.\r
119 @param[in] NextHeader The extension header type of first extension header.\r
120 @param[in] LastHeader The extension header type of last extension header.\r
121 @param[in] ExtHdrs The length of the original extension header.\r
122 @param[in] ExtHdrsLen The length of the extension headers.\r
123 @param[in] FragmentOffset The fragment offset of the data following the header.\r
124 @param[out] UpdatedExtHdrs The updated ExtHdrs with Fragment header inserted.\r
125 It's caller's responsiblity to free this buffer.\r
126\r
127 @retval EFI_OUT_OF_RESOURCES Failed to finish the operation due to lake of\r
128 resource.\r
129 @retval EFI_UNSUPPORTED The extension header specified in ExtHdrs is not\r
130 supported currently.\r
131 @retval EFI_SUCCESS The operation performed successfully.\r
132\r
133**/\r
134EFI_STATUS\r
135Ip6FillFragmentHeader (\r
136 IN IP6_SERVICE *IpSb,\r
137 IN UINT8 NextHeader,\r
138 IN UINT8 LastHeader,\r
139 IN UINT8 *ExtHdrs,\r
140 IN UINT32 ExtHdrsLen,\r
141 IN UINT16 FragmentOffset,\r
142 OUT UINT8 **UpdatedExtHdrs\r
143 );\r
144\r
145/**\r
146 Copy the extension headers from the original to buffer. A Fragment header is\r
147 appended to the end.\r
148\r
149 @param[in] NextHeader The 8-bit selector indicates the type of\r
150 the fragment header's next header.\r
151 @param[in] ExtHdrs The length of the original extension header.\r
152 @param[in] LastHeader The pointer of next header of last extension header.\r
153 @param[in] FragmentOffset The fragment offset of the data following the header.\r
154 @param[in] UnFragmentHdrLen The length of unfragmented length of extension headers.\r
155 @param[in, out] Buf The buffer to copy options to.\r
156 @param[in, out] BufLen The length of the buffer.\r
157\r
158 @retval EFI_SUCCESS The options are copied over.\r
159 @retval EFI_BUFFER_TOO_SMALL The buffer caller provided is too small.\r
160\r
161**/\r
162EFI_STATUS\r
163Ip6CopyExts (\r
164 IN UINT8 NextHeader,\r
165 IN UINT8 *ExtHdrs,\r
166 IN UINT8 *LastHeader,\r
167 IN UINT16 FragmentOffset,\r
168 IN UINT32 UnFragmentHdrLen,\r
169 IN OUT UINT8 *Buf,\r
170 IN OUT UINT32 *BufLen\r
171 );\r
172\r
173/**\r
174 Validate the IP6 option format for both the packets we received\r
175 and that we will transmit. It supports the defined options in Neighbor\r
176 Discovery messages.\r
177\r
178 @param[in] Option The first byte of the option.\r
179 @param[in] OptionLen The length of the whole option.\r
180\r
181 @retval TRUE The option is properly formatted.\r
182 @retval FALSE The option is malformated.\r
183\r
184**/\r
185BOOLEAN\r
186Ip6IsNDOptionValid (\r
187 IN UINT8 *Option,\r
188 IN UINT16 OptionLen\r
189 );\r
190\r
191#endif\r