[DHCP]
[reactos.git] / reactos / base / services / dhcp / compat.c
index ec132ca..83c9c12 100644 (file)
@@ -32,11 +32,36 @@ u_int32_t arc4random()
 
 
 int inet_aton(const char *cp, struct in_addr *inp)
+/* inet_addr code from ROS, slightly modified. */
 {
-       inp->S_un.S_addr = inet_addr(cp);
-       if (INADDR_NONE == inp->S_un.S_addr)
+       ULONG Octets[4] = {0,0,0,0};
+       ULONG i = 0;
+
+       if(!cp)
                return 0;
 
+       while(*cp)
+       {
+               CHAR c = *cp;
+               cp++;
+
+               if(c == '.')
+               {
+                       i++;
+                       continue;
+               }
+
+               if(c < '0' || c > '9')
+                       return 0;
+
+               Octets[i] *= 10;
+               Octets[i] += (c - '0');
+
+               if(Octets[i] > 255)
+                       return 0;
+               }
+
+       inp->S_un.S_addr = (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
        return 1;
 }