]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
DHCPv4 Fixups
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Jun 2017 00:33:20 +0000 (20:33 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 29 Jun 2017 01:17:05 +0000 (21:17 -0400)
22 files changed:
raddb/all.mk
raddb/mods-available/dhcpv4 [moved from raddb/mods-available/dhcp with 98% similarity]
src/lib/util/udp.c
src/modules/proto_dhcpv4/dhcpclient.c
src/modules/proto_dhcpv4/dhcpclient.mk
src/modules/proto_dhcpv4/rlm_dhcpv4.c
src/protocols/dhcpv4/all.mk
src/protocols/dhcpv4/base.c
src/protocols/dhcpv4/decode.c
src/protocols/dhcpv4/dhcpv4.h
src/protocols/dhcpv4/encode.c
src/protocols/dhcpv4/packet.c
src/protocols/dhcpv4/pcap.c
src/protocols/dhcpv4/raw.c
src/protocols/dhcpv4/udp.c
src/protocols/radius/base.c
src/protocols/radius/decode.c
src/protocols/radius/encode.c
src/protocols/radius/list.c
src/protocols/radius/packet.c
src/protocols/radius/radius.h
src/protocols/radius/tcp.c

index c63c1523d75a827c0ee34118bb5d0d27d59f644d..4aa0fdcf395a0b50bda2ca378e9dd18058d21147 100644 (file)
@@ -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
similarity index 98%
rename from raddb/mods-available/dhcp
rename to raddb/mods-available/dhcpv4
index a4316335d7f73b37ec5aa9278de91d37dd28eddc..a6b31b89d69da28f8d731a1ccb8ad652171454a8 100644 (file)
@@ -15,5 +15,5 @@
 #      * Alcatel lucent SR     - Alc-ToServer-Dhcp-Options
 #                              - Alc-ToClient-Dhcp-Options
 #
-dhcp {
+dhcpv4 {
 }
index f0777e46c57f80418cef827d82db9c70b8b335c5..5b05c57f00563060b0697726e15329e741a743e6 100644 (file)
@@ -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
index 9ccb119bdfea7f6228e4cadb2d95f5d021084a41..029ec5775be2d55f16dd9c52eebc3a80fb008d9c 100644 (file)
@@ -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;
        }
index 909407e99dfa77957e51463f744f728728d58e26..6068ce8869bf90d2748fe9dfb2ee4dd581f533d3 100644 (file)
@@ -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)
index 4945884a6134632e59a2c884bdfe640700bf3cd7..eddc0c6b8d690366b4d91f4aca48b32f4486970a 100644 (file)
@@ -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,
index 211b0ff0ebe5006b7e896645fe260f48e28345a4..d358dd3f5b467df44f7ab746c76791be02c17793 100644 (file)
@@ -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
index c4c3abd75c618a413986b0f7f2be2c33ef99be3a..0acc44c25eb6ee4bd493f7b531fdfcc49e977617 100644 (file)
@@ -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)
index 743958ccded5dac56c35e0a9d1e3c28a6a54fc60..85469ca4b97e7f8c833af08605e443375a028f75 100644 (file)
@@ -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
index 392a9a68bed28c0de2eedc3f722a83113478cea0..820ad3c244ada3370b18f07823c87a244a72fbba 100644 (file)
@@ -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 <linux/if_packet.h>
-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);
 
index 213c28e318a5d5b8ba6ccc2f8ac926a9075170e1..99930bef5af46ee56458002e1ec9747034fa03cd 100644 (file)
@@ -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
index 7de4f0e7fd688e021720cefe8d53e4804e33022f..9f8204c8556f9448d262d064e244a68bffd50b6c 100644 (file)
@@ -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
index a15b1d19db4b7a6a9ae143d829f158afd52d1e39..9ce98e853376d84c5cbf4f8aa8c5d96c6ca4a7a2 100644 (file)
@@ -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
index a7f1adc20c38a8b5b1f2473be6fdf6231647baeb..50df39f5ab58c6ee5acf58f0f1b512fff787e6c8 100644 (file)
@@ -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
index 6c4d82868dedc2ec1850294ff0b10905257f20ff..4d3c8cad7c0e993ff3aa13d166cee41bfe7be8b3 100644 (file)
@@ -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
index 6feda2225d1a2e3245b07fca9fbc2dfc39dd7948..400d3975210a5af760910b5b421484b52723fc07 100644 (file)
@@ -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
index 05f6404063d512c49553104c3540d0da0a9e76f0..7ece8294698b634c079ee604cc881d0d3608bf90 100644 (file)
@@ -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
index 0dc72732aa08f65056050924ddb62680c670a2c6..a659bb4355b0134533508ad671169caca04dcec0 100644 (file)
@@ -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
index 48c38d42f2d2668b631f33269ad66fe5fa44b3ab..9f0c3899be842c22310aaf4a47c2014933dc7d7b 100644 (file)
@@ -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
index 9271afae7daa6284d38e215981e2dc55bd64ce4d..f9636fe67610323835c9d41697a0037f0427dce5 100644 (file)
 /**
  * $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 <freeradius-devel/libradius.h>
index f87309115bc5d03b47d04979a0115811ecd19e22..56aa7c62e540904fa1cef94340cebaf54678d78d 100644 (file)
@@ -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
index 0faf435d68e206b121324cedb540f4ee60c3f43d..d55d09738993236a59ec818472af2f5fc009fdd9 100644 (file)
@@ -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       <freeradius-devel/libradius.h>
+#include <freeradius-devel/libradius.h>
 
 #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.