44
44
#include "noncopyable.h"
49
// SIP specific configuration keys
50
const char *const interfaceKey = "interface";
51
const char *const portKey = "port";
52
const char *const publishAddrKey = "publishAddr";
53
const char *const publishPortKey = "publishPort";
54
const char *const sameasLocalKey = "sameasLocal";
55
const char *const dtmfTypeKey = "dtmfType";
56
const char *const serviceRouteKey = "serviceRoute";
57
const char *const updateContactHeaderKey = "updateContact";
59
// TODO: write an object to store credential which implement serializable
60
const char *const srtpKey = "srtp";
61
const char *const srtpEnableKey = "enable";
62
const char *const keyExchangeKey = "keyExchange";
63
const char *const rtpFallbackKey = "rtpFallback";
65
// TODO: wirte an object to store zrtp params wich implement serializable
66
const char *const zrtpKey = "zrtp";
67
const char *const displaySasKey = "displaySas";
68
const char *const displaySasOnceKey = "displaySasOnce";
69
const char *const helloHashEnabledKey = "helloHashEnabled";
70
const char *const notSuppWarningKey = "notSuppWarning";
72
// TODO: write an object to store tls params which implement serializable
73
const char *const tlsKey = "tls";
74
const char *const tlsPortKey = "tlsPort";
75
const char *const certificateKey = "certificate";
76
const char *const calistKey = "calist";
77
const char *const ciphersKey = "ciphers";
78
const char *const tlsEnableKey = "enable";
79
const char *const methodKey = "method";
80
const char *const timeoutKey = "timeout";
81
const char *const tlsPasswordKey = "password";
82
const char *const privateKeyKey = "privateKey";
83
const char *const requireCertifKey = "requireCertif";
84
const char *const serverKey = "server";
85
const char *const verifyClientKey = "verifyClient";
86
const char *const verifyServerKey = "verifyServer";
88
const char *const stunEnabledKey = "stunEnabled";
89
const char *const stunServerKey = "stunServer";
91
const char *const credKey = "credential";
50
enum DtmfType { OVERRTP, SIPINFO};
52
// SIP specific configuration keys
53
static const char *const expireKey = "expire";
54
static const char *const interfaceKey = "interface";
55
static const char *const portKey = "port";
56
static const char *const publishAddrKey = "publishAddr";
57
static const char *const publishPortKey = "publishPort";
58
static const char *const sameasLocalKey = "sameasLocal";
59
static const char *const dtmfTypeKey = "dtmfType";
60
static const char *const serviceRouteKey = "serviceRoute";
62
// TODO: write an object to store credential which implement serializable
63
static const char *const srtpKey = "srtp";
64
static const char *const srtpEnableKey = "enable";
65
static const char *const keyExchangeKey = "keyExchange";
66
static const char *const rtpFallbackKey = "rtpFallback";
68
// TODO: wirte an object to store zrtp params wich implement serializable
69
static const char *const zrtpKey = "zrtp";
70
static const char *const displaySasKey = "displaySas";
71
static const char *const displaySasOnceKey = "displaySasOnce";
72
static const char *const helloHashEnabledKey = "helloHashEnabled";
73
static const char *const notSuppWarningKey = "notSuppWarning";
75
// TODO: write an object to store tls params which implement serializable
76
static const char *const tlsKey = "tls";
77
static const char *const tlsPortKey = "tlsPort";
78
static const char *const certificateKey = "certificate";
79
static const char *const calistKey = "calist";
80
static const char *const ciphersKey = "ciphers";
81
static const char *const tlsEnableKey = "enable";
82
static const char *const methodKey = "method";
83
static const char *const timeoutKey = "timeout";
84
static const char *const tlsPasswordKey = "password";
85
static const char *const privateKeyKey = "privateKey";
86
static const char *const requireCertifKey = "requireCertif";
87
static const char *const serverKey = "server";
88
static const char *const verifyClientKey = "verifyClient";
89
static const char *const verifyServerKey = "verifyServer";
91
static const char *const stunEnabledKey = "stunEnabled";
92
static const char *const stunServerKey = "stunServer";
94
static const char *const credKey = "credential";
112
113
* Virtual destructor
114
115
virtual ~SIPAccount();
117
virtual VoIPLink* getVoIPLink();
115
119
std::string getUserAgentName() const;
116
120
void setRegistrationStateDetailed(const std::pair<int, std::string> &details) {
117
121
registrationStateDetailed_ = details;
125
* Serialize internal state of this account for configuration
126
* @param YamlEmitter the configuration engine which generate the configuration file
120
128
virtual void serialize(Conf::YamlEmitter *emitter);
131
* Populate the internal state for this account based on info stored in the configuration file
132
* @param The configuration node for this account
122
134
virtual void unserialize(Conf::MappingNode *map);
137
* Set the internal state for this account, mainly used to manage account details from the client application.
138
* @param The map containing the account information.
124
140
virtual void setAccountDetails(std::map<std::string, std::string> details);
143
* Return an map containing the internal state of this account. Client application can use this method to manage
145
* @return A map containing the account information.
126
147
virtual std::map<std::string, std::string> getAccountDetails() const;
150
* Return the information for the default IP to IP account
127
152
std::map<std::string, std::string> getIp2IpDetails() const;
155
* Return the TLS settings, mainly used to return security information to
156
* a client application
128
158
std::map<std::string, std::string> getTlsSettings() const;
161
* Manage the TLS settings from a client application
129
163
void setTlsSettings(const std::map<std::string, std::string>& details);
302
363
std::string getServerUri() const;
366
* Set the contact header
305
367
* @param port Optional port. Otherwise set to the port defined for that account.
306
368
* @param hostname Optional local address. Otherwise set to the hostname defined for that account.
370
void setContactHeader(std::string address, std::string port);
373
* Get the contact header for
307
374
* @return pj_str_t The contact header based on account information
309
std::string getContactHeader(const std::string& address, const std::string& port) const;
376
std::string getContactHeader(void) const;
379
* The contact header can be rewritten based on the contact provided by the registrar in 200 OK
381
void enableContactUpdate(void) {
382
contactUpdateEnabled_ = true;
386
* The contact header is not updated even if the registrar
388
void disableContactUpdate(void) {
389
contactUpdateEnabled_ = false;
392
bool isContactUpdateEnabled(void) {
393
return contactUpdateEnabled_;
312
397
* Get the local interface name on which this account is bound.
470
566
pj_uint16_t tlsListenerPort_;
569
* Transport type used for this sip account. Currently supported types:
570
* PJSIP_TRANSPORT_UNSPECIFIED
571
* PJSIP_TRANSPORT_UDP
572
* PJSIP_TRANSPORT_TLS
472
574
pjsip_transport_type_e transportType_;
474
//Credential information
577
* Credential information stored for further registration.
475
579
pjsip_cred_info *cred_;
477
// The TLS settings, if tls is chosen as
582
* The TLS settings, used only if tls is chosen as a sip transport.
479
584
pjsip_tls_setting tlsSetting_;
481
// The STUN server name, if applicable for internal use only
587
* The CONTACT header used for registration as provided by the registrar, this value could differ
588
* from the host name in case the registrar is inside a subnetwork (such as a VPN).
589
* The header will be stored
591
std::string contactHeader_;
594
* Enble the contact header based on the header received from the registrar in 200 OK
596
bool contactUpdateEnabled_;
599
* The STUN server name (hostname)
482
601
pj_str_t stunServerName_;
484
// The STUN server port, if applicable
604
* The STUN server port
485
606
pj_uint16_t stunPort_;
609
* DTMF type used for this account SIPINFO or RTP
611
std::string dtmfType_;
614
* Determine if TLS is enabled for this account. TLS provides a secured channel for
615
* SIP signalization. It is independant than the media encription provided by SRTP or ZRTP.
489
617
std::string tlsEnable_;
620
* Specify the TLS port
625
* Certificate autority file
491
627
std::string tlsCaListFile_;
492
628
std::string tlsCertificateFile_;
493
629
std::string tlsPrivateKeyFile_;
501
637
std::string tlsNegotiationTimeoutSec_;
502
638
std::string tlsNegotiationTimeoutMsec_;
641
* The stun server hostname (optional), used to provide the public IP address in case the softphone
504
644
std::string stunServer_;
647
* Determine if STUN public address resolution is required to register this account. In this case a
648
* STUN server hostname must be specified.
505
650
bool stunEnabled_;
653
* Determine if SRTP is enabled for this account, SRTP and ZRTP are mutually exclusive
654
* This only determine if the media channel is secured. One could only enable TLS
655
* with no secured media channel.
507
657
bool srtpEnabled_;
660
* Specifies the type of key exchange usd for SRTP (sdes/zrtp)
508
662
std::string srtpKeyExchange_;
665
* Determine if the softphone should fallback on non secured media channel if SRTP negotiation fails.
666
* Make sure other SIP endpoints share the same behavior since it could result in encrypted data to be
667
* played through the audio device.
509
669
bool srtpFallback_;
672
* Determine if the SAS sould be displayed on client side. SAS is a 4-charcter string
673
* that end users should verbaly validate to ensure the channel is secured. Used especially
674
* to prevent man-in-the-middle attack.
511
676
bool zrtpDisplaySas_;
679
* Only display SAS 4-character string once at the begining of the call.
512
681
bool zrtpDisplaySasOnce_;
513
683
bool zrtpHelloHash_;
514
684
bool zrtpNotSuppWarning_;
516
* Details about the registration state.
517
* This is a protocol Code:Description pair.
687
* Details about the registration state.
688
* This is a protocol Code:Description pair.
519
690
std::pair<int, std::string> registrationStateDetailed_;
693
* Timer used to regularrly send re-register request based
694
* on the "Expire" sip header (or the "expire" Contact parameter)
696
pj_timer_entry keepAliveTimer_;
700
* Voice over IP Link contains a listener thread and calls