]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Socket.h
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / StdLib / EfiSocketLib / Socket.h
index 25133e6f89776815d51de8ac3c7bc87b0841db49..b38bec6bde4e77ca20c6add3dc80c533b7d48349 100644 (file)
@@ -33,9 +33,9 @@
 #define DEBUG_OPTION        0x00080000  ///<  Display option messages\r
 \r
 #define MAX_PENDING_CONNECTIONS     1   ///<  Maximum connection FIFO depth\r
-#define MAX_RX_DATA         65536       ///<  Maximum receive data size\r
+#define MAX_RX_DATA         0x01000000  ///<  Maximum receive data size\r
 #define MAX_TX_DATA         ( MAX_RX_DATA * 2 ) ///<  Maximum buffered transmit data in bytes\r
-#define RX_PACKET_DATA      16384       ///<  Maximum number of bytes in a RX packet\r
+#define RX_PACKET_DATA      0x00100000  ///<  Maximum number of bytes in a RX packet\r
 #define MAX_UDP_RETRANSMIT  16          ///<  UDP retransmit attempts to handle address not mapped\r
 \r
 #define ESL_STRUCTURE_ALIGNMENT_BYTES   15  ///<  Number of bytes for structure alignment\r
@@ -137,6 +137,26 @@ typedef struct
 } ESL_TCP4_TX_DATA;\r
 \r
 \r
+/**\r
+  Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r
+**/\r
+typedef struct\r
+{\r
+  EFI_TCP6_RECEIVE_DATA RxData;         ///<  Receive operation description\r
+  UINT8 Buffer[ RX_PACKET_DATA ];       ///<  Data buffer\r
+} ESL_TCP6_RX_DATA;\r
+\r
+\r
+/**\r
+  Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r
+**/\r
+typedef struct\r
+{\r
+  EFI_TCP6_TRANSMIT_DATA TxData;        ///<  Transmit operation description\r
+  UINT8 Buffer[ 1 ];                    ///<  Data buffer\r
+} ESL_TCP6_TX_DATA;\r
+\r
+\r
 /**\r
   Receive context for SOCK_DGRAM sockets using UDPv4.\r
 **/\r
@@ -159,6 +179,28 @@ typedef struct
 } ESL_UDP4_TX_DATA;\r
 \r
 \r
+/**\r
+  Receive context for SOCK_DGRAM sockets using UDPv6.\r
+**/\r
+typedef struct\r
+{\r
+  EFI_UDP6_SESSION_DATA Session;        ///<  Remote network address\r
+  EFI_UDP6_RECEIVE_DATA * pRxData;      ///<  Receive operation description\r
+} ESL_UDP6_RX_DATA;\r
+\r
+\r
+/**\r
+  Transmit context for SOCK_DGRAM sockets using UDPv6.\r
+**/\r
+typedef struct\r
+{\r
+  EFI_UDP6_SESSION_DATA Session;        ///<  Remote network address\r
+  EFI_UDP6_TRANSMIT_DATA TxData;        ///<  Transmit operation description\r
+  UINTN RetransmitCount;                ///<  Retransmit to handle ARP negotiation\r
+  UINT8 Buffer[ 1 ];                    ///<  Data buffer\r
+} ESL_UDP6_TX_DATA;\r
+\r
+\r
 /**\r
   Network specific context for transmit and receive packets.\r
 **/\r
@@ -172,8 +214,12 @@ typedef struct _ESL_PACKET {
     ESL_IP4_TX_DATA Ip4Tx;              ///<  Transmit operation description\r
     ESL_TCP4_RX_DATA Tcp4Rx;            ///<  Receive operation description\r
     ESL_TCP4_TX_DATA Tcp4Tx;            ///<  Transmit operation description\r
+    ESL_TCP6_RX_DATA Tcp6Rx;            ///<  Receive operation description\r
+    ESL_TCP6_TX_DATA Tcp6Tx;            ///<  Transmit operation description\r
     ESL_UDP4_RX_DATA Udp4Rx;            ///<  Receive operation description\r
     ESL_UDP4_TX_DATA Udp4Tx;            ///<  Transmit operation description\r
+    ESL_UDP6_RX_DATA Udp6Rx;            ///<  Receive operation description\r
+    ESL_UDP6_TX_DATA Udp6Tx;            ///<  Transmit operation description\r
   } Op;                                 ///<  Network specific context\r
 } GCC_ESL_PACKET;\r
 \r
