From: Arran Cudbard-Bell Date: Thu, 29 Jun 2017 00:33:20 +0000 (-0400) Subject: DHCPv4 Fixups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=365a892d1bd5696efdd099925d136b367eb816df;p=thirdparty%2Ffreeradius-server.git DHCPv4 Fixups --- diff --git a/raddb/all.mk b/raddb/all.mk index c63c1523d75..4aa0fdcf395 100644 --- a/raddb/all.mk +++ b/raddb/all.mk @@ -8,7 +8,7 @@ DEFAULT_SITES := default inner-tunnel LOCAL_SITES := $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES)) DEFAULT_MODULES := always attr_filter cache_eap chap client \ - detail detail.log digest dhcp eap \ + detail detail.log digest dhcpv4 eap \ eap_inner echo exec expiration expr files linelog logintime \ mschap ntlm_auth pam pap passwd preprocess radutmp realm \ replicate soh sradutmp unix unpack utf8 diff --git a/raddb/mods-available/dhcp b/raddb/mods-available/dhcpv4 similarity index 98% rename from raddb/mods-available/dhcp rename to raddb/mods-available/dhcpv4 index a4316335d7f..a6b31b89d69 100644 --- a/raddb/mods-available/dhcp +++ b/raddb/mods-available/dhcpv4 @@ -15,5 +15,5 @@ # * Alcatel lucent SR - Alc-ToServer-Dhcp-Options # - Alc-ToClient-Dhcp-Options # -dhcp { +dhcpv4 { } diff --git a/src/lib/util/udp.c b/src/lib/util/udp.c index f0777e46c57..5b05c57f005 100644 --- a/src/lib/util/udp.c +++ b/src/lib/util/udp.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file udp.c + * @file util/udp.c * @brief Functions to send/receive UDP packets. * * @copyright 2000-2003,2006 The FreeRADIUS server project diff --git a/src/modules/proto_dhcpv4/dhcpclient.c b/src/modules/proto_dhcpv4/dhcpclient.c index 9ccb119bdfe..029ec5775be 100644 --- a/src/modules/proto_dhcpv4/dhcpclient.c +++ b/src/modules/proto_dhcpv4/dhcpclient.c @@ -58,7 +58,6 @@ static int sockfd; #ifdef HAVE_LIBPCAP static fr_pcap_t *pcap; -static uint8_t eth_bcast[ETH_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #endif static char *iface = NULL; @@ -373,7 +372,7 @@ static int send_with_socket(RADIUS_PACKET **reply, RADIUS_PACKET *request) #ifdef HAVE_LINUX_IF_PACKET_H if (raw_mode) { - sockfd = fr_dhcpv4_raw_socket_open(iface_ind, &ll); + sockfd = fr_dhcpv4_raw_socket_open(&ll, iface_ind); if (sockfd < 0) { ERROR("Error opening socket"); return -1; @@ -468,13 +467,13 @@ static int send_with_pcap(RADIUS_PACKET **reply, RADIUS_PACKET *request) sprintf(pcap_filter, "udp and dst port %d", request->src_port); if (fr_pcap_apply_filter(pcap, pcap_filter) < 0) { - ERROR("dhcoclient: Failed setting filter for interface"); + ERROR("Failing setting filter"); talloc_free(pcap); return -1; } if (fr_dhcpv4_pcap_send(pcap, eth_bcast, request) < 0) { - ERROR("Failed sending packet via PCAP: %s", pcap_geterr(pcap->handle)); + ERROR("Failed sending packet"); talloc_free(pcap); return -1; } diff --git a/src/modules/proto_dhcpv4/dhcpclient.mk b/src/modules/proto_dhcpv4/dhcpclient.mk index 909407e99df..6068ce8869b 100644 --- a/src/modules/proto_dhcpv4/dhcpclient.mk +++ b/src/modules/proto_dhcpv4/dhcpclient.mk @@ -1,5 +1,5 @@ TARGET := dhcpclient SOURCES := dhcpclient.c -TGT_PREREQS := libfreeradius-dhcpv4.a +TGT_PREREQS := libfreeradius-util.a libfreeradius-dhcpv4.a TGT_LDLIBS := $(LIBS) diff --git a/src/modules/proto_dhcpv4/rlm_dhcpv4.c b/src/modules/proto_dhcpv4/rlm_dhcpv4.c index 4945884a613..eddc0c6b8d6 100644 --- a/src/modules/proto_dhcpv4/rlm_dhcpv4.c +++ b/src/modules/proto_dhcpv4/rlm_dhcpv4.c @@ -40,9 +40,9 @@ RCSID("$Id$") * a lot cleaner to do so, and a pointer to the structure can * be used as the instance handle. */ -typedef struct rlm_dhcp_t { +typedef struct rlm_dhcpv4_t { int nothing; -} rlm_dhcp_t; +} rlm_dhcpv4_t; /* @@ -163,7 +163,7 @@ static ssize_t dhcp_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, */ static int mod_bootstrap(void *instance, UNUSED CONF_SECTION *conf) { - rlm_dhcp_t *inst = instance; + rlm_dhcpv4_t *inst = instance; fr_dict_attr_t const *da; xlat_register(inst, "dhcp_options", dhcp_options_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN); @@ -222,10 +222,10 @@ static int dhcp_load(void) * is single-threaded. */ extern rad_module_t rlm_dhcp; -rad_module_t rlm_dhcp = { +rad_module_t rlm_dhcpv4 = { .magic = RLM_MODULE_INIT, - .name = "dhcp", - .inst_size = sizeof(rlm_dhcp_t), + .name = "dhcpv4", + .inst_size = sizeof(rlm_dhcpv4_t), .load = dhcp_load, .bootstrap = mod_bootstrap, diff --git a/src/protocols/dhcpv4/all.mk b/src/protocols/dhcpv4/all.mk index 211b0ff0ebe..d358dd3f5b4 100644 --- a/src/protocols/dhcpv4/all.mk +++ b/src/protocols/dhcpv4/all.mk @@ -14,5 +14,6 @@ SOURCES := base.c \ udp.c SRC_CFLAGS := -I$(top_builddir)/src - +TGT_LDLIBS := $(PCAP_LIBS) +TGT_LDFLAGS := $(PCAP_LDFLAGS) TGT_PREREQS := libfreeradius-util.a diff --git a/src/protocols/dhcpv4/base.c b/src/protocols/dhcpv4/base.c index c4c3abd75c6..0acc44c25eb 100644 --- a/src/protocols/dhcpv4/base.c +++ b/src/protocols/dhcpv4/base.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/base.c + * @file protocols/dhcpv4/base.c * @brief Functions to send/receive dhcp packets. * * @copyright 2008 The FreeRADIUS server project @@ -98,6 +98,8 @@ int dhcp_header_sizes[] = { DHCP_FILE_LEN /* file */ }; +uint8_t eth_bcast[ETH_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + fr_dict_attr_t const *dhcp_option_82; int8_t fr_dhcpv4_attr_cmp(void const *a, void const *b) diff --git a/src/protocols/dhcpv4/decode.c b/src/protocols/dhcpv4/decode.c index 743958ccded..85469ca4b97 100644 --- a/src/protocols/dhcpv4/decode.c +++ b/src/protocols/dhcpv4/decode.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/decode.c + * @file protocols/dhcpv4/decode.c * @brief Functions to decode DHCP options. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/dhcpv4/dhcpv4.h b/src/protocols/dhcpv4/dhcpv4.h index 392a9a68bed..820ad3c244a 100644 --- a/src/protocols/dhcpv4/dhcpv4.h +++ b/src/protocols/dhcpv4/dhcpv4.h @@ -18,7 +18,7 @@ /** * $Id$ * - * @file dhcpv4/dhcpv4.h + * @file protocols/dhcpv4/dhcpv4.h * @brief Implementation of the DHCPv4 protocol. * * @copyright 2008 The FreeRADIUS server project @@ -118,12 +118,11 @@ typedef struct dhcp_packet_t { extern char const *dhcp_header_names[]; extern char const *dhcp_message_types[]; extern int dhcp_header_sizes[]; +extern uint8_t eth_bcast[ETH_ADDR_LEN]; extern fr_dict_attr_t const *dhcp_option_82; #ifdef HAVE_LINUX_IF_PACKET_H # define ETH_HDR_SIZE 14 -static uint8_t eth_bcast[ETH_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - /* Discard raw packets which we are not interested in. Allow to trace why we discard. */ # define DISCARD_RP(...) { \ if (fr_debug_lvl > 2) { \ @@ -176,7 +175,7 @@ int fr_dhcpv4_packet_encode(RADIUS_PACKET *packet); * raw.c */ #include -int fr_dhcpv4_raw_socket_open(int iface_index, struct sockaddr_ll *p_ll); +int fr_dhcpv4_raw_socket_open(struct sockaddr_ll *p_ll, int iface_index); int fr_dhcpv4_raw_packet_send(int sockfd, struct sockaddr_ll *p_ll, RADIUS_PACKET *packet); diff --git a/src/protocols/dhcpv4/encode.c b/src/protocols/dhcpv4/encode.c index 213c28e318a..99930bef5af 100644 --- a/src/protocols/dhcpv4/encode.c +++ b/src/protocols/dhcpv4/encode.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/encode.c + * @file protocols/dhcpv4/encode.c * @brief Functions to encode DHCP options. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/dhcpv4/packet.c b/src/protocols/dhcpv4/packet.c index 7de4f0e7fd6..9f8204c8556 100644 --- a/src/protocols/dhcpv4/packet.c +++ b/src/protocols/dhcpv4/packet.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/packet.c + * @file protocols/dhcpv4/packet.c * @brief Functions to encode/decode DHCP packets. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/dhcpv4/pcap.c b/src/protocols/dhcpv4/pcap.c index a15b1d19db4..9ce98e85337 100644 --- a/src/protocols/dhcpv4/pcap.c +++ b/src/protocols/dhcpv4/pcap.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/pcap.c + * @file protocols/dhcpv4/pcap.c * @brief Alternative mechanism to send/recv DHCP packets using libpcap. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/dhcpv4/raw.c b/src/protocols/dhcpv4/raw.c index a7f1adc20c3..50df39f5ab5 100644 --- a/src/protocols/dhcpv4/raw.c +++ b/src/protocols/dhcpv4/raw.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/raw.c + * @file protocols/dhcpv4/raw.c * @brief Send/recv DHCP packets using raw sockets. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/dhcpv4/udp.c b/src/protocols/dhcpv4/udp.c index 6c4d82868de..4d3c8cad7c0 100644 --- a/src/protocols/dhcpv4/udp.c +++ b/src/protocols/dhcpv4/udp.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file dhcpv4/udp.c + * @file protocols/dhcpv4/udp.c * @brief Send/recv DHCP packets using udp sockets. * * @copyright 2008,2017 The FreeRADIUS server project diff --git a/src/protocols/radius/base.c b/src/protocols/radius/base.c index 6feda2225d1..400d3975210 100644 --- a/src/protocols/radius/base.c +++ b/src/protocols/radius/base.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file base.c + * @file protocols/radius/base.c * @brief Functions to send/receive radius packets. * * @copyright 2000-2003,2006 The FreeRADIUS server project diff --git a/src/protocols/radius/decode.c b/src/protocols/radius/decode.c index 05f6404063d..7ece8294698 100644 --- a/src/protocols/radius/decode.c +++ b/src/protocols/radius/decode.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file decode.c + * @file protocols/radius/decode.c * @brief Functions to decode RADIUS attributes * * @copyright 2000-2003,2006-2015 The FreeRADIUS server project diff --git a/src/protocols/radius/encode.c b/src/protocols/radius/encode.c index 0dc72732aa0..a659bb4355b 100644 --- a/src/protocols/radius/encode.c +++ b/src/protocols/radius/encode.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file encode.c + * @file protocols/radius/encode.c * @brief Functions to encode RADIUS attributes * * @copyright 2000-2003,2006-2015 The FreeRADIUS server project diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index 48c38d42f2d..9f0c3899be8 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -17,7 +17,7 @@ /** * $Id$ * - * @file list.c + * @file protocols/radius/list.c * @brief Functions to deal with outgoing lists / sets of packets. * * @copyright 2000-2017 The FreeRADIUS server project diff --git a/src/protocols/radius/packet.c b/src/protocols/radius/packet.c index 9271afae7da..f9636fe6761 100644 --- a/src/protocols/radius/packet.c +++ b/src/protocols/radius/packet.c @@ -17,12 +17,11 @@ /** * $Id$ * - * @file packet.c + * @file protocols/radius/packet.c * @brief Functions to deal with RADIUS_PACKET data structures. * * @copyright 2000-2017 The FreeRADIUS server project */ - RCSID("$Id$") #include diff --git a/src/protocols/radius/radius.h b/src/protocols/radius/radius.h index f87309115bc..56aa7c62e54 100644 --- a/src/protocols/radius/radius.h +++ b/src/protocols/radius/radius.h @@ -18,7 +18,7 @@ /* * $Id$ * - * @file radius/radius.h + * @file protocols/radius/radius.h * @brief Structures and prototypes for base RADIUS functionality. * * @copyright 1999-2017 The FreeRADIUS server project diff --git a/src/protocols/radius/tcp.c b/src/protocols/radius/tcp.c index 0faf435d68e..d55d0973899 100644 --- a/src/protocols/radius/tcp.c +++ b/src/protocols/radius/tcp.c @@ -1,28 +1,30 @@ /* - * tcp.c TCP-specific functions. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * Version: $Id$ + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * $Id$ * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * @file protocols/radius/packet.c + * @brief TCP-specific functions. * - * Copyright (C) 2009 Dante http://dante.net + * @copyright (C) 2009 Dante http://dante.net */ - RCSID("$Id$") -#include +#include #ifdef WITH_TCP @@ -42,7 +44,6 @@ RADIUS_PACKET *fr_tcp_recv(int sockfd, int flags) return packet; } - /* * Receives a packet, assuming that the RADIUS_PACKET structure * has been filled out already.