Commit of a draft of the pcap-based strategy for a Windows tap. This may, in the end, not work, since winpcap may not support immediate capture and also because some software flags winpcap as malware. Like I said, trying to do anything interesting with Windows is PAIN.
This commit is contained in:
parent
d19516b40a
commit
c8213a3f58
4 changed files with 228 additions and 17 deletions
|
@ -30,12 +30,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "InetAddress.hpp"
|
||||
#include "MAC.hpp"
|
||||
|
@ -43,16 +46,30 @@
|
|||
#include "MulticastGroup.hpp"
|
||||
#include "Thread.hpp"
|
||||
#include "Buffer.hpp"
|
||||
#include "Array.hpp"
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <pcap/pcap.h>
|
||||
#include <pcap/bpf.h>
|
||||
#include <Win32-Extensions.h>
|
||||
#endif
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class RuntimeEnvironment;
|
||||
#ifdef __WINDOWS__
|
||||
class _WinEthernetTapPcapIOThread;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* System ethernet tap device
|
||||
*/
|
||||
class EthernetTap
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
friend class _WinEthernetTapPcapIOThread;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new TAP device
|
||||
|
@ -172,18 +189,19 @@ public:
|
|||
*/
|
||||
bool updateMulticastGroups(std::set<MulticastGroup> &groups);
|
||||
|
||||
#ifdef __UNIX_LIKE__
|
||||
/**
|
||||
* Thread main method; do not call elsewhere
|
||||
*/
|
||||
void threadMain()
|
||||
throw();
|
||||
#endif
|
||||
|
||||
private:
|
||||
const MAC _mac;
|
||||
const unsigned int _mtu;
|
||||
|
||||
const RuntimeEnvironment *_r;
|
||||
Thread _thread;
|
||||
|
||||
std::set<InetAddress> _ips;
|
||||
Mutex _ips_m;
|
||||
|
@ -192,10 +210,19 @@ private:
|
|||
void *_arg;
|
||||
|
||||
#ifdef __UNIX_LIKE__
|
||||
Thread _thread;
|
||||
char _dev[16];
|
||||
int _fd;
|
||||
int _shutdownSignalPipe[2];
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
pcap_t *_pcap;
|
||||
std::string _myDeviceInstanceId;
|
||||
std::queue< std::pair< Array<char,ZT_IF_MTU + 32>,unsigned int > > _injectPending;
|
||||
Mutex _injectPending_m;
|
||||
static void _pcapHandler(u_char *user,const struct pcap_pkthdr *pkt_header,const u_char *pkt_data);
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue