SockImpl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /** @file
  2. The function declaration that provided for Socket Interface.
  3. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _SOCK_IMPL_H_
  7. #define _SOCK_IMPL_H_
  8. #include "Socket.h"
  9. #include "TcpMain.h"
  10. /**
  11. Signal a event with the given status.
  12. @param[in] Token The token's event is to be signaled.
  13. @param[in] TokenStatus The status to be sent with the event.
  14. **/
  15. #define SIGNAL_TOKEN(Token, TokenStatus) \
  16. do { \
  17. (Token)->Status = (TokenStatus); \
  18. gBS->SignalEvent ((Token)->Event); \
  19. } while (0)
  20. #define SOCK_HEADER_SPACE (60 + 60 + 72)
  21. /**
  22. Process the TCP send data, buffer the tcp txdata and append
  23. the buffer to socket send buffer, then try to send it.
  24. @param[in] Sock Pointer to the socket.
  25. @param[in] TcpTxData Pointer to the application provided send buffer.
  26. @retval EFI_SUCCESS The operation completed successfully.
  27. @retval EFI_OUT_OF_RESOURCES Failed due to resource limits.
  28. **/
  29. EFI_STATUS
  30. SockProcessTcpSndData (
  31. IN SOCKET *Sock,
  32. IN VOID *TcpTxData
  33. );
  34. /**
  35. Get received data from the socket layer to the receive token.
  36. @param[in, out] Sock Pointer to the socket.
  37. @param[in, out] RcvToken Pointer to the application provided receive token.
  38. @return The length of data received in this token.
  39. **/
  40. UINT32
  41. SockProcessRcvToken (
  42. IN OUT SOCKET *Sock,
  43. IN OUT SOCK_IO_TOKEN *RcvToken
  44. );
  45. /**
  46. Flush the sndBuffer and rcvBuffer of socket.
  47. @param[in, out] Sock Pointer to the socket.
  48. **/
  49. VOID
  50. SockConnFlush (
  51. IN OUT SOCKET *Sock
  52. );
  53. /**
  54. Cancel the tokens in the specific token list.
  55. @param[in] Token Pointer to the Token. If NULL, all tokens
  56. in SpecifiedTokenList will be canceled.
  57. @param[in, out] SpecifiedTokenList Pointer to the token list to be checked.
  58. @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully.
  59. @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList.
  60. **/
  61. EFI_STATUS
  62. SockCancelToken (
  63. IN SOCK_COMPLETION_TOKEN *Token,
  64. IN OUT LIST_ENTRY *SpecifiedTokenList
  65. );
  66. /**
  67. Create a socket with initial data SockInitData.
  68. @param[in] SockInitData Pointer to the initial data of the socket.
  69. @return Pointer to the newly created socket, return NULL when exception occurred.
  70. **/
  71. SOCKET *
  72. SockCreate (
  73. IN SOCK_INIT_DATA *SockInitData
  74. );
  75. /**
  76. Destroy a socket.
  77. @param[in, out] Sock Pointer to the socket.
  78. **/
  79. VOID
  80. SockDestroy (
  81. IN OUT SOCKET *Sock
  82. );
  83. #endif