Skip to content

Commit

Permalink
registrar: Update the Contact URI on param-based matching
Browse files Browse the repository at this point in the history
(cherry picked from commit 8cc4b32)
  • Loading branch information
liviuchircu committed Jun 17, 2021
1 parent 4801023 commit 9a592a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/registrar/save.c
Expand Up @@ -444,7 +444,7 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,

/* pack the contact_info */
if ( (ci=pack_ci( 0, _c, e, 0, ul.nat_flag, _sctx->flags,
&_sctx->ownership_tag, NULL))==0 ) {
&_sctx->ownership_tag, &_sctx->cmatch))==0 ) {
LM_ERR("failed to extract contact info\n");
goto error;
}
Expand Down Expand Up @@ -511,7 +511,7 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,

/* pack the contact specific info */
if ( (ci=pack_ci( 0, _c, e, 0, ul.nat_flag, _sctx->flags,
&_sctx->ownership_tag, NULL))==0 ) {
&_sctx->ownership_tag, &_sctx->cmatch))==0 ) {
LM_ERR("failed to pack contact specific info\n");
goto error;
}
Expand Down
3 changes: 3 additions & 0 deletions modules/usrloc/urecord.c
Expand Up @@ -990,6 +990,9 @@ static inline struct ucontact* contact_params_match(ucontact_t* contacts,
}

for (param = _params; param; param = param->next) {
/* a bit counter-intuitive, but, according to RFC 3261 § 19.1.4, if
* an unknown URI parameter is missing from either URI,
* the matching of that parameter is successful! */
if (get_uri_param_val(&ct, &param->s, &v1) != 0 ||
get_uri_param_val(&cti, &param->s, &v2) != 0)
continue;
Expand Down
5 changes: 4 additions & 1 deletion parser/parse_uri.h
Expand Up @@ -111,7 +111,10 @@ static inline unsigned short get_uri_port(struct sip_uri* _uri,
* @param - URI param name to search for
* @val - output value
*
* Return: 0 on parser-recognized parameters or success, -1 otherwise
* Return:
* 0 on RFC-recognized parameters (even if they are missing!)
* or successful search of unknown ones
* -1 otherwise
*/
static inline int get_uri_param_val(const struct sip_uri *uri,
const str *param, str *val)
Expand Down

0 comments on commit 9a592a8

Please sign in to comment.