From 4c59497b95e2fbd56a79f880251b960c1c801d0c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko <adam.ierymenko@gmail.com> Date: Wed, 29 Oct 2014 16:32:24 -0700 Subject: [PATCH] Linux build fixes for testnet. --- make-linux.mk | 13 +++++++++---- testnet.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/make-linux.mk b/make-linux.mk index 46520b9c3..60b0b9c3a 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -6,6 +6,10 @@ INCLUDES= DEFS= LIBS= +include objects.mk +OBJS+=osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o +TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o + # Enable SSE-optimized Salsa20 on x86 and x86_64 machines MACHINE=$(shell uname -m) ifeq ($(MACHINE),x86_64) @@ -58,9 +62,6 @@ endif CXXFLAGS=$(CFLAGS) -fno-rtti -include objects.mk -OBJS+=osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o - all: one one: $(OBJS) main.o @@ -73,11 +74,15 @@ selftest: $(OBJS) selftest.o $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS) $(STRIP) zerotier-selftest +testnet: $(TESTNET_OBJS) $(OBJS) testnet.o + $(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS) + $(STRIP) zerotier-testnet + installer: one FORCE ./buildinstaller.sh clean: - rm -rf $(OBJS) node/*.o osnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-* + rm -rf $(OBJS) $(TESTNET_OBJS) node/*.o osnet/*.o control/*.o testnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-* debug: FORCE make -j 4 ZT_DEBUG=1 diff --git a/testnet.cpp b/testnet.cpp index 374915bfd..465c9909a 100644 --- a/testnet.cpp +++ b/testnet.cpp @@ -321,7 +321,7 @@ static void doJoin(const std::vector<std::string> &cmd) std::map< Address,SimNode * >::iterator n(nodes.find(*a)); if (n != nodes.end()) { n->second->node.join(nwid); - printf("%s join %.16llx"ZT_EOL_S,n->first.toString().c_str(),nwid); + printf("%s join %.16llx"ZT_EOL_S,n->first.toString().c_str(),(unsigned long long)nwid); } } } @@ -348,7 +348,7 @@ static void doLeave(const std::vector<std::string> &cmd) std::map< Address,SimNode * >::iterator n(nodes.find(*a)); if (n != nodes.end()) { n->second->node.leave(nwid); - printf("%s leave %.16llx"ZT_EOL_S,n->first.toString().c_str(),nwid); + printf("%s leave %.16llx"ZT_EOL_S,n->first.toString().c_str(),(unsigned long long)nwid); } } } @@ -537,14 +537,14 @@ static void doUnicast(const std::vector<std::string> &cmd) pkt.i[0] = s->toInt(); pkt.i[1] = Utils::now(); stap->injectPacketFromHost(stap->mac(),rtap->mac(),0xdead,pkt.data,frameLen); - printf("%s -> %s etherType 0xdead network %.16llx length %u"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid,frameLen); + printf("%s -> %s etherType 0xdead network %.16llx length %u"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),(unsigned long long)nwid,frameLen); sentPairs.insert(std::pair<Address,Address>(*s,*r)); } else if (stap) { - printf("%s -> !%s (receiver not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid); + printf("%s -> !%s (receiver not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),(unsigned long long)nwid); } else if (rtap) { - printf("%s -> !%s (sender not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid); + printf("%s -> !%s (sender not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),(unsigned long long)nwid); } else { - printf("%s -> !%s (neither party is a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid); + printf("%s -> !%s (neither party is a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),(unsigned long long)nwid); } } } @@ -563,7 +563,7 @@ static void doUnicast(const std::vector<std::string> &cmd) if ((frame.len == frameLen)&&(!memcmp(frame.data + 16,pkt.data + 16,frameLen - 16))) { uint64_t ints[2]; memcpy(ints,frame.data,16); - printf("%s <- %.10llx received test packet, length == %u, latency == %llums"ZT_EOL_S,r->toString().c_str(),ints[0],frame.len,frame.timestamp - ints[1]); + printf("%s <- %.10llx received test packet, length == %u, latency == %llums"ZT_EOL_S,r->toString().c_str(),(unsigned long long)ints[0],frame.len,(unsigned long long)(frame.timestamp - ints[1])); receivedPairs.insert(std::pair<Address,Address>(Address(ints[0]),*r)); } else { printf("%s !! got spurious packet, length == %u, etherType == 0x%.4x"ZT_EOL_S,r->toString().c_str(),frame.len,frame.etherType); @@ -640,9 +640,9 @@ static void doMulticast(const std::vector<std::string> &cmd) pkt.i[0] = s->toInt(); pkt.i[1] = Utils::now(); stap->injectPacketFromHost(stap->mac(),mcaddr,0xdead,pkt.data,frameLen); - printf("%s -> %s etherType 0xdead network %.16llx length %u"ZT_EOL_S,s->toString().c_str(),mcaddr.toString().c_str(),nwid,frameLen); + printf("%s -> %s etherType 0xdead network %.16llx length %u"ZT_EOL_S,s->toString().c_str(),mcaddr.toString().c_str(),(unsigned long long)nwid,frameLen); } else { - printf("%s -> !%s (sender is not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),mcaddr.toString().c_str(),nwid); + printf("%s -> !%s (sender is not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),mcaddr.toString().c_str(),(unsigned long long)nwid); } } @@ -660,7 +660,7 @@ static void doMulticast(const std::vector<std::string> &cmd) if ((frame.len == frameLen)&&(!memcmp(frame.data + 16,pkt.data + 16,frameLen - 16))) { uint64_t ints[2]; memcpy(ints,frame.data,16); - printf("%s <- %.10llx received test packet, length == %u, latency == %llums"ZT_EOL_S,nn->first.toString().c_str(),ints[0],frame.len,frame.timestamp - ints[1]); + printf("%s <- %.10llx received test packet, length == %u, latency == %llums"ZT_EOL_S,nn->first.toString().c_str(),(unsigned long long)ints[0],frame.len,(unsigned long long)(frame.timestamp - ints[1])); ++receiveCount; } else { printf("%s !! got spurious packet, length == %u, etherType == 0x%.4x"ZT_EOL_S,nn->first.toString().c_str(),frame.len,frame.etherType);