]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rename fr_radius_foo to fr_radius_packet_foo
authorAlan T. DeKok <aland@freeradius.org>
Mon, 1 May 2017 15:55:26 +0000 (11:55 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 1 May 2017 15:55:26 +0000 (11:55 -0400)
These functions take RADIUS_PACKETs as arguments.  We want to
create new functions which operate on raw buffers, so these
need to be renamed.

16 files changed:
src/include/libradius.h
src/lib/util/radius.c
src/lib/util/radius_decode.c
src/lib/util/tcp.c
src/main/listen.c
src/main/process.c
src/main/radclient.c
src/main/radsniff.c
src/main/radsnmp.c
src/main/tls_listen.c
src/modules/proto_radius/proto_radius_acct.c
src/modules/proto_radius/proto_radius_auth.c
src/modules/proto_radius/proto_radius_coa.c
src/modules/proto_radius/proto_radius_status.c
src/modules/rlm_radius_client/rlm_radius_client.c
src/modules/rlm_replicate/rlm_replicate.c

index 24ce9d8568551b02408196a242e3c5634360a821..76b590b1f2cf926001f3f39df26923df04e95caf 100644 (file)
@@ -120,7 +120,7 @@ typedef void (*sig_t)(int);
 /*
  *     vector:         Request authenticator from access-request packet
  *                     Put in there by rad_decode, and must be put in the
- *                     response RADIUS_PACKET as well before calling fr_radius_send
+ *                     response RADIUS_PACKET as well before calling fr_radius_packet_send
  *
  *     verified:       Filled in by rad_decode for accounting-request packets
  *
@@ -216,23 +216,23 @@ void              fr_radius_ascend_secret(uint8_t *digest, uint8_t const *vector, char const
 
 void           fr_radius_print_hex(RADIUS_PACKET const *packet);
 
-int            fr_radius_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret);
+int            fr_radius_packet_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret);
 
 ssize_t                fr_radius_len(uint8_t const *data, size_t data_len);
 
-bool           fr_radius_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason);
+bool           fr_radius_packet_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason);
 
 RADIUS_PACKET  *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_ma);
 
 ssize_t                fr_radius_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, unsigned int *code);
 
-int            fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret);
+int            fr_radius_packet_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret);
 
 int            fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret);
 
 int            fr_radius_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret);
 
-int            fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret);
+int            fr_radius_packet_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret);
 
 int            fr_radius_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length);
 
index 016781e05c8bad2832497f223b56c5cac7a22cd1..04d9e35f3b301db980cfdde51e1a8faa302ac514 100644 (file)
@@ -381,7 +381,7 @@ static ssize_t rad_recvfrom(int sockfd, RADIUS_PACKET *packet, int flags)
 /** Sign a previously encoded packet
  *
  */
-int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
+int fr_radius_packet_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                   char const *secret)
 {
        radius_packet_t *hdr = (radius_packet_t *)packet->data;
@@ -396,7 +396,7 @@ int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
 
        if (!packet->data || (packet->data_len < RADIUS_HDR_LEN) ||
            (packet->offset < 0)) {
-               fr_strerror_printf("ERROR: You must call fr_radius_encode() before fr_radius_sign()");
+               fr_strerror_printf("ERROR: You must call fr_radius_encode() before fr_radius_packet_sign()");
                return -1;
        }
 
@@ -523,7 +523,7 @@ int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
  *
  * Also attach reply attribute value pairs and any user message provided.
  */
-int fr_radius_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
+int fr_radius_packet_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                   char const *secret)
 {
        /*
@@ -548,7 +548,7 @@ int fr_radius_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                 *      Re-sign it, including updating the
                 *      Message-Authenticator.
                 */
-               if (fr_radius_sign(packet, original, secret) < 0) {
+               if (fr_radius_packet_sign(packet, original, secret) < 0) {
                        return -1;
                }
 
@@ -748,7 +748,7 @@ ssize_t fr_radius_len(uint8_t const *data, size_t data_len)
  *     - True on success.
  *     - False on failure.
  */
-bool fr_radius_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason)
+bool fr_radius_packet_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason)
 {
        uint8_t                 *attr;
        size_t                  totallen;
@@ -1124,7 +1124,7 @@ RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_m
        /*
         *      See if it's a well-formed RADIUS packet.
         */
-       if (!fr_radius_ok(packet, require_ma, NULL)) {
+       if (!fr_radius_packet_ok(packet, require_ma, NULL)) {
                fr_radius_free(&packet);
                return NULL;
        }
@@ -1155,7 +1155,7 @@ RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_m
 /** Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet
  *
  */
-int fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret)
+int fr_radius_packet_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret)
 {
        uint8_t         *ptr;
        int             length;
@@ -1556,7 +1556,7 @@ int fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const
 
                /*
                 *      VSA's may not have been counted properly in
-                *      fr_radius_ok() above, as it is hard to count
+                *      fr_radius_packet_ok() above, as it is hard to count
                 *      then without using the dictionary.  We
                 *      therefore enforce the limits here, too.
                 */
index d145f9f2d767dc8cf2edc6c0c9a64c80957307b6..b594e8d68d08c4bbeafc9989312ab4d3c8d89a8b 100644 (file)
@@ -896,7 +896,7 @@ create_attrs:
  *
  * "length" is AT LEAST the length of this attribute, as we
  * expect the caller to have verified the data with
- * fr_radius_ok().  "length" may be up to the length of the
+ * fr_radius_packet_ok().  "length" may be up to the length of the
  * packet.
  *
  * @return
index 105987b4f3a671d14f63570a3e7e60af8759e674..6d1b36e3f4f6ba05043ed045d87a849b87e1c639 100644 (file)
@@ -140,7 +140,7 @@ int fr_tcp_read_packet(RADIUS_PACKET *packet, bool require_ma)
        /*
         *      See if it's a well-formed RADIUS packet.
         */
-       if (!fr_radius_ok(packet, require_ma, NULL)) {
+       if (!fr_radius_packet_ok(packet, require_ma, NULL)) {
                return -1;
        }
 
index 3419a5b67acff5022dcb6c858181db09fe973635..27eb7300faa9512f2b78bd8036685ee1d1a7a27d 100644 (file)
@@ -1657,7 +1657,7 @@ static int auth_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *reque
        }
 #endif
 
-       if (fr_radius_send(request->reply, request->packet,
+       if (fr_radius_packet_send(request->reply, request->packet,
                           request->client->secret) < 0) {
                RERROR("Failed sending reply: %s",
                               fr_strerror());
@@ -1697,7 +1697,7 @@ static int acct_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *reque
        }
 #  endif
 
-       if (fr_radius_send(request->reply, request->packet,
+       if (fr_radius_packet_send(request->reply, request->packet,
                           request->client->secret) < 0) {
                RERROR("Failed sending reply: %s",
                               fr_strerror());
@@ -1719,7 +1719,7 @@ static int proxy_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *requ
        rad_assert(request->proxy->listener == listener);
        rad_assert(listener->send == proxy_socket_send);
 
-       if (fr_radius_send(request->proxy->packet, NULL,
+       if (fr_radius_packet_send(request->proxy->packet, NULL,
                           request->proxy->home_server->secret) < 0) {
                RERROR("Failed sending proxied request: %s",
                               fr_strerror());
@@ -2440,7 +2440,7 @@ static int client_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request)
                        request->reply->data_len, MAX_PACKET_LEN);
        }
 
-       if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) {
+       if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) {
                RPERROR("Failed signing packet");
 
                return -1;
@@ -2456,7 +2456,7 @@ static int client_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request)
        listen_socket_t *sock;
 #endif
 
-       if (fr_radius_verify(request->packet, NULL,
+       if (fr_radius_packet_verify(request->packet, NULL,
                             request->client->secret) < 0) {
                return -1;
        }
@@ -2499,7 +2499,7 @@ static int proxy_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request)
                        request->proxy->packet->data_len, MAX_PACKET_LEN);
        }
 
-       if (fr_radius_sign(request->proxy->packet, NULL, request->proxy->home_server->secret) < 0) {
+       if (fr_radius_packet_sign(request->proxy->packet, NULL, request->proxy->home_server->secret) < 0) {
                RPERROR("Failed signing proxied packet");
 
                return -1;
@@ -2512,7 +2512,7 @@ static int proxy_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request)
 static int proxy_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request)
 {
        /*
-        *      fr_radius_verify is run in event.c, received_proxy_response()
+        *      fr_radius_packet_verify is run in event.c, received_proxy_response()
         */
 
        return fr_radius_decode(request->proxy->reply, request->proxy->packet,
index 09bd82a4abb6a1af894c098f6b3040c9614b7f20..a6d9826bbb66f09d5102d593b6d7bb91d855a59f 100644 (file)
@@ -2393,7 +2393,7 @@ int request_proxy_reply(RADIUS_PACKET *reply)
         *      ignore it.  This does the MD5 calculations in the
         *      server core, but I guess we can fix that later.
         */
-       if (!proxy->reply && (fr_radius_verify(reply, proxy->packet, proxy->home_server->secret) != 0)) {
+       if (!proxy->reply && (fr_radius_packet_verify(reply, proxy->packet, proxy->home_server->secret) != 0)) {
                RWDEBUG("Discarding invalid reply from host %s port %d - ID: %d: %s",
                        inet_ntop(reply->src_ipaddr.af, &reply->src_ipaddr.ipaddr, buffer, sizeof(buffer)),
                        reply->src_port, reply->id, fr_strerror());
index 2037621e5f71af15d0cd2628159a648ca1158ff3..cb24a70ef854a1b10fb486eaadd609bc2fa4658e 100644 (file)
@@ -961,7 +961,7 @@ static int send_one_packet(rc_request_t *request)
        /*
         *      Send the packet.
         */
-       if (fr_radius_send(request->packet, NULL, secret) < 0) {
+       if (fr_radius_packet_send(request->packet, NULL, secret) < 0) {
                REDEBUG("Failed to send packet for ID %d", request->packet->id);
                deallocate_id(request);
                request->done = true;
@@ -1055,7 +1055,7 @@ static int recv_one_packet(int wait_time)
         *      Fails the signature validation: not a real reply.
         *      FIXME: Silently drop it and listen for another packet.
         */
-       if (fr_radius_verify(reply, request->packet, secret) < 0) {
+       if (fr_radius_packet_verify(reply, request->packet, secret) < 0) {
                REDEBUG("Reply verification failed");
                stats.lost++;
                goto packet_done; /* shared secret is incorrect */
index fbd482e49353e39a9936e3a96eb3d021c736f4c9..f65d4e767efb8d21f1d9629a64085dbcc6bd6494 100644 (file)
@@ -1330,7 +1330,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
        current->src_port = ntohs(udp->src);
        current->dst_port = ntohs(udp->dst);
 
-       if (!fr_radius_ok(current, false, &reason)) {
+       if (!fr_radius_packet_ok(current, false, &reason)) {
                REDEBUG("%s", fr_strerror());
                if (conf->event_flags & RS_ERROR) {
                        rs_packet_print(NULL, count, RS_ERROR, event->in, current, &elapsed, NULL, false, false);
@@ -1375,7 +1375,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
                        FILE *log_fp = fr_log_fp;
 
                        fr_log_fp = NULL;
-                       ret = fr_radius_verify(current, original->expect, conf->radius_secret);
+                       ret = fr_radius_packet_verify(current, original->expect, conf->radius_secret);
                        fr_log_fp = log_fp;
                        if (ret != 0) {
                                REDEBUG("Failed verifying packet ID %d", current->id);
@@ -1386,7 +1386,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
 
                /*
                 *      Only decode attributes if we want to print them or filter on them
-                *      fr_radius_ok( does checks to verify the packet is actually valid.
+                *      fr_radius_packet_ok( does checks to verify the packet is actually valid.
                 */
                if (conf->decode_attrs) {
                        int ret;
@@ -1492,7 +1492,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
 
                /*
                 *      Only decode attributes if we want to print them or filter on them
-                *      fr_radius_ok( does checks to verify the packet is actually valid.
+                *      fr_radius_packet_ok( does checks to verify the packet is actually valid.
                 */
                if (conf->decode_attrs) {
                        int ret;
index 6482145581f3130985bdb1105938a8fd1116d1f4..b58143464f75bb85ec58cb5c13951895b5e01c23 100644 (file)
@@ -759,7 +759,7 @@ static int radsnmp_send_recv(radsnmp_conf_t *conf, int fd)
                                ERROR("Failed encoding request: %s", fr_strerror());
                                return EXIT_FAILURE;
                        }
-                       if (fr_radius_sign(request, NULL, conf->secret) < 0) {
+                       if (fr_radius_packet_sign(request, NULL, conf->secret) < 0) {
                                ERROR("Failed signing request: %s", fr_strerror());
                                return EXIT_FAILURE;
                        }
index b855a6358b1eab5ef503434f7bc39615892b45be..cf56930a51731818b9c390457a83fba535241c91 100644 (file)
@@ -251,7 +251,7 @@ static int tls_socket_recv(rad_listen_t *listener)
        packet->vps = NULL;
        pthread_mutex_unlock(&sock->mutex);
 
-       if (!fr_radius_ok(packet, 0, NULL)) {
+       if (!fr_radius_packet_ok(packet, 0, NULL)) {
                if (DEBUG_ENABLED) ERROR("Receive - %s", fr_strerror());
                DEBUG("Closing TLS socket from client");
                pthread_mutex_lock(&sock->mutex);
@@ -408,7 +408,7 @@ int dual_tls_send(rad_listen_t *listener, REQUEST *request)
        /*
         *      Sign the packet.
         */
-       if (fr_radius_sign(request->reply, request->packet,
+       if (fr_radius_packet_sign(request->reply, request->packet,
                           request->client->secret) < 0) {
                RPERROR("Failed signing packet");
                return 0;
index f667c5d816c4a04f4bee29cbc4df43da3305acc5..56072d345067ec2adcea2ff86c09d85471465325 100644 (file)
@@ -214,12 +214,12 @@ static void acct_running(REQUEST *request, fr_state_action_t action)
                        goto done;
                }
 
-               if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed signing RADIUS reply: %s", fr_strerror());
                        goto done;
                }
 
-               if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                }
                /* FALL-THROUGH */
index cea439358d93b57953770fadf46c84f458497447..8605ab3daf2e7b8e6d5b5aa6ff9304106712103a 100644 (file)
@@ -169,7 +169,7 @@ static void auth_cleanup_delay(REQUEST *request, fr_state_action_t action)
                if (request->reply->code != 0) {
                        gettimeofday(&request->reply->timestamp, NULL);
 
-                       if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+                       if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                                RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                                goto done;
                        }
@@ -243,7 +243,7 @@ static void auth_reject_delay(REQUEST *request, fr_state_action_t action)
                if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false);
 
                gettimeofday(&request->reply->timestamp, NULL);
-               if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                        goto done;
                }
@@ -771,7 +771,7 @@ static void auth_running(REQUEST *request, fr_state_action_t action)
                        goto stop_processing;
                }
 
-               if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed signing RADIUS reply: %s", fr_strerror());
 
                        /*
@@ -844,7 +844,7 @@ static void auth_running(REQUEST *request, fr_state_action_t action)
                        /* else fall through to sending the response immediately. */
                }
 
-               if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                        goto done;
                }
index 15dafca03559709dfcd1df7c10b7075bc4090c29..3d6104bf2da73a089a475b5925b983e1c7b64119 100644 (file)
@@ -253,12 +253,12 @@ static void coa_running(REQUEST *request, fr_state_action_t action)
                        goto done;
                }
 
-               if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed signing RADIUS reply: %s", fr_strerror());
                        goto done;
                }
 
-               if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                }
                /* FALL-THROUGH */
index aa87d9a70a02b2cc883010a7f53a8857ce3f2d4c..49e884448066b13e1c3fd2da82483da5b40dc5c3 100644 (file)
@@ -214,12 +214,12 @@ static void status_running(REQUEST *request, fr_state_action_t action)
                        goto done;
                }
 
-               if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed signing RADIUS reply: %s", fr_strerror());
                        goto done;
                }
 
-               if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) {
+               if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) {
                        RDEBUG("Failed sending RADIUS reply: %s", fr_strerror());
                }
                /* FALL-THROUGH */
index 4d9e55c370fd437c0a19530b011f4b64606bc1e0..55fe9a205ba45a6a7c9a286ee706b7d823645500 100644 (file)
@@ -150,7 +150,7 @@ static void mod_event_fd(UNUSED fr_event_list_t *el, int fd, void *ctx)
        /*
         *      If the reply fails the signature validation, it's not a real reply.
         */
-       if (fr_radius_verify(reply, ccr->packet, ccr->inst->home_server->secret) < 0) {
+       if (fr_radius_packet_verify(reply, ccr->packet, ccr->inst->home_server->secret) < 0) {
                REDEBUG("Reply verification failed for home server %s", ccr->inst->home_server->name);
                fr_radius_free(&reply);
                return;
@@ -280,7 +280,7 @@ static void mod_action_dup(REQUEST *request, void *instance, UNUSED void *thread
                         buffer, sizeof(buffer)),
               packet->dst_port, packet->id);
 
-       fr_radius_send(packet, NULL, inst->home_server->secret);
+       fr_radius_packet_send(packet, NULL, inst->home_server->secret);
        packet->count++;
 }
 
@@ -417,7 +417,7 @@ static rlm_rcode_t mod_wait_for_reply(REQUEST *request, rlm_radius_client_instan
                         buffer, sizeof(buffer)),
               packet->dst_port, packet->id);
 
-       (void) fr_radius_send(packet, NULL, inst->home_server->secret);
+       (void) fr_radius_packet_send(packet, NULL, inst->home_server->secret);
        packet->count++;
 
        timeout = ccr->inst->home_server->response_window;
index f5775d2c26e2dd2465530df94db2bdcde4c5106d..23f055d80acc71eb94a8214b7e2916695874db4f 100644 (file)
@@ -213,7 +213,7 @@ static rlm_rcode_t replicate_packet(UNUSED void const *instance, REQUEST *reques
                 *      Encode, sign and then send the packet.
                 */
                RDEBUG("Replicating %s list to Realm \"%s\"", fr_int2str(pair_lists, list, "<INVALID>"), realm->name);
-               if (fr_radius_send(packet, NULL, home->secret) < 0) {
+               if (fr_radius_packet_send(packet, NULL, home->secret) < 0) {
                        RPEDEBUG("Failed replicating packet");
                        rcode = RLM_MODULE_FAIL;
                        goto done;