Browse code

dispatcher: add ping_from attribute

Giacomo Vacca authored on 05/09/2018 12:35:52
Showing 3 changed files
... ...
@@ -300,6 +300,9 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
300 300
 			} else {
301 301
 				LM_ERR("rweight %d not in 1-100 range; skipped", tmp_rweight);
302 302
 			}
303
+		} else if(pit->name.len == 9
304
+				&& strncasecmp(pit->name.s, "ping_from", 9) == 0) {
305
+			dest->attrs.ping_from = pit->body;
303 306
 		}
304 307
 	}
305 308
 	if(params_list)
... ...
@@ -3020,6 +3023,7 @@ void ds_ping_set(ds_set_t *node)
3020 3020
 {
3021 3021
 	uac_req_t uac_r;
3022 3022
 	int i, j;
3023
+	str ping_from;
3023 3024
 
3024 3025
 	if(!node)
3025 3026
 		return;
... ...
@@ -3051,10 +3055,21 @@ void ds_ping_set(ds_set_t *node)
3051 3051
 				uac_r.ssock = &ds_default_socket;
3052 3052
 			}
3053 3053
 
3054
+			/* Overwrite default ping From URI with attribute */
3055
+			if(node->dlist[j].attrs.ping_from.s != NULL
3056
+					&& node->dlist[j].attrs.ping_from.len > 0) {
3057
+				ping_from = node->dlist[j].attrs.ping_from;
3058
+				LM_DBG("ping_from: %.*s\n", ping_from.len, ping_from.s);
3059
+			}
3060
+			else {
3061
+				ping_from = ds_ping_from;
3062
+				LM_DBG("Default ping_from: %.*s\n", ping_from.len, ping_from.s);
3063
+			}
3064
+
3054 3065
 			gettimeofday(&node->dlist[j].latency_stats.start, NULL);
3055 3066
 
3056 3067
 			if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
3057
-					   &ds_ping_from, &ds_outbound_proxy)
3068
+					   &ping_from, &ds_outbound_proxy)
3058 3069
 					< 0) {
3059 3070
 				LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
3060 3071
 						node->dlist[j].uri.s);
... ...
@@ -169,6 +169,7 @@ typedef struct _ds_attrs {
169 169
 	int weight;
170 170
 	int rweight;
171 171
 	int congestion_control;
172
+	str ping_from;
172 173
 } ds_attrs_t;
173 174
 
174 175
 typedef struct _ds_latency_stats {
... ...
@@ -1829,6 +1829,10 @@ onreply_route {
1829 1829
 					It is used for sending the SIP traffic as well as
1830 1830
 					OPTIONS keepalives.
1831 1831
 				</listitem>
1832
+				<listitem>
1833
+					'ping_from' - used to set the From URI in OPTIONS keepalives.
1834
+					It overwrites the general ds_ping_from parameter.
1835
+				</listitem>
1832 1836
 			</itemizedlist>
1833 1837
 		</para>
1834 1838
 		</section>
... ...
@@ -1848,7 +1852,7 @@ setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attrs(str,opt)
1848 1848
 		</para>
1849 1849
 		<programlisting format="linespecific">
1850 1850
 ...
1851
-1 sip:127.0.0.1:5080 0 0 duid=abc;socket=udp:192.168.0.125:5060;my=xyz
1851
+1 sip:127.0.0.1:5080 0 0 duid=abc;socket=udp:192.168.0.125:5060;my=xyz;ping_from=sip:myproxy.com
1852 1852
 ...
1853 1853
 </programlisting>
1854 1854