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