]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/UseSocketDxe/UseSocketDxe.c
MdePkg/Library/BaseLib: Enable VS2017/ARM64 builds
[mirror_edk2.git] / StdLib / UseSocketDxe / UseSocketDxe.c
index 0b7194c234e4ba3c8f2bf5f84aa1f42ab564f096..423419c23e55d9cd1176003eece0ea8e1544a7ff 100644 (file)
 \r
 \r
 /**\r
-  Connect to the socket driver\r
+  Free the socket resources\r
 \r
-  @param [in] ppSocketProtocol  Address to receive the socket protocol address\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
+  EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;\r
+  int RetVal;\r
+  EFI_STATUS Status;\r
+\r
+  //\r
+  //  Assume success\r
+  //\r
+  RetVal = 0;\r
+\r
+  //\r
+  //  Locate the socket protocol\r
+  //\r
+  Status = gBS->LocateProtocol ( &gEfiSocketServiceBindingProtocolGuid,\r
+                                 NULL,\r
+                                 (VOID **) &pServiceBinding );\r
+  if ( !EFI_ERROR ( Status )) {\r
+    //\r
+    //  Release the handle\r
+    //\r
+    Status = pServiceBinding->DestroyChild ( pServiceBinding,\r
+                                             pSocketProtocol->SocketHandle );\r
+  }\r
+  if ( EFI_ERROR ( Status )) {\r
+    RetVal = EIO;\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
+\r
+\r
+/**\r
+  Connect to the EFI socket library\r
+\r
+  This routine establishes a connection to the socket driver\r
+  and returns the API (::EFI_SOCKET_PROTOCOL address) to the\r
+  socket file system layer in BsdSocketLib.  This routine looks for\r
+  the gEfiSocketServiceBindingProtocolGuid to locate the socket\r
+  driver.  This routine then creates a child handle and locates\r
+  the gEfiSocketProtocolGuid protocol on that handle to get the\r
+  ::EFI_SOCKET_PROTOCOL structure address.\r
+\r
+  This routine is called from the ::socket routine in BsdSocketLib\r
+  to create the data structure and initialize the API for a socket.\r
+  Note that this implementation is only used by socket applications\r
+  that link directly to UseSocketDxe.\r
+\r
+  @param [in] ppSocketProtocol  Address to receive the ::EFI_SOCKET_PROTOCOL\r
+                                structure address\r
+\r
+  @return       Value for ::errno, zero (0) indicates success.\r
 \r
-  @retval 0             Successfully returned the socket protocol\r
-  @retval other         Value for errno\r
  **/\r
 int\r
 EslServiceGetProtocol (\r
@@ -148,7 +215,7 @@ EslServiceGetProtocol (
   }\r
   else {\r
     DEBUG (( DEBUG_ERROR,\r
-              "ERROR - No socket service binding protocol, Status: %r\r\n",\r
+              "ERROR - Socket driver not loaded, Status: %r\r\n",\r
               Status ));\r
     RetVal = ENODEV;\r
   }\r