diff options
author | Ted Lemon <source@isc.org> | 1999-02-03 19:06:58 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 1999-02-03 19:06:58 +0000 |
commit | 70d7130a0fe5989933458adc77afc9521cea0340 (patch) | |
tree | 2370ec1e7d83a79a52ecabffd3009951a36c7350 /common | |
parent | 4048b50ac73731545fb74bc6f3e3ef18b0a247da (diff) | |
download | isc-dhcp-70d7130a0fe5989933458adc77afc9521cea0340.tar.gz |
Make sure interface structures get ifreqs.
Diffstat (limited to 'common')
-rw-r--r-- | common/dispatch.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/common/dispatch.c b/common/dispatch.c index a2b72209..313fd207 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.47.2.6 1998/12/23 14:14:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.47.2.7 1999/02/03 19:06:58 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -299,11 +299,25 @@ void discover_interfaces (state) if (!strcmp (tmp -> name, name)) break; - /* If we already found the interface with SIOCGIFCONF, - go on to the next. */ - if (tmp) + /* If we found one, and it already has an ifreq + structure, nothing more to do.. */ + if (tmp && tmp -> ifp) continue; + /* Make up an ifreq structure. */ + tif = (struct ifreq *)malloc (sizeof (struct ifreq)); + if (!tif) + error ("no space to remember ifp."); + memset (tif, 0, sizeof (struct ifreq)); + strcpy (tif -> ifr_name, name); + + /* Now, if we just needed the ifreq structure, hook + it in and move on. */ + if (tmp) { + tmp -> ifp = tif; + continue; + } + /* Otherwise, allocate one. */ tmp = ((struct interface_info *) dmalloc (sizeof *tmp, "discover_interfaces")); @@ -313,12 +327,6 @@ void discover_interfaces (state) memset (tmp, 0, sizeof *tmp); strcpy (tmp -> name, name); - /* Mock up an ifreq structure. */ - tif = (struct ifreq *)malloc (sizeof (struct ifreq)); - if (!tif) - error ("no space to remember ifp."); - memset (tif, 0, sizeof (struct ifreq)); - strcpy (tif -> ifr_name, name); tmp -> ifp = tif; tmp -> flags = ir; tmp -> next = interfaces; |