summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-15 12:27:06 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-15 12:27:06 +0000
commit86891c4b1884a53bcd6e6bd021eb2a7b3987ab28 (patch)
tree828736cf5477351b488b02ad722b2442fbee335e /src
parentsmall cleanup (diff)
small cleanup
Diffstat (limited to 'src')
-rw-r--r--src/anytun.cpp82
-rw-r--r--src/authAlgo.cpp10
-rw-r--r--src/keyDerivation.cpp6
3 files changed, 56 insertions, 42 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index bbea08a..bf20d1c 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -105,6 +105,47 @@ void createConnection(const PacketSourceEndpoint & remote_end, window_size_t seq
#endif
}
+#ifndef ANYTUN_NOSYNC
+void syncConnector(void* p )
+{
+ ThreadParam* param = reinterpret_cast<ThreadParam*>(p);
+
+ SyncClient sc ( param->connto.host, param->connto.port);
+ sc.run();
+}
+
+void syncListener(SyncQueue * queue)
+{
+ try
+ {
+ boost::asio::io_service io_service;
+ SyncTcpConnection::proto::resolver resolver(io_service);
+ SyncTcpConnection::proto::endpoint e;
+ if(gOpt.getLocalSyncAddr()!="")
+ {
+ SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncAddr(), gOpt.getLocalSyncPort());
+ e = *resolver.resolve(query);
+ } else {
+ SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncPort());
+ e = *resolver.resolve(query);
+ }
+
+
+ SyncServer server(io_service,e);
+ server.onConnect=boost::bind(syncOnConnect,_1);
+ queue->setSyncServerPtr(&server);
+ io_service.run();
+ }
+ catch (std::exception& e)
+ {
+ std::string addr = gOpt.getLocalSyncAddr() == "" ? "*" : gOpt.getLocalSyncAddr();
+ cLog.msg(Log::PRIO_ERR) << "sync: cannot bind to " << addr << ":" << gOpt.getLocalSyncPort()
+ << " (" << e.what() << ")" << std::endl;
+ }
+
+}
+#endif
+
void sender(void* p)
{
try
@@ -193,47 +234,6 @@ void sender(void* p)
cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught exception: " << e.what();
}
}
-
-#ifndef ANYTUN_NOSYNC
-void syncConnector(void* p )
-{
- ThreadParam* param = reinterpret_cast<ThreadParam*>(p);
-
- SyncClient sc ( param->connto.host, param->connto.port);
- sc.run();
-}
-
-void syncListener(SyncQueue * queue)
-{
- try
- {
- boost::asio::io_service io_service;
- SyncTcpConnection::proto::resolver resolver(io_service);
- SyncTcpConnection::proto::endpoint e;
- if(gOpt.getLocalSyncAddr()!="")
- {
- SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncAddr(), gOpt.getLocalSyncPort());
- e = *resolver.resolve(query);
- } else {
- SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncPort());
- e = *resolver.resolve(query);
- }
-
-
- SyncServer server(io_service,e);
- server.onConnect=boost::bind(syncOnConnect,_1);
- queue->setSyncServerPtr(&server);
- io_service.run();
- }
- catch (std::exception& e)
- {
- std::string addr = gOpt.getLocalSyncAddr() == "" ? "*" : gOpt.getLocalSyncAddr();
- cLog.msg(Log::PRIO_ERR) << "sync: cannot bind to " << addr << ":" << gOpt.getLocalSyncPort()
- << " (" << e.what() << ")" << std::endl;
- }
-
-}
-#endif
void receiver(void* p)
{
diff --git a/src/authAlgo.cpp b/src/authAlgo.cpp
index 3088c72..8293d70 100644
--- a/src/authAlgo.cpp
+++ b/src/authAlgo.cpp
@@ -76,6 +76,11 @@ Sha1AuthAlgo::~Sha1AuthAlgo()
void Sha1AuthAlgo::generate(KeyDerivation& kd, kd_dir dir, EncryptedPacket& packet)
{
+#ifndef USE_SSL_CRYPTO
+ if(!handle)
+ return;
+#endif
+
packet.addAuthTag();
if(!packet.getAuthTagLength())
return;
@@ -113,6 +118,11 @@ void Sha1AuthAlgo::generate(KeyDerivation& kd, kd_dir dir, EncryptedPacket& pack
bool Sha1AuthAlgo::checkTag(KeyDerivation& kd, kd_dir dir, EncryptedPacket& packet)
{
+#ifndef USE_SSL_CRYPTO
+ if(!handle)
+ return false;
+#endif
+
packet.withAuthTag(true);
if(!packet.getAuthTagLength())
return true;
diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp
index 46c1568..fcb3001 100644
--- a/src/keyDerivation.cpp
+++ b/src/keyDerivation.cpp
@@ -198,6 +198,11 @@ bool AesIcmKeyDerivation::generate(kd_dir dir, satp_prf_label label, seq_nr_t se
{
ReadersLock lock(mutex_);
+#ifndef USE_SSL_CRYPTO
+ if(!handle_[dir])
+ return false;
+#endif
+
seq_nr_t r;
calcCtr(dir, &r, label, seq_nr);
// TODO: return stored key
@@ -212,7 +217,6 @@ bool AesIcmKeyDerivation::generate(kd_dir dir, satp_prf_label label, seq_nr_t se
// return false;
// }
-
#ifndef USE_SSL_CRYPTO
gcry_error_t err = gcry_cipher_reset(handle_[dir]);
if(err) {