Implemented barebones VL2 SOCK_RAW functionality, moved ZT core helper functions from OneService to libzt

This commit is contained in:
Joseph Henry
2017-08-02 14:39:21 -07:00
parent ecb2dc5178
commit 7e30474ee4
14 changed files with 549 additions and 80 deletions

View File

@@ -37,9 +37,44 @@
/* work on other platforms. Mayber later down the road we will customize */
/* this for each different platform. Maybe. */
/****************************************************************************/
#if !defined(__linux__)
#define SIOCGIFINDEX 101
#define SIOCGIFHWADDR 102
// Normally defined in linux/if_packet.h, defined here so we can offer a linux-like
// raw socket API on non-linux platforms
struct sockaddr_ll {
unsigned short sll_family; /* Always AF_PACKET */
unsigned short sll_protocol; /* Physical layer protocol */
int sll_ifindex; /* Interface number */
unsigned short sll_hatype; /* ARP hardware type */
unsigned char sll_pkttype; /* Packet type */
unsigned char sll_halen; /* Length of address */
unsigned char sll_addr[8]; /* Physical layer address */
};
/*
struct zts_ifreq {
char ifr_name[IFNAMSIZ]; // Interface name
union {
struct sockaddr ifr_addr;
struct sockaddr ifr_dstaddr;
struct sockaddr ifr_broadaddr;
struct sockaddr ifr_netmask;
struct sockaddr ifr_hwaddr;
short ifr_flags;
int ifr_ifindex;
int ifr_metric;
int ifr_mtu;
struct ifmap ifr_map;
char ifr_slave[IFNAMSIZ];
char ifr_newname[IFNAMSIZ];
char *ifr_data;
};
};
*/
#endif
/****************************************************************************/
@@ -437,6 +472,9 @@ namespace ZeroTier
class lwIP;
extern ZeroTier::lwIP *lwipstack;
class SocketTap;
struct InetAddress;
}
/*
@@ -461,6 +499,17 @@ int zts_nsockets();
int zts_maxsockets();
int pico_ntimers();
/****************************************************************************/
/* ZeroTier Core helper functions for libzt - DON'T CALL THESE DIRECTLY */
/****************************************************************************/
ZeroTier::SocketTap *getTapByNWID(uint64_t nwid);
ZeroTier::SocketTap *getTapByAddr(ZeroTier::InetAddress &addr);
ZeroTier::SocketTap *getTapByName(char *ifname);
ZeroTier::SocketTap *getTapByIndex(int index);
void dismantleTaps();
/**
* Don't call this directly, use 'zts_start()'
*/