diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 11:59:50 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 11:59:50 -0700 |
commit | 67aa23530b7e051709002b521aa6e93cb6350918 (patch) | |
tree | 35d9c8dbd1125279596949479b6e915908c3b358 /testnet/TestEthernetTap.hpp | |
parent | 2a58c3fb98c3ff06cf7f5255a13ba4d128f3ce49 (diff) | |
download | infinitytier-67aa23530b7e051709002b521aa6e93cb6350918.tar.gz infinitytier-67aa23530b7e051709002b521aa6e93cb6350918.zip |
More work on adding testnet and user-mode capabilities for local network simulation.
Diffstat (limited to 'testnet/TestEthernetTap.hpp')
-rw-r--r-- | testnet/TestEthernetTap.hpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/testnet/TestEthernetTap.hpp b/testnet/TestEthernetTap.hpp index c1e9c720..93eb4c5b 100644 --- a/testnet/TestEthernetTap.hpp +++ b/testnet/TestEthernetTap.hpp @@ -36,15 +36,13 @@ #include <queue> #include <string> +#include "../node/Constants.hpp" +#include "../node/EthernetTap.hpp" #include "../node/AtomicCounter.hpp" #include "../node/SharedPtr.hpp" -#include "../node/EthernetTap.hpp" #include "../node/Thread.hpp" #include "../node/Mutex.hpp" -#include "Condition.hpp" - -// Ethernet frame type to use on fake testnet -#define ZT_TEST_ETHERNET_ETHERTYPE 0xdead +#include "../node/Condition.hpp" namespace ZeroTier { @@ -57,16 +55,18 @@ class TestEthernetTap : public EthernetTap private: struct TestFrame { - TestFrame() : len(0) {} - TestFrame(const MAC &f,const MAC &t,const void *d,unsigned int l) : + TestFrame() : etherType(0),len(0) {} + TestFrame(const MAC &f,const MAC &t,const void *d,unsigned int et,unsigned int l) : from(f), to(t), + etherType(et), len(l) { memcpy(data,d,l); } MAC from; MAC to; + unsigned int etherType; unsigned int len; char data[4096]; }; @@ -94,21 +94,11 @@ public: virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups); + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); void threadMain() throw(); - inline void sendFromHost(const MAC &from,const MAC &to,const void *data,unsigned int len) - { - if (!len) - return; - { - Mutex::Lock _l(_pq_m); - _pq.push(TestFrame(from,to,data,len)); - } - _pq_c.signal(); - } - private: TestEthernetTapFactory *_parent; |