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