Module: kamailio
Branch: master
Commit: 3f9c38be11416f7abe5c4448088ba66d2d3e6aad
URL:
https://github.com/kamailio/kamailio/commit/3f9c38be11416f7abe5c4448088ba66…
Author: Giacomo Vacca <giacomo.vacca(a)gmail.com>
Committer: Giacomo Vacca <giacomo.vacca(a)gmail.com>
Date: 2018-09-05T14:35:52+02:00
dispatcher: add ping_from attribute
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h
Modified: src/modules/dispatcher/doc/dispatcher_admin.xml
---
Diff:
https://github.com/kamailio/kamailio/commit/3f9c38be11416f7abe5c4448088ba66…
Patch:
https://github.com/kamailio/kamailio/commit/3f9c38be11416f7abe5c4448088ba66…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index cb87392eb8..0422cd6b20 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -300,6 +300,9 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
} else {
LM_ERR("rweight %d not in 1-100 range; skipped", tmp_rweight);
}
+ } else if(pit->name.len == 9
+ && strncasecmp(pit->name.s, "ping_from", 9) == 0) {
+ dest->attrs.ping_from = pit->body;
}
}
if(params_list)
@@ -3020,6 +3023,7 @@ void ds_ping_set(ds_set_t *node)
{
uac_req_t uac_r;
int i, j;
+ str ping_from;
if(!node)
return;
@@ -3051,10 +3055,21 @@ void ds_ping_set(ds_set_t *node)
uac_r.ssock = &ds_default_socket;
}
+ /* Overwrite default ping From URI with attribute */
+ if(node->dlist[j].attrs.ping_from.s != NULL
+ && node->dlist[j].attrs.ping_from.len > 0) {
+ ping_from = node->dlist[j].attrs.ping_from;
+ LM_DBG("ping_from: %.*s\n", ping_from.len, ping_from.s);
+ }
+ else {
+ ping_from = ds_ping_from;
+ LM_DBG("Default ping_from: %.*s\n", ping_from.len, ping_from.s);
+ }
+
gettimeofday(&node->dlist[j].latency_stats.start, NULL);
if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
- &ds_ping_from, &ds_outbound_proxy)
+ &ping_from, &ds_outbound_proxy)
< 0) {
LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
node->dlist[j].uri.s);
diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h
index 7845616714..7a798fc162 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -169,6 +169,7 @@ typedef struct _ds_attrs {
int weight;
int rweight;
int congestion_control;
+ str ping_from;
} ds_attrs_t;
typedef struct _ds_latency_stats {
diff --git a/src/modules/dispatcher/doc/dispatcher_admin.xml
b/src/modules/dispatcher/doc/dispatcher_admin.xml
index b113b284fd..b409c5208d 100644
--- a/src/modules/dispatcher/doc/dispatcher_admin.xml
+++ b/src/modules/dispatcher/doc/dispatcher_admin.xml
@@ -1829,6 +1829,10 @@ onreply_route {
It is used for sending the SIP traffic as well as
OPTIONS keepalives.
</listitem>
+ <listitem>
+ 'ping_from' - used to set the From URI in OPTIONS keepalives.
+ It overwrites the general ds_ping_from parameter.
+ </listitem>
</itemizedlist>
</para>
</section>
@@ -1848,7 +1852,7 @@ setid(int) destination(sip uri) flags(int,opt) priority(int,opt)
attrs(str,opt)
</para>
<programlisting format="linespecific">
...
-1 sip:127.0.0.1:5080 0 0 duid=abc;socket=udp:192.168.0.125:5060;my=xyz
+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
...
</programlisting>