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 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program (see the file COPYING included with this
27 * distribution); if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "datatypes.h"
35 #include "keyDerivation.h"
37 #include "seqWindow.h"
38 #include "connectionList.h"
39 #include "routingTable.h"
40 #include "networkAddress.h"
41 #include "syncCommand.h"
47 #include <boost/archive/text_oarchive.hpp>
48 #include <boost/archive/text_iarchive.hpp>
51 void output(ConnectionList
&cl
)
55 ConnectionMap::iterator it
= cl
.getBeginUnlocked();
56 mux_t mux
= it
->first
;
57 ConnectionParam
&conn( it
->second
);
58 std::cout
<< "Client " << mux
<< ": " ;
59 if( conn
.remote_host_
=="")
61 std::cout
<< "not registered";
63 std::cout
<< conn
.remote_host_
<< ':'<<conn
.remote_port_
;
65 std::cout
<< std::endl
;
66 //std::cout << "Connection: Keyderivation-Type: " << conn.kd_.printType() << std::endl;
69 else if( !gRoutingTable
.empty() )
71 RoutingMap::iterator it
= gRoutingTable
.getBeginUnlocked();
72 NetworkPrefix
pref( it
->first
);
73 std::cout
<< "Route: " << pref
.toString() << "/" << pref
.getNetworkPrefixLength() << " -> ";
74 mux_t mux
= it
->second
;
75 std::cout
<< mux
<< std::endl
;
76 gRoutingTable
.clear();
80 int main(int argc
, char* argv
[])
83 if(!gOpt
.parse(argc
, argv
))
90 std::stringstream iss_
;
91 int32_t missing_chars
=-1;
92 int32_t buffer_size_
=0;
93 while( std::cin
.good() )
101 if(missing_chars
==-1 && buffer_size_
>5)
103 char * buffer
= new char [6+1];
105 std::stringstream tmp
;
111 else if( missing_chars
>0 && missing_chars
<=buffer_size_
)
113 char * buffer
= new char [missing_chars
+1];
114 iss_
.read(buffer
,missing_chars
);
115 std::stringstream tmp
;
116 tmp
.write(buffer
,missing_chars
);
117 boost::archive::text_iarchive
ia(tmp
);
118 SyncCommand
scom(cl
);
120 buffer_size_
-=missing_chars
;