]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move fd_info to client_info structure
authorAlan T. DeKok <aland@freeradius.org>
Wed, 15 May 2024 12:56:47 +0000 (08:56 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 15 May 2024 12:56:47 +0000 (08:56 -0400)
src/bin/radclient-ng.c
src/protocols/radius/client.c
src/protocols/radius/client.h
src/protocols/radius/client_priv.h

index 60ad50dc164b94b1ac75058f604f24fc362f853a..156c34cb7d38af53789573fa40cf7c4d52a40ad6 100644 (file)
@@ -83,10 +83,6 @@ static bool paused = false;
 
 static fr_bio_fd_config_t fd_config;
 
-static fr_bio_fd_info_t const *fd_info = NULL;
-
-static fr_bio_t *bio = NULL;
-
 static fr_radius_client_config_t client_config;
 
 static fr_bio_packet_t *client_bio = NULL;
@@ -887,9 +883,9 @@ error:
  */
 static int radclient_sane(rc_request_t *request)
 {
-       request->packet->socket.inet.src_ipaddr = fd_info->socket.inet.src_ipaddr;
-       request->packet->socket.inet.src_port = fd_info->socket.inet.src_port;
-       request->packet->socket.inet.ifindex = fd_info->socket.inet.ifindex;
+       request->packet->socket.inet.src_ipaddr = client_info->fd_info->socket.inet.src_ipaddr;
+       request->packet->socket.inet.src_port = client_info->fd_info->socket.inet.src_port;
+       request->packet->socket.inet.ifindex = client_info->fd_info->socket.inet.ifindex;
 
        if (request->packet->socket.inet.dst_port == 0) {
                request->packet->socket.inet.dst_port = fd_config.dst_port;
@@ -1684,12 +1680,6 @@ int main(int argc, char **argv)
        client_info = fr_radius_client_bio_info(client_bio);
        fr_assert(client_info != NULL);
 
-       bio = fr_radius_client_bio_get_fd(client_bio);
-       fr_assert(bio != NULL);
-
-       fd_info = fr_bio_fd_info(bio);
-       fr_assert(fd_info != NULL);
-
        if (forced_id >= 0) {
                if (fr_radius_client_bio_force_id(client_bio, packet_code, forced_id) < 0) {
                        fr_perror("radclient");
@@ -1715,7 +1705,7 @@ int main(int argc, char **argv)
         *
         *      Once the connect() passes, we start reading from the request list, and processing packets.
         */
-       if (fr_event_fd_insert(autofree, NULL, client_config.retry_cfg.el, fd_info->socket.fd, NULL,
+       if (fr_event_fd_insert(autofree, NULL, client_config.retry_cfg.el, client_info->fd_info->socket.fd, NULL,
                               client_connect, client_error, client_bio) < 0) {
                fr_perror("radclient");
                fr_exit_now(1);
@@ -1735,7 +1725,7 @@ int main(int argc, char **argv)
         ***********************************************************************/
        fr_dlist_talloc_free(&rc_request_list);
 
-       (void) fr_event_fd_delete(client_config.retry_cfg.el, fd_info->socket.fd, FR_EVENT_FILTER_IO);
+       (void) fr_event_fd_delete(client_config.retry_cfg.el, client_info->fd_info->socket.fd, FR_EVENT_FILTER_IO);
 
        fr_radius_global_free();
 
index adc2b29dd370cb2a73e879c07b1a0a850e45c528..3e22b799eba178b99282b42c6341531b38eb1e79 100644 (file)
@@ -90,12 +90,12 @@ fr_radius_client_fd_bio_t *fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t
         */
        my->fd->uctx = my;
 
-       my->fd_info = fr_bio_fd_info(my->fd);
-       fr_assert(my->fd_info != NULL);
+       my->info.fd_info = fr_bio_fd_info(my->fd);
+       fr_assert(my->info.fd_info != NULL);
 
-       my->reply_socket = my->fd_info->socket;
+       my->reply_socket = my->info.fd_info->socket;
        if ((my->reply_socket.af == AF_INET) || (my->reply_socket.af == AF_INET6)) {
-               fr_socket_addr_swap(&my->reply_socket, &my->fd_info->socket);
+               fr_socket_addr_swap(&my->reply_socket, &my->info.fd_info->socket);
        }
 
        my->mem = fr_bio_mem_alloc(my, read_size, 2 * 4096, my->fd);
@@ -114,7 +114,7 @@ fr_radius_client_fd_bio_t *fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t
        /*
         *      Set up the connected status.
         */
-       my->info.connected = (my->fd_info->type == FR_BIO_FD_CONNECTED) && (my->fd_info->state == FR_BIO_FD_STATE_OPEN);
+       my->info.connected = (my->info.fd_info->type == FR_BIO_FD_CONNECTED) && (my->info.fd_info->state == FR_BIO_FD_STATE_OPEN);
 
        talloc_set_destructor(my, _radius_client_fd_bio_free);
 
@@ -465,7 +465,7 @@ int fr_radius_client_bio_connect(fr_bio_packet_t *bio)
 
        if (my->info.connected) return 0;
 
-       switch (my->fd_info->type) {
+       switch (my->info.fd_info->type) {
        default:
                fr_strerror_const("Invalid RADIUS client bio for connect");
                return fr_bio_error(GENERIC);
@@ -477,7 +477,7 @@ int fr_radius_client_bio_connect(fr_bio_packet_t *bio)
                break;
        }
 
-       switch(my->fd_info->state) {
+       switch(my->info.fd_info->state) {
        case FR_BIO_FD_STATE_INVALID:
                fr_strerror_const("Invalid RADIUS client bio state");
                return fr_bio_error(GENERIC);
@@ -559,7 +559,5 @@ int fr_radius_client_bio_cb_set(fr_bio_packet_t *bio, fr_bio_packet_cb_funcs_t c
        SET(write_resume);
        SET(read_resume);
 
-       (void) fr_bio_cb_set(my->fd, &bio_cb);
-
-       return 0;
+       return fr_bio_cb_set(my->fd, &bio_cb);
 }
index cafde75784200c3b535d2e9d03baddf0df3b3e3d..7c0671444702df2067b19ca49bd9384de3c63b2b 100644 (file)
@@ -47,6 +47,8 @@ typedef struct {
        bool                    connected;
 
        size_t                  outstanding;
+
+       fr_bio_fd_info_t const  *fd_info;
 } fr_radius_client_bio_info_t;
 
 fr_bio_packet_t *fr_radius_client_bio_alloc(TALLOC_CTX *ctx, fr_radius_client_config_t *cfg, fr_bio_fd_config_t const *fd_cfg) CC_HINT(nonnull);
index c2e6580f95ba0ae7436cc366dcc8ca0e95f301dd..011e4b0bb40e000c9319406e3679a29797cae228 100644 (file)
@@ -38,7 +38,6 @@ typedef struct {
 
        fr_radius_code_id_t     codes;
 
-       fr_bio_fd_info_t const  *fd_info;
        fr_socket_t             reply_socket;
 
        fr_bio_t                *retry;