]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Make ethernet.h the sole definer of ethernet_header_t
authorJames Jones <jejones3141@gmail.com>
Wed, 6 May 2020 14:22:45 +0000 (09:22 -0500)
committerAlan DeKok <aland@freeradius.org>
Wed, 6 May 2020 19:51:18 +0000 (15:51 -0400)
Member name references are now consistent with the now-sole definition.

src/lib/util/net.h
src/modules/proto_arp/proto_arp_ethernet.c
src/protocols/dhcpv4/pcap.c
src/protocols/dhcpv4/raw.c

index e35ce6977dc00577b4e2a130add3a79a76937c2d..3448308c12e5b63ca736f5d9f6893450390b8331 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
 #endif
 
 #include <freeradius-devel/build.h>
+#include <freeradius-devel/ethernet/ethernet.h>
 #include <freeradius-devel/missing.h>
 #include <freeradius-devel/util/hash.h>
 #include <freeradius-devel/util/misc.h>
@@ -97,15 +98,6 @@ typedef enum {
 #define IP_MF          0x2000          //!< More fragments flag.
 #define IP_OFFMASK     0x1fff          //!< Mask for fragmenting bits.
 
-/*
- *     Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
- */
-typedef struct CC_HINT(__packed__) {
-       uint8_t         ether_dst[ETHER_ADDR_LEN];
-       uint8_t         ether_src[ETHER_ADDR_LEN];
-       uint16_t        ether_type;
-} ethernet_header_t;
-
 /*
  *     Structure of an internet header, naked of options.
  */
index 367ce57551a3109b601cfaa19e68464e41071778..d3e7170b59f54bc90daeaad1cbcd1d516aba7247 100644 (file)
@@ -145,8 +145,8 @@ static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_tim
         *      Set the destination MAC as the target address from
         *      ARP.
         */
-       memcpy(eth_hdr->ether_src, thread->pcap->ether_addr, ETHER_ADDR_LEN);
-       memcpy(eth_hdr->ether_dst, arp->tha, ETHER_ADDR_LEN);
+       memcpy(eth_hdr->src_addr, thread->pcap->ether_addr, ETHER_ADDR_LEN);
+       memcpy(eth_hdr->dst_addr, arp->tha, ETHER_ADDR_LEN);
 
        /*
         *      If we fail injecting the reply, just ignore it.
index 9685fbfb262c564438bcc7fe781e8c86580b245f..c203b41afdde5953ce08446f8c01f42c1775e264 100644 (file)
@@ -51,8 +51,8 @@ int fr_dhcpv4_pcap_send(fr_pcap_t *pcap, uint8_t *dst_ether_addr, RADIUS_PACKET
 
        /* fill in Ethernet layer (L2) */
        eth_hdr = (ethernet_header_t *)dhcp_packet;
-       memcpy(eth_hdr->ether_dst, dst_ether_addr, ETH_ADDR_LEN);
-       memcpy(eth_hdr->ether_src, pcap->ether_addr, ETH_ADDR_LEN);
+       memcpy(eth_hdr->src_addr, dst_ether_addr, ETH_ADDR_LEN);
+       memcpy(eth_hdr->dst_addr, pcap->ether_addr, ETH_ADDR_LEN);
        eth_hdr->ether_type = htons(ETH_TYPE_IP);
        end += ETH_ADDR_LEN + ETH_ADDR_LEN + sizeof(eth_hdr->ether_type);
 
index b618ecdc109b94c35998c2777b080f83e735d3a7..e7dd9d3151cdf286d270b72e8ace72ce9fef9399 100644 (file)
@@ -122,8 +122,8 @@ int fr_dhcpv4_raw_packet_send(int sockfd, struct sockaddr_ll *link_layer, RADIUS
        }
 
        /* fill in Ethernet layer (L2) */
-       memcpy(eth_hdr->ether_dst, eth_bcast, ETH_ADDR_LEN);
-       memcpy(eth_hdr->ether_src, dhmac, ETH_ADDR_LEN);
+       memcpy(eth_hdr->dst_addr, eth_bcast, ETH_ADDR_LEN);
+       memcpy(eth_hdr->src_addr, dhmac, ETH_ADDR_LEN);
        eth_hdr->ether_type = htons(ETH_TYPE_IP);
 
        /* fill in IP layer (L3) */
@@ -225,13 +225,13 @@ RADIUS_PACKET *fr_dhcv4_raw_packet_recv(int sockfd, struct sockaddr_ll *link_lay
         *      If Ethernet destination is not broadcast (ff:ff:ff:ff:ff:ff)
         *      Check if it matches the source HW address used (DHCP-Client-Hardware-Address = 267)
         */
-       if ((memcmp(&eth_bcast, &eth_hdr->ether_dst, ETH_ADDR_LEN) != 0) &&
+       if ((memcmp(&eth_bcast, &eth_hdr->dst_addr, ETH_ADDR_LEN) != 0) &&
            (vp = fr_pair_find_by_da(request->vps, attr_dhcp_client_hardware_address, TAG_ANY)) &&
-           ((vp->vp_type == FR_TYPE_ETHERNET) && (memcmp(vp->vp_ether, &eth_hdr->ether_dst, ETH_ADDR_LEN) != 0))) {
+           ((vp->vp_type == FR_TYPE_ETHERNET) && (memcmp(vp->vp_ether, &eth_hdr->dst_addr, ETH_ADDR_LEN) != 0))) {
 
                /* No match. */
                DISCARD_RP("Ethernet destination (%pV) is not broadcast and doesn't match request source (%pV)",
-                          fr_box_ether(eth_hdr->ether_dst), &vp->data);
+                          fr_box_ether(eth_hdr->dst_addr), &vp->data);
        }
 
        /*