Browse code

path: new param sockname_mode

- if set to 1, socket name is added to Path URI in 'sn' param

Daniel-Constantin Mierla authored on 02/04/2020 12:17:36
Showing 2 changed files
... ...
@@ -56,6 +56,8 @@ const static char *proto_strings[] = {
56 56
 	[PROTO_WSS] = "%3Btransport%3Dws",
57 57
 };
58 58
 
59
+extern int path_sockname_mode;
60
+
59 61
 static char *path_strzdup(char *src, int len)
60 62
 {
61 63
 	char *res;
... ...
@@ -187,7 +189,8 @@ static int prepend_path(sip_msg_t* _m, str *user, path_param_t param,
187 189
 
188 190
 	l = insert_new_lump_before(l, prefix, prefix_len, 0);
189 191
 	if (!l) goto out3;
190
-	l = insert_subst_lump_before(l, SUBST_SND_ALL, 0);
192
+	l = insert_subst_lump_before(l,
193
+			(path_sockname_mode)?SUBST_SND_ALL_EX:SUBST_SND_ALL, 0);
191 194
 	if (!l) goto out2;
192 195
 	l = insert_new_lump_before(l, suffix, cp - suffix, 0);
193 196
 	if (!l) goto out2;
... ...
@@ -197,7 +200,8 @@ static int prepend_path(sip_msg_t* _m, str *user, path_param_t param,
197 200
 		if(dp==NULL) goto out1;
198 201
 		l = insert_new_lump_before(l, dp, prefix_len, 0);
199 202
 		if (!l) goto out1;
200
-		l = insert_subst_lump_before(l, SUBST_RCV_ALL, 0);
203
+		l = insert_subst_lump_before(l,
204
+				(path_sockname_mode)?SUBST_RCV_ALL_EX:SUBST_RCV_ALL, 0);
201 205
 		if (!l) goto out1;
202 206
 		dp = path_strzdup(suffix, cp - suffix);
203 207
 		if(dp==NULL) goto out1;
... ...
@@ -68,6 +68,7 @@ int path_use_received = 0;
68 68
 
69 69
 int path_received_format = 0;
70 70
 int path_enable_r2 = 0;
71
+int path_sockname_mode = 0;
71 72
 
72 73
 /*! \brief
73 74
  * Module initialization function prototype
... ...
@@ -111,6 +112,7 @@ static param_export_t params[] = {
111 112
 	{"use_received",    INT_PARAM, &path_use_received },
112 113
 	{"received_format", INT_PARAM, &path_received_format },
113 114
 	{"enable_r2",       INT_PARAM, &path_enable_r2 },
115
+	{"sockname_mode",   INT_PARAM, &path_sockname_mode },
114 116
 	{ 0, 0, 0 }
115 117
 };
116 118