Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
32553ac7
Commit
32553ac7
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
DNS SRV resolution functional
parent
84906270
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sipvoiplink.cpp
+52
-5
52 additions, 5 deletions
src/sipvoiplink.cpp
with
52 additions
and
5 deletions
src/sipvoiplink.cpp
+
52
−
5
View file @
32553ac7
...
...
@@ -25,6 +25,11 @@
#include
"sipaccount.h"
#include
"audio/audiortp.h"
#include
<netinet/in.h>
#include
<arpa/nameser.h>
#include
<resolv.h>
//extern struct state _res;
#define CAN_REINVITE 1
...
...
@@ -1261,13 +1266,42 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
// Private functions
///////////////////////////////////////////////////////////////////////////////
bool
get_dns_server_addresses
(
std
::
vector
<
std
::
string
>
*
servers
)
{
int
server_count
,
i
;
std
::
vector
<
std
::
string
>
nameservers
;
struct
sockaddr_in
current_server
;
in_addr
address
;
// Read configuration files
if
(
res_init
()
!=
0
)
{
_debug
(
"Resolver initialization failed
\n
"
);
return
false
;
}
server_count
=
_res
.
nscount
;
for
(
i
=
0
;
i
<
server_count
;
i
++
)
{
current_server
=
(
struct
sockaddr_in
)
_res
.
nsaddr_list
[
i
];
address
=
current_server
.
sin_addr
;
nameservers
.
push_back
(
inet_ntoa
(
address
));
}
//nameservers.push_back ("192.168.50.3");
*
servers
=
nameservers
;
return
true
;
}
pj_status_t
SIPVoIPLink
::
enable_dns_srv_resolver
(
pjsip_endpoint
*
endpt
,
pj_dns_resolver
**
p_resv
)
{
pj_status_t
status
;
pj_dns_resolver
*
resv
;
pj_str_t
servers
[
1
]
;
std
::
vector
<
std
::
string
>
dns_
servers
;
pj_uint16_t
port
=
5353
;
pjsip_resolver_t
*
res
;
int
scount
,
i
;
// Create the DNS resolver instance
status
=
pjsip_endpt_create_resolver
(
endpt
,
&
resv
);
...
...
@@ -1276,9 +1310,22 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
return
status
;
}
if
(
!
get_dns_server_addresses
(
&
dns_servers
))
{
_debug
(
"Error while fetching DNS information
\n
"
);
return
-
1
;
}
// Build the nameservers list needed by pjsip
scount
=
dns_servers
.
size
();
pj_str_t
nameservers
[
scount
];
for
(
i
=
0
;
i
<
scount
;
i
++
)
{
nameservers
[
i
]
=
pj_str
((
char
*
)
dns_servers
[
i
].
c_str
());
}
// Update the name servers for the DNS resolver
servers
[
0
]
=
pj_str
((
char
*
)
"savoirfairelinux.com"
);
status
=
pj_dns_resolver_set_ns
(
resv
,
1
,
servers
,
NULL
);
status
=
pj_dns_resolver_set_ns
(
resv
,
scount
,
nameservers
,
NULL
);
if
(
status
!=
PJ_SUCCESS
){
_debug
(
"Error updating the name servers for the DNS resolver
\n
"
);
return
status
;
...
...
@@ -1431,8 +1478,8 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
status
=
pjsip_xfer_init_module
(
_endpt
);
PJ_ASSERT_RETURN
(
status
==
PJ_SUCCESS
,
1
);
//
status = enable_dns_srv_resolver (_endpt, &p_resv);
//
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );
status
=
enable_dns_srv_resolver
(
_endpt
,
&
p_resv
);
PJ_ASSERT_RETURN
(
status
==
PJ_SUCCESS
,
1
);
// Init the callback for INVITE session:
pj_bzero
(
&
inv_cb
,
sizeof
(
inv_cb
));
...
...
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