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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #ifndef __OPAL_SRTP_H
00075 #define __OPAL_SRTP_H
00076
00077 #ifdef P_USE_PRAGMA
00078 #pragma interface
00079 #endif
00080
00081 #ifndef _PTLIB_H
00082 #include <ptlib.h>
00083 #endif
00084
00085 #include <opal/buildopts.h>
00086 #include <rtp/rtp.h>
00087 #include <opal/connection.h>
00088
00089 #if OPAL_SRTP
00090
00091 namespace PWLibStupidLinkerHacks {
00092 extern int libSRTPLoader;
00093 };
00094
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 class OpalSRTPSecurityMode : public OpalSecurityMode
00110 {
00111 PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00112 public:
00113 struct KeySalt {
00114 KeySalt() { }
00115 KeySalt(const PBYTEArray & data) : key(data) { }
00116 KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00117 PBYTEArray key;
00118 PBYTEArray salt;
00119 };
00120 virtual BOOL SetOutgoingKey(const KeySalt & key) = 0;
00121 virtual BOOL GetOutgoingKey(KeySalt & key) const = 0;
00122 virtual BOOL SetOutgoingSSRC(DWORD ssrc) = 0;
00123 virtual BOOL GetOutgoingSSRC(DWORD & ssrc) const = 0;
00124
00125 virtual BOOL SetIncomingKey(const KeySalt & key) = 0;
00126 virtual BOOL GetIncomingKey(KeySalt & key) const = 0;
00127 virtual BOOL SetIncomingSSRC(DWORD ssrc) = 0;
00128 virtual BOOL GetIncomingSSRC(DWORD & ssrc) const = 0;
00129 };
00130
00132
00133
00134
00135
00136 class OpalSRTP_UDP : public SecureRTP_UDP
00137 {
00138 PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00139 public:
00140 OpalSRTP_UDP(
00141 PHandleAggregator * _aggregator,
00142 unsigned id,
00143 BOOL remoteIsNAT
00144 );
00145
00146 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame) = 0;
00147 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00148 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00149 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00150 };
00151
00152
00154
00155
00156
00157
00158 #if HAS_LIBSRTP || HAS_LIBZRTP
00159
00160 class LibSRTP_UDP : public OpalSRTP_UDP
00161 {
00162 PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00163 public:
00164 LibSRTP_UDP(PHandleAggregator * _aggregator,
00165 unsigned int id,
00166 BOOL remoteIsNAT
00167 );
00168
00169 ~LibSRTP_UDP();
00170
00171 BOOL Open(
00172 PIPSocket::Address localAddress,
00173 WORD portBase,
00174 WORD portMax,
00175 BYTE ipTypeOfService,
00176 PSTUNClient * stun = NULL,
00177 RTP_QOS * rtpqos = NULL
00178 );
00179
00180 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame);
00181 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00182 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00183 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00184 };
00185
00186 #endif // HAS_LIBSRTP
00187
00188
00189 #endif // OPAL_SRTP
00190
00191 #endif // __OPAL_SRTP_H