MT#55283 update interface config queue to typed

Change-Id: I4fbd0385be7b63cc33516bd53fadde54b65e15b6
rfuchs/dataport
Richard Fuchs 2 years ago
parent 6d4ffb8ceb
commit 5e6d4cf6a3

@ -283,7 +283,6 @@ static void cli_endpoints_print(struct cli_writer *cw, const GQueue *q, const ch
static void cli_incoming_params_start(str *instr, struct cli_writer *cw) {
int count = 0;
GList *s;
struct intf_config *ifa;
for (unsigned int i = 0; i < num_log_levels; i++)
@ -317,13 +316,13 @@ static void cli_incoming_params_start(str *instr, struct cli_writer *cw) {
initial_rtpe_config.bw_limit,
initial_rtpe_config.max_recv_iters);
for(s = initial_rtpe_config.interfaces.head; s ; s = s->next) {
for (__auto_type s = initial_rtpe_config.interfaces.head; s ; s = s->next) {
ifa = s->data;
cw->cw_printf(cw,"interface[%d] = %s\\%s \n", count, ifa->name.s, sockaddr_print_buf(&(ifa->local_address.addr)));
++count;
}
count=0;
for (s = initial_rtpe_config.redis_subscribed_keyspaces.head; s ; s = s->next) {
for (__auto_type s = initial_rtpe_config.redis_subscribed_keyspaces.head; s ; s = s->next) {
cw->cw_printf(cw,"keyspace[%d] = %d \n", count, GPOINTER_TO_UINT(s->data));
++count;
}
@ -340,7 +339,6 @@ static void cli_incoming_params_start(str *instr, struct cli_writer *cw) {
static void cli_incoming_params_current(str *instr, struct cli_writer *cw) {
int count = 0;
GList *c;
struct intf_config *ifa;
for (unsigned int i = 0; i < num_log_levels; i++)
@ -371,13 +369,13 @@ static void cli_incoming_params_current(str *instr, struct cli_writer *cw) {
rtpe_config.bw_limit,
rtpe_config.max_recv_iters);
for(c = rtpe_config.interfaces.head; c ; c = c->next) {
for (__auto_type c = rtpe_config.interfaces.head; c ; c = c->next) {
ifa = c->data;
cw->cw_printf(cw,"interface[%d] = %s\\%s \n", count, ifa->name.s, sockaddr_print_buf(&(ifa->local_address.addr)));
++count;
}
count=0;
for (c = rtpe_config.redis_subscribed_keyspaces.head; c ; c = c->next) {
for (__auto_type c = rtpe_config.redis_subscribed_keyspaces.head; c ; c = c->next) {
cw->cw_printf(cw,"keyspace[%d] = %d \n", count, GPOINTER_TO_UINT(c->data));
++count;
}

@ -87,7 +87,7 @@ struct rtpengine_config rtpe_config = {
.delete_delay = 30,
.redis_subscribed_keyspaces = G_QUEUE_INIT,
.redis_expires_secs = 86400,
.interfaces = G_QUEUE_INIT,
.interfaces = TYPED_GQUEUE_INIT,
.homer_protocol = SOCK_DGRAM,
.homer_id = 2001,
.homer_ng_capt_proto = 0x3d, // first available value in HEP proto specification
@ -268,7 +268,7 @@ static void __resolve_ifname(char *s, GQueue *addrs) {
freeaddrinfo(res);
}
static int if_addr_parse(GQueue *q, char *s, struct ifaddrs *ifas) {
static int if_addr_parse(intf_config_q *q, char *s, struct ifaddrs *ifas) {
str name;
char *c;
sockaddr_t *addr, adv;
@ -342,7 +342,7 @@ static int if_addr_parse(GQueue *q, char *s, struct ifaddrs *ifas) {
ifa->name_rr_spec = ifa->name;
str_token(&ifa->name_base, &ifa->name_rr_spec, ':'); // sets name_rr_spec to null string if no ':' found
g_queue_push_tail(q, ifa);
t_queue_push_tail(q, ifa);
g_slice_free1(sizeof(*addr), addr);
}
@ -1067,18 +1067,17 @@ static void options(int *argc, char ***argv) {
static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
GList* l;
struct intf_config* gptr_data;
for(l = rtpe_config.interfaces.head; l ; l=l->next) {
for (__auto_type l = rtpe_config.interfaces.head; l ; l=l->next) {
gptr_data = g_slice_alloc0(sizeof(*gptr_data));
memcpy(gptr_data, (struct intf_config*)(l->data), sizeof(*gptr_data));
str_init_dup(&gptr_data->name, ((struct intf_config*)(l->data))->name.s);
memcpy(gptr_data, l->data, sizeof(*gptr_data));
str_init_dup_str(&gptr_data->name, &l->data->name);
g_queue_push_tail(&ini_rtpe_cfg->interfaces, gptr_data);
t_queue_push_tail(&ini_rtpe_cfg->interfaces, gptr_data);
}
for(l = rtpe_config.redis_subscribed_keyspaces.head; l ; l = l->next) {
for (__auto_type l = rtpe_config.redis_subscribed_keyspaces.head; l ; l = l->next) {
// l->data has been assigned to a variable before being given into the queue structure not to get a shallow copy
unsigned int num = GPOINTER_TO_UINT(l->data);
g_queue_push_tail(&ini_rtpe_cfg->redis_subscribed_keyspaces, GINT_TO_POINTER(num));
@ -1147,18 +1146,14 @@ static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
ini_rtpe_cfg->max_recv_iters = rtpe_config.max_recv_iters;
}
static void
free_config_interfaces (gpointer data)
{
struct intf_config* gptr_data = data;
str_free_dup(&gptr_data->name);
g_slice_free1(sizeof(*gptr_data), gptr_data);
static void free_config_interfaces(struct intf_config *i) {
str_free_dup(&i->name);
g_slice_free1(sizeof(*i), i);
}
static void unfill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
// clear queues
g_queue_clear_full(&ini_rtpe_cfg->interfaces, (GDestroyNotify)free_config_interfaces);
t_queue_clear_full(&ini_rtpe_cfg->interfaces, free_config_interfaces);
g_queue_clear(&ini_rtpe_cfg->redis_subscribed_keyspaces);
// free g_strdup
@ -1173,7 +1168,7 @@ static void unfill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
static void options_free(void) {
// clear queues
g_queue_clear_full(&rtpe_config.interfaces, (GDestroyNotify)free_config_interfaces);
t_queue_clear_full(&rtpe_config.interfaces, free_config_interfaces);
g_queue_clear(&rtpe_config.redis_subscribed_keyspaces);
// free config options

@ -815,9 +815,8 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool
}
// called during single-threaded startup only
void interfaces_init(GQueue *interfaces) {
void interfaces_init(intf_config_q *interfaces) {
int i;
GList *l;
struct intf_config *ifa;
sockfamily_t *fam;
@ -831,7 +830,7 @@ void interfaces_init(GQueue *interfaces) {
g_queue_init(&__preferred_lists_for_family[i]);
/* build primary lists first */
for (l = interfaces->head; l; l = l->next) {
for (__auto_type l = interfaces->head; l; l = l->next) {
ifa = l->data;
__interface_append(ifa, ifa->local_address.addr.family, true);
}
@ -839,7 +838,7 @@ void interfaces_init(GQueue *interfaces) {
/* then append to each other as lower-preference alternatives */
for (i = 0; i < __SF_LAST; i++) {
fam = get_socket_family_enum(i);
for (l = interfaces->head; l; l = l->next) {
for (__auto_type l = interfaces->head; l; l = l->next) {
ifa = l->data;
if (ifa->local_address.addr.family == fam)
continue;

@ -6,6 +6,7 @@
#include "helpers.h"
#include "socket.h"
#include "auxlib.h"
#include "types.h"
enum xmlrpc_format {
XF_SEMS = 0,
@ -59,7 +60,7 @@ struct rtpengine_config {
int graphite_interval;
int graphite_timeout;
int redis_num_threads;
GQueue interfaces;
intf_config_q interfaces;
GQueue tcp_listen_ep;
GQueue udp_listen_ep;
GQueue ng_listen_ep;

@ -261,7 +261,7 @@ extern GQueue all_local_interfaces; // read-only during runtime
extern __thread struct bufferpool *media_bufferpool;
void interfaces_init(GQueue *interfaces);
void interfaces_init(intf_config_q *interfaces);
void interfaces_free(void);
struct logical_intf *get_logical_interface(const str *name, sockfamily_t *fam, int num_ports);

@ -55,4 +55,7 @@ TYPED_GQUEUE(call, call_t)
struct sdp_attr;
TYPED_GQUEUE(sdp_attr, struct sdp_attr)
struct intf_config;
TYPED_GQUEUE(intf_config, struct intf_config)
#endif

Loading…
Cancel
Save