mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 13:24:09 -07:00
Style match
This commit is contained in:
parent
cd191778c2
commit
269c8d415a
2 changed files with 437 additions and 328 deletions
|
@ -1,3 +1,16 @@
|
|||
/*
|
||||
* Copyright (c)2019 ZeroTier, Inc.
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file in the project's root directory.
|
||||
*
|
||||
* Change Date: 2026-01-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2.0 of the Apache License.
|
||||
*/
|
||||
/****/
|
||||
|
||||
#ifndef ZT_EXTOSDEP_HPP
|
||||
#define ZT_EXTOSDEP_HPP
|
||||
|
||||
|
@ -5,25 +18,25 @@
|
|||
|
||||
#define ZT_EOD_MAXMSGSIZE (64 * 1024)
|
||||
|
||||
#define ZT_EOD_MSG_STARTED 1 // no data
|
||||
#define ZT_EOD_MSG_ADDTAP 2
|
||||
#define ZT_EOD_MSG_ADDTAPRESP 3
|
||||
#define ZT_EOD_MSG_DELTAP 4
|
||||
#define ZT_EOD_MSG_DELTAPRESP 5 // no data
|
||||
#define ZT_EOD_MSG_SETMTU 6
|
||||
#define ZT_EOD_MSG_SETMTURESP 7
|
||||
#define ZT_EOD_MSG_ADDIP 8
|
||||
#define ZT_EOD_MSG_ADDIPRESP 9
|
||||
#define ZT_EOD_MSG_DELIP 10
|
||||
#define ZT_EOD_MSG_DELIPRESP 11
|
||||
#define ZT_EOD_MSG_GETIPS 12
|
||||
#define ZT_EOD_MSG_GETIPSRESP 13
|
||||
#define ZT_EOD_MSG_GETBINDADDRS 14
|
||||
#define ZT_EOD_MSG_STARTED 1 // no data
|
||||
#define ZT_EOD_MSG_ADDTAP 2
|
||||
#define ZT_EOD_MSG_ADDTAPRESP 3
|
||||
#define ZT_EOD_MSG_DELTAP 4
|
||||
#define ZT_EOD_MSG_DELTAPRESP 5 // no data
|
||||
#define ZT_EOD_MSG_SETMTU 6
|
||||
#define ZT_EOD_MSG_SETMTURESP 7
|
||||
#define ZT_EOD_MSG_ADDIP 8
|
||||
#define ZT_EOD_MSG_ADDIPRESP 9
|
||||
#define ZT_EOD_MSG_DELIP 10
|
||||
#define ZT_EOD_MSG_DELIPRESP 11
|
||||
#define ZT_EOD_MSG_GETIPS 12
|
||||
#define ZT_EOD_MSG_GETIPSRESP 13
|
||||
#define ZT_EOD_MSG_GETBINDADDRS 14
|
||||
#define ZT_EOD_MSG_GETBINDADDRSRESP 15
|
||||
#define ZT_EOD_MSG_ADDROUTE 16
|
||||
#define ZT_EOD_MSG_ADDROUTERESP 17
|
||||
#define ZT_EOD_MSG_DELROUTE 18
|
||||
#define ZT_EOD_MSG_DELROUTERESP 19
|
||||
#define ZT_EOD_MSG_ADDROUTE 16
|
||||
#define ZT_EOD_MSG_ADDROUTERESP 17
|
||||
#define ZT_EOD_MSG_DELROUTE 18
|
||||
#define ZT_EOD_MSG_DELROUTERESP 19
|
||||
|
||||
struct zt_eod_msg_addtap {
|
||||
unsigned char cmd;
|
||||
|
@ -53,8 +66,8 @@ struct zt_eod_msg_setmtu {
|
|||
struct zt_eod_msg_ip {
|
||||
unsigned char cmd;
|
||||
char name[16];
|
||||
unsigned char afi; // 1 ip, 2 ip6
|
||||
unsigned char len; // bits in mask
|
||||
unsigned char afi; // 1 ip, 2 ip6
|
||||
unsigned char len; // bits in mask
|
||||
unsigned char data[16];
|
||||
} __attribute__((packed));
|
||||
|
||||
|
@ -87,7 +100,7 @@ struct zt_eod_msg_getbindaddrsresp {
|
|||
|
||||
struct zt_eod_msg_route {
|
||||
unsigned char cmd;
|
||||
unsigned char afi; // 1 ip, 2 ip6
|
||||
unsigned char afi; // 1 ip, 2 ip6
|
||||
unsigned char dstlen;
|
||||
unsigned char dst[16];
|
||||
unsigned char gw[16];
|
||||
|
@ -110,89 +123,91 @@ struct zt_eod_mgmt_reply {
|
|||
|
||||
#ifndef ZT_EXTOSDEP_IFACEONLY
|
||||
|
||||
#include "../node/AtomicCounter.hpp"
|
||||
#include "../node/Hashtable.hpp"
|
||||
#include "../node/InetAddress.hpp"
|
||||
#include "../node/MAC.hpp"
|
||||
#include "Thread.hpp"
|
||||
#include "../node/Hashtable.hpp"
|
||||
#include "../node/Mutex.hpp"
|
||||
#include "../node/AtomicCounter.hpp"
|
||||
#include "EthernetTap.hpp"
|
||||
#include "BlockingQueue.hpp"
|
||||
#include "EthernetTap.hpp"
|
||||
#include "Thread.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class ExtOsdep {
|
||||
public:
|
||||
public:
|
||||
static void init(int, int);
|
||||
static void started(int *, void **);
|
||||
static void started(int*, void**);
|
||||
|
||||
static void routeAddDel(bool, const InetAddress &target, const InetAddress &via, const InetAddress &src, const char *ifaceName);
|
||||
static bool getBindAddrs(std::map<InetAddress,std::string> &);
|
||||
static void routeAddDel(bool, const InetAddress& target, const InetAddress& via, const InetAddress& src, const char* ifaceName);
|
||||
static bool getBindAddrs(std::map<InetAddress, std::string>&);
|
||||
|
||||
static bool mgmtRecv(void *cookie, void *data, unsigned long len,
|
||||
std::function<unsigned (unsigned, const std::string &, const std::string &, std::string &)>);
|
||||
static bool mgmtWritable(void *);
|
||||
static bool mgmtRecv(void* cookie, void* data, unsigned long len, std::function<unsigned(unsigned, const std::string&, const std::string&, std::string&)>);
|
||||
static bool mgmtWritable(void*);
|
||||
};
|
||||
|
||||
class ExtOsdepTap : public EthernetTap
|
||||
{
|
||||
public:
|
||||
class ExtOsdepTap : public EthernetTap {
|
||||
public:
|
||||
ExtOsdepTap(
|
||||
const char *homePath,
|
||||
const MAC &mac,
|
||||
const char* homePath,
|
||||
const MAC& mac,
|
||||
unsigned int mtu,
|
||||
unsigned int metric,
|
||||
uint64_t nwid,
|
||||
const char *friendlyName,
|
||||
void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
|
||||
void *arg);
|
||||
const char* friendlyName,
|
||||
void (*handler)(void*, void*, uint64_t, const MAC&, const MAC&, unsigned int, unsigned int, const void*, unsigned int),
|
||||
void* arg);
|
||||
|
||||
virtual ~ExtOsdepTap();
|
||||
|
||||
virtual void setEnabled(bool en);
|
||||
virtual bool enabled() const;
|
||||
virtual bool addIp(const InetAddress &ip);
|
||||
virtual bool addIp(const InetAddress& ip);
|
||||
virtual bool addIps(std::vector<InetAddress> ips);
|
||||
virtual bool removeIp(const InetAddress &ip);
|
||||
virtual bool removeIp(const InetAddress& ip);
|
||||
virtual std::vector<InetAddress> ips() const;
|
||||
virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
|
||||
virtual void put(const MAC& from, const MAC& to, unsigned int etherType, const void* data, unsigned int len);
|
||||
virtual std::string deviceName() const;
|
||||
virtual void setFriendlyName(const char *friendlyName);
|
||||
virtual void scanMulticastGroups(std::vector<MulticastGroup> &added,std::vector<MulticastGroup> &removed);
|
||||
virtual void setFriendlyName(const char* friendlyName);
|
||||
virtual void scanMulticastGroups(std::vector<MulticastGroup>& added, std::vector<MulticastGroup>& removed);
|
||||
virtual void setMtu(unsigned int mtu);
|
||||
virtual void setDns(const char *domain, const std::vector<InetAddress> &servers) {}
|
||||
private:
|
||||
void (*_handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int);
|
||||
void *_arg;
|
||||
uint64_t _nwid;
|
||||
MAC _mac;
|
||||
std::string _homePath;
|
||||
std::string _dev;
|
||||
std::vector<MulticastGroup> _multicastGroups;
|
||||
unsigned int _mtu;
|
||||
virtual void setDns(const char* domain, const std::vector<InetAddress>& servers)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void (*_handler)(void*, void*, uint64_t, const MAC&, const MAC&, unsigned int, unsigned int, const void*, unsigned int);
|
||||
void* _arg;
|
||||
uint64_t _nwid;
|
||||
MAC _mac;
|
||||
std::string _homePath;
|
||||
std::string _dev;
|
||||
std::vector<MulticastGroup> _multicastGroups;
|
||||
unsigned int _mtu;
|
||||
int _fd;
|
||||
int _shutdownSignalPipe[2];
|
||||
std::atomic_bool _enabled;
|
||||
std::atomic_bool _run;
|
||||
std::thread _tapReaderThread[2];
|
||||
std::thread _tapProcessorThread;
|
||||
std::mutex _buffers_l;
|
||||
std::vector<void *> _buffers;
|
||||
BlockingQueue< std::pair<void *,int> > _tapq;
|
||||
int _shutdownSignalPipe[2];
|
||||
std::atomic_bool _enabled;
|
||||
std::atomic_bool _run;
|
||||
std::thread _tapReaderThread[2];
|
||||
std::thread _tapProcessorThread;
|
||||
std::mutex _buffers_l;
|
||||
std::vector<void*> _buffers;
|
||||
BlockingQueue<std::pair<void*, int> > _tapq;
|
||||
AtomicCounter _tapqsize;
|
||||
|
||||
std::vector<InetAddress> allIps;
|
||||
void doRemoveIp(const InetAddress &);
|
||||
void doRemoveIp(const InetAddress&);
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif // ZT_EXTOSDEP_IFACEONLY
|
||||
#endif // ZT_EXTOSDEP
|
||||
#endif // ZT_EXTOSDEP_IFACEONLY
|
||||
#endif // ZT_EXTOSDEP
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue