summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2008-02-29 13:58:15 +0000
committerErwin Nindl <nine@wirdorange.org>2008-02-29 13:58:15 +0000
commit0b07a4a6a4a2f9ea38ce76ed2ade4e475bda1719 (patch)
tree22f16377c36c88355e3d144cb425e76b623c63d9
parentfixed network prefix serialization (diff)
delete[] bugfix in syncClientSocket.cpp,
anytunschowtables
-rw-r--r--anytun-showtables.cpp107
-rw-r--r--syncClientSocket.cpp4
-rw-r--r--syncConnectionCommand.h31
3 files changed, 91 insertions, 51 deletions
diff --git a/anytun-showtables.cpp b/anytun-showtables.cpp
index 89f6e02..830f535 100644
--- a/anytun-showtables.cpp
+++ b/anytun-showtables.cpp
@@ -28,43 +28,18 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iostream>
-#include <poll.h>
-
-#include <gcrypt.h>
-#include <cerrno> // for ENOMEM
-
#include "datatypes.h"
#include "log.h"
#include "buffer.h"
-#include "plainPacket.h"
-#include "encryptedPacket.h"
-#include "cipher.h"
#include "keyDerivation.h"
-#include "authAlgo.h"
-#include "authTag.h"
-#include "cipherFactory.h"
-#include "authAlgoFactory.h"
-#include "keyDerivationFactory.h"
-#include "signalController.h"
-#include "packetSource.h"
-#include "tunDevice.h"
#include "options.h"
#include "seqWindow.h"
#include "connectionList.h"
#include "routingTable.h"
#include "networkAddress.h"
-
-#include "syncQueue.h"
-#include "syncSocketHandler.h"
-#include "syncListenSocket.h"
-
-#include "syncSocket.h"
-#include "syncClientSocket.h"
#include "syncCommand.h"
-#include "threadParam.h"
#include <sstream>
#include <iostream>
#include <string>
@@ -72,41 +47,75 @@
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
-#define MAX_PACKET_LENGTH 1600
-#define SESSION_KEYLEN_AUTH 20 // TODO: hardcoded size
-#define SESSION_KEYLEN_ENCR 16 // TODO: hardcoded size
-#define SESSION_KEYLEN_SALT 14 // TODO: hardcoded size
+void output(ConnectionList & cl)
+{
+ if( !cl.empty() )
+ {
+ ConnectionMap::iterator it = cl.getBeginUnlocked();
+ mux_t mux = it->first;
+ std::cout << "mux: " << mux << std::endl;
+ ConnectionParam &conn( it->second );
+ std::cout << "Keyderivation-Type: " << conn.kd_.printType() << std::endl;
+ }
+ else if( !gRoutingTable.empty() )
+ {
+ RoutingMap::iterator it = gRoutingTable.getBeginUnlocked();
+ NetworkPrefix pref( it->first );
+ mux_t mux = it->second;
+ }
+ std::cout << std::endl;
+}
int main(int argc, char* argv[])
{
- int ret=0;
+ int ret = 0;
if(!gOpt.parse(argc, argv))
{
gOpt.printUsage();
exit(-1);
}
- SignalController sig;
- sig.init();
-
ConnectionList cl;
-
- boost::archive::text_iarchive ia(std::cin);
- SyncCommand scom(cl);
- ia>>scom;
- if (!cl.empty())
- {
- ConnectionMap::iterator it=cl.getBeginUnlocked();
- mux_t mux = it->first;
- std::cout <<mux;
- ConnectionParam & conn ( it->second);
- } else if (!gRoutingTable.empty()) {
- RoutingMap::iterator it=gRoutingTable.getBeginUnlocked();
- NetworkPrefix pref (it->first);
- mux_t mux = it->second;
- }
- std::cout << std::endl;
+ std::stringstream iss_;
+ int32_t missing_chars=-1;
+ int32_t buffer_size_=0;
+ while(std::cin.good())
+ {
+ char c;
+ std::cin.get(c);
+ iss_ << c;
+ buffer_size_++;
+ while (1)
+ {
+ if(missing_chars==-1 && buffer_size_>5)
+ {
+ char * buffer = new char [6+1];
+ iss_.read(buffer,6);
+ std::stringstream tmp;
+ tmp.write(buffer,6);
+ tmp>>missing_chars;
+ delete[] buffer;
+ buffer_size_-=6;
+ }
+ else if(missing_chars>0 && missing_chars<=buffer_size_)
+ {
+ char * buffer = new char [missing_chars+1];
+ iss_.read(buffer,missing_chars);
+ std::stringstream tmp;
+ tmp.write(buffer,missing_chars);
+ boost::archive::text_iarchive ia(tmp);
+ SyncCommand scom(cl);
+ ia >> scom;
+ buffer_size_-=missing_chars;
+ missing_chars=-1;
+ output(cl);
+ delete[] buffer;
+ }
+ else
+ break;
+ }
+ }
return ret;
}
diff --git a/syncClientSocket.cpp b/syncClientSocket.cpp
index bdfd973..cf266ca 100644
--- a/syncClientSocket.cpp
+++ b/syncClientSocket.cpp
@@ -59,7 +59,7 @@ void SyncClientSocket::OnRawData(const char *buf,size_t len)
tmp.write(buffer,6);
tmp>>missing_chars;
cLog.msg(Log::PRIO_NOTICE) << "recieved sync inforamtaion length from " << GetRemoteHostname() <<" "<<tmp.str()<<"bytes of data"<< std::endl;
- delete buffer;
+ delete[] buffer;
buffer_size_-=6;
} else
if(missing_chars>0 && missing_chars<=buffer_size_)
@@ -74,7 +74,7 @@ void SyncClientSocket::OnRawData(const char *buf,size_t len)
ia >> scom;
buffer_size_-=missing_chars;
missing_chars=-1;
- delete buffer;
+ delete[] buffer;
} else
break;
}
diff --git a/syncConnectionCommand.h b/syncConnectionCommand.h
index 225ec9c..e9852c2 100644
--- a/syncConnectionCommand.h
+++ b/syncConnectionCommand.h
@@ -1,5 +1,36 @@
+/*
+ * anytun
+ *
+ * The secure anycast tunneling protocol (satp) defines a protocol used
+ * for communication between any combination of unicast and anycast
+ * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
+ * mode and allows tunneling of every ETHER TYPE protocol (e.g.
+ * ethernet, ip, arp ...). satp directly includes cryptography and
+ * message authentication based on the methodes used by SRTP. It is
+ * intended to deliver a generic, scaleable and secure solution for
+ * tunneling and relaying of packets of any protocol.
+ *
+ *
+ * Copyright (C) 2007 anytun.org <satp@wirdorange.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING included with this
+ * distribution); if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
#ifndef _SYNCCONNECTIONCOMMAND_H
#define _SYNCCONNECTIONCOMMAND_H
+
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>