~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/src/sip/sipaccount.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2012-02-18 21:47:09 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120218214709-6362d71gqdsdkrj5
Tags: 1.0.2-1
* New upstream release
  - remove logging patch (applied upstream)
  - update s390 patch since it was partially applied upstream
* Include the Evolution plugin as a separate binary package

* Fix compilation issues on SH4 (closes: #658987)
* Merge Ubuntu's binutils-gold linking fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "noncopyable.h"
45
45
 
46
46
namespace Conf {
47
 
class YamlEmitter;
48
 
class MappingNode;
 
47
    class YamlEmitter;
 
48
    class MappingNode;
 
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";
 
58
 
 
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";
 
64
 
 
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";
 
71
 
 
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";
 
87
 
 
88
    const char *const stunEnabledKey = "stunEnabled";
 
89
    const char *const stunServerKey = "stunServer";
 
90
 
 
91
    const char *const credKey = "credential";
49
92
}
50
 
enum DtmfType { OVERRTP, SIPINFO};
51
 
 
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";
61
 
 
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";
67
 
 
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";
74
 
 
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";
90
 
 
91
 
static const char *const stunEnabledKey = "stunEnabled";
92
 
static const char *const stunServerKey = "stunServer";
93
 
 
94
 
static const char *const credKey = "credential";
95
93
 
96
94
class SIPVoIPLink;
97
95
 
102
100
 
103
101
class SIPAccount : public Account {
104
102
    public:
 
103
        static const char * const OVERRTP_STR;
 
104
        static const char * const SIPINFO_STR;
 
105
 
105
106
        /**
106
107
         * Constructor
107
108
         * @param accountID The account identifier
112
113
         * Virtual destructor
113
114
         */
114
115
        virtual ~SIPAccount();
 
116
 
 
117
        virtual VoIPLink* getVoIPLink();
 
118
 
115
119
        std::string getUserAgentName() const;
116
120
        void setRegistrationStateDetailed(const std::pair<int, std::string> &details) {
117
121
            registrationStateDetailed_ = details;
118
122
        }
119
123
 
 
124
        /**
 
125
         * Serialize internal state of this account for configuration
 
126
         * @param YamlEmitter the configuration engine which generate the configuration file
 
127
         */
120
128
        virtual void serialize(Conf::YamlEmitter *emitter);
121
129
 
 
130
        /**
 
131
         * Populate the internal state for this account based on info stored in the configuration file
 
132
         * @param The configuration node for this account
 
133
         */
122
134
        virtual void unserialize(Conf::MappingNode *map);
123
135
 
 
136
        /**
 
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.
 
139
         */
124
140
        virtual void setAccountDetails(std::map<std::string, std::string> details);
125
141
 
 
142
        /**
 
143
         * Return an map containing the internal state of this account. Client application can use this method to manage
 
144
         * account info.
 
145
         * @return A map containing the account information.
 
146
         */
126
147
        virtual std::map<std::string, std::string> getAccountDetails() const;
 
148
 
 
149
        /**
 
150
         * Return the information for the default IP to IP account
 
151
         */
127
152
        std::map<std::string, std::string> getIp2IpDetails() const;
 
153
 
 
154
        /**
 
155
         * Return the TLS settings, mainly used to return security information to
 
156
         * a client application
 
157
         */
128
158
        std::map<std::string, std::string> getTlsSettings() const;
 
159
 
 
160
        /**
 
161
         * Manage the TLS settings from a client application
 
162
         */
129
163
        void setTlsSettings(const std::map<std::string, std::string>& details);
130
164
 
131
165
        /**
143
177
         */
144
178
        void unregisterVoIPLink();
145
179
 
 
180
        /**
 
181
         * Start the keep alive function, once started, the account will be registered periodically
 
182
         * a new REGISTER request is sent bey the client application. The account must be initially
 
183
         * registered for this call to be effective.
 
184
         */
 
185
        void startKeepAliveTimer();
 
186
 
 
187
        /**
 
188
         * Stop the keep alive timer. Once canceled, no further registration will be scheduled
 
189
         */
 
190
        void stopKeepAliveTimer();
 
191
 
 
192
 
146
193
        pjsip_cred_info *getCredInfo() const {
147
194
            return cred_;
148
195
        }
175
222
        }
176
223
 
177
224
        /**
178
 
         * Doubles the Expiration Interval of Contact Addresses.
 
225
         * Set the expiration for this account as found in
 
226
         * the "Expire" sip header or the CONTACT's "expire" param.
 
227
         */
 
228
        void setRegistrationExpire(int expire) {
 
229
            if (expire > 0)
 
230
                registrationExpire_ = expire;
 
231
        }
 
232
 
 
233
        /**
 
234
         * Doubles the Expiration Interval sepecified for registration.
179
235
         */
180
236
        void doubleRegistrationExpire() {
181
237
            registrationExpire_ *= 2;
188
244
        bool userMatch(const std::string& username) const;
189
245
        bool hostnameMatch(const std::string& hostname) const;
190
246
 
191
 
        /* Registration flag */
192
 
        bool isRegister() const {
 
247
        /**
 
248
         * Registration flag
 
249
         */
 
250
        bool isRegistered() const {
193
251
            return bRegister_;
194
252
        }
 
253
 
 
254
        /**
 
255
         * Set registration flag
 
256
         */
195
257
        void setRegister(bool result) {
196
258
            bRegister_ = result;
197
259
        }
200
262
         * Get the registration stucture that is used
201
263
         * for PJSIP in the registration process.
202
264
         * Settings are loaded from configuration file.
203
 
         * @param void
204
265
         * @return pjsip_regc* A pointer to the registration structure
205
266
         */
206
267
        pjsip_regc* getRegistrationInfo() {
302
363
        std::string getServerUri() const;
303
364
 
304
365
        /**
 
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.
 
369
         */
 
370
        void setContactHeader(std::string address, std::string port);
 
371
 
 
372
        /**
 
373
         * Get the contact header for
307
374
         * @return pj_str_t The contact header based on account information
308
375
         */
309
 
        std::string getContactHeader(const std::string& address, const std::string& port) const;
 
376
        std::string getContactHeader(void) const;
 
377
 
 
378
        /**
 
379
         * The contact header can be rewritten based on the contact provided by the registrar in 200 OK
 
380
         */
 
381
        void enableContactUpdate(void) {
 
382
            contactUpdateEnabled_ = true;
 
383
        }
 
384
 
 
385
        /**
 
386
         * The contact header is not updated even if the registrar
 
387
         */
 
388
        void disableContactUpdate(void) {
 
389
            contactUpdateEnabled_ = false;
 
390
        }
 
391
 
 
392
        bool isContactUpdateEnabled(void) {
 
393
            return contactUpdateEnabled_;
 
394
        }
310
395
 
311
396
        /**
312
397
         * Get the local interface name on which this account is bound.
390
475
            return serviceRoute_;
391
476
        }
392
477
 
393
 
        DtmfType getDtmfType() const {
 
478
        std::string getDtmfType() const {
394
479
            return dtmfType_;
395
480
        }
396
481
 
410
495
            return zrtpHelloHash_;
411
496
        }
412
497
 
 
498
        /**
 
499
         * Timer used to periodically send re-register request based
 
500
         * on the "Expire" sip header (or the "expire" Contact parameter)
 
501
         */
 
502
        static void keepAliveRegistrationCb(pj_timer_heap_t *th, pj_timer_entry *te);
 
503
 
413
504
        pjsip_transport* transport_;
414
505
    private:
415
506
        NON_COPYABLE(SIPAccount);
442
533
         */
443
534
        static std::string getLoginName();
444
535
 
445
 
        // The pjsip client registration information
 
536
        /**
 
537
         * The pjsip client registration information
 
538
         */
446
539
        pjsip_regc *regc_;
447
 
        // To check if the account is registered
 
540
 
 
541
        /**
 
542
         * To check if the account is registered
 
543
         */
448
544
        bool bRegister_;
449
545
 
450
546
        // Network settings
469
565
         */
470
566
        pj_uint16_t tlsListenerPort_;
471
567
 
 
568
        /**
 
569
         * Transport type used for this sip account. Currently supported types:
 
570
         *    PJSIP_TRANSPORT_UNSPECIFIED
 
571
         *    PJSIP_TRANSPORT_UDP
 
572
         *    PJSIP_TRANSPORT_TLS
 
573
         */
472
574
        pjsip_transport_type_e transportType_;
473
575
 
474
 
        //Credential information
 
576
        /**
 
577
         * Credential information stored for further registration.
 
578
         */
475
579
        pjsip_cred_info *cred_;
476
580
 
477
 
        // The TLS settings, if tls is chosen as
478
 
        // a sip transport.
 
581
        /**
 
582
         * The TLS settings, used only if tls is chosen as a sip transport.
 
583
         */
479
584
        pjsip_tls_setting tlsSetting_;
480
585
 
481
 
        // The STUN server name, if applicable for internal use only
 
586
        /**
 
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
 
590
         */
 
591
        std::string contactHeader_;
 
592
 
 
593
        /**
 
594
         * Enble the contact header based on the header received from the registrar in 200 OK
 
595
         */
 
596
        bool contactUpdateEnabled_;
 
597
 
 
598
        /**
 
599
         * The STUN server name (hostname)
 
600
         */
482
601
        pj_str_t stunServerName_;
483
602
 
484
 
        // The STUN server port, if applicable
 
603
        /**
 
604
         * The STUN server port
 
605
         */
485
606
        pj_uint16_t stunPort_;
486
607
 
487
 
        DtmfType dtmfType_;
 
608
        /**
 
609
         * DTMF type used for this account SIPINFO or RTP
 
610
         */
 
611
        std::string dtmfType_;
488
612
 
 
613
        /**
 
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.
 
616
         */
489
617
        std::string tlsEnable_;
 
618
 
 
619
        /**
 
620
         * Specify the TLS port
 
621
         */
490
622
        int tlsPort_;
 
623
 
 
624
        /**
 
625
         * Certificate autority file
 
626
         */
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_;
503
639
 
 
640
        /**
 
641
         * The stun server hostname (optional), used to provide the public IP address in case the softphone
 
642
         * stay behind a NAT.
 
643
         */
504
644
        std::string stunServer_;
 
645
 
 
646
        /**
 
647
         * Determine if STUN public address resolution is required to register this account. In this case a
 
648
         * STUN server hostname must be specified.
 
649
         */
505
650
        bool stunEnabled_;
506
651
 
 
652
        /**
 
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.
 
656
         */
507
657
        bool srtpEnabled_;
 
658
 
 
659
        /**
 
660
         * Specifies the type of key exchange usd for SRTP (sdes/zrtp)
 
661
         */
508
662
        std::string srtpKeyExchange_;
 
663
 
 
664
        /**
 
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.
 
668
         */
509
669
        bool srtpFallback_;
510
670
 
 
671
        /**
 
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.
 
675
         */
511
676
        bool zrtpDisplaySas_;
 
677
 
 
678
        /**
 
679
         * Only display SAS 4-character string once at the begining of the call.
 
680
         */
512
681
        bool zrtpDisplaySasOnce_;
 
682
 
513
683
        bool zrtpHelloHash_;
514
684
        bool zrtpNotSuppWarning_;
515
 
        /*
516
 
        * Details about the registration state.
517
 
        * This is a protocol Code:Description pair.
518
 
        */
 
685
 
 
686
        /**
 
687
         * Details about the registration state.
 
688
         * This is a protocol Code:Description pair.
 
689
         */
519
690
        std::pair<int, std::string> registrationStateDetailed_;
 
691
 
 
692
        /**
 
693
         * Timer used to regularrly send re-register request based
 
694
         * on the "Expire" sip header (or the "expire" Contact parameter)
 
695
         */
 
696
        pj_timer_entry keepAliveTimer_;
 
697
 
 
698
 
 
699
        /**
 
700
         * Voice over IP Link contains a listener thread and calls
 
701
         */
 
702
        SIPVoIPLink* link_;
520
703
};
521
704
 
522
705
#endif