blob: 098ec062b025687bf6073b6fdfa64f985a23f6ec [file] [log] [blame]
Alexandre Lision51140e12013-12-02 10:54:09 -05001/*
2 This class maps the ZRTP C++ callback methods to C callback methods.
Alexandre Lision907ed2e2014-02-04 10:33:09 -05003 Copyright (C) 2010-2013 Werner Dittmann
Alexandre Lision51140e12013-12-02 10:54:09 -05004
5 This program is free software: you can redistribute it and/or modify
Alexandre Lision907ed2e2014-02-04 10:33:09 -05006 it under the terms of the GNU Lesser General Public License as published by
Alexandre Lision51140e12013-12-02 10:54:09 -05007 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#ifndef ZRTPCALLBACKWRAPPER_H
21#define ZRTPCALLBACKWRAPPER_H
22
23#include <stdlib.h>
24
25#include <libzrtpcpp/ZrtpCallback.h>
26#include <libzrtpcpp/ZrtpConfigure.h>
27#include <libzrtpcpp/ZrtpCWrapper.h>
28
29/**
30 *
31 * @file ZrtpCallbackWrapper.h
32 * @brief C-Wrapper helper
33 *
34 * This is a helper class for for the C wrapper and implements
35 * the GNU ZRTP callback interface. For detailed documentation about
36 * the callback method refer to file <code>ZrtpCallback</code>
37 * @ingroup GNU_ZRTP
38 * @{
39 *
40 * @see ZrtpCallback
41 * @see ZrtpCWrapper
42 */
43class __EXPORT ZrtpCallbackWrapper : public ZrtpCallback
44{
45public:
46 /**
47 * Construct a class that implements ZrtpCallback and uses a C structure
48 * to call C functions that implement the callbacks.
49 *
50 * @param cb
51 * The C callback structure that hold the addresses of the C methods
52 * that implement the actual callback functions.
53 * @param ctx
54 * Pointer to the ZrtpContext
55 */
56 ZrtpCallbackWrapper(zrtp_Callbacks* cb, ZrtpContext* ctx);
57
58 int32_t sendDataZRTP ( const unsigned char* data, int32_t length );
59
60 int32_t activateTimer ( int32_t time );
61
62 int32_t cancelTimer();
63
64 void sendInfo ( GnuZrtpCodes::MessageSeverity severity, int32_t subCode );
65
66 bool srtpSecretsReady ( SrtpSecret_t* secrets, EnableSecurity part );
67
68 void srtpSecretsOff ( EnableSecurity part );
69
70 void srtpSecretsOn ( std::string c, std::string s, bool verified );
71
72 void handleGoClear();
73
74 void zrtpNegotiationFailed ( GnuZrtpCodes::MessageSeverity severity, int32_t subCode );
75
76 void zrtpNotSuppOther();
77
78 void synchEnter();
79
80 void synchLeave();
81
82 void zrtpAskEnrollment (GnuZrtpCodes::InfoEnrollment info );
83
84 void zrtpInformEnrollment (GnuZrtpCodes::InfoEnrollment info );
85
86 void signSAS (uint8_t* sasHash );
87
88 bool checkSASSignature (uint8_t* sasHash );
89
90private:
91 void init();
92 zrtp_Callbacks *c_callbacks;
93 ZrtpContext* zrtpCtx;
94
95};
96
97/**
98 * @}
99 */
100
101#endif // ZRTPCALLBACKWRAPPER_H