summaryrefslogtreecommitdiff
path: root/anytun.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2007-06-18 23:10:07 +0000
committerChristian Pointner <equinox@anytun.org>2007-06-18 23:10:07 +0000
commit99122b5d0da14bfb36cc3760bc6637d396b83cda (patch)
tree6b6555f1851ec7a92aea6b1692a3f58839b42723 /anytun.cpp
parentpackage with all member functions (not working yet) (diff)
package works now
Diffstat (limited to 'anytun.cpp')
-rw-r--r--anytun.cpp160
1 files changed, 43 insertions, 117 deletions
diff --git a/anytun.cpp b/anytun.cpp
index 8213df3..daae3bc 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -39,6 +39,17 @@
#include "cypher.h"
#include "authAlgo.h"
+void printStat(Package& pack)
+{
+ std::cout << "pack[0-" << pack.getLength() << "]: '";
+ for(unsigned int i=0; i<pack.getLength(); ++i)
+ std::cout << (int)pack[i] << ",";
+ std::cout << std::endl;
+ std::cout << "pack: hdr=" << pack.hasHeader() << " payt=" << pack.hasPayloadType() << " autht=" << pack.hasAuthTag();
+ std::cout << " -- seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << " payload_type=" << pack.getPayloadType()
+ << " auth_tag=" << pack.getAuthTag() << std::endl << std::endl;
+}
+
int main(int argc, char* argv[])
{
std::cout << "anytun - secure anycast tunneling protocol" << std::endl;
@@ -50,136 +61,51 @@ int main(int argc, char* argv[])
std::cout << std::hex;
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasHeader() << " seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << std::endl;
+ pack.setSeqNr(0x55AA55AA).setSenderId(0xBB11);
+ printStat(pack);
-// pack.setSeqNr(0x55AA55AA).setSenderId(0xBB11);
+ pack.addHeader(0x12345678, 0x9ABC);
+ printStat(pack);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasHeader() << " seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << std::endl;
-
-// pack.addHeader(0x12345678, 0x9ABC);
+ pack.removeHeader();
+ printStat(pack);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasHeader() << " seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << std::endl;
+ pack.withHeader(true);
+ printStat(pack);
-// pack.removeHeader();
+ pack.withHeader(false);
+ printStat(pack);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasHeader() << " seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << std::endl;
+ pack.addPayloadType(0xCCFF);
+ printStat(pack);
-// pack.withHeader(true);
+ pack.addPayloadType(0xEEBB);
+ printStat(pack);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasHeader() << " seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << std::endl;
+ pack.removePayloadType();
+ printStat(pack);
-// pack.withHeader(false);
+ pack.withPayloadType(true);
+ printStat(pack);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: hdr=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
-
-// pack.addPayloadType(0xCCFF);
+ pack.withPayloadType(false);
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: payt=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
+ pack.addAuthTag(0xCCDDEEFF);
+ printStat(pack);
-// pack.addPayloadType(0xEEBB);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: payt=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
-
-// pack.removePayloadType();
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: payt=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
-
-// pack.withPayloadType(true);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: payt=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
-
-// pack.withPayloadType(false);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: payt=" << pack.hasPayloadType() << " payload_type=" << pack.getPayloadType() << std::endl;
-
-// pack.addAuthTag(0xCCDDEEFF);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: autht=" << pack.hasAuthTag() << " auth_tag=" << pack.getAuthTag() << std::endl;
-
-// pack.removeAuthTag();
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: autht=" << pack.hasAuthTag() << " auth_tag=" << pack.getAuthTag() << std::endl;
-
-// pack.withAuthTag(true);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: autht=" << pack.hasAuthTag() << " auth_tag=" << pack.getAuthTag() << std::endl;
-
-// pack.withAuthTag(false);
-
-// std::cout << "pack[0-" << pack.getLength() << "]: '";
-// for(unsigned int i=0; i<pack.getLength(); ++i)
-// std::cout << (int)pack[i] << ",";
-// std::cout << std::endl;
-// std::cout << "pack: autht=" << pack.hasAuthTag() << " auth_tag=" << pack.getAuthTag() << std::endl;
+ pack.removeAuthTag();
+ printStat(pack);
+
+ pack.withAuthTag(true);
+ printStat(pack);
+
+ pack.withAuthTag(false);
+ printStat(pack);
std::cout << std::endl << std::endl;
-
- pack.addHeader(0x56789ABC,0xDEF0);
-
- std::cout << "pack[0-" << pack.getLength() << "]: '";
- for(unsigned int i=0; i<pack.getLength(); ++i)
- std::cout << (int)pack[i] << ",";
- std::cout << std::endl;
- std::cout << "pack: hdr=" << pack.hasHeader() << " payt=" << pack.hasPayloadType() << " autht=" << pack.hasAuthTag() << std::endl;
- std::cout << "seq_nr=" << pack.getSeqNr() << " sender_id=" << pack.getSenderId() << " payload_type=" << pack.getPayloadType()
- << " auth_tag=" << pack.getAuthTag() << std::endl;
-
+ pack.addPayloadType(0x1234).addHeader(0x56789ABC,0xDEF0).addAuthTag(0xFEDCBA98);
+ printStat(pack);
+
std::cout << std::dec;
// TunDevice* dev;