This file is indexed.

/usr/include/svxlink/EchoLinkProxy.h is in libecholib-dev 14.08.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
/**
@file	 EchoLinkProxy.h
@brief   A class implementing the EchoLink Proxy protocol
@author  Tobias Blomberg / SM0SVX
@date	 2013-04-28

\verbatim
EchoLib - A library for EchoLink communication
Copyright (C) 2003-2013 Tobias Blomberg / SM0SVX

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
\endverbatim
*/

/** @example EchoLinkProxy_demo.cpp
An example of how to use the EchoLinkProxy class
*/


#ifndef ECHOLINK_PROXY_INCLUDED
#define ECHOLINK_PROXY_INCLUDED


/****************************************************************************
 *
 * System Includes
 *
 ****************************************************************************/

#include <string>
#include <sigc++/sigc++.h>


/****************************************************************************
 *
 * Project Includes
 *
 ****************************************************************************/

#include <AsyncTcpClient.h>
#include <AsyncTimer.h>


/****************************************************************************
 *
 * Local Includes
 *
 ****************************************************************************/



/****************************************************************************
 *
 * Forward declarations
 *
 ****************************************************************************/



/****************************************************************************
 *
 * Namespace
 *
 ****************************************************************************/

namespace EchoLink
{


/****************************************************************************
 *
 * Forward declarations of classes inside of the declared namespace
 *
 ****************************************************************************/

  

/****************************************************************************
 *
 * Defines & typedefs
 *
 ****************************************************************************/



/****************************************************************************
 *
 * Exported Global Variables
 *
 ****************************************************************************/



/****************************************************************************
 *
 * Class definitions
 *
 ****************************************************************************/

/**
@brief	Implements the EchoLink Proxy protocol
@author Tobias Blomberg / SM0SVX
@date   2013-04-28

This class implements the EchoLink Proxy protocol. This protocol is used to
wrap all EchoLink protocol connections in one TCP connection. Both the two
UDP connections (port 5198 and 5199) and the TCP connection to the EchoLink
directory server will be wrapped inside the TCP connection to the EchoLink
proxy server. This is of most use when the two UDP ports cannot be forwarded
to your local EchoLink computer for one or the other reason, like when being
on a public network. Instead of your computer listening directly to the two
UDP ports, the EchoLink proxy server will do it for you.

\include EchoLinkProxy_demo.cpp
*/
class Proxy : public sigc::trackable
{
  public:
    typedef enum
    {
      STATE_DISCONNECTED, STATE_WAITING_FOR_DIGEST, STATE_CONNECTED
    } ProxyState;

    typedef enum
    {
      TCP_STATE_DISCONNECTED, TCP_STATE_DISCONNECTING, TCP_STATE_CONNECTING,
      TCP_STATE_CONNECTED
    } TcpState;

    static Proxy *instance(void) { return the_instance; }

    /**
     * @brief 	Default constuctor
     */
    Proxy(const std::string &host, uint16_t port, const std::string &callsign,
          const std::string &password);
  
    /**
     * @brief 	Destructor
     */
    ~Proxy(void);
  
    /**
     * @brief 	Connect to the proxy server
     */
    void connect(void);

    /**
     * @brief   Disconnect from the proxy server
     */
    void disconnect(void);
    
    /**
     * @brief   Disconnect from proxy server then connect again after a delay
     */
    void reset(void);

    /**
     * @brief   Open a TCP connection to port 5200 to the specified host
     * @param   remote_ip The remote IP address to open the TCP connection to
     * @return  Returns \em true on success or else \em false.
     *
     * This function is used to initialize the connection to the EchoLink
     * directory server. It will indicate success if the connection request
     * was successfully sent tot he proxy server. Success does not mean that
     * the connection to the directory server has been established. That is
     * indicated by the emission of the tcpConnected signal. If the connection
     * fail, the tcpDisconnected signal will be emitted instead.
     */
    bool tcpOpen(const Async::IpAddress &remote_ip);

    /**
     * @brief   Close an active TCP connection
     * @return  Return \em true on success or else \em false
     *
     * This function is used to close a previously established TCP connection
     * to an EchoLink directory server. The function will indicate success if
     * the disconnect is successfully sent to the EchoLink proxy server.
     * Success does not mean that the connection has been closed. This is
     * indicated by the emission of the tcpDisconnected signal
     * If no connection is established at the moment, the function will
     * indicate success.
     */
    bool tcpClose(void);

    /**
     * @brief   Read back the current TCP connection state
     * @return  Returns the current TCP connection state (@see TcpState)
     */
    TcpState tcpState(void) { return tcp_state; }

    /**
     * @brief   Send TCP data through an established TCP connection
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     * @return  Returns \em true on success or else \em false
     *
     * Use this function to send data to the EchoLink directory server through
     * an already established connection through the proxy server. Before
     * calling this function, tcpOpen should have been called to open the
     * connection.
     */
    bool tcpData(const void *data, unsigned len);

    /**
     * @brief   Send UDP data to the specified remote IP
     * @param   addr The remote IP address to send to
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     * @return  Returns \em true on success or else \em false
     *
     * Use this function to send UDP frames to the specified remote IP address.
     * The UDP frames should contain data, like audio.
     */
    bool udpData(const Async::IpAddress &addr, const void *data, unsigned len);

    /**
     * @brief   Send UDP control data to the specified remote IP
     * @param   addr The remote IP address to send to
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     * @return  Returns \em true on success or else \em false
     *
     * Use this function to send UDP frames to the specified remote IP address.
     * The UDP frames should contain control data.
     */
    bool udpCtrl(const Async::IpAddress &addr, const void *data, unsigned len);

