summaryrefslogtreecommitdiff
path: root/common/discover.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/discover.c')
-rw-r--r--common/discover.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/common/discover.c b/common/discover.c
index 06b9e2c4..9c8a5ca4 100644
--- a/common/discover.c
+++ b/common/discover.c
@@ -3,39 +3,30 @@
Network input dispatcher... */
/*
- * Copyright (c) 1995-2001 Internet Software Consortium.
- * All rights reserved.
+ * Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Internet Software Consortium nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * Internet Systems Consortium, Inc.
+ * 950 Charter Street
+ * Redwood City, CA 94063
+ * <info@isc.org>
+ * http://www.isc.org/
*
- * This software has been written for the Internet Software Consortium
+ * This software has been written for Internet Systems Consortium
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
- * To learn more about the Internet Software Consortium, see
+ * To learn more about Internet Systems Consortium, see
* ``http://www.isc.org/''. To learn more about Vixie Enterprises,
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
* ``http://www.nominum.com''.
@@ -43,7 +34,7 @@
#ifndef lint
static char copyright[] =
-"$Id: discover.c,v 1.47 2002/06/10 00:12:34 murray Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
+"$Id: discover.c,v 1.48 2005/03/17 20:14:57 dhankins Exp $ Copyright (c) 2004-2005 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -94,7 +85,7 @@ isc_result_t interface_setup ()
dhcp_interface_remove,
0, 0, 0,
sizeof (struct interface_info),
- interface_initialize);
+ interface_initialize, RC_MISC);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register interface object type: %s",
isc_result_totext (status));
@@ -258,10 +249,12 @@ void discover_interfaces (state)
if (!strcmp (tmp -> name, ifp -> ifr_name))
break;
- /* Skip loopback, point-to-point and down interfaces,
- except don't skip down interfaces if we're trying to
- get a list of configurable interfaces. */
- if (((ifr.ifr_flags & IFF_LOOPBACK ||
+ /* Skip non broadcast interfaces (plus loopback and
+ point-to-point in case an OS incorrectly marks them
+ as broadcast). Also skip down interfaces unless we're
+ trying to get a list of configurable interfaces. */
+ if (((!(ifr.ifr_flags & IFF_BROADCAST) ||
+ ifr.ifr_flags & IFF_LOOPBACK ||
ifr.ifr_flags & IFF_POINTOPOINT) && !tmp) ||
(!(ifr.ifr_flags & IFF_UP) &&
state != DISCOVER_UNCONFIGURED))
@@ -399,6 +392,18 @@ void discover_interfaces (state)
if (tmp)
continue;
+ strncpy (ifr.ifr_name, name, IFNAMSIZ);
+
+ /* Skip non broadcast interfaces (plus loopback and
+ * point-to-point in case an OS incorrectly marks them
+ * as broadcast).
+ */
+ if ((ioctl (sock, SIOCGIFFLAGS, &ifr) < 0) ||
+ (!(ifr.ifr_flags & IFF_BROADCAST)) ||
+ (ifr.ifr_flags & IFF_LOOPBACK ) ||
+ (ifr.ifr_flags & IFF_POINTOPOINT))
+ continue;
+
/* Otherwise, allocate one. */
tmp = (struct interface_info *)0;
status = interface_allocate (&tmp, MDL);
@@ -540,8 +545,12 @@ void discover_interfaces (state)
if (tmp -> next)
interface_reference (&next, tmp -> next, MDL);
/* skip interfaces that are running already */
- if (tmp -> flags & INTERFACE_RUNNING)
+ if (tmp -> flags & INTERFACE_RUNNING) {
+ interface_dereference(&tmp, MDL);
+ if(next)
+ interface_reference(&tmp, next, MDL);
continue;
+ }
if ((tmp -> flags & INTERFACE_AUTOMATIC) &&
state == DISCOVER_REQUESTED)
tmp -> flags &= ~(INTERFACE_AUTOMATIC |