]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/EfiSocketLib/Ip4.c
ArmVirtPkg: add "Contributions.txt" and "License.txt"
[mirror_edk2.git] / StdLib / EfiSocketLib / Ip4.c
index 84646e726a49df04a4801bf9517646015a9d1c2f..bca36ea7d22b21e446ced72b5dcad91115d760d4 100644 (file)
@@ -9,14 +9,11 @@
 \r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
 **/\r
-\r
 #include "Socket.h"\r
 \r
 \r
-/**\r
-  Get the local socket address\r
+/** Get the local socket address.\r
 \r
   This routine returns the IPv4 address associated with the local\r
   socket.\r
@@ -25,9 +22,7 @@
   network address for the SOCK_RAW socket.\r
 \r
   @param [in] pPort       Address of an ::ESL_PORT structure.\r
-\r
   @param [out] pAddress   Network address to receive the local system address\r
-\r
 **/\r
 VOID\r
 EslIp4LocalAddressGet (\r
@@ -40,9 +35,7 @@ EslIp4LocalAddressGet (
 \r
   DBG_ENTER ( );\r
 \r
-  //\r
   //  Return the local address\r
-  //\r
   pIp4 = &pPort->Context.Ip4;\r
   pLocalAddress = (struct sockaddr_in *)pAddress;\r
   pLocalAddress->sin_family = AF_INET;\r
@@ -54,8 +47,7 @@ EslIp4LocalAddressGet (
 }\r
 \r
 \r
-/**\r
-  Set the local port address.\r
+/** Set the local port address.\r
 \r
   This routine sets the local port address.\r
 \r
@@ -75,7 +67,6 @@ EslIp4LocalAddressGet (
   @param [in] bBindTest   TRUE = run bind testing\r
 \r
   @retval EFI_SUCCESS     The operation was successful\r
-\r
  **/\r
 EFI_STATUS\r
 EslIp4LocalAddressSet (\r
@@ -91,23 +82,17 @@ EslIp4LocalAddressSet (
 \r
   DBG_ENTER ( );\r
 \r
-  //\r
   //  Validate the address\r
-  //\r
   pIpAddress = (struct sockaddr_in *)pSockAddr;\r
   if ( INADDR_BROADCAST == pIpAddress->sin_addr.s_addr ) {\r
-    //\r
     //  The local address must not be the broadcast address\r
-    //\r
     Status = EFI_INVALID_PARAMETER;\r
     pPort->pSocket->errno = EADDRNOTAVAIL;\r
   }\r
   else {\r
     Status = EFI_SUCCESS;\r
 \r
-    //\r
     //  Set the local address\r
-    //\r
     pIpAddress = (struct sockaddr_in *)pSockAddr;\r
     pIpv4Address = (UINT8 *)&pIpAddress->sin_addr.s_addr;\r
     pConfig = &pPort->Context.Ip4.ModeData.ConfigData;\r
@@ -116,14 +101,10 @@ EslIp4LocalAddressSet (
     pConfig->StationAddress.Addr[2] = pIpv4Address[2];\r
     pConfig->StationAddress.Addr[3] = pIpv4Address[3];\r
 \r
-    //\r
     //  Determine if the default address is used\r
-    //\r
     pConfig->UseDefaultAddress = (BOOLEAN)( 0 == pIpAddress->sin_addr.s_addr );\r
 \r
-    //\r
     //  Display the local address\r
-    //\r
     DEBUG (( DEBUG_BIND,\r
               "0x%08x: Port, Local IP4 Address: %d.%d.%d.%d\r\n",\r
               pPort,\r
@@ -132,9 +113,7 @@ EslIp4LocalAddressSet (
               pConfig->StationAddress.Addr[2],\r
               pConfig->StationAddress.Addr[3]));\r
 \r
-    //\r
     //  Set the subnet mask\r
-    //\r
     if ( pConfig->UseDefaultAddress ) {\r
       pConfig->SubnetMask.Addr[0] = 0;\r
       pConfig->SubnetMask.Addr[1] = 0;\r
@@ -148,17 +127,13 @@ EslIp4LocalAddressSet (
       pConfig->SubnetMask.Addr[3] = ( 224 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;\r
     }\r
   }\r
-\r
-  //\r
   //  Return the operation status\r
-  //\r
   DBG_EXIT_STATUS ( Status );\r
   return Status;\r
 }\r
 \r
 \r
-/**\r
-  Get the option value\r
+/** Get the option value.\r
 \r
   This routine handles the IPv4 level options.\r
 \r
@@ -171,7 +146,6 @@ EslIp4LocalAddressSet (
   @param [out] pOptionLength    Buffer to receive the option length\r
 \r
   @retval EFI_SUCCESS - Socket data successfully received\r
-\r
  **/\r
 EFI_STATUS\r
 EslIp4OptionGet (\r
@@ -185,20 +159,14 @@ EslIp4OptionGet (
 \r
   DBG_ENTER ( );\r
 \r
-  //\r
   //  Assume success\r
-  //\r
   pSocket->errno = 0;\r
   Status = EFI_SUCCESS;\r
 \r
-  //\r
   //  Attempt to get the option\r
-  //\r
   switch ( OptionName ) {\r
   default:\r
-    //\r
     //  Option not supported\r
-    //\r
     pSocket->errno = ENOPROTOOPT;\r
     Status = EFI_INVALID_PARAMETER;\r
     break;\r
@@ -208,17 +176,13 @@ EslIp4OptionGet (
     *pOptionLength = sizeof ( pSocket->bIncludeHeader );\r
     break;\r
   }\r
-\r
-  //\r
   //  Return the operation status\r
-  //\r
   DBG_EXIT_STATUS ( Status );\r
   return Status;\r
 }\r
 \r
 \r
-/**\r
-  Set the option value\r
+/** Set the option value.\r
 \r
   This routine handles the IPv4 level options.\r
 \r
@@ -231,7 +195,6 @@ EslIp4OptionGet (
   @param [in] OptionLength    Length of the buffer in bytes\r
 \r
   @retval EFI_SUCCESS - Option successfully set\r
-\r
  **/\r
 EFI_STATUS\r
 EslIp4OptionSet (\r
@@ -242,28 +205,22 @@ EslIp4OptionSet (
   )\r
 {\r
   BOOLEAN bTrueFalse;\r
-  socklen_t LengthInBytes;\r
-  UINT8 * pOptionData;\r
+  //socklen_t LengthInBytes;\r
+  //UINT8 * pOptionData;\r
   EFI_STATUS Status;\r
 \r
   DBG_ENTER ( );\r
 \r
-  //\r
   //  Assume success\r
-  //\r
   pSocket->errno = 0;\r
   Status = EFI_SUCCESS;\r
 \r
-  //\r
   //  Determine if the option protocol matches\r
-  //\r
-  LengthInBytes = 0;\r
-  pOptionData = NULL;\r
+  //LengthInBytes = 0;\r
+  //pOptionData = NULL;\r
   switch ( OptionName ) {\r
   default:\r
-    //\r
     //  Protocol level not supported\r
-    //\r
     DEBUG (( DEBUG_INFO | DEBUG_OPTION, "ERROR - Invalid protocol option\r\n" ));\r
     pSocket->errno = ENOTSUP;\r
     Status = EFI_UNSUPPORTED;\r
@@ -271,31 +228,22 @@ EslIp4OptionSet (
 \r
   case IP_HDRINCL:\r
 \r
-    //\r
     //  Validate the option length\r
-    //\r
     if ( sizeof ( UINT32 ) == OptionLength ) {\r
-      //\r
       //  Restrict the input to TRUE or FALSE\r
-      //\r
       bTrueFalse = TRUE;\r
       if ( 0 == *(UINT32 *)pOptionValue ) {\r
         bTrueFalse = FALSE;\r
       }\r
       pOptionValue = &bTrueFalse;\r
 \r
-      //\r
       //  Set the option value\r
-      //\r
-      pOptionData = (UINT8 *)&pSocket->bIncludeHeader;\r
-      LengthInBytes = sizeof ( pSocket->bIncludeHeader );\r
+      //pOptionData = (UINT8 *)&pSocket->bIncludeHeader;\r
+      //LengthInBytes = sizeof ( pSocket->bIncludeHeader );\r
     }\r
     break;\r
   }\r
-\r
-  //\r
   //  Return the operation status\r
-  //\r
   DBG_EXIT_STATUS ( Status );\r
   return Status;\r
 }\r