    /**
     * @brief   A signal that is emitted when the proxy is ready for operation
     * @param   is_ready Set to true if the proxy is ready or false if it's not
     *
     * Beofre calling any communication functions in this class one should wait
     * for this signal to be emitted with a \em true argument. The user of this
     * class should first call the connect method and then wait for this
     * signal.
     */
    sigc::signal<void, bool> proxyReady;

    /**
     * @brief   Signal that is emitted when a TCP connection is established
     *
     * This signal will be emitted when a TCP connection to the EchoLink
     * directory server has been established through the proxy server.
     */
    sigc::signal<void> tcpConnected;

    /**
     * @brief   Signal that is emitted when a TCP connection is closed
     *
     * This signal will be emitted when a TCP connection to the EchoLink
     * directory server has been closed.
     */
    sigc::signal<void> tcpDisconnected;

    /**
     * @brief   Signal emitted when TCP data has been received
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     * @return  Return the number of bytes that was processed
     *
     * This signal will be emitted when TCP data has been received from the
     * EchoLink directory server via the proxy. The receiver of the signal
     * must indicate with the return value how many bytes of the received
     * data was processed. Any unprocessed data will be present in the next
     * emission of this signal. The signal will not be emitted again until
     * more data have been received. This behaviour will make it easy to
     * handle the data stream in suitable chunks.
     */
    sigc::signal<int, void*, unsigned> tcpDataReceived;

    /**
     * @brief   Signal emitted when UDP data has been received
     * @param   addr The remote IP address
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     *
     * This signal will be emitted when UDP data, like audio, have been
     * received through the EchoLink proxy server.
     */
    sigc::signal<void, const Async::IpAddress&, void*,
                 unsigned> udpDataReceived;

    /**
     * @brief   Signal emitted when UDP control data has been received
     * @param   addr The remote IP address
     * @param   data Pointer to a buffer containing the data to send
     * @param   len The size of the data buffer
     *
     * This signal will be emitted when UDP control data have been
     * received through the EchoLink proxy server.
     */
    sigc::signal<void, const Async::IpAddress&, void*,
                 unsigned> udpCtrlReceived;

    /**
     * @brief   Signal emitted when the TCP_STATUS proxy message is received
     * @param   status The status word
     *
     * This signal will be emitted when a TCP_STATUS message has been
     * received from the EchoLink proxy server. The user of this class should
     * not need to use this raw protocol message signal since it's easier to
     * use the tcpConnected signal.
     * A status word set to zero will indicate a successful connection. A
     * non zero status word does not mean anything special other than that the
     * connection failed.
     */
    sigc::signal<void, uint32_t> tcpStatusReceived;

    /**
     * @brief   Signal emitted when the TCP_CLOSE proxy message is received
     *
     * This signal will be emitted when a TCP_CLOSE proxy protocol message
     * is received. This signal should normally not be used since it's better
     * to use the tcpDisconnected signal.
     */
    sigc::signal<void> tcpCloseReceived;

  protected:
    
  private:
    typedef enum
    {
      MSG_TYPE_TCP_OPEN=1, MSG_TYPE_TCP_DATA, MSG_TYPE_TCP_CLOSE,
      MSG_TYPE_TCP_STATUS, MSG_TYPE_UDP_DATA, MSG_TYPE_UDP_CONTROL,
      MSG_TYPE_SYSTEM
    } MsgBlockType;

    static const int NONCE_SIZE         = 8;
    static const int MSG_HEADER_SIZE    = 1 + 4 + 4;
    static const int RECONNECT_INTERVAL = 10000;
    static const int CMD_TIMEOUT        = 10000;
    static const int recv_buf_size      = 16384;

    static Proxy *the_instance;

    Async::TcpClient  con;
    const std::string callsign;
    std::string       password;
    ProxyState        state;
    TcpState          tcp_state;
    uint8_t           recv_buf[recv_buf_size];
    int               recv_buf_cnt;
    Async::Timer      reconnect_timer;
    Async::Timer      cmd_timer;

    Proxy(const Proxy&);
    Proxy& operator=(const Proxy&);
    bool sendMsgBlock(MsgBlockType type,
                      const Async::IpAddress &remote_ip=Async::IpAddress(),
                      const void *data=0, unsigned len=0);
    void onConnected(void);
    int onDataReceived(Async::TcpConnection *con, void *data, int len);
    void onDisconnected(Async::TcpConnection *con,
        Async::TcpClient::DisconnectReason reason);
    void disconnectHandler(void);
    int handleAuthentication(const unsigned char *buf, int len);
    int parseProxyMessageBlock(unsigned char *buf, int len);
    void handleProxyMessageBlock(MsgBlockType type,
        const Async::IpAddress &remote_ip, uint32_t len,
        unsigned char *data);
    void handleTcpDataMsg(uint8_t *buf, int len);
    void handleTcpCloseMsg(const uint8_t *buf, int len);
    void handleTcpStatusMsg(const uint8_t *buf, int len);
    void handleUdpDataMsg(const Async::IpAddress &remote_ip, uint8_t *buf,
                          int len);
    void handleUdpCtrlMsg(const Async::IpAddress &remote_ip, uint8_t *buf,
                          int len);
    void handleSystemMsg(const unsigned char *buf, int len);
    void cmdTimeout(void);
    
};  /* class Proxy */


} /* namespace */

#endif /* ECHOLINK_PROXY_INCLUDED */



/*
 * This file has not been truncated
 */