]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Shorten fr_socket_addr_t to fr_socket_t
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 8 Oct 2020 20:53:06 +0000 (15:53 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 8 Oct 2020 20:53:06 +0000 (15:53 -0500)
src/lib/io/base.h
src/lib/io/listen.h
src/lib/redis/cluster.c
src/lib/redis/cluster.h
src/lib/util/packet.h
src/lib/util/socket.h
src/modules/proto_bfd/proto_bfd.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c
src/protocols/radius/list.c

index 4de6067f80cbe7659c0a889637d18dadb8b42b33..45fe55d5e031809ec151a7a7eaca6ddfd56bce31 100644 (file)
@@ -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;
index 0b34f860d3fc7a5807d78f9549111c6abf54f7cd..d5154e7763052acac5ee56461b81a6a042de5003 100644 (file)
@@ -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;
index b0362ec1d18afc2b909d5d0384dae4f4877fa034..18fd0e9b08fd50b681a3da067604ccd3960cde60 100644 (file)
@@ -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;
index 3d42aea72595e3c938d7717d97a91f78cf4cbbe4..9ca1fa3cae7778b0ad95bd2e5eb4bc300bcee8d8 100644 (file)
@@ -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);
 
 /*
index 7a9d1da4b7a5b2d84b7d90d8dd5697fe78fa097b..581fc97669a273a0d258c8a85ff0a9598d0b5155 100644 (file)
@@ -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).
index 3d733ea4d158004437b6e3b9a59828e775f0ee46..6d86ce2f98067206e560b59962f4ef76245dfc4e 100644 (file)
@@ -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)
 
index 533d7c9b05b05d3cecb24e0ec0707165e24de4a7..43c716b5aeedf044aa5c3339745106d9d5fa24fb 100644 (file)
@@ -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;
index 7b1c8e30d0c64e1448796e04c8019cdfbc64f89f..9ec99d900d387584dc729b2707dc92a99c359634 100644 (file)
@@ -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");
index ec0022906c8a206f6691f3a255b4bc5747a550cf..802f94b1f937000ecff3204891d7c740d42ad0d9 100644 (file)
@@ -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;
index c9e7117a27dff2f96ca32535f7a27e898e36ddd0..883391388ad682e643136081fbee636633bc8af1 100644 (file)
@@ -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;