4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methodes used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl,
15 * Christian Pointner <satp@wirdorange.org>
17 * This file is part of Anytun.
19 * Anytun is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
24 * Anytun is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with anytun. If not, see <http://www.gnu.org/licenses/>.
33 #include "datatypes.h"
37 #include "keyDerivation.h"
38 #include "seqWindow.h"
39 #include "connectionList.h"
40 #include "routingTable.h"
41 #include "networkAddress.h"
42 #include "syncCommand.h"
48 #include <boost/archive/text_oarchive.hpp>
49 #include <boost/archive/text_iarchive.hpp>
54 ConnectionList &cl(gConnectionList);
57 ConnectionMap::iterator it = cl.getBeginUnlocked();
58 mux_t mux = it->first;
59 ConnectionParam &conn( it->second );
60 std::cout << "Client " << mux << ": " ;
61 if( conn.remote_end_==PacketSourceEndpoint())
63 std::cout<< "not registered";
65 std::cout<< conn.remote_end_;
67 std::cout << std::endl;
68 //std::cout << "Connection: Keyderivation-Type: " << conn.kd_.printType() << std::endl;
71 network_address_type_t types[] = {ipv4,ipv6,ethernet};
72 for (int types_idx=0; types_idx<3; types_idx++)
74 network_address_type_t type = types[types_idx];
75 if( !gRoutingTable.empty(type) )
77 RoutingMap::iterator it = gRoutingTable.getBeginUnlocked(type);
78 NetworkPrefix pref( it->first );
79 std::cout << "Route: " << pref.toString() << "/" << (int)pref.getNetworkPrefixLength() << " -> ";
80 mux_t mux = it->second;
81 std::cout << mux << std::endl;
82 gRoutingTable.clear(type);
88 void readExactly(size_t toread, std::iostream & result)
91 while (toread > hasread && std::cin.good())
100 void readAndProcessOne()
102 size_t message_lenght ;
103 std::stringstream message_lenght_stream;
104 readExactly(5,message_lenght_stream);
105 message_lenght_stream >> message_lenght;
106 std::stringstream void_stream;
107 readExactly(1,void_stream); //skip space
110 std::stringstream sync_command_stream;
111 readExactly(message_lenght, sync_command_stream);
112 //std::cout << message_lenght << std::endl;
113 //std::cout << sync_command_stream.str()<< std::endl;
114 boost::archive::text_iarchive ia(sync_command_stream);
115 SyncCommand scom(gConnectionList);
119 int main(int argc, char* argv[])
123 while( std::cin.good() )
129 catch(std::exception& e)
131 std::cout << "uncaught exception, exiting: " << e.what() << std::endl;