Udp4Impl.h 26 KB

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