Browse code

dispatcher: add new gateway attr "obproxy"

Federico Cabiddu authored on 07/04/2020 12:37:29
Showing 3 changed files
... ...
@@ -324,6 +324,9 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
324 324
 		} else if(pit->name.len == 9
325 325
 				&& strncasecmp(pit->name.s, "ping_from", 9) == 0) {
326 326
 			dest->attrs.ping_from = pit->body;
327
+		} else if(pit->name.len == 7 
328
+				  && strncasecmp(pit->name.s, "obproxy", 7) == 0) {
329
+			dest->attrs.obproxy = pit->body;
327 330
 		}
328 331
 	}
329 332
 	if(params_list)
... ...
@@ -3295,6 +3298,7 @@ void ds_ping_set(ds_set_t *node)
3295 3298
 	uac_req_t uac_r;
3296 3299
 	int i, j;
3297 3300
 	str ping_from;
3301
+	str obproxy;
3298 3302
 
3299 3303
 	if(!node)
3300 3304
 		return;
... ...
@@ -3342,10 +3346,20 @@ void ds_ping_set(ds_set_t *node)
3342 3346
 				LM_DBG("Default ping_from: %.*s\n", ping_from.len, ping_from.s);
3343 3347
 			}
3344 3348
 
3349
+			if(node->dlist[j].attrs.obproxy.s != NULL
3350
+					&& node->dlist[j].attrs.obproxy.len > 0) {
3351
+				obproxy = node->dlist[j].attrs.obproxy;
3352
+				LM_DBG("outbound proxy: %.*s\n", obproxy.len, obproxy.s);
3353
+			}
3354
+			else {
3355
+				obproxy = ds_outbound_proxy;
3356
+				LM_DBG("Default outbound proxy: %.*s\n", ds_outbound_proxy.len, ds_outbound_proxy.s);
3357
+			}
3358
+
3345 3359
 			gettimeofday(&node->dlist[j].latency_stats.start, NULL);
3346 3360
 
3347 3361
 			if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
3348
-					   &ping_from, &ds_outbound_proxy)
3362
+					   &ping_from, &obproxy)
3349 3363
 					< 0) {
3350 3364
 				LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
3351 3365
 						node->dlist[j].uri.s);
... ...
@@ -188,6 +188,7 @@ typedef struct _ds_attrs {
188 188
 	int rweight;
189 189
 	int congestion_control;
190 190
 	str ping_from;
191
+	str obproxy;
191 192
 } ds_attrs_t;
192 193
 
193 194
 typedef struct _ds_latency_stats {
... ...
@@ -1573,7 +1573,7 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
1573 1573
 				rpc->fault(ctx, 500, "Internal error creating dest struct");
1574 1574
 				return -1;
1575 1575
 			}
1576
-			if(rpc->struct_add(wh, "SSdddSS",
1576
+			if(rpc->struct_add(wh, "SSdddSSS",
1577 1577
 						"BODY", &(node->dlist[j].attrs.body),
1578 1578
 						"DUID", (node->dlist[j].attrs.duid.s)
1579 1579
 									? &(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)
1583 1583
 						"SOCKET", (node->dlist[j].attrs.socket.s)
1584 1584
 									? &(node->dlist[j].attrs.socket) : &data,
1585 1585
 						"SOCKNAME", (node->dlist[j].attrs.sockname.s)
1586
-									? &(node->dlist[j].attrs.sockname) : &data)
1586
+									? &(node->dlist[j].attrs.sockname) : &data,
1587
+						"OBPROXY", (node->dlist[j].attrs.obproxy.s)
1588
+									? &(node->dlist[j].attrs.obproxy) : &data)
1587 1589
 					< 0) {
1588 1590
 				rpc->fault(ctx, 500, "Internal error creating attrs struct");
1589 1591
 				return -1;