Skip to content

Commit

Permalink
rr: append_fromtag on upstream in-dialog requests
Browse files Browse the repository at this point in the history
Record-Routing for in-dialog request are not needed by RFC 3162. But
there are many clients out there not sending initial route-set in
in-dialog requests. To provided them with the initial route-set together
with UAC modified requests the ;ftag parameter must be the to-tag on
upstream requests.

append_fromtag parameter added the tag value from "from" header  always,
even on upstream. This is fixed here.

It is not done on record_route_preset(). This should not be called on
record routing anyway.
  • Loading branch information
schoberw authored and miconda committed Mar 9, 2016
1 parent 924a861 commit 92054da
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions modules/rr/record.c
Expand Up @@ -40,6 +40,7 @@
#include "../../data_lump.h"
#include "record.h"
#include "rr_mod.h"
#include "loose.h"


#define RR_PREFIX_SIP "Record-Route: <sip:"
Expand Down Expand Up @@ -375,7 +376,6 @@ int record_route(struct sip_msg* _m, str *params)
{
struct lump* l, *l2;
str user = {NULL, 0};
struct to_body* from = NULL;
str* tag;
int use_ob = rr_obb.use_outbound ? rr_obb.use_outbound(_m) : 0;
int sips;
Expand Down Expand Up @@ -404,13 +404,21 @@ int record_route(struct sip_msg* _m, str *params)
}

if (append_fromtag) {
if (parse_from_header(_m) < 0) {
LM_ERR("From parsing failed\n");
ret = -2;
goto error;
if (is_direction(_m, RR_FLOW_UPSTREAM) == 0) {
if (parse_to_header(_m) < 0) {
LM_ERR("To parsing failed\n");
ret = -2;
goto error;
}
tag = &((struct to_body*)_m->to->parsed)->tag_value;
} else {
if (parse_from_header(_m) < 0) {
LM_ERR("From parsing failed\n");
ret = -2;
goto error;
}
tag = &((struct to_body*)_m->from->parsed)->tag_value;
}
from = (struct to_body*)_m->from->parsed;
tag = &from->tag_value;
} else {
tag = 0;
}
Expand Down Expand Up @@ -777,12 +785,23 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
}

if (append_fromtag) {
if (parse_from_header(_m) < 0) {
LM_ERR("From parsing failed\n");
ret = -2;
goto error;
if (is_direction(_m, RR_FLOW_UPSTREAM) == 0) {
if (parse_to_header(_m) < 0) {
LM_ERR("To parsing failed\n");
ret = -2;
goto error;
}
tag = &((struct to_body*)_m->to->parsed)->tag_value;
} else {
if (parse_from_header(_m) < 0) {
LM_ERR("From parsing failed\n");
ret = -2;
goto error;
}
tag = &((struct to_body*)_m->from->parsed)->tag_value;
}
tag = &((struct to_body*)_m->from->parsed)->tag_value;
} else {
tag = 0;
}

sips = rr_is_sips(_m);
Expand Down

0 comments on commit 92054da

Please sign in to comment.