TcpMain.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. /** @file
  2. Declaration of protocol interfaces in EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
  3. It is the common head file for all Tcp*.c in TCP driver.
  4. Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _TCP_MAIN_H_
  8. #define _TCP_MAIN_H_
  9. #include <Protocol/ServiceBinding.h>
  10. #include <Protocol/DriverBinding.h>
  11. #include <Library/IpIoLib.h>
  12. #include <Library/DevicePathLib.h>
  13. #include <Library/PrintLib.h>
  14. #include "Socket.h"
  15. #include "TcpProto.h"
  16. #include "TcpDriver.h"
  17. #include "TcpFunc.h"
  18. extern UINT16 mTcp4RandomPort;
  19. extern UINT16 mTcp6RandomPort;
  20. extern CHAR16 *mTcpStateName[];
  21. extern EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName;
  22. extern EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2;
  23. extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable;
  24. extern LIST_ENTRY mTcpRunQue;
  25. extern LIST_ENTRY mTcpListenQue;
  26. extern TCP_SEQNO mTcpGlobalIss;
  27. extern UINT32 mTcpTick;
  28. ///
  29. /// 30 seconds.
  30. ///
  31. #define TCP6_KEEP_NEIGHBOR_TIME 30
  32. ///
  33. /// 5 seconds, since 1 tick equals 200ms.
  34. ///
  35. #define TCP6_REFRESH_NEIGHBOR_TICK 25
  36. #define TCP_EXPIRE_TIME 65535
  37. ///
  38. /// The implementation selects the initial send sequence number and the unit to
  39. /// be added when it is increased.
  40. ///
  41. #define TCP_BASE_ISS 0x4d7e980b
  42. #define TCP_ISS_INCREMENT_1 2048
  43. #define TCP_ISS_INCREMENT_2 100
  44. typedef union {
  45. EFI_TCP4_CONFIG_DATA Tcp4CfgData;
  46. EFI_TCP6_CONFIG_DATA Tcp6CfgData;
  47. } TCP_CONFIG_DATA;
  48. typedef union {
  49. EFI_TCP4_ACCESS_POINT Tcp4Ap;
  50. EFI_TCP6_ACCESS_POINT Tcp6Ap;
  51. } TCP_ACCESS_POINT;
  52. typedef struct _TCP4_MODE_DATA {
  53. EFI_TCP4_CONNECTION_STATE *Tcp4State;
  54. EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
  55. EFI_IP4_MODE_DATA *Ip4ModeData;
  56. EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
  57. EFI_SIMPLE_NETWORK_MODE *SnpModeData;
  58. } TCP4_MODE_DATA;
  59. typedef struct _TCP6_MODE_DATA {
  60. EFI_TCP6_CONNECTION_STATE *Tcp6State;
  61. EFI_TCP6_CONFIG_DATA *Tcp6ConfigData;
  62. EFI_IP6_MODE_DATA *Ip6ModeData;
  63. EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
  64. EFI_SIMPLE_NETWORK_MODE *SnpModeData;
  65. } TCP6_MODE_DATA;
  66. typedef struct _TCP4_ROUTE_INFO {
  67. BOOLEAN DeleteRoute;
  68. EFI_IPv4_ADDRESS *SubnetAddress;
  69. EFI_IPv4_ADDRESS *SubnetMask;
  70. EFI_IPv4_ADDRESS *GatewayAddress;
  71. } TCP4_ROUTE_INFO;
  72. typedef struct {
  73. EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
  74. UINTN NumberOfChildren;
  75. EFI_HANDLE *ChildHandleBuffer;
  76. } TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
  77. //
  78. // EFI_TCP4_PROTOCOL definitions.
  79. //
  80. /**
  81. Get the current operational status.
  82. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  83. @param[out] Tcp4State Pointer to the buffer to receive the current TCP
  84. state. Optional parameter that may be NULL.
  85. @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
  86. configuration. Optional parameter that may be NULL.
  87. @param[out] Ip4ModeData Pointer to the buffer to receive the current
  88. IPv4 configuration. Optional parameter that may be NULL.
  89. @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
  90. configuration data indirectly used by the TCPv4
  91. Instance. Optional parameter that may be NULL.
  92. @param[out] SnpModeData Pointer to the buffer to receive the current SNP
  93. configuration data indirectly used by the TCPv4
  94. Instance. Optional parameter that may be NULL.
  95. @retval EFI_SUCCESS The mode data was read.
  96. @retval EFI_NOT_STARTED No configuration data is available because this
  97. instance hasn't been started.
  98. @retval EFI_INVALID_PARAMETER This is NULL.
  99. **/
  100. EFI_STATUS
  101. EFIAPI
  102. Tcp4GetModeData (
  103. IN EFI_TCP4_PROTOCOL *This,
  104. OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
  105. OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
  106. OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
  107. OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
  108. OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
  109. );
  110. /**
  111. Initialize or brutally reset the operational parameters for
  112. this EFI TCPv4 instance.
  113. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  114. @param[in] TcpConfigData Pointer to the configure data to configure the
  115. instance. Optional parameter that may be NULL.
  116. @retval EFI_SUCCESS The operational settings are set, changed, or
  117. reset successfully.
  118. @retval EFI_NO_MAPPING When using a default address, configuration
  119. (through DHCP, BOOTP, RARP, etc.) is not
  120. finished.
  121. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
  122. @retval EFI_ACCESS_DENIED Configuring the TCP instance when it is already
  123. configured.
  124. @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
  125. @retval EFI_UNSUPPORTED One or more of the control options are not
  126. supported in the implementation.
  127. @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
  128. **/
  129. EFI_STATUS
  130. EFIAPI
  131. Tcp4Configure (
  132. IN EFI_TCP4_PROTOCOL *This,
  133. IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
  134. );
  135. /**
  136. Add or delete routing entries.
  137. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  138. @param[in] DeleteRoute If TRUE, delete the specified route from routing
  139. table; if FALSE, add the specified route to
  140. routing table.
  141. @param[in] SubnetAddress The destination network.
  142. @param[in] SubnetMask The subnet mask for the destination network.
  143. @param[in] GatewayAddress The gateway address for this route.
  144. @retval EFI_SUCCESS The operation completed successfully.
  145. @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
  146. configured.
  147. @retval EFI_NO_MAPPING When using a default address, configuration
  148. (through DHCP, BOOTP, RARP, etc.) is not
  149. finished.
  150. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
  151. @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
  152. entry to the routing table.
  153. @retval EFI_NOT_FOUND This route is not in the routing table.
  154. @retval EFI_ACCESS_DENIED This route is already in the routing table.
  155. @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
  156. **/
  157. EFI_STATUS
  158. EFIAPI
  159. Tcp4Routes (
  160. IN EFI_TCP4_PROTOCOL *This,
  161. IN BOOLEAN DeleteRoute,
  162. IN EFI_IPv4_ADDRESS *SubnetAddress,
  163. IN EFI_IPv4_ADDRESS *SubnetMask,
  164. IN EFI_IPv4_ADDRESS *GatewayAddress
  165. );
  166. /**
  167. Initiate a nonblocking TCP connection request for an active TCP instance.
  168. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  169. @param[in] ConnectionToken Pointer to the connection token to return when
  170. the TCP three way handshake finishes.
  171. @retval EFI_SUCCESS The connection request is successfully
  172. initiated.
  173. @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
  174. configured.
  175. @retval EFI_ACCESS_DENIED The instance is not configured as an active one
  176. or it is not in Tcp4StateClosed state.
  177. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
  178. @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
  179. initiate the active open.
  180. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  181. **/
  182. EFI_STATUS
  183. EFIAPI
  184. Tcp4Connect (
  185. IN EFI_TCP4_PROTOCOL *This,
  186. IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
  187. );
  188. /**
  189. Listen on the passive instance to accept an incoming connection request.
  190. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  191. @param[in] ListenToken Pointer to the listen token to return when
  192. operation finishes.
  193. @retval EFI_SUCCESS The listen token has been queued successfully.
  194. @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
  195. configured.
  196. @retval EFI_ACCESS_DENIED The instance is not a passive one or it is not
  197. in Tcp4StateListen state, or a same listen token
  198. has already existed in the listen token queue of
  199. this TCP instance.
  200. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
  201. @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
  202. the operation.
  203. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  204. **/
  205. EFI_STATUS
  206. EFIAPI
  207. Tcp4Accept (
  208. IN EFI_TCP4_PROTOCOL *This,
  209. IN EFI_TCP4_LISTEN_TOKEN *ListenToken
  210. );
  211. /**
  212. Queues outgoing data into the transmit queue
  213. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance
  214. @param[in] Token Pointer to the completion token to queue to the
  215. transmit queue
  216. @retval EFI_SUCCESS The data has been queued for transmission
  217. @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
  218. configured.
  219. @retval EFI_NO_MAPPING When using a default address, configuration
  220. (DHCP, BOOTP, RARP, etc.) is not finished yet.
  221. @retval EFI_INVALID_PARAMETER One or more parameters are invalid
  222. @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
  223. * A transmit completion token with the same
  224. Token-> CompletionToken.Event was already in the
  225. transmission queue. * The current instance is in
  226. Tcp4StateClosed state * The current instance is
  227. a passive one and it is in Tcp4StateListen
  228. state. * User has called Close() to disconnect
  229. this connection.
  230. @retval EFI_NOT_READY The completion token could not be queued because
  231. the transmit queue is full.
  232. @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
  233. resource shortage.
  234. @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
  235. address.
  236. **/
  237. EFI_STATUS
  238. EFIAPI
  239. Tcp4Transmit (
  240. IN EFI_TCP4_PROTOCOL *This,
  241. IN EFI_TCP4_IO_TOKEN *Token
  242. );
  243. /**
  244. Place an asynchronous receive request into the receiving queue.
  245. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  246. @param[in] Token Pointer to a token that is associated with the
  247. receive data descriptor.
  248. @retval EFI_SUCCESS The receive completion token was cached.
  249. @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
  250. configured.
  251. @retval EFI_NO_MAPPING When using a default address, configuration
  252. (DHCP, BOOTP, RARP, etc.) is not finished yet.
  253. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
  254. @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
  255. due to a lack of system resources.
  256. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  257. @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
  258. * A receive completion token with the same
  259. Token->CompletionToken.Event was already in the
  260. receive queue. * The current instance is in
  261. Tcp4StateClosed state. * The current instance is
  262. a passive one and it is in Tcp4StateListen
  263. state. * User has called Close() to disconnect
  264. this connection.
  265. @retval EFI_CONNECTION_FIN The communication peer has closed the connection
  266. and there is no buffered data in the receive
  267. buffer of this instance.
  268. @retval EFI_NOT_READY The receive request could not be queued because
  269. the receive queue is full.
  270. **/
  271. EFI_STATUS
  272. EFIAPI
  273. Tcp4Receive (
  274. IN EFI_TCP4_PROTOCOL *This,
  275. IN EFI_TCP4_IO_TOKEN *Token
  276. );
  277. /**
  278. Disconnecting a TCP connection gracefully or reset a TCP connection.
  279. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  280. @param[in] CloseToken Pointer to the close token to return when
  281. operation finishes.
  282. @retval EFI_SUCCESS The operation completed successfully.
  283. @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
  284. configured.
  285. @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
  286. Configure() has been called with TcpConfigData
  287. set to NULL and this function has not returned.
  288. * Previous Close() call on this instance has not
  289. finished.
  290. @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
  291. @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
  292. operation.
  293. @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error
  294. categories given above.
  295. **/
  296. EFI_STATUS
  297. EFIAPI
  298. Tcp4Close (
  299. IN EFI_TCP4_PROTOCOL *This,
  300. IN EFI_TCP4_CLOSE_TOKEN *CloseToken
  301. );
  302. /**
  303. Abort an asynchronous connection, listen, transmission or receive request.
  304. @param This The pointer to the EFI_TCP4_PROTOCOL instance.
  305. @param Token The pointer to a token that has been issued by
  306. EFI_TCP4_PROTOCOL.Connect(),
  307. EFI_TCP4_PROTOCOL.Accept(),
  308. EFI_TCP4_PROTOCOL.Transmit() or
  309. EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
  310. tokens issued by above four functions will be aborted. Type
  311. EFI_TCP4_COMPLETION_TOKEN is defined in
  312. EFI_TCP4_PROTOCOL.Connect().
  313. @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
  314. is signaled.
  315. @retval EFI_INVALID_PARAMETER This is NULL.
  316. @retval EFI_NOT_STARTED This instance hasn't been configured.
  317. @retval EFI_NO_MAPPING When using the default address, configuration
  318. (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
  319. @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
  320. transmission or receive queue. It has either
  321. completed or wasn't issued by Transmit() and Receive().
  322. **/
  323. EFI_STATUS
  324. EFIAPI
  325. Tcp4Cancel (
  326. IN EFI_TCP4_PROTOCOL *This,
  327. IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
  328. );
  329. /**
  330. Poll to receive incoming data and transmit outgoing segments.
  331. @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
  332. @retval EFI_SUCCESS Incoming or outgoing data was processed.
  333. @retval EFI_INVALID_PARAMETER This is NULL.
  334. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  335. @retval EFI_NOT_READY No incoming or outgoing data was processed.
  336. @retval EFI_TIMEOUT Data was dropped out of the transmission or
  337. receive queue. Consider increasing the polling
  338. rate.
  339. **/
  340. EFI_STATUS
  341. EFIAPI
  342. Tcp4Poll (
  343. IN EFI_TCP4_PROTOCOL *This
  344. );
  345. //
  346. // EFI_TCP6_PROTOCOL definitions.
  347. //
  348. /**
  349. Get the current operational status.
  350. The GetModeData() function copies the current operational settings of this EFI TCPv6
  351. Protocol instance into user-supplied buffers. This function can also be used to retrieve
  352. the operational setting of underlying drivers such as IPv6, MNP, or SNP.
  353. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  354. @param[out] Tcp6State The buffer in which the current TCP state is
  355. returned. Optional parameter that may be NULL.
  356. @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
  357. is returned. Optional parameter that may be NULL.
  358. @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
  359. data used by the TCP instance is returned.
  360. Optional parameter that may be NULL.
  361. @param[out] MnpConfigData The buffer in which the current MNP configuration
  362. data used indirectly by the TCP instance is returned.
  363. Optional parameter that may be NULL.
  364. @param[out] SnpModeData The buffer in which the current SNP mode data
  365. used indirectly by the TCP instance is returned.
  366. Optional parameter that may be NULL.
  367. @retval EFI_SUCCESS The mode data was read.
  368. @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
  369. been started.
  370. @retval EFI_INVALID_PARAMETER This is NULL.
  371. **/
  372. EFI_STATUS
  373. EFIAPI
  374. Tcp6GetModeData (
  375. IN EFI_TCP6_PROTOCOL *This,
  376. OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
  377. OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
  378. OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
  379. OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
  380. OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
  381. );
  382. /**
  383. Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
  384. The Configure() function does the following:
  385. - Initialize this TCP instance, i.e., initialize the communication end settings and
  386. specify active open or passive open for an instance.
  387. - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
  388. transmission and receiving buffer directly without informing the communication peer.
  389. No other TCPv6 Protocol operation except Poll() can be executed by this instance until
  390. it is configured properly. For an active TCP instance, after a proper configuration it
  391. may call Connect() to initiates the three-way handshake. For a passive TCP instance,
  392. its state will transit to Tcp6StateListen after configuration, and Accept() may be
  393. called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
  394. the instance is reset. Resetting process will be done brutally, the state machine will
  395. be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
  396. and no traffic is allowed through this instance.
  397. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  398. @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
  399. If Tcp6ConfigData is set to NULL, the instance is reset.
  400. @retval EFI_SUCCESS The operational settings were set, changed, or reset
  401. successfully.
  402. @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
  403. address for this instance, but no source address was available for
  404. use.
  405. @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
  406. - This is NULL.
  407. - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
  408. one of the configured IP addresses in the underlying IPv6 driver.
  409. - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
  410. IPv6 address.
  411. - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
  412. Tcp6ConfigData->AccessPoint.RemotePort is zero when
  413. Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
  414. - A same access point has been configured in other TCP
  415. instance properly.
  416. @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
  417. calling Configure() with NULL to reset it.
  418. @retval EFI_UNSUPPORTED One or more of the control options are not supported in
  419. the implementation.
  420. @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
  421. executing Configure().
  422. @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
  423. **/
  424. EFI_STATUS
  425. EFIAPI
  426. Tcp6Configure (
  427. IN EFI_TCP6_PROTOCOL *This,
  428. IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
  429. );
  430. /**
  431. Initiate a nonblocking TCP connection request for an active TCP instance.
  432. The Connect() function will initiate an active open to the remote peer configured
  433. in current TCP instance if it is configured active. If the connection succeeds or
  434. fails due to an error, the ConnectionToken->CompletionToken.Event will be signaled,
  435. and ConnectionToken->CompletionToken.Status will be updated accordingly. This
  436. function can only be called for the TCP instance in Tcp6StateClosed state. The
  437. instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
  438. If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished;
  439. otherwise, the state will return to Tcp6StateClosed.
  440. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  441. @param[in] ConnectionToken Pointer to the connection token to return when the TCP
  442. three-way handshake finishes.
  443. @retval EFI_SUCCESS The connection request successfully initiated and the state of
  444. this TCP instance has been changed to Tcp6StateSynSent.
  445. @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
  446. @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
  447. - This instance is not configured as an active instance.
  448. - This instance is not in Tcp6StateClosed state.
  449. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
  450. - This is NULL.
  451. - ConnectionToken is NULL.
  452. - ConnectionToken->CompletionToken.Event is NULL.
  453. @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
  454. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  455. **/
  456. EFI_STATUS
  457. EFIAPI
  458. Tcp6Connect (
  459. IN EFI_TCP6_PROTOCOL *This,
  460. IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
  461. );
  462. /**
  463. Listen on the passive instance to accept an incoming connection request. This is a
  464. nonblocking operation.
  465. The Accept() function initiates an asynchronous accept request to wait for an incoming
  466. connection on the passive TCP instance. If a remote peer successfully establishes a
  467. connection with this instance, a new TCP instance will be created and its handle will
  468. be returned in ListenToken->NewChildHandle. The newly created instance is configured
  469. by inheriting the passive instance's configuration, and is ready for use upon return.
  470. The new instance is in the Tcp6StateEstablished state.
  471. The ListenToken->CompletionToken.Event will be signaled when a new connection is
  472. accepted, user aborts the listen or connection is reset.
  473. This function only can be called when the current TCP instance is in Tcp6StateListen state.
  474. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  475. @param[in] ListenToken Pointer to the listen token to return when the operation finishes.
  476. @retval EFI_SUCCESS The listen token was been queued successfully.
  477. @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
  478. @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
  479. - This instance is not a passive instance.
  480. - This instance is not in Tcp6StateListen state.
  481. - The same listen token has already existed in the listen
  482. token queue of this TCP instance.
  483. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
  484. - This is NULL.
  485. - ListenToken is NULL.
  486. - ListenToken->CompletionToken.Event is NULL.
  487. @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
  488. @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error
  489. categories given above.
  490. **/
  491. EFI_STATUS
  492. EFIAPI
  493. Tcp6Accept (
  494. IN EFI_TCP6_PROTOCOL *This,
  495. IN EFI_TCP6_LISTEN_TOKEN *ListenToken
  496. );
  497. /**
  498. Queues outgoing data into the transmit queue.
  499. The Transmit() function queues a sending request to this TCP instance along with the
  500. user data. The status of the token is updated and the event in the token will be
  501. signaled once the data is sent out or some error occurs.
  502. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  503. @param[in] Token Pointer to the completion token to queue to the transmit queue.
  504. @retval EFI_SUCCESS The data has been queued for transmission.
  505. @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
  506. @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
  507. source address for this instance, but no source address was
  508. available for use.
  509. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
  510. - This is NULL.
  511. - Token is NULL.
  512. - Token->CompletionToken.Event is NULL.
  513. - Token->Packet.TxData is NULL.
  514. - Token->Packet.FragmentCount is zero.
  515. - Token->Packet.DataLength is not equal to the sum of fragment lengths.
  516. @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
  517. - A transmit completion token with the same Token->
  518. CompletionToken.Event was already in the
  519. transmission queue.
  520. - The current instance is in Tcp6StateClosed state.
  521. - The current instance is a passive one and it is in
  522. Tcp6StateListen state.
  523. - User has called Close() to disconnect this connection.
  524. @retval EFI_NOT_READY The completion token could not be queued because the
  525. transmit queue is full.
  526. @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a resource
  527. shortage.
  528. @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
  529. **/
  530. EFI_STATUS
  531. EFIAPI
  532. Tcp6Transmit (
  533. IN EFI_TCP6_PROTOCOL *This,
  534. IN EFI_TCP6_IO_TOKEN *Token
  535. );
  536. /**
  537. Places an asynchronous receive request into the receiving queue.
  538. The Receive() function places a completion token into the receive packet queue. This
  539. function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
  540. and the FragmentBuffer used to receive data. The caller also must fill the DataLength, which
  541. represents the whole length of all FragmentBuffer. When the receive operation completes, the
  542. EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
  543. fields, and the Token->CompletionToken.Event is signaled. If data is obtained, the data and its length
  544. will be copied into the FragmentTable. At the same time the full length of received data will
  545. be recorded in the DataLength fields. Providing a proper notification function and context
  546. for the event enables the user to receive the notification and receiving status. That
  547. notification function is guaranteed to not be re-entered.
  548. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  549. @param[in] Token Pointer to a token that is associated with the receive data
  550. descriptor.
  551. @retval EFI_SUCCESS The receive completion token was cached.
  552. @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
  553. @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
  554. address for this instance, but no source address was available for use.
  555. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  556. - This is NULL.
  557. - Token is NULL.
  558. - Token->CompletionToken.Event is NULL.
  559. - Token->Packet.RxData is NULL.
  560. - Token->Packet.RxData->DataLength is 0.
  561. - The Token->Packet.RxData->DataLength is not the
  562. sum of all FragmentBuffer length in FragmentTable.
  563. @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
  564. system resources (usually memory).
  565. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  566. The EFI TCPv6 Protocol instance has been reset to startup defaults.
  567. @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
  568. - A receive completion token with the same Token->CompletionToken.Event
  569. was already in the receive queue.
  570. - The current instance is in Tcp6StateClosed state.
  571. - The current instance is a passive one and it is in
  572. Tcp6StateListen state.
  573. - The user has called Close() to disconnect this connection.
  574. @retval EFI_CONNECTION_FIN The communication peer has closed the connection, and there is no
  575. buffered data in the receive buffer of this instance.
  576. @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
  577. **/
  578. EFI_STATUS
  579. EFIAPI
  580. Tcp6Receive (
  581. IN EFI_TCP6_PROTOCOL *This,
  582. IN EFI_TCP6_IO_TOKEN *Token
  583. );
  584. /**
  585. Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
  586. nonblocking operation.
  587. Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
  588. transmission data will be sent by the TCP driver, and the current instance will have a graceful close
  589. working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet
  590. will be sent by TCP driver to fast disconnect this connection. When the close operation completes
  591. successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
  592. operations are signaled, and any buffers used for TCP network traffic are flushed.
  593. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  594. @param[in] CloseToken Pointer to the close token to return when operation finishes.
  595. @retval EFI_SUCCESS The Close() was called successfully.
  596. @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
  597. @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
  598. - CloseToken or CloseToken->CompletionToken.Event is already in use.
  599. - Previous Close() call on this instance has not finished.
  600. @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
  601. - This is NULL.
  602. - CloseToken is NULL.
  603. - CloseToken->CompletionToken.Event is NULL.
  604. @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
  605. @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error categories given above.
  606. **/
  607. EFI_STATUS
  608. EFIAPI
  609. Tcp6Close (
  610. IN EFI_TCP6_PROTOCOL *This,
  611. IN EFI_TCP6_CLOSE_TOKEN *CloseToken
  612. );
  613. /**
  614. Abort an asynchronous connection, listen, transmission or receive request.
  615. The Cancel() function aborts a pending connection, listen, transmit or
  616. receive request.
  617. If Token is not NULL and the token is in the connection, listen, transmission
  618. or receive queue when it is being cancelled, its Token->Status will be set
  619. to EFI_ABORTED and then Token->Event will be signaled.
  620. If the token is not in one of the queues, which usually means that the
  621. asynchronous operation has completed, EFI_NOT_FOUND is returned.
  622. If Token is NULL all asynchronous token issued by Connect(), Accept(),
  623. Transmit() and Receive() will be aborted.
  624. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  625. @param[in] Token Pointer to a token that has been issued by
  626. EFI_TCP6_PROTOCOL.Connect(),
  627. EFI_TCP6_PROTOCOL.Accept(),
  628. EFI_TCP6_PROTOCOL.Transmit() or
  629. EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
  630. tokens issued by above four functions will be aborted. Type
  631. EFI_TCP6_COMPLETION_TOKEN is defined in
  632. EFI_TCP_PROTOCOL.Connect().
  633. @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
  634. is signaled.
  635. @retval EFI_INVALID_PARAMETER This is NULL.
  636. @retval EFI_NOT_STARTED This instance hasn't been configured.
  637. @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
  638. receive queue. It has either completed or wasn't issued by
  639. Transmit() and Receive().
  640. **/
  641. EFI_STATUS
  642. EFIAPI
  643. Tcp6Cancel (
  644. IN EFI_TCP6_PROTOCOL *This,
  645. IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
  646. );
  647. /**
  648. Poll to receive incoming data and transmit outgoing segments.
  649. The Poll() function increases the rate that data is moved between the network
  650. and application and can be called when the TCP instance is created successfully.
  651. Its use is optional.
  652. @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
  653. @retval EFI_SUCCESS Incoming or outgoing data was processed.
  654. @retval EFI_INVALID_PARAMETER This is NULL.
  655. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  656. @retval EFI_NOT_READY No incoming or outgoing data is processed.
  657. @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
  658. Consider increasing the polling rate.
  659. **/
  660. EFI_STATUS
  661. EFIAPI
  662. Tcp6Poll (
  663. IN EFI_TCP6_PROTOCOL *This
  664. );
  665. #endif