]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
unify checks for buffer_len==1 and do_not_respond
authorAlan T. DeKok <aland@freeradius.org>
Wed, 27 Jan 2021 19:42:58 +0000 (14:42 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 27 Jan 2021 19:42:58 +0000 (14:42 -0500)
src/modules/proto_arp/proto_arp.c
src/modules/proto_dhcpv4/proto_dhcpv4.c
src/modules/proto_dhcpv6/proto_dhcpv6.c
src/modules/proto_radius/proto_radius.c
src/modules/proto_tacacs/proto_tacacs.c
src/modules/proto_vmps/proto_vmps.c

index 3bbbfa03a3d8fa71d50b2d438494329f5aa6ec7b..cdf70a341cde9d038cf54d83943b3f1dae03c64b 100644 (file)
@@ -110,17 +110,9 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        fr_arp_packet_t         *arp;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      Process layer NAK, never respond, or "Do not respond".
         */
-       if (buffer_len == 1) {
-               *buffer = true;
-               return 1;
-       }
-
-       /*
-        *      "Do not respond"
-        */
-       if (!inst->active ||
+       if ((buffer_len == 1) || !inst->active ||
            (request->reply->code == FR_ARP_CODE_DO_NOT_RESPOND) ||
            (request->reply->code == 0) || (request->reply->code >= FR_ARP_MAX_PACKET_CODE)) {
                *buffer = false;
index cedec26d2516ac70a11b773832e49bb71dbbfdeb..b86f37b9b390b657181686d1633546d011541835 100644 (file)
@@ -252,21 +252,14 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        RADCLIENT const *client;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      process layer NAK, or "Do not respond".  We also never
+        *      send replies to a release.
         */
-       if (buffer_len == 1) {
-               *buffer = true;
-               return 1;
-       }
-
-       /*
-        *      "Do not respond".  We also never send replies to a release.
-        */
-       if ((request->reply->code == FR_MESSAGE_TYPE_VALUE_DO_NOT_RESPOND) ||
+       if ((buffer_len == 1) ||
+           (request->reply->code == FR_MESSAGE_TYPE_VALUE_DO_NOT_RESPOND) ||
            (request->reply->code == 0) || (request->reply->code >= FR_DHCP_MAX) ||
            (request->packet->code == FR_DHCP_RELEASE)) {
                track->do_not_respond = true;
-               *buffer = false;
                return 1;
        }
 
index 802d6a41cc5284eaa288c7304ce88906b6d96d5f..864d4efb920034de641e82fcad66c5d4b77f5a3e 100644 (file)
@@ -251,20 +251,12 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        RADCLIENT const         *client;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      Process layer NAK, never respond, or "Do not respond".
         */
-       if (buffer_len == 1) {
-               *buffer = true;
-               return 1;
-       }
-
-       /*
-        *      "Do not respond".  We also never send replies to a release.
-        */
-       if ((request->reply->code == FR_DHCPV6_DO_NOT_RESPOND) ||
+       if ((buffer_len == 1) ||
+           (request->reply->code == FR_DHCPV6_DO_NOT_RESPOND) ||
            (request->reply->code == 0) || (request->reply->code >= FR_DHCPV6_MAX_CODE)) {
                track->do_not_respond = true;
-               *buffer = false;
                return 1;
        }
 
index 1d3d2e69a3e708884c65c75f3a729ea701607a94..781800684f0b5e14f72434441eb841132a96e85a 100644 (file)
@@ -309,20 +309,12 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        RADCLIENT const         *client;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      Process layer NAK, or "Do not respond".
         */
-       if (buffer_len == 1) {
-               *buffer = true;
-               return 1;
-       }
-
-       /*
-        *      "Do not respond"
-        */
-       if ((request->reply->code == FR_CODE_DO_NOT_RESPOND) ||
+       if ((buffer_len == 1) ||
+           (request->reply->code == FR_CODE_DO_NOT_RESPOND) ||
            (request->reply->code == 0) || (request->reply->code >= FR_RADIUS_MAX_PACKET_CODE)) {
                track->do_not_respond = true;
-               *buffer = false;
                return 1;
        }
 
index 549d712a0cae6c776c3c91d2917b132bd747509e..821826191179d338b78c0d5922e6bfa61c3dd83b 100644 (file)
@@ -324,23 +324,15 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        RADCLIENT const         *client;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      Process layer NAK, or "Do not respond".
         */
-       if (buffer_len == 1) {
-               *buffer = true;
+       if ((buffer_len == 1) ||
+           (request->reply->code == FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND) ||
+           (request->reply->code == 0) || (request->reply->code >= FR_PACKET_TYPE_MAX)) {
+               track->do_not_respond = true;
                return 1;
        }
 
-       /*
-        *      "Do not respond"
-        */
-       if (request->reply->code == FR_PACKET_TYPE_VALUE_DO_NOT_RESPOND) {
-               *buffer = false;
-               return 1;
-       }
-       fr_assert(request->reply->code != 0);
-       fr_assert(request->reply->code < FR_PACKET_TYPE_MAX);
-
        client = address->radclient;
        fr_assert(client);
 
index fc7b280828987cc8e8ca0d9bbf36c41489ddcd66..e1497af49c5383b15ea07e1a452b2ab655281c7e 100644 (file)
@@ -236,20 +236,12 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        fr_dcursor_t cursor;
 
        /*
-        *      The packet timed out.  Tell the network side that the packet is dead.
+        *      Process layer NAK, never respond, or "Do not respond".
         */
-       if (buffer_len == 1) {
-               *buffer = true;
-               return 1;
-       }
-
-       /*
-        *      "Do not respond"
-        */
-       if ((request->reply->code == FR_CODE_DO_NOT_RESPOND) ||
+       if ((buffer_len == 1) ||
+           (request->reply->code == FR_CODE_DO_NOT_RESPOND) ||
            (request->reply->code >= FR_VQP_MAX_CODE)) {
                track->do_not_respond = true;
-               *buffer = false;
                return 1;
        }