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
abebe234
Commit
abebe234
authored
13 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
#3674: Apply contact header update optionnaly
parent
0661b858
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
daemon/src/sip/sipaccount.cpp
+19
-0
19 additions, 0 deletions
daemon/src/sip/sipaccount.cpp
daemon/src/sip/sipaccount.h
+24
-4
24 additions, 4 deletions
daemon/src/sip/sipaccount.h
daemon/src/sip/sipvoiplink.cpp
+33
-9
33 additions, 9 deletions
daemon/src/sip/sipvoiplink.cpp
with
76 additions
and
13 deletions
daemon/src/sip/sipaccount.cpp
+
19
−
0
View file @
abebe234
...
...
@@ -59,6 +59,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
,
cred_
(
NULL
)
,
tlsSetting_
()
,
contactHeader_
()
,
contactUpdateEnabled_
(
false
)
,
stunServerName_
()
,
stunPort_
(
0
)
,
dtmfType_
(
OVERRTP_STR
)
...
...
@@ -760,6 +761,24 @@ std::string SIPAccount::getServerUri() const
return
"<"
+
scheme
+
hostname_
+
transport
+
">"
;
}
void
SIPAccount
::
setContactHeader
(
std
::
string
address
,
std
::
string
port
)
{
std
::
string
scheme
;
std
::
string
transport
;
// UDP does not require the transport specification
if
(
transportType_
==
PJSIP_TRANSPORT_TLS
)
{
scheme
=
"sips:"
;
transport
=
";transport="
+
std
::
string
(
pjsip_transport_get_type_name
(
transportType_
));
}
else
scheme
=
"sip:"
;
contactHeader_
=
displayName_
+
(
displayName_
.
empty
()
?
""
:
" "
)
+
"<"
+
scheme
+
username_
+
(
username_
.
empty
()
?
""
:
"@"
)
+
address
+
":"
+
port
+
transport
+
">"
;
}
std
::
string
SIPAccount
::
getContactHeader
()
const
{
std
::
string
scheme
;
...
...
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipaccount.h
+
24
−
4
View file @
abebe234
...
...
@@ -364,10 +364,7 @@ class SIPAccount : public Account {
* @param port Optional port. Otherwise set to the port defined for that account.
* @param hostname Optional local address. Otherwise set to the hostname defined for that account.
*/
void
setContactHeader
(
std
::
string
&
contact
)
{
contactHeader_
=
contact
;
}
void
setContactHeader
(
std
::
string
address
,
std
::
string
port
);
/**
* Get the contact header for
...
...
@@ -375,6 +372,24 @@ class SIPAccount : public Account {
*/
std
::
string
getContactHeader
(
void
)
const
;
/**
* The contact header can be rewritten based on the contact provided by the registrar in 200 OK
*/
void
enableContactUpdate
(
void
)
{
contactUpdateEnabled_
=
true
;
}
/**
* The contact header is not updated even if the registrar
*/
void
disableContactUpdate
(
void
)
{
contactUpdateEnabled_
=
false
;
}
bool
isContactUpdateEnabled
(
void
)
{
return
contactUpdateEnabled_
;
}
/**
* Get the local interface name on which this account is bound.
*/
...
...
@@ -572,6 +587,11 @@ class SIPAccount : public Account {
*/
std
::
string
contactHeader_
;
/**
* Enble the contact header based on the header received from the registrar in 200 OK
*/
bool
contactUpdateEnabled_
;
/**
* The STUN server name (hostname)
*/
...
...
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipvoiplink.cpp
+
33
−
9
View file @
abebe234
...
...
@@ -304,8 +304,7 @@ void SIPVoIPLink::sendRegister(Account *a)
std
::
string
from
(
account
->
getFromUri
());
pj_str_t
pjFrom
=
pj_str
((
char
*
)
from
.
c_str
());
// Store the CONTACT header for future usage
// account->setContactHeader(address, port);
// Get the contact header for this account
std
::
string
contact
(
account
->
getContactHeader
());
pj_str_t
pjContact
=
pj_str
((
char
*
)
contact
.
c_str
());
...
...
@@ -1618,10 +1617,12 @@ static void update_contact_header(struct pjsip_regc_cbparam *param, SIPAccount *
pj_pool_t
*
pool
=
NULL
;
pjsip_contact_hdr
*
contact_hdr
=
NULL
;
pjsip_sip_uri
*
uri
=
NULL
;
std
::
string
currentContactHeader
=
""
;
// if(!account->updateContactAllowed())
// return;
SIPVoIPLink
*
siplink
=
dynamic_cast
<
SIPVoIPLink
*>
(
account
->
getVoIPLink
());
if
(
siplink
==
NULL
)
{
ERROR
(
"SIPVoIPLink: Could not find voip link from account"
);
return
;
}
pool
=
pj_pool_create
(
&
cp_
->
factory
,
"tmp"
,
512
,
512
,
NULL
);
if
(
pool
==
NULL
)
{
...
...
@@ -1655,13 +1656,34 @@ static void update_contact_header(struct pjsip_regc_cbparam *param, SIPAccount *
std
::
stringstream
ss
;
ss
<<
uri
->
port
;
std
::
string
recvContactPort
=
ss
.
str
();
DEBUG
(
"SIPVoIPLink: Current contact header %s:%s"
,
recvContactHost
.
c_str
(),
recvContactPort
.
c_str
());
currentContactHeader
=
account
->
getContactHeader
();
DEBUG
(
"SIPVoIPLink: Current contact header %s"
,
currentContactHeader
.
c_str
());
std
::
string
currentAddress
,
currentPort
;
siplink
->
findLocalAddressFromTransport
(
account
->
transport_
,
PJSIP_TRANSPORT_UDP
,
currentAddress
,
currentPort
);
DEBUG
(
"SIPVoIPLink: Current contact header %s:%s
\n
"
,
currentAddress
.
c_str
(),
currentPort
.
c_str
());
// DEBUG("Received contact header %s",
bool
updateContact
=
false
;
std
::
string
currentContactHeader
=
account
->
getContactHeader
();
size_t
foundHost
=
currentContactHeader
.
find
(
recvContactHost
);
if
(
foundHost
==
std
::
string
::
npos
)
{
DEBUG
(
"SIPVoIPLink: Host %s not in current contact header
\n
"
,
recvContactHost
.
c_str
());
updateContact
=
true
;
}
size_t
foundPort
=
currentContactHeader
.
find
(
recvContactPort
);
if
(
foundPort
==
std
::
string
::
npos
)
{
DEBUG
(
"SIPVoIPLink: Port %s not in current contact header
\n
"
,
recvContactPort
.
c_str
());
updateContact
=
true
;
}
if
(
updateContact
)
{
account
->
setContactHeader
(
recvContactHost
,
recvContactPort
);
siplink
->
sendRegister
(
account
);
}
pj_pool_release
(
pool
);
}
...
...
@@ -1682,7 +1704,9 @@ void registration_cb(struct pjsip_regc_cbparam *param)
}
DEBUG
(
"SipVoipLink: Contact header from UAS, %d contact(s)"
,
param
->
contact_cnt
);
update_contact_header
(
param
,
account
);
if
(
account
->
isContactUpdateEnabled
())
{
update_contact_header
(
param
,
account
);
}
const
pj_str_t
*
description
=
pjsip_get_status_text
(
param
->
code
);
...
...
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