diff options
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/Makefile | 4 | ||||
-rw-r--r-- | sbin/dhclient/bpf.c | 19 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 58 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 4 | ||||
-rw-r--r-- | sbin/dhclient/osdep.h | 77 | ||||
-rw-r--r-- | sbin/dhclient/socket.c | 144 |
6 files changed, 8 insertions, 298 deletions
diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile index dbe268154f7..1f149bab1e3 100644 --- a/sbin/dhclient/Makefile +++ b/sbin/dhclient/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2004/02/04 12:16:56 henning Exp $ +# $OpenBSD: Makefile,v 1.4 2004/02/23 18:21:15 henning Exp $ # # Copyright (c) 1996, 1997 The Internet Software Consortium. # All rights reserved. @@ -34,7 +34,7 @@ SRCS= dhclient.c clparse.c \ alloc.c dispatch.c hash.c memory.c print.c bpf.c icmp.c options.c \ - tree.c conflex.c errwarn.c inet.c packet.c socket.c convert.c \ + tree.c conflex.c errwarn.c inet.c packet.c convert.c \ ethernet.c tables.c parse.c PROG= dhclient diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index aacddb8291e..df1f8350591 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.5 2004/02/07 17:59:22 henning Exp $ */ +/* $OpenBSD: bpf.c,v 1.6 2004/02/23 18:21:15 henning Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -223,10 +223,6 @@ send_packet(struct interface_info *interface, struct packet *packet, struct iovec iov[2]; int result; - if (!strcmp(interface->name, "fallback")) - return (send_fallback(interface, packet, raw, - len, from, to, hto)); - /* Assemble the headers... */ assemble_hw_header(interface, buf, &bufp, hto); assemble_udp_ip_header(interface, buf, &bufp, from.s_addr, @@ -369,16 +365,3 @@ can_receive_unicast_unconfigured(struct interface_info *ip) { return (1); } - -void -maybe_setup_fallback(void) -{ - struct interface_info *fbi; - - fbi = setup_fallback(); - if (fbi) { - if_register_fallback(fbi); - add_protocol("fallback", fallback_interface->wfdesc, - fallback_discard, fallback_interface); - } -} diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 8c89fe191ca..cda2ef0380f 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.5 2004/02/10 13:12:48 henning Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.6 2004/02/23 18:21:15 henning Exp $ */ /* Definitions for dhcpd... */ @@ -612,76 +612,20 @@ void dump_raw(unsigned char *, int); void dump_packet(struct packet *); void hash_dump(struct hash_table *); -/* socket.c */ -#if defined(USE_SOCKET_SEND) || defined(USE_SOCKET_RECEIVE) \ - || defined(USE_SOCKET_FALLBACK) -int if_register_socket(struct interface_info *); -#endif - -#if defined(USE_SOCKET_FALLBACK) && !defined(USE_SOCKET_SEND) -void if_reinitialize_fallback(struct interface_info *); -void if_register_fallback(struct interface_info *); -ssize_t send_fallback(struct interface_info *, - struct packet *, struct dhcp_packet *, size_t, struct in_addr, - struct sockaddr_in *, struct hardware *); -#endif - -#ifdef USE_SOCKET_SEND -void if_reinitialize_send(struct interface_info *); -void if_register_send(struct interface_info *); -ssize_t send_packet(struct interface_info *, - struct packet *, struct dhcp_packet *, size_t, struct in_addr, - struct sockaddr_in *, struct hardware *); -#endif -#ifdef USE_SOCKET_FALLBACK -void fallback_discard(struct protocol *); -#endif -#ifdef USE_SOCKET_RECEIVE -void if_reinitialize_receive(struct interface_info *); -void if_register_receive(struct interface_info *); -ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, - struct sockaddr_in *, struct hardware *); -#endif -#ifdef USE_SOCKET_SEND -int can_unicast_without_arp(void); -int can_receive_unicast_unconfigured(struct interface_info *); -void maybe_setup_fallback(void); -#endif - /* bpf.c */ -#if defined(USE_BPF_SEND) || defined(USE_BPF_RECEIVE) int if_register_bpf(struct interface_info *); -#endif -#ifdef USE_BPF_SEND void if_reinitialize_send(struct interface_info *); void if_register_send(struct interface_info *); ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *); -#endif -#ifdef USE_BPF_RECEIVE void if_reinitialize_receive(struct interface_info *); void if_register_receive(struct interface_info *); ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, struct sockaddr_in *, struct hardware *); -#endif -#ifdef USE_BPF_SEND -int can_unicast_without_arp(void); -int can_receive_unicast_unconfigured(struct interface_info *); -void maybe_setup_fallback(void); -#endif - -/* raw.c */ -#ifdef USE_RAW_SEND -void if_reinitialize_send(struct interface_info *); -void if_register_send(struct interface_info *); -ssize_t send_packet(struct interface_info *, - struct packet *, struct dhcp_packet *, size_t, struct in_addr, - struct sockaddr_in *, struct hardware *); int can_unicast_without_arp(void); int can_receive_unicast_unconfigured(struct interface_info *); void maybe_setup_fallback(void); -#endif /* dispatch.c */ extern struct interface_info *interfaces, diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 8934ca12055..97d4b3835aa 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.7 2004/02/10 13:12:48 henning Exp $ */ +/* $OpenBSD: dispatch.c,v 1.8 2004/02/23 18:21:15 henning Exp $ */ /* Network input dispatcher... */ @@ -288,8 +288,6 @@ discover_interfaces(int state) add_protocol(tmp->name, tmp->rfdesc, got_one, tmp); freeifaddrs(ifap); - - maybe_setup_fallback(); } struct interface_info * diff --git a/sbin/dhclient/osdep.h b/sbin/dhclient/osdep.h index 99f51896160..0b95af63403 100644 --- a/sbin/dhclient/osdep.h +++ b/sbin/dhclient/osdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: osdep.h,v 1.6 2004/02/08 22:34:19 naddy Exp $ */ +/* $OpenBSD: osdep.h,v 1.7 2004/02/23 18:21:15 henning Exp $ */ /* Operating system dependencies... */ @@ -36,18 +36,6 @@ * under a contract with Vixie Laboratories. */ -#if !defined (USE_SOCKETS) && \ - !defined (USE_SOCKET_SEND) && \ - !defined (USE_SOCKET_RECEIVE) && \ - !defined (USE_RAW_SOCKETS) && \ - !defined (USE_RAW_SEND) && \ - !defined (USE_SOCKET_RECEIVE) && \ - !defined (USE_BPF) && \ - !defined (USE_BPF_SEND) && \ - !defined (USE_BPF_RECEIVE) -# define USE_DEFAULT_NETWORK -#endif - #include <syslog.h> #include <sys/types.h> #include <string.h> @@ -84,8 +72,6 @@ extern int h_errno; #define HAVE_SA_LEN #define HAVE_MKSTEMP -#define USE_BPF - #if defined(__alpha__) || (defined(__sparc64__) && defined(__arch64__)) #define PTRSIZE_64BIT #endif @@ -94,65 +80,8 @@ extern int h_errno; # define TIME_MAX 2147483647 #endif -/* Porting:: - - If you add a new network API, and have it set up so that it can be - used for sending or receiving, but doesn't have to be used for both, - then set up an ifdef like the ones below: */ - -#ifdef USE_SOCKETS -# define USE_SOCKET_SEND -# define USE_SOCKET_RECEIVE -#endif - -#ifdef USE_RAW_SOCKETS -# define USE_RAW_SEND -# define USE_SOCKET_RECEIVE -#endif - -#ifdef USE_BPF -# define USE_BPF_SEND -# define USE_BPF_RECEIVE -#endif - -/* Porting:: - - If you add support for sending packets directly out an interface, - and your support does not do ARP or routing, you must use a fallback - mechanism to deal with packets that need to be sent to routers. - Currently, all low-level packet interfaces use BSD sockets as a - fallback. */ - -#if defined(USE_BPF_SEND) || defined(USE_NIT_SEND) || \ - defined(USE_DLPI_SEND) || defined(USE_UPF_SEND) || defined(USE_LPF_SEND) -# define USE_SOCKET_FALLBACK -# define USE_FALLBACK -#endif - -/* Porting:: - - If you add support for sending packets directly out an interface - and need to be able to assemble packets, add the USE_XXX_SEND - definition for your interface to the list tested below. */ - -#if defined(USE_RAW_SEND) || defined(USE_BPF_SEND) || \ - defined(USE_NIT_SEND) || defined(USE_UPF_SEND) || \ - defined(USE_DLPI_SEND) || defined(USE_LPF_SEND) -# define PACKET_ASSEMBLY -#endif - -/* Porting:: - - If you add support for receiving packets directly from an interface - and need to be able to decode raw packets, add the USE_XXX_RECEIVE - definition for your interface to the list tested below. */ - -#if defined(USE_RAW_RECEIVE) || defined(USE_BPF_SEND) || \ - defined(USE_NIT_RECEIVE) || defined(USE_UPF_RECEIVE) || \ - defined(USE_DLPI_RECEIVE) || defined(USE_LPF_SEND) || \ - (defined(USE_SOCKET_SEND) && defined(SO_BINDTODEVICE)) -# define PACKET_DECODING -#endif +#define PACKET_ASSEMBLY +#define PACKET_DECODING /* jmp_buf is assumed to be a struct unless otherwise defined in the system header. */ diff --git a/sbin/dhclient/socket.c b/sbin/dhclient/socket.c deleted file mode 100644 index 1e4766b3187..00000000000 --- a/sbin/dhclient/socket.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $OpenBSD: socket.c,v 1.6 2004/02/07 17:59:22 henning Exp $ */ - -/* BSD socket interface code... */ - -/* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 - * The Internet Software Consortium. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 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. - * - * 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. - * - * This software has been written for the Internet Software Consortium - * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie - * Enterprises. To learn more about the Internet Software Consortium, - * see ``http://www.vix.com/isc''. To learn more about Vixie - * Enterprises, see ``http://www.vix.com''. - */ - -#include "dhcpd.h" - -/* - * Generic interface registration routine... - */ -int -if_register_socket(struct interface_info *info) -{ - struct sockaddr_in name; - int sock; - int flag; - - /* Set up the address we're going to bind to. */ - memset(&name, 0, sizeof(name)); - name.sin_family = AF_INET; - name.sin_port = local_port; - name.sin_addr.s_addr = INADDR_ANY; - - /* Make a socket... */ - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) - error("Can't create dhcp socket: %m"); - - /* Set the REUSEADDR option so that we don't fail to start if - we're being restarted. */ - flag = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&flag, sizeof(flag)) < 0) - error("Can't set SO_REUSEADDR option on dhcp socket: %m"); - - flag = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, - (char *)&flag, sizeof(flag)) < 0) - error("Can't set SO_REUSEPORT option on dhcp socket: %m"); - - /* Set the BROADCAST option so that we can broadcast DHCP responses. */ - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, - (char *)&flag, sizeof(flag)) < 0) - error("Can't set SO_BROADCAST option on dhcp socket: %m"); - - /* Bind the socket to this interface's IP address. */ - if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) - error("Can't bind to dhcp address: %m"); - - flag = IPSEC_LEVEL_BYPASS; - if (setsockopt(sock, IPPROTO_IP, IP_AUTH_LEVEL, - (char *)&flag, sizeof(flag)) == -1) - if (errno != EOPNOTSUPP) - error("Can't bypass auth IPsec on dhcp socket: %m"); - if (setsockopt(sock, IPPROTO_IP, IP_ESP_TRANS_LEVEL, - (char *)&flag, sizeof(flag)) == -1) - if (errno != EOPNOTSUPP) - error("Can't bypass ESP transport on dhcp socket: %m"); - if (setsockopt(sock, IPPROTO_IP, IP_ESP_NETWORK_LEVEL, - (char *)&flag, sizeof(flag)) == -1) - if (errno != EOPNOTSUPP) - error("Can't bypass ESP network on dhcp socket: %m"); - - return (sock); -} - -void -if_register_fallback(struct interface_info *info) -{ - info->wfdesc = if_register_socket(info); -} - -ssize_t -send_fallback(struct interface_info *interface, struct packet *packet, - struct dhcp_packet *raw, size_t len, struct in_addr from, - struct sockaddr_in *to, struct hardware *hto) -{ - int result; - - result = sendto(interface->wfdesc, (char *)raw, len, 0, - (struct sockaddr *)to, sizeof(*to)); - - if (result == -1) { - warn("send_fallback: %m"); - if (errno == ENETUNREACH) - warn("send_fallback: please consult README file %s", - "regarding broadcast address."); - } - return (result); -} - -/* - * This just reads in a packet and silently discards it. - */ -void -fallback_discard(struct protocol *protocol) -{ - char buf[1540]; - struct sockaddr_in from; - socklen_t flen = sizeof(from); - int status; - struct interface_info *interface = protocol->local; - - status = recvfrom(interface->wfdesc, buf, sizeof(buf), 0, - (struct sockaddr *)&from, &flen); - if (status == 0) - warn("fallback_discard: %m"); -} |