1995-11-29 07:40:04 +00:00
|
|
|
/* socket.c
|
|
|
|
|
|
|
|
BSD socket interface code... */
|
|
|
|
|
|
|
|
/*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
|
|
|
* Copyright (c) 1995-2003 by Internet Software Consortium
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* 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.
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* 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.
|
1995-11-29 07:40:04 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Internet Systems Consortium, Inc.
|
|
|
|
* 950 Charter Street
|
|
|
|
* Redwood City, CA 94063
|
|
|
|
* <info@isc.org>
|
|
|
|
* http://www.isc.org/
|
2000-03-17 04:00:32 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* This software has been written for Internet Systems Consortium
|
2000-03-17 04:00:32 +00:00
|
|
|
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
|
2005-03-17 20:15:29 +00:00
|
|
|
* To learn more about Internet Systems Consortium, see
|
2000-03-17 04:00:32 +00:00
|
|
|
* ``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''.
|
1995-11-29 07:40:04 +00:00
|
|
|
*/
|
|
|
|
|
1997-01-02 12:00:19 +00:00
|
|
|
/* SO_BINDTODEVICE support added by Elliot Poger (poger@leland.stanford.edu).
|
|
|
|
* This sockopt allows a socket to be bound to a particular interface,
|
|
|
|
* thus enabling the use of DHCPD on a multihomed host.
|
|
|
|
* If SO_BINDTODEVICE is defined in your system header files, the use of
|
|
|
|
* this sockopt will be automatically enabled.
|
|
|
|
* I have implemented it under Linux; other systems should be doable also.
|
|
|
|
*/
|
|
|
|
|
1995-11-29 07:40:04 +00:00
|
|
|
#ifndef lint
|
|
|
|
static char copyright[] =
|
2006-07-25 17:41:18 +00:00
|
|
|
"$Id: socket.c,v 1.59 2006/07/25 17:41:18 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
|
1995-11-29 07:40:04 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include "dhcpd.h"
|
|
|
|
|
1996-05-22 07:30:19 +00:00
|
|
|
#ifdef USE_SOCKET_FALLBACK
|
1999-10-24 23:23:41 +00:00
|
|
|
# if !defined (USE_SOCKET_SEND)
|
1996-05-22 07:30:19 +00:00
|
|
|
# define if_register_send if_register_fallback
|
|
|
|
# define send_packet send_fallback
|
1997-02-19 10:51:44 +00:00
|
|
|
# define if_reinitialize_send if_reinitialize_fallback
|
1999-10-24 23:23:41 +00:00
|
|
|
# endif
|
1997-02-19 10:51:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static int once = 0;
|
|
|
|
|
|
|
|
/* Reinitializes the specified interface after an address change. This
|
|
|
|
is not required for packet-filter APIs. */
|
|
|
|
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
|
1997-02-19 10:51:44 +00:00
|
|
|
void if_reinitialize_send (info)
|
|
|
|
struct interface_info *info;
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
#ifndef USE_SOCKET_RECEIVE
|
|
|
|
once = 0;
|
|
|
|
close (info -> wfdesc);
|
|
|
|
#endif
|
|
|
|
if_register_send (info);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_SOCKET_RECEIVE
|
|
|
|
void if_reinitialize_receive (info)
|
|
|
|
struct interface_info *info;
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
once = 0;
|
|
|
|
close (info -> rfdesc);
|
|
|
|
if_register_receive (info);
|
|
|
|
#endif
|
|
|
|
}
|
1996-05-22 07:30:19 +00:00
|
|
|
#endif
|
|
|
|
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_SEND) || \
|
|
|
|
defined (USE_SOCKET_RECEIVE) || \
|
|
|
|
defined (USE_SOCKET_FALLBACK)
|
1996-05-13 00:08:05 +00:00
|
|
|
/* Generic interface registration routine... */
|
1997-02-19 10:51:44 +00:00
|
|
|
int if_register_socket (info)
|
1996-04-11 06:49:21 +00:00
|
|
|
struct interface_info *info;
|
1995-11-29 07:40:04 +00:00
|
|
|
{
|
|
|
|
struct sockaddr_in name;
|
|
|
|
int sock;
|
|
|
|
int flag;
|
1997-01-02 12:00:19 +00:00
|
|
|
|
1999-02-25 23:30:43 +00:00
|
|
|
#if !defined (HAVE_SO_BINDTODEVICE) && !defined (USE_FALLBACK)
|
1996-05-13 00:08:05 +00:00
|
|
|
/* Make sure only one interface is registered. */
|
|
|
|
if (once)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("The standard socket API can only support %s",
|
1998-03-15 20:54:20 +00:00
|
|
|
"hosts with a single network interface.");
|
1997-01-02 12:00:19 +00:00
|
|
|
once = 1;
|
1996-05-22 07:30:19 +00:00
|
|
|
#endif
|
1996-05-13 00:08:05 +00:00
|
|
|
|
2002-06-09 22:17:09 +00:00
|
|
|
memset (&name, 0, sizeof (name));
|
1996-05-13 00:08:05 +00:00
|
|
|
/* Set up the address we're going to bind to. */
|
1995-11-29 07:40:04 +00:00
|
|
|
name.sin_family = AF_INET;
|
1997-02-18 14:32:51 +00:00
|
|
|
name.sin_port = local_port;
|
2000-05-01 23:31:49 +00:00
|
|
|
name.sin_addr = local_address;
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1996-05-22 07:30:19 +00:00
|
|
|
/* Make a socket... */
|
1995-11-29 07:40:04 +00:00
|
|
|
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("Can't create dhcp socket: %m");
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1996-05-13 00:08:05 +00:00
|
|
|
/* Set the REUSEADDR option so that we don't fail to start if
|
|
|
|
we're being restarted. */
|
1995-11-29 07:40:04 +00:00
|
|
|
flag = 1;
|
|
|
|
if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
|
1996-05-16 23:13:59 +00:00
|
|
|
(char *)&flag, sizeof flag) < 0)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("Can't set SO_REUSEADDR option on dhcp socket: %m");
|
1995-11-29 07:40:04 +00:00
|
|
|
|
2000-09-01 23:03:39 +00:00
|
|
|
/* Set the BROADCAST option so that we can broadcast DHCP responses.
|
|
|
|
We shouldn't do this for fallback devices, and we can detect that
|
|
|
|
a device is a fallback because it has no ifp structure. */
|
|
|
|
if (info -> ifp &&
|
|
|
|
(setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
|
|
|
|
(char *)&flag, sizeof flag) < 0))
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("Can't set SO_BROADCAST option on dhcp socket: %m");
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1996-05-13 00:08:05 +00:00
|
|
|
/* Bind the socket to this interface's IP address. */
|
2000-07-20 03:15:00 +00:00
|
|
|
if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0) {
|
|
|
|
log_error ("Can't bind to dhcp address: %m");
|
|
|
|
log_error ("Please make sure there is no other dhcp server");
|
|
|
|
log_error ("running and that there's no entry for dhcp or");
|
|
|
|
log_error ("bootp in /etc/inetd.conf. Also make sure you");
|
|
|
|
log_error ("are not running HP JetAdmin software, which");
|
|
|
|
log_fatal ("includes a bootp server.");
|
|
|
|
}
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1999-02-25 23:30:43 +00:00
|
|
|
#if defined (HAVE_SO_BINDTODEVICE)
|
1997-01-02 12:00:19 +00:00
|
|
|
/* Bind this socket to this interface. */
|
1999-02-14 19:04:05 +00:00
|
|
|
if (info -> ifp &&
|
|
|
|
setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE,
|
1997-02-19 10:51:44 +00:00
|
|
|
(char *)(info -> ifp), sizeof *(info -> ifp)) < 0) {
|
1999-05-06 20:21:39 +00:00
|
|
|
log_fatal ("setsockopt: SO_BINDTODEVICE: %m");
|
1997-01-02 12:00:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-25 17:41:18 +00:00
|
|
|
/* IP_BROADCAST_IF instructs the kernel which interface to send
|
|
|
|
* IP packets whose destination address is 255.255.255.255. These
|
|
|
|
* will be treated as subnet broadcasts on the interface identified
|
|
|
|
* by ip address (info -> primary_address). This is only known to
|
|
|
|
* be defined in SCO system headers, and may not be defined in all
|
|
|
|
* releases.
|
|
|
|
*/
|
|
|
|
#if defined(SCO) && defined(IP_BROADCAST_IF)
|
|
|
|
if (setsockopt (sock, IPPROTO_IP, IP_BROADCAST_IF,
|
|
|
|
&info -> primary_address,
|
|
|
|
sizeof (info -> primary_address)) < 0)
|
|
|
|
log_fatal ("Can't set IP_BROADCAST_IF on dhcp socket: %m");
|
|
|
|
#endif
|
|
|
|
|
1996-05-13 00:08:05 +00:00
|
|
|
return sock;
|
1995-11-29 07:40:04 +00:00
|
|
|
}
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif /* USE_SOCKET_SEND || USE_SOCKET_RECEIVE || USE_SOCKET_FALLBACK */
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
|
1997-02-19 10:51:44 +00:00
|
|
|
void if_register_send (info)
|
1996-04-11 06:49:21 +00:00
|
|
|
struct interface_info *info;
|
1995-11-29 07:40:04 +00:00
|
|
|
{
|
1996-05-13 00:08:05 +00:00
|
|
|
#ifndef USE_SOCKET_RECEIVE
|
1997-02-19 10:51:44 +00:00
|
|
|
info -> wfdesc = if_register_socket (info);
|
1999-09-23 01:15:25 +00:00
|
|
|
#if defined (USE_SOCKET_FALLBACK)
|
|
|
|
/* Fallback only registers for send, but may need to receive as
|
|
|
|
well. */
|
|
|
|
info -> rfdesc = info -> wfdesc;
|
|
|
|
#endif
|
1996-05-13 00:08:05 +00:00
|
|
|
#else
|
|
|
|
info -> wfdesc = info -> rfdesc;
|
|
|
|
#endif
|
1997-10-20 21:47:15 +00:00
|
|
|
if (!quiet_interface_discovery)
|
1999-02-25 23:30:43 +00:00
|
|
|
log_info ("Sending on Socket/%s%s%s",
|
1997-10-20 21:47:15 +00:00
|
|
|
info -> name,
|
1999-02-25 23:30:43 +00:00
|
|
|
(info -> shared_network ? "/" : ""),
|
1997-10-20 21:47:15 +00:00
|
|
|
(info -> shared_network ?
|
1999-02-25 23:30:43 +00:00
|
|
|
info -> shared_network -> name : ""));
|
1995-11-29 07:40:04 +00:00
|
|
|
}
|
2000-03-06 19:39:54 +00:00
|
|
|
|
2000-09-12 20:23:54 +00:00
|
|
|
#if defined (USE_SOCKET_SEND)
|
2000-03-06 19:39:54 +00:00
|
|
|
void if_deregister_send (info)
|
|
|
|
struct interface_info *info;
|
|
|
|
{
|
|
|
|
#ifndef USE_SOCKET_RECEIVE
|
|
|
|
close (info -> wfdesc);
|
|
|
|
#endif
|
|
|
|
info -> wfdesc = -1;
|
|
|
|
|
|
|
|
if (!quiet_interface_discovery)
|
|
|
|
log_info ("Disabling output on Socket/%s%s%s",
|
|
|
|
info -> name,
|
|
|
|
(info -> shared_network ? "/" : ""),
|
|
|
|
(info -> shared_network ?
|
|
|
|
info -> shared_network -> name : ""));
|
|
|
|
}
|
2000-09-12 20:23:54 +00:00
|
|
|
#endif /* USE_SOCKET_SEND */
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
|
1995-11-29 07:40:04 +00:00
|
|
|
|
1996-05-13 00:08:05 +00:00
|
|
|
#ifdef USE_SOCKET_RECEIVE
|
1997-02-19 10:51:44 +00:00
|
|
|
void if_register_receive (info)
|
1996-05-13 00:08:05 +00:00
|
|
|
struct interface_info *info;
|
|
|
|
{
|
|
|
|
/* If we're using the socket API for sending and receiving,
|
|
|
|
we don't need to register this interface twice. */
|
1997-02-19 10:51:44 +00:00
|
|
|
info -> rfdesc = if_register_socket (info);
|
1997-10-20 21:47:15 +00:00
|
|
|
if (!quiet_interface_discovery)
|
1999-02-25 23:30:43 +00:00
|
|
|
log_info ("Listening on Socket/%s%s%s",
|
1997-10-20 21:47:15 +00:00
|
|
|
info -> name,
|
1999-02-25 23:30:43 +00:00
|
|
|
(info -> shared_network ? "/" : ""),
|
1997-10-20 21:47:15 +00:00
|
|
|
(info -> shared_network ?
|
1999-02-25 23:30:43 +00:00
|
|
|
info -> shared_network -> name : ""));
|
1996-05-13 00:08:05 +00:00
|
|
|
}
|
2000-03-06 19:39:54 +00:00
|
|
|
|
|
|
|
void if_deregister_receive (info)
|
|
|
|
struct interface_info *info;
|
|
|
|
{
|
|
|
|
close (info -> rfdesc);
|
|
|
|
info -> rfdesc = -1;
|
|
|
|
|
|
|
|
if (!quiet_interface_discovery)
|
|
|
|
log_info ("Disabling input on Socket/%s%s%s",
|
|
|
|
info -> name,
|
|
|
|
(info -> shared_network ? "/" : ""),
|
|
|
|
(info -> shared_network ?
|
|
|
|
info -> shared_network -> name : ""));
|
2000-04-06 23:56:01 +00:00
|
|
|
}
|
1996-05-13 00:08:05 +00:00
|
|
|
#endif /* USE_SOCKET_RECEIVE */
|
|
|
|
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
|
1997-06-08 03:18:09 +00:00
|
|
|
ssize_t send_packet (interface, packet, raw, len, from, to, hto)
|
1996-05-13 00:08:05 +00:00
|
|
|
struct interface_info *interface;
|
1996-03-16 17:50:30 +00:00
|
|
|
struct packet *packet;
|
|
|
|
struct dhcp_packet *raw;
|
|
|
|
size_t len;
|
1996-05-22 07:30:19 +00:00
|
|
|
struct in_addr from;
|
1996-04-11 06:49:21 +00:00
|
|
|
struct sockaddr_in *to;
|
1996-05-13 00:08:05 +00:00
|
|
|
struct hardware *hto;
|
1996-03-16 17:50:30 +00:00
|
|
|
{
|
1997-03-29 00:06:07 +00:00
|
|
|
int result;
|
|
|
|
#ifdef IGNORE_HOSTUNREACH
|
|
|
|
int retry = 0;
|
|
|
|
do {
|
|
|
|
#endif
|
|
|
|
result = sendto (interface -> wfdesc, (char *)raw, len, 0,
|
|
|
|
(struct sockaddr *)to, sizeof *to);
|
|
|
|
#ifdef IGNORE_HOSTUNREACH
|
1998-03-15 20:54:20 +00:00
|
|
|
} while (to -> sin_addr.s_addr == htonl (INADDR_BROADCAST) &&
|
1997-03-29 00:06:07 +00:00
|
|
|
result < 0 &&
|
|
|
|
(errno == EHOSTUNREACH ||
|
|
|
|
errno == ECONNREFUSED) &&
|
|
|
|
retry++ < 10);
|
|
|
|
#endif
|
1999-02-25 23:30:43 +00:00
|
|
|
if (result < 0) {
|
1999-03-16 06:37:55 +00:00
|
|
|
log_error ("send_packet: %m");
|
1999-02-25 23:30:43 +00:00
|
|
|
if (errno == ENETUNREACH)
|
1999-10-24 23:23:41 +00:00
|
|
|
log_error ("send_packet: please consult README file%s",
|
|
|
|
" regarding broadcast address.");
|
1999-02-25 23:30:43 +00:00
|
|
|
}
|
1997-03-29 01:26:08 +00:00
|
|
|
return result;
|
1996-03-16 17:50:30 +00:00
|
|
|
}
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
|
1996-03-16 17:50:30 +00:00
|
|
|
|
1996-04-11 06:49:21 +00:00
|
|
|
#ifdef USE_SOCKET_RECEIVE
|
1997-06-08 03:18:09 +00:00
|
|
|
ssize_t receive_packet (interface, buf, len, from, hfrom)
|
1996-05-13 00:08:05 +00:00
|
|
|
struct interface_info *interface;
|
|
|
|
unsigned char *buf;
|
|
|
|
size_t len;
|
|
|
|
struct sockaddr_in *from;
|
|
|
|
struct hardware *hfrom;
|
1996-03-16 17:50:30 +00:00
|
|
|
{
|
2000-02-03 03:43:51 +00:00
|
|
|
SOCKLEN_T flen = sizeof *from;
|
1997-03-29 00:06:07 +00:00
|
|
|
int result;
|
1996-05-13 00:08:05 +00:00
|
|
|
|
1997-03-29 00:06:07 +00:00
|
|
|
#ifdef IGNORE_HOSTUNREACH
|
|
|
|
int retry = 0;
|
|
|
|
do {
|
|
|
|
#endif
|
1999-10-24 17:17:51 +00:00
|
|
|
result = recvfrom (interface -> rfdesc, (char *)buf, len, 0,
|
1997-03-29 00:06:07 +00:00
|
|
|
(struct sockaddr *)from, &flen);
|
|
|
|
#ifdef IGNORE_HOSTUNREACH
|
|
|
|
} while (result < 0 &&
|
|
|
|
(errno == EHOSTUNREACH ||
|
|
|
|
errno == ECONNREFUSED) &&
|
|
|
|
retry++ < 10);
|
|
|
|
#endif
|
1997-03-29 01:26:08 +00:00
|
|
|
return result;
|
1996-04-11 06:49:21 +00:00
|
|
|
}
|
|
|
|
#endif /* USE_SOCKET_RECEIVE */
|
1996-06-12 23:52:38 +00:00
|
|
|
|
1999-05-27 14:18:27 +00:00
|
|
|
#if defined (USE_SOCKET_FALLBACK)
|
1996-06-12 23:52:38 +00:00
|
|
|
/* This just reads in a packet and silently discards it. */
|
|
|
|
|
1999-09-08 01:44:08 +00:00
|
|
|
isc_result_t fallback_discard (object)
|
1999-09-09 23:53:29 +00:00
|
|
|
omapi_object_t *object;
|
1996-06-12 23:52:38 +00:00
|
|
|
{
|
|
|
|
char buf [1540];
|
|
|
|
struct sockaddr_in from;
|
2000-02-03 03:43:51 +00:00
|
|
|
SOCKLEN_T flen = sizeof from;
|
1997-03-06 06:55:53 +00:00
|
|
|
int status;
|
1999-09-08 01:44:08 +00:00
|
|
|
struct interface_info *interface;
|
|
|
|
|
|
|
|
if (object -> type != dhcp_type_interface)
|
|
|
|
return ISC_R_INVALIDARG;
|
|
|
|
interface = (struct interface_info *)object;
|
1996-06-12 23:52:38 +00:00
|
|
|
|
1997-03-06 06:55:53 +00:00
|
|
|
status = recvfrom (interface -> wfdesc, buf, sizeof buf, 0,
|
|
|
|
(struct sockaddr *)&from, &flen);
|
2002-06-09 22:19:37 +00:00
|
|
|
#if defined (DEBUG)
|
|
|
|
/* Only report fallback discard errors if we're debugging. */
|
1999-09-08 01:44:08 +00:00
|
|
|
if (status < 0) {
|
1999-02-24 17:56:53 +00:00
|
|
|
log_error ("fallback_discard: %m");
|
1999-09-08 01:44:08 +00:00
|
|
|
return ISC_R_UNEXPECTED;
|
|
|
|
}
|
2002-06-09 22:19:37 +00:00
|
|
|
#endif
|
1999-09-08 01:44:08 +00:00
|
|
|
return ISC_R_SUCCESS;
|
1996-06-12 23:52:38 +00:00
|
|
|
}
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif /* USE_SOCKET_FALLBACK */
|
1999-02-14 19:04:05 +00:00
|
|
|
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_SEND)
|
1999-03-13 18:56:47 +00:00
|
|
|
int can_unicast_without_arp (ip)
|
|
|
|
struct interface_info *ip;
|
1999-02-14 19:04:05 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-13 18:56:47 +00:00
|
|
|
int can_receive_unicast_unconfigured (ip)
|
|
|
|
struct interface_info *ip;
|
1999-03-13 18:53:15 +00:00
|
|
|
{
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (SOCKET_CAN_RECEIVE_UNICAST_UNCONFIGURED)
|
|
|
|
return 1;
|
|
|
|
#else
|
1999-03-13 18:53:15 +00:00
|
|
|
return 0;
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif
|
1999-03-13 18:53:15 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 23:03:39 +00:00
|
|
|
int supports_multiple_interfaces (ip)
|
|
|
|
struct interface_info *ip;
|
|
|
|
{
|
|
|
|
#if defined (SO_BINDTODEVICE)
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-02-14 19:04:05 +00:00
|
|
|
/* If we have SO_BINDTODEVICE, set up a fallback interface; otherwise,
|
|
|
|
do not. */
|
|
|
|
|
|
|
|
void maybe_setup_fallback ()
|
|
|
|
{
|
1999-10-24 23:23:41 +00:00
|
|
|
#if defined (USE_SOCKET_FALLBACK)
|
1999-09-08 01:44:08 +00:00
|
|
|
isc_result_t status;
|
2000-09-11 17:39:14 +00:00
|
|
|
struct interface_info *fbi = (struct interface_info *)0;
|
|
|
|
if (setup_fallback (&fbi, MDL)) {
|
1999-02-14 19:04:05 +00:00
|
|
|
fbi -> wfdesc = if_register_socket (fbi);
|
2000-09-30 01:24:55 +00:00
|
|
|
fbi -> rfdesc = fbi -> wfdesc;
|
|
|
|
log_info ("Sending on Socket/%s%s%s",
|
|
|
|
fbi -> name,
|
|
|
|
(fbi -> shared_network ? "/" : ""),
|
|
|
|
(fbi -> shared_network ?
|
|
|
|
fbi -> shared_network -> name : ""));
|
|
|
|
|
2000-01-02 22:21:23 +00:00
|
|
|
status = omapi_register_io_object ((omapi_object_t *)fbi,
|
1999-09-08 01:44:08 +00:00
|
|
|
if_readsocket, 0,
|
|
|
|
fallback_discard, 0, 0);
|
|
|
|
if (status != ISC_R_SUCCESS)
|
|
|
|
log_fatal ("Can't register I/O handle for %s: %s",
|
|
|
|
fbi -> name, isc_result_totext (status));
|
2000-09-11 17:39:14 +00:00
|
|
|
interface_dereference (&fbi, MDL);
|
1999-02-14 19:04:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
1999-10-24 23:23:41 +00:00
|
|
|
#endif /* USE_SOCKET_SEND */
|