MT#61140 call_delete_ng: add normal parsing

Add `call_ng_process_flags()` based parsing
as for other opmodes, like offer and answer.

This keeps the backwards compatibility with
the older "flags" parsing approach on the
module side, as well as adds the possibility
to parse rtpp-flags on the daemon side.

As an advantage, there is no need to use
specific local parsing for things like
to/from tags, call-id, delete-delay etc.

Additionally:
- this commit introduces flags-flags parsing
  for the "fatal" flag.
  However, as before is only taken into account
  by the `call_delete_ng()` processing,
  so no functional change.
- this commit introduces main-flags parsing
  for the "delete-delay" flag, which is also
  only taken into account by the `call_delete_ng()`
  processing, so no functional change.
- this commit adds To-tag options flag prasing
  into the `call_ng_flags_flags()` function,
  and is used by `call_delete_ng()` specificially,
  for cases when more specific identification of
  monologues to be deleted is used.

Change-Id: Ia992e5375a2f86318d9ad193a7857dd589038eed
(cherry picked from commit d31d49370f)
(cherry picked from commit 3793a29e92)
mr12.5.1
Donat Zenichev 1 year ago
parent d280fde953
commit 028c62e3d4

@ -1059,6 +1059,9 @@ void call_ng_flags_flags(sdp_ng_flags *out, str *s, helper_arg dummy) {
case CSH_LOOKUP("exclude-recording"):
out->exclude_recording = 1;
break;
case CSH_LOOKUP("fatal"):
out->fatal = 1;
break;
case CSH_LOOKUP("fragment"):
out->fragment = 1;
break;
@ -1186,6 +1189,11 @@ void call_ng_flags_flags(sdp_ng_flags *out, str *s, helper_arg dummy) {
case CSH_LOOKUP("symmetric-codecs"):
ilog(LOG_INFO, "Ignoring obsolete flag `symmetric-codecs`");
break;
case CSH_LOOKUP("to-tag"):
case CSH_LOOKUP("to_tag"):
/* including the “To” tag in the “delete” message allows to be more selective
* about monologues within a dialog to be torn down. */
out->to_tag_flag = 1;
case CSH_LOOKUP("trickle-ICE"):
case CSH_LOOKUP("trickle-ice"):
out->trickle_ice = 1;
@ -1302,6 +1310,7 @@ void call_ng_flags_init(sdp_ng_flags *out, enum call_opmode opmode) {
out->el_option = rtpe_config.endpoint_learning;
out->tos = 256;
out->delay_buffer = -1;
out->delete_delay = -1;
out->volume = 9999;
out->digit = -1;
out->frequencies = g_array_new(false, false, sizeof(int));
@ -1537,6 +1546,11 @@ void call_ng_main_flags(sdp_ng_flags *out, str *key, bencode_item_t *value,
case CSH_LOOKUP("db-id"):
out->db_id = bencode_get_integer_str(value, out->db_id);
break;
case CSH_LOOKUP("delete delay"):
case CSH_LOOKUP("delete-delay"):
case CSH_LOOKUP("delete_delay"):
out->delete_delay = bencode_get_integer_str(value, out->delete_delay);
break;
case CSH_LOOKUP("direction"):
call_ng_direction_flag(out, value);
break;
@ -2315,53 +2329,32 @@ const char *call_answer_ng(ng_buffer *ngbuf, bencode_item_t *input, bencode_item
}
const char *call_delete_ng(bencode_item_t *input, bencode_item_t *output) {
str fromtag, totag, viabranch, callid;
bencode_item_t *flags, *it;
bool fatal = false;
bool discard = false;
int delete_delay;
g_auto(sdp_ng_flags) rtpp_flags;
if (!bencode_dictionary_get_str(input, "call-id", &callid))
call_ng_process_flags(&rtpp_flags, input, OP_DELETE);
if (!rtpp_flags.call_id.len)
return "No call-id in message";
bencode_dictionary_get_str(input, "from-tag", &fromtag);
bencode_dictionary_get_str(input, "to-tag", &totag);
bencode_dictionary_get_str(input, "via-branch", &viabranch);
flags = bencode_dictionary_get_expect(input, "flags", BENCODE_LIST);
if (flags) {
for (it = flags->child; it; it = it->sibling) {
if (!bencode_strcmp(it, "fatal"))
fatal = true;
else if (!bencode_strcmp(it, "discard-recording"))
discard = true;
}
}
delete_delay = bencode_dictionary_get_int_str(input, "delete-delay", -1);
if (delete_delay == -1) {
delete_delay = bencode_dictionary_get_int_str(input, "delete delay", -1);
if (delete_delay == -1) {
/* legacy support */
str s;
bencode_dictionary_get_str(input, "delete-delay", &s);
if (s.s)
delete_delay = str_to_i(&s, -1);
}
}
call_t *c = call_get(&callid);
call_t *c = call_get(&rtpp_flags.call_id);
if (!c)
goto err;
if (discard)
if (rtpp_flags.discard_recording)
recording_discard(c);
if (call_delete_branch(c, &viabranch, &fromtag, &totag, output, delete_delay))
if (call_delete_branch(c, &rtpp_flags.via_branch,
&rtpp_flags.from_tag,
(rtpp_flags.to_tag_flag ? &rtpp_flags.to_tag : NULL),
output, rtpp_flags.delete_delay))
{
goto err;
}
return NULL;
err:
if (fatal)
if (rtpp_flags.fatal)
return "Call-ID not found or tags didn't match";
bencode_dictionary_add_string(output, "warning", "Call-ID not found or tags didn't match");
return NULL;

@ -128,6 +128,7 @@ struct sdp_ng_flags {
int trigger_end_ms;
int dtmf_delay;
int repeat_times;
int delete_delay;
str file;
str blob;
long long db_id;
@ -234,7 +235,10 @@ struct sdp_ng_flags {
disable_jb:1,
nat_wait:1,
pierce_nat:1,
directional:1;
directional:1,
fatal:1,
/* to_tag is used especially by delete handling */
to_tag_flag:1;
};

Loading…
Cancel
Save