From: Arran Cudbard-Bell Date: Thu, 8 Oct 2020 20:53:06 +0000 (-0500) Subject: Shorten fr_socket_addr_t to fr_socket_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7733337c3aa17cdf4cc6fa95445bc6241e430b34;p=thirdparty%2Ffreeradius-server.git Shorten fr_socket_addr_t to fr_socket_t --- diff --git a/src/lib/io/base.h b/src/lib/io/base.h index 4de6067f80c..45fe55d5e03 100644 --- a/src/lib/io/base.h +++ b/src/lib/io/base.h @@ -331,7 +331,7 @@ typedef int (*fr_io_close_t)(fr_listen_t *li); * Structures and definitions for the master IO handler. */ typedef struct { - fr_socket_addr_t socket; //!< src/dst ip and port. + fr_socket_t socket; //!< src/dst ip and port. RADCLIENT const *radclient; //!< old-style client definition } fr_io_address_t; diff --git a/src/lib/io/listen.h b/src/lib/io/listen.h index 0b34f860d3f..d5154e77630 100644 --- a/src/lib/io/listen.h +++ b/src/lib/io/listen.h @@ -30,7 +30,7 @@ struct fr_listen { void const *app_io_instance; //!< I/O path configuration context. void *thread_instance; //!< thread / socket context - fr_socket_addr_t *app_io_addr; //!< for tracking duplicate sockets + fr_socket_t *app_io_addr; //!< for tracking duplicate sockets fr_app_t const *app; void const *app_instance; diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index b0362ec1d18..18fd0e9b08f 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -204,8 +204,8 @@ struct fr_redis_cluster_node_s { //!< text for debug messages. uint8_t id; //!< Node ID (index in node array). - fr_socket_addr_t addr; //!< Current node address. - fr_socket_addr_t pending_addr; //!< New node address to be applied when the pool + fr_socket_t addr; //!< Current node address. + fr_socket_t pending_addr; //!< New node address to be applied when the pool //!< is reconnected. fr_redis_cluster_t *cluster; //!< Commmon configuration (database number, @@ -428,7 +428,7 @@ static fr_redis_cluster_rcode_t cluster_node_connect(fr_redis_cluster_t *cluster * - FR_REDIS_CLUSTER_RCODE_SUCCESS on success. * - FR_REDIS_CLUSTER_RCODE_BAD_INPUT if the server returned an invalid redirect. */ -static fr_redis_cluster_rcode_t cluster_node_conf_from_redirect(uint16_t *key_slot, fr_socket_addr_t *node_addr, +static fr_redis_cluster_rcode_t cluster_node_conf_from_redirect(uint16_t *key_slot, fr_socket_t *node_addr, redisReply *redirect) { char *p, *q; @@ -2025,7 +2025,7 @@ try_again: * - -1 if no such node exists. */ int fr_redis_cluster_pool_by_node_addr(fr_pool_t **pool, fr_redis_cluster_t *cluster, - fr_socket_addr_t *node_addr, bool create) + fr_socket_t *node_addr, bool create) { fr_redis_cluster_node_t find, *found; @@ -2083,7 +2083,7 @@ typedef struct { bool is_master; bool is_slave; uint8_t count; - fr_socket_addr_t *found; + fr_socket_t *found; } addr_by_role_ctx_t; /** Walk all used pools, recording the IP addresses of ones matching the filter @@ -2117,7 +2117,7 @@ static int _cluster_role_walk(void *data, void *uctx) * @param[in] is_slave If true, include the addresses of all the slaves nodes. * @return the number of ip addresses written to out. */ -ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_addr_t *out[], +ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_t *out[], fr_redis_cluster_t *cluster, bool is_master, bool is_slave) { addr_by_role_ctx_t context; @@ -2131,7 +2131,7 @@ ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_addr_t *ou context.is_master = is_master; context.is_slave = is_slave; context.count = 0; - context.found = talloc_zero_array(ctx, fr_socket_addr_t, in_use); + context.found = talloc_zero_array(ctx, fr_socket_t, in_use); if (!context.found) { fr_strerror_printf("Out of memory"); return -1; diff --git a/src/lib/redis/cluster.h b/src/lib/redis/cluster.h index 3d42aea7259..9ca1fa3cae7 100644 --- a/src/lib/redis/cluster.h +++ b/src/lib/redis/cluster.h @@ -119,8 +119,8 @@ fr_redis_rcode_t fr_redis_cluster_state_next(fr_redis_cluster_state_t *state, fr * or KEYS. */ int fr_redis_cluster_pool_by_node_addr(fr_pool_t **pool, fr_redis_cluster_t *cluster, - fr_socket_addr_t *node, bool create); -ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_addr_t *out[], + fr_socket_t *node, bool create); +ssize_t fr_redis_cluster_node_addr_by_role(TALLOC_CTX *ctx, fr_socket_t *out[], fr_redis_cluster_t *cluster, bool is_master, bool is_slave); /* diff --git a/src/lib/util/packet.h b/src/lib/util/packet.h index 7a9d1da4b7a..581fc97669a 100644 --- a/src/lib/util/packet.h +++ b/src/lib/util/packet.h @@ -54,7 +54,7 @@ extern "C" { * data,data_len: Used between fr_radius_recv and fr_radius_decode. */ typedef struct { - fr_socket_addr_t socket; //!< This packet was received on. + fr_socket_t socket; //!< This packet was received on. int id; //!< Packet ID (used to link requests/responses). unsigned int code; //!< Packet code (type). diff --git a/src/lib/util/socket.h b/src/lib/util/socket.h index 3d733ea4d15..6d86ce2f980 100644 --- a/src/lib/util/socket.h +++ b/src/lib/util/socket.h @@ -78,7 +78,7 @@ typedef struct { int proto; //!< Protocol. int fd; //!< File descriptor if this is a live socket. -} fr_socket_addr_t; +} fr_socket_t; /** Check the proto value is sane/supported * @@ -108,20 +108,20 @@ static inline bool fr_socket_is_inet(int proto) #define FR_SOCKET_ADDR_ALLOC_DEF_FUNC(_func, ...) \ { \ - fr_socket_addr_t *addr; \ - addr = talloc(ctx, fr_socket_addr_t); \ + fr_socket_t *addr; \ + addr = talloc(ctx, fr_socket_t); \ if (unlikely(!addr)) return NULL; \ return _func(addr, ##__VA_ARGS__); \ } -/** Swap src/dst information of a fr_socket_addr_t +/** Swap src/dst information of a fr_socket_t * * @param[out] dst Where to write the swapped addresses. May be the same as src. * @param[in] src Socket address to swap. */ -static inline void fr_socket_addr_swap(fr_socket_addr_t *dst, fr_socket_addr_t const *src) +static inline void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src) { - fr_socket_addr_t tmp = *src; + fr_socket_t tmp = *src; if (dst != src) *dst = tmp; @@ -142,7 +142,7 @@ static inline void fr_socket_addr_swap(fr_socket_addr_t *dst, fr_socket_addr_t c } } -/** Initialise a fr_socket_addr_t for connecting to a remote host using a specific src interface, address and port +/** Initialise a fr_socket_t for connecting to a remote host using a specific src interface, address and port * * Can also be used to record information from an incoming packet so that we can * identify the correct return path later. @@ -158,16 +158,16 @@ static inline void fr_socket_addr_swap(fr_socket_addr_t *dst, fr_socket_addr_t c * @param[in] dst_port The destination port of the packet. * @return * - NULL if invalid parameters are provided. - * - An initialised fr_socket_addr_t struct. + * - An initialised fr_socket_t struct. */ -static inline fr_socket_addr_t *fr_socket_addr_init_inet(fr_socket_addr_t *addr, +static inline fr_socket_t *fr_socket_addr_init_inet(fr_socket_t *addr, int proto, int ifindex, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port) { if (!fr_socket_is_inet(proto)) return NULL; - *addr = (fr_socket_addr_t){ + *addr = (fr_socket_t){ .proto = proto, .inet = { .ifindex = ifindex, @@ -181,13 +181,13 @@ static inline fr_socket_addr_t *fr_socket_addr_init_inet(fr_socket_addr_t *addr, return addr; } -static inline fr_socket_addr_t *fr_socket_addr_alloc_inet(TALLOC_CTX *ctx, int proto, +static inline fr_socket_t *fr_socket_addr_alloc_inet(TALLOC_CTX *ctx, int proto, int ifindex, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port) FR_SOCKET_ADDR_ALLOC_DEF_FUNC(fr_socket_addr_init_inet, proto, ifindex, src_ipaddr, src_port, dst_ipaddr, dst_port) -/** Initialise a fr_socket_addr_t for binding to a local socket +/** Initialise a fr_socket_t for binding to a local socket * * @param[out] addr to initialise. * @param[in] proto one of the IPPROTO_* macros, i.e. IPPROTO_TCP, IPPROTO_UDP @@ -198,14 +198,14 @@ FR_SOCKET_ADDR_ALLOC_DEF_FUNC(fr_socket_addr_init_inet, * @param[in] port The source port to bind to. * @return * - NULL if invalid parameters are provided. - * - An initialised fr_socket_addr_t struct. + * - An initialised fr_socket_t struct. */ -static inline fr_socket_addr_t *fr_socket_addr_init_inet_src(fr_socket_addr_t *addr, +static inline fr_socket_t *fr_socket_addr_init_inet_src(fr_socket_t *addr, int proto, int ifindex, fr_ipaddr_t const *ipaddr, int port) { if (!fr_socket_is_inet(proto)) return NULL; - *addr = (fr_socket_addr_t){ + *addr = (fr_socket_t){ .proto = proto, .inet = { .ifindex = ifindex, @@ -217,11 +217,11 @@ static inline fr_socket_addr_t *fr_socket_addr_init_inet_src(fr_socket_addr_t *a return addr; } -static inline fr_socket_addr_t *fr_socket_addr_alloc_inet_src(TALLOC_CTX *ctx, int proto, +static inline fr_socket_t *fr_socket_addr_alloc_inet_src(TALLOC_CTX *ctx, int proto, int ifindex, fr_ipaddr_t const *ipaddr, int port) FR_SOCKET_ADDR_ALLOC_DEF_FUNC(fr_socket_addr_init_inet_src, proto, ifindex, ipaddr, port) -/** Initialise a fr_socket_addr_t for connecting to a remote host +/** Initialise a fr_socket_t for connecting to a remote host * * @param[out] addr to initialise. * @param[in] proto one of the IPPROTO_* macros, i.e. IPPROTO_TCP, IPPROTO_UDP @@ -230,14 +230,14 @@ FR_SOCKET_ADDR_ALLOC_DEF_FUNC(fr_socket_addr_init_inet_src, proto, ifindex, ipad * @param[in] port The source port to bind to. * @return * - NULL if invalid parameters are provided. - * - An initialised fr_socket_addr_t struct. + * - An initialised fr_socket_t struct. */ -static inline fr_socket_addr_t *fr_socket_addr_init_inet_dst(fr_socket_addr_t *addr, +static inline fr_socket_t *fr_socket_addr_init_inet_dst(fr_socket_t *addr, int proto, fr_ipaddr_t const *ipaddr, int port) { if (!fr_socket_is_inet(proto)) return NULL; - *addr = (fr_socket_addr_t){ + *addr = (fr_socket_t){ .proto = proto, .inet = { .dst_ipaddr = *ipaddr, @@ -248,7 +248,7 @@ static inline fr_socket_addr_t *fr_socket_addr_init_inet_dst(fr_socket_addr_t *a return addr; } -static inline fr_socket_addr_t *fr_socket_addr_alloc_inet_dst(TALLOC_CTX *ctx, int proto, +static inline fr_socket_t *fr_socket_addr_alloc_inet_dst(TALLOC_CTX *ctx, int proto, fr_ipaddr_t const *ipaddr, int port) FR_SOCKET_ADDR_ALLOC_DEF_FUNC(fr_socket_addr_init_inet_dst, proto, ipaddr, port) diff --git a/src/modules/proto_bfd/proto_bfd.c b/src/modules/proto_bfd/proto_bfd.c index 533d7c9b05b..43c716b5aee 100644 --- a/src/modules/proto_bfd/proto_bfd.c +++ b/src/modules/proto_bfd/proto_bfd.c @@ -70,7 +70,7 @@ typedef enum bfd_auth_type_t { typedef struct { int number; - fr_socket_addr_t socket; + fr_socket_t socket; fr_event_list_t *el; CONF_SECTION *server_cs; diff --git a/src/modules/rlm_redis/rlm_redis.c b/src/modules/rlm_redis/rlm_redis.c index 7b1c8e30d0c..9ec99d900d3 100644 --- a/src/modules/rlm_redis/rlm_redis.c +++ b/src/modules/rlm_redis/rlm_redis.c @@ -164,7 +164,7 @@ static xlat_action_t redis_remap_xlat(TALLOC_CTX *ctx, fr_cursor_t *out, rlm_redis_t const *inst = talloc_get_type_abort_const(*((void const * const *)xlat_inst), rlm_redis_t); - fr_socket_addr_t node_addr; + fr_socket_t node_addr; fr_pool_t *pool; fr_redis_conn_t *conn; fr_redis_cluster_rcode_t rcode; @@ -322,7 +322,7 @@ static ssize_t redis_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, * Hack to allow querying against a specific node for testing */ if (p[0] == '@') { - fr_socket_addr_t node_addr; + fr_socket_t node_addr; fr_pool_t *pool; RDEBUG3("Overriding node selection"); diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c index ec0022906c8..802f94b1f93 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c @@ -718,7 +718,7 @@ static int8_t pool_cmp(void const *a, void const *b) */ static ssize_t driver_get_pools(TALLOC_CTX *ctx, uint8_t **out[], void *instance) { - fr_socket_addr_t *master; + fr_socket_t *master; size_t k; ssize_t ret, i, used = 0; fr_redis_conn_t *conn = NULL; diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index c9e7117a27d..883391388ad 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -96,7 +96,7 @@ void fr_request_from_reply(RADIUS_PACKET *request, * We need to keep track of the socket & it's IP/port. */ typedef struct { - fr_socket_addr_t socket; + fr_socket_t socket; int src_any; int dst_any;