@@ -217,10 +263,14 @@ typedef struct _ESL_IO_MGMT {
     EFI_IP4_COMPLETION_TOKEN Ip4Tx;   ///<  IP4 transmit token\r
     EFI_TCP4_IO_TOKEN Tcp4Rx;         ///<  TCP4 receive token\r
     EFI_TCP4_IO_TOKEN Tcp4Tx;         ///<  TCP4 transmit token\r
+    EFI_TCP6_IO_TOKEN Tcp6Rx;         ///<  TCP6 receive token\r
+    EFI_TCP6_IO_TOKEN Tcp6Tx;         ///<  TCP6 transmit token\r
     EFI_UDP4_COMPLETION_TOKEN Udp4Rx; ///<  UDP4 receive token\r
     EFI_UDP4_COMPLETION_TOKEN Udp4Tx; ///<  UDP4 transmit token\r
+    EFI_UDP6_COMPLETION_TOKEN Udp6Rx; ///<  UDP6 receive token\r
+    EFI_UDP6_COMPLETION_TOKEN Udp6Tx; ///<  UDP6 transmit token\r
   } Token;                            ///<  Completion token for the network operation\r
-};\r
+} GCC_IO_MGMT;\r
 \r
 /**\r
   IP4 context structure\r
@@ -256,6 +306,26 @@ typedef struct {
   EFI_TCP4_CLOSE_TOKEN CloseToken;        ///<  Close control\r
 } ESL_TCP4_CONTEXT;\r
 \r
+/**\r
+  TCP6 context structure\r
+\r
+  The driver uses this structure to manage the TCP6 connections.\r
+**/\r
+typedef struct {\r
+  //\r
+  //  TCP6 context\r
+  //\r
+  EFI_TCP6_CONFIG_DATA ConfigData;        ///<  TCP6 configuration data\r
+  EFI_TCP6_OPTION Option;                 ///<  TCP6 port options\r
+\r
+  //\r
+  //  Tokens\r
+  //\r
+  EFI_TCP6_LISTEN_TOKEN ListenToken;      ///<  Listen control\r
+  EFI_TCP6_CONNECTION_TOKEN ConnectToken; ///<  Connection control\r
+  EFI_TCP6_CLOSE_TOKEN CloseToken;        ///<  Close control\r
+} ESL_TCP6_CONTEXT;\r
+\r
 /**\r
   UDP4 context structure\r
 \r
@@ -268,6 +338,18 @@ typedef struct {
   EFI_UDP4_CONFIG_DATA ConfigData;  ///<  UDP4 configuration data\r
 } ESL_UDP4_CONTEXT;\r
 \r
+/**\r
+  UDP6 context structure\r
+\r
+  The driver uses this structure to manage the UDP6 connections.\r
+**/\r
+typedef struct {\r
+  //\r
+  //  UDP6 context\r
+  //\r
+  EFI_UDP6_CONFIG_DATA ConfigData;  ///<  UDP6 configuration data\r
+} ESL_UDP6_CONTEXT;\r
+\r
 \r
 /**\r
   Configure the network layer.\r
@@ -280,7 +362,7 @@ typedef struct {
 **/\r
 typedef\r
 EFI_STATUS\r
