]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove packet->offset
authorAlan T. DeKok <aland@freeradius.org>
Tue, 9 May 2017 14:46:57 +0000 (10:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 9 May 2017 14:46:57 +0000 (10:46 -0400)
which was only used for caching the offset of Message-Authenticator,
and is no longer used

src/include/packet.h
src/lib/util/mem.c
src/main/listen.c
src/main/process.c
src/main/stats.c
src/protocols/radius/packet.c

index ccc68c9dfd40f66a6d8186b0f0a3688a4dbeb2d8..8627c7b6ed4f7ca5b27d50be524786f9e0bb59e3 100644 (file)
@@ -62,7 +62,6 @@ typedef struct radius_packet {
        uint8_t                 *data;                  //!< Packet data (body).
        size_t                  data_len;               //!< Length of packet data.
        VALUE_PAIR              *vps;                   //!< Result of decoding the packet into VALUE_PAIRs.
-       ssize_t                 offset;
 
        uint32_t                rounds;                 //!< for State[0]
 
index f9a7db9ac038776d617c41d3dc1b4ecab67fd9f6..02507c242183a5df85b4748c4c7e140f80de31ff 100644 (file)
@@ -43,7 +43,6 @@ RADIUS_PACKET *fr_radius_alloc(TALLOC_CTX *ctx, bool new_vector)
                return NULL;
        }
        rp->id = -1;
-       rp->offset = -1;
 
        if (new_vector) {
                int i;
@@ -154,7 +153,6 @@ RADIUS_PACKET *fr_radius_copy(TALLOC_CTX *ctx, RADIUS_PACKET const *in)
        out->data_len = 0;
 
        out->vps = fr_pair_list_copy(out, in->vps);
-       out->offset = 0;
 
        return out;
 }
index 648dab7ac6c2b08347e455e5abf60c47e19964e3..57f28ad4123d688a0ee77121d26df895057ae969 100644 (file)
@@ -2458,6 +2458,7 @@ static int client_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request)
 
        if (fr_radius_packet_verify(request->packet, NULL,
                             request->client->secret) < 0) {
+               if (request->reply) request->reply->id = -1;
                return -1;
        }
 
index df7cdd02fe5f7a1e5f04a305359767901c5a611f..3bfb0b85a00437467dd26e0f834216b82e95962b 100644 (file)
@@ -1124,7 +1124,6 @@ static int request_pre_handler(REQUEST *request, UNUSED fr_state_action_t action
 
        if (rcode < 0) {
                RATE_LIMIT(INFO("Dropping packet without response because of error: %s", fr_strerror()));
-               request->reply->offset = -2; /* bad authenticator */
                return 0;
        }
 
index 05aeb048b120f22e5db620bab92c7c59ee32868f..6ed184d41bff47cfa9a6369b9ecde80bddfc94e4 100644 (file)
@@ -184,18 +184,46 @@ void request_stats_final(REQUEST *request)
                 *      authenticator.
                 */
        case 0:
-               if (request->packet->code == PW_CODE_ACCESS_REQUEST) {
-                       if (request->reply->offset == -2) {
+               switch (request->packet->code) {
+               case PW_CODE_ACCESS_REQUEST:
+                       if (request->reply->id == -1) {
                                INC_AUTH(total_bad_authenticators);
                        } else {
                                INC_AUTH(total_packets_dropped);
                        }
-               } else if (request->packet->code == PW_CODE_ACCOUNTING_REQUEST) {
-                       if (request->reply->offset == -2) {
+                       break;
+
+
+#ifdef WITH_ACCOUNTING
+               case PW_CODE_ACCOUNTING_REQUEST:
+                       if (request->reply->id == -1) {
                                INC_ACCT(total_bad_authenticators);
                        } else {
                                INC_ACCT(total_packets_dropped);
                        }
+                       break;
+#endif
+
+#ifdef WITH_COA
+               case PW_CODE_COA_REQUEST:
+                       if (request->reply->id == -1) {
+                               INC_COA(total_bad_authenticators);
+                       } else {
+                               INC_COA(total_packets_dropped);
+                       }
+                       break;
+
+               case PW_CODE_DISCONNECT_REQUEST:
+                       if (request->reply->id == -1) {
+                               INC_DSC(total_bad_authenticators);
+                       } else {
+                               INC_DSC(total_packets_dropped);
+                       }
+                       break;
+#endif
+
+                       default:
+                               break;
                }
                break;
 
index ba052b40eb8cbbde17f9dea647e7a4311de44de2..eefadc04b3605327f134cde0811cde16c017fc51 100644 (file)
@@ -115,7 +115,6 @@ int fr_radius_packet_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original
         *      Load up the configuration values for the user
         */
        ptr = hdr->data;
-       packet->offset = 0;
 
        /*
         *      Loop over the reply attributes for the packet.
@@ -163,11 +162,6 @@ int fr_radius_packet_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original
                 *      length and initial value.
                 */
                if (!vp->da->vendor && (vp->da->attr == PW_MESSAGE_AUTHENTICATOR)) {
-                       /*
-                        *      Cache the offset to the
-                        *      Message-Authenticator
-                        */
-                       packet->offset = total_length;
                        last_len = 16;
                } else {
                        last_len = vp->vp_length;