Module: kamailio
Branch: master
Commit: 74ef108fe0371bd261acc42291d7adbba357f769
URL:
https://github.com/kamailio/kamailio/commit/74ef108fe0371bd261acc42291d7adb…
Author: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Committer: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Date: 2020-04-07T15:07:44+02:00
dispatcher: add new gateway attr "obproxy"
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h
Modified: src/modules/dispatcher/dispatcher.c
---
Diff:
https://github.com/kamailio/kamailio/commit/74ef108fe0371bd261acc42291d7adb…
Patch:
https://github.com/kamailio/kamailio/commit/74ef108fe0371bd261acc42291d7adb…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index b62d4c86de..6ded012085 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -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)
@@ -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;
@@ -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);
diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h
index e067d30478..6c167a9551 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -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 {
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index 06e96da61a..6ac01bbd2a 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -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,
@@ -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;