]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Make sure interface structures get ifreqs.
authorTed Lemon <source@isc.org>
Wed, 3 Feb 1999 19:06:58 +0000 (19:06 +0000)
committerTed Lemon <source@isc.org>
Wed, 3 Feb 1999 19:06:58 +0000 (19:06 +0000)
common/dispatch.c

index a2b72209c3d2d0d294d17a151dd2693702aa77d1..313fd2078e50caa4b8f8776d8d44dd1e1de4b556 100644 (file)
@@ -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;