diff --git a/daemon/cli.c b/daemon/cli.c index d3e20cb42..673782008 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -1749,8 +1749,7 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct cli_writer *cw, } static void cli_incoming_list_interfaces(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { - for (__auto_type l = all_local_interfaces.head; l; l = l->next) { - struct local_intf *lif = l->data; + IQUEUE_FOREACH(&all_local_interfaces, lif) { // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) continue; diff --git a/daemon/graphite.c b/daemon/graphite.c index e526f6775..052a00ff4 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -172,8 +172,7 @@ GString *print_graphite_data(void) { GPF("timeout_sess %" PRIu64, atomic64_get_na(&rtpe_stats_graphite_diff.timeout_sess)); GPF("reject_sess %" PRIu64, atomic64_get_na(&rtpe_stats_graphite_diff.rejected_sess)); - for (__auto_type l = all_local_interfaces.head; l; l = l->next) { - struct local_intf *lif = l->data; + IQUEUE_FOREACH(&all_local_interfaces, lif) { // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) continue; diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 931af1765..5143b7400 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -442,7 +442,7 @@ static intf_spec_ht __intf_spec_addr_type_hash; static local_intf_ht __local_intf_addr_type_hash; static logical_intf_q __preferred_lists_for_family[__SF_LAST]; -local_intf_q all_local_interfaces = TYPED_GQUEUE_INIT; +all_local_intf_q all_local_interfaces = IQUEUE_INIT; TYPED_GHASHTABLE(local_sockets_ht, endpoint_t, stream_fd, endpoint_hash, endpoint_eq, NULL, stream_fd_put) static rwlock_t local_media_socket_endpoints_lock = RWLOCK_STATIC_INIT; @@ -989,7 +989,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool ifc->logical = lif; ifc->stats = bufferpool_alloc0(static_bufferpool, sizeof(*ifc->stats)); - t_queue_push_tail(&all_local_interfaces, ifc); + i_queue_push_tail(&all_local_interfaces, ifc); __insert_local_intf_addr_type(&spec->local_address, ifc); __insert_local_intf_addr_type(&ifc->advertised_address, ifc); @@ -1031,8 +1031,7 @@ void interfaces_init(intf_config_q *interfaces) { } void interfaces_exclude_port(endpoint_t *e) { - for (__auto_type l = all_local_interfaces.head; l; l = l->next) { - __auto_type ifa = l->data; + IQUEUE_FOREACH(&all_local_interfaces, ifa) { __auto_type spec = ifa->spec; if (e->address.family != spec->local_address.addr.family) continue; @@ -4179,7 +4178,7 @@ void play_buffered(struct jb_packet *cp) { void interfaces_free(void) { struct local_intf *ifc; - while ((ifc = t_queue_pop_head(&all_local_interfaces))) { + while ((ifc = i_queue_pop_head(&all_local_interfaces))) { free(ifc->ice_foundation.s); bufferpool_unref(ifc->stats); } @@ -4296,8 +4295,7 @@ const str *resolve_interface_from_peer_ip(const str *peer_ip) { close_socket(&sock); /* find first matching interface (loop preserves config ordering) */ - for (__auto_type l = all_local_interfaces.head; l; l = l->next) { - struct local_intf *lif = l->data; + IQUEUE_FOREACH(&all_local_interfaces, lif) { if (sockaddr_eq(&local_addr, &lif->spec->local_address.addr)) return &lif->logical->name; } diff --git a/daemon/statistics.c b/daemon/statistics.c index 7960e9749..cfc211ae3 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -681,8 +681,7 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i HEADER("interfaces", NULL); HEADER("[", NULL); - for (__auto_type l = all_local_interfaces.head; l; l = l->next) { - struct local_intf *lif = l->data; + IQUEUE_FOREACH(&all_local_interfaces, lif) { // only show first-order interface entries: socket families must match if (lif->logical->preferred_family != lif->spec->local_address.addr.family) continue; diff --git a/include/media_socket.h b/include/media_socket.h index 9f3019a58..7817118b5 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -183,6 +183,7 @@ struct interface_stats_block *interface_sampled_rate_stats_get(struct interface_ struct local_intf *lif, int64_t *time_diff_us); struct local_intf { + IQUEUE_LINK glob_link; struct intf_spec *spec; struct intf_address advertised_address; unsigned int unique_id; /* starting with 0 - serves as preference */ @@ -201,6 +202,7 @@ struct sfd_intf_list { }; TYPED_GQUEUE(socket_intf_list, struct socket_intf_list) /* RO */ TYPED_GQUEUE(sfd_intf_list, struct sfd_intf_list) +typedef IQUEUE(struct local_intf, glob_link) all_local_intf_q; /** * stream_fd is an entry-point object for RTP packets handling, @@ -381,7 +383,7 @@ rtp_ext_handler rtp_extension_get_handler(const str *); extern struct rtp_extension media_rtp_ext_mid; -extern local_intf_q all_local_interfaces; // read-only during runtime +extern all_local_intf_q all_local_interfaces; // read-only during runtime extern __thread struct bufferpool *media_bufferpool;