Applied styling rules from .clang-format

This commit is contained in:
Joseph Henry
2021-04-17 23:46:21 -07:00
parent 8e7bcdb16a
commit a5121b1e3c
22 changed files with 3215 additions and 2231 deletions

View File

@@ -39,21 +39,28 @@ struct InetAddress;
* A virtual tap device. The ZeroTier Node Service will create one per
* joined network. It will be destroyed upon leave().
*/
class VirtualTap
{
friend class Phy<VirtualTap *>;
class VirtualTap {
friend class Phy<VirtualTap*>;
public:
public:
VirtualTap(
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* 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);
~VirtualTap();
@@ -63,7 +70,7 @@ public:
/**
* Mutex for protecting IP address container for this tap.
*/
Mutex _ips_m; // Public because we want it accessible by the driver layer
Mutex _ips_m; // Public because we want it accessible by the driver layer
/**
* Return whether this tap has been assigned an IPv4 address.
@@ -79,18 +86,18 @@ public:
* Adds an address to the user-space stack interface associated with this VirtualTap
* - Starts VirtualTap main thread ONLY if successful
*/
bool addIp(const InetAddress &ip);
bool addIp(const InetAddress& ip);
/**
* Removes an address from the user-space stack interface associated with this VirtualTap
*/
bool removeIp(const InetAddress &ip);
bool removeIp(const InetAddress& ip);
/**
* Presents data to the user-space stack
*/
void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,
unsigned int len);
void
put(const MAC& from, const MAC& to, unsigned int etherType, const void* data, unsigned int len);
/**
* Get VirtualTap device name (e.g. 'libzt17d72843bc2c5760')
@@ -100,13 +107,13 @@ public:
/**
* Set friendly name
*/
void setFriendlyName(const char *friendlyName);
void setFriendlyName(const char* friendlyName);
/**
* Scan multicast groups
*/
void scanMulticastGroups(std::vector<MulticastGroup> &added,
std::vector<MulticastGroup> &removed);
void
scanMulticastGroups(std::vector<MulticastGroup>& added, std::vector<MulticastGroup>& removed);
/**
* Set MTU
@@ -116,17 +123,24 @@ public:
/**
* Calls main network stack loops
*/
void threadMain()
throw();
void threadMain() throw();
/**
* For moving data onto the ZeroTier virtual wire
*/
void (*_handler)(void *, void *, uint64_t, const MAC &, const MAC &, unsigned int, unsigned int,
const void *, unsigned int);
void (*_handler)(
void*,
void*,
uint64_t,
const MAC&,
const MAC&,
unsigned int,
unsigned int,
const void*,
unsigned int);
void *netif4 = NULL;
void *netif6 = NULL;
void* netif4 = NULL;
void* netif6 = NULL;
/**
* The last time that this virtual tap received a network config update from the core
@@ -143,21 +157,21 @@ public:
std::vector<InetAddress> _ips;
std::string _homePath;
void *_arg;
void* _arg;
volatile bool _initialized;
volatile bool _enabled;
volatile bool _run;
MAC _mac;
unsigned int _mtu;
uint64_t _nwid;
PhySocket *_unixListenSocket;
Phy<VirtualTap *> _phy;
PhySocket* _unixListenSocket;
Phy<VirtualTap*> _phy;
Thread _thread;
int _shutdownSignalPipe[2];
std::string _dev; // path to Unix domain socket
std::string _dev; // path to Unix domain socket
std::vector<MulticastGroup> _multicastGroups;
Mutex _multicastGroups_m;
@@ -166,15 +180,24 @@ public:
// Not used in this implementation //
//////////////////////////////////////////////////////////////////////////////
void phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *local_address,
const struct sockaddr *from,void *data,unsigned long len);
void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success);
void phyOnTcpAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN,
const struct sockaddr *from);
void phyOnTcpClose(PhySocket *sock,void **uptr);
void phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len);
void phyOnTcpWritable(PhySocket *sock,void **uptr);
void phyOnUnixClose(PhySocket *sock,void **uptr);
void phyOnDatagram(
PhySocket* sock,
void** uptr,
const struct sockaddr* local_address,
const struct sockaddr* from,
void* data,
unsigned long len);
void phyOnTcpConnect(PhySocket* sock, void** uptr, bool success);
void phyOnTcpAccept(
PhySocket* sockL,
PhySocket* sockN,
void** uptrL,
void** uptrN,
const struct sockaddr* from);
void phyOnTcpClose(PhySocket* sock, void** uptr);
void phyOnTcpData(PhySocket* sock, void** uptr, void* data, unsigned long len);
void phyOnTcpWritable(PhySocket* sock, void** uptr);
void phyOnUnixClose(PhySocket* sock, void** uptr);
};
/**
@@ -182,7 +205,7 @@ public:
*
* @usage This is a convenience function to encapsulate a macro
*/
bool _lwip_is_netif_up(void *netif);
bool _lwip_is_netif_up(void* netif);
/**
* @brief Increase the delay multiplier for the main driver loop
@@ -206,28 +229,29 @@ bool _lwip_is_up();
/**
* @brief Initialize network stack semaphores, threads, and timers.
*
* @usage This is called during the initial setup of each VirtualTap but is only allowed to execute once
* @usage This is called during the initial setup of each VirtualTap but is only allowed to execute
* once
*/
void _lwip_driver_init();
/**
* @brief Shutdown the stack as completely as possible (not officially supported by lwIP)
*
* @usage This is to be called after it is determined that no further network activity will take place.
* The tcpip thread will be stopped, all interfaces will be brought down and all resources will
* be deallocated. A full application restart will be required to bring the stack back online.
* @usage This is to be called after it is determined that no further network activity will take
* place. The tcpip thread will be stopped, all interfaces will be brought down and all resources
* will be deallocated. A full application restart will be required to bring the stack back online.
*/
void _lwip_driver_shutdown();
/**
* @brief Requests that a netif be brought down and removed.
*/
void _lwip_remove_netif(void *netif);
void _lwip_remove_netif(void* netif);
/**
* @brief Starts DHCP timers
*/
void _lwip_start_dhcp(void *netif);
void _lwip_start_dhcp(void* netif);
/**
* @brief Called when the status of a netif changes:
@@ -235,21 +259,22 @@ void _lwip_start_dhcp(void *netif);
* - Address changes while up (ZTS_EVENT_NETIF_NEW_ADDRESS)
*/
#if LWIP_NETIF_STATUS_CALLBACK
static void _netif_status_callback(struct netif *netif);
static void _netif_status_callback(struct netif* netif);
#endif
/**
* @brief Called when a netif is removed (ZTS_EVENT_NETIF_INTERFACE_REMOVED)
*/
#if LWIP_NETIF_REMOVE_CALLBACK
static void _netif_remove_callback(struct netif *netif);
static void _netif_remove_callback(struct netif* netif);
#endif
/**
* @brief Called when a link is brought up or down (ZTS_EVENT_NETIF_LINK_UP, ZTS_EVENT_NETIF_LINK_DOWN)
* @brief Called when a link is brought up or down (ZTS_EVENT_NETIF_LINK_UP,
* ZTS_EVENT_NETIF_LINK_DOWN)
*/
#if LWIP_NETIF_LINK_CALLBACK
static void _netif_link_callback(struct netif *netif);
static void _netif_link_callback(struct netif* netif);
#endif
/**
@@ -258,7 +283,7 @@ static void _netif_link_callback(struct netif *netif);
* @param tapref Reference to VirtualTap that will be responsible for sending and receiving data
* @param ip Virtual IP address for this ZeroTier VirtualTap interface
*/
void _lwip_init_interface(void *tapref, const InetAddress &ip);
void _lwip_init_interface(void* tapref, const InetAddress& ip);
/**
* @brief Remove an assigned address from an lwIP netif
@@ -266,17 +291,19 @@ void _lwip_init_interface(void *tapref, const InetAddress &ip);
* @param tapref Reference to VirtualTap
* @param ip Virtual IP address to remove from this interface
*/
void _lwip_remove_address_from_netif(void *tapref, const InetAddress &ip);
void _lwip_remove_address_from_netif(void* tapref, const InetAddress& ip);
/**
* @brief Called from the stack, outbound ethernet frames from the network stack enter the ZeroTier virtual wire here.
* @brief Called from the stack, outbound ethernet frames from the network stack enter the ZeroTier
* virtual wire here.
*
* @usage This shall only be called from the stack or the stack driver. Not the application thread.
* @param netif Transmits an outgoing Ethernet fram from the network stack onto the ZeroTier virtual wire
* @param netif Transmits an outgoing Ethernet fram from the network stack onto the ZeroTier virtual
* wire
* @param p A pointer to the beginning of a chain pf struct pbufs
* @return
*/
err_t _lwip_eth_tx(struct netif *netif, struct pbuf *p);
err_t _lwip_eth_tx(struct netif* netif, struct pbuf* p);
/**
* @brief Receives incoming Ethernet frames from the ZeroTier virtual wire
@@ -289,10 +316,14 @@ err_t _lwip_eth_tx(struct netif *netif, struct pbuf *p);
* @param data Pointer to Ethernet frame
* @param len Length of Ethernet frame
*/
void _lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int etherType,
const void *data, unsigned int len);
void _lwip_eth_rx(
VirtualTap* tap,
const MAC& from,
const MAC& to,
unsigned int etherType,
const void* data,
unsigned int len);
} // namespace ZeroTier
#endif // _H
} // namespace ZeroTier
#endif // _H