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
33519a0f
Commit
33519a0f
authored
6 months ago
by
Iryna Antsyferova
Committed by
Iryna Antsyferova
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Implement "pjsip show srv_lookups" CLI command, REF 15305
parent
6c142872
No related branches found
No related tags found
No related merge requests found
Pipeline
#179484
skipped
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip/pjsip_resolver.c
+64
-0
64 additions, 0 deletions
res/res_pjsip/pjsip_resolver.c
with
64 additions
and
0 deletions
res/res_pjsip/pjsip_resolver.c
+
64
−
0
View file @
33519a0f
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include
<arpa/nameser.h>
#include
<arpa/nameser.h>
#include
"asterisk/astobj2.h"
#include
"asterisk/astobj2.h"
#include
"asterisk/cli.h"
#include
"asterisk/dns_core.h"
#include
"asterisk/dns_core.h"
#include
"asterisk/dns_query_set.h"
#include
"asterisk/dns_query_set.h"
#include
"asterisk/dns_srv.h"
#include
"asterisk/dns_srv.h"
...
@@ -950,6 +951,63 @@ static void sip_check_transport(pj_pool_t *pool, pjsip_transport_type_e transpor
...
@@ -950,6 +951,63 @@ static void sip_check_transport(pj_pool_t *pool, pjsip_transport_type_e transpor
}
}
}
}
static
char
*
cli_show_tasks
(
struct
ast_cli_entry
*
e
,
int
cmd
,
struct
ast_cli_args
*
a
)
{
char
addr
[
PJ_INET6_ADDRSTRLEN
+
10
];
struct
host_track_entry
*
host
=
NULL
;
char
*
port
=
NULL
;
int
idx
;
switch
(
cmd
)
{
case
CLI_INIT
:
e
->
command
=
"pjsip show srv_lookups"
;
e
->
usage
=
"Usage: pjsip show SRV DNS lookup records
\n
"
;
return
NULL
;
case
CLI_GENERATE
:
return
NULL
;
}
if
(
a
->
argc
!=
3
)
{
return
CLI_SHOWUSAGE
;
}
ast_cli
(
a
->
fd
,
"<Host name......................................> "
"<IP address.................> <Port> <Transport.....> "
"<Weight> <Priority> <Expired at>
\n
"
"============================================================="
"============================================================="
"======
\n
"
);
AST_LIST_LOCK
(
&
sip_resolve_track
);
AST_LIST_TRAVERSE_SAFE_BEGIN
(
&
sip_resolve_track
,
host
,
next
)
{
for
(
idx
=
0
;
idx
<
host
->
addresses
.
count
;
++
idx
)
{
pj_sockaddr_print
(
&
host
->
addresses
.
entry
[
idx
].
addr
,
addr
,
sizeof
(
addr
),
3
);
/* ipv6 is not supported */
if
(
!
pj_gethostip
(
pj_AF_INET
(),
&
host
->
addresses
.
entry
[
idx
].
addr
))
{
if
((
port
=
strstr
(
addr
,
":"
)))
{
*
port
=
'\0'
;
port
++
;
}
}
ast_cli
(
a
->
fd
,
"%-40.40s %-25.25s %-6s %-15.15s %8d %10d %-24s
\n
"
,
host
->
target
.
host
,
addr
,
host
->
target
.
port
?
atoi
(
host
->
target
.
port
)
:
(
port
?
port
:
0
),
pjsip_transport_get_type_desc
(
host
->
target
.
type
),
host
->
addresses
.
entry
[
idx
].
weight
,
host
->
addresses
.
entry
[
idx
].
priority
,
ctime
(
&
host
->
expiry
));
}
}
AST_LIST_TRAVERSE_SAFE_END
;
AST_LIST_UNLOCK
(
&
sip_resolve_track
);
return
CLI_SUCCESS
;
}
static
struct
ast_cli_entry
cli_commands
[]
=
{
AST_CLI_DEFINE
(
cli_show_tasks
,
"Show pjsip SRV DNS lookup records"
),
};
/*! \brief External resolver implementation for PJSIP */
/*! \brief External resolver implementation for PJSIP */
static
pjsip_ext_resolver
ext_resolver
=
{
static
pjsip_ext_resolver
ext_resolver
=
{
.
resolve
=
sip_resolve
,
.
resolve
=
sip_resolve
,
...
@@ -991,6 +1049,7 @@ void ast_sip_initialize_resolver(void)
...
@@ -991,6 +1049,7 @@ void ast_sip_initialize_resolver(void)
{
{
/* Replace the existing PJSIP resolver with our own implementation */
/* Replace the existing PJSIP resolver with our own implementation */
ast_sip_push_task_wait_servant
(
NULL
,
sip_replace_resolver
,
NULL
);
ast_sip_push_task_wait_servant
(
NULL
,
sip_replace_resolver
,
NULL
);
ast_cli_register_multiple
(
cli_commands
,
ARRAY_LEN
(
cli_commands
));
}
}
#else
#else
...
@@ -1002,3 +1061,8 @@ void ast_sip_initialize_resolver(void)
...
@@ -1002,3 +1061,8 @@ void ast_sip_initialize_resolver(void)
}
}
#endif
#endif
int
ast_sip_destroy_resolver
(
void
)
{
ast_cli_unregister_multiple
(
cli_commands
,
ARRAY_LEN
(
cli_commands
));
}
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