Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
ccc981e9
Commit
ccc981e9
authored
6 years ago
by
George Joseph
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "res/res_pjsip_nat: Fix logic for REINVITES"
parents
fe64ca0b
d0554783
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip_nat.c
+67
-7
67 additions, 7 deletions
res/res_pjsip_nat.c
with
67 additions
and
7 deletions
res/res_pjsip_nat.c
+
67
−
7
View file @
ccc981e9
...
...
@@ -45,10 +45,42 @@ static void rewrite_uri(pjsip_rx_data *rdata, pjsip_sip_uri *uri)
}
}
/*
* Update the Record-Route headers in the request or response and in the dialog
* object if exists.
*
* When NAT is in use, the address of the next hop in the SIP may be incorrect.
* To address this asterisk uses two strategies in parallel:
* 1. intercept the messages at the transaction level and rewrite the
* messages before arriving at the dialog layer
* 2. after the application processing, update the dialog object with the
* correct information
*
* The first strategy has a limitation that the SIP message may not have all
* the information required to determine if the next hop is in the route set
* or in the contact. Causing risk that asterisk will update the Contact on
* receipt of an in-dialog message despite there being a route set saved in
* the dialog.
*
* The second strategy has a limitation that not all UAC layers have interfaces
* available to invoke this module after dialog creation. (pjsip_sesion does
* but pjsip_pubsub does not), thus this strategy can't update the dialog in
* all cases needed.
*
* The ideal solution would be to implement an "incomming_request" event
* in pubsub module that can then pass the dialog object to this module
* on SUBSCRIBE, this module then should add itself as a listener to the dialog
* for the subsequent requests and responses & then be able to properly update
* the dialog object for all required events.
*/
static
int
rewrite_route_set
(
pjsip_rx_data
*
rdata
,
pjsip_dialog
*
dlg
)
{
pjsip_rr_hdr
*
rr
=
NULL
;
pjsip_sip_uri
*
uri
;
int
res
=
-
1
;
int
ignore_rr
=
0
;
int
pubsub
=
0
;
if
(
rdata
->
msg_info
.
msg
->
type
==
PJSIP_RESPONSE_MSG
)
{
pjsip_hdr
*
iter
;
...
...
@@ -60,21 +92,49 @@ static int rewrite_route_set(pjsip_rx_data *rdata, pjsip_dialog *dlg)
}
}
else
if
(
pjsip_method_cmp
(
&
rdata
->
msg_info
.
msg
->
line
.
req
.
method
,
&
pjsip_register_method
))
{
rr
=
pjsip_msg_find_hdr
(
rdata
->
msg_info
.
msg
,
PJSIP_H_RECORD_ROUTE
,
NULL
);
}
else
{
/**
* Record-Route header has no meaning in REGISTER requests
* and should be ignored
*/
ignore_rr
=
1
;
}
if
(
!
pjsip_method_cmp
(
&
rdata
->
msg_info
.
cseq
->
method
,
&
pjsip_subscribe_method
)
||
!
pjsip_method_cmp
(
&
rdata
->
msg_info
.
cseq
->
method
,
&
pjsip_notify_method
))
{
/**
* There is currently no good way to get the dlg object for a pubsub dialog
* so we will just look at the rr & contact of the current message and
* hope for the best
*/
pubsub
=
1
;
}
if
(
rr
)
{
uri
=
pjsip_uri_get_uri
(
&
rr
->
name_addr
);
rewrite_uri
(
rdata
,
uri
);
if
(
dlg
&&
!
pj_list_empty
(
&
dlg
->
route_set
)
&&
!
dlg
->
route_set_frozen
)
{
pjsip_routing_hdr
*
route
=
dlg
->
route_set
.
next
;
uri
=
pjsip_uri_get_uri
(
&
route
->
name_addr
);
rewrite_uri
(
rdata
,
uri
);
}
res
=
0
;
}
return
0
;
if
(
dlg
&&
!
pj_list_empty
(
&
dlg
->
route_set
)
&&
!
dlg
->
route_set_frozen
)
{
pjsip_routing_hdr
*
route
=
dlg
->
route_set
.
next
;
uri
=
pjsip_uri_get_uri
(
&
route
->
name_addr
);
rewrite_uri
(
rdata
,
uri
);
res
=
0
;
}
return
-
1
;
if
(
!
dlg
&&
!
rr
&&
!
ignore_rr
&&
!
pubsub
&&
rdata
->
msg_info
.
to
->
tag
.
slen
){
/**
* Even if this message doesn't have any route headers
* the dialog may, so wait until a later invocation that
* has a dialog reference to make sure there isn't a
* previously saved routset in the dialog before deciding
* the contact needs to be modified
*/
res
=
0
;
}
return
res
;
}
static
int
rewrite_contact
(
pjsip_rx_data
*
rdata
,
pjsip_dialog
*
dlg
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment