]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.c
Update modules to show real dependencies on the BaseMemoryLib and MemoryAllocationLib
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Option.c
index 0f66fe5433676df8ff7d13da0bbfe01cf985bcd0..19157a7506d19619cf269f33b76d2dea62bcd55b 100644 (file)
@@ -22,6 +22,134 @@ CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = {
 };\r
 \r
 \r
+/**\r
+  Check whether two ascii strings are equel, ignore the case.\r
+\r
+  @param  Str1                   The first ascii string\r
+  @param  Str2                   The second ascii string\r
+\r
+  @retval TRUE                   Two strings are equal when case is ignored.\r
+  @retval FALSE                  Two string are not equal.\r
+\r
+**/\r
+BOOLEAN\r
+NetStringEqualNoCase (\r
+  IN UINT8                 *Str1,\r
+  IN UINT8                 *Str2\r
+  )\r
+{\r
+  UINT8                     Ch1;\r
+  UINT8                     Ch2;\r
+\r
+  ASSERT ((Str1 != NULL) && (Str2 != NULL));\r
+\r
+  for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {\r
+    Ch1 = *Str1;\r
+    Ch2 = *Str2;\r
+\r
+    //\r
+    // Convert them to lower case then compare two\r
+    //\r
+    if (('A' <= Ch1) && (Ch1 <= 'Z')) {\r
+      Ch1 += 'a' - 'A';\r
+    }\r
+\r
+    if (('A' <= Ch2) && (Ch2 <= 'Z')) {\r
+      Ch2 += 'a' - 'A';\r
+    }\r
+\r
+    if (Ch1 != Ch2) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return (BOOLEAN) (*Str1 == *Str2);\r
+}\r
+\r
+\r
+/**\r
+  Convert a string to a UINT32 number.\r
+\r
+  @param  Str                    The string to convert from\r
+\r
+  @return The number get from the string\r
+\r
+**/\r
+UINT32\r
+NetStringToU32 (\r
+  IN UINT8                 *Str\r
+  )\r
+{\r
+  UINT32                    Num;\r
+\r
+  ASSERT (Str != NULL);\r
+\r
+  Num = 0;\r
+\r
+  for (; NET_IS_DIGIT (*Str); Str++) {\r
+    Num = Num * 10 + (*Str - '0');\r
+  }\r
+\r
+  return Num;\r
+}\r
+\r
+\r
+/**\r
+  Convert a string of the format "192.168.0.1" to an IP address.\r
+\r
+  @param  Str                    The string representation of IP\r
+  @param  Ip                     The varible to get IP.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The IP string is invalid.\r
+  @retval EFI_SUCCESS            The IP is parsed into the Ip\r
+\r
+**/\r
+EFI_STATUS\r
+NetStringToIp (\r
+  IN     UINT8                 *Str,\r
+     OUT IP4_ADDR              *Ip\r
+  )\r
+{\r
+  UINT32                    Byte;\r
+  UINT32                    Addr;\r
+  UINTN                     Index;\r
+\r
+  *Ip  = 0;\r
+  Addr = 0;\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    if (!NET_IS_DIGIT (*Str)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    Byte = NetStringToU32 (Str);\r
+\r
+    if (Byte > 255) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    Addr = (Addr << 8) | Byte;\r
+\r
+    //\r
+    // Skip all the digitals and check whether the sepeator is the dot\r
+    //\r
+    while (NET_IS_DIGIT (*Str)) {\r
+      Str++;\r
+    }\r
+\r
+    if ((Index < 3) && (*Str != '.')) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    Str++;\r
+  }\r
+\r
+  *Ip = Addr;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
 /**\r
   Go through the packet to fill the Options array with the start\r
   addresses of each MTFTP option name/value pair.\r
@@ -171,134 +299,6 @@ Mtftp4ExtractOptions (
 }\r
 \r
 \r
-/**\r
-  Check whether two ascii strings are equel, ignore the case.\r
-\r
-  @param  Str1                   The first ascii string\r
-  @param  Str2                   The second ascii string\r
-\r
-  @retval TRUE                   Two strings are equal when case is ignored.\r
-  @retval FALSE                  Two string are not equal.\r
-\r
-**/\r
-BOOLEAN\r
-NetStringEqualNoCase (\r
-  IN UINT8                 *Str1,\r
-  IN UINT8                 *Str2\r
-  )\r
-{\r
-  UINT8                     Ch1;\r
-  UINT8                     Ch2;\r
-\r
-  ASSERT ((Str1 != NULL) && (Str2 != NULL));\r
-\r
-  for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) {\r
-    Ch1 = *Str1;\r
-    Ch2 = *Str2;\r
-\r
-    //\r
-    // Convert them to lower case then compare two\r
-    //\r
-    if (('A' <= Ch1) && (Ch1 <= 'Z')) {\r
-      Ch1 += 'a' - 'A';\r
-    }\r
-\r
-    if (('A' <= Ch2) && (Ch2 <= 'Z')) {\r
-      Ch2 += 'a' - 'A';\r
-    }\r
-\r
-    if (Ch1 != Ch2) {\r
-      return FALSE;\r
-    }\r
-  }\r
-\r
-  return (BOOLEAN) (*Str1 == *Str2);\r
-}\r
-\r
-\r
-/**\r
-  Convert a string to a UINT32 number.\r
-\r
-  @param  Str                    The string to convert from\r
-\r
-  @return The number get from the string\r
-\r
-**/\r
-UINT32\r
-NetStringToU32 (\r
-  IN UINT8                 *Str\r
-  )\r
-{\r
-  UINT32                    Num;\r
-\r
-  ASSERT (Str != NULL);\r
-\r
-  Num = 0;\r
-\r
-  for (; NET_IS_DIGIT (*Str); Str++) {\r
-    Num = Num * 10 + (*Str - '0');\r
-  }\r
-\r
-  return Num;\r
-}\r
-\r
-\r
-/**\r
-  Convert a string of the format "192.168.0.1" to an IP address.\r
-\r
-  @param  Str                    The string representation of IP\r
-  @param  Ip                     The varible to get IP.\r
-\r
-  @retval EFI_INVALID_PARAMETER  The IP string is invalid.\r
-  @retval EFI_SUCCESS            The IP is parsed into the Ip\r
-\r
-**/\r
-EFI_STATUS\r
-NetStringToIp (\r
-  IN     UINT8                 *Str,\r
-     OUT IP4_ADDR              *Ip\r
-  )\r
-{\r
-  UINT32                    Byte;\r
-  UINT32                    Addr;\r
-  UINTN                     Index;\r
-\r
-  *Ip  = 0;\r
-  Addr = 0;\r
-\r
-  for (Index = 0; Index < 4; Index++) {\r
-    if (!NET_IS_DIGIT (*Str)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    Byte = NetStringToU32 (Str);\r
-\r
-    if (Byte > 255) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    Addr = (Addr << 8) | Byte;\r
-\r
-    //\r
-    // Skip all the digitals and check whether the sepeator is the dot\r
-    //\r
-    while (NET_IS_DIGIT (*Str)) {\r
-      Str++;\r
-    }\r
-\r
-    if ((Index < 3) && (*Str != '.')) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    Str++;\r
-  }\r
-\r
-  *Ip = Addr;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
 /**\r
   Parse the MTFTP multicast option.\r
 \r