#ifndef lint
static char copyright[] =
-"$Id: dispatch.c,v 1.47.2.9 1999/02/05 20:23:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dispatch.c,v 1.47.2.10 1999/02/13 19:17:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
struct shared_network *share;
struct sockaddr_in foo;
int ir;
+ struct ifreq *tif;
#ifdef ALIAS_NAMES_PERMUTED
char *s;
#endif
for (i = 0; i < ic.ifc_len;) {
struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
#ifdef HAVE_SA_LEN
- if (ifp -> ifr_addr.sa_len)
+ if (ifp -> ifr_addr.sa_len > sizeof (struct sockaddr))
i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
else
#endif
found, keep a pointer to ifreq structure in
which we found it. */
if (!tmp -> ifp) {
- struct ifreq *tif;
#ifdef HAVE_SA_LEN
int len = ((sizeof ifp -> ifr_name) +
ifp -> ifr_addr.sa_len);
if (state == DISCOVER_UNCONFIGURED) {
FILE *proc_dev;
char buffer [256];
- struct ifreq *tif;
int skip = 2;
proc_dev = fopen (PROCDEV_DEVICE, "r");
if (!strcmp (tmp -> name, name))
break;
- /* If we found one, and it already has an ifreq
- structure, nothing more to do.. */
- if (tmp && tmp -> ifp)
+ /* If we found one, nothing more to do.. */
+ if (tmp)
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"));
memset (tmp, 0, sizeof *tmp);
strcpy (tmp -> name, name);
- tmp -> ifp = tif;
tmp -> flags = ir;
tmp -> next = interfaces;
interfaces = tmp;
struct sockaddr sa;
int b, sk;
+ if (!tmp -> ifp) {
+ /* 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, tmp -> name);
+ tmp -> ifp = tif;
+ }
+
/* Read the hardware address from this interface. */
ifr = *tmp -> ifp;
if (ioctl (sock, SIOCGIFHWADDR, &ifr) < 0)