]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Allow IP addresses to be specified on the command line; don't use herror().
authorTed Lemon <source@isc.org>
Sat, 29 Mar 1997 03:30:44 +0000 (03:30 +0000)
committerTed Lemon <source@isc.org>
Sat, 29 Mar 1997 03:30:44 +0000 (03:30 +0000)
relay/dhcrelay.c

index 25483eeb51a9806a62335498da278b806fa4394b..6c63fb04aae341eec57cbb73a8388699cda21091 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcrelay.c,v 1.5 1997/03/06 06:58:37 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcrelay.c,v 1.6 1997/03/29 03:30:44 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -117,17 +117,26 @@ int main (argc, argv, envp)
                    usage ();
                } else {
                        struct hostent *he;
-                       he = gethostbyname (argv [i]);
-                       if (!he) {
-                               herror (argv [i]);
+                       struct in_addr ia, *iap = (struct in_addr *)0;
+                       if (inet_aton (argv [i], &ia)) {
+                               iap = &ia;
                        } else {
+                               he = gethostbyname (argv [i]);
+                               if (!he) {
+                                       warn ("%s: host unknown", argv [i]);
+                               } else {
+                                       iap = ((struct in_addr *)
+                                              he -> h_addr_list [0]);
+                               }
+                       }
+                       if (iap) {
                                sp = (struct server_list *)malloc (sizeof *sp);
                                if (!sp)
                                        error ("no memory for server.\n");
                                sp -> next = servers;
                                servers = sp;
                                memcpy (&sp -> to.sin_addr,
-                                       he -> h_addr_list [0], he -> h_length);
+                                       iap, sizeof *iap);
                        }
                }
        }