Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
b49182af
Commit
b49182af
authored
Aug 15, 2013
by
Tristan Matthews
Browse files
* #28529: sip: serialize/unserialize port ranges
parent
dd4a7eba
Changes
2
Hide whitespace changes
Inline
Side-by-side
daemon/src/sip/sipaccount.cpp
View file @
b49182af
...
...
@@ -117,9 +117,9 @@ SIPAccount::SIPAccount(const std::string& accountID)
,
receivedParameter_
(
""
)
,
rPort_
(
-
1
)
,
via_addr_
()
,
audioPortRange_
(
16384
,
32766
)
,
audioPortRange_
(
{
16384
,
32766
}
)
#ifdef SFL_VIDEO
,
videoPortRange_
(
49152
,
65534
)
,
videoPortRange_
(
{
49152
,
UINT16_MAX
-
2
}
)
#endif
{
via_addr_
.
host
.
ptr
=
0
;
...
...
@@ -130,6 +130,44 @@ SIPAccount::SIPAccount(const std::string& accountID)
alias_
=
IP2IP_PROFILE
;
}
namespace
{
std
::
array
<
std
::
unique_ptr
<
Conf
::
ScalarNode
>
,
2
>
serializeRange
(
Conf
::
MappingNode
&
accountMap
,
const
char
*
minKey
,
const
char
*
maxKey
,
const
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
)
{
using
namespace
Conf
;
std
::
array
<
std
::
unique_ptr
<
ScalarNode
>
,
2
>
result
;
std
::
ostringstream
os
;
os
<<
range
.
first
;
result
[
0
].
reset
(
new
ScalarNode
(
os
.
str
()));
os
.
str
(
""
);
accountMap
.
setKeyValue
(
minKey
,
result
[
0
].
get
());
os
<<
range
.
second
;
ScalarNode
portMax
(
os
.
str
());
result
[
1
].
reset
(
new
ScalarNode
(
os
.
str
()));
accountMap
.
setKeyValue
(
maxKey
,
result
[
1
].
get
());
return
result
;
}
void
unserializeRange
(
const
Conf
::
YamlNode
&
mapNode
,
const
char
*
minKey
,
const
char
*
maxKey
,
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
)
{
std
::
stringstream
ss
;
ss
<<
mapNode
.
getValue
(
minKey
);
uint16_t
tmp
;
ss
>>
tmp
;
if
(
tmp
)
range
.
first
=
tmp
;
ss
.
str
(
""
);
ss
<<
mapNode
.
getValue
(
maxKey
);
ss
>>
tmp
;
if
(
tmp
)
range
.
second
=
tmp
;
}
}
void
SIPAccount
::
serialize
(
Conf
::
YamlEmitter
&
emitter
)
{
using
namespace
Conf
;
...
...
@@ -283,6 +321,11 @@ void SIPAccount::serialize(Conf::YamlEmitter &emitter)
ScalarNode
userAgent
(
userAgent_
);
accountmap
.
setKeyValue
(
USER_AGENT_KEY
,
&
userAgent
);
std
::
array
<
std
::
unique_ptr
<
ScalarNode
>
,
2
>
audioPortNodes
(
serializeRange
(
accountmap
,
AUDIO_PORT_MIN_KEY
,
AUDIO_PORT_MAX_KEY
,
audioPortRange_
));
#ifdef SFL_VIDEO
std
::
array
<
std
::
unique_ptr
<
ScalarNode
>
,
2
>
videoPortNodes
(
serializeRange
(
accountmap
,
VIDEO_PORT_MIN_KEY
,
VIDEO_PORT_MAX_KEY
,
videoPortRange_
));
#endif
try
{
emitter
.
serializeAccount
(
&
accountmap
);
}
catch
(
const
YamlEmitterException
&
e
)
{
...
...
@@ -488,6 +531,11 @@ void SIPAccount::unserialize(const Conf::YamlNode &mapNode)
tlsMap
->
getValue
(
TIMEOUT_KEY
,
&
tlsNegotiationTimeoutMsec_
);
}
mapNode
.
getValue
(
USER_AGENT_KEY
,
&
userAgent_
);
unserializeRange
(
mapNode
,
AUDIO_PORT_MIN_KEY
,
AUDIO_PORT_MAX_KEY
,
audioPortRange_
);
#ifdef SFL_VIDEO
unserializeRange
(
mapNode
,
VIDEO_PORT_MIN_KEY
,
VIDEO_PORT_MAX_KEY
,
videoPortRange_
);
#endif
}
void
SIPAccount
::
setAccountDetails
(
std
::
map
<
std
::
string
,
std
::
string
>
details
)
...
...
daemon/src/sip/sipaccount.h
View file @
b49182af
...
...
@@ -36,7 +36,6 @@
#define SIPACCOUNT_H
#include
<vector>
#include
<set>
#include
<map>
#include
"account.h"
#include
"pjsip/sip_transport_tls.h"
...
...
@@ -91,6 +90,12 @@ namespace Conf {
const
char
*
const
STUN_ENABLED_KEY
=
"stunEnabled"
;
const
char
*
const
STUN_SERVER_KEY
=
"stunServer"
;
const
char
*
const
CRED_KEY
=
"credential"
;
const
char
*
const
AUDIO_PORT_MIN_KEY
=
"audioPortMin"
;
const
char
*
const
AUDIO_PORT_MAX_KEY
=
"audioPortMax"
;
#ifdef SFL_VIDEO
const
char
*
const
VIDEO_PORT_MIN_KEY
=
"videoPortMin"
;
const
char
*
const
VIDEO_PORT_MAX_KEY
=
"videoPortMax"
;
#endif
}
class
SIPVoIPLink
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment