From: Ted Lemon Date: Tue, 6 Jul 1999 17:17:16 +0000 (+0000) Subject: Add a -s flag to specify the broadcast destination IP address. X-Git-Tag: V3-BETA-1-PATCH-0~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3a84e356262d73b45bef3ab3c889e745d2dc553;p=thirdparty%2Fdhcp.git Add a -s flag to specify the broadcast destination IP address. --- diff --git a/server/dhcpd.c b/server/dhcpd.c index 8b7d77067..9ee861482 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -22,7 +22,7 @@ #ifndef lint static char ocopyright[] = -"$Id: dhcpd.c,v 1.70 1999/05/07 17:32:38 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium."; +"$Id: dhcpd.c,v 1.71 1999/07/06 17:17:16 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium."; #endif static char copyright[] = @@ -46,6 +46,8 @@ int server_identifier_matched; u_int16_t local_port; u_int16_t remote_port; +struct in_addr limited_broadcast; + int log_priority; #ifdef DEBUG int log_perror = -1; @@ -74,6 +76,7 @@ int main (argc, argv, envp) int daemon = 1; #endif int quiet = 0; + char *server = (char *)0; /* Initially, log errors to stderr as well as to syslogd. */ #ifdef SYSLOG_4_2 @@ -115,6 +118,10 @@ int main (argc, argv, envp) daemon = 0; #endif log_perror = -1; + } else if (!strcmp (argv [i], "-s")) { + if (++i == argc) + usage (); + server = argv [i]; } else if (!strcmp (argv [i], "-cf")) { if (++i == argc) usage (); @@ -177,6 +184,21 @@ int main (argc, argv, envp) remote_port = htons (ntohs (local_port) + 1); + if (server) { + if (!inet_aton (server, &limited_broadcast)) { + struct hostent *he; + he = gethostbyname (server); + if (he) { + memcpy (&limited_broadcast, + he -> h_addr_list [0], + sizeof limited_broadcast); + } else + limited_broadcast.s_addr = INADDR_BROADCAST; + } + } else { + limited_broadcast.s_addr = INADDR_BROADCAST; + } + /* Get the current time... */ GET_TIME (&cur_time);