-(* PFN_NET_CONFIGURE) (\r
+(EFIAPI * PFN_NET_CONFIGURE) (\r
   IN VOID * pProtocol,\r
   IN VOID * pConfigData\r
   );\r
@@ -296,11 +378,26 @@ EFI_STATUS
 **/\r
 typedef\r
 EFI_STATUS\r
-(* PFN_NET_IO_START) (\r
+(EFIAPI * PFN_NET_IO_START) (\r
   IN VOID * pProtocol,\r
   IN VOID * pToken\r
   );\r
 \r
+/**\r
+  Poll the LAN adapter for receive packets.\r
+\r
+  @param [in] pProtocol   Protocol structure address\r
+  @param [in] pToken      Completion token address\r
+\r
+  @return   Returns EFI_SUCCESS if the operation is successfully\r
+            started.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * PFN_NET_POLL) (\r
+  IN VOID * pProtocol\r
+  );\r
+\r
 /**\r
   Port control structure\r
 \r
@@ -353,6 +450,7 @@ typedef struct _ESL_PORT {
   //  Receive data management\r
   //\r
   PFN_NET_IO_START pfnRxCancel; ///<  Cancel a receive on the network\r
+  PFN_NET_POLL pfnRxPoll;       ///<  Poll the LAN adapter for receive packets\r
   PFN_NET_IO_START pfnRxStart;  ///<  Start a receive on the network\r
   ESL_IO_MGMT * pRxActive;      ///<  Active receive operation queue\r
   ESL_IO_MGMT * pRxFree;        ///<  Free structure queue\r
@@ -364,12 +462,16 @@ typedef struct _ESL_PORT {
     VOID * v;                   ///<  VOID pointer\r
     EFI_IP4_PROTOCOL * IPv4;    ///<  IP4 protocol pointer\r
     EFI_TCP4_PROTOCOL * TCPv4;  ///<  TCP4 protocol pointer\r
+    EFI_TCP6_PROTOCOL * TCPv6;  ///<  TCP6 protocol pointer\r
     EFI_UDP4_PROTOCOL * UDPv4;  ///<  UDP4 protocol pointer\r
+    EFI_UDP6_PROTOCOL * UDPv6;  ///<  UDP6 protocol pointer\r
   } pProtocol;                  ///<  Protocol structure address\r
   union {\r
     ESL_IP4_CONTEXT Ip4;        ///<  IPv4 management data\r
     ESL_TCP4_CONTEXT Tcp4;      ///<  TCPv4 management data\r
+    ESL_TCP6_CONTEXT Tcp6;      ///<  TCPv6 management data\r
     ESL_UDP4_CONTEXT Udp4;      ///<  UDPv4 management data\r
+    ESL_UDP6_CONTEXT Udp6;      ///<  UDPv6 management data\r
   } Context;                    ///<  Network specific context\r
 }GCC_ESL_PORT;\r
 \r
@@ -480,6 +582,26 @@ EFI_STATUS
   IN BOOLEAN bBindTest\r
   );\r
 \r
+/**\r
+  Process the completion event\r
+\r
+  This routine handles the I/O completion event.\r
+\r
+  This routine is called by the low level network driver when\r
+  the operation is completed.\r
+\r
+  @param [in] Event     The receive completion event\r
+\r
+  @param [in] pIo       The address of an ::ESL_IO_MGMT structure\r
+\r
+**/\r
+typedef\r
+VOID\r
+(* PFN_API_IO_COMPLETE) (\r
+  IN EFI_EVENT Event,\r
+  IN ESL_IO_MGMT * pIo\r
+  );\r
+\r
 /**\r
   Determine if the socket is configured.\r
 \r
@@ -726,26 +848,6 @@ EFI_STATUS
   IN socklen_t SockAddrLength\r
   );\r
 \r
-/**\r
-  Process the receive completion\r
-\r
-  This routine handles the receive completion event.\r
-\r
-  This routine is called by the low level network driver when\r
-  data is received.\r
-\r
-  @param [in] Event     The receive completion event\r
-\r
-  @param [in] pIo       The address of an ::ESL_IO_MGMT structure\r
-\r
-**/\r
-typedef\r
-VOID\r
-(* PFN_API_RX_COMPLETE) (\r
-  IN EFI_EVENT Event,\r
-  IN ESL_IO_MGMT * pIo\r
-  );\r
-\r
 /**\r
   Start a receive operation\r
 \r
@@ -853,7 +955,7 @@ typedef struct {
   PFN_API_RECEIVE pfnReceive;               ///<  Attempt to receive some data\r
   PFN_API_REMOTE_ADDR_GET pfnRemoteAddrGet; ///<  Get remote address\r
   PFN_API_REMOTE_ADDR_SET pfnRemoteAddrSet; ///<  Set the remote system address\r
-  PFN_API_RX_COMPLETE pfnRxComplete;        ///<  RX completion\r
+  PFN_API_IO_COMPLETE pfnRxComplete;        ///<  RX completion\r
   PFN_API_RX_START pfnRxStart;              ///<  Start a network specific receive operation\r
   PFN_API_TRANSMIT pfnTransmit;             ///<  Attempt to buffer a packet for transmit\r
   PFN_API_TX_COMPLETE pfnTxComplete;        ///<  TX completion for normal data\r
@@ -887,9 +989,10 @@ typedef struct _ESL_SOCKET {
   //\r
   //  Socket options\r
   //\r
+  BOOLEAN bIncludeHeader;       ///<  TRUE if including the IP header\r
   BOOLEAN bListenCalled;        ///<  TRUE if listen was successfully called\r
   BOOLEAN bOobInLine;           ///<  TRUE if out-of-band messages are to be received inline with normal data\r
-  BOOLEAN bIncludeHeader;       ///<  TRUE if including the IP header\r
+  BOOLEAN bReUseAddr;           ///<  TRUE if using same address is allowed\r
 \r
   //\r
   //  Socket data\r
@@ -897,6 +1000,7 @@ typedef struct _ESL_SOCKET {
   int Domain;                   ///<  Specifies family of protocols\r
   int Type;                     ///<  Specifies how to make network connection\r
   int Protocol;                 ///<  Specifies lower layer protocol to use\r
+  BOOLEAN bAddressSet;          ///<  Set when the address is specified\r
   BOOLEAN bConfigured;          ///<  Set after the socket is configured\r
 \r
   BOOLEAN bRxDisable;           ///<  Receive disabled via shutdown\r
@@ -975,7 +1079,9 @@ typedef struct {
   //\r
   ESL_SERVICE * pIp4List;       ///<  List of Ip4 services\r
   ESL_SERVICE * pTcp4List;      ///<  List of Tcp4 services\r
+  ESL_SERVICE * pTcp6List;      ///<  List of Tcp6 services\r
   ESL_SERVICE * pUdp4List;      ///<  List of Udp4 services\r
+  ESL_SERVICE * pUdp6List;      ///<  List of Udp6 services\r
 \r
   //\r
   //  Socket management\r
@@ -992,8 +1098,11 @@ typedef struct {
 extern ESL_LAYER mEslLayer;\r
 \r
 extern CONST ESL_PROTOCOL_API cEslIp4Api;\r
+extern CONST ESL_PROTOCOL_API cEslIp6Api;\r
 extern CONST ESL_PROTOCOL_API cEslTcp4Api;\r
+extern CONST ESL_PROTOCOL_API cEslTcp6Api;\r
 extern CONST ESL_PROTOCOL_API cEslUdp4Api;\r
+extern CONST ESL_PROTOCOL_API cEslUdp6Api;\r
 \r
 extern CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding;\r
 \r
@@ -1078,6 +1187,28 @@ EslSocketCopyFragmentedBuffer (
   OUT size_t * pDataLength\r
   );\r
 \r
+/**\r
+  Free the socket.\r
+\r
+  This routine frees the socket structure and handle resources.\r
+\r
+  The ::close routine calls EslServiceFreeProtocol which then calls\r
+  this routine to free the socket context structure and close the\r
+  handle.\r
+\r
+  @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
+  \r
+  @param [out] pErrno         Address to receive the errno value upon completion.\r
+\r
+  @retval EFI_SUCCESS   The socket resources were returned successfully.\r
+\r
+ **/\r
+EFI_STATUS\r
+EslSocketFree (\r
+  IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
+  IN int * pErrno\r
+  );\r
+\r
 /**\r
   Free the ESL_IO_MGMT event and structure\r
 \r
@@ -1132,7 +1263,7 @@ EslSocketIoInit (
   IN ESL_IO_MGMT ** ppFreeQueue,\r
   IN UINTN DebugFlags,\r
   IN CHAR8 * pEventName,\r
-  IN EFI_EVENT_NOTIFY pfnCompletion\r
+  IN PFN_API_IO_COMPLETE pfnCompletion\r
   );\r
 \r
 /**\r
@@ -1423,6 +1554,24 @@ EslSocketRxComplete (
   IN BOOLEAN bUrgent\r
   );\r
 \r
+/**\r
+  Poll a socket for pending receive activity.\r
+\r
+  This routine is called at elivated TPL and extends the idle\r
+  loop which polls a socket down into the LAN driver layer to\r
+  determine if there is any receive activity.\r
+\r
+  The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit\r
+  routines call this routine when there is nothing to do.\r
+\r
+  @param [in] pSocket   Address of an ::EFI_SOCKET structure.\r
+\r
+ **/\r
+VOID\r
+EslSocketRxPoll (\r
+  IN ESL_SOCKET * pSocket\r
+  );\r
+\r
 /**\r
   Start a receive operation\r
 \r