1 /*
2 Copyright (C) 2006-2009 Werner Dittmann
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef _ZRTPQUEUE_H_
19 #define _ZRTPQUEUE_H_
20
26
29
30 NAMESPACE_COMMONCPP
31
188
189 public:
190
236 int32_t initialize(const char *zidFilename, bool autoEnable = true,
238
239 /*
240 * Applications use the following methods to control ZRTP, for example
241 * to enable ZRTP, set flags etc.
242 */
243
273 void setEnableZrtp(bool onOff);
274
281 bool isEnableZrtp();
282
302 void SASVerified();
303
308 void resetSASVerified();
309
315 void goClearOk();
316
325 void requestGoClear();
326
338 void setAuxSecret(uint8_t* data, int32_t length);
339
352
369 void setClientId(std::string id);
370
384 std::string getHelloHash();
385
401 std::string getPeerHelloHash();
402
423 std::string getMultiStrParams();
424
441 void setMultiStrParams(std::string parameters);
442
454 bool isMultiStream();
455
465 bool isMultiStreamAvailable();
466
479 void acceptEnrollment(bool accepted);
480
486 std::string getSasType();
487
498 uint8_t* getSasHash();
499
510 bool sendSASRelayPacket(uint8_t* sh, std::string render);
511
520 bool isMitmMode();
521
530 void setMitmMode(bool mitmMode);
531
560 void setParanoidMode(bool yesNo);
561
568 bool isParanoidMode();
569
578 bool isEnrollmentMode();
579
591 void setEnrollmentMode(bool enrollmentMode);
592
597 {setMitmMode(enrollmentMode); setEnrollmentMode(enrollmentMode);}
598
609
618 void setSignSas(bool sasSignMode);
619
636 bool setSignatureData(uint8* data, int32 length);
637
649 const uint8* getSignatureData();
650
661 int32 getSignatureLength();
662
681 void
682 putData(uint32 stamp,
const unsigned char* data = NULL,
size_t len = 0);
683
703 void
704 sendImmediate(uint32 stamp,
const unsigned char* data = NULL,
size_t len = 0);
705
721 void startZrtp();
722
730 void stopZrtp();
731
750 int32 getPeerZid(uint8* data);
751
752 protected:
754
769 virtual bool
770 onSRTPPacketError(IncomingRTPPkt& pkt, int32 errorCode);
771
777 void handleTimeout(const std::string &c);
778
788 virtual size_t takeInDataPacket();
789
790 /*
791 * The following methods implement the GNU ZRTP callback interface.
792 * For detailed documentation refer to file ZrtpCallback.h
793 */
794 int32_t sendDataZRTP(const unsigned char* data, int32_t length);
795
796 int32_t activateTimer(int32_t time);
797
798 int32_t cancelTimer();
799
800 void sendInfo(GnuZrtpCodes::MessageSeverity severity, int32_t subCode);
801
802 bool srtpSecretsReady(SrtpSecret_t* secrets, EnableSecurity part);
803
804 void srtpSecretsOff(EnableSecurity part);
805
806 void srtpSecretsOn(std::string c, std::string s, bool verified);
807
808 void handleGoClear();
809
810 void zrtpNegotiationFailed(GnuZrtpCodes::MessageSeverity severity, int32_t subCode);
811
812 void zrtpNotSuppOther();
813
814 void synchEnter();
815
816 void synchLeave();
817
818 void zrtpAskEnrollment(GnuZrtpCodes::InfoEnrollment info);
819
820 void zrtpInformEnrollment(GnuZrtpCodes::InfoEnrollment info);
821
822 void signSAS(uint8_t* sasHash);
823
824 bool checkSASSignature(uint8_t* sasHash);
825
826 /*
827 * End of ZrtpCallback functions.
828 */
829
830 ZrtpQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
831 RTPApplication& app = defaultApplication());
832
837 RTPDataQueue::defaultMembersHashSize,
838 RTPApplication& app = defaultApplication());
839
841
842 private:
843 void init();
844 size_t rtpDataPacket(unsigned char* packet, int32 rtn,
845 InetHostAddress network_address,
846 tpport_t transport_port);
847
850
851 std::string clientIdString;
852
854
856
857 int16 senderZrtpSeqNo;
858 ost::Mutex
synchLock;
// Mutex for ZRTP (used by ZrtpStateClass)
863 bool enableParanoidMode;
864 };
865
867
868 public:
878
880 { }
881
882 uint32
883 getZrtpMagic() const;
884
885 uint32
886 getSSRC() const;
887 };
888
890
891 public:
903 { }
904 };
905
906 END_NAMESPACE
907
908 #endif
909
void setPBXEnrollment(bool enrollmentMode)
Backwards compatible api fix...
Class to generate objects giving timeout functionality.
RTP packets received from other participants.
void putData(uint32 stamp, const unsigned char *data=NULL, size_t len=0)
This is used to create a data packet in the send queue.
This abstract class defines the callback functions required by GNU ZRTP.
Application callback methods.
GNU ccRTP extension to support GNU ZRTP.
int32_t isPeerEnrolled(ZrtpContext *zrtpContext)
Check if a peer's cache entry has a vaild MitM key.
Generic RTCP control queues.
Callback interface between ZRTP and the RTP stack implementation.
void sendImmediate(uint32 stamp, const unsigned char *data=NULL, size_t len=0)
This is used to create a data packet and send it immediately.
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...