Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/stir_shaken/stir_shaken.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,20 @@ static int build_unsigned_pport(str *buf, time_t iat_ts, str *attest,
return -1;
}

/* RFC 4904 allows telephone-related parameters (tgrp, trunk-context, ...) to
* be carried as semicolon-separated fields inside the userinfo part of a
* SIP/TEL URI (before the '@'). parse_uri() returns the whole userinfo in the
* .user field, so a value such as "+33123456789;tgrp=...;trunk-context=..."
* would otherwise fail the E.164 check. Keep only the leading telephone
* number by trimming at the first ';'. */
static inline void trim_tn_params(str *tn)
{
char *semi = q_memchr(tn->s, ';', tn->len);

if (semi)
tn->len = semi - tn->s;
}

static int get_orig_tn_from_msg(struct sip_msg *msg, str *orig_tn)
{
struct to_body *body;
Expand Down Expand Up @@ -889,6 +903,7 @@ static int get_orig_tn_from_msg(struct sip_msg *msg, str *orig_tn)
}

*orig_tn = parsed_uri.user;
trim_tn_params(orig_tn);

return 0;
}
Expand Down Expand Up @@ -920,6 +935,7 @@ static int get_dest_tn_from_msg(struct sip_msg *msg, str *dest_tn)
}

*dest_tn = parsed_uri.user;
trim_tn_params(dest_tn);

return 0;
}
Expand Down
Loading