]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/UseEfiSocketLib.c
MdeModulePkg/DxeLoadFunc: Add use case for new Perf macro
[mirror_edk2.git] / StdLib / EfiSocketLib / UseEfiSocketLib.c
index ed72e8e76368893c4f80fd55773cffb3b7d6a4ea..060598af31e4b6f0684833d2492c372404f777dd 100644 (file)
@@ -23,7 +23,7 @@
   \r
   Tag GUID - IPv4 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslIp4ServiceGuid = {\r
+CONST EFI_GUID mEslIp4ServiceGuid __attribute__((weak)) = {\r
   0x9c756011, 0x5d44, 0x4ee0, { 0xbc, 0xe7, 0xc3, 0x82, 0x18, 0xfe, 0x39, 0x8d }\r
 };\r
 \r
@@ -31,7 +31,7 @@ CONST EFI_GUID mEslIp4ServiceGuid = {
 /**\r
   Tag GUID - IPv6 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslIp6ServiceGuid = {\r
+CONST EFI_GUID mEslIp6ServiceGuid __attribute__((weak)) = {\r
   0xc51b2761, 0xc476, 0x45fe, { 0xbe, 0x61, 0xba, 0x4b, 0xcc, 0x32, 0xf2, 0x34 }\r
 };\r
 \r
@@ -39,7 +39,7 @@ CONST EFI_GUID mEslIp6ServiceGuid = {
 /**\r
   Tag GUID - TCPv4 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslTcp4ServiceGuid = {\r
+CONST EFI_GUID mEslTcp4ServiceGuid __attribute__((weak)) = {\r
   0xffc659c2, 0x4ef2, 0x4532, { 0xb8, 0x75, 0xcd, 0x9a, 0xa4, 0x27, 0x4c, 0xde }\r
 };\r
 \r
@@ -47,7 +47,7 @@ CONST EFI_GUID mEslTcp4ServiceGuid = {
 /**\r
   Tag GUID - TCPv6 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslTcp6ServiceGuid = {\r
+CONST EFI_GUID mEslTcp6ServiceGuid __attribute__((weak)) = {\r
   0x279858a4, 0x4e9e, 0x4e53, { 0x93, 0x22, 0xf2, 0x54, 0xe0, 0x7e, 0xef, 0xd4 }\r
 };\r
 \r
@@ -55,7 +55,7 @@ CONST EFI_GUID mEslTcp6ServiceGuid = {
 /**\r
   Tag GUID - UDPv4 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslUdp4ServiceGuid = {\r
+CONST EFI_GUID mEslUdp4ServiceGuid __attribute__((weak)) = {\r
   0x44e03a55, 0x8d97, 0x4511, { 0xbf, 0xef, 0xa, 0x8b, 0xc6, 0x2c, 0x25, 0xae }\r
 };\r
 \r
@@ -63,11 +63,45 @@ CONST EFI_GUID mEslUdp4ServiceGuid = {
 /**\r
   Tag GUID - UDPv6 in use by an application using EfiSocketLib\r
 **/\r
-CONST EFI_GUID mEslUdp6ServiceGuid = {\r
+CONST EFI_GUID mEslUdp6ServiceGuid __attribute__((weak)) = {\r
   0xaa4af677, 0x6efe, 0x477c, { 0x96, 0x68, 0xe8, 0x13, 0x9d, 0x2, 0xfd, 0x9b }\r
 };\r
 \r
 \r
+/**\r
+  Free the socket resources\r
+\r
+  This releases the socket resources allocated by calling\r
+  EslServiceGetProtocol.\r
+\r
+  This routine is called from the ::close routine in BsdSocketLib\r
+  to release the socket resources.\r
+\r
+  @param [in] pSocketProtocol   Address of an ::EFI_SOCKET_PROTOCOL\r
+                                structure\r
+\r
+  @return       Value for ::errno, zero (0) indicates success.\r
+\r
+ **/\r
+int\r
+EslServiceFreeProtocol (\r
+  IN EFI_SOCKET_PROTOCOL * pSocketProtocol\r
+  )\r
+{\r
+  int RetVal;\r
+\r
+  //\r
+  //  Release the socket resources\r
+  //\r
+  EslSocketFree ( pSocketProtocol, &RetVal );\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
+\r
+\r
 /**\r
   Connect to the EFI socket library\r
 \r
@@ -196,10 +230,17 @@ EslServiceNetworkConnect (
         for ( Index = 0; HandleCount > Index; Index++ ) {\r
           Status = EslServiceConnect ( gImageHandle,\r
                                        pHandles[ Index ]);\r
-          if ( EFI_ERROR ( Status )) {\r
-            break;\r
+          if ( !EFI_ERROR ( Status )) {\r
+            bSomethingFound = TRUE;\r
+          }\r
+          else {\r
+            if ( EFI_OUT_OF_RESOURCES == Status ) {\r
+              //\r
+              //  Pointless to continue without memory\r
+              //\r
+              break;\r
+            }\r
           }\r
-          bSomethingFound = TRUE;\r
         }\r
 \r
         //\r
@@ -320,7 +361,7 @@ EslServiceNetworkDisconnect (
 /**\r
   Socket layer's service binding protocol delcaration.\r
 **/\r
-CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {\r
+CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding __attribute__((weak)) = {\r
   NULL,\r
   NULL\r
 };\r
@@ -331,5 +372,5 @@ CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {
   for any socket application that links against the EfiSocketLib.\r
   Note that the SocketDxe driver uses different redirection.\r
 **/\r
-PFN_ESL_xSTRUCTOR mpfnEslConstructor = EslServiceNetworkConnect;    ///<  Constructor for EfiSocketLib\r
-PFN_ESL_xSTRUCTOR mpfnEslDestructor = EslServiceNetworkDisconnect;  ///<  Destructor for EfiSocketLib\r
+PFN_ESL_xSTRUCTOR mpfnEslConstructor __attribute__((weak)) = EslServiceNetworkConnect;    ///<  Constructor for EfiSocketLib\r
+PFN_ESL_xSTRUCTOR mpfnEslDestructor __attribute__((weak)) = EslServiceNetworkDisconnect;  ///<  Destructor for EfiSocketLib\r