From 49147bacbfb07337c54ddd3df94499c166a0376c Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Tue, 6 Nov 2007 23:28:11 +0000 Subject: router + connection manage eingebaut --- Makefile | 1 + connectionList.cpp | 3 ++- connectionList.h | 4 ++-- connectionParam.cpp | 35 +++++++++++++++++++++++++++++++++++ connectionParam.h | 13 +++++++------ router.cpp | 4 ++-- router.h | 2 +- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 connectionParam.cpp diff --git a/Makefile b/Makefile index ffb4b1c..4148821 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ OBJS = anytun.o \ authAlgo.o \ keyDerivation.o \ connectionList.o \ + connectionParams.o \ networkAddress.o \ PracticalSocket.o \ router.o \ diff --git a/connectionList.cpp b/connectionList.cpp index 0395284..2b857f3 100644 --- a/connectionList.cpp +++ b/connectionList.cpp @@ -41,9 +41,10 @@ ConnectionList::~ConnectionList() { } -void ConnectionList::addConnection() +void ConnectionList::addConnection(ConnectionParam &conn, const std::string &name) { Lock lock(mutex_); + connections_[name]=conn; } void ConnectionList::clear() diff --git a/connectionList.h b/connectionList.h index ce467c1..7a3b5c6 100644 --- a/connectionList.h +++ b/connectionList.h @@ -44,13 +44,13 @@ class ConnectionList public: ConnectionList(); ~ConnectionList(); - void addConnection(); + void addConnection(ConnectionParam &conn, const std::string &name); void clear(); private: ConnectionList(const ConnectionList &s); void operator=(const ConnectionList &s); - typedef std::map ConnectionMap; + typedef std::map ConnectionMap; ConnectionMap connections_; Mutex mutex_; }; diff --git a/connectionParam.cpp b/connectionParam.cpp new file mode 100644 index 0000000..d053c6b --- /dev/null +++ b/connectionParam.cpp @@ -0,0 +1,35 @@ +/* + * 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 + * + * 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 + */ + +#include "connectionParam.h" + +ConnectionParam::ConnectionParam(Options& opt,KeyDerivation& kd,Cypher& c,AuthAlgo& a,SeqWindow& seq):opt_(opt),kd_(kd),c_(c),a_(a),seq_(seq) +{ +} diff --git a/connectionParam.h b/connectionParam.h index ba1f757..96d5525 100644 --- a/connectionParam.h +++ b/connectionParam.h @@ -37,13 +37,14 @@ #include "authAlgo.h" #include "seqWindow.h" -struct connection_param_t +class ConnectionParam { - Options& opt; - KeyDerivation& kd; - Cypher& c; - AuthAlgo& a; - SeqWindow& seq; + ConnectionParam(Options& opt,KeyDerivation& kd,Cypher& c,AuthAlgo& a,SeqWindow& seq); + Options& opt_; + KeyDerivation& kd_; + Cypher& c_; + AuthAlgo& a_; + SeqWindow& seq_; }; #endif diff --git a/router.cpp b/router.cpp index 0948a9f..438a23a 100644 --- a/router.cpp +++ b/router.cpp @@ -41,9 +41,9 @@ Router::~Router() { } -void Router::addConnection(connection_param_t conn) +void Router::addConnection(ConnectionParam &conn,const std::string &name) { - Lock lock(mutex_); + con_list_.addConnection(conn,name); } connection_param_t Router::getRoute() diff --git a/router.h b/router.h index 6630bd2..8ff5f5f 100644 --- a/router.h +++ b/router.h @@ -41,7 +41,7 @@ class Router public: Router(); ~Router(); - void addConnection(connection_param_t conn); + void addConnection(ConnectionParam &conn,const std::string &name); connection_param_t getRoute(); private: -- cgit v1.2.3