Skip to content

Commit

Permalink
Merge pull request #2275 from kamailio/grumvalski/ds_outbound_proxy
Browse files Browse the repository at this point in the history
Grumvalski/ds outbound proxy
  • Loading branch information
grumvalski committed Apr 9, 2020
2 parents 0b3a669 + 8fa5e4f commit 541d1bd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/modules/dispatcher/dispatch.c
Expand Up @@ -324,6 +324,9 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
} else if(pit->name.len == 9
&& strncasecmp(pit->name.s, "ping_from", 9) == 0) {
dest->attrs.ping_from = pit->body;
} else if(pit->name.len == 7
&& strncasecmp(pit->name.s, "obproxy", 7) == 0) {
dest->attrs.obproxy = pit->body;
}
}
if(params_list)
Expand Down Expand Up @@ -3295,6 +3298,7 @@ void ds_ping_set(ds_set_t *node)
uac_req_t uac_r;
int i, j;
str ping_from;
str obproxy;

if(!node)
return;
Expand Down Expand Up @@ -3342,10 +3346,20 @@ void ds_ping_set(ds_set_t *node)
LM_DBG("Default ping_from: %.*s\n", ping_from.len, ping_from.s);
}

if(node->dlist[j].attrs.obproxy.s != NULL
&& node->dlist[j].attrs.obproxy.len > 0) {
obproxy = node->dlist[j].attrs.obproxy;
LM_DBG("outbound proxy: %.*s\n", obproxy.len, obproxy.s);
}
else {
obproxy = ds_outbound_proxy;
LM_DBG("Default outbound proxy: %.*s\n", ds_outbound_proxy.len, ds_outbound_proxy.s);
}

gettimeofday(&node->dlist[j].latency_stats.start, NULL);

if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
&ping_from, &ds_outbound_proxy)
&ping_from, &obproxy)
< 0) {
LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
node->dlist[j].uri.s);
Expand Down
1 change: 1 addition & 0 deletions src/modules/dispatcher/dispatch.h
Expand Up @@ -188,6 +188,7 @@ typedef struct _ds_attrs {
int rweight;
int congestion_control;
str ping_from;
str obproxy;
} ds_attrs_t;

typedef struct _ds_latency_stats {
Expand Down
6 changes: 4 additions & 2 deletions src/modules/dispatcher/dispatcher.c
Expand Up @@ -1573,7 +1573,7 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
rpc->fault(ctx, 500, "Internal error creating dest struct");
return -1;
}
if(rpc->struct_add(wh, "SSdddSS",
if(rpc->struct_add(wh, "SSdddSSS",
"BODY", &(node->dlist[j].attrs.body),
"DUID", (node->dlist[j].attrs.duid.s)
? &(node->dlist[j].attrs.duid) : &data,
Expand All @@ -1583,7 +1583,9 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
"SOCKET", (node->dlist[j].attrs.socket.s)
? &(node->dlist[j].attrs.socket) : &data,
"SOCKNAME", (node->dlist[j].attrs.sockname.s)
? &(node->dlist[j].attrs.sockname) : &data)
? &(node->dlist[j].attrs.sockname) : &data,
"OBPROXY", (node->dlist[j].attrs.obproxy.s)
? &(node->dlist[j].attrs.obproxy) : &data)
< 0) {
rpc->fault(ctx, 500, "Internal error creating attrs struct");
return -1;
Expand Down
9 changes: 9 additions & 0 deletions src/modules/dispatcher/doc/dispatcher.xml
Expand Up @@ -59,6 +59,11 @@
<surname>Chavanton</surname>
<email>jchavanton@gmail.com</email>
</editor>
<editor>
<firstname>Federico</firstname>
<surname>Cabiddu</surname>
<email>federico.cabiddu@gmail.com</email>
</editor>
</authorgroup>
<copyright>
<year>2004</year>
Expand All @@ -84,6 +89,10 @@
<year>2017, 2018</year>
<holder>Julien chavanton, Flowroute</holder>
</copyright>
<copyright>
<year>2020</year>
<holder>Federico Cabiddu, Libon</holder>
</copyright>
</bookinfo>
<toc></toc>

Expand Down
5 changes: 5 additions & 0 deletions src/modules/dispatcher/doc/dispatcher_admin.xml
Expand Up @@ -1316,6 +1316,7 @@ DEST: {
RWEIGHT: 50
SOCKET:
SOCKNAME:
OBPROXY:
}
LATENCY: {
AVG: 20.104000
Expand Down Expand Up @@ -2055,6 +2056,10 @@ DEST: {
'ping_from' - used to set the From URI in OPTIONS keepalives.
It overwrites the general ds_ping_from parameter.
</listitem>
<listitem>
'obproxy' - SIP URI of outbound proxy to be used when sending pings.
It overwrites the general ds_outbound_proxy parameter.
</listitem>
</itemizedlist>
</para>
</section>
Expand Down

0 comments on commit 541d1bd

Please sign in to comment.