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_RTP_SRTP_H
00035 #define OPAL_RTP_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 
00047 #include <rtp/rtp.h>
00048 #include <opal/rtpconn.h>
00049 
00050 #if OPAL_SRTP
00051 
00052 namespace PWLibStupidLinkerHacks {
00053   extern int libSRTPLoader;
00054 };
00055 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 class OpalSRTPSecurityMode : public OpalSecurityMode
00071 {
00072   PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
00073   public:
00074     struct KeySalt {
00075       KeySalt()                                                       { }
00076       KeySalt(const PBYTEArray & data)           : key(data)          { }
00077       KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
00078       PBYTEArray key;
00079       PBYTEArray salt;
00080     };
00081     virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
00082     virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
00083     virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
00084     virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
00085 
00086     virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
00087     virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
00088     virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
00089     virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
00090 };
00091 
00093 
00094 
00095 
00096 
00097 class OpalSRTP_UDP : public SecureRTP_UDP
00098 {
00099   PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
00100   public:
00101     OpalSRTP_UDP(
00102       const Params & options 
00103     );
00104 
00105     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame) = 0;
00106     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
00107     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
00108     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
00109 };
00110 
00111 
00113 
00114 
00115 
00116 
00117 class LibSRTP_UDP : public OpalSRTP_UDP
00118 {
00119   PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
00120   public:
00121     LibSRTP_UDP(
00122       const Params & options 
00123     );
00124 
00125     ~LibSRTP_UDP();
00126 
00127     PBoolean Open(
00128       PIPSocket::Address localAddress,  
00129       WORD portBase,                    
00130       WORD portMax,                     
00131       BYTE ipTypeOfService,             
00132       PNatMethod * natMethod = NULL,    
00133       RTP_QOS * rtpqos = NULL           
00134     );
00135 
00136     virtual SendReceiveStatus OnSendData   (RTP_DataFrame & frame);
00137     virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
00138     virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
00139     virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
00140 };
00141 
00142 
00143 #endif // OPAL_SRTP
00144 
00145 #endif // OPAL_RTP_SRTP_H