Skip to content

Commit 072e522

Browse files
Change for non auto routed requests
1 parent 4940161 commit 072e522

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

modules/topology_hiding/th_no_dlg_logic.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static void th_no_dlg_onreply(struct cell *t, int type, struct tmcb_params *para
396396
str *additional_rrs = NULL;
397397
struct sip_msg *req = param->req;
398398
struct sip_msg *rpl = param->rpl;
399-
struct lump *lmp = NULL;
399+
struct lump *lmp = NULL, *rr_lmp = NULL;
400400
char *suffix = NULL, *req_rr_buf = NULL;
401401
int rr_count_to_delete = 0, rr_count_to_skip_encode = 0, req_rr_count = 0, req_rr_buf_len = 0;
402402
unsigned int flags = p->flags;
@@ -449,11 +449,18 @@ static void th_no_dlg_onreply(struct cell *t, int type, struct tmcb_params *para
449449
}
450450

451451
if (one_way_hiding) {
452-
if (!is_sequential && auto_route_on_trusted_socket) {
453-
if ((lmp = th_no_dlg_add_auto_record_route(rpl, flags)) == NULL) {
454-
LM_ERR("Failed to add Record-Route header\n");
455-
pkg_free(suffix);
456-
return;
452+
if (!is_sequential) {
453+
if (auto_route_on_trusted_socket) {
454+
rr_lmp = th_no_dlg_add_auto_record_route(rpl, flags);
455+
if (rr_lmp == NULL) {
456+
LM_ERR("Failed to add Record-Route header\n");
457+
pkg_free(suffix);
458+
return;
459+
}
460+
}
461+
462+
if (rr_lmp == NULL) {
463+
rr_lmp = anchor_lump(rpl, rpl->headers->name.s - rpl->buf, HDR_RECORDROUTE_T);
457464
}
458465

459466
if ((req_rr_count = list_rr_body(req->record_route, &additional_rrs)) < 0 ){
@@ -469,7 +476,7 @@ static void th_no_dlg_onreply(struct cell *t, int type, struct tmcb_params *para
469476
return;
470477
}
471478

472-
if (!(lmp = insert_new_lump_after(lmp, req_rr_buf, req_rr_buf_len, 0))) {
479+
if (!(rr_lmp = insert_new_lump_after(rr_lmp, req_rr_buf, req_rr_buf_len, 0))) {
473480
LM_ERR("failed to insert prefix\n");
474481
pkg_free(req_rr_buf);
475482
return;

0 commit comments

Comments
 (0)