From 41966c9648066879759fdb8895dce9b2d12e6929 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 4 Oct 2021 09:43:19 -0400 Subject: [PATCH] TT#14008 associate interface with call_monologue This makes it possible to add new streams without specifying the direction/interface again. Reported in #1366 Change-Id: I8f320ecbe72f123d755ba80370de9c40960eb0f0 --- daemon/call.c | 14 ++++---------- daemon/redis.c | 9 +++++++++ include/call.h | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 27c1da265..a58c32caa 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1916,9 +1916,8 @@ static void __tos_change(struct call *call, const struct sdp_ng_flags *flags) { } static void __init_interface(struct call_media *media, const str *ifname, int num_ports) { - /* we're holding master_lock in W mode here, so we can safely ignore the - * atomic ops */ - + if (!media->logical_intf && media->monologue) + media->logical_intf = media->monologue->logical_intf; if (!media->logical_intf) goto get; if (media->logical_intf->preferred_family != media->desired_family) @@ -1946,13 +1945,8 @@ get: media->logical_intf = get_logical_interface(NULL, NULL, 0); } } -// media->local_intf = ifa = get_interface_address(media->logical_intf, media->desired_family); -// if (!ifa) { -// ilog(LOG_WARNING, "No usable address in interface '"STR_FORMAT"' found, using default", -// STR_FMT(ifname)); -// media->local_intf = ifa = get_any_interface_address(media->logical_intf, media->desired_family); -// media->desired_family = ifa->spec->address.addr.family; -// } + if (media->monologue) + media->monologue->logical_intf = media->logical_intf; } diff --git a/daemon/redis.c b/daemon/redis.c index e06450f25..8ad50511e 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1426,6 +1426,13 @@ static int redis_tags(struct call *c, struct redis_list *tags, JsonReader *root_ if (!redis_hash_get_int(&ii, rh, "block_media")) ml->block_media = ii ? 1 : 0; + if (redis_hash_get_str(&s, rh, "logical_intf") + || !(ml->logical_intf = get_logical_interface(&s, NULL, 0))) + { + rlog(LOG_ERR, "unable to find specified local interface"); + ml->logical_intf = get_logical_interface(NULL, NULL, 0); + } + if (json_build_ssrc(ml, root_reader)) return -1; @@ -2329,6 +2336,8 @@ char* redis_encode_json(struct call *c) { JSON_SET_SIMPLE("deleted","%llu",(long long unsigned) ml->deleted); JSON_SET_SIMPLE("block_dtmf","%i",ml->block_dtmf ? 1 : 0); JSON_SET_SIMPLE("block_media","%i",ml->block_media ? 1 : 0); + if (ml->logical_intf) + JSON_SET_SIMPLE_STR("logical_intf", &ml->logical_intf->name); if (ml->tag.s) JSON_SET_SIMPLE_STR("tag",&ml->tag); diff --git a/include/call.h b/include/call.h index 0cbf79769..04358dca0 100644 --- a/include/call.h +++ b/include/call.h @@ -413,6 +413,7 @@ struct call_monologue { struct timeval started; /* for CDR */ struct timeval terminated; /* for CDR */ enum termination_reason term_reason; + const struct logical_intf *logical_intf; GHashTable *other_tags; GHashTable *branches; GQueue subscriptions; // who am I subscribed to (sources)