]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
cache interface MAC
authorAlan T. DeKok <aland@freeradius.org>
Wed, 27 May 2020 14:08:47 +0000 (10:08 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 27 May 2020 14:08:47 +0000 (10:08 -0400)
so that we can automatically add a Server-Id attribute

src/modules/proto_dhcpv6/proto_dhcpv6_udp.c

index e2ea0e0dd2ec6e2fc3b9ba5561c289739a8397d5..9fdc9b4cac4e2bd7944aa6d1f2b90faa8ad590b0 100644 (file)
@@ -55,6 +55,7 @@ typedef struct {
 
        char const                      *interface;             //!< Interface to bind to.
        char const                      *port_name;             //!< Name of the port for getservent().
+       uint8_t                         ethernet[6];            //!< ethernet address associated with the interface
 
        uint32_t                        recv_buff;              //!< How big the kernel's receive buffer should be.
 
@@ -128,7 +129,7 @@ fr_dict_attr_autoload_t proto_dhcpv6_udp_dict_attr[] = {
 
 static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover, UNUSED uint32_t *priority, UNUSED bool *is_dup)
 {
-//     proto_dhcpv6_udp_t const        *inst = talloc_get_type_abort_const(li->app_io_instance, proto_dhcpv6_udp_t);
+       proto_dhcpv6_udp_t const        *inst = talloc_get_type_abort_const(li->app_io_instance, proto_dhcpv6_udp_t);
        proto_dhcpv6_udp_thread_t       *thread = talloc_get_type_abort(li->thread_instance, proto_dhcpv6_udp_thread_t);
        fr_io_address_t                 *address, **address_p;
 
@@ -182,7 +183,7 @@ static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time
         *      RFC 8415 Section 18.4 forbids certain types of packets
         *      from being received on a unicast address.
         */
-       if (address->dst_ipaddr.addr.v6.s6_addr[0] != 0xff) {
+       if (!inst->multicast) {
                if ((packet->code == FR_DHCPV6_SOLICIT) ||
                    (packet->code == FR_DHCPV6_REBIND) ||
                    (packet->code == FR_DHCPV6_CONFIRM)) {
@@ -480,6 +481,12 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                return -1;
        }
 
+       /*
+        *      Get the MAC address associated with this interface.
+        *      It can be used to create a server ID.
+        */
+       (void) fr_interface_to_ethernet(inst->interface, inst->ethernet);
+
        if (inst->recv_buff_is_set) {
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);