ccRTP 2.1.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ZrtpQueue.h
Go to the documentation of this file.
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 
21 #include <ccrtp/cqueue.h>
22 #include <ccrtp/rtppkt.h>
26 
28 class __EXPORT ZRtp;
29 
30 NAMESPACE_COMMONCPP
31 
188 
189 public:
190 
236  int32_t initialize(const char *zidFilename, bool autoEnable = true,
237  ZrtpConfigure* config = NULL);
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 
351  void setUserCallback(ZrtpUserCallback* ucb);
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 
596  inline void setPBXEnrollment(bool enrollmentMode)
597  {setMitmMode(enrollmentMode); setEnrollmentMode(enrollmentMode);}
598 
608  bool isPeerEnrolled();
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:
753  friend class TimeoutProvider<std::string, ost::ZrtpQueue*>;
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 
836  ZrtpQueue(uint32 ssrc, uint32 size =
837  RTPDataQueue::defaultMembersHashSize,
838  RTPApplication& app = defaultApplication());
839 
840  virtual ~ZrtpQueue();
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 
848  ZRtp *zrtpEngine;
849  ZrtpUserCallback* zrtpUserCallback;
850 
851  std::string clientIdString;
852 
853  bool enableZrtp;
854 
855  int32 secureParts;
856 
857  int16 senderZrtpSeqNo;
858  ost::Mutex synchLock; // Mutex for ZRTP (used by ZrtpStateClass)
859  uint32 peerSSRC;
860  bool started;
861  bool mitmMode;
862  bool signSas;
863  bool enableParanoidMode;
864 };
865 
867 
868 public:
877  IncomingZRTPPkt(const unsigned char* block, size_t len);
878 
880  { }
881 
882  uint32
883  getZrtpMagic() const;
884 
885  uint32
886  getSSRC() const;
887 };
888 
890 
891 public:
901  OutgoingZRTPPkt(const unsigned char* const hdrext, uint32 hdrextlen);
903  { }
904 };
905 
906 END_NAMESPACE
907 
908 #endif
909 
ZRTP configuration data.
void setPBXEnrollment(bool enrollmentMode)
Backwards compatible api fix...
Definition: ZrtpQueue.h:596
Class to generate objects giving timeout functionality.
RTP packets received from other participants.
Definition: rtppkt.h:704
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.
Definition: outqueue.cpp:404
This abstract class defines the callback functions required by GNU ZRTP.
Definition: ZrtpCallback.h:119
Application callback methods.
GNU ccRTP extension to support GNU ZRTP.
Definition: ZrtpQueue.h:187
int32_t isPeerEnrolled(ZrtpContext *zrtpContext)
Check if a peer's cache entry has a vaild MitM key.
The ZRTP configure functions.
Generic RTCP control queues.
#define __EXPORT
Definition: ZrtpCallback.h:40
struct ZRtp ZRtp
Definition: ZrtpCWrapper.h:260
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.
Definition: outqueue.cpp:464
RTP packets handling.
ost::Mutex synchLock
RTP packets being sent.
Definition: rtppkt.h:507
This class, an RTP/RTCP queue, adds audio/video profile (AVP) specific methods to the generic RTCP se...
Definition: cqueue.h:708