]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2006 - 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Udp4Impl.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | EFI UDPv4 protocol implementation\r | |
19 | \r | |
20 | \r | |
21 | **/\r | |
22 | \r | |
23 | #ifndef _UDP4_IMPL_H_\r | |
24 | #define _UDP4_IMPL_H_\r | |
25 | \r | |
8a67d61d | 26 | #include <PiDxe.h>\r |
27 | \r | |
eaf343ff | 28 | #include <Protocol/Ip4.h>\r |
8a67d61d | 29 | #include <Protocol/Udp4.h>\r |
83cbd279 | 30 | \r |
8a67d61d | 31 | #include <Library/IpIoLib.h>\r |
32 | #include <Library/DebugLib.h>\r | |
33 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
34 | #include <Library/UefiDriverEntryPoint.h>\r | |
35 | #include <Library/UefiBootServicesTableLib.h>\r | |
36 | #include <Library/BaseLib.h>\r | |
83cbd279 | 37 | #include <Library/UefiLib.h>\r |
38 | #include <Library/BaseMemoryLib.h>\r | |
39 | #include <Library/MemoryAllocationLib.h>\r | |
19873973 | 40 | #include <Library/TimerLib.h>\r |
83cbd279 | 41 | \r |
42 | #include "Udp4Driver.h"\r | |
43 | \r | |
44 | \r | |
45 | extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName;\r | |
46 | extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2;\r | |
47 | extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;\r | |
48 | extern EFI_UDP4_PROTOCOL mUdp4Protocol;\r | |
49 | extern UINT16 mUdp4RandomPort;\r | |
50 | \r | |
51 | #define ICMP_ERROR_PACKET_LENGTH 8\r | |
52 | \r | |
19873973 | 53 | #define UDP4_TIMEOUT_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds\r |
83cbd279 | 54 | \r |
55 | #define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER)\r | |
56 | #define UDP4_MAX_DATA_SIZE 65507\r | |
57 | \r | |
58 | #define UDP4_PORT_KNOWN 1024\r | |
59 | \r | |
60 | #define UDP4_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', '4')\r | |
61 | \r | |
62 | #define UDP4_SERVICE_DATA_FROM_THIS(a) \\r | |
63 | CR ( \\r | |
64 | (a), \\r | |
65 | UDP4_SERVICE_DATA, \\r | |
66 | ServiceBinding, \\r | |
67 | UDP4_SERVICE_DATA_SIGNATURE \\r | |
68 | )\r | |
69 | \r | |
70 | typedef struct _UDP4_SERVICE_DATA_ {\r | |
71 | UINT32 Signature;\r | |
72 | EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r | |
73 | EFI_HANDLE ImageHandle;\r | |
74 | EFI_HANDLE ControllerHandle;\r | |
e48e37fc | 75 | LIST_ENTRY ChildrenList;\r |
83cbd279 | 76 | UINTN ChildrenNumber;\r |
77 | IP_IO *IpIo;\r | |
78 | \r | |
79 | EFI_EVENT TimeoutEvent;\r | |
80 | \r | |
81 | CHAR16 *MacString;\r | |
82 | } UDP4_SERVICE_DATA;\r | |
83 | \r | |
84 | #define UDP4_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', 'I')\r | |
85 | \r | |
86 | #define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r | |
87 | CR ( \\r | |
88 | (a), \\r | |
89 | UDP4_INSTANCE_DATA, \\r | |
90 | Udp4Proto, \\r | |
91 | UDP4_INSTANCE_DATA_SIGNATURE \\r | |
92 | )\r | |
93 | \r | |
94 | typedef struct _UDP4_INSTANCE_DATA_ {\r | |
95 | UINT32 Signature;\r | |
e48e37fc | 96 | LIST_ENTRY Link;\r |
83cbd279 | 97 | \r |
98 | UDP4_SERVICE_DATA *Udp4Service;\r | |
99 | EFI_UDP4_PROTOCOL Udp4Proto;\r | |
100 | EFI_UDP4_CONFIG_DATA ConfigData;\r | |
101 | EFI_HANDLE ChildHandle;\r | |
102 | BOOLEAN Configured;\r | |
103 | BOOLEAN IsNoMapping;\r | |
104 | \r | |
105 | NET_MAP TxTokens;\r | |
106 | NET_MAP RxTokens;\r | |
107 | \r | |
108 | NET_MAP McastIps;\r | |
109 | \r | |
e48e37fc | 110 | LIST_ENTRY RcvdDgramQue;\r |
111 | LIST_ENTRY DeliveredDgramQue;\r | |
83cbd279 | 112 | \r |
113 | UINT16 HeadSum;\r | |
114 | \r | |
115 | EFI_STATUS IcmpError;\r | |
116 | \r | |
117 | IP_IO_IP_INFO *IpInfo;\r | |
118 | \r | |
119 | BOOLEAN Destroyed;\r | |
120 | } UDP4_INSTANCE_DATA;\r | |
121 | \r | |
122 | typedef struct _UDP4_RXDATA_WRAP_ {\r | |
e48e37fc | 123 | LIST_ENTRY Link;\r |
83cbd279 | 124 | NET_BUF *Packet;\r |
125 | UINT32 TimeoutTick;\r | |
126 | EFI_UDP4_RECEIVE_DATA RxData;\r | |
127 | } UDP4_RXDATA_WRAP;\r | |
128 | \r | |
ce904bae | 129 | /**\r |
130 | Reads the current operational settings.\r | |
131 | \r | |
132 | The GetModeData() function copies the current operational settings of this EFI\r | |
133 | UDPv4 Protocol instance into user-supplied buffers. This function is used\r | |
134 | optionally to retrieve the operational mode data of underlying networks or\r | |
135 | drivers.\r | |
136 | \r | |
137 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
138 | @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r | |
139 | @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r | |
140 | @param MnpConfigData Pointer to the managed network configuration data structure.\r | |
141 | @param SnpModeData Pointer to the simple network mode data structure.\r | |
142 | \r | |
143 | @retval EFI_SUCCESS The mode data was read.\r | |
144 | @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is\r | |
145 | available because this instance has not been started.\r | |
146 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
147 | \r | |
148 | **/\r | |
83cbd279 | 149 | EFI_STATUS\r |
150 | EFIAPI\r | |
151 | Udp4GetModeData (\r | |
152 | IN EFI_UDP4_PROTOCOL *This,\r | |
153 | OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,\r | |
154 | OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r | |
155 | OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r | |
156 | OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r | |
157 | );\r | |
158 | \r | |
ce904bae | 159 | /**\r |
160 | Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4\r | |
161 | Protocol.\r | |
162 | \r | |
163 | The Configure() function is used to do the following:\r | |
164 | * Initialize and start this instance of the EFI UDPv4 Protocol.\r | |
165 | * Change the filtering rules and operational parameters.\r | |
166 | * Reset this instance of the EFI UDPv4 Protocol.\r | |
167 | Until these parameters are initialized, no network traffic can be sent or\r | |
168 | received by this instance. This instance can be also reset by calling Configure()\r | |
169 | with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting\r | |
170 | queue are flushed and no traffic is allowed through this instance.\r | |
171 | With different parameters in UdpConfigData, Configure() can be used to bind\r | |
172 | this instance to specified port.\r | |
173 | \r | |
174 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
175 | @param UdpConfigData Pointer to the buffer to receive the current configuration data.\r | |
176 | \r | |
177 | @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.\r | |
178 | @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r | |
179 | RARP, etc.) is not finished yet.\r | |
180 | @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r | |
181 | @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured\r | |
182 | and must be stopped/reset before it can be reconfigured.\r | |
183 | @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE\r | |
184 | and UdpConfigData.StationPort is already used by\r | |
185 | other instance.\r | |
186 | @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this\r | |
187 | EFI UDPv4 Protocol instance.\r | |
188 | @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance\r | |
189 | was not opened. \r | |
190 | \r | |
191 | **/\r | |
83cbd279 | 192 | EFI_STATUS\r |
193 | EFIAPI\r | |
194 | Udp4Configure (\r | |
195 | IN EFI_UDP4_PROTOCOL *This,\r | |
196 | IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL\r | |
197 | );\r | |
198 | \r | |
ce904bae | 199 | /**\r |
200 | Joins and leaves multicast groups.\r | |
201 | \r | |
202 | The Groups() function is used to enable and disable the multicast group\r | |
203 | filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all\r | |
204 | currently joined groups are left.\r | |
205 | \r | |
206 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
207 | @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one\r | |
208 | or all multicast groups.\r | |
209 | @param MulticastAddress Pointer to multicast group address to join or leave.\r | |
210 | \r | |
211 | @retval EFI_SUCCESS The operation completed successfully.\r | |
212 | @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r | |
213 | @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r | |
214 | RARP, etc.) is not finished yet.\r | |
215 | @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.\r | |
216 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
217 | - This is NULL.\r | |
218 | - JoinFlag is TRUE and MulticastAddress is NULL.\r | |
219 | - JoinFlag is TRUE and *MulticastAddress is not\r | |
220 | a valid multicast address.\r | |
221 | @retval EFI_ALREADY_STARTED The group address is already in the group table (when\r | |
222 | JoinFlag is TRUE).\r | |
223 | @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is\r | |
224 | FALSE).\r | |
225 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
226 | \r | |
227 | **/\r | |
83cbd279 | 228 | EFI_STATUS\r |
229 | EFIAPI\r | |
230 | Udp4Groups (\r | |
231 | IN EFI_UDP4_PROTOCOL *This,\r | |
232 | IN BOOLEAN JoinFlag,\r | |
233 | IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL\r | |
234 | );\r | |
235 | \r | |
ce904bae | 236 | /**\r |
237 | Adds and deletes routing table entries.\r | |
238 | \r | |
239 | The Routes() function adds a route to or deletes a route from the routing table.\r | |
240 | Routes are determined by comparing the SubnetAddress with the destination IP\r | |
241 | address and arithmetically AND-ing it with the SubnetMask. The gateway address\r | |
242 | must be on the same subnet as the configured station address.\r | |
243 | The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.\r | |
244 | The default route matches all destination IP addresses that do not match any\r | |
245 | other routes.\r | |
246 | A zero GatewayAddress is a nonroute. Packets are sent to the destination IP\r | |
247 | address if it can be found in the Address Resolution Protocol (ARP) cache or\r | |
248 | on the local subnet. One automatic nonroute entry will be inserted into the\r | |
249 | routing table for outgoing packets that are addressed to a local subnet\r | |
250 | (gateway address of 0.0.0.0).\r | |
251 | Each instance of the EFI UDPv4 Protocol has its own independent routing table.\r | |
252 | Instances of the EFI UDPv4 Protocol that use the default IP address will also\r | |
253 | have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These\r | |
254 | copies will be updated automatically whenever the IP driver reconfigures its\r | |
255 | instances; as a result, the previous modification to these copies will be lost.\r | |
256 | \r | |
257 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
258 | @param DeleteRoute Set to TRUE to delete this route from the routing table.\r | |
259 | Set to FALSE to add this route to the routing table.\r | |
260 | @param SubnetAddress The destination network address that needs to be routed.\r | |
261 | @param SubnetMask The subnet mask of SubnetAddress.\r | |
262 | @param GatewayAddress The gateway IP address for this route.\r | |
263 | \r | |
264 | @retval EFI_SUCCESS The operation completed successfully.\r | |
265 | @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r | |
266 | @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r | |
267 | - RARP, etc.) is not finished yet.\r | |
268 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
269 | @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r | |
270 | @retval EFI_NOT_FOUND This route is not in the routing table.\r | |
271 | @retval EFI_ACCESS_DENIED The route is already defined in the routing table.\r | |
272 | \r | |
273 | **/\r | |
83cbd279 | 274 | EFI_STATUS\r |
275 | EFIAPI\r | |
276 | Udp4Routes (\r | |
277 | IN EFI_UDP4_PROTOCOL *This,\r | |
278 | IN BOOLEAN DeleteRoute,\r | |
279 | IN EFI_IPv4_ADDRESS *SubnetAddress,\r | |
280 | IN EFI_IPv4_ADDRESS *SubnetMask,\r | |
281 | IN EFI_IPv4_ADDRESS *GatewayAddress\r | |
282 | );\r | |
283 | \r | |
ce904bae | 284 | /**\r |
285 | Queues outgoing data packets into the transmit queue.\r | |
286 | \r | |
287 | The Transmit() function places a sending request to this instance of the EFI\r | |
288 | UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever\r | |
289 | the packet in the token is sent out or some errors occur, the Token.Event will\r | |
290 | be signaled and Token.Status is updated. Providing a proper notification function\r | |
291 | and context for the event will enable the user to receive the notification and\r | |
292 | transmitting status.\r | |
293 | \r | |
294 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
295 | @param Token Pointer to the completion token that will be placed into the\r | |
296 | transmit queue.\r | |
297 | \r | |
298 | @retval EFI_SUCCESS The data has been queued for transmission.\r | |
299 | @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r | |
300 | @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r | |
301 | RARP, etc.) is not finished yet.\r | |
302 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
303 | @retval EFI_ACCESS_DENIED The transmit completion token with the same\r | |
304 | Token.Event was already in the transmit queue.\r | |
305 | @retval EFI_NOT_READY The completion token could not be queued because the\r | |
306 | transmit queue is full.\r | |
307 | @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.\r | |
308 | @retval EFI_NOT_FOUND There is no route to the destination network or address.\r | |
309 | @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet\r | |
310 | size. Or the length of the IP header + UDP header + data\r | |
311 | length is greater than MTU if DoNotFragment is TRUE.\r | |
312 | \r | |
313 | **/\r | |
83cbd279 | 314 | EFI_STATUS\r |
315 | EFIAPI\r | |
316 | Udp4Transmit (\r | |
317 | IN EFI_UDP4_PROTOCOL *This,\r | |
318 | IN EFI_UDP4_COMPLETION_TOKEN *Token\r | |
319 | );\r | |
320 | \r | |
ce904bae | 321 | /**\r |
322 | Places an asynchronous receive request into the receiving queue.\r | |
323 | \r | |
324 | The Receive() function places a completion token into the receive packet queue.\r | |
325 | This function is always asynchronous.\r | |
326 | The caller must fill in the Token.Event field in the completion token, and this\r | |
327 | field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol\r | |
328 | driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event\r | |
329 | is signaled. Providing a proper notification function and context for the event\r | |
330 | will enable the user to receive the notification and receiving status. That\r | |
331 | notification function is guaranteed to not be re-entered.\r | |
332 | \r | |
333 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
334 | @param Token Pointer to a token that is associated with the receive data\r | |
335 | descriptor.\r | |
336 | \r | |
337 | @retval EFI_SUCCESS The receive completion token was cached.\r | |
338 | @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r | |
339 | @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)\r | |
340 | is not finished yet.\r | |
341 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
342 | @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system\r | |
343 | resources (usually memory).\r | |
344 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
345 | @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in\r | |
346 | the receive queue.\r | |
347 | @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r | |
348 | \r | |
349 | **/\r | |
83cbd279 | 350 | EFI_STATUS\r |
351 | EFIAPI\r | |
352 | Udp4Receive (\r | |
353 | IN EFI_UDP4_PROTOCOL *This,\r | |
354 | IN EFI_UDP4_COMPLETION_TOKEN *Token\r | |
355 | );\r | |
356 | \r | |
ce904bae | 357 | /**\r |
358 | Aborts an asynchronous transmit or receive request.\r | |
359 | \r | |
360 | The Cancel() function is used to abort a pending transmit or receive request.\r | |
361 | If the token is in the transmit or receive request queues, after calling this\r | |
362 | function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r | |
363 | signaled. If the token is not in one of the queues, which usually means that\r | |
364 | the asynchronous operation has completed, this function will not signal the\r | |
365 | token and EFI_NOT_FOUND is returned.\r | |
366 | \r | |
367 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
368 | @param Token Pointer to a token that has been issued by\r | |
369 | EFI_UDP4_PROTOCOL.Transmit() or\r | |
370 | EFI_UDP4_PROTOCOL.Receive().If NULL, all pending\r | |
371 | tokens are aborted.\r | |
372 | \r | |
373 | @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event\r | |
374 | was signaled. When Token is NULL, all pending requests are\r | |
375 | aborted and their events are signaled.\r | |
376 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
377 | @retval EFI_NOT_STARTED This instance has not been started.\r | |
378 | @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r | |
379 | RARP, etc.) is not finished yet.\r | |
380 | @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was\r | |
381 | not found in the transmit or receive queue. It has either completed\r | |
382 | or was not issued by Transmit() and Receive().\r | |
383 | \r | |
384 | **/\r | |
83cbd279 | 385 | EFI_STATUS\r |
386 | EFIAPI\r | |
387 | Udp4Cancel (\r | |
388 | IN EFI_UDP4_PROTOCOL *This,\r | |
389 | IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r | |
390 | );\r | |
391 | \r | |
ce904bae | 392 | /**\r |
393 | Polls for incoming data packets and processes outgoing data packets.\r | |
394 | \r | |
395 | The Poll() function can be used by network drivers and applications to increase\r | |
396 | the rate that data packets are moved between the communications device and the\r | |
397 | transmit and receive queues.\r | |
398 | In some systems, the periodic timer event in the managed network driver may not\r | |
399 | poll the underlying communications device fast enough to transmit and/or receive\r | |
400 | all data packets without missing incoming packets or dropping outgoing packets.\r | |
401 | Drivers and applications that are experiencing packet loss should try calling\r | |
402 | the Poll() function more often.\r | |
403 | \r | |
404 | @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r | |
405 | \r | |
406 | @retval EFI_SUCCESS Incoming or outgoing data was processed.\r | |
407 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
408 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
409 | @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r | |
410 | \r | |
411 | **/\r | |
83cbd279 | 412 | EFI_STATUS\r |
413 | EFIAPI\r | |
414 | Udp4Poll (\r | |
415 | IN EFI_UDP4_PROTOCOL *This\r | |
416 | );\r | |
417 | \r | |
ce904bae | 418 | /**\r |
419 | Create the Udp service context data.\r | |
420 | \r | |
421 | @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r | |
422 | @param ImageHandle The image handle of this udp4 driver.\r | |
423 | @param ControllerHandle The controller handle this udp4 driver binds on.\r | |
424 | \r | |
425 | @retval EFI_SUCCESS The udp4 service context data is created and\r | |
426 | initialized.\r | |
427 | @retval EFI_OUT_OF_RESOURCES Cannot allocate memory.\r | |
428 | @retval other Other error occurs.\r | |
429 | \r | |
430 | **/\r | |
83cbd279 | 431 | EFI_STATUS\r |
432 | Udp4CreateService (\r | |
ce904bae | 433 | IN OUT UDP4_SERVICE_DATA *Udp4Service,\r |
434 | IN EFI_HANDLE ImageHandle,\r | |
435 | IN EFI_HANDLE ControllerHandle\r | |
83cbd279 | 436 | );\r |
437 | \r | |
ce904bae | 438 | /**\r |
439 | Clean the Udp service context data.\r | |
440 | \r | |
441 | @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r | |
442 | \r | |
443 | @return None.\r | |
444 | \r | |
445 | **/\r | |
83cbd279 | 446 | VOID\r |
447 | Udp4CleanService (\r | |
448 | IN UDP4_SERVICE_DATA *Udp4Service\r | |
449 | );\r | |
450 | \r | |
ce904bae | 451 | /**\r |
452 | This function intializes the new created udp instance.\r | |
453 | \r | |
454 | @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r | |
455 | @param Instance Pointer to the un-initialized UDP4_INSTANCE_DATA.\r | |
456 | \r | |
457 | @return None.\r | |
458 | \r | |
459 | **/\r | |
83cbd279 | 460 | VOID\r |
461 | Udp4InitInstance (\r | |
ce904bae | 462 | IN UDP4_SERVICE_DATA *Udp4Service,\r |
463 | IN OUT UDP4_INSTANCE_DATA *Instance\r | |
83cbd279 | 464 | );\r |
465 | \r | |
ce904bae | 466 | /**\r |
467 | This function cleans the udp instance.\r | |
468 | \r | |
469 | @param Instance Pointer to the UDP4_INSTANCE_DATA to clean.\r | |
470 | \r | |
471 | @return None.\r | |
472 | \r | |
473 | **/\r | |
83cbd279 | 474 | VOID\r |
475 | Udp4CleanInstance (\r | |
476 | IN UDP4_INSTANCE_DATA *Instance\r | |
477 | );\r | |
478 | \r | |
ce904bae | 479 | /**\r |
480 | This function tries to bind the udp instance according to the configured port\r | |
481 | allocation strategy.\r | |
482 | \r | |
483 | @param InstanceList Pointer to the head of the list linking the udp\r | |
484 | instances.\r | |
485 | @param ConfigData Pointer to the ConfigData of the instance to be\r | |
486 | bound. ConfigData->StationPort will be assigned\r | |
487 | with an available port value on success.\r | |
488 | \r | |
489 | @retval EFI_SUCCESS The bound operation is completed successfully.\r | |
490 | @retval EFI_ACCESS_DENIED The <Address, Port> specified by the ConfigData is\r | |
491 | already used by other instance.\r | |
492 | @retval EFI_OUT_OF_RESOURCES No available port resources.\r | |
493 | \r | |
494 | **/\r | |
83cbd279 | 495 | EFI_STATUS\r |
496 | Udp4Bind (\r | |
ce904bae | 497 | IN LIST_ENTRY *InstanceList,\r |
498 | IN OUT EFI_UDP4_CONFIG_DATA *ConfigData\r | |
83cbd279 | 499 | );\r |
500 | \r | |
ce904bae | 501 | /**\r |
502 | This function is used to check whether the NewConfigData has any un-reconfigurable\r | |
503 | parameters changed compared to the OldConfigData.\r | |
504 | \r | |
505 | @param OldConfigData Pointer to the current ConfigData the udp instance\r | |
506 | uses.\r | |
507 | @param NewConfigData Pointer to the new ConfigData.\r | |
508 | \r | |
509 | @retval TRUE The instance is reconfigurable.\r | |
510 | @retval FALSE Otherwise.\r | |
511 | \r | |
512 | **/\r | |
83cbd279 | 513 | BOOLEAN\r |
514 | Udp4IsReconfigurable (\r | |
515 | IN EFI_UDP4_CONFIG_DATA *OldConfigData,\r | |
516 | IN EFI_UDP4_CONFIG_DATA *NewConfigData\r | |
517 | );\r | |
518 | \r | |
ce904bae | 519 | /**\r |
520 | This function builds the Ip4 configdata from the Udp4ConfigData.\r | |
521 | \r | |
522 | @param Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA.\r | |
523 | @param Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA.\r | |
524 | \r | |
525 | @return None.\r | |
526 | \r | |
527 | **/\r | |
83cbd279 | 528 | VOID\r |
529 | Udp4BuildIp4ConfigData (\r | |
ce904bae | 530 | IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData,\r |
531 | IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData\r | |
83cbd279 | 532 | );\r |
533 | \r | |
ce904bae | 534 | /**\r |
535 | This function validates the TxToken, it returns the error code according to the spec.\r | |
536 | \r | |
537 | @param Instance Pointer to the udp instance context data.\r | |
538 | @param TxToken Pointer to the token to be checked.\r | |
539 | \r | |
540 | @retval EFI_SUCCESS The TxToken is valid.\r | |
541 | @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is\r | |
542 | NULL. Token is NULL. Token.Event is NULL.\r | |
543 | Token.Packet.TxData is NULL.\r | |
544 | Token.Packet.TxData.FragmentCount is zero.\r | |
545 | Token.Packet.TxData.DataLength is not equal to the\r | |
546 | sum of fragment lengths. One or more of the\r | |
547 | Token.Packet.TxData.FragmentTable[].\r | |
548 | FragmentLength fields is zero. One or more of the\r | |
549 | Token.Packet.TxData.FragmentTable[].\r | |
550 | FragmentBuffer fields is NULL.\r | |
551 | Token.Packet.TxData. GatewayAddress is not a\r | |
552 | unicast IPv4 address if it is not NULL. One or\r | |
553 | more IPv4 addresses in Token.Packet.TxData.\r | |
554 | UdpSessionData are not valid unicast IPv4\r | |
555 | addresses if the UdpSessionData is not NULL.\r | |
556 | @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP\r | |
557 | packet size.\r | |
558 | \r | |
559 | **/\r | |
83cbd279 | 560 | EFI_STATUS\r |
561 | Udp4ValidateTxToken (\r | |
562 | IN UDP4_INSTANCE_DATA *Instance,\r | |
563 | IN EFI_UDP4_COMPLETION_TOKEN *TxToken\r | |
564 | );\r | |
565 | \r | |
ce904bae | 566 | /**\r |
567 | This function checks whether the specified Token duplicates with the one in the Map.\r | |
568 | \r | |
569 | @param Map Pointer to the NET_MAP.\r | |
570 | @param Item Pointer to the NET_MAP_ITEM contain the pointer to\r | |
571 | the Token.\r | |
572 | @param Context Pointer to the Token to be checked.\r | |
573 | \r | |
574 | @retval EFI_SUCCESS The Token specified by Context differs from the\r | |
575 | one in the Item.\r | |
576 | @retval EFI_ACCESS_DENIED The Token duplicates with the one in the Item.\r | |
577 | \r | |
578 | **/\r | |
83cbd279 | 579 | EFI_STATUS\r |
580 | Udp4TokenExist (\r | |
581 | IN NET_MAP *Map,\r | |
582 | IN NET_MAP_ITEM *Item,\r | |
583 | IN VOID *Context\r | |
584 | );\r | |
585 | \r | |
ce904bae | 586 | /**\r |
587 | This function calculates the checksum for the Packet, utilizing the pre-calculated\r | |
588 | pseudo HeadSum to reduce some overhead.\r | |
589 | \r | |
590 | @param Packet Pointer to the NET_BUF contains the udp datagram.\r | |
591 | @param HeadSum Checksum of the pseudo header execpt the length\r | |
592 | field.\r | |
593 | \r | |
594 | @return The 16-bit checksum of this udp datagram.\r | |
595 | \r | |
596 | **/\r | |
83cbd279 | 597 | UINT16\r |
598 | Udp4Checksum (\r | |
599 | IN NET_BUF *Packet,\r | |
600 | IN UINT16 HeadSum\r | |
601 | );\r | |
602 | \r | |
ce904bae | 603 | /**\r |
604 | This function removes the specified Token from the TokenMap.\r | |
605 | \r | |
606 | @param TokenMap Pointer to the NET_MAP containing the tokens.\r | |
607 | @param Token Pointer to the Token to be removed.\r | |
608 | \r | |
609 | @retval EFI_SUCCESS The specified Token is removed from the TokenMap.\r | |
610 | @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap.\r | |
611 | \r | |
612 | **/\r | |
83cbd279 | 613 | EFI_STATUS\r |
614 | Udp4RemoveToken (\r | |
ce904bae | 615 | IN OUT NET_MAP *TokenMap,\r |
616 | IN EFI_UDP4_COMPLETION_TOKEN *Token\r | |
83cbd279 | 617 | );\r |
618 | \r | |
ce904bae | 619 | /**\r |
620 | This function removes the multicast group specified by Arg from the Map.\r | |
621 | \r | |
622 | @param Map Pointer to the NET_MAP.\r | |
623 | @param Item Pointer to the NET_MAP_ITEM.\r | |
624 | @param Arg Pointer to the Arg, it's the pointer to a\r | |
625 | multicast IPv4 Address.\r | |
626 | \r | |
627 | @retval EFI_SUCCESS The multicast address is removed.\r | |
628 | @retval EFI_ABORTED The specified multicast address is removed and the\r | |
629 | Arg is not NULL.\r | |
630 | \r | |
631 | **/\r | |
83cbd279 | 632 | EFI_STATUS\r |
633 | Udp4LeaveGroup (\r | |
ce904bae | 634 | IN OUT NET_MAP *Map,\r |
635 | IN NET_MAP_ITEM *Item,\r | |
636 | IN VOID *Arg OPTIONAL\r | |
83cbd279 | 637 | );\r |
638 | \r | |
ce904bae | 639 | /**\r |
640 | This function removes all the Wrap datas in the RcvdDgramQue.\r | |
641 | \r | |
642 | @param Instance Pointer to the udp instance context data.\r | |
643 | \r | |
644 | @return None.\r | |
645 | \r | |
646 | **/\r | |
83cbd279 | 647 | VOID\r |
36ee91ca | 648 | Udp4FlushRcvdDgram (\r |
649 | IN UDP4_INSTANCE_DATA *Instance\r | |
83cbd279 | 650 | );\r |
651 | \r | |
ce904bae | 652 | /**\r |
653 | Cancel Udp4 tokens from the Udp4 instance.\r | |
654 | \r | |
655 | @param Instance Pointer to the udp instance context data.\r | |
656 | @param Token Pointer to the token to be canceled, if NULL, all\r | |
657 | tokens in this instance will be cancelled.\r | |
658 | \r | |
659 | @retval EFI_SUCCESS The Token is cancelled.\r | |
660 | @retval EFI_NOT_FOUND The Token is not found.\r | |
661 | \r | |
662 | **/\r | |
83cbd279 | 663 | EFI_STATUS\r |
664 | Udp4InstanceCancelToken (\r | |
665 | IN UDP4_INSTANCE_DATA *Instance,\r | |
666 | IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r | |
667 | );\r | |
668 | \r | |
ce904bae | 669 | /**\r |
670 | This function delivers the received datagrams for the specified instance.\r | |
671 | \r | |
672 | @param Instance Pointer to the instance context data.\r | |
673 | \r | |
674 | @return None.\r | |
675 | \r | |
676 | **/\r | |
83cbd279 | 677 | VOID\r |
678 | Udp4InstanceDeliverDgram (\r | |
679 | IN UDP4_INSTANCE_DATA *Instance\r | |
680 | );\r | |
681 | \r | |
ce904bae | 682 | /**\r |
683 | This function reports the received ICMP error.\r | |
684 | \r | |
685 | @param Instance Pointer to the udp instance context data.\r | |
686 | \r | |
687 | @return None.\r | |
688 | \r | |
689 | **/\r | |
83cbd279 | 690 | VOID\r |
691 | Udp4ReportIcmpError (\r | |
692 | IN UDP4_INSTANCE_DATA *Instance\r | |
693 | );\r | |
694 | \r | |
ce904bae | 695 | /**\r |
696 | This function is a dummy ext-free function for the NET_BUF created for the output\r | |
697 | udp datagram.\r | |
698 | \r | |
699 | @param Context Pointer to the context data.\r | |
700 | \r | |
701 | @return None.\r | |
702 | \r | |
703 | **/\r | |
83cbd279 | 704 | VOID\r |
705 | Udp4NetVectorExtFree (\r | |
706 | VOID *Context\r | |
707 | );\r | |
708 | \r | |
ce904bae | 709 | /**\r |
710 | Set the Udp4 variable data.\r | |
711 | \r | |
712 | @param Udp4Service Udp4 service data.\r | |
713 | \r | |
714 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the\r | |
715 | variable.\r | |
716 | @retval EFI_SUCCESS Set variable successfully.\r | |
717 | @retval other Set variable failed.\r | |
718 | \r | |
719 | **/\r | |
83cbd279 | 720 | EFI_STATUS\r |
721 | Udp4SetVariableData (\r | |
722 | IN UDP4_SERVICE_DATA *Udp4Service\r | |
723 | );\r | |
724 | \r | |
ce904bae | 725 | /**\r |
726 | Clear the variable and free the resource.\r | |
727 | \r | |
728 | @param Udp4Service Udp4 service data.\r | |
729 | \r | |
730 | @return None.\r | |
731 | \r | |
732 | **/\r | |
83cbd279 | 733 | VOID\r |
734 | Udp4ClearVariableData (\r | |
735 | IN UDP4_SERVICE_DATA *Udp4Service\r | |
736 | );\r | |
737 | \r | |
738 | #endif\r | |
739 | \r |