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
42abcfd3
Commit
42abcfd3
authored
2 years ago
by
Wenpeng Song
Committed by
Yalu Zhang
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Enable NAPTR/SRV types of DNS lookup
parent
c2c8e829
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!84
Enable DNS NAPTR+SRV+A
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip/pjsip_resolver.c
+35
-37
35 additions, 37 deletions
res/res_pjsip/pjsip_resolver.c
with
35 additions
and
37 deletions
res/res_pjsip/pjsip_resolver.c
+
35
−
37
View file @
42abcfd3
...
...
@@ -544,49 +544,47 @@ static void sip_resolve(pjsip_resolver_t *resolver, pj_pool_t *pool, const pjsip
ast_debug
(
2
,
"[%p] Created resolution tracking for target '%s'
\n
"
,
resolve
,
host
);
/* If no port has been specified we can do NAPTR + SRV */
if
(
!
target
->
addr
.
port
)
{
char
srv
[
NI_MAXHOST
];
/* When resolving addresses PJSIP can request an explicit transport type. It will explicitly
* request an IPv6 transport if a message has been tagged to use an explicitly IPv6 transport.
* For other cases it can be left unspecified OR an explicit non-IPv6 transport can be requested.
* In the case where a non-IPv6 transport is requested there is no way to differentiate between
* a transport being requested as part of a SIP URI (sip:test.com;transport=tcp) and a message
* being tagged with a specific IPv4 transport. In this case we look for both IPv4 and IPv6 addresses.
* If a message has been tagged with a specific IPv4 transport the IPv6 addresses will simply
* be discarded. The code below and elsewhere handles the case where we know they requested IPv6
* explicitly and only looks for IPv6 records.
*/
/* NAPTR + SRV */
char
srv
[
NI_MAXHOST
];
/* When resolving addresses PJSIP can request an explicit transport type. It will explicitly
* request an IPv6 transport if a message has been tagged to use an explicitly IPv6 transport.
* For other cases it can be left unspecified OR an explicit non-IPv6 transport can be requested.
* In the case where a non-IPv6 transport is requested there is no way to differentiate between
* a transport being requested as part of a SIP URI (sip:test.com;transport=tcp) and a message
* being tagged with a specific IPv4 transport. In this case we look for both IPv4 and IPv6 addresses.
* If a message has been tagged with a specific IPv4 transport the IPv6 addresses will simply
* be discarded. The code below and elsewhere handles the case where we know they requested IPv6
* explicitly and only looks for IPv6 records.
*/
res
|=
sip_resolve_add
(
resolve
,
host
,
T_NAPTR
,
C_IN
,
type
,
0
);
res
|=
sip_resolve_add
(
resolve
,
host
,
T_NAPTR
,
C_IN
,
type
,
0
);
if
(
type
==
PJSIP_TRANSPORT_UNSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_TLS
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TLS
))
||
(
type
==
PJSIP_TRANSPORT_TLS6
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TLS6
)))
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_sips._tcp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_TLS
:
type
,
0
);
}
if
(
type
==
PJSIP_TRANSPORT_UNSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_TLS
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TLS
))
||
(
type
==
PJSIP_TRANSPORT_TLS6
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TLS6
)))
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_sips._tcp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_TLS
:
type
,
0
);
}
if
(
type
==
PJSIP_TRANSPORT_UNSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_
TCP
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TCP
))
||
(
type
==
PJSIP_TRANSPORT_TCP
6
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TCP
6
)
))
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_
sip
.
_t
cp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_TCP
:
type
,
0
);
}
}
if
(
type
==
PJSIP_TRANSPORT_
UNSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_TCP
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_TCP
))
||
(
type
==
PJSIP_TRANSPORT_TCP6
&&
sip_t
ransport_is_available
(
PJSIP_TRANSPORT_TCP6
))
)
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_sip._tcp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_TCP
:
type
,
0
);
}
if
(
type
==
PJSIP_TRANSPORT_UNSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_U
DP
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_UDP
))
||
(
type
==
PJSIP_TRANSPORT_UDP
6
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_UDP
6
)
))
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_sip._udp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_UDP
:
type
,
0
);
}
}
if
(
type
==
PJSIP_TRANSPORT_U
NSPECIFIED
||
(
type
==
PJSIP_TRANSPORT_UDP
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_UDP
))
||
(
type
==
PJSIP_TRANSPORT_UDP6
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_UDP6
))
)
{
if
(
snprintf
(
srv
,
sizeof
(
srv
),
"_sip._udp.%s"
,
host
)
<
NI_MAXHOST
)
{
res
|=
sip_resolve_add
(
resolve
,
srv
,
T_SRV
,
C_IN
,
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_UDP
:
type
,
0
);
}
}
/* AAAA + A */
if
((
type
==
PJSIP_TRANSPORT_UNSPECIFIED
&&
sip_transport_is_available
(
PJSIP_TRANSPORT_UDP6
))
||
((
type
&
PJSIP_TRANSPORT_IPV6
)
&&
sip_transport_is_available
(
type
)))
{
res
|=
sip_resolve_add
(
resolve
,
host
,
T_AAAA
,
C_IN
,
(
type
==
PJSIP_TRANSPORT_UNSPECIFIED
?
PJSIP_TRANSPORT_UDP6
:
type
),
target
->
addr
.
port
);
...
...
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