From 31d92814679fdeca96d7f90bb85938eb9894a4e4 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 2 Apr 2020 14:17:36 +0200 Subject: [PATCH] path: new param sockname_mode - if set to 1, socket name is added to Path URI in 'sn' param --- src/modules/path/path.c | 8 ++++++-- src/modules/path/path_mod.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/path/path.c b/src/modules/path/path.c index f95d68ab70b..55cd859c901 100644 --- a/src/modules/path/path.c +++ b/src/modules/path/path.c @@ -56,6 +56,8 @@ const static char *proto_strings[] = { [PROTO_WSS] = "%3Btransport%3Dws", }; +extern int path_sockname_mode; + static char *path_strzdup(char *src, int len) { char *res; @@ -187,7 +189,8 @@ static int prepend_path(sip_msg_t* _m, str *user, path_param_t param, l = insert_new_lump_before(l, prefix, prefix_len, 0); if (!l) goto out3; - l = insert_subst_lump_before(l, SUBST_SND_ALL, 0); + l = insert_subst_lump_before(l, + (path_sockname_mode)?SUBST_SND_ALL_EX:SUBST_SND_ALL, 0); if (!l) goto out2; l = insert_new_lump_before(l, suffix, cp - suffix, 0); if (!l) goto out2; @@ -197,7 +200,8 @@ static int prepend_path(sip_msg_t* _m, str *user, path_param_t param, if(dp==NULL) goto out1; l = insert_new_lump_before(l, dp, prefix_len, 0); if (!l) goto out1; - l = insert_subst_lump_before(l, SUBST_RCV_ALL, 0); + l = insert_subst_lump_before(l, + (path_sockname_mode)?SUBST_RCV_ALL_EX:SUBST_RCV_ALL, 0); if (!l) goto out1; dp = path_strzdup(suffix, cp - suffix); if(dp==NULL) goto out1; diff --git a/src/modules/path/path_mod.c b/src/modules/path/path_mod.c index 21f1a256df4..cc27d1a4576 100644 --- a/src/modules/path/path_mod.c +++ b/src/modules/path/path_mod.c @@ -68,6 +68,7 @@ int path_use_received = 0; int path_received_format = 0; int path_enable_r2 = 0; +int path_sockname_mode = 0; /*! \brief * Module initialization function prototype @@ -111,6 +112,7 @@ static param_export_t params[] = { {"use_received", INT_PARAM, &path_use_received }, {"received_format", INT_PARAM, &path_received_format }, {"enable_r2", INT_PARAM, &path_enable_r2 }, + {"sockname_mode", INT_PARAM, &path_sockname_mode }, { 0, 0, 0 } };