diff --git a/debian/patches/debian/fix_export.patch b/debian/patches/debian/fix_export.patch index d8fe9752f..69021c7e3 100644 --- a/debian/patches/debian/fix_export.patch +++ b/debian/patches/debian/fix_export.patch @@ -7,7 +7,7 @@ Subject: fix_export 1 file changed, 2 insertions(+) diff --git a/src/Makefile b/src/Makefile -index 23a5235..14cc0d7 100644 +index 40def34..3c8dcda 100644 --- a/src/Makefile +++ b/src/Makefile @@ -139,6 +139,8 @@ endif diff --git a/debian/patches/debian/no_INSTALL_file.patch b/debian/patches/debian/no_INSTALL_file.patch index a88adefc9..0ee8eacdc 100644 --- a/debian/patches/debian/no_INSTALL_file.patch +++ b/debian/patches/debian/no_INSTALL_file.patch @@ -7,7 +7,7 @@ Subject: no_INSTALL_file 1 file changed, 2 deletions(-) diff --git a/src/Makefile b/src/Makefile -index 11be15f..23a5235 100644 +index a6380c2..40def34 100644 --- a/src/Makefile +++ b/src/Makefile @@ -861,8 +861,6 @@ install-modules-all: install-every-module install-every-module-doc diff --git a/debian/patches/debian/no_lib64_on_64_bits.patch b/debian/patches/debian/no_lib64_on_64_bits.patch index f71384ed9..c4306023b 100644 --- a/debian/patches/debian/no_lib64_on_64_bits.patch +++ b/debian/patches/debian/no_lib64_on_64_bits.patch @@ -7,7 +7,7 @@ Subject: no_lib64_on_64_bits 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Makefile.defs b/src/Makefile.defs -index 18afd9c..f47160e 100644 +index 5fdc880..4833e85 100644 --- a/src/Makefile.defs +++ b/src/Makefile.defs @@ -454,15 +454,7 @@ endif diff --git a/debian/patches/series b/debian/patches/series index a043710d4..b1e238c2a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -32,12 +32,9 @@ sipwise/sca-debug.patch sipwise/sca-fix-notify-after-bye.patch sipwise/sca-add-pai_avp-parameter.patch ## upstream 5.5 -upstream/presence-info-logs-instead-of-error-for-not-maching-.patch -upstream/db_redis-don-t-leave-unconsumed-redis-replies-in-cas.patch # https://github.com/kamailio/kamailio/pull/979 # collides with our changes to pua_dialoginfo sipwise/Revert-pua_dialoginfo-disable-publish-notifications-.patch -upstream/pv_headers-restore-pvh_real_hdr_del_by_name.patch ## upstream master upstream/lcr-source-port-check-for-from_any_gw-and-from_gw.patch upstream/lcr-remove-excessive-checks-for-the-src_port-accurac.patch diff --git a/debian/patches/sipwise/db_redis_graceful_scan.patch b/debian/patches/sipwise/db_redis_graceful_scan.patch index 42dbe2b02..c19e30bcd 100644 --- a/debian/patches/sipwise/db_redis_graceful_scan.patch +++ b/debian/patches/sipwise/db_redis_graceful_scan.patch @@ -7,7 +7,7 @@ Subject: db_redis_graceful_scan 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c -index 1b0c72e..d088b89 100644 +index 68d8412..c82f82b 100644 --- a/src/modules/db_redis/redis_dbase.c +++ b/src/modules/db_redis/redis_dbase.c @@ -754,7 +754,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con, const str *matc diff --git a/debian/patches/sipwise/db_redis_skip_empty_keys.patch b/debian/patches/sipwise/db_redis_skip_empty_keys.patch index d8c09a457..6a3cb508d 100644 --- a/debian/patches/sipwise/db_redis_skip_empty_keys.patch +++ b/debian/patches/sipwise/db_redis_skip_empty_keys.patch @@ -7,7 +7,7 @@ Subject: db_redis_skip_empty_keys 1 file changed, 3 insertions(+) diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c -index c9a25ad..1b0c72e 100644 +index ac1bd2b..68d8412 100644 --- a/src/modules/db_redis/redis_dbase.c +++ b/src/modules/db_redis/redis_dbase.c @@ -641,6 +641,9 @@ static int db_redis_build_query_keys(km_redis_con_t *con, const str *table_name, diff --git a/debian/patches/sipwise/db_redis_sscan.patch b/debian/patches/sipwise/db_redis_sscan.patch index e9cf7d7f2..74463b92e 100644 --- a/debian/patches/sipwise/db_redis_sscan.patch +++ b/debian/patches/sipwise/db_redis_sscan.patch @@ -7,7 +7,7 @@ Subject: db_redis_sscan 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c -index d088b89..11188c4 100644 +index c82f82b..dd11ad5 100644 --- a/src/modules/db_redis/redis_dbase.c +++ b/src/modules/db_redis/redis_dbase.c @@ -591,7 +591,7 @@ err: @@ -174,7 +174,7 @@ index d088b89..11188c4 100644 LM_ERR("failed to scan query keys\n"); goto error; } -@@ -2298,6 +2327,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, +@@ -2300,6 +2329,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, int do_table_scan = 0; uint64_t ts_scan_start = 0; str ts_scan_key = {0,}; @@ -182,7 +182,7 @@ index d088b89..11188c4 100644 redis_key_t *keys = NULL; int keys_count = 0; -@@ -2369,7 +2399,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, +@@ -2371,7 +2401,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, if (_n > 0) { if (db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n, &keys, &keys_count, &manual_keys, &manual_keys_count, &do_table_scan, &ts_scan_start, @@ -191,7 +191,7 @@ index d088b89..11188c4 100644 LM_ERR("failed to build query keys\n"); goto error; } -@@ -2387,7 +2417,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, +@@ -2389,7 +2419,7 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, } if (db_redis_perform_query(_h, con, _k, _v, query_ops, _c, _n, _nc, _r, @@ -200,7 +200,7 @@ index d088b89..11188c4 100644 goto error; } -@@ -2403,6 +2433,8 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, +@@ -2405,6 +2435,8 @@ int db_redis_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, } if (ts_scan_key.s) pkg_free(ts_scan_key.s); @@ -209,7 +209,7 @@ index d088b89..11188c4 100644 db_redis_consume_replies(con); return 0; -@@ -2418,6 +2450,8 @@ error: +@@ -2420,6 +2452,8 @@ error: } if (ts_scan_key.s) pkg_free(ts_scan_key.s); @@ -218,7 +218,7 @@ index d088b89..11188c4 100644 db_redis_consume_replies(con); -@@ -2603,6 +2637,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, +@@ -2605,6 +2639,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, int do_table_scan = 0; uint64_t ts_scan_start = 0; str ts_scan_key = {0,}; @@ -226,7 +226,7 @@ index d088b89..11188c4 100644 db_op_t *query_ops = NULL; int i; -@@ -2648,7 +2683,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, +@@ -2650,7 +2685,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, if (_n > 0) { if (db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n, &keys, &keys_count, &manual_keys, &manual_keys_count, &do_table_scan, &ts_scan_start, @@ -235,7 +235,7 @@ index d088b89..11188c4 100644 LM_ERR("failed to build query keys\n"); goto error; } -@@ -2666,7 +2701,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, +@@ -2668,7 +2703,7 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, } if (db_redis_perform_delete(_h, con, _k, _v, query_ops, _n, @@ -244,7 +244,7 @@ index d088b89..11188c4 100644 goto error; } -@@ -2680,6 +2715,8 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, +@@ -2682,6 +2717,8 @@ int db_redis_delete(const db1_con_t* _h, const db_key_t* _k, pkg_free(manual_keys); if (ts_scan_key.s) pkg_free(ts_scan_key.s); @@ -253,7 +253,7 @@ index d088b89..11188c4 100644 db_redis_consume_replies(con); return 0; -@@ -2694,6 +2731,8 @@ error: +@@ -2696,6 +2733,8 @@ error: pkg_free(manual_keys); if (ts_scan_key.s) pkg_free(ts_scan_key.s); @@ -262,7 +262,7 @@ index d088b89..11188c4 100644 db_redis_consume_replies(con); return -1; } -@@ -2718,6 +2757,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, +@@ -2720,6 +2759,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, int do_table_scan = 0; uint64_t ts_scan_start = 0; str ts_scan_key = {0,}; @@ -270,7 +270,7 @@ index d088b89..11188c4 100644 redis_key_t *keys = NULL; int keys_count = 0; -@@ -2768,7 +2808,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, +@@ -2770,7 +2810,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, if (_n > 0) { if (db_redis_build_query_keys(con, CON_TABLE(_h), _k, _v, query_ops, _n, &keys, &keys_count, &manual_keys, &manual_keys_count, &do_table_scan, &ts_scan_start, @@ -279,7 +279,7 @@ index d088b89..11188c4 100644 LM_ERR("failed to build query keys\n"); goto error; } -@@ -2785,7 +2825,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, +@@ -2787,7 +2827,7 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, } if (db_redis_perform_update(_h, con, _k, _v, query_ops, _uk, _uv, _n, _nu, @@ -288,7 +288,7 @@ index d088b89..11188c4 100644 goto error; } -@@ -2801,6 +2841,8 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, +@@ -2803,6 +2843,8 @@ int db_redis_update(const db1_con_t* _h, const db_key_t* _k, } if (ts_scan_key.s) pkg_free(ts_scan_key.s); @@ -297,7 +297,7 @@ index d088b89..11188c4 100644 db_redis_consume_replies(con); return 0; -@@ -2815,6 +2857,8 @@ error: +@@ -2817,6 +2859,8 @@ error: } if (ts_scan_key.s) pkg_free(ts_scan_key.s); diff --git a/debian/patches/sipwise/db_redis_sscan_fix_empty_key.patch b/debian/patches/sipwise/db_redis_sscan_fix_empty_key.patch index cd0cf6fbf..bf3d2a04a 100644 --- a/debian/patches/sipwise/db_redis_sscan_fix_empty_key.patch +++ b/debian/patches/sipwise/db_redis_sscan_fix_empty_key.patch @@ -7,7 +7,7 @@ Subject: db_redis_sscan_fix_empty_key 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c -index 11188c4..5258d57 100644 +index dd11ad5..ffe6ad7 100644 --- a/src/modules/db_redis/redis_dbase.c +++ b/src/modules/db_redis/redis_dbase.c @@ -784,7 +784,7 @@ static int db_redis_scan_query_keys_pattern(km_redis_con_t *con, const str *matc diff --git a/debian/patches/sipwise/do-not-install-default-config.patch b/debian/patches/sipwise/do-not-install-default-config.patch index 15c3e7d60..9af453a83 100644 --- a/debian/patches/sipwise/do-not-install-default-config.patch +++ b/debian/patches/sipwise/do-not-install-default-config.patch @@ -8,7 +8,7 @@ Subject: do-not-install-default-config 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile -index 14cc0d7..0e37b95 100644 +index 3c8dcda..7a8a402 100644 --- a/src/Makefile +++ b/src/Makefile @@ -652,7 +652,7 @@ sunpkg: diff --git a/debian/patches/sipwise/lcr-stopper_mode-parameter.patch b/debian/patches/sipwise/lcr-stopper_mode-parameter.patch index a445590d5..eed670be5 100644 --- a/debian/patches/sipwise/lcr-stopper_mode-parameter.patch +++ b/debian/patches/sipwise/lcr-stopper_mode-parameter.patch @@ -10,7 +10,7 @@ but will sort them first before stopping 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 579ec06..0565044 100644 +index fb85f5b..15e62bc 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c @@ -205,6 +205,10 @@ static unsigned int priority_ordering_param = 0; @@ -24,7 +24,7 @@ index 579ec06..0565044 100644 /* * Other module types and variables */ -@@ -351,6 +355,7 @@ static param_export_t params[] = { +@@ -357,6 +361,7 @@ static param_export_t params[] = { {"ping_valid_reply_codes", PARAM_STR, &ping_valid_reply_codes_param}, {"ping_from", PARAM_STR, &ping_from_param}, {"ping_socket", PARAM_STR, &ping_socket_param}, @@ -32,7 +32,7 @@ index 579ec06..0565044 100644 {0, 0, 0} }; -@@ -2201,6 +2206,8 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri, +@@ -2227,6 +2232,8 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri, matched_gws[gw_index].priority = t->priority; matched_gws[gw_index].weight = t->weight * (kam_rand() >> 8); matched_gws[gw_index].duplicate = 0; @@ -41,7 +41,7 @@ index 579ec06..0565044 100644 LM_DBG("added matched_gws[%d]=[%u, %u, %u, %u]\n", gw_index, t->gw_index, pl->prefix_len, t->priority, matched_gws[gw_index].weight); -@@ -2208,8 +2215,10 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri, +@@ -2234,8 +2241,10 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri, skip_gw: t = t->next; } @@ -53,7 +53,7 @@ index 579ec06..0565044 100644 next: rule = rule->next; -@@ -2236,6 +2245,11 @@ done: +@@ -2262,6 +2271,11 @@ done: if(matched_gws[i].duplicate == 1) continue; gw_indexes[j] = matched_gws[i].gw_index; @@ -65,7 +65,7 @@ index 579ec06..0565044 100644 j++; } -@@ -2251,7 +2265,7 @@ static int ki_load_gws_furi( +@@ -2277,7 +2291,7 @@ static int ki_load_gws_furi( { str *request_uri; int i, j; @@ -74,7 +74,7 @@ index 579ec06..0565044 100644 int_str val; struct matched_gw_info matched_gws[MAX_NO_OF_GWS + 1]; struct rule_info **rules, *rule, *pl; -@@ -2366,6 +2380,8 @@ static int ki_load_gws_furi( +@@ -2392,6 +2406,8 @@ static int ki_load_gws_furi( matched_gws[gw_index].priority = t->priority; matched_gws[gw_index].weight = t->weight * (kam_rand() >> 8); matched_gws[gw_index].duplicate = 0; @@ -83,7 +83,7 @@ index 579ec06..0565044 100644 LM_DBG("added matched_gws[%d]=[%u, %u, %u, %u]\n", gw_index, t->gw_index, pl->prefix_len, t->priority, matched_gws[gw_index].weight); -@@ -2374,8 +2390,10 @@ static int ki_load_gws_furi( +@@ -2400,8 +2416,10 @@ static int ki_load_gws_furi( t = t->next; } /* Do not look further if this matching rule was stopper */ @@ -95,7 +95,7 @@ index 579ec06..0565044 100644 next: rule = rule->next; -@@ -2400,6 +2418,24 @@ done: +@@ -2426,6 +2444,24 @@ done: } } diff --git a/debian/patches/sipwise/pv-headers-clone-branch-ignore-skip-header.patch b/debian/patches/sipwise/pv-headers-clone-branch-ignore-skip-header.patch index 28d879357..cba58d4a6 100644 --- a/debian/patches/sipwise/pv-headers-clone-branch-ignore-skip-header.patch +++ b/debian/patches/sipwise/pv-headers-clone-branch-ignore-skip-header.patch @@ -1,6 +1,16 @@ +From: Sipwise Development Team +Date: Thu, 10 Mar 2022 16:34:37 +0100 +Subject: pv-headers-clone-branch-ignore-skip-header + +--- + src/modules/pv_headers/pvh_xavp.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c +index b8e4f92..8b2acbf 100644 --- a/src/modules/pv_headers/pvh_xavp.c +++ b/src/modules/pv_headers/pvh_xavp.c -@@ -515,8 +515,6 @@ int pvh_clone_branch_xavi(struct sip_msg +@@ -515,8 +515,6 @@ int pvh_clone_branch_xavi(struct sip_msg *msg, str *xname) } do { diff --git a/debian/patches/sipwise/usrloc_dbro.patch b/debian/patches/sipwise/usrloc_dbro.patch index ce7f6bf8a..4aca4353f 100644 --- a/debian/patches/sipwise/usrloc_dbro.patch +++ b/debian/patches/sipwise/usrloc_dbro.patch @@ -8,7 +8,7 @@ Subject: usrloc_dbro 2 files changed, 67 insertions(+) diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c -index 733c16a..de06cfb 100644 +index db8bfbe..729fb6a7 100644 --- a/src/modules/usrloc/usrloc_mod.c +++ b/src/modules/usrloc/usrloc_mod.c @@ -167,6 +167,7 @@ str ulattrs_avalue_col = str_init(ULATTRS_AVALUE_COL); /*!< Name of column conta diff --git a/debian/patches/upstream/core_sdp_parser_check_value_of_ptr_with_white_space.patch b/debian/patches/upstream/core_sdp_parser_check_value_of_ptr_with_white_space.patch index 6e5dd61f9..270a92382 100644 --- a/debian/patches/upstream/core_sdp_parser_check_value_of_ptr_with_white_space.patch +++ b/debian/patches/upstream/core_sdp_parser_check_value_of_ptr_with_white_space.patch @@ -1,4 +1,3 @@ -From f65c98cf74e4495a6e892a701980c4b691a3390b Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 4 Mar 2022 09:43:13 +0100 Subject: [PATCH] core: parser - check value of pointer with white space code @@ -8,7 +7,7 @@ Subject: [PATCH] core: parser - check value of pointer with white space code 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/parser/sdp/sdp_helpr_funcs.c b/src/core/parser/sdp/sdp_helpr_funcs.c -index 9fae1f7448..c2b817f3e4 100644 +index 9fae1f7..c2b817f 100644 --- a/src/core/parser/sdp/sdp_helpr_funcs.c +++ b/src/core/parser/sdp/sdp_helpr_funcs.c @@ -376,7 +376,7 @@ int extract_ice_option(str *body, sdp_stream_cell_t *stream) @@ -20,6 +19,3 @@ index 9fae1f7448..c2b817f3e4 100644 /* identify all existing ICE options, if they are listed in one row */ while (*ptr_src && *ptr_src != '\r' && *ptr_src != '\n' && max_options-->0) --- -2.25.1 - diff --git a/debian/patches/upstream/core_sdp_parser_improve_ice_options_and_cloning.patch b/debian/patches/upstream/core_sdp_parser_improve_ice_options_and_cloning.patch index ee57d88b0..31bb651ef 100644 --- a/debian/patches/upstream/core_sdp_parser_improve_ice_options_and_cloning.patch +++ b/debian/patches/upstream/core_sdp_parser_improve_ice_options_and_cloning.patch @@ -1,4 +1,3 @@ -From 236fada43f610b910490f7e0c216ac9aa3d9480c Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 18 Feb 2022 11:44:14 +0100 Subject: [PATCH 1/2] core: add support of ICE media options to SDP parser @@ -35,14 +34,14 @@ leads to a proper work of other side modules' functions (which use SDP parser's data structures), such as 'is_audio_on_hold()' from the textops.so module. --- - src/core/parser/sdp/sdp.c | 59 ++++++++++++++++++++------ - src/core/parser/sdp/sdp.h | 40 ++++++++++++------ - src/core/parser/sdp/sdp_helpr_funcs.c | 60 +++++++++++++++++++++++++++ - src/core/parser/sdp/sdp_helpr_funcs.h | 1 + - 4 files changed, 136 insertions(+), 24 deletions(-) + src/core/parser/sdp/sdp.c | 290 ++++++++++++++++++++++++++++++---- + src/core/parser/sdp/sdp.h | 40 +++-- + src/core/parser/sdp/sdp_helpr_funcs.c | 60 +++++++ + src/core/parser/sdp/sdp_helpr_funcs.h | 1 + + 4 files changed, 352 insertions(+), 39 deletions(-) diff --git a/src/core/parser/sdp/sdp.c b/src/core/parser/sdp/sdp.c -index c3c94c37da..eddb3988db 100644 +index c3c94c3..dc584e1 100644 --- a/src/core/parser/sdp/sdp.c +++ b/src/core/parser/sdp/sdp.c @@ -38,9 +38,6 @@ @@ -136,200 +135,7 @@ index c3c94c37da..eddb3988db 100644 } } ++stream_num; -diff --git a/src/core/parser/sdp/sdp.h b/src/core/parser/sdp/sdp.h -index d8c1b15b66..417cb2b4c0 100644 ---- a/src/core/parser/sdp/sdp.h -+++ b/src/core/parser/sdp/sdp.h -@@ -36,6 +36,16 @@ - #define RFC2543_HOLD 1 - #define RFC3264_HOLD 2 - -+#define HOLD_IP_STR "0.0.0.0" -+#define HOLD_IP_LEN 7 -+ -+#define HOLD_PORT_ICE_TRICKLE_STR "9" -+#define HOLD_PORT_ICE_TRICKLE_LEN 1 -+ -+#define ICE_OPTIONS "a=ice-options:" -+#define ICE_OPT_TRICKLE_STR "trickle" -+#define ICE_OPT_TRICKLE_LEN 7 -+ - typedef struct sdp_payload_attr { - struct sdp_payload_attr *next; - int payload_num; /**< payload index inside stream */ -@@ -46,15 +56,20 @@ typedef struct sdp_payload_attr { - str fmtp_string; - } sdp_payload_attr_t; - -+typedef struct sdp_ice_opt { -+ struct sdp_ice_opt *next; -+ str option; /* for e.g. 'trickle', 'rtp+ecn' */ -+} sdp_ice_opt_t; -+ - typedef struct sdp_ice_attr { -- struct sdp_ice_attr *next; -- str foundation; -- unsigned int component_id; -- str transport; -- str connection_addr; -- str port; -- str candidate_type; -- int candidateType; /* ICE_HOST/ICE_SRFLX/ICE_PRFLX/ICE_RELAY/ICE_UNKNOWN */ -+ struct sdp_ice_attr *next; -+ str foundation; -+ unsigned int component_id; -+ str transport; -+ str connection_addr; -+ str port; -+ str candidate_type; -+ int candidateType; /* ICE_HOST/ICE_SRFLX/ICE_PRFLX/ICE_RELAY/ICE_UNKNOWN */ - } sdp_ice_attr_t; - - typedef struct sdp_stream_cell { -@@ -88,10 +103,11 @@ typedef struct sdp_stream_cell { - str raw_stream; /**< fast access to raw stream string */ - struct sdp_payload_attr **p_payload_attr; /**< fast access pointers to payloads */ - struct sdp_payload_attr *payload_attr; -- int ice_attrs_num; /**< number of ICE attrs inside a stream */ -- /* add fast access pointers to ice attributes if you need them */ -- sdp_ice_attr_t *ice_attr; -- str remote_candidates; /**< ICE a:remote-candidates */ -+ int ice_attrs_num; /* number of candidate ICE attrs inside a stream */ -+ sdp_ice_attr_t *ice_attr; /* add fast access pointers to ice candidate attributes */ -+ int ice_opt_num; /* number of media level ICE options inside the stream */ -+ sdp_ice_opt_t *ice_opt; /* add fast access pointers to media level ICE options */ -+ str remote_candidates; /* ICE a:remote-candidates */ - } sdp_stream_cell_t; - - typedef struct sdp_session_cell { -diff --git a/src/core/parser/sdp/sdp_helpr_funcs.c b/src/core/parser/sdp/sdp_helpr_funcs.c -index 9b7a442e79..9fae1f7448 100644 ---- a/src/core/parser/sdp/sdp_helpr_funcs.c -+++ b/src/core/parser/sdp/sdp_helpr_funcs.c -@@ -279,6 +279,26 @@ static inline sdp_ice_attr_t *add_sdp_ice(sdp_stream_cell_t* _stream) - return ice_attr; - } - -+static inline sdp_ice_opt_t *add_sdp_ice_opt(sdp_stream_cell_t* _stream) -+{ -+ sdp_ice_opt_t *ice_opt; -+ int len; -+ -+ len = sizeof(sdp_ice_opt_t); -+ ice_opt = (sdp_ice_opt_t *)pkg_malloc(len); -+ if (ice_opt == NULL) { -+ PKG_MEM_ERROR; -+ return NULL; -+ } -+ memset( ice_opt, 0, len); -+ -+ /* Insert the new ice option */ -+ ice_opt->next = _stream->ice_opt; -+ _stream->ice_opt = ice_opt; -+ _stream->ice_opt_num++; -+ -+ return ice_opt; -+} - - int extract_candidate(str *body, sdp_stream_cell_t *stream) - { -@@ -343,6 +363,46 @@ int extract_field(str *body, str *value, str field) - return 0; - } - -+int extract_ice_option(str *body, sdp_stream_cell_t *stream) -+{ -+ sdp_ice_opt_t *ice_opt; -+ -+ char * ptr_src; -+ int max_options = 10; /* protection - max options can be listed in one line */ -+ int length = 0; /* each option length */ -+ -+ /* a=ice-options: */ -+ if ((body->len < 14) || (strncasecmp(body->s, ICE_OPTIONS, 14) != 0)) -+ return -1; -+ -+ ptr_src = body->s + 14; -+ if (ptr_src == 32) ptr_src++; /* if starts with a space, skip it */ -+ -+ /* identify all existing ICE options, if they are listed in one row */ -+ while (*ptr_src && *ptr_src != '\r' && *ptr_src != '\n' && max_options-->0) -+ { -+ while (*ptr_src != 32 && *ptr_src && *ptr_src != '\r' && *ptr_src != '\n') -+ { -+ length++; -+ ptr_src++; -+ } -+ -+ ice_opt = add_sdp_ice_opt(stream); -+ if (ice_opt == NULL) { -+ LM_ERR("failed to add ice option\n"); -+ return -1; -+ } -+ -+ ice_opt->option.s = ptr_src-length; -+ ice_opt->option.len = length; -+ trim_len(ice_opt->option.len, ice_opt->option.s, ice_opt->option); -+ -+ length = 0; -+ if (*ptr_src == 32) ptr_src++; /* skip space */ -+ } -+ -+ return 0; -+} - - int extract_ptime(str *body, str *ptime) - { -diff --git a/src/core/parser/sdp/sdp_helpr_funcs.h b/src/core/parser/sdp/sdp_helpr_funcs.h -index 406f57b165..3c4c7d78a2 100644 ---- a/src/core/parser/sdp/sdp_helpr_funcs.h -+++ b/src/core/parser/sdp/sdp_helpr_funcs.h -@@ -52,6 +52,7 @@ int extract_mediaip(str *body, str *mediaip, int *pf, char *line); - int extract_media_attr(str *body, str *mediamedia, str *mediaport, str *mediatransport, str *mediapayload, int *is_rtp); - int extract_bwidth(str *body, str *bwtype, str *bwwitdth); - int extract_candidate(str *body, sdp_stream_cell_t *stream); -+int extract_ice_option(str *body, sdp_stream_cell_t *stream); - int extract_sess_version(str* oline, str* sess_version); - - /* RFC3605 attributes */ --- -2.25.1 - - -From fe7d7c571b6c8d446cf66a1cf27d335d98f5f945 Mon Sep 17 00:00:00 2001 -From: Donat Zenichev -Date: Fri, 18 Feb 2022 12:03:49 +0100 -Subject: [PATCH 2/2] core: improve an existing data structures cloning in the - SDP parser - -It's been noticed that the cloning of SDP session(s) and -SDP stream(s) structures doesn't allocate the ICE candidate attributes, -nor it allocates (recently introduced) ICE media stream options. - -In order to target this a couple of new functions have been introduced: -- clone_sdp_opt_attr() -- clone_sdp_ice_attr() - -And additionally the following functions have been improved, in order to -properly clone/free ICE candidate attributes and (recently introduced) -ICE media stream options: -- clone_sdp_stream_cell() -- free_cloned_sdp_stream() -- free_sdp() -- print_sdp_stream() - -Additionally for a proper new structure length calculation, the following -function is fixed: -- clone_sdp_session_cell() ---- - src/core/parser/sdp/sdp.c | 231 +++++++++++++++++++++++++++++++++++--- - 1 file changed, 216 insertions(+), 15 deletions(-) - -diff --git a/src/core/parser/sdp/sdp.c b/src/core/parser/sdp/sdp.c -index eddb3988db..dc584e1c8b 100644 ---- a/src/core/parser/sdp/sdp.c -+++ b/src/core/parser/sdp/sdp.c -@@ -853,7 +853,8 @@ void free_sdp(sdp_info_t** _sdp) +@@ -818,7 +853,8 @@ void free_sdp(sdp_info_t** _sdp) sdp_session_cell_t *session, *l_session; sdp_stream_cell_t *stream, *l_stream; sdp_payload_attr_t *payload, *l_payload; @@ -339,7 +145,7 @@ index eddb3988db..dc584e1c8b 100644 LM_DBG("_sdp = %p\n", _sdp); if (sdp == NULL) return; -@@ -876,10 +877,17 @@ void free_sdp(sdp_info_t** _sdp) +@@ -841,10 +877,17 @@ void free_sdp(sdp_info_t** _sdp) if (l_stream->p_payload_attr) { pkg_free(l_stream->p_payload_attr); } @@ -361,7 +167,7 @@ index eddb3988db..dc584e1c8b 100644 } pkg_free(l_stream); } -@@ -893,7 +901,8 @@ void free_sdp(sdp_info_t** _sdp) +@@ -858,7 +901,8 @@ void free_sdp(sdp_info_t** _sdp) void print_sdp_stream(sdp_stream_cell_t *stream, int log_level) { sdp_payload_attr_t *payload; @@ -371,7 +177,7 @@ index eddb3988db..dc584e1c8b 100644 LOG(log_level , "....stream[%d]:%p=>%p {%p} '%.*s' '%.*s:%.*s:%.*s' '%.*s' [%d] '%.*s' '%.*s:%.*s' (%d)=>%p (%d)=>%p '%.*s' '%.*s' '%.*s' '%.*s' '%.*s' '%.*s' '%.*s'\n", stream->stream_num, stream, stream->next, -@@ -911,8 +920,9 @@ void print_sdp_stream(sdp_stream_cell_t *stream, int log_level) +@@ -876,8 +920,9 @@ void print_sdp_stream(sdp_stream_cell_t *stream, int log_level) stream->path.len, stream->path.s, stream->max_size.len, stream->max_size.s, stream->accept_types.len, stream->accept_types.s, @@ -383,7 +189,7 @@ index eddb3988db..dc584e1c8b 100644 payload = stream->payload_attr; while (payload) { LOG(log_level, "......payload[%d]:%p=>%p p_payload_attr[%d]:%p '%.*s' '%.*s' '%.*s' '%.*s' '%.*s'\n", -@@ -925,12 +935,19 @@ void print_sdp_stream(sdp_stream_cell_t *stream, int log_level) +@@ -890,12 +935,19 @@ void print_sdp_stream(sdp_stream_cell_t *stream, int log_level) payload->fmtp_string.len, payload->fmtp_string.s); payload=payload->next; } @@ -407,7 +213,7 @@ index eddb3988db..dc584e1c8b 100644 } } -@@ -983,6 +1000,8 @@ void free_cloned_sdp_stream(sdp_stream_cell_t *_stream) +@@ -948,6 +1000,8 @@ void free_cloned_sdp_stream(sdp_stream_cell_t *_stream) { sdp_stream_cell_t *stream, *l_stream; sdp_payload_attr_t *payload, *l_payload; @@ -416,7 +222,7 @@ index eddb3988db..dc584e1c8b 100644 stream = _stream; while (stream) { -@@ -997,6 +1016,18 @@ void free_cloned_sdp_stream(sdp_stream_cell_t *_stream) +@@ -962,6 +1016,18 @@ void free_cloned_sdp_stream(sdp_stream_cell_t *_stream) if (l_stream->p_payload_attr) { shm_free(l_stream->p_payload_attr); } @@ -435,7 +241,7 @@ index eddb3988db..dc584e1c8b 100644 shm_free(l_stream); } } -@@ -1088,10 +1119,114 @@ sdp_payload_attr_t * clone_sdp_payload_attr(sdp_payload_attr_t *attr) +@@ -1053,10 +1119,114 @@ sdp_payload_attr_t * clone_sdp_payload_attr(sdp_payload_attr_t *attr) return clone_attr; } @@ -550,7 +356,7 @@ index eddb3988db..dc584e1c8b 100644 int len, i; char *p; -@@ -1111,7 +1246,10 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t *stream) +@@ -1076,7 +1246,10 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t *stream) stream->payloads.len + stream->bw_type.len + stream->bw_width.len + @@ -562,7 +368,7 @@ index eddb3988db..dc584e1c8b 100644 clone_stream = (sdp_stream_cell_t*)shm_malloc(len); if (clone_stream == NULL) { SHM_MEM_ERROR; -@@ -1130,15 +1268,76 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t *stream) +@@ -1095,15 +1268,76 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t *stream) clone_payload_attr->next = payload_attr; payload_attr = clone_payload_attr; } @@ -640,7 +446,7 @@ index eddb3988db..dc584e1c8b 100644 clone_stream->stream_num = stream->stream_num; clone_stream->pf = stream->pf; -@@ -1241,7 +1440,9 @@ sdp_session_cell_t * clone_sdp_session_cell(sdp_session_cell_t *session) +@@ -1206,7 +1440,9 @@ sdp_session_cell_t * clone_sdp_session_cell(sdp_session_cell_t *session) session->ip_addr.len + session->o_ip_addr.len + session->bw_type.len + @@ -651,6 +457,159 @@ index eddb3988db..dc584e1c8b 100644 clone_session = (sdp_session_cell_t*)shm_malloc(len); if (clone_session == NULL) { SHM_MEM_ERROR; --- -2.25.1 - +diff --git a/src/core/parser/sdp/sdp.h b/src/core/parser/sdp/sdp.h +index d8c1b15..417cb2b 100644 +--- a/src/core/parser/sdp/sdp.h ++++ b/src/core/parser/sdp/sdp.h +@@ -36,6 +36,16 @@ + #define RFC2543_HOLD 1 + #define RFC3264_HOLD 2 + ++#define HOLD_IP_STR "0.0.0.0" ++#define HOLD_IP_LEN 7 ++ ++#define HOLD_PORT_ICE_TRICKLE_STR "9" ++#define HOLD_PORT_ICE_TRICKLE_LEN 1 ++ ++#define ICE_OPTIONS "a=ice-options:" ++#define ICE_OPT_TRICKLE_STR "trickle" ++#define ICE_OPT_TRICKLE_LEN 7 ++ + typedef struct sdp_payload_attr { + struct sdp_payload_attr *next; + int payload_num; /**< payload index inside stream */ +@@ -46,15 +56,20 @@ typedef struct sdp_payload_attr { + str fmtp_string; + } sdp_payload_attr_t; + ++typedef struct sdp_ice_opt { ++ struct sdp_ice_opt *next; ++ str option; /* for e.g. 'trickle', 'rtp+ecn' */ ++} sdp_ice_opt_t; ++ + typedef struct sdp_ice_attr { +- struct sdp_ice_attr *next; +- str foundation; +- unsigned int component_id; +- str transport; +- str connection_addr; +- str port; +- str candidate_type; +- int candidateType; /* ICE_HOST/ICE_SRFLX/ICE_PRFLX/ICE_RELAY/ICE_UNKNOWN */ ++ struct sdp_ice_attr *next; ++ str foundation; ++ unsigned int component_id; ++ str transport; ++ str connection_addr; ++ str port; ++ str candidate_type; ++ int candidateType; /* ICE_HOST/ICE_SRFLX/ICE_PRFLX/ICE_RELAY/ICE_UNKNOWN */ + } sdp_ice_attr_t; + + typedef struct sdp_stream_cell { +@@ -88,10 +103,11 @@ typedef struct sdp_stream_cell { + str raw_stream; /**< fast access to raw stream string */ + struct sdp_payload_attr **p_payload_attr; /**< fast access pointers to payloads */ + struct sdp_payload_attr *payload_attr; +- int ice_attrs_num; /**< number of ICE attrs inside a stream */ +- /* add fast access pointers to ice attributes if you need them */ +- sdp_ice_attr_t *ice_attr; +- str remote_candidates; /**< ICE a:remote-candidates */ ++ int ice_attrs_num; /* number of candidate ICE attrs inside a stream */ ++ sdp_ice_attr_t *ice_attr; /* add fast access pointers to ice candidate attributes */ ++ int ice_opt_num; /* number of media level ICE options inside the stream */ ++ sdp_ice_opt_t *ice_opt; /* add fast access pointers to media level ICE options */ ++ str remote_candidates; /* ICE a:remote-candidates */ + } sdp_stream_cell_t; + + typedef struct sdp_session_cell { +diff --git a/src/core/parser/sdp/sdp_helpr_funcs.c b/src/core/parser/sdp/sdp_helpr_funcs.c +index 9b7a442..9fae1f7 100644 +--- a/src/core/parser/sdp/sdp_helpr_funcs.c ++++ b/src/core/parser/sdp/sdp_helpr_funcs.c +@@ -279,6 +279,26 @@ static inline sdp_ice_attr_t *add_sdp_ice(sdp_stream_cell_t* _stream) + return ice_attr; + } + ++static inline sdp_ice_opt_t *add_sdp_ice_opt(sdp_stream_cell_t* _stream) ++{ ++ sdp_ice_opt_t *ice_opt; ++ int len; ++ ++ len = sizeof(sdp_ice_opt_t); ++ ice_opt = (sdp_ice_opt_t *)pkg_malloc(len); ++ if (ice_opt == NULL) { ++ PKG_MEM_ERROR; ++ return NULL; ++ } ++ memset( ice_opt, 0, len); ++ ++ /* Insert the new ice option */ ++ ice_opt->next = _stream->ice_opt; ++ _stream->ice_opt = ice_opt; ++ _stream->ice_opt_num++; ++ ++ return ice_opt; ++} + + int extract_candidate(str *body, sdp_stream_cell_t *stream) + { +@@ -343,6 +363,46 @@ int extract_field(str *body, str *value, str field) + return 0; + } + ++int extract_ice_option(str *body, sdp_stream_cell_t *stream) ++{ ++ sdp_ice_opt_t *ice_opt; ++ ++ char * ptr_src; ++ int max_options = 10; /* protection - max options can be listed in one line */ ++ int length = 0; /* each option length */ ++ ++ /* a=ice-options: */ ++ if ((body->len < 14) || (strncasecmp(body->s, ICE_OPTIONS, 14) != 0)) ++ return -1; ++ ++ ptr_src = body->s + 14; ++ if (ptr_src == 32) ptr_src++; /* if starts with a space, skip it */ ++ ++ /* identify all existing ICE options, if they are listed in one row */ ++ while (*ptr_src && *ptr_src != '\r' && *ptr_src != '\n' && max_options-->0) ++ { ++ while (*ptr_src != 32 && *ptr_src && *ptr_src != '\r' && *ptr_src != '\n') ++ { ++ length++; ++ ptr_src++; ++ } ++ ++ ice_opt = add_sdp_ice_opt(stream); ++ if (ice_opt == NULL) { ++ LM_ERR("failed to add ice option\n"); ++ return -1; ++ } ++ ++ ice_opt->option.s = ptr_src-length; ++ ice_opt->option.len = length; ++ trim_len(ice_opt->option.len, ice_opt->option.s, ice_opt->option); ++ ++ length = 0; ++ if (*ptr_src == 32) ptr_src++; /* skip space */ ++ } ++ ++ return 0; ++} + + int extract_ptime(str *body, str *ptime) + { +diff --git a/src/core/parser/sdp/sdp_helpr_funcs.h b/src/core/parser/sdp/sdp_helpr_funcs.h +index 406f57b..3c4c7d7 100644 +--- a/src/core/parser/sdp/sdp_helpr_funcs.h ++++ b/src/core/parser/sdp/sdp_helpr_funcs.h +@@ -52,6 +52,7 @@ int extract_mediaip(str *body, str *mediaip, int *pf, char *line); + int extract_media_attr(str *body, str *mediamedia, str *mediaport, str *mediatransport, str *mediapayload, int *is_rtp); + int extract_bwidth(str *body, str *bwtype, str *bwwitdth); + int extract_candidate(str *body, sdp_stream_cell_t *stream); ++int extract_ice_option(str *body, sdp_stream_cell_t *stream); + int extract_sess_version(str* oline, str* sess_version); + + /* RFC3605 attributes */ diff --git a/debian/patches/upstream/db_redis-don-t-leave-unconsumed-redis-replies-in-cas.patch b/debian/patches/upstream/db_redis-don-t-leave-unconsumed-redis-replies-in-cas.patch deleted file mode 100644 index cee9ccf1c..000000000 --- a/debian/patches/upstream/db_redis-don-t-leave-unconsumed-redis-replies-in-cas.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Andrii Pogrebennyk -Date: Sun, 28 Nov 2021 08:34:36 +0100 -Subject: db_redis: don't leave unconsumed redis replies in case of error on - update - -Execute db_redis_consume_replies on failed update same as in db_redis_insert: -if db_redis_perform_update encounters an error it was leaving unconsumed data -thus causing unexpected reply later on when reading from the same connection. - -(cherry picked from commit bbd7b2ed5827252680e9d8949c193699da0a76b2) ---- - src/modules/db_redis/redis_dbase.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c -index 5258d57..ffe6ad7 100644 ---- a/src/modules/db_redis/redis_dbase.c -+++ b/src/modules/db_redis/redis_dbase.c -@@ -2292,6 +2292,7 @@ static int db_redis_perform_update(const db1_con_t* _h, km_redis_con_t *con, con - - db_redis_key_free(&all_type_keys); - db_redis_key_free(&new_type_keys); -+ db_redis_consume_replies(con); - return 0; - - error: -@@ -2303,6 +2304,7 @@ error: - db_redis_key_free(&type_keys); - db_redis_key_free(&set_keys); - db_redis_key_free(&new_type_keys); -+ db_redis_consume_replies(con); - return -1; - } - diff --git a/debian/patches/upstream/lcr-improve-binary-search-to-support-match-including-src-port.patch b/debian/patches/upstream/lcr-improve-binary-search-to-support-match-including-src-port.patch index cbdf36839..3c5dc48eb 100644 --- a/debian/patches/upstream/lcr-improve-binary-search-to-support-match-including-src-port.patch +++ b/debian/patches/upstream/lcr-improve-binary-search-to-support-match-including-src-port.patch @@ -1,4 +1,3 @@ -From e82819e6613dd64ca5c887759eab18cd38d20373 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 17 Sep 2021 12:56:39 +0300 Subject: [PATCH 1/3] lcr: improve binary search to support a match including @@ -22,11 +21,11 @@ when from_gw() and from_any_gw() functions are used with the 'src_port' paramete This means backwards compatibility is still present (when one uses functions without 'src_port'). --- - src/modules/lcr/lcr_mod.c | 37 ++++++++++++++++++++++++++++++++++--- - 1 file changed, 34 insertions(+), 3 deletions(-) + src/modules/lcr/lcr_mod.c | 41 +++++++++++++++++++++++++++++++++++------ + 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 21f05a4730..8c5b05d1df 100644 +index c25ed61..bc5a0cd 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c @@ -921,6 +921,30 @@ static int comp_gws(const void *_g1, const void *_g2) @@ -60,7 +59,7 @@ index 21f05a4730..8c5b05d1df 100644 /* * Insert gw info into index i or gws table -@@ -2997,10 +3021,17 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, +@@ -2999,15 +3023,20 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, return -1; } @@ -80,67 +79,10 @@ index 21f05a4730..8c5b05d1df 100644 + } /* Store tag and flags and return result */ - if((res != NULL) --- -2.25.1 - - -From 7a3a54433bbbfdb2521d4f8981c5b72423299bb1 Mon Sep 17 00:00:00 2001 -From: Donat Zenichev -Date: Sun, 19 Sep 2021 10:01:53 +0300 -Subject: [PATCH 2/3] lcr: remove excessive conditional check in do_from_gw() - -After an update of the bsearch(), which now supports matching not only -by the IP address, but also using the 'src_port', there is no need to check, -if the source port of a request matched the one from the 'lcr_gw' -('res' pointer will be NULL anyway, if ports don't match). - -Nor do we need to check if it's zero. ---- - src/modules/lcr/lcr_mod.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 8c5b05d1df..23b5bce0dc 100644 ---- a/src/modules/lcr/lcr_mod.c -+++ b/src/modules/lcr/lcr_mod.c -@@ -3035,8 +3035,7 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, - - /* Store tag and flags and return result */ - if((res != NULL) +- if((res != NULL) - && ((transport == PROTO_NONE) || (res->transport_code == transport)) - && ((src_port == 0) || (res->port == src_port))) { -+ && ((transport == PROTO_NONE) || (res->transport_code == transport))) { - LM_DBG("request came from gw\n"); - if(tag_avp_param) { - val.s.s = res->tag; --- -2.25.1 - - -From 10b014b505080a918a8443ff83029a0155364661 Mon Sep 17 00:00:00 2001 -From: Henning Westerholt -Date: Mon, 20 Sep 2021 18:14:35 +0000 -Subject: [PATCH 3/3] lcr: small white-space (related to GH #2859) - ---- - src/modules/lcr/lcr_mod.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 23b5bce0dc..93c5181600 100644 ---- a/src/modules/lcr/lcr_mod.c -+++ b/src/modules/lcr/lcr_mod.c -@@ -3034,8 +3034,7 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, - } - - /* Store tag and flags and return result */ -- if((res != NULL) -- && ((transport == PROTO_NONE) || (res->transport_code == transport))) { + if((res != NULL) && ((transport == PROTO_NONE) || (res->transport_code == transport))) { LM_DBG("request came from gw\n"); if(tag_avp_param) { val.s.s = res->tag; --- -2.25.1 - diff --git a/debian/patches/upstream/lcr-remove-excessive-checks-for-the-src_port-accurac.patch b/debian/patches/upstream/lcr-remove-excessive-checks-for-the-src_port-accurac.patch index 162cbc46c..15e65d613 100644 --- a/debian/patches/upstream/lcr-remove-excessive-checks-for-the-src_port-accurac.patch +++ b/debian/patches/upstream/lcr-remove-excessive-checks-for-the-src_port-accurac.patch @@ -1,4 +1,3 @@ -From 536736f2529f7554929f3aa6b74ac616c382bc6e Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 24 Aug 2021 18:50:16 +0300 Subject: [PATCH 1/2] lcr: remove excessive checks for the 'src_port' accuracy @@ -14,10 +13,10 @@ and the check concerns whether it's less than 0 or not. 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 858352f2c7..57b4021ac9 100644 +index 983d4b4..c25ed61 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c -@@ -3093,9 +3093,9 @@ static int ki_from_gw_addr( +@@ -3095,9 +3095,9 @@ static int ki_from_gw_addr( return -1; } @@ -30,7 +29,7 @@ index 858352f2c7..57b4021ac9 100644 return -1; } -@@ -3215,9 +3215,9 @@ static int ki_from_any_gw_addr(sip_msg_t *_m, str *addr_str, int transport, unsi +@@ -3217,9 +3217,9 @@ static int ki_from_any_gw_addr(sip_msg_t *_m, str *addr_str, int transport, unsi return -1; } @@ -43,6 +42,3 @@ index 858352f2c7..57b4021ac9 100644 return -1; } --- -2.25.1 - diff --git a/debian/patches/upstream/lcr-source-port-check-for-from_any_gw-and-from_gw.patch b/debian/patches/upstream/lcr-source-port-check-for-from_any_gw-and-from_gw.patch index 14430c541..8280decde 100644 --- a/debian/patches/upstream/lcr-source-port-check-for-from_any_gw-and-from_gw.patch +++ b/debian/patches/upstream/lcr-source-port-check-for-from_any_gw-and-from_gw.patch @@ -1,4 +1,3 @@ -From 9115d74b33aefb0febad7c7fffe7d184e4066b77 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Mon, 23 Aug 2021 21:50:50 +0300 Subject: [PATCH 2/2] lcr: source port check for from_any_gw() and from_gw(). @@ -13,12 +12,12 @@ Improvements are done for the following functions of the lcr module: Back compatibility provided, hence it does not affect already existing behavior. --- - src/modules/lcr/doc/lcr_admin.xml | 31 ++++---- - src/modules/lcr/lcr_mod.c | 116 +++++++++++++++++++++++++----- + src/modules/lcr/doc/lcr_admin.xml | 31 +++++----- + src/modules/lcr/lcr_mod.c | 116 ++++++++++++++++++++++++++++++++------ 2 files changed, 116 insertions(+), 31 deletions(-) diff --git a/src/modules/lcr/doc/lcr_admin.xml b/src/modules/lcr/doc/lcr_admin.xml -index 2c5bfb0d85..f6461e1a24 100644 +index 2c5bfb0..f6461e1 100644 --- a/src/modules/lcr/doc/lcr_admin.xml +++ b/src/modules/lcr/doc/lcr_admin.xml @@ -1425,16 +1425,16 @@ defunct_gw(60); @@ -101,7 +100,7 @@ index 2c5bfb0d85..f6461e1a24 100644 diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 579ec06d4d..858352f2c7 100644 +index d24f952..983d4b4 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c @@ -260,8 +260,10 @@ static int inactivate_gw(struct sip_msg *_m, char *_s1, char *_s2); @@ -130,7 +129,7 @@ index 579ec06d4d..858352f2c7 100644 {"to_gw", (cmd_function)to_gw_1, 1, 0, 0, REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE}, {"to_gw", (cmd_function)to_gw_3, 3, 0, 0, -@@ -2978,7 +2984,7 @@ static int next_gw(struct sip_msg *_m, char *_s1, char *_s2) +@@ -2980,7 +2986,7 @@ static int next_gw(struct sip_msg *_m, char *_s1, char *_s2) * Checks if request comes from ip address of a gateway */ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, @@ -139,7 +138,7 @@ index 579ec06d4d..858352f2c7 100644 { struct gw_info *res, gw, *gws; int_str val; -@@ -2997,9 +3003,10 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, +@@ -2999,9 +3005,10 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, sizeof(struct gw_info), comp_gws); /* Store tag and flags and return result */ @@ -153,7 +152,7 @@ index 579ec06d4d..858352f2c7 100644 if(tag_avp_param) { val.s.s = res->tag; val.s.len = res->tag_len; -@@ -3021,22 +3028,24 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, +@@ -3023,22 +3030,24 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, /* * Checks if request comes from ip address of a gateway taking source @@ -181,7 +180,7 @@ index 579ec06d4d..858352f2c7 100644 } static int from_gw_1(struct sip_msg *_m, char *_lcr_id, char *_s2) -@@ -3056,10 +3065,10 @@ static int from_gw_1(struct sip_msg *_m, char *_lcr_id, char *_s2) +@@ -3058,10 +3067,10 @@ static int from_gw_1(struct sip_msg *_m, char *_lcr_id, char *_s2) /* * Checks if request comes from ip address of a gateway taking source @@ -194,7 +193,7 @@ index 579ec06d4d..858352f2c7 100644 { struct ip_addr src_addr; struct ip_addr *ip; -@@ -3084,8 +3093,14 @@ static int ki_from_gw_addr( +@@ -3086,8 +3095,14 @@ static int ki_from_gw_addr( return -1; } @@ -210,7 +209,7 @@ index 579ec06d4d..858352f2c7 100644 } static int from_gw_3( -@@ -3112,7 +3127,41 @@ static int from_gw_3( +@@ -3114,7 +3129,41 @@ static int from_gw_3( return -1; } @@ -253,7 +252,7 @@ index 579ec06d4d..858352f2c7 100644 } /* -@@ -3123,11 +3172,14 @@ static int ki_from_any_gw(sip_msg_t *_m) +@@ -3125,11 +3174,14 @@ static int ki_from_any_gw(sip_msg_t *_m) { unsigned int i; uri_transport transport; @@ -269,7 +268,7 @@ index 579ec06d4d..858352f2c7 100644 return i; } } -@@ -3141,9 +3193,9 @@ static int from_any_gw_0(struct sip_msg *_m, char *_s1, char *_s2) +@@ -3143,9 +3195,9 @@ static int from_any_gw_0(struct sip_msg *_m, char *_s1, char *_s2) /* * Checks if request comes from ip address of a a gateway taking source @@ -281,7 +280,7 @@ index 579ec06d4d..858352f2c7 100644 { unsigned int i; struct ip_addr *ip, src_addr; -@@ -3163,9 +3215,15 @@ static int ki_from_any_gw_addr(sip_msg_t *_m, str *addr_str, int transport) +@@ -3165,9 +3217,15 @@ static int ki_from_any_gw_addr(sip_msg_t *_m, str *addr_str, int transport) return -1; } @@ -298,7 +297,7 @@ index 579ec06d4d..858352f2c7 100644 return i; } } -@@ -3188,7 +3246,33 @@ static int from_any_gw_2(struct sip_msg *_m, char *_addr, char *_transport) +@@ -3190,7 +3248,33 @@ static int from_any_gw_2(struct sip_msg *_m, char *_addr, char *_transport) return -1; } @@ -333,6 +332,3 @@ index 579ec06d4d..858352f2c7 100644 } /* --- -2.25.1 - diff --git a/debian/patches/upstream/lcr_improve_gw_search_when_both_ipaddress_and_src_port_used.patch b/debian/patches/upstream/lcr_improve_gw_search_when_both_ipaddress_and_src_port_used.patch index d9db21372..314a157c6 100644 --- a/debian/patches/upstream/lcr_improve_gw_search_when_both_ipaddress_and_src_port_used.patch +++ b/debian/patches/upstream/lcr_improve_gw_search_when_both_ipaddress_and_src_port_used.patch @@ -1,4 +1,3 @@ -From d737c876cc36b4de802da77dfcd361323ad7cd8e Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 8 Oct 2021 16:18:47 +0300 Subject: [PATCH] lcr: improve the search for GW when both IP address and @@ -41,7 +40,7 @@ based on two objects (ip_addr and src_port) being used for comparison. 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c -index 93c5181600..d796c08c2c 100644 +index bc5a0cd..fb85f5b 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c @@ -922,28 +922,24 @@ static int comp_gws(const void *_g1, const void *_g2) @@ -89,7 +88,7 @@ index 93c5181600..d796c08c2c 100644 } /* -@@ -3025,8 +3021,7 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, +@@ -3027,8 +3023,7 @@ static int do_from_gw(struct sip_msg *_m, unsigned int lcr_id, if (src_port != 0) { /* Search for gw based on its ip address and port */ gw.port = src_port; @@ -99,6 +98,3 @@ index 93c5181600..d796c08c2c 100644 } else { /* Search for gw based on its ip address */ res = (struct gw_info *)bsearch(&gw, &(gws[1]), gws[0].ip_addr.u.addr32[0], --- -2.25.1 - diff --git a/debian/patches/upstream/presence-info-logs-instead-of-error-for-not-maching-.patch b/debian/patches/upstream/presence-info-logs-instead-of-error-for-not-maching-.patch deleted file mode 100644 index 95cb0f792..000000000 --- a/debian/patches/upstream/presence-info-logs-instead-of-error-for-not-maching-.patch +++ /dev/null @@ -1,26 +0,0 @@ -From: Daniel-Constantin Mierla -Date: Mon, 13 Dec 2021 08:31:07 +0100 -Subject: presence: info logs instead of error for not maching conditions - -(cherry picked from commit f42b6c5cf2ee9861cb1eed016a5ddcc499d2b854) ---- - src/modules/presence/presentity.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/modules/presence/presentity.c b/src/modules/presence/presentity.c -index bc17bf1..9b3b9cd 100644 ---- a/src/modules/presence/presentity.c -+++ b/src/modules/presence/presentity.c -@@ -1367,10 +1367,10 @@ done: - send_412: - - if(!ruid) { -- LM_ERR("No E_Tag match %*s\n", presentity->etag.len, -+ LM_INFO("No E-Tag match %*s\n", presentity->etag.len, - presentity->etag.s); - } else { -- LM_ERR("No ruid match %*s\n", ruid->len, ruid->s); -+ LM_INFO("No ruid match %*s\n", ruid->len, ruid->s); - } - - if(msg != NULL) { diff --git a/debian/patches/upstream/pv_headers-restore-pvh_real_hdr_del_by_name.patch b/debian/patches/upstream/pv_headers-restore-pvh_real_hdr_del_by_name.patch deleted file mode 100644 index 322a175db..000000000 --- a/debian/patches/upstream/pv_headers-restore-pvh_real_hdr_del_by_name.patch +++ /dev/null @@ -1,41 +0,0 @@ -From b42dfd30ba74562e3c7673b3de449760bb315d62 Mon Sep 17 00:00:00 2001 -From: Victor Seva -Date: Wed, 22 Dec 2021 11:19:19 +0100 -Subject: [PATCH] pv_headers: restore pvh_real_hdr_del_by_name() - -it was wrongly removed at 09981c41cb6685fa18f61b9e7d66339917c4f097 - -(cherry picked from commit d8f0e71a0497e0bb98be60452914df51c84b56d8) ---- - src/modules/pv_headers/pvh_hdr.c | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/src/modules/pv_headers/pvh_hdr.c b/src/modules/pv_headers/pvh_hdr.c -index 31c09b4b5d..fbb471ccd5 100644 ---- a/src/modules/pv_headers/pvh_hdr.c -+++ b/src/modules/pv_headers/pvh_hdr.c -@@ -131,6 +131,21 @@ int pvh_real_hdr_append(struct sip_msg *msg, str *hname, str *hvalue) - return 1; - } - -+int pvh_real_hdr_del_by_name(struct sip_msg *msg, str *hname) -+{ -+ hdr_field_t *hf = NULL; -+ -+ for(hf = msg->headers; hf; hf = hf->next) { -+ if(hf->name.len == hname->len -+ && strncasecmp(hf->name.s, hname->s, hname->len) == 0) { -+ LM_DBG("remove header[%.*s]: %.*s\n", hf->name.len, hf->name.s, -+ hf->body.len, hf->body.s); -+ del_lump(msg, hf->name.s - msg->buf, hf->len, 0); -+ } -+ } -+ return 1; -+} -+ - int pvh_real_hdr_remove_display(struct sip_msg *msg, str *hname) - { - hdr_field_t *hf = NULL; --- -2.30.2 - diff --git a/debian/patches/upstream/tm_api_improvement_t_append_branches_with_contact.patch b/debian/patches/upstream/tm_api_improvement_t_append_branches_with_contact.patch index 503526edf..7426e640f 100644 --- a/debian/patches/upstream/tm_api_improvement_t_append_branches_with_contact.patch +++ b/debian/patches/upstream/tm_api_improvement_t_append_branches_with_contact.patch @@ -1,8 +1,7 @@ -From f564c0d33974eeaa1833abeb7972f5d207c5663f Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 12 Nov 2021 17:16:37 +0200 -Subject: [PATCH 1/2] tm: API improvement, new function introduced: - t_append_branch_by_contact() +Subject: [PATCH 1/2] tm: API improvement, + new function introduced: t_append_branch_by_contact() New module functions introduced: - t_append_branch_by_contact() @@ -17,296 +16,12 @@ of str type. The separate function has been introduced, in order to save full back-compatibility, and not affect existing implementation. --- - src/modules/tm/t_append_branches.c | 206 +++++++++++++++++++++++++++++ - src/modules/tm/t_append_branches.h | 4 + - src/modules/tm/tm_load.c | 1 + - src/modules/tm/tm_load.h | 1 + - 4 files changed, 212 insertions(+) + src/modules/tm/t_append_branches.c | 34 ++++++++++++++++++++++++++++++++-- + src/modules/tm/t_append_branches.h | 4 ++-- + 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/modules/tm/t_append_branches.c b/src/modules/tm/t_append_branches.c -index c754a90823..2daca1a593 100644 ---- a/src/modules/tm/t_append_branches.c -+++ b/src/modules/tm/t_append_branches.c -@@ -237,3 +237,209 @@ done: - } - return ret; - } -+ -+/* append a new transaction based on desired Contact hf value -+ * contact parameter must be of syntax (no hf parameters): -+ * sip:@: */ -+int t_append_branch_by_contact(str * contact) { -+ struct cell *t = NULL; -+ struct sip_msg *orig_msg = NULL; -+ struct sip_msg *faked_req; -+ int faked_req_len = 0; -+ -+ short outgoings; -+ -+ int success_branch; -+ -+ str current_uri; -+ str dst_uri, path, instance, ruid, location_ua; -+ struct socket_info* si; -+ int q, i, found, append; -+ flag_t backup_bflags = 0; -+ flag_t bflags = 0; -+ int new_branch, branch_ret, lowest_ret; -+ branch_bm_t added_branches; -+ int replies_locked = 0; -+ int ret = 0; -+ -+ t = get_t(); -+ if(t == NULL) -+ { -+ LM_ERR("cannot get transaction\n"); -+ return -1; -+ } -+ -+ LM_DBG("transaction %u:%u in status %d\n", t->hash_index, t->label, t->uas.status); -+ -+ /* test if transaction has already been canceled */ -+ if (t->flags & T_CANCELED) { -+ ser_error=E_CANCELED; -+ return -1; -+ } -+ -+ if ((t->uas.status >= 200 && t->uas.status<=399) -+ || ((t->uas.status >= 600 && t->uas.status) -+ && !(t->flags & (T_6xx | T_DISABLE_6xx))) ) { -+ LM_DBG("transaction %u:%u in status %d: cannot append new branch\n", -+ t->hash_index, t->label, t->uas.status); -+ return -1; -+ } -+ -+ /* set the lock on the transaction here */ -+ LOCK_REPLIES(t); -+ replies_locked = 1; -+ outgoings = t->nr_of_outgoings; -+ orig_msg = t->uas.request; -+ -+ LM_DBG("Call %.*s: %d (%d) outgoing branches\n",orig_msg->callid->body.len, -+ orig_msg->callid->body.s,outgoings, nr_branches); -+ -+ lowest_ret=E_UNSPEC; -+ added_branches=0; -+ -+ /* it's a "late" branch so the on_branch variable has already been -+ reset by previous execution of t_forward_nonack: we use the saved -+ value */ -+ if (t->on_branch_delayed) { -+ /* tell add_uac that it should run branch route actions */ -+ set_branch_route(t->on_branch_delayed); -+ } -+ faked_req = fake_req(orig_msg, 0, NULL, &faked_req_len); -+ if (faked_req==NULL) { -+ LM_ERR("fake_req failed\n"); -+ return -1; -+ } -+ -+ /* fake also the env. conforming to the fake msg */ -+ faked_env( t, faked_req, 0); -+ -+ /* DONE with faking ;-) -> run the failure handlers */ -+ init_branch_iterator(); -+ -+ while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri, &path, -+ &bflags, &si, &ruid, &instance, &location_ua))) { -+ LM_DBG("Current uri %.*s\n",current_uri.len, current_uri.s); -+ -+ append = 1; -+ if (strstr(current_uri.s, contact->s) == NULL) { -+ append = 0; -+ } -+ -+ /* do not append the branch if a contact does not match */ -+ if (!append) -+ continue; -+ -+ LM_DBG("Branch will be appended for contact <%.*s>\n", contact->len, contact->s); -+ -+ found = 0; -+ for (i=0; iuac[i].ruid.len == ruid.len -+ && !memcmp(t->uac[i].ruid.s, ruid.s, ruid.len) -+ && t->uac[i].uri.len == current_uri.len -+ && !memcmp(t->uac[i].uri.s, current_uri.s, current_uri.len)) { -+ LM_DBG("branch already added [%.*s]\n", ruid.len, ruid.s); -+ found = 1; -+ break; -+ } -+ } -+ if (found) -+ continue; -+ -+ setbflagsval(0, bflags); -+ new_branch=add_uac( t, faked_req, ¤t_uri, -+ (dst_uri.len) ? (&dst_uri) : ¤t_uri, -+ &path, 0, si, faked_req->fwd_send_flags, -+ PROTO_NONE, (dst_uri.len)?0:UAC_SKIP_BR_DST_F, &instance, -+ &ruid, &location_ua); -+ -+ LM_DBG("added branch [%.*s] with ruid [%.*s]\n", -+ current_uri.len, current_uri.s, ruid.len, ruid.s); -+ -+ /* test if cancel was received meanwhile */ -+ if (t->flags & T_CANCELED) goto canceled; -+ -+ if (new_branch>=0) -+ added_branches |= 1<callid->body.len, orig_msg->callid->body.s,outgoings, nr_branches); -+ setbflagsval(0, backup_bflags); -+ -+ /* update message flags, if changed in branch route */ -+ t->uas.request->flags = faked_req->flags; -+ -+ if (added_branches==0) { -+ if(lowest_ret!=E_CFG) -+ LM_ERR("failure to add branches (%d)\n", lowest_ret); -+ ser_error=lowest_ret; -+ ret = lowest_ret; -+ goto done; -+ } -+ -+ ser_error=0; /* clear branch adding errors */ -+ /* send them out now */ -+ success_branch=0; -+ /* since t_append_branch can only be called from REQUEST_ROUTE, always lock replies */ -+ -+ for (i=outgoings; inr_of_outgoings; i++) { -+ if (added_branches & (1<=0){ /* some kind of success */ -+ if (branch_ret==i) { /* success */ -+ success_branch++; -+ if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_OUT))) -+ run_trans_callbacks_with_buf( TMCB_REQUEST_OUT, -+ &t->uac[nr_branches].request, -+ faked_req, 0, TMCB_NONE_F); -+ } -+ else /* new branch added */ -+ added_branches |= 1<uas.request->flags = faked_req->flags; -+ /* if needed unlock transaction's replies */ -+ /* restore the number of outgoing branches -+ * since new branches have not been completed */ -+ t->nr_of_outgoings = outgoings; -+ ser_error=E_CANCELED; -+ ret = -1; -+done: -+ /* restore original environment and free the fake msg */ -+ faked_env( t, 0, 0); -+ free_faked_req(faked_req, faked_req_len); -+ -+ if (likely(replies_locked)) { -+ replies_locked = 0; -+ UNLOCK_REPLIES(t); -+ } -+ return ret; -+} -\ No newline at end of file -diff --git a/src/modules/tm/t_append_branches.h b/src/modules/tm/t_append_branches.h -index 2e1cbfb38a..a502909fbf 100644 ---- a/src/modules/tm/t_append_branches.h -+++ b/src/modules/tm/t_append_branches.h -@@ -34,4 +34,8 @@ - int t_append_branches(void); - typedef int (*t_append_branches_f)(void); - -+/* append a new transaction based on desired Contact hf value */ -+int t_append_branch_by_contact(str * contact); -+typedef int (*t_append_branch_by_contact_f)(str * contact); -+ - #endif -diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c -index 911be5d917..c6fd305655 100644 ---- a/src/modules/tm/tm_load.c -+++ b/src/modules/tm/tm_load.c -@@ -134,6 +134,7 @@ int load_tm( struct tm_binds *tmb) - tmb->tm_ctx_get = tm_ctx_get; - #endif - tmb->t_append_branches = t_append_branches; -+ tmb->t_append_branch_by_contact = t_append_branch_by_contact; - tmb->t_load_contacts = t_load_contacts; - tmb->t_next_contacts = t_next_contacts; - tmb->set_fr = t_set_fr; -diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h -index a0f3afde00..7ecfd1b5f3 100644 ---- a/src/modules/tm/tm_load.h -+++ b/src/modules/tm/tm_load.h -@@ -117,6 +117,7 @@ struct tm_binds { - void* reserved5; - #endif - t_append_branches_f t_append_branches; -+ t_append_branch_by_contact_f t_append_branch_by_contact; - cmd_function t_load_contacts; - cmd_function t_next_contacts; - tset_fr_f set_fr; --- -2.25.1 - - -From cb1b78e7bc8d61261e429664c6deb8bb1b4b53d0 Mon Sep 17 00:00:00 2001 -From: Donat Zenichev -Date: Sun, 14 Nov 2021 22:59:58 +0200 -Subject: [PATCH 2/2] tm: merge t_append_branches() and - t_append_branch_by_contact() - -Because the implementation of the functions -'t_append_branches()' and 't_append_branch_by_contact()' is pretty -much the same, it's proposed to merge them into one: -'t_append_branches()' - -The way how the function acts now depends on if the contact -parameter of str type is given or not (empty or not). -If the contact parameter is given, then only a desired location -is meant for appending. If not found in the location table, -an append will not happen for this AOR. - -Otherwise create branches for all existing location records -of this particular AOR. Search for locations is done in the location table. ---- - src/modules/tm/t_append_branches.c | 228 ++++------------------------- - src/modules/tm/t_append_branches.h | 8 +- - src/modules/tm/tm_load.c | 1 - - src/modules/tm/tm_load.h | 1 - - 4 files changed, 28 insertions(+), 210 deletions(-) - -diff --git a/src/modules/tm/t_append_branches.c b/src/modules/tm/t_append_branches.c -index 2daca1a593..203f67a36a 100644 +index c754a90..203f67a 100644 --- a/src/modules/tm/t_append_branches.c +++ b/src/modules/tm/t_append_branches.c @@ -46,7 +46,18 @@ @@ -338,280 +53,43 @@ index 2daca1a593..203f67a36a 100644 flag_t backup_bflags = 0; flag_t bflags = 0; int new_branch, branch_ret, lowest_ret; -@@ -125,212 +136,25 @@ int t_append_branches(void) { +@@ -125,6 +136,25 @@ int t_append_branches(void) { &bflags, &si, &ruid, &instance, &location_ua))) { LM_DBG("Current uri %.*s\n",current_uri.len, current_uri.s); -- found = 0; -- for (i=0; iuac[i].ruid.len == ruid.len -- && !memcmp(t->uac[i].ruid.s, ruid.s, ruid.len) -- && t->uac[i].uri.len == current_uri.len -- && !memcmp(t->uac[i].uri.s, current_uri.s, current_uri.len)) { -- LM_DBG("branch already added [%.*s]\n", ruid.len, ruid.s); -- found = 1; -- break; -- } -- } -- if (found) -- continue; -- -- setbflagsval(0, bflags); -- new_branch=add_uac( t, faked_req, ¤t_uri, -- (dst_uri.len) ? (&dst_uri) : ¤t_uri, -- &path, 0, si, faked_req->fwd_send_flags, -- PROTO_NONE, (dst_uri.len)?0:UAC_SKIP_BR_DST_F, &instance, -- &ruid, &location_ua); -- -- LM_DBG("added branch [%.*s] with ruid [%.*s]\n", -- current_uri.len, current_uri.s, ruid.len, ruid.s); -- -- /* test if cancel was received meanwhile */ -- if (t->flags & T_CANCELED) goto canceled; -- -- if (new_branch>=0) -- added_branches |= 1<callid->body.len, orig_msg->callid->body.s,outgoings, nr_branches); -- setbflagsval(0, backup_bflags); -- -- /* update message flags, if changed in branch route */ -- t->uas.request->flags = faked_req->flags; -- -- if (added_branches==0) { -- if(lowest_ret!=E_CFG) -- LM_ERR("failure to add branches (%d)\n", lowest_ret); -- ser_error=lowest_ret; -- ret = lowest_ret; -- goto done; -- } + /* if the contact parameter is given, then append by + an exact location that has been requested for this function call */ + if (contact->s != NULL && contact->len != 0) { - -- ser_error=0; /* clear branch adding errors */ -- /* send them out now */ -- success_branch=0; -- /* since t_append_branch can only be called from REQUEST_ROUTE, always lock replies */ ++ + LM_DBG("Comparing requested contact <%.*s> against location <%.*s>\n", + contact->len, contact->s, current_uri.len, current_uri.s); - -- for (i=outgoings; inr_of_outgoings; i++) { -- if (added_branches & (1<=0){ /* some kind of success */ -- if (branch_ret==i) { /* success */ -- success_branch++; -- if (unlikely(has_tran_tmcbs(t, TMCB_REQUEST_OUT))) -- run_trans_callbacks_with_buf( TMCB_REQUEST_OUT, -- &t->uac[nr_branches].request, -- faked_req, 0, TMCB_NONE_F); -- } -- else /* new branch added */ -- added_branches |= 1<s) == NULL) { + append = 0; /* this while cycle will be stopped */ - } -- } -- } -- if (success_branch<=0) { -- /* return always E_SEND for now -- * (the real reason could be: denied by onsend routes, blocklisted, -- * send failed or any of the errors listed before + dns failed -- * when attempting dns failover) */ -- ser_error=E_SEND; -- /* else return the last error (?) */ -- ret = -1; -- goto done; -- } -- -- ser_error=0; /* clear branch send errors, we have overall success */ -- set_kr(REQ_FWDED); -- ret = success_branch; -- goto done; -- --canceled: -- LM_DBG("cannot append branches to a canceled transaction\n"); -- /* reset processed branches */ -- clear_branches(); -- /* restore backup flags from initial env */ -- setbflagsval(0, backup_bflags); -- /* update message flags, if changed in branch route */ -- t->uas.request->flags = faked_req->flags; -- /* if needed unlock transaction's replies */ -- /* restore the number of outgoing branches -- * since new branches have not been completed */ -- t->nr_of_outgoings = outgoings; -- ser_error=E_CANCELED; -- ret = -1; --done: -- /* restore original environment and free the fake msg */ -- faked_env( t, 0, 0); -- free_faked_req(faked_req, faked_req_len); -- -- if (likely(replies_locked)) { -- replies_locked = 0; -- UNLOCK_REPLIES(t); -- } -- return ret; --} -- --/* append a new transaction based on desired Contact hf value -- * contact parameter must be of syntax (no hf parameters): -- * sip:@: */ --int t_append_branch_by_contact(str * contact) { -- struct cell *t = NULL; -- struct sip_msg *orig_msg = NULL; -- struct sip_msg *faked_req; -- int faked_req_len = 0; -- -- short outgoings; -- -- int success_branch; -- -- str current_uri; -- str dst_uri, path, instance, ruid, location_ua; -- struct socket_info* si; -- int q, i, found, append; -- flag_t backup_bflags = 0; -- flag_t bflags = 0; -- int new_branch, branch_ret, lowest_ret; -- branch_bm_t added_branches; -- int replies_locked = 0; -- int ret = 0; -- -- t = get_t(); -- if(t == NULL) -- { -- LM_ERR("cannot get transaction\n"); -- return -1; -- } -- -- LM_DBG("transaction %u:%u in status %d\n", t->hash_index, t->label, t->uas.status); -- -- /* test if transaction has already been canceled */ -- if (t->flags & T_CANCELED) { -- ser_error=E_CANCELED; -- return -1; -- } -- -- if ((t->uas.status >= 200 && t->uas.status<=399) -- || ((t->uas.status >= 600 && t->uas.status) -- && !(t->flags & (T_6xx | T_DISABLE_6xx))) ) { -- LM_DBG("transaction %u:%u in status %d: cannot append new branch\n", -- t->hash_index, t->label, t->uas.status); -- return -1; -- } -- -- /* set the lock on the transaction here */ -- LOCK_REPLIES(t); -- replies_locked = 1; -- outgoings = t->nr_of_outgoings; -- orig_msg = t->uas.request; -- -- LM_DBG("Call %.*s: %d (%d) outgoing branches\n",orig_msg->callid->body.len, -- orig_msg->callid->body.s,outgoings, nr_branches); -- -- lowest_ret=E_UNSPEC; -- added_branches=0; -- -- /* it's a "late" branch so the on_branch variable has already been -- reset by previous execution of t_forward_nonack: we use the saved -- value */ -- if (t->on_branch_delayed) { -- /* tell add_uac that it should run branch route actions */ -- set_branch_route(t->on_branch_delayed); -- } -- faked_req = fake_req(orig_msg, 0, NULL, &faked_req_len); -- if (faked_req==NULL) { -- LM_ERR("fake_req failed\n"); -- return -1; -- } -- -- /* fake also the env. conforming to the fake msg */ -- faked_env( t, faked_req, 0); -- -- /* DONE with faking ;-) -> run the failure handlers */ -- init_branch_iterator(); - -- while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri, &path, -- &bflags, &si, &ruid, &instance, &location_ua))) { -- LM_DBG("Current uri %.*s\n",current_uri.len, current_uri.s); ++ } ++ + /* do not append the branch if a contact does not match */ + if (!append) + continue; - -- append = 1; -- if (strstr(current_uri.s, contact->s) == NULL) { -- append = 0; ++ + LM_DBG("Branch will be appended for contact <%.*s>\n", contact->len, contact->s); - } - -- /* do not append the branch if a contact does not match */ -- if (!append) -- continue; -- -- LM_DBG("Branch will be appended for contact <%.*s>\n", contact->len, contact->s); -- ++ } ++ found = 0; for (i=0; iuac[i].ruid.len == ruid.len -@@ -442,4 +266,4 @@ done: - UNLOCK_REPLIES(t); - } - return ret; --} -\ No newline at end of file -+} diff --git a/src/modules/tm/t_append_branches.h b/src/modules/tm/t_append_branches.h -index a502909fbf..1baec4acd0 100644 +index 2e1cbfb..1baec4a 100644 --- a/src/modules/tm/t_append_branches.h +++ b/src/modules/tm/t_append_branches.h -@@ -31,11 +31,7 @@ +@@ -31,7 +31,7 @@ #include "../../core/proxy.h" #include "h_table.h" -int t_append_branches(void); -typedef int (*t_append_branches_f)(void); -- --/* append a new transaction based on desired Contact hf value */ --int t_append_branch_by_contact(str * contact); --typedef int (*t_append_branch_by_contact_f)(str * contact); +int t_append_branches(str * contact); +typedef int (*t_append_branches_f)(str * contact); #endif -diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c -index c6fd305655..911be5d917 100644 ---- a/src/modules/tm/tm_load.c -+++ b/src/modules/tm/tm_load.c -@@ -134,7 +134,6 @@ int load_tm( struct tm_binds *tmb) - tmb->tm_ctx_get = tm_ctx_get; - #endif - tmb->t_append_branches = t_append_branches; -- tmb->t_append_branch_by_contact = t_append_branch_by_contact; - tmb->t_load_contacts = t_load_contacts; - tmb->t_next_contacts = t_next_contacts; - tmb->set_fr = t_set_fr; -diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h -index 7ecfd1b5f3..a0f3afde00 100644 ---- a/src/modules/tm/tm_load.h -+++ b/src/modules/tm/tm_load.h -@@ -117,7 +117,6 @@ struct tm_binds { - void* reserved5; - #endif - t_append_branches_f t_append_branches; -- t_append_branch_by_contact_f t_append_branch_by_contact; - cmd_function t_load_contacts; - cmd_function t_next_contacts; - tset_fr_f set_fr; --- -2.25.1 - diff --git a/debian/patches/upstream/tsilo_append_by_contact.patch b/debian/patches/upstream/tsilo_append_by_contact.patch index eb962b1a3..84632fd8a 100644 --- a/debian/patches/upstream/tsilo_append_by_contact.patch +++ b/debian/patches/upstream/tsilo_append_by_contact.patch @@ -1,7 +1,7 @@ -From 7265f1cf7c57d258538119bc0d41146a04183eec Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Fri, 12 Nov 2021 15:30:44 +0200 -Subject: [PATCH] tsilo: Add support of a lookup and branch creating by contact +Subject: [PATCH] tsilo: Add support of a lookup and branch creating by + contact Improvement of the TSILO module, which allows to run a lookup using the provided RURI, but only to create a new branch for the Contact, which is set in the currently processed REGISTER. @@ -31,13 +31,13 @@ The documentation has been updated accordingly. --- src/modules/tsilo/doc/tsilo.xml | 5 + src/modules/tsilo/doc/tsilo_admin.xml | 54 ++++++ - src/modules/tsilo/ts_append.c | 116 +++++++++++ - src/modules/tsilo/ts_append.h | 2 + - src/modules/tsilo/tsilo.c | 269 +++++++++++++++++++++++++- - 5 files changed, 445 insertions(+), 1 deletion(-) + src/modules/tsilo/ts_append.c | 42 +++-- + src/modules/tsilo/ts_append.h | 4 +- + src/modules/tsilo/tsilo.c | 303 +++++++++++++++++++++++++++++++++- + 5 files changed, 388 insertions(+), 20 deletions(-) diff --git a/src/modules/tsilo/doc/tsilo.xml b/src/modules/tsilo/doc/tsilo.xml -index 6a2be7b0e7..1ad967ae64 100644 +index 6a2be7b..1ad967a 100644 --- a/src/modules/tsilo/doc/tsilo.xml +++ b/src/modules/tsilo/doc/tsilo.xml @@ -23,6 +23,11 @@ @@ -53,7 +53,7 @@ index 6a2be7b0e7..1ad967ae64 100644 2015 diff --git a/src/modules/tsilo/doc/tsilo_admin.xml b/src/modules/tsilo/doc/tsilo_admin.xml -index c294e7c282..965c339156 100644 +index c294e7c..965c339 100644 --- a/src/modules/tsilo/doc/tsilo_admin.xml +++ b/src/modules/tsilo/doc/tsilo_admin.xml @@ -181,6 +181,60 @@ if (is_method("REGISTER")) { @@ -118,143 +118,144 @@ index c294e7c282..965c339156 100644 diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c -index 7d951865f0..1847ac1c1b 100644 +index 7d95186..2781def 100644 --- a/src/modules/tsilo/ts_append.c +++ b/src/modules/tsilo/ts_append.c -@@ -139,3 +139,119 @@ done: +@@ -36,26 +36,37 @@ + #include "ts_hash.h" + #include "ts_append.h" - return ret; - } -+ -+int ts_append_by_contact(struct sip_msg* msg, str *ruri, str *contact, char *table) { -+ ts_urecord_t* _r; -+ ts_transaction_t* ptr; -+ -+ struct sip_uri p_uri; +-int ts_append(struct sip_msg* msg, str *ruri, char *table) { ++int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) { + ts_urecord_t* _r; + ts_transaction_t* ptr; + + struct sip_uri p_uri; + struct sip_uri c_uri; -+ str *t_uri; -+ -+ int res; -+ int appended; + str *t_uri; + + int res; + int appended; +- + + /* parse R-URI */ -+ if (use_domain) { -+ t_uri = ruri; -+ } else { -+ if (parse_uri(ruri->s, ruri->len, &p_uri) < 0) { -+ LM_ERR("tsilo: failed to parse uri %.*s\n", ruri->len, ruri->s); + if (use_domain) { + t_uri = ruri; + } else { +- if(parse_uri(ruri->s, ruri->len, &p_uri)<0) { ++ if(parse_uri(ruri->s, ruri->len, &p_uri) < 0) { + LM_ERR("failed to parse uri %.*s\n", ruri->len, ruri->s); + return -1; + } + t_uri = &p_uri.user; + } + ++ /* parse contact if given */ ++ if(contact->s != NULL && contact->len != 0) { ++ if (parse_uri(contact->s, contact->len, &c_uri) < 0) { ++ LM_ERR("failed to parse contact %.*s\n", ruri->len, ruri->s); + return -1; + } -+ t_uri = &p_uri.user; -+ } -+ -+ /* parse contact */ -+ if (parse_uri(contact->s, contact->len, &c_uri) < 0) { -+ LM_ERR("tsilo: failed to parse contact %.*s\n", ruri->len, ruri->s); -+ return -1; + } + + /* find urecord in TSILO cache */ -+ lock_entry_by_ruri(t_uri); -+ res = get_ts_urecord(t_uri, &_r); -+ -+ if (res != 0) { -+ LM_ERR("tsilo: failed to retrieve record for %.*s\n", t_uri->len, t_uri->s); -+ unlock_entry_by_ruri(t_uri); -+ return -1; -+ } -+ + lock_entry_by_ruri(t_uri); + + res = get_ts_urecord(t_uri, &_r); +@@ -66,12 +77,13 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) { + return -1; + } + + /* cycle through existing transactions */ -+ ptr = _r->transactions; -+ while(ptr) { -+ LM_DBG("tsilo: transaction %u:%u found for %.*s, going to append branches\n", -+ ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s); -+ /* append only if the desired contact has been found in locations */ -+ appended = ts_append_by_contact_to(msg, ptr->tindex, ptr->tlabel, table, ruri, contact); -+ if (appended > 0) -+ update_stat(added_branches, appended); -+ ptr = ptr->next; + ptr = _r->transactions; + + while(ptr) { + LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s); + +- appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri); ++ appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri, contact); + if (appended > 0) + update_stat(added_branches, appended); + ptr = ptr->next; +@@ -82,23 +94,28 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) { + return 1; + } + +-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri) { ++int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact) { + struct cell *t=0; +- struct cell *orig_t; ++ struct cell *orig_t; /* a pointer to an existing transaction or 0 if lookup fails */ + struct sip_msg *orig_msg; + int ret; + str stable; + ++ if(contact->s!=NULL && contact->len > 0) { ++ LM_DBG("trying to append based on specific contact <%.*s>\n", contact->len, contact->s); + } + -+ unlock_entry_by_ruri(t_uri); -+ -+ return 1; -+} -+ -+int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact) { -+ struct cell *t=0; -+ struct cell *orig_t; /* a pointer to an existing transaction or 0 if lookup fails*/ -+ struct sip_msg *orig_msg; -+ int ret; -+ str stable; -+ -+ LM_DBG("tsilo: trying to append based on contact <%.*s>\n", contact->len, contact->s); -+ + /* lookup a transaction based on its identifier (hash_index:label) */ -+ orig_t = _tmb.t_gett(); -+ if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) -+ { -+ LM_ERR("tsilo: transaction [%u:%u] not found\n", tindex, tlabel); -+ ret = -1; -+ goto done; -+ } -+ + orig_t = _tmb.t_gett(); + + if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) + { +- LM_ERR("transaction [%u:%u] not found\n", +- tindex, tlabel); ++ LM_ERR("transaction [%u:%u] not found\n", tindex, tlabel); + ret = -1; + goto done; + } + + /* check if the dialog is still in the early stage */ -+ if (t->flags & T_CANCELED) { -+ LM_DBG("tsilo: trasaction [%u:%u] was cancelled\n", tindex, tlabel); -+ ret = -2; -+ goto done; -+ } -+ if (t->uas.status >= 200) { -+ LM_DBG("tsilo: trasaction [%u:%u] sent out a final response already - %d\n", -+ tindex, tlabel, t->uas.status); -+ ret = -3; -+ goto done; -+ } -+ + if (t->flags & T_CANCELED) { + LM_DBG("trasaction [%u:%u] was cancelled\n", + tindex, tlabel); +@@ -113,10 +130,11 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str * + goto done; + } + + /* get original (very first) request of the transaction */ -+ orig_msg = t->uas.request; -+ stable.s = table; -+ stable.len = strlen(stable.s); -+ -+ if(uri==NULL || uri->s==NULL || uri->len<=0) { -+ ret = _regapi.lookup_to_dset(orig_msg, &stable, NULL); -+ } else { -+ ret = _regapi.lookup_to_dset(orig_msg, &stable, uri); -+ } -+ -+ if(ret != 1) { -+ LM_ERR("tsilo: transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); -+ ret = -4; -+ goto done; -+ } -+ -+ /* start the transaction only for the desired contact -+ contact must be of syntax: sip:@: with no parameters list*/ -+ ret = _tmb.t_append_branch_by_contact(contact); -+ -+done: -+ /* unref the transaction which had been referred by t_lookup_ident() call. -+ * Restore the original transaction (if any) */ -+ if(t) _tmb.unref_cell(t); -+ _tmb.t_sett(orig_t, T_BR_UNDEFINED); + orig_msg = t->uas.request; +- + stable.s = table; + stable.len = strlen(stable.s); + -+ return ret; -+} + if(uri==NULL || uri->s==NULL || uri->len<=0) { + ret = _regapi.lookup_to_dset(orig_msg, &stable, NULL); + } else { +@@ -124,12 +142,14 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str * + } + + if(ret != 1) { +- LM_DBG("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); ++ LM_ERR("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); + ret = -4; + goto done; + } + +- ret = _tmb.t_append_branches(); ++ /* if the contact has been given previously ++ then do a new append only for the desired location */ ++ ret = _tmb.t_append_branches(contact); + + done: + /* unref the transaction which had been referred by t_lookup_ident() call. diff --git a/src/modules/tsilo/ts_append.h b/src/modules/tsilo/ts_append.h -index 56f91204df..461f8881f3 100644 +index 56f9120..02f3244 100644 --- a/src/modules/tsilo/ts_append.h +++ b/src/modules/tsilo/ts_append.h -@@ -24,5 +24,7 @@ +@@ -22,7 +22,7 @@ + #ifndef _TS_APPEND_H + #define _TS_APPEND_H - int ts_append(struct sip_msg* msg, str *ruri, char *table); - int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri); -+int ts_append_by_contact(struct sip_msg* msg, str *ruri, str *contact, char *table); -+int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact); +-int ts_append(struct sip_msg* msg, str *ruri, char *table); +-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri); ++int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table); ++int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact); #endif diff --git a/src/modules/tsilo/tsilo.c b/src/modules/tsilo/tsilo.c -index 0c531acc74..2eefb2fe2d 100644 +index 0c531ac..9769a3c 100644 --- a/src/modules/tsilo/tsilo.c +++ b/src/modules/tsilo/tsilo.c @@ -34,6 +34,8 @@ @@ -312,10 +313,110 @@ index 0c531acc74..2eefb2fe2d 100644 /** * */ -@@ -357,6 +382,238 @@ static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel, - _table->s, _uri); +@@ -250,6 +275,9 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri) + str ruri = STR_NULL; + int rc; + ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ + if(_ruri==NULL || (fixup_get_svalue(_msg, (gparam_p)_ruri, &tmp)!=0 || tmp.len<=0)) { + LM_ERR("invalid ruri parameter\n"); + return -1; +@@ -260,7 +288,7 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri) + if (pkg_str_dup(&ruri, &tmp) < 0) + return -1; + +- rc = ts_append(_msg, &ruri, _table); ++ rc = ts_append(_msg, &ruri, &contact, _table); + + pkg_free(ruri.s); + +@@ -275,13 +303,16 @@ static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri) + str ruri = STR_NULL; + int rc; + ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ + if(ts_check_uri(_ruri)<0) + return -1; + + if (pkg_str_dup(&ruri, _ruri) < 0) + return -1; + +- rc = ts_append(_msg, &ruri, _table->s); ++ rc = ts_append(_msg, &ruri, &contact, _table->s); + + pkg_free(ruri.s); + +@@ -296,6 +327,9 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table + unsigned int tindex; + unsigned int tlabel; + ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ + if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) { + LM_ERR("cannot get transaction index\n"); + return -1; +@@ -306,7 +340,8 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table + return -1; + } + +- return ts_append_to(msg, tindex, tlabel, table, 0); ++ /* we do not want to do append by particular location here */ ++ return ts_append_to(msg, tindex, tlabel, table, 0, &contact); + } + + /** +@@ -314,8 +349,12 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table + */ + static int ki_ts_append_to(sip_msg_t* _msg, int tindex, int tlabel, str *_table) + { ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ ++ /* we do not want to do append by particular location here */ + return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel, +- _table->s, 0); ++ _table->s, 0, &contact); + } + + /** +@@ -327,6 +366,9 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl + unsigned int tlabel; + str suri; + ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ + if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) { + LM_ERR("cannot get transaction index\n"); + return -1; +@@ -344,7 +386,8 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl + if(ts_check_uri(&suri)<0) + return -1; + +- return ts_append_to(msg, tindex, tlabel, table, &suri); ++ /* we do not want to do append by particular location here */ ++ return ts_append_to(msg, tindex, tlabel, table, &suri, &contact); } + /** +@@ -353,8 +396,244 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl + static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel, + str *_table, str *_uri) + { ++ /* we do not want to do append by particular location */ ++ str contact = STR_NULL; ++ ++ /* we do not want to do append by particular location here */ + return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel, +- _table->s, _uri); ++ _table->s, _uri, &contact); ++} ++ +/** + * + */ @@ -389,7 +490,7 @@ index 0c531acc74..2eefb2fe2d 100644 + } + + /* contact must be of syntax: sip:@: with no parameters list */ -+ rc = ts_append_by_contact(_msg, &ruri, &contact, _table); ++ rc = ts_append(_msg, &ruri, &contact, _table); + + /* free previously used memory */ + pkg_free(ruri.s); @@ -446,7 +547,7 @@ index 0c531acc74..2eefb2fe2d 100644 + } + + /* contact must be of syntax: sip:@: with no parameters list */ -+ rc = ts_append_by_contact(_msg, &ruri, &contact, _table->s); ++ rc = ts_append(_msg, &ruri, &contact, _table->s); + + pkg_free(ruri.s); + pkg_free(contact.s); @@ -510,7 +611,7 @@ index 0c531acc74..2eefb2fe2d 100644 + } + + /* contact must be of syntax: sip:@: with no parameters list */ -+ rc = ts_append_by_contact(_msg, &ruri, &contact, _table); ++ rc = ts_append(_msg, &ruri, &contact, _table); + + pkg_free(ruri.s); + pkg_free(contact.s); @@ -540,18 +641,16 @@ index 0c531acc74..2eefb2fe2d 100644 + return -1; + + /* contact must be of syntax: sip:@: with no parameters list */ -+ rc = ts_append_by_contact(_msg, &ruri, &contact, _table->s); ++ rc = ts_append(_msg, &ruri, &contact, _table->s); + + pkg_free(ruri.s); + pkg_free(contact.s); + + return rc; -+} -+ + } + /** - * - */ -@@ -417,6 +674,16 @@ static sr_kemi_t sr_kemi_tsilo_exports[] = { +@@ -417,6 +696,16 @@ static sr_kemi_t sr_kemi_tsilo_exports[] = { { SR_KEMIP_INT, SR_KEMIP_INT, SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE } }, @@ -568,484 +667,3 @@ index 0c531acc74..2eefb2fe2d 100644 { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } }; --- -2.25.1 - -From 474649171d3c269e2fcfb00c7b1dbd318a952f51 Mon Sep 17 00:00:00 2001 -From: Donat Zenichev -Date: Sun, 14 Nov 2021 23:13:15 +0200 -Subject: [PATCH] tsilo: Be compliant with changes in TM, now only - t_append_branches() - -Since of changes in TM's module, where 't_append_branches()' and -'t_append_branch_by_contact()' have been merged into one function, -we need to edit all the occurences where TM's API is called -in TSILO. - -No logic changes. ---- - src/modules/tsilo/ts_append.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c -index 1847ac1c1b..e4967f8167 100644 ---- a/src/modules/tsilo/ts_append.c -+++ b/src/modules/tsilo/ts_append.c -@@ -89,6 +89,10 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str * - int ret; - str stable; - -+ str contact; /* needed for usage of TM's API, t_append_branches() */ -+ contact.s = NULL; /* must be emptied */ -+ contact.len = 0; -+ - orig_t = _tmb.t_gett(); - - if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) -@@ -129,7 +133,7 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str * - goto done; - } - -- ret = _tmb.t_append_branches(); -+ ret = _tmb.t_append_branches(&contact); - - done: - /* unref the transaction which had been referred by t_lookup_ident() call. -@@ -245,7 +249,7 @@ int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *t - - /* start the transaction only for the desired contact - contact must be of syntax: sip:@: with no parameters list*/ -- ret = _tmb.t_append_branch_by_contact(contact); -+ ret = _tmb.t_append_branches(contact); - - done: - /* unref the transaction which had been referred by t_lookup_ident() call. --- -2.25.1 - -From c1fd9ebaa0fe0eb7457ea74e8a22444b855af9cd Mon Sep 17 00:00:00 2001 -From: Donat Zenichev -Date: Wed, 17 Nov 2021 16:27:37 +0200 -Subject: [PATCH] tsilo: Merge similar functions in ts_append.c - -We need to merge similar functions in ts_append.c implementation -to give less work for maintaining similar code. -Furthermore the purpose of them is quite the same, -but differes just in some details (usage of TM's API). - -Merged functions are: -- ts_append() and ts_append_by_contact() -- ts_append_to() and ts_append_by_contact_to() - -Now all appending in TSILO happens only through ts_append() / ts_append_to() -An implementation in tsilo.c has been updated accordingly. - -Usage. -In case we do not want to append based on specific Contact (location), -the contact parameter being passed to either ts_append() or ts_append_to() -must be set to zero. -In case we do want to append by a specific Contact, then we must -set the Contact parameter of str type beforehand calling ts_append() / ts_append_to(). ---- - src/modules/tsilo/ts_append.c | 154 ++++++---------------------------- - src/modules/tsilo/ts_append.h | 6 +- - src/modules/tsilo/tsilo.c | 42 +++++++--- - 3 files changed, 61 insertions(+), 141 deletions(-) - -diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c -index e4967f8167..2781deffc4 100644 ---- a/src/modules/tsilo/ts_append.c -+++ b/src/modules/tsilo/ts_append.c -@@ -36,26 +36,37 @@ - #include "ts_hash.h" - #include "ts_append.h" - --int ts_append(struct sip_msg* msg, str *ruri, char *table) { -+int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) { - ts_urecord_t* _r; - ts_transaction_t* ptr; - - struct sip_uri p_uri; -+ struct sip_uri c_uri; - str *t_uri; - - int res; - int appended; -- -+ -+ /* parse R-URI */ - if (use_domain) { - t_uri = ruri; - } else { -- if(parse_uri(ruri->s, ruri->len, &p_uri)<0) { -+ if(parse_uri(ruri->s, ruri->len, &p_uri) < 0) { - LM_ERR("failed to parse uri %.*s\n", ruri->len, ruri->s); - return -1; - } - t_uri = &p_uri.user; - } - -+ /* parse contact if given */ -+ if(contact->s != NULL && contact->len != 0) { -+ if (parse_uri(contact->s, contact->len, &c_uri) < 0) { -+ LM_ERR("failed to parse contact %.*s\n", ruri->len, ruri->s); -+ return -1; -+ } -+ } -+ -+ /* find urecord in TSILO cache */ - lock_entry_by_ruri(t_uri); - - res = get_ts_urecord(t_uri, &_r); -@@ -66,12 +77,13 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) { - return -1; - } - -+ /* cycle through existing transactions */ - ptr = _r->transactions; - - while(ptr) { - LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s); - -- appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri); -+ appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri, contact); - if (appended > 0) - update_stat(added_branches, appended); - ptr = ptr->next; -@@ -82,27 +94,28 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) { - return 1; - } - --int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri) { -+int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact) { - struct cell *t=0; -- struct cell *orig_t; -+ struct cell *orig_t; /* a pointer to an existing transaction or 0 if lookup fails */ - struct sip_msg *orig_msg; - int ret; - str stable; - -- str contact; /* needed for usage of TM's API, t_append_branches() */ -- contact.s = NULL; /* must be emptied */ -- contact.len = 0; -+ if(contact->s!=NULL && contact->len > 0) { -+ LM_DBG("trying to append based on specific contact <%.*s>\n", contact->len, contact->s); -+ } - -+ /* lookup a transaction based on its identifier (hash_index:label) */ - orig_t = _tmb.t_gett(); - - if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) - { -- LM_ERR("transaction [%u:%u] not found\n", -- tindex, tlabel); -+ LM_ERR("transaction [%u:%u] not found\n", tindex, tlabel); - ret = -1; - goto done; - } - -+ /* check if the dialog is still in the early stage */ - if (t->flags & T_CANCELED) { - LM_DBG("trasaction [%u:%u] was cancelled\n", - tindex, tlabel); -@@ -117,119 +130,6 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str * - goto done; - } - -- orig_msg = t->uas.request; -- -- stable.s = table; -- stable.len = strlen(stable.s); -- if(uri==NULL || uri->s==NULL || uri->len<=0) { -- ret = _regapi.lookup_to_dset(orig_msg, &stable, NULL); -- } else { -- ret = _regapi.lookup_to_dset(orig_msg, &stable, uri); -- } -- -- if(ret != 1) { -- LM_DBG("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); -- ret = -4; -- goto done; -- } -- -- ret = _tmb.t_append_branches(&contact); -- --done: -- /* unref the transaction which had been referred by t_lookup_ident() call. -- * Restore the original transaction (if any) */ -- if(t) _tmb.unref_cell(t); -- _tmb.t_sett(orig_t, T_BR_UNDEFINED); -- -- return ret; --} -- --int ts_append_by_contact(struct sip_msg* msg, str *ruri, str *contact, char *table) { -- ts_urecord_t* _r; -- ts_transaction_t* ptr; -- -- struct sip_uri p_uri; -- struct sip_uri c_uri; -- str *t_uri; -- -- int res; -- int appended; -- -- /* parse R-URI */ -- if (use_domain) { -- t_uri = ruri; -- } else { -- if (parse_uri(ruri->s, ruri->len, &p_uri) < 0) { -- LM_ERR("tsilo: failed to parse uri %.*s\n", ruri->len, ruri->s); -- return -1; -- } -- t_uri = &p_uri.user; -- } -- -- /* parse contact */ -- if (parse_uri(contact->s, contact->len, &c_uri) < 0) { -- LM_ERR("tsilo: failed to parse contact %.*s\n", ruri->len, ruri->s); -- return -1; -- } -- -- /* find urecord in TSILO cache */ -- lock_entry_by_ruri(t_uri); -- res = get_ts_urecord(t_uri, &_r); -- -- if (res != 0) { -- LM_ERR("tsilo: failed to retrieve record for %.*s\n", t_uri->len, t_uri->s); -- unlock_entry_by_ruri(t_uri); -- return -1; -- } -- -- /* cycle through existing transactions */ -- ptr = _r->transactions; -- while(ptr) { -- LM_DBG("tsilo: transaction %u:%u found for %.*s, going to append branches\n", -- ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s); -- /* append only if the desired contact has been found in locations */ -- appended = ts_append_by_contact_to(msg, ptr->tindex, ptr->tlabel, table, ruri, contact); -- if (appended > 0) -- update_stat(added_branches, appended); -- ptr = ptr->next; -- } -- -- unlock_entry_by_ruri(t_uri); -- -- return 1; --} -- --int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact) { -- struct cell *t=0; -- struct cell *orig_t; /* a pointer to an existing transaction or 0 if lookup fails*/ -- struct sip_msg *orig_msg; -- int ret; -- str stable; -- -- LM_DBG("tsilo: trying to append based on contact <%.*s>\n", contact->len, contact->s); -- -- /* lookup a transaction based on its identifier (hash_index:label) */ -- orig_t = _tmb.t_gett(); -- if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) -- { -- LM_ERR("tsilo: transaction [%u:%u] not found\n", tindex, tlabel); -- ret = -1; -- goto done; -- } -- -- /* check if the dialog is still in the early stage */ -- if (t->flags & T_CANCELED) { -- LM_DBG("tsilo: trasaction [%u:%u] was cancelled\n", tindex, tlabel); -- ret = -2; -- goto done; -- } -- if (t->uas.status >= 200) { -- LM_DBG("tsilo: trasaction [%u:%u] sent out a final response already - %d\n", -- tindex, tlabel, t->uas.status); -- ret = -3; -- goto done; -- } -- - /* get original (very first) request of the transaction */ - orig_msg = t->uas.request; - stable.s = table; -@@ -242,13 +142,13 @@ int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *t - } - - if(ret != 1) { -- LM_ERR("tsilo: transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); -+ LM_ERR("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret); - ret = -4; - goto done; - } - -- /* start the transaction only for the desired contact -- contact must be of syntax: sip:@: with no parameters list*/ -+ /* if the contact has been given previously -+ then do a new append only for the desired location */ - ret = _tmb.t_append_branches(contact); - - done: -diff --git a/src/modules/tsilo/ts_append.h b/src/modules/tsilo/ts_append.h -index 461f8881f3..02f3244b27 100644 ---- a/src/modules/tsilo/ts_append.h -+++ b/src/modules/tsilo/ts_append.h -@@ -22,9 +22,7 @@ - #ifndef _TS_APPEND_H - #define _TS_APPEND_H - --int ts_append(struct sip_msg* msg, str *ruri, char *table); --int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri); --int ts_append_by_contact(struct sip_msg* msg, str *ruri, str *contact, char *table); --int ts_append_by_contact_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact); -+int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table); -+int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact); - - #endif -diff --git a/src/modules/tsilo/tsilo.c b/src/modules/tsilo/tsilo.c -index 2eefb2fe2d..9769a3c7d8 100644 ---- a/src/modules/tsilo/tsilo.c -+++ b/src/modules/tsilo/tsilo.c -@@ -275,6 +275,9 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri) - str ruri = STR_NULL; - int rc; - -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ - if(_ruri==NULL || (fixup_get_svalue(_msg, (gparam_p)_ruri, &tmp)!=0 || tmp.len<=0)) { - LM_ERR("invalid ruri parameter\n"); - return -1; -@@ -285,7 +288,7 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri) - if (pkg_str_dup(&ruri, &tmp) < 0) - return -1; - -- rc = ts_append(_msg, &ruri, _table); -+ rc = ts_append(_msg, &ruri, &contact, _table); - - pkg_free(ruri.s); - -@@ -300,13 +303,16 @@ static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri) - str ruri = STR_NULL; - int rc; - -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ - if(ts_check_uri(_ruri)<0) - return -1; - - if (pkg_str_dup(&ruri, _ruri) < 0) - return -1; - -- rc = ts_append(_msg, &ruri, _table->s); -+ rc = ts_append(_msg, &ruri, &contact, _table->s); - - pkg_free(ruri.s); - -@@ -321,6 +327,9 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table - unsigned int tindex; - unsigned int tlabel; - -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ - if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) { - LM_ERR("cannot get transaction index\n"); - return -1; -@@ -331,7 +340,8 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table - return -1; - } - -- return ts_append_to(msg, tindex, tlabel, table, 0); -+ /* we do not want to do append by particular location here */ -+ return ts_append_to(msg, tindex, tlabel, table, 0, &contact); - } - - /** -@@ -339,8 +349,12 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table - */ - static int ki_ts_append_to(sip_msg_t* _msg, int tindex, int tlabel, str *_table) - { -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ -+ /* we do not want to do append by particular location here */ - return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel, -- _table->s, 0); -+ _table->s, 0, &contact); - } - - /** -@@ -352,6 +366,9 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl - unsigned int tlabel; - str suri; - -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ - if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) { - LM_ERR("cannot get transaction index\n"); - return -1; -@@ -369,7 +386,8 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl - if(ts_check_uri(&suri)<0) - return -1; - -- return ts_append_to(msg, tindex, tlabel, table, &suri); -+ /* we do not want to do append by particular location here */ -+ return ts_append_to(msg, tindex, tlabel, table, &suri, &contact); - } - - /** -@@ -378,8 +396,12 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl - static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel, - str *_table, str *_uri) - { -+ /* we do not want to do append by particular location */ -+ str contact = STR_NULL; -+ -+ /* we do not want to do append by particular location here */ - return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel, -- _table->s, _uri); -+ _table->s, _uri, &contact); - } - - /** -@@ -455,7 +477,7 @@ static int w_ts_append_by_contact2(struct sip_msg* _msg, char *_table, char *_ru - } - - /* contact must be of syntax: sip:@: with no parameters list */ -- rc = ts_append_by_contact(_msg, &ruri, &contact, _table); -+ rc = ts_append(_msg, &ruri, &contact, _table); - - /* free previously used memory */ - pkg_free(ruri.s); -@@ -512,7 +534,7 @@ static int ki_ts_append_by_contact(sip_msg_t* _msg, str *_table, str *_ruri) { - } - - /* contact must be of syntax: sip:@: with no parameters list */ -- rc = ts_append_by_contact(_msg, &ruri, &contact, _table->s); -+ rc = ts_append(_msg, &ruri, &contact, _table->s); - - pkg_free(ruri.s); - pkg_free(contact.s); -@@ -576,7 +598,7 @@ static int w_ts_append_by_contact3(struct sip_msg* _msg, char *_table, char *_ru - } - - /* contact must be of syntax: sip:@: with no parameters list */ -- rc = ts_append_by_contact(_msg, &ruri, &contact, _table); -+ rc = ts_append(_msg, &ruri, &contact, _table); - - pkg_free(ruri.s); - pkg_free(contact.s); -@@ -606,7 +628,7 @@ static int ki_ts_append_by_contact_uri(sip_msg_t* _msg, str *_table, str *_ruri, - return -1; - - /* contact must be of syntax: sip:@: with no parameters list */ -- rc = ts_append_by_contact(_msg, &ruri, &contact, _table->s); -+ rc = ts_append(_msg, &ruri, &contact, _table->s); - - pkg_free(ruri.s); - pkg_free(contact.s); --- -2.25.1 -