Skip to content

Commit

Permalink
mid_registrar: Improve the advertised socket logic
Browse files Browse the repository at this point in the history
Instead of blindly advertising the first UDP interface in the
self-generated, outgoing Contact URIs, the mid_registrar is now
aware of the next SIP hop and properly advertises the actual
sending interface which will be used. This includes any forced
send socket logic at script level.
  • Loading branch information
liviuchircu committed Jan 4, 2018
1 parent 3acaf2e commit 7bafce9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/mid_registrar/save.c
Expand Up @@ -146,8 +146,15 @@ static int trim_to_single_contact(struct sip_msg *msg, str *aor)
char *buf;
int e, is_dereg = 1, len, len1;
struct hdr_field *ct;
union sockaddr_union _;

adv_sock = *get_sock_info_list(PROTO_UDP);
/* get the source socket on the way to the next hop */
adv_sock = uri2sock(msg, GET_NEXT_HOP(msg), &_, PROTO_NONE);
if (!adv_sock) {
LM_ERR("failed to obtain next hop socket, ci=%.*s\n",
msg->callid->body.len, msg->callid->body.s);
return -1;
}

/* completely remove all Contact hfs, except the last one */
for (ct = msg->contact; ct && ct->sibling; ct = ct->sibling) {
Expand Down Expand Up @@ -249,6 +256,7 @@ static int overwrite_req_contacts(struct sip_msg *req,
uint64_t ctid;
struct ct_mapping *ctmap;
struct list_head *_;
union sockaddr_union __;

ul_api.lock_udomain(mri->dom, &mri->aor);
ul_api.get_urecord(mri->dom, &mri->aor, &r);
Expand All @@ -269,7 +277,13 @@ static int overwrite_req_contacts(struct sip_msg *req,
return -1;
}

adv_sock = *get_sock_info_list(PROTO_UDP);
/* get the source socket on the way to the next hop */
adv_sock = uri2sock(req, GET_NEXT_HOP(req), &__, PROTO_NONE);
if (!adv_sock) {
LM_ERR("failed to obtain next hop socket, ci=%.*s\n",
req->callid->body.len, req->callid->body.s);
return -1;
}

c = get_first_contact(req);
list_for_each(_, &mri->ct_mappings) {
Expand Down

0 comments on commit 7bafce9

Please sign in to comment.