Module: kamailio
Branch: 4.4
Commit: 2250b3e562d6dbcab1477c7ed5a71daa7e462bb9
URL:
https://github.com/kamailio/kamailio/commit/2250b3e562d6dbcab1477c7ed5a71da…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-12-22T09:15:22+01:00
rtjson: enforce send socket with the attribute from json
- reported by Diego Nadares
(backport of 1d23f81353dd7a68b0f537e9a064587a5f733bb7)
---
Modified: modules/rtjson/rtjson_routing.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2250b3e562d6dbcab1477c7ed5a71da…
Patch:
https://github.com/kamailio/kamailio/commit/2250b3e562d6dbcab1477c7ed5a71da…
---
diff --git a/modules/rtjson/rtjson_routing.c b/modules/rtjson/rtjson_routing.c
index 60bdcad..5a21599 100644
--- a/modules/rtjson/rtjson_routing.c
+++ b/modules/rtjson/rtjson_routing.c
@@ -318,6 +318,7 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t
*iavp)
str val;
unsigned int bflags = 0;
unsigned int old_bflags = 0;
+ struct socket_info* fsocket = NULL;
tj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
@@ -370,6 +371,17 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t
*iavp)
}
}
+ rj = srjson_GetObjectItem(jdoc, nj, "socket");
+ if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL)
{
+ val.s = rj->valuestring;
+ val.len = strlen(val.s);
+ LM_DBG("trying to set send socket to: [%.*s]\n", val.len, val.s);
+ fsocket = lookup_local_socket(&val);
+ if(fsocket) {
+ set_force_socket(msg, fsocket);
+ }
+ }
+
rj = srjson_GetObjectItem(jdoc, nj, "branch_flags");
if(rj!=NULL && rj->type==srjson_Number && SRJSON_GET_UINT(rj)!=0) {
bflags = SRJSON_GET_UINT(rj);
@@ -498,6 +510,7 @@ int rtjson_append_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t
*nj)
str uri = {0};
str duri = {0};
str path = {0};
+ str socket = {0};
struct socket_info* fsocket = NULL;
unsigned int bflags = 0;
@@ -519,7 +532,12 @@ int rtjson_append_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t
*nj)
path.s = rj->valuestring;
path.len = strlen(path.s);
}
-
+ rj = srjson_GetObjectItem(jdoc, nj, "socket");
+ if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL)
{
+ socket.s = rj->valuestring;
+ socket.len = strlen(socket.s);
+ fsocket = lookup_local_socket(&socket);
+ }
if (append_branch(msg, &uri, &duri, &path, 0, bflags,
fsocket, 0 /*instance*/, 0,
0, 0) <0) {