00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __OPAL_SRTP_H
00035 #define __OPAL_SRTP_H
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041 #ifndef _PTLIB_H
00042 #include <ptlib.h>
00043 #endif
00044
00045 #include <opal/buildopts.h>
00046 #include <rtp/rtp.h>
00047 #include <opal/connection.h>
00048
00049 #if OPAL_SRTP
00050
00051 namespace PWLibStupidLinkerHacks {
00052 extern int libSRTPLoader;
00053 };
00054
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 class OpalSRTPSecurityMode : public OpalSecurityMode
00070 {
00071 PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00072 public:
00073 struct KeySalt {
00074 KeySalt() { }
00075 KeySalt(const PBYTEArray & data) : key(data) { }
00076 KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00077 PBYTEArray key;
00078 PBYTEArray salt;
00079 };
00080 virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
00081 virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
00082 virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
00083 virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
00084
00085 virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
00086 virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
00087 virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
00088 virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
00089 };
00090
00092
00093
00094
00095
00096 class OpalSRTP_UDP : public SecureRTP_UDP
00097 {
00098 PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00099 public:
00100 OpalSRTP_UDP(
00101 #if OPAL_RTP_AGGREGATE
00102 PHandleAggregator * _aggregator,
00103 #endif
00104 unsigned id,
00105 PBoolean remoteIsNAT
00106 );
00107
00108 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame) = 0;
00109 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00110 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00111 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00112 };
00113
00114
00116
00117
00118
00119
00120 #if HAS_LIBSRTP || HAS_LIBZRTP
00121
00122 class LibSRTP_UDP : public OpalSRTP_UDP
00123 {
00124 PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00125 public:
00126 LibSRTP_UDP(
00127 #if OPAL_RTP_AGGREGATE
00128 PHandleAggregator * _aggregator,
00129 #endif
00130 unsigned int id,
00131 PBoolean remoteIsNAT
00132 );
00133
00134 ~LibSRTP_UDP();
00135
00136 PBoolean Open(
00137 PIPSocket::Address localAddress,
00138 WORD portBase,
00139 WORD portMax,
00140 BYTE ipTypeOfService,
00141 PSTUNClient * stun = NULL,
00142 RTP_QOS * rtpqos = NULL
00143 );
00144
00145 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame);
00146 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00147 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00148 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00149 };
00150
00151 #endif // HAS_LIBSRTP
00152
00153
00154 #endif // OPAL_SRTP
00155
00156 #endif // __OPAL_SRTP_H