... | ... |
@@ -410,6 +410,26 @@ modparam("topos", "a_contact_avp", "$avp(tps-act)") |
410 | 410 |
... |
411 | 411 |
modparam("topos", "b_contact_avp", "$avp(tps-bct)") |
412 | 412 |
... |
413 |
+</programlisting> |
|
414 |
+ </example> |
|
415 |
+ </section> |
|
416 |
+ <section id="topos.p.update_rr_dialog"> |
|
417 |
+ <title><varname>update_rr_dialog</varname> (int)</title> |
|
418 |
+ <para> |
|
419 |
+ If set to 1, topos module will track and update record |
|
420 |
+ route changes on re-invite. |
|
421 |
+ </para> |
|
422 |
+ <para> |
|
423 |
+ <emphasis> |
|
424 |
+ Default value is 0 (do not update record route changes within dialog). |
|
425 |
+ </emphasis> |
|
426 |
+ </para> |
|
427 |
+ <example> |
|
428 |
+ <title>Set <varname>update_rr_dialog</varname> parameter</title> |
|
429 |
+ <programlisting format="linespecific"> |
|
430 |
+... |
|
431 |
+modparam("topos", "update_rr_dialog", 1) |
|
432 |
+... |
|
413 | 433 |
</programlisting> |
414 | 434 |
</example> |
415 | 435 |
</section> |
... | ... |
@@ -78,6 +78,7 @@ sruid_t _tps_sruid; |
78 | 78 |
static str _tps_db_url = str_init(DEFAULT_DB_URL); |
79 | 79 |
int _tps_param_mask_callid = 0; |
80 | 80 |
int _tps_sanity_checks = 0; |
81 |
+int _tps_update_rr_dialog = 0; |
|
81 | 82 |
str _tps_storage = str_init("db"); |
82 | 83 |
|
83 | 84 |
extern int _tps_branch_expire; |
... | ... |
@@ -141,6 +142,7 @@ static param_export_t params[]={ |
141 | 142 |
{"cparam_name", PARAM_STR, &_tps_cparam_name}, |
142 | 143 |
{"a_contact_avp", PARAM_STR, &_tps_acontact_avp}, |
143 | 144 |
{"b_contact_avp", PARAM_STR, &_tps_bcontact_avp}, |
145 |
+ {"update_rr_dialog", PARAM_INT, &_tps_update_rr_dialog}, |
|
144 | 146 |
{0,0,0} |
145 | 147 |
}; |
146 | 148 |
|
... | ... |
@@ -49,6 +49,7 @@ |
49 | 49 |
extern int _tps_param_mask_callid; |
50 | 50 |
extern int _tps_contact_mode; |
51 | 51 |
extern str _tps_cparam_name; |
52 |
+extern int _tps_update_rr_dialog; |
|
52 | 53 |
|
53 | 54 |
str _sr_hname_xbranch = str_init("P-SR-XBranch"); |
54 | 55 |
str _sr_hname_xuuid = str_init("P-SR-XUID"); |
... | ... |
@@ -368,11 +369,18 @@ int tps_pack_message(sip_msg_t *msg, tps_data_t *ptsd) |
368 | 369 |
int vlen; |
369 | 370 |
int r2; |
370 | 371 |
int isreq; |
372 |
+ int update_rr_dialog = _tps_update_rr_dialog; |
|
371 | 373 |
|
372 | 374 |
if(ptsd->cp==NULL) { |
373 | 375 |
ptsd->cp = ptsd->cbuf; |
374 | 376 |
} |
375 | 377 |
|
378 |
+ if(_tps_update_rr_dialog) { |
|
379 |
+ if((msg->first_line.type==SIP_REQUEST) && !(get_to(msg)->tag_value.len>0)) { |
|
380 |
+ update_rr_dialog = 0; |
|
381 |
+ } |
|
382 |
+ } |
|
383 |
+ |
|
376 | 384 |
i = 0; |
377 | 385 |
for(hdr=msg->h_via1; hdr; hdr=next_sibling_hdr(hdr)) { |
378 | 386 |
for(via=(struct via_body*)hdr->parsed; via; via=via->next) { |
... | ... |
@@ -429,7 +437,7 @@ int tps_pack_message(sip_msg_t *msg, tps_data_t *ptsd) |
429 | 437 |
LM_ERR("no more space to pack rr headers\n"); |
430 | 438 |
return -1; |
431 | 439 |
} |
432 |
- if(isreq==1) { |
|
440 |
+ if(isreq==1 || update_rr_dialog) { |
|
433 | 441 |
/* sip request - get a+s-side record route */ |
434 | 442 |
if(i>1) { |
435 | 443 |
if(i==2 &&r2==0) { |
... | ... |
@@ -441,6 +449,12 @@ int tps_pack_message(sip_msg_t *msg, tps_data_t *ptsd) |
441 | 449 |
*ptsd->cp = ','; |
442 | 450 |
ptsd->cp++; |
443 | 451 |
ptsd->a_rr.len++; |
452 |
+ if(update_rr_dialog) { |
|
453 |
+ ptsd->b_rr.len++; |
|
454 |
+ } |
|
455 |
+ } |
|
456 |
+ if(i==1 && update_rr_dialog) { |
|
457 |
+ ptsd->b_rr.s = ptsd->cp; |
|
444 | 458 |
} |
445 | 459 |
*ptsd->cp = '<'; |
446 | 460 |
if(i==1) { |
... | ... |
@@ -458,6 +472,9 @@ int tps_pack_message(sip_msg_t *msg, tps_data_t *ptsd) |
458 | 472 |
|
459 | 473 |
ptsd->cp++; |
460 | 474 |
ptsd->a_rr.len++; |
475 |
+ if(update_rr_dialog) { |
|
476 |
+ ptsd->b_rr.len++; |
|
477 |
+ } |
|
461 | 478 |
|
462 | 479 |
memcpy(ptsd->cp, rr->nameaddr.uri.s, rr->nameaddr.uri.len); |
463 | 480 |
if(i==1) { |
... | ... |
@@ -483,6 +500,10 @@ int tps_pack_message(sip_msg_t *msg, tps_data_t *ptsd) |
483 | 500 |
*ptsd->cp = '>'; |
484 | 501 |
ptsd->cp++; |
485 | 502 |
ptsd->a_rr.len++; |
503 |
+ if(update_rr_dialog) { |
|
504 |
+ ptsd->b_rr.len += rr->nameaddr.uri.len; |
|
505 |
+ ptsd->b_rr.len++; |
|
506 |
+ } |
|
486 | 507 |
} else { |
487 | 508 |
/* sip response - get b-side record route */ |
488 | 509 |
if(i==1) { |
... | ... |
@@ -879,6 +900,11 @@ int tps_request_received(sip_msg_t *msg, int dialog) |
879 | 900 |
} |
880 | 901 |
if(dialog!=0) { |
881 | 902 |
tps_append_xuuid(msg, &stsd.a_uuid); |
903 |
+ if(_tps_update_rr_dialog) { |
|
904 |
+ if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_RPLATTRS|TPS_DBU_BRR)<0) { |
|
905 |
+ goto error; |
|
906 |
+ } |
|
907 |
+ } |
|
882 | 908 |
} |
883 | 909 |
return 0; |
884 | 910 |
|
... | ... |
@@ -934,7 +960,7 @@ int tps_response_received(sip_msg_t *msg) |
934 | 960 |
TPS_DBU_CONTACT|TPS_DBU_RPLATTRS)<0) { |
935 | 961 |
goto error; |
936 | 962 |
} |
937 |
- if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_RPLATTRS)<0) { |
|
963 |
+ if(tps_storage_update_dialog(msg, &mtsd, &stsd, _tps_update_rr_dialog?TPS_DBU_RPLATTRS|TPS_DBU_BRR|TPS_DBU_ARR:TPS_DBU_RPLATTRS)<0) { |
|
938 | 964 |
goto error; |
939 | 965 |
} |
940 | 966 |
tps_storage_lock_release(&lkey); |
... | ... |
@@ -1037,7 +1063,7 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int local) |
1037 | 1063 |
|
1038 | 1064 |
if(dialog!=0) { |
1039 | 1065 |
tps_storage_end_dialog(msg, &mtsd, ptsd); |
1040 |
- if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_CONTACT)<0) { |
|
1066 |
+ if(tps_storage_update_dialog(msg, &mtsd, &stsd, _tps_update_rr_dialog?TPS_DBU_CONTACT|TPS_DBU_ARR:TPS_DBU_CONTACT)<0) { |
|
1041 | 1067 |
goto error; |
1042 | 1068 |
} |
1043 | 1069 |
} |
... | ... |
@@ -39,7 +39,9 @@ |
39 | 39 |
|
40 | 40 |
#define TPS_DBU_CONTACT (1<<0) |
41 | 41 |
#define TPS_DBU_RPLATTRS (1<<1) |
42 |
-#define TPS_DBU_ALL (0xffffffff) |
|
42 |
+#define TPS_DBU_ARR (1<<2) |
|
43 |
+#define TPS_DBU_BRR (1<<3) |
|
44 |
+#define TPS_DBU_ALL (0xffffffff) |
|
43 | 45 |
|
44 | 46 |
#define TPS_DATA_SIZE 8192 |
45 | 47 |
typedef struct tps_data { |
... | ... |
@@ -1283,6 +1283,21 @@ int tps_redis_update_dialog(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd, |
1283 | 1283 |
} |
1284 | 1284 |
} |
1285 | 1285 |
|
1286 |
+ if(sd->b_tag.len>0 && ((mode & TPS_DBU_BRR) || (mode & TPS_DBU_ARR))) { |
|
1287 |
+ if(((md->direction == TPS_DIR_DOWNSTREAM) && (msg->first_line.type==SIP_REPLY)) || |
|
1288 |
+ ((md->direction == TPS_DIR_UPSTREAM) && (msg->first_line.type==SIP_REQUEST))) { |
|
1289 |
+ if(((sd->iflags&TPS_IFLAG_DLGON) == 0) && (mode & TPS_DBU_BRR)) { |
|
1290 |
+ TPS_REDIS_SET_ARGS(&md->b_rr, argc, &td_key_b_rr, argv, argvlen); |
|
1291 |
+ } |
|
1292 |
+ } |
|
1293 |
+ else { |
|
1294 |
+ if(((sd->iflags&TPS_IFLAG_DLGON) == 0) && (mode & TPS_DBU_ARR)) { |
|
1295 |
+ TPS_REDIS_SET_ARGS(&md->a_rr, argc, &td_key_a_rr, argv, argvlen); |
|
1296 |
+ TPS_REDIS_SET_ARGS(&md->s_rr, argc, &td_key_s_rr, argv, argvlen); |
|
1297 |
+ } |
|
1298 |
+ } |
|
1299 |
+ } |
|
1300 |
+ |
|
1286 | 1301 |
if(argc<=2) { |
1287 | 1302 |
return 0; |
1288 | 1303 |
} |