summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2008-02-29 14:29:00 +0000
committerErwin Nindl <nine@wirdorange.org>2008-02-29 14:29:00 +0000
commit23acebd364d21086d73e2cf5fcb6f23a9d6eddcb (patch)
tree09fa7bcb4435be41c7dfb5b2aac20e3c9f26be17
parentrouting (diff)
output route on anytun-showtables;
cl option to anyctr
-rw-r--r--anyctr.cpp5
-rw-r--r--anyctrOptions.cpp17
-rw-r--r--anyctrOptions.h3
-rw-r--r--anytun-showtables.cpp4
4 files changed, 26 insertions, 3 deletions
diff --git a/anyctr.cpp b/anyctr.cpp
index 2e4e9c2..61c238b 100644
--- a/anyctr.cpp
+++ b/anyctr.cpp
@@ -64,8 +64,9 @@ void createConnection(const std::string & remote_host, u_int16_t remote_port, Co
cl.addConnection( connparam, mux );
NetworkAddress addr( ipv4, gOpt.getIfconfigParamRemoteNetmask().c_str() );
NetworkPrefix prefix( addr );
- // TODO configurierbar machen!!!
- prefix.setNetworkPrefixLength(32);
+
+ prefix.setNetworkPrefixLength(gOpt.getNetworkPrefixLength());
+
gRoutingTable.addRoute( prefix, mux );
std::ostringstream sout;
boost::archive::text_oarchive oa( sout );
diff --git a/anyctrOptions.cpp b/anyctrOptions.cpp
index e1ff47f..17a8f3f 100644
--- a/anyctrOptions.cpp
+++ b/anyctrOptions.cpp
@@ -59,6 +59,7 @@ Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
seq_window_size_ = 100;
kd_prf_ = "aes-ctr";
mux_ = 0;
+ network_prefix_length_ = 32;
}
Options::~Options()
@@ -144,6 +145,7 @@ bool Options::parse(int argc, char* argv[])
PARSE_SCALAR_PARAM2("-n","--ifconfig", ifconfig_param_local_, ifconfig_param_remote_netmask_)
PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_)
PARSE_SCALAR_PARAM("-m","--mux", mux_)
+ PARSE_SCALAR_PARAM("-l","--prefix-len", network_prefix_length_)
PARSE_HEXSTRING_PARAM("-K","--key", key_)
PARSE_HEXSTRING_PARAM("-a","--salt", salt_)
PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_)
@@ -175,6 +177,7 @@ void Options::printUsage()
<< " <remote|netmask> the remote address(tun) or netmask(tap)" << std::endl;
std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
+ std::cout << " [-l|--prefix-len] <prefix length> network prefix length" << std::endl;
std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
std::cout << " [-a|--salt] <master salt> master salt to use for encryption" << std::endl;
std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
@@ -190,6 +193,7 @@ void Options::printOptions()
std::cout << "ifconfig_param_remote_netmask='" << ifconfig_param_remote_netmask_ << "'" << std::endl;
std::cout << "seq_window_size='" << seq_window_size_ << "'" << std::endl;
std::cout << "mux_id='" << mux_ << "'" << std::endl;
+ std::cout << "network_prefix_length='" << network_prefix_length_ << "'" << std::endl;
std::cout << "key=" << key_.getHexDumpOneLine() << std::endl;
std::cout << "salt=" << salt_.getHexDumpOneLine() << std::endl;
std::cout << "kd_prf='" << kd_prf_ << "'" << std::endl;
@@ -293,6 +297,19 @@ Options& Options::setMux(u_int16_t m)
return *this;
}
+u_int16_t Options::getNetworkPrefixLength()
+{
+ Lock lock(mutex);
+ return network_prefix_length_;
+}
+
+Options& Options::setNetworkPrefixLength(u_int16_t l)
+{
+ Lock lock(mutex);
+ network_prefix_length_ = l;
+ return *this;
+}
+
Buffer Options::getKey()
{
Lock lock(mutex);
diff --git a/anyctrOptions.h b/anyctrOptions.h
index 8bd83c0..edbd621 100644
--- a/anyctrOptions.h
+++ b/anyctrOptions.h
@@ -72,6 +72,8 @@ public:
Buffer getKey();
Options& setSalt(std::string s);
Buffer getSalt();
+ Options& setNetworkPrefixLength(u_int16_t l);
+ u_int16_t getNetworkPrefixLength();
private:
Options();
@@ -100,6 +102,7 @@ private:
window_size_t seq_window_size_;
std::string kd_prf_;
u_int16_t mux_;
+ u_int16_t network_prefix_length_;
Buffer key_;
Buffer salt_;
};
diff --git a/anytun-showtables.cpp b/anytun-showtables.cpp
index 830f535..8e5929f 100644
--- a/anytun-showtables.cpp
+++ b/anytun-showtables.cpp
@@ -54,7 +54,7 @@ void output(ConnectionList & cl)
{
ConnectionMap::iterator it = cl.getBeginUnlocked();
mux_t mux = it->first;
- std::cout << "mux: " << mux << std::endl;
+ std::cout << "Mux-ID: " << mux << std::endl;
ConnectionParam &conn( it->second );
std::cout << "Keyderivation-Type: " << conn.kd_.printType() << std::endl;
}
@@ -62,7 +62,9 @@ void output(ConnectionList & cl)
{
RoutingMap::iterator it = gRoutingTable.getBeginUnlocked();
NetworkPrefix pref( it->first );
+ std::cout << "Network-Prefix: " << pref.getNetworkPrefixLength() << std::endl;
mux_t mux = it->second;
+ std::cout << "Mux-ID: " << mux << std::endl;
}
std::cout << std::endl;
}