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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
c84d4313
Commit
c84d4313
authored
Mar 26, 2012
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
#9547: Destroy the STUN resolver if server name change
parent
525bffef
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
daemon/src/sip/sipaccount.cpp
+7
-2
7 additions, 2 deletions
daemon/src/sip/sipaccount.cpp
daemon/src/sip/sipvoiplink.cpp
+28
-5
28 additions, 5 deletions
daemon/src/sip/sipvoiplink.cpp
daemon/src/sip/sipvoiplink.h
+17
-5
17 additions, 5 deletions
daemon/src/sip/sipvoiplink.h
with
52 additions
and
12 deletions
daemon/src/sip/sipaccount.cpp
+
7
−
2
View file @
c84d4313
...
...
@@ -405,6 +405,11 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
publishedIpAddress_
=
details
[
CONFIG_PUBLISHED_ADDRESS
];
localPort_
=
atoi
(
details
[
CONFIG_LOCAL_PORT
].
c_str
());
publishedPort_
=
atoi
(
details
[
CONFIG_PUBLISHED_PORT
].
c_str
());
if
(
stunServer_
!=
details
[
CONFIG_STUN_SERVER
])
{
DEBUG
(
"Stun server changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
link_
->
destroyStunResolver
(
stunServer_
);
// pj_stun_sock_destroy(pj_stun_sock *stun_sock);
}
stunServer_
=
details
[
CONFIG_STUN_SERVER
];
stunEnabled_
=
details
[
CONFIG_STUN_ENABLE
]
==
"true"
;
dtmfType_
=
details
[
CONFIG_ACCOUNT_DTMF_TYPE
];
...
...
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipvoiplink.cpp
+
28
−
5
View file @
c84d4313
...
...
@@ -57,7 +57,7 @@
#include
"pjsip/sip_endpoint.h"
#include
"pjsip/sip_transport_tls.h"
#include
"pjsip/sip_uri.h"
#include
<
pjnath.h
>
#include
"
pjnath.h
"
#include
<netinet/in.h>
#include
<arpa/nameser.h>
...
...
@@ -427,7 +427,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata)
/*************************************************************************************************/
SIPVoIPLink
::
SIPVoIPLink
()
:
transportMap_
(),
evThread_
(
new
EventThread
(
this
))
SIPVoIPLink
::
SIPVoIPLink
()
:
transportMap_
(),
stunSocketMap_
(),
evThread_
(
new
EventThread
(
this
))
{
#define TRY(ret) do { \
if (ret != PJ_SUCCESS) \
...
...
@@ -1273,11 +1273,13 @@ stun_sock_on_rx_data_cb(pj_stun_sock * /*stun_sock*/, void * /*pkt*/,
}
pj_status_t
SIPVoIPLink
::
stunServer
Resolve
(
pj_str_t
serverName
,
pj_uint16_t
port
)
pj_status_t
SIPVoIPLink
::
createStun
Resolve
r
(
pj_str_t
serverName
,
pj_uint16_t
port
)
{
pj_stun_config
stunCfg
;
pj_stun_config_init
(
&
stunCfg
,
&
cp_
->
factory
,
0
,
pjsip_endpt_get_ioqueue
(
endpt_
),
pjsip_endpt_get_timer_heap
(
endpt_
));
DEBUG
(
"***************** Create Stun Resolver *********************"
);
static
const
pj_stun_sock_cb
stun_sock_cb
=
{
stun_sock_on_rx_data_cb
,
NULL
,
...
...
@@ -1285,7 +1287,12 @@ pj_status_t SIPVoIPLink::stunServerResolve(pj_str_t serverName, pj_uint16_t port
};
pj_stun_sock
*
stun_sock
;
pj_status_t
status
=
pj_stun_sock_create
(
&
stunCfg
,
"stunresolve"
,
pj_AF_INET
(),
&
stun_sock_cb
,
NULL
,
NULL
,
&
stun_sock
);
std
::
string
stunResolverName
(
serverName
.
ptr
,
serverName
.
slen
);
pj_status_t
status
=
pj_stun_sock_create
(
&
stunCfg
,
stunResolverName
.
c_str
(),
pj_AF_INET
(),
&
stun_sock_cb
,
NULL
,
NULL
,
&
stun_sock
);
// store socket inside list
DEBUG
(
" insert %s resolver in map"
,
stunResolverName
.
c_str
());
stunSocketMap_
.
insert
(
std
::
pair
<
std
::
string
,
pj_stun_sock
*>
(
stunResolverName
.
c_str
(),
stun_sock
));
if
(
status
!=
PJ_SUCCESS
)
{
char
errmsg
[
PJ_ERR_MSG_SIZE
];
...
...
@@ -1306,6 +1313,22 @@ pj_status_t SIPVoIPLink::stunServerResolve(pj_str_t serverName, pj_uint16_t port
return
status
;
}
pj_status_t
SIPVoIPLink
::
destroyStunResolver
(
const
std
::
string
serverName
)
{
std
::
map
<
std
::
string
,
pj_stun_sock
*>::
iterator
it
;
it
=
stunSocketMap_
.
find
(
serverName
);
DEBUG
(
"***************** Destroy Stun Resolver *********************"
);
if
(
it
!=
stunSocketMap_
.
end
())
{
DEBUG
(
"UserAgent: Deleting stun resolver %s"
,
it
->
first
.
c_str
());
pj_stun_sock_destroy
(
it
->
second
);
stunSocketMap_
.
erase
(
it
);
}
return
PJ_SUCCESS
;
}
void
SIPVoIPLink
::
createDefaultSipUdpTransport
()
{
pj_uint16_t
port
=
0
;
...
...
@@ -1496,7 +1519,7 @@ pjsip_transport *SIPVoIPLink::createStunTransport(pj_str_t serverName, pj_uint16
pjsip_transport
*
transport
;
DEBUG
(
"UserAgent: Create stun transport server name: %s, port: %d"
,
serverName
,
port
);
// account->getStunPort());
if
(
stunServer
Resolve
(
serverName
,
port
)
!=
PJ_SUCCESS
)
{
if
(
createStun
Resolve
r
(
serverName
,
port
)
!=
PJ_SUCCESS
)
{
ERROR
(
"UserAgent: Can't resolve STUN server"
);
Manager
::
instance
().
getDbusManager
()
->
getConfigurationManager
()
->
stunStatusFailure
(
""
);
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipvoiplink.h
+
17
−
5
View file @
c84d4313
...
...
@@ -43,6 +43,7 @@
#include
<pjlib.h>
#include
<pjsip_ua.h>
#include
<pjlib-util.h>
#include
<pjnath.h>
#include
<pjnath/stun_config.h>
///////////////////////////////
...
...
@@ -279,6 +280,16 @@ class SIPVoIPLink : public VoIPLink {
*/
void
findLocalAddressFromTransport
(
pjsip_transport
*
transport
,
pjsip_transport_type_e
transportType
,
std
::
string
&
address
,
std
::
string
&
port
)
const
;
/**
* Create a new stun resolver. Store it inside the array. Resolve public address for this
* server name.
* @param serverName The name of the stun server
* @param port number
*/
pj_status_t
createStunResolver
(
pj_str_t
serverName
,
pj_uint16_t
port
);
pj_status_t
destroyStunResolver
(
const
std
::
string
serverName
);
private:
/**
* Start a SIP Call
...
...
@@ -293,11 +304,6 @@ class SIPVoIPLink : public VoIPLink {
SIPVoIPLink
();
/**
* Resolve public address for this account
*/
pj_status_t
stunServerResolve
(
pj_str_t
serverName
,
pj_uint16_t
port
);
/**
* General Sip transport creation method according to the
* transport type specified in account settings
...
...
@@ -348,6 +354,12 @@ class SIPVoIPLink : public VoIPLink {
*/
std
::
map
<
pj_uint16_t
,
pjsip_transport
*>
transportMap_
;
/**
* Stun resolver array
*/
std
::
map
<
std
::
string
,
pj_stun_sock
*>
stunSocketMap_
;
/**
* Threading object
*/
...
...
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
sign in
to comment