| TimeoutProvider.h | | TimeoutProvider.h | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| * Modified to use the common c++ library functions and the STL | | * Modified to use the common c++ library functions and the STL | |
| * list by Werner Dittmann. | | * list by Werner Dittmann. | |
| * | | * | |
| * @author Erik Eliasson, eliasson@it.kth.se, 2003 | | * @author Erik Eliasson, eliasson@it.kth.se, 2003 | |
| * @author Werner Dittmann <Werner.Dittmann@t-online.de> | | * @author Werner Dittmann <Werner.Dittmann@t-online.de> | |
| */ | | */ | |
| | | | |
| #include <list> | | #include <list> | |
| #include <sys/time.h> | | #include <sys/time.h> | |
| | | | |
|
| #include <cc++/config.h> | | #include <commoncpp/config.h> | |
| #include <cc++/thread.h> | | #include <commoncpp/thread.h> | |
| | | | |
| /** | | /** | |
| * Represents a request of a "timeout" (delivery of a command to a | | * Represents a request of a "timeout" (delivery of a command to a | |
| * "timeout receiver" after at least a specified time period). | | * "timeout receiver" after at least a specified time period). | |
| * | | * | |
| * Slightly modified to use gettimeofday directly. | | * Slightly modified to use gettimeofday directly. | |
| * | | * | |
| * NOTE: This class is only used internaly. | | * NOTE: This class is only used internaly. | |
| * @author Erik Eliasson | | * @author Erik Eliasson | |
| * @author Werner Dittmann | | * @author Werner Dittmann | |
| */ | | */ | |
| template <class TOCommand, class TOSubscriber> | | template <class TOCommand, class TOSubscriber> | |
| class TPRequest | | class TPRequest | |
| { | | { | |
| | | | |
| public: | | public: | |
| | | | |
| TPRequest( TOSubscriber tsi, int timeoutMs, const TOCommand &command): | | TPRequest( TOSubscriber tsi, int timeoutMs, const TOCommand &command): | |
|
| subscriber(tsi) | | subscriber(tsi) | |
| { | | { | |
| struct timeval tv; | | struct timeval tv; | |
| gettimeofday(&tv, NULL ); | | gettimeofday(&tv, NULL ); | |
| | | | |
| when_ms = ((uint64)tv.tv_sec) * (uint64)1000 + ((uint64)tv.tv_usec)
/ (uint64)1000; | | when_ms = ((uint64)tv.tv_sec) * (uint64)1000 + ((uint64)tv.tv_usec)
/ (uint64)1000; | |
|
| when_ms += timeoutMs; | | when_ms += timeoutMs; | |
| this->command = command; | | this->command = command; | |
| } | | } | |
| | | | |
| /** | | /** | |
| * @param t ms since Epoch | | * @param t ms since Epoch | |
| */ | | */ | |
| bool happensBefore(uint64 t) | | bool happensBefore(uint64 t) | |
| { | | { | |
|
| if (when_ms < t) { | | if (when_ms < t) { | |
| return true; | | return true; | |
| } | | } | |
| if (when_ms > t) { | | if (when_ms > t) { | |
| return false; | | return false; | |
| } | | } | |
| return false; // if equal it does not "happens_before" | | return false; // if equal it does not "happens_before" | |
| | | | |
| } | | } | |
| | | | |
| bool happensBefore(const TPRequest *req){ | | bool happensBefore(const TPRequest *req){ | |
|
| return happensBefore(req->when_ms); | | return happensBefore(req->when_ms); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Number of milli seconds until timeout from when this method is | | * Number of milli seconds until timeout from when this method is | |
| * called | | * called | |
| */ | | */ | |
| int getMsToTimeout () | | int getMsToTimeout () | |
| { | | { | |
| struct timeval tv; | | struct timeval tv; | |
| gettimeofday(&tv, NULL ); | | gettimeofday(&tv, NULL ); | |
| | | | |
| uint64 now = ((uint64)tv.tv_sec) * (uint64)1000 + ((uint64)tv.tv_us
ec) / (uint64)1000; | | uint64 now = ((uint64)tv.tv_sec) * (uint64)1000 + ((uint64)tv.tv_us
ec) / (uint64)1000; | |
| | | | |
|
| if (happensBefore(now)) { | | if (happensBefore(now)) { | |
| return 0; | | return 0; | |
| } | | } | |
| else { | | else { | |
| return (int)(when_ms - now); | | return (int)(when_ms - now); | |
| } | | } | |
| } | | } | |
| | | | |
| TOCommand getCommand() | | TOCommand getCommand() | |
| { | | { | |
|
| return command; | | return command; | |
| } | | } | |
| | | | |
| TOSubscriber getSubscriber() | | TOSubscriber getSubscriber() | |
| { | | { | |
|
| return subscriber; | | return subscriber; | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Two timeout requests are considered equeal if they have | | * Two timeout requests are considered equeal if they have | |
| * the same subscriber AND command AND time when they | | * the same subscriber AND command AND time when they | |
| * occur. If one of the time is zero then this is a | | * occur. If one of the time is zero then this is a | |
| * wildcard and matches always. | | * wildcard and matches always. | |
| */ | | */ | |
| bool operator==(const TPRequest<TOCommand, TOSubscriber> &req) | | bool operator==(const TPRequest<TOCommand, TOSubscriber> &req) | |
| { | | { | |
|
| if (req.subscriber == subscriber && | | if (req.subscriber == subscriber && | |
| req.command == command && | | req.command == command && | |
| req.when_ms == when_ms) { | | req.when_ms == when_ms) { | |
| return true; | | return true; | |
| } | | } | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| private: | | private: | |
| TOSubscriber subscriber; | | TOSubscriber subscriber; | |
|
| uint64 when_ms; // Time since Epoch in ms when the timeout | | uint64 when_ms; // Time since Epoch in ms when the timeout | |
| // will happen | | // will happen | |
| | | | |
|
| TOCommand command; // Command that will be delivered to the | | TOCommand command; // Command that will be delivered to the | |
| // receiver (subscriber) of the timeout. | | // receiver (subscriber) of the timeout. | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Class to generate objects giving timeout functionality. | | * Class to generate objects giving timeout functionality. | |
| * | | * | |
| * @author Erik Eliasson | | * @author Erik Eliasson | |
| * @author Werner Dittmann | | * @author Werner Dittmann | |
| */ | | */ | |
| template<class TOCommand, class TOSubscriber> | | template<class TOCommand, class TOSubscriber> | |
| class TimeoutProvider : public ost::Thread, ost::Event { | | class TimeoutProvider : public ost::Thread, ost::Event { | |
| | | | |
| skipping to change at line 160 | | skipping to change at line 160 | |
| | | | |
| /** | | /** | |
| * Timeout Provide Constructor | | * Timeout Provide Constructor | |
| */ | | */ | |
| TimeoutProvider(): requests(), synchLock(), stop(false) { } | | TimeoutProvider(): requests(), synchLock(), stop(false) { } | |
| | | | |
| /** | | /** | |
| * Destructor also terminates the Timeout thread. | | * Destructor also terminates the Timeout thread. | |
| */ | | */ | |
| ~TimeoutProvider() { | | ~TimeoutProvider() { | |
|
| terminate(); | | terminate(); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Terminates the Timeout provider thread. | | * Terminates the Timeout provider thread. | |
| */ | | */ | |
| void stopThread(){ | | void stopThread(){ | |
|
| stop = true; | | stop = true; | |
| signal(); // signal event to waiting thread | | signal(); // signal event to waiting thread | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Request a timeout trigger. | | * Request a timeout trigger. | |
| * | | * | |
|
| * @param time_ms Number of milli-seconds until the timeout is | | * @param time_ms Number of milli-seconds until the timeout is | |
| * wanted. Note that a small additional period | | * wanted. Note that a small additional period of time is | |
| of time is | | * added that depends on execution speed. | |
| * added that depends on execution speed. | | | |
| * @param subscriber The receiver of the callback when the command has
timed | | * @param subscriber The receiver of the callback when the command has
timed | |
|
| * out. This argument must not be NULL. | | * out. This argument must not be NULL. | |
| * @param command Specifies the String command to be passed back in th | | * @param command Specifies the String command to be passed back in t | |
| e | | he | |
| * callback. | | * callback. | |
| */ | | */ | |
| void requestTimeout(int32_t time_ms, TOSubscriber subscriber, const TOC
ommand &command) | | void requestTimeout(int32_t time_ms, TOSubscriber subscriber, const TOC
ommand &command) | |
| { | | { | |
| TPRequest<TOCommand, TOSubscriber>* request = | | TPRequest<TOCommand, TOSubscriber>* request = | |
| new TPRequest<TOCommand, TOSubscriber>(subscriber, time_ms,
command); | | new TPRequest<TOCommand, TOSubscriber>(subscriber, time_ms,
command); | |
| | | | |
| synchLock.enter(); | | synchLock.enter(); | |
| | | | |
|
| if (requests.size()==0) { | | if (requests.size()==0) { | |
| requests.push_front(request); | | requests.push_front(request); | |
| signal(); | | signal(); | |
| synchLock.leave(); | | synchLock.leave(); | |
| return; | | return; | |
| } | | } | |
| if (request->happensBefore(requests.front())) { | | if (request->happensBefore(requests.front())) { | |
|
| requests.push_front(request); | | requests.push_front(request); | |
| signal(); | | signal(); | |
| synchLock.leave(); | | synchLock.leave(); | |
|
| return; | | return; | |
| } | | } | |
| if (requests.back()->happensBefore(request)){ | | if (requests.back()->happensBefore(request)){ | |
|
| requests.push_back(request); | | requests.push_back(request); | |
| signal(); | | signal(); | |
| synchLock.leave(); | | synchLock.leave(); | |
|
| return; | | return; | |
| } | | } | |
| | | | |
| typename std::list<TPRequest<TOCommand, TOSubscriber>* >::iterator
i; | | typename std::list<TPRequest<TOCommand, TOSubscriber>* >::iterator
i; | |
| for(i = requests.begin(); i != requests.end(); i++ ) { | | for(i = requests.begin(); i != requests.end(); i++ ) { | |
| if( request->happensBefore(*i)) { | | if( request->happensBefore(*i)) { | |
| requests.insert(i, request); | | requests.insert(i, request); | |
| break; | | break; | |
| } | | } | |
| } | | } | |
|
| signal(); | | signal(); | |
| synchLock.leave(); | | synchLock.leave(); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Removes timeout requests that belong to a subscriber and command. | | * Removes timeout requests that belong to a subscriber and command. | |
| * | | * | |
| * @see requestTimeout | | * @see requestTimeout | |
| */ | | */ | |
| void cancelRequest(TOSubscriber subscriber, const TOCommand &command) | | void cancelRequest(TOSubscriber subscriber, const TOCommand &command) | |
| { | | { | |
| synchLock.enter(); | | synchLock.enter(); | |
| typename std::list<TPRequest<TOCommand, TOSubscriber>* >::iterator
i; | | typename std::list<TPRequest<TOCommand, TOSubscriber>* >::iterator
i; | |
| for(i = requests.begin(); i != requests.end(); ) { | | for(i = requests.begin(); i != requests.end(); ) { | |
| if( (*i)->getCommand() == command && | | if( (*i)->getCommand() == command && | |
| (*i)->getSubscriber() == subscriber) { | | (*i)->getSubscriber() == subscriber) { | |
| i = requests.erase(i); | | i = requests.erase(i); | |
| continue; | | continue; | |
| } | | } | |
| i++; | | i++; | |
| } | | } | |
|
| synchLock.leave(); | | synchLock.leave(); | |
| } | | } | |
| | | | |
| protected: | | protected: | |
| | | | |
| void run() | | void run() | |
| { | | { | |
|
| do { | | do { | |
| synchLock.enter(); | | synchLock.enter(); | |
| int32_t time = 3600000; | | int32_t time = 3600000; | |
| int32_t size = 0; | | int32_t size = 0; | |
| if ((size = requests.size()) > 0) { | | if ((size = requests.size()) > 0) { | |
| time = requests.front()->getMsToTimeout(); | | time = requests.front()->getMsToTimeout(); | |
| } | | } | |
|
| if (time == 0 && size > 0) { | | if (time == 0 && size > 0) { | |
| if (stop){ // This must be checked so that we will | | if (stop){ // This must be checked so that we will | |
| // stop even if we have timeouts to deliver. | | // stop even if we have timeouts to deliver. | |
| synchLock.leave(); | | synchLock.leave(); | |
|
| return; | | return; | |
| } | | } | |
| TPRequest<TOCommand, TOSubscriber>* req = requests.front(); | | TPRequest<TOCommand, TOSubscriber>* req = requests.front(); | |
|
| TOSubscriber subs = req->getSubscriber(); | | TOSubscriber subs = req->getSubscriber(); | |
| TOCommand command = req->getCommand(); | | TOCommand command = req->getCommand(); | |
| | | | |
| requests.pop_front(); | | requests.pop_front(); | |
| | | | |
|
| synchLock.leave(); // call the command with free Mutex | | synchLock.leave(); // call the command with free Mutex | |
| subs->handleTimeout(command); | | subs->handleTimeout(command); | |
| continue; | | continue; | |
| } | | } | |
| synchLock.leave(); | | synchLock.leave(); | |
| if (stop) { // If we were told to stop while delivering | | if (stop) { // If we were told to stop while delivering | |
| // a timeout we will exit here | | // a timeout we will exit here | |
|
| return; | | return; | |
| } | | } | |
| reset(); // ready to receive triggers again | | reset(); // ready to receive triggers again | |
| wait(time); | | wait(time); | |
|
| if (stop) { // If we are told to exit while waiting we | | if (stop) { // If we are told to exit while waiting we | |
| // will exit | | // will exit | |
|
| return; | | return; | |
| } | | } | |
| } while(true); | | } while(true); | |
| } | | } | |
| | | | |
| private: | | private: | |
| | | | |
| // The timeouts are ordered in the order of which they | | // The timeouts are ordered in the order of which they | |
| // will expire. Nearest in future is first in list. | | // will expire. Nearest in future is first in list. | |
| std::list<TPRequest<TOCommand, TOSubscriber> *> requests; | | std::list<TPRequest<TOCommand, TOSubscriber> *> requests; | |
| | | | |
|
| ost::Mutex synchLock; // Protects the internal data structures | | ost::Mutex synchLock; // Protects the internal data structures | |
| | | | |
|
| bool stop; // Flag to tell the worker thread | | bool stop; // Flag to tell the worker thread | |
| // to terminate. Set to true and | | // to terminate. Set to true and | |
| // wake the worker thread to | | // wake the worker thread to | |
| // terminate it. | | // terminate it. | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
| /** EMACS ** | | /** EMACS ** | |
| * Local variables: | | * Local variables: | |
| * mode: c++ | | * mode: c++ | |
| | | | |
End of changes. 32 change blocks. |
| 81 lines changed or deleted | | 80 lines changed or added | |
|
| ZrtpCallback.h | | ZrtpCallback.h | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| | | | |
| /** | | /** | |
| * @file ZrtpCallback.h | | * @file ZrtpCallback.h | |
| * @brief Callback interface between ZRTP and the RTP stack implementation | | * @brief Callback interface between ZRTP and the RTP stack implementation | |
| * @ingroup GNU_ZRTP | | * @ingroup GNU_ZRTP | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| #include <string> | | #include <string> | |
| #include <stdint.h> | | #include <stdint.h> | |
|
| | | #include <commoncpp/config.h> | |
| #include <libzrtpcpp/ZrtpCodes.h> | | #include <libzrtpcpp/ZrtpCodes.h> | |
| | | | |
| /** | | /** | |
| * This enum defines which role a ZRTP peer has. | | * This enum defines which role a ZRTP peer has. | |
| * | | * | |
| * According to the ZRTP specification the role determines which keys to | | * According to the ZRTP specification the role determines which keys to | |
| * use to encrypt or decrypt SRTP data. | | * use to encrypt or decrypt SRTP data. | |
| * | | * | |
| * <ul> | | * <ul> | |
| * <li> The Initiator encrypts SRTP data using the <em>keyInitiator</em> an
d the | | * <li> The Initiator encrypts SRTP data using the <em>keyInitiator</em> an
d the | |
| | | | |
| skipping to change at line 54 | | skipping to change at line 55 | |
| * </li> | | * </li> | |
| * </ul> | | * </ul> | |
| */ | | */ | |
| typedef enum { | | typedef enum { | |
| Responder = 1, ///< This client is in ZRTP Responder mode | | Responder = 1, ///< This client is in ZRTP Responder mode | |
| Initiator ///< This client is in ZRTP Initiator mode | | Initiator ///< This client is in ZRTP Initiator mode | |
| } Role; | | } Role; | |
| | | | |
| /// The algorihms that we support in SRTP and that ZRTP can negotiate. | | /// The algorihms that we support in SRTP and that ZRTP can negotiate. | |
| typedef enum { | | typedef enum { | |
|
| | | None, | |
| Aes = 1, ///< Use AES as symmetrical cipher algorithm | | Aes = 1, ///< Use AES as symmetrical cipher algorithm | |
| TwoFish, ///< Use TwoFish as symmetrical cipher algorithm | | TwoFish, ///< Use TwoFish as symmetrical cipher algorithm | |
| Sha1, ///< Use Sha1 as authentication algorithm | | Sha1, ///< Use Sha1 as authentication algorithm | |
| Skein ///< Use Skein as authentication algorithm | | Skein ///< Use Skein as authentication algorithm | |
| } SrtpAlgorithms; | | } SrtpAlgorithms; | |
| | | | |
| /** | | /** | |
| * This structure contains pointers to the SRTP secrets and the role info. | | * This structure contains pointers to the SRTP secrets and the role info. | |
| * | | * | |
| * About the role and what the meaning of the role is refer to the | | * About the role and what the meaning of the role is refer to the | |
| | | | |
| skipping to change at line 105 | | skipping to change at line 107 | |
| * must implement. The generic part of GNU ZRTP uses these mehtods | | * must implement. The generic part of GNU ZRTP uses these mehtods | |
| * to communicate with the specific part, for example to send data | | * to communicate with the specific part, for example to send data | |
| * via the RTP/SRTP stack, to set timers and cancel timer and so on. | | * via the RTP/SRTP stack, to set timers and cancel timer and so on. | |
| * | | * | |
| * The generiy part of GNU ZRTP needs only a few callback methods to | | * The generiy part of GNU ZRTP needs only a few callback methods to | |
| * be implemented by the specific part. | | * be implemented by the specific part. | |
| * | | * | |
| * @author Werner Dittmann <Werner.Dittmann@t-online.de> | | * @author Werner Dittmann <Werner.Dittmann@t-online.de> | |
| */ | | */ | |
| | | | |
|
| class ZrtpCallback { | | class __EXPORT ZrtpCallback { | |
| | | | |
| protected: | | protected: | |
| friend class ZRtp; | | friend class ZRtp; | |
| | | | |
| virtual ~ZrtpCallback() {}; | | virtual ~ZrtpCallback() {}; | |
| | | | |
| /** | | /** | |
| * Send a ZRTP packet via RTP. | | * Send a ZRTP packet via RTP. | |
| * | | * | |
| * ZRTP calls this method to send a ZRTP packet via the RTP session. | | * ZRTP calls this method to send a ZRTP packet via the RTP session. | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| ZrtpConfigure.h | | ZrtpConfigure.h | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include <stdint.h> | | #include <stdint.h> | |
| #include <list> | | #include <list> | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| #include <string.h> | | #include <string.h> | |
| | | | |
|
| | | #include <libzrtpcpp/ZrtpCallback.h> | |
| | | | |
| /** | | /** | |
| * This enumerations list all configurable algorithm types. | | * This enumerations list all configurable algorithm types. | |
| */ | | */ | |
| | | | |
| enum AlgoTypes { | | enum AlgoTypes { | |
| Invalid = 0, HashAlgorithm = 1, CipherAlgorithm, PubKeyAlgorithm, SasTy
pe, AuthLength | | Invalid = 0, HashAlgorithm = 1, CipherAlgorithm, PubKeyAlgorithm, SasTy
pe, AuthLength | |
| }; | | }; | |
| | | | |
|
| | | typedef void(*encrypt_t)(uint8_t*, int32_t, uint8_t*, uint8_t*, int32_t); | |
| | | typedef void(*decrypt_t)(uint8_t*, int32_t, const uint8_t*, uint8_t*, int32 | |
| | | _t); | |
| | | | |
| /** | | /** | |
| * The algorithm enumration class. | | * The algorithm enumration class. | |
| * | | * | |
| * This simple class is just a container of an algorithm's name and | | * This simple class is just a container of an algorithm's name and | |
| * its associated algorithm type. We use this class together with the | | * its associated algorithm type. We use this class together with the | |
| * EnumBase class to implement a Java-like enum class functionality | | * EnumBase class to implement a Java-like enum class functionality | |
| * (not fully, but OK for our use case). | | * (not fully, but OK for our use case). | |
| * | | * | |
| * An application shall use the get / check methods to retrieve information
. | | * An application shall use the get / check methods to retrieve information
. | |
| */ | | */ | |
| | | | |
| skipping to change at line 70 | | skipping to change at line 75 | |
| * Create an AlgorithmEnum object. | | * Create an AlgorithmEnum object. | |
| * | | * | |
| * @param type | | * @param type | |
| * Defines the algorithm type | | * Defines the algorithm type | |
| * @param name | | * @param name | |
| * Set the names of the algorithm. The name is copied | | * Set the names of the algorithm. The name is copied | |
| * and the call may reuse the space. | | * and the call may reuse the space. | |
| * | | * | |
| * @see AlgoTypes | | * @see AlgoTypes | |
| */ | | */ | |
|
| AlgorithmEnum(const AlgoTypes type, const char* name); | | AlgorithmEnum(const AlgoTypes type, const char* name, int32_t klen, | |
| | | const char* ra, encrypt_t en, decrypt_t de, SrtpAlgorithm | |
| | | s alId); | |
| | | | |
| /** | | /** | |
| * AlgorithmEnum destructor | | * AlgorithmEnum destructor | |
| */ | | */ | |
| ~AlgorithmEnum(); | | ~AlgorithmEnum(); | |
| | | | |
| /** | | /** | |
| * Get the algorihm's name | | * Get the algorihm's name | |
| * | | * | |
| * @returns | | * @returns | |
| * Algorithm's name as null terminated C-string. The | | * Algorithm's name as null terminated C-string. The | |
| * application must not free this memory. | | * application must not free this memory. | |
| */ | | */ | |
| const char* getName(); | | const char* getName(); | |
| | | | |
| /** | | /** | |
|
| | | * Get the algorihm's readable name | |
| | | * | |
| | | * @returns | |
| | | * Algorithm's readable name as null terminated C-string. The | |
| | | * application must not free this memory. | |
| | | */ | |
| | | const char* getReadable(); | |
| | | | |
| | | /** | |
| | | * Get the algorihm's key length. | |
| | | * | |
| | | * @returns | |
| | | * An integer definig the key length in bytes. | |
| | | */ | |
| | | int getKeylen(); | |
| | | | |
| | | /** | |
| | | * Get the algorihm's integer id. | |
| | | * | |
| | | * @returns | |
| | | * An integer that defines the algorithm. | |
| | | */ | |
| | | SrtpAlgorithms getAlgoId(); | |
| | | /** | |
| | | * Get the algorihm's key length. | |
| | | * | |
| | | * @returns | |
| | | * An integer definig the key length in bytes. | |
| | | */ | |
| | | encrypt_t getEncrypt(); | |
| | | | |
| | | /** | |
| | | * Get the algorihm's key length. | |
| | | * | |
| | | * @returns | |
| | | * An integer definig the key length in bytes. | |
| | | */ | |
| | | decrypt_t getDecrypt(); | |
| | | | |
| | | /** | |
| * Get the algorithm type of this AlgorithmEnum object. | | * Get the algorithm type of this AlgorithmEnum object. | |
| * | | * | |
| * @returns | | * @returns | |
| * The algorithm type. | | * The algorithm type. | |
| * | | * | |
| * @see AlgoTypes | | * @see AlgoTypes | |
| */ | | */ | |
| AlgoTypes getAlgoType(); | | AlgoTypes getAlgoType(); | |
| | | | |
| /** | | /** | |
| * Check if this AlgorithmEnum object is valid | | * Check if this AlgorithmEnum object is valid | |
| * | | * | |
| * @returns | | * @returns | |
| * @c true if the object is valid, @c false otherwise | | * @c true if the object is valid, @c false otherwise | |
| */ | | */ | |
| bool isValid(); | | bool isValid(); | |
| | | | |
| private: | | private: | |
| AlgoTypes algoType; | | AlgoTypes algoType; | |
| std::string algoName; | | std::string algoName; | |
|
| | | int32_t keyLen; | |
| | | std::string readable; | |
| | | encrypt_t encrypt; | |
| | | decrypt_t decrypt; | |
| | | SrtpAlgorithms algoId; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * EnumBase provides methods to store and access algorithm enumerations of | | * EnumBase provides methods to store and access algorithm enumerations of | |
| * a specific algorithm type. | | * a specific algorithm type. | |
| * | | * | |
| * An application shall use the get / check methods to retrieve information | | * An application shall use the get / check methods to retrieve information | |
| * from the preset Algorithm Enumerations. | | * from the preset Algorithm Enumerations. | |
| * | | * | |
| * @see AlgoTypes | | * @see AlgoTypes | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 238 | |
| * @return | | * @return | |
| * Return the ordinal number of this AlgorithmEnum if found, | | * Return the ordinal number of this AlgorithmEnum if found, | |
| * -1 otherwise. | | * -1 otherwise. | |
| */ | | */ | |
| int getOrdinal(AlgorithmEnum& algo); | | int getOrdinal(AlgorithmEnum& algo); | |
| | | | |
| protected: | | protected: | |
| EnumBase(AlgoTypes algo); | | EnumBase(AlgoTypes algo); | |
| ~EnumBase(); | | ~EnumBase(); | |
| void insert(const char* name); | | void insert(const char* name); | |
|
| | | void insert(const char* name, int32_t klen, | |
| | | const char* ra, encrypt_t en, decrypt_t de, SrtpAlgorithms | |
| | | alId); | |
| | | | |
| private: | | private: | |
| AlgoTypes algoType; | | AlgoTypes algoType; | |
| std::vector <AlgorithmEnum* > algos; | | std::vector <AlgorithmEnum* > algos; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * The enumaration subclasses that contain the supported algorithm enumerat
ions. | | * The enumaration subclasses that contain the supported algorithm enumerat
ions. | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 250 | | skipping to change at line 303 | |
| * restrict or allow use of algorithms. | | * restrict or allow use of algorithms. | |
| * | | * | |
| * The constructor does not set any algorithms, thus it is an empty | | * The constructor does not set any algorithms, thus it is an empty | |
| * configuration. An application may use this empty configuration and | | * configuration. An application may use this empty configuration and | |
| * hand it over to ZRTP. In this case ZRTP does not announce any algorithms | | * hand it over to ZRTP. In this case ZRTP does not announce any algorithms | |
| * in its Hello message and uses mandatory algorithms only. | | * in its Hello message and uses mandatory algorithms only. | |
| * | | * | |
| * An application can configure implemented algorithms only. | | * An application can configure implemented algorithms only. | |
| */ | | */ | |
| | | | |
|
| class ZrtpConfigure { | | class __EXPORT ZrtpConfigure { | |
| public: | | public: | |
|
| ZrtpConfigure(); /* Creates Configuration data */ | | ZrtpConfigure(); /* Creates Configuration data */ | |
| ~ZrtpConfigure(); | | ~ZrtpConfigure(); | |
| | | | |
| /** | | /** | |
| * Set the maximum number of algorithms per algorithm type that an appl
ication can | | * Set the maximum number of algorithms per algorithm type that an appl
ication can | |
| * configure. | | * configure. | |
| */ | | */ | |
| static const int maxNoOfAlgos = 7; | | static const int maxNoOfAlgos = 7; | |
| /** | | /** | |
| * Convenience function that sets a pre-defined standard configuration. | | * Convenience function that sets a pre-defined standard configuration. | |
| * | | * | |
| | | | |
End of changes. 8 change blocks. |
| 3 lines changed or deleted | | 59 lines changed or added | |
|
| ZrtpQueue.h | | ZrtpQueue.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| | | | |
| #ifndef _ZRTPQUEUE_H_ | | #ifndef _ZRTPQUEUE_H_ | |
| #define _ZRTPQUEUE_H_ | | #define _ZRTPQUEUE_H_ | |
| | | | |
| #include <ccrtp/cqueue.h> | | #include <ccrtp/cqueue.h> | |
| #include <ccrtp/rtppkt.h> | | #include <ccrtp/rtppkt.h> | |
| #include <libzrtpcpp/ZrtpCallback.h> | | #include <libzrtpcpp/ZrtpCallback.h> | |
| #include <libzrtpcpp/TimeoutProvider.h> | | #include <libzrtpcpp/TimeoutProvider.h> | |
| #include <libzrtpcpp/ZrtpConfigure.h> | | #include <libzrtpcpp/ZrtpConfigure.h> | |
| | | | |
|
| class ZrtpUserCallback; | | class __EXPORT ZrtpUserCallback; | |
| class ZRtp; | | class __EXPORT ZRtp; | |
| | | | |
|
| #ifdef CCXX_NAMESPACES | | NAMESPACE_COMMONCPP | |
| namespace ost { | | | |
| #endif | | | |
| | | | |
| /** | | /** | |
| * GNU ccRTP extension to support GNU ZRTP. | | * GNU ccRTP extension to support GNU ZRTP. | |
| * | | * | |
| * ZRTP was developed by Phil Zimmermann and provides functions to | | * ZRTP was developed by Phil Zimmermann and provides functions to | |
| * negotiate keys and other necessary data (crypto data) to set-up | | * negotiate keys and other necessary data (crypto data) to set-up | |
| * the Secure RTP (SRTP) crypto context. Refer to Phil's ZRTP | | * the Secure RTP (SRTP) crypto context. Refer to Phil's ZRTP | |
| * specification at his <a href="http://zfoneproject.com/">Zfone | | * specification at his <a href="http://zfoneproject.com/">Zfone | |
| * project</a> site to get more detailed imformation about the | | * project</a> site to get more detailed imformation about the | |
| * capabilities of ZRTP. | | * capabilities of ZRTP. | |
| | | | |
| skipping to change at line 189 | | skipping to change at line 187 | |
| * how to use GNU ZRTP. | | * how to use GNU ZRTP. | |
| * | | * | |
| * Please refer to the GNU ccRTP documentation for a description | | * Please refer to the GNU ccRTP documentation for a description | |
| * of ccRTP methods and functions. This ZrtpQueue documentation | | * of ccRTP methods and functions. This ZrtpQueue documentation | |
| * shows the ZRTP specific extensions and describes overloaded | | * shows the ZRTP specific extensions and describes overloaded | |
| * methods and a possible different behaviour. | | * methods and a possible different behaviour. | |
| * | | * | |
| * @author Werner Dittmann <Werner.Dittmann@t-online.de> | | * @author Werner Dittmann <Werner.Dittmann@t-online.de> | |
| */ | | */ | |
| | | | |
|
| class ZrtpQueue : public AVPQueue, ZrtpCallback { | | class __EXPORT ZrtpQueue : public AVPQueue, ZrtpCallback { | |
| | | | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Initialize the ZrtpQueue. | | * Initialize the ZrtpQueue. | |
| * | | * | |
| * Before an application can use ZRTP it has to initialize the | | * Before an application can use ZRTP it has to initialize the | |
| * ZRTP implementation. This method initializes the timeout | | * ZRTP implementation. This method initializes the timeout | |
| * thread and opens a file that contains ZRTP specific | | * thread and opens a file that contains ZRTP specific | |
| * information such as the applications ZID (ZRTP id) and its | | * information such as the applications ZID (ZRTP id) and its | |
| | | | |
| skipping to change at line 632 | | skipping to change at line 630 | |
| * @param data | | * @param data | |
| * Pointer to a data buffer. This buffer must have a size of | | * Pointer to a data buffer. This buffer must have a size of | |
| * at least 12 bytes (96 bit) (ZRTP Identifier, see chap. 4.9) | | * at least 12 bytes (96 bit) (ZRTP Identifier, see chap. 4.9) | |
| * @return | | * @return | |
| * Number of bytes copied into the data buffer - must be equival
ent | | * Number of bytes copied into the data buffer - must be equival
ent | |
| * to 96 bit, usually 12 bytes. | | * to 96 bit, usually 12 bytes. | |
| */ | | */ | |
| int32 getZid(uint8* data); | | int32 getZid(uint8* data); | |
| | | | |
| protected: | | protected: | |
|
| friend class TimeoutProvider<std::string, ost::ZrtpQueue*>; | | friend class TimeoutProvider<std::string, ost::ZrtpQueue*>; | |
| | | | |
| /** | | /** | |
| * A hook that gets called if the decoding of an incoming SRTP | | * A hook that gets called if the decoding of an incoming SRTP | |
| * was erroneous | | * was erroneous | |
| * | | * | |
| * @param pkt | | * @param pkt | |
| * The SRTP packet with error. | | * The SRTP packet with error. | |
| * @param errorCode | | * @param errorCode | |
| * The error code: -1 - SRTP authentication failure, -2 - repla
y | | * The error code: -1 - SRTP authentication failure, -2 - repla
y | |
| * check failed | | * check failed | |
| | | | |
| skipping to change at line 785 | | skipping to change at line 783 | |
| * along with the fixed header) is created. | | * along with the fixed header) is created. | |
| * | | * | |
| * @param hdrext whole header extension. | | * @param hdrext whole header extension. | |
| * @param hdrextlen size of whole header extension, in octets. | | * @param hdrextlen size of whole header extension, in octets. | |
| **/ | | **/ | |
| OutgoingZRTPPkt(const unsigned char* const hdrext, uint32 hdrextlen
); | | OutgoingZRTPPkt(const unsigned char* const hdrext, uint32 hdrextlen
); | |
| ~OutgoingZRTPPkt() | | ~OutgoingZRTPPkt() | |
| { } | | { } | |
| }; | | }; | |
| | | | |
|
| #ifdef CCXX_NAMESPACES | | END_NAMESPACE | |
| } | | | |
| #endif | | | |
| | | | |
| #endif | | #endif | |
| | | | |
| /** EMACS ** | | /** EMACS ** | |
| * Local variables: | | * Local variables: | |
| * mode: c++ | | * mode: c++ | |
| * c-default-style: ellemtel | | * c-default-style: ellemtel | |
| * c-basic-offset: 4 | | * c-basic-offset: 4 | |
| * End: | | * End: | |
| */ | | */ | |
| | | | |
End of changes. 5 change blocks. |
| 10 lines changed or deleted | | 6 lines changed or added | |
|