2018-05-28 16:03:39 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/pqi: pqissludp.h *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
2019-10-09 08:59:46 -04:00
|
|
|
* Copyright (C) 2004-2006 Robert Fernie <retroshare@lunamutt.com> *
|
|
|
|
* Copyright (C) 2015-2019 Gioacchino Mazzurco <gio@altermundi.net> *
|
2018-05-28 16:03:39 -04:00
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2019-10-09 08:59:46 -04:00
|
|
|
#pragma once
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "pqi/pqissl.h"
|
2019-10-09 08:59:46 -04:00
|
|
|
#include "pqi/pqinetwork.h"
|
|
|
|
#include "util/rsdebug.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
2019-10-09 08:59:46 -04:00
|
|
|
/**
|
|
|
|
* @brief pqissludp is the special NAT traversal protocol.
|
|
|
|
* This class will implement the basics of streaming ssl over udp using a
|
|
|
|
* tcponudp library.
|
|
|
|
* It provides a NetBinInterface, which is primarily inherited from pqissl.
|
|
|
|
* Some methods are override all others are identical.
|
2007-11-14 22:18:48 -05:00
|
|
|
*/
|
|
|
|
class pqissludp: public pqissl
|
|
|
|
{
|
|
|
|
public:
|
2015-10-30 04:23:59 -04:00
|
|
|
pqissludp(PQInterface *parent, p3LinkMgr *lm);
|
2019-10-09 08:59:46 -04:00
|
|
|
~pqissludp() override;
|
2008-01-28 00:40:32 -05:00
|
|
|
|
2019-10-09 08:59:46 -04:00
|
|
|
int listen() override { return 1; }
|
|
|
|
int stoplistening() override { return 1; }
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2015-10-30 04:23:59 -04:00
|
|
|
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
|
|
|
virtual bool connect_additional_address(uint32_t type, const struct sockaddr_storage &addr);
|
2008-02-26 21:32:20 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
// BinInterface.
|
|
|
|
// These are reimplemented.
|
2015-10-30 04:23:59 -04:00
|
|
|
virtual bool moretoread(uint32_t usec);
|
|
|
|
virtual bool cansend(uint32_t usec);
|
2007-11-14 22:18:48 -05:00
|
|
|
/* UDP always through firewalls -> always bandwidth Limited */
|
2015-10-30 04:23:59 -04:00
|
|
|
virtual bool bandwidthLimited() { return true; }
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2013-10-01 06:11:34 -04:00
|
|
|
protected:
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
// pqissludp specific.
|
2008-01-25 01:36:40 -05:00
|
|
|
// called to initiate a connection;
|
2015-10-30 04:23:59 -04:00
|
|
|
int attach();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2015-10-30 04:23:59 -04:00
|
|
|
virtual int reset_locked();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2015-10-30 04:23:59 -04:00
|
|
|
virtual int Initiate_Connection();
|
|
|
|
virtual int Basic_Connection_Complete();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2015-10-30 04:23:59 -04:00
|
|
|
/* Do we really need this ?
|
|
|
|
* It is very specific UDP+ToU+SSL stuff and unlikely to be reused.
|
|
|
|
* In fact we are overloading them here becase they are very do different of pqissl.
|
|
|
|
*/
|
|
|
|
virtual int net_internal_close(int fd);
|
|
|
|
virtual int net_internal_SSL_set_fd(SSL *ssl, int fd);
|
2019-10-09 08:59:46 -04:00
|
|
|
virtual int net_internal_fcntl_nonblock(int /*fd*/) { return 0; }
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
BIO *tou_bio; // specific to ssludp.
|
|
|
|
|
2008-02-26 21:32:20 -05:00
|
|
|
uint32_t mConnectPeriod;
|
2011-07-13 18:23:40 -04:00
|
|
|
uint32_t mConnectFlags;
|
2011-07-14 10:56:33 -04:00
|
|
|
uint32_t mConnectBandwidth;
|
|
|
|
|
2013-09-13 10:35:19 -04:00
|
|
|
struct sockaddr_storage mConnectProxyAddr;
|
|
|
|
struct sockaddr_storage mConnectSrcAddr;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2019-10-09 08:59:46 -04:00
|
|
|
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
|
|
|
};
|