summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarkus Grüneis <gimpf@gimpf.org>2010-02-18 09:15:27 +0000
committerMarkus Grüneis <gimpf@gimpf.org>2010-02-18 09:15:27 +0000
commite191eab68d905bfe14e3590a92fa653f0ae2ebce (patch)
treea5837b067ecab92c645008b537087b0d163ef1ab /src
parentwhitespace only change: unified formatting with "astyle --style=k/r --indent=... (diff)
non-functional changes only: use standard writing of stdint.h types; still import from boost (compiler compatibility)
Diffstat (limited to 'src')
-rw-r--r--src/anyrtpproxy/anyrtpproxy.cpp4
-rw-r--r--src/anyrtpproxy/commandHandler.cpp6
-rw-r--r--src/anyrtpproxy/connectionList.cpp6
-rw-r--r--src/anyrtpproxy/connectionList.h8
-rw-r--r--src/anyrtpproxy/options.cpp8
-rw-r--r--src/anyrtpproxy/options.h12
-rw-r--r--src/anyrtpproxy/portWindow.cpp10
-rw-r--r--src/anyrtpproxy/portWindow.h14
-rw-r--r--src/anyrtpproxy/rtpSession.h8
-rw-r--r--src/anytun-config.cpp4
-rw-r--r--src/anytun.cpp10
-rw-r--r--src/authAlgo.cpp28
-rw-r--r--src/authAlgo.h4
-rw-r--r--src/authAlgoFactory.cpp3
-rw-r--r--src/authAlgoFactory.h2
-rw-r--r--src/bsd/tunDevice.cpp12
-rw-r--r--src/buffer.cpp54
-rw-r--r--src/buffer.h24
-rw-r--r--src/cipher.cpp20
-rw-r--r--src/cipher.h38
-rw-r--r--src/connectionList.cpp10
-rw-r--r--src/connectionList.h8
-rw-r--r--src/connectionParam.h2
-rw-r--r--src/datatypes.h29
-rw-r--r--src/deviceConfig.hpp10
-rw-r--r--src/encryptedPacket.cpp18
-rw-r--r--src/encryptedPacket.h24
-rw-r--r--src/keyDerivation.cpp14
-rw-r--r--src/keyDerivation.h28
-rw-r--r--src/linux/tunDevice.cpp6
-rw-r--r--src/networkAddress.cpp8
-rw-r--r--src/networkAddress.h8
-rw-r--r--src/networkPrefix.cpp6
-rw-r--r--src/networkPrefix.h8
-rw-r--r--src/options.cpp22
-rw-r--r--src/options.h10
-rw-r--r--src/packetSource.cpp10
-rw-r--r--src/packetSource.h14
-rw-r--r--src/plainPacket.cpp10
-rw-r--r--src/plainPacket.h12
-rw-r--r--src/resolver.cpp6
-rw-r--r--src/routingTable.cpp14
-rw-r--r--src/routingTable.h10
-rw-r--r--src/routingTree.hpp6
-rw-r--r--src/routingTreeNode.h2
-rw-r--r--src/seqWindow.cpp2
-rw-r--r--src/seqWindow.h2
-rw-r--r--src/syncBuffer.h6
-rw-r--r--src/syncCommand.cpp2
-rw-r--r--src/syncCommand.h2
-rw-r--r--src/syncConnectionCommand.cpp4
-rw-r--r--src/syncConnectionCommand.h6
-rw-r--r--src/syncRouteCommand.h4
-rw-r--r--src/tunDevice.h6
-rw-r--r--src/win32/tunDevice.cpp8
55 files changed, 305 insertions, 307 deletions
diff --git a/src/anyrtpproxy/anyrtpproxy.cpp b/src/anyrtpproxy/anyrtpproxy.cpp
index 22d7494..1daf35b 100644
--- a/src/anyrtpproxy/anyrtpproxy.cpp
+++ b/src/anyrtpproxy/anyrtpproxy.cpp
@@ -67,12 +67,12 @@ void listener(RtpSession::proto::socket* sock1, RtpSession::proto::socket* sock2
cLog.msg(Log::PRIO_NOTICE) << "listener(" << call_id << "/" << dir << ") started";
try {
- Buffer buf(u_int32_t(MAX_PACKET_SIZE));
+ Buffer buf(uint32_t(MAX_PACKET_SIZE));
RtpSession::proto::endpoint remote_end;
while(1) {
buf.setLength(MAX_PACKET_SIZE);
- u_int32_t len=0;
+ uint32_t len=0;
if(dir == 1) {
len = 0; //sock1->recvFromNonBlocking(buf.getBuf(), buf.getLength(), remote_end, 1000);
} else if(dir == 2) {
diff --git a/src/anyrtpproxy/commandHandler.cpp b/src/anyrtpproxy/commandHandler.cpp
index 72c3061..a8f1df8 100644
--- a/src/anyrtpproxy/commandHandler.cpp
+++ b/src/anyrtpproxy/commandHandler.cpp
@@ -76,7 +76,7 @@ void CommandHandler::run(void* s)
{
CommandHandler* self = reinterpret_cast<CommandHandler*>(s);
- Buffer buf(u_int32_t(MAX_COMMAND_LENGTH));
+ Buffer buf(uint32_t(MAX_COMMAND_LENGTH));
try {
proto::endpoint remote_end;
@@ -171,8 +171,8 @@ string CommandHandler::handleRequest(string modifiers, string call_id, string ad
bool is_new;
RtpSession& session = gRtpSessionTable.getOrNewSession(call_id, is_new);
if(is_new) {
- u_int16_t port1 = port_window_.newPort(); // TODO: get next available port
- u_int16_t port2 = port_window_.newPort(); // TODO: get next available port
+ uint16_t port1 = port_window_.newPort(); // TODO: get next available port
+ uint16_t port2 = port_window_.newPort(); // TODO: get next available port
if(!port1 || !port2) {
if(port1) { port_window_.freePort(port1); }
if(port2) { port_window_.freePort(port2); }
diff --git a/src/anyrtpproxy/connectionList.cpp b/src/anyrtpproxy/connectionList.cpp
index e83a6ba..afda1d8 100644
--- a/src/anyrtpproxy/connectionList.cpp
+++ b/src/anyrtpproxy/connectionList.cpp
@@ -40,7 +40,7 @@ ConnectionList::~ConnectionList()
{
}
-void ConnectionList::addConnection(ConnectionParam& conn, u_int16_t mux)
+void ConnectionList::addConnection(ConnectionParam& conn, uint16_t mux)
{
}
@@ -59,7 +59,7 @@ ConnectionMap::iterator ConnectionList::getEndUnlocked()
return connections_.end();
}
-const ConnectionMap::iterator ConnectionList::getConnection(u_int16_t mux)
+const ConnectionMap::iterator ConnectionList::getConnection(uint16_t mux)
{
Lock lock(mutex_);
ConnectionMap::iterator it = connections_.find(mux);
@@ -67,7 +67,7 @@ const ConnectionMap::iterator ConnectionList::getConnection(u_int16_t mux)
}
-ConnectionParam& ConnectionList::getOrNewConnectionUnlocked(u_int16_t mux)
+ConnectionParam& ConnectionList::getOrNewConnectionUnlocked(uint16_t mux)
{
ConnectionMap::iterator it = connections_.find(mux);
return it->second;
diff --git a/src/anyrtpproxy/connectionList.h b/src/anyrtpproxy/connectionList.h
index 62da471..8df0781 100644
--- a/src/anyrtpproxy/connectionList.h
+++ b/src/anyrtpproxy/connectionList.h
@@ -39,19 +39,19 @@
#include "../datatypes.h"
#include "../connectionParam.h"
#include "../networkAddress.h"
-typedef std::map<u_int16_t, ConnectionParam> ConnectionMap;
+typedef std::map<uint16_t, ConnectionParam> ConnectionMap;
class ConnectionList
{
public:
ConnectionList();
~ConnectionList();
- void addConnection(ConnectionParam& conn, u_int16_t mux);
- const ConnectionMap::iterator getConnection(u_int16_t mux);
+ void addConnection(ConnectionParam& conn, uint16_t mux);
+ const ConnectionMap::iterator getConnection(uint16_t mux);
const ConnectionMap::iterator getEnd();
ConnectionMap::iterator getEndUnlocked();
ConnectionMap::iterator getBeginUnlocked();
- ConnectionParam& getOrNewConnectionUnlocked(u_int16_t mux);
+ ConnectionParam& getOrNewConnectionUnlocked(uint16_t mux);
bool empty();
void clear();
Mutex& getMutex();
diff --git a/src/anyrtpproxy/options.cpp b/src/anyrtpproxy/options.cpp
index 3fd9975..218fd56 100644
--- a/src/anyrtpproxy/options.cpp
+++ b/src/anyrtpproxy/options.cpp
@@ -384,23 +384,23 @@ Options& Options::setLocalSyncPort(std::string l)
return *this;
}
-u_int16_t Options::getRtpStartPort()
+uint16_t Options::getRtpStartPort()
{
return rtp_start_port_;
}
-Options& Options::setRtpStartPort(u_int16_t l)
+Options& Options::setRtpStartPort(uint16_t l)
{
rtp_start_port_ = l;
return *this;
}
-u_int16_t Options::getRtpEndPort()
+uint16_t Options::getRtpEndPort()
{
return rtp_end_port_;
}
-Options& Options::setRtpEndPort(u_int16_t l)
+Options& Options::setRtpEndPort(uint16_t l)
{
rtp_end_port_ = l;
return *this;
diff --git a/src/anyrtpproxy/options.h b/src/anyrtpproxy/options.h
index 8188831..cf32c87 100644
--- a/src/anyrtpproxy/options.h
+++ b/src/anyrtpproxy/options.h
@@ -90,10 +90,10 @@ public:
Options& setLocalSyncAddr(std::string l);
std::string getLocalSyncPort();
Options& setLocalSyncPort(std::string l);
- u_int16_t getRtpStartPort();
- Options& setRtpStartPort(u_int16_t l);
- u_int16_t getRtpEndPort();
- Options& setRtpEndPort(u_int16_t l);
+ uint16_t getRtpStartPort();
+ Options& setRtpStartPort(uint16_t l);
+ uint16_t getRtpEndPort();
+ Options& setRtpEndPort(uint16_t l);
ConnectToList getConnectTo();
private:
@@ -129,8 +129,8 @@ private:
std::string local_sync_addr_;
std::string local_sync_port_;
std::string local_addr_;
- u_int16_t rtp_start_port_;
- u_int16_t rtp_end_port_;
+ uint16_t rtp_start_port_;
+ uint16_t rtp_end_port_;
ConnectToList connect_to_;
Host control_interface_;
};
diff --git a/src/anyrtpproxy/portWindow.cpp b/src/anyrtpproxy/portWindow.cpp
index ed23686..3ef1767 100644
--- a/src/anyrtpproxy/portWindow.cpp
+++ b/src/anyrtpproxy/portWindow.cpp
@@ -32,7 +32,7 @@
#include "portWindow.h"
-PortWindow::PortWindow(u_int16_t start, u_int16_t end) : start_port_(start), end_port_(end)
+PortWindow::PortWindow(uint16_t start, uint16_t end) : start_port_(start), end_port_(end)
{
}
@@ -46,7 +46,7 @@ PortWindow::PortSet::size_type PortWindow::getLength()
return ports_.size();
}
-bool PortWindow::hasPort(u_int16_t port)
+bool PortWindow::hasPort(uint16_t port)
{
Lock lock(mutex_);
@@ -57,7 +57,7 @@ bool PortWindow::hasPort(u_int16_t port)
return true;
}
-bool PortWindow::freePort(u_int16_t port)
+bool PortWindow::freePort(uint16_t port)
{
Lock lock(mutex_);
@@ -69,10 +69,10 @@ bool PortWindow::freePort(u_int16_t port)
return true;
}
-u_int16_t PortWindow::newPort()
+uint16_t PortWindow::newPort()
{
Lock lock(mutex_);
- u_int16_t port= start_port_;
+ uint16_t port= start_port_;
while(port<end_port_ && ports_.find(port) !=ports_.end()) {
port++;
}
diff --git a/src/anyrtpproxy/portWindow.h b/src/anyrtpproxy/portWindow.h
index 74cd4ed..d552ae1 100644
--- a/src/anyrtpproxy/portWindow.h
+++ b/src/anyrtpproxy/portWindow.h
@@ -40,21 +40,21 @@
class PortWindow
{
public:
- typedef std::set<u_int16_t> PortSet;
+ typedef std::set<uint16_t> PortSet;
- PortWindow(u_int16_t,u_int16_t);
+ PortWindow(uint16_t,uint16_t);
~PortWindow();
PortSet::size_type getLength();
- bool hasPort(u_int16_t);
- bool freePort(u_int16_t);
- u_int16_t newPort();
+ bool hasPort(uint16_t);
+ bool freePort(uint16_t);
+ uint16_t newPort();
void clear();
private:
- u_int16_t start_port_;
- u_int16_t end_port_;
+ uint16_t start_port_;
+ uint16_t end_port_;
::Mutex mutex_;
PortSet ports_;
diff --git a/src/anyrtpproxy/rtpSession.h b/src/anyrtpproxy/rtpSession.h
index 3247dcc..cfdd36c 100644
--- a/src/anyrtpproxy/rtpSession.h
+++ b/src/anyrtpproxy/rtpSession.h
@@ -82,13 +82,13 @@ private:
// address of local_end1 and local_end2 are always equal
std::string local_addr(local_end1_.address().to_string());
- u_int16_t local_port1 = local_end1_.port();
- u_int16_t local_port2 = local_end2_.port();
+ uint16_t local_port1 = local_end1_.port();
+ uint16_t local_port2 = local_end2_.port();
std::string remote_addr1(remote_end1_.address().to_string());
- u_int16_t remote_port1 = remote_end1_.port();
+ uint16_t remote_port1 = remote_end1_.port();
std::string remote_addr2(remote_end2_.address().to_string());
- u_int16_t remote_port2 = remote_end2_.port();
+ uint16_t remote_port2 = remote_end2_.port();
ar& dead_;
ar& complete_;
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp
index 43c4ada..4f61353 100644
--- a/src/anytun-config.cpp
+++ b/src/anytun-config.cpp
@@ -51,7 +51,7 @@
-void createConnection(const PacketSourceEndpoint& remote_end, ConnectionList& cl, u_int16_t seqSize, SyncQueue& queue, mux_t mux, Semaphore& sem)
+void createConnection(const PacketSourceEndpoint& remote_end, ConnectionList& cl, uint16_t seqSize, SyncQueue& queue, mux_t mux, Semaphore& sem)
{
SeqWindow* seq = new SeqWindow(seqSize);
seq_nr_t seq_nr_ = 0;
@@ -87,7 +87,7 @@ void createConnection(const PacketSourceEndpoint& remote_end, ConnectionList& cl
sem.up();
}
-void createConnectionResolver(PacketSourceResolverIt& it, ConnectionList& cl, u_int16_t seqSize, SyncQueue& queue, mux_t mux, Semaphore& sem)
+void createConnectionResolver(PacketSourceResolverIt& it, ConnectionList& cl, uint16_t seqSize, SyncQueue& queue, mux_t mux, Semaphore& sem)
{
createConnection(*it, cl, seqSize, queue, mux, sem);
}
diff --git a/src/anytun.cpp b/src/anytun.cpp
index 16c20b4..d125ee9 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -144,7 +144,7 @@ void sender(TunDevice* dev, PacketSource* src)
PlainPacket plain_packet(MAX_PACKET_LENGTH);
EncryptedPacket encrypted_packet(MAX_PACKET_LENGTH, gOpt.getAuthTagLength());
- u_int16_t mux = gOpt.getMux();
+ uint16_t mux = gOpt.getMux();
PacketSourceEndpoint emptyEndpoint;
while(1) {
plain_packet.setLength(MAX_PACKET_LENGTH);
@@ -157,7 +157,7 @@ void sender(TunDevice* dev, PacketSource* src)
continue; // silently ignore device read errors, this is probably no good idea...
}
- if(static_cast<u_int32_t>(len) < PlainPacket::getHeaderLength()) {
+ if(static_cast<uint32_t>(len) < PlainPacket::getHeaderLength()) {
continue; // ignore short packets
}
plain_packet.setPayloadLength(len);
@@ -233,7 +233,7 @@ void receiver(TunDevice* dev, PacketSource* src)
std::auto_ptr<Cipher> c(CipherFactory::create(gOpt.getCipher(), KD_INBOUND));
std::auto_ptr<AuthAlgo> a(AuthAlgoFactory::create(gOpt.getAuthAlgo(), KD_INBOUND));
- u_int32_t auth_tag_length = gOpt.getAuthTagLength();
+ uint32_t auth_tag_length = gOpt.getAuthTagLength();
EncryptedPacket encrypted_packet(MAX_PACKET_LENGTH, auth_tag_length);
PlainPacket plain_packet(MAX_PACKET_LENGTH);
@@ -257,7 +257,7 @@ void receiver(TunDevice* dev, PacketSource* src)
continue; // silently ignore socket recv errors, this is probably no good idea...
}
- if(static_cast<u_int32_t>(len) < (EncryptedPacket::getHeaderLength() + auth_tag_length)) {
+ if(static_cast<uint32_t>(len) < (EncryptedPacket::getHeaderLength() + auth_tag_length)) {
continue; // ignore short packets
}
encrypted_packet.setLength(len);
@@ -429,7 +429,7 @@ int main(int argc, char* argv[])
NetworkList::const_iterator rit;
for(rit = routes.begin(); rit != routes.end(); ++rit) {
NetworkAddress addr(rit->net_addr);
- NetworkPrefix prefix(addr, static_cast<u_int8_t>(rit->prefix_length));
+ NetworkPrefix prefix(addr, static_cast<uint8_t>(rit->prefix_length));
gRoutingTable.addRoute(prefix, gOpt.getMux());
}
if(connect_to.begin() == connect_to.end() || gOpt.getDevType()!="tun") {
diff --git a/src/authAlgo.cpp b/src/authAlgo.cpp
index 75f6a86..8317e9e 100644
--- a/src/authAlgo.cpp
+++ b/src/authAlgo.cpp
@@ -101,17 +101,17 @@ void Sha1AuthAlgo::generate(KeyDerivation& kd, EncryptedPacket& packet)
gcry_md_reset(handle_);
gcry_md_write(handle_, packet.getAuthenticatedPortion(), packet.getAuthenticatedPortionLength());
gcry_md_final(handle_);
- u_int8_t* hmac = gcry_md_read(handle_, 0);
+ uint8_t* hmac = gcry_md_read(handle_, 0);
#else
HMAC_Init_ex(&ctx_, key_.getBuf(), key_.getLength(), EVP_sha1(), NULL);
- u_int8_t hmac[DIGEST_LENGTH];
+ uint8_t hmac[DIGEST_LENGTH];
HMAC_Update(&ctx_, packet.getAuthenticatedPortion(), packet.getAuthenticatedPortionLength());
HMAC_Final(&ctx_, hmac, NULL);
#endif
- u_int8_t* tag = packet.getAuthTag();
- u_int32_t length = (packet.getAuthTagLength() < DIGEST_LENGTH) ? packet.getAuthTagLength() : DIGEST_LENGTH;
+ uint8_t* tag = packet.getAuthTag();
+ uint32_t length = (packet.getAuthTagLength() < DIGEST_LENGTH) ? packet.getAuthTagLength() : DIGEST_LENGTH;
if(length > DIGEST_LENGTH) {
std::memset(tag, 0, packet.getAuthTagLength());
@@ -144,32 +144,30 @@ bool Sha1AuthAlgo::checkTag(KeyDerivation& kd, EncryptedPacket& packet)
gcry_md_reset(handle_);
gcry_md_write(handle_, packet.getAuthenticatedPortion(), packet.getAuthenticatedPortionLength());
gcry_md_final(handle_);
- u_int8_t* hmac = gcry_md_read(handle_, 0);
+ uint8_t* hmac = gcry_md_read(handle_, 0);
#else
HMAC_Init_ex(&ctx_, key_.getBuf(), key_.getLength(), EVP_sha1(), NULL);
- u_int8_t hmac[DIGEST_LENGTH];
+ uint8_t hmac[DIGEST_LENGTH];
HMAC_Update(&ctx_, packet.getAuthenticatedPortion(), packet.getAuthenticatedPortionLength());
HMAC_Final(&ctx_, hmac, NULL);
#endif
- u_int8_t* tag = packet.getAuthTag();
- u_int32_t length = (packet.getAuthTagLength() < DIGEST_LENGTH) ? packet.getAuthTagLength() : DIGEST_LENGTH;
+ uint8_t* tag = packet.getAuthTag();
+ uint32_t length = (packet.getAuthTagLength() < DIGEST_LENGTH) ? packet.getAuthTagLength() : DIGEST_LENGTH;
if(length > DIGEST_LENGTH)
- for(u_int32_t i=0; i < (packet.getAuthTagLength() - DIGEST_LENGTH); ++i)
+ for(uint32_t i=0; i < (packet.getAuthTagLength() - DIGEST_LENGTH); ++i)
if(tag[i]) { return false; }
int ret = std::memcmp(&tag[packet.getAuthTagLength() - length], &hmac[DIGEST_LENGTH - length], length);
packet.removeAuthTag();
- if(ret) {
- return false;
- }
-
+ if(ret) {
+ return false;
+ }
+
return true;
-
}
#endif
-
diff --git a/src/authAlgo.h b/src/authAlgo.h
index c616f84..663962f 100644
--- a/src/authAlgo.h
+++ b/src/authAlgo.h
@@ -76,7 +76,7 @@ public:
void generate(KeyDerivation& kd, EncryptedPacket& packet);
bool checkTag(KeyDerivation& kd, EncryptedPacket& packet);
- static const u_int32_t DIGEST_LENGTH = 0;
+ static const uint32_t DIGEST_LENGTH = 0;
};
#ifndef NO_CRYPT
@@ -92,7 +92,7 @@ public:
void generate(KeyDerivation& kd, EncryptedPacket& packet);
bool checkTag(KeyDerivation& kd, EncryptedPacket& packet);
- static const u_int32_t DIGEST_LENGTH = 20;
+ static const uint32_t DIGEST_LENGTH = 20;
private:
#ifndef USE_SSL_CRYPTO
diff --git a/src/authAlgoFactory.cpp b/src/authAlgoFactory.cpp
index c96027a..0cd22ce 100644
--- a/src/authAlgoFactory.cpp
+++ b/src/authAlgoFactory.cpp
@@ -52,7 +52,7 @@ AuthAlgo* AuthAlgoFactory::create(std::string const& type, kd_dir_t dir)
}
}
-u_int32_t AuthAlgoFactory::getDigestLength(std::string const& type)
+uint32_t AuthAlgoFactory::getDigestLength(std::string const& type)
{
if(type == "null") {
return NullAuthAlgo::DIGEST_LENGTH;
@@ -66,4 +66,3 @@ u_int32_t AuthAlgoFactory::getDigestLength(std::string const& type)
throw std::invalid_argument("auth algo not available");
}
}
-
diff --git a/src/authAlgoFactory.h b/src/authAlgoFactory.h
index 597539c..86a4c38 100644
--- a/src/authAlgoFactory.h
+++ b/src/authAlgoFactory.h
@@ -42,7 +42,7 @@ class AuthAlgoFactory
{
public:
static AuthAlgo* create(std::string const& type, kd_dir_t dir);
- static u_int32_t getDigestLength(std::string const& type);
+ static uint32_t getDigestLength(std::string const& type);
private:
AuthAlgoFactory();
diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp
index 87f8578..b4b5e29 100644
--- a/src/bsd/tunDevice.cpp
+++ b/src/bsd/tunDevice.cpp
@@ -54,7 +54,7 @@
#define DEVICE_FILE_MAX 255
-TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400),sys_exec_(NULL)
+TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400),sys_exec_(NULL)
{
std::string device_file = "/dev/";
bool dynamic = true;
@@ -80,7 +80,7 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
AnytunError::throwErr() << "unable to recognize type of device (tun or tap)";
}
- u_int32_t dev_id=0;
+ uint32_t dev_id=0;
if(dynamic) {
for(; dev_id <= DEVICE_FILE_MAX; ++dev_id) {
std::ostringstream ds;
@@ -211,7 +211,7 @@ int TunDevice::fix_return(int ret, size_t pi_length) const
return (static_cast<size_t>(ret) > pi_length ? (ret - pi_length) : 0);
}
-int TunDevice::read(u_int8_t* buf, u_int32_t len)
+int TunDevice::read(uint8_t* buf, uint32_t len)
{
if(fd_ < 0) {
return -1;
@@ -219,7 +219,7 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
if(with_pi_) {
struct iovec iov[2];
- u_int32_t type;
+ uint32_t type;
iov[0].iov_base = &type;
iov[0].iov_len = sizeof(type);
@@ -231,7 +231,7 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
}
}
-int TunDevice::write(u_int8_t* buf, u_int32_t len)
+int TunDevice::write(uint8_t* buf, uint32_t len)
{
if(fd_ < 0) {
return -1;
@@ -243,7 +243,7 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len)
if(with_pi_) {
struct iovec iov[2];
- u_int32_t type;
+ uint32_t type;
struct ip* hdr = reinterpret_cast<struct ip*>(buf);
type = 0;
diff --git a/src/buffer.cpp b/src/buffer.cpp
index c4b0c5c..320129d 100644
--- a/src/buffer.cpp
+++ b/src/buffer.cpp
@@ -44,10 +44,10 @@ Buffer::Buffer(bool allow_realloc) : buf_(0), length_(0), real_length_(0), allow
{
}
-Buffer::Buffer(u_int32_t length, bool allow_realloc) : length_(length), real_length_(length_ + Buffer::OVER_SIZE_),
+Buffer::Buffer(uint32_t length, bool allow_realloc) : length_(length), real_length_(length_ + Buffer::OVER_SIZE_),
allow_realloc_(allow_realloc)
{
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
@@ -56,7 +56,7 @@ Buffer::Buffer(u_int32_t length, bool allow_realloc) : length_(length), real_len
std::memset(buf_, 0, real_length_);
}
-Buffer::Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc) : length_(length), real_length_(length + Buffer::OVER_SIZE_),
+Buffer::Buffer(uint8_t* data, uint32_t length, bool allow_realloc) : length_(length), real_length_(length + Buffer::OVER_SIZE_),
allow_realloc_(allow_realloc)
{
if(!data) {
@@ -65,7 +65,7 @@ Buffer::Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc) : length_(l
return;
}
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
@@ -74,22 +74,22 @@ Buffer::Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc) : length_(l
std::memcpy(buf_, data, length_);
}
-Buffer::Buffer(std::string hex_data, bool allow_realloc) : length_(static_cast<u_int32_t>(hex_data.size())/2),
+Buffer::Buffer(std::string hex_data, bool allow_realloc) : length_(static_cast<uint32_t>(hex_data.size())/2),
real_length_(length_ + Buffer::OVER_SIZE_),
allow_realloc_(allow_realloc)
{
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
throw std::bad_alloc();
}
- for(u_int32_t i=0; i<length_; ++i) {
- u_int32_t tmp;
+ for(uint32_t i=0; i<length_; ++i) {
+ uint32_t tmp;
std::istringstream ss(std::string(hex_data.c_str(), i*2, 2));
if(!(ss >> std::hex >> tmp)) { tmp = 0; }
- buf_[i] = static_cast<u_int8_t>(tmp);
+ buf_[i] = static_cast<uint8_t>(tmp);
}
}
@@ -102,7 +102,7 @@ Buffer::~Buffer()
Buffer::Buffer(const Buffer& src) : length_(src.length_), real_length_(src.real_length_), allow_realloc_(src.allow_realloc_)
{
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
@@ -121,7 +121,7 @@ void Buffer::operator=(const Buffer& src)
real_length_ = src.real_length_;
allow_realloc_ = src.allow_realloc_;
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
@@ -145,23 +145,23 @@ bool Buffer::operator==(const Buffer& cmp) const
Buffer Buffer::operator^(const Buffer& xor_by) const
{
- u_int32_t res_length = (xor_by.length_ > length_) ? xor_by.length_ : length_;
- u_int32_t min_length = (xor_by.length_ < length_) ? xor_by.length_ : length_;
+ uint32_t res_length = (xor_by.length_ > length_) ? xor_by.length_ : length_;
+ uint32_t min_length = (xor_by.length_ < length_) ? xor_by.length_ : length_;
Buffer res(res_length);
- for(u_int32_t index = 0; index < min_length; index++) {
+ for(uint32_t index = 0; index < min_length; index++) {
res[index] = buf_[index] ^ xor_by[index];
}
return res;
}
-u_int32_t Buffer::getLength() const
+uint32_t Buffer::getLength() const
{
return length_;
}
-void Buffer::setLength(u_int32_t new_length)
+void Buffer::setLength(uint32_t new_length)
{
if(new_length == length_) {
return;
@@ -172,13 +172,13 @@ void Buffer::setLength(u_int32_t new_length)
throw std::out_of_range("buffer::setLength() - reallocation not allowed for this Buffer");
}
- u_int8_t* old_buf = buf_;
- u_int32_t old_length = length_;
+ uint8_t* old_buf = buf_;
+ uint32_t old_length = length_;
length_ = new_length;
real_length_ = length_ + Buffer::OVER_SIZE_;
- buf_ = new u_int8_t[real_length_];
+ buf_ = new uint8_t[real_length_];
if(!buf_) {
length_ = 0;
real_length_ = 0;
@@ -204,12 +204,12 @@ void Buffer::setLength(u_int32_t new_length)
}
-u_int8_t* Buffer::getBuf()
+uint8_t* Buffer::getBuf()
{
return buf_;
}
-u_int8_t& Buffer::operator[](u_int32_t index)
+uint8_t& Buffer::operator[](uint32_t index)
{
if(index >= length_) {
throw std::out_of_range("buffer::operator[]");
@@ -218,7 +218,7 @@ u_int8_t& Buffer::operator[](u_int32_t index)
return buf_[index];
}
-u_int8_t Buffer::operator[](u_int32_t index) const
+uint8_t Buffer::operator[](uint32_t index) const
{
if(index >= length_) {
throw std::out_of_range("buffer::operator[] const");
@@ -227,7 +227,7 @@ u_int8_t Buffer::operator[](u_int32_t index) const
return buf_[index];
}
-Buffer::operator u_int8_t*()
+Buffer::operator uint8_t*()
{
return buf_;
}
@@ -236,8 +236,8 @@ std::string Buffer::getHexDump() const
{
std::stringstream ss;
ss << "Length=" << length_ << std::endl << std::hex << std::uppercase;
- for(u_int32_t index = 0; index < length_; index++) {
- ss << std::setw(2) << std::setfill('0') << u_int32_t(buf_[index]) << " ";
+ for(uint32_t index = 0; index < length_; index++) {
+ ss << std::setw(2) << std::setfill('0') << uint32_t(buf_[index]) << " ";
if(!((index+1) % 16)) {
ss << std::endl;
continue;
@@ -253,8 +253,8 @@ std::string Buffer::getHexDumpOneLine() const
{
std::stringstream ss;
ss << length_ << " Bytes,'" << std::hex << std::uppercase;
- for(u_int32_t index = 0; index < length_; index++) {
- ss << std::setw(2) << std::setfill('0') << u_int32_t(buf_[index]);
+ for(uint32_t index = 0; index < length_; index++) {
+ ss << std::setw(2) << std::setfill('0') << uint32_t(buf_[index]);
}
ss << "'";
return ss.str();
diff --git a/src/buffer.h b/src/buffer.h
index 4dafd5e..12e771f 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -43,8 +43,8 @@ class Buffer
{
public:
Buffer(bool allow_realloc = true);
- Buffer(u_int32_t length, bool allow_realloc = true);
- Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc = true);
+ Buffer(uint32_t length, bool allow_realloc = true);
+ Buffer(uint8_t* data, uint32_t length, bool allow_realloc = true);
Buffer(std::string hex_data, bool allow_realloc = true);
virtual ~Buffer();
Buffer(const Buffer& src);
@@ -52,27 +52,27 @@ public:
bool operator==(const Buffer& cmp) const;
Buffer operator^(const Buffer& xor_by) const;
- u_int32_t getLength() const;
- virtual void setLength(u_int32_t new_length);
- u_int8_t* getBuf();
- u_int8_t& operator[](u_int32_t index);
- u_int8_t operator[](u_int32_t index) const;
+ uint32_t getLength() const;
+ virtual void setLength(uint32_t new_length);
+ uint8_t* getBuf();
+ uint8_t& operator[](uint32_t index);
+ uint8_t operator[](uint32_t index) const;
std::string getHexDump() const;
std::string getHexDumpOneLine() const;
bool isReallocAllowed() const;
- operator u_int8_t*();
+ operator uint8_t*();
protected:
virtual void reinit() {};
- u_int8_t* buf_;
- u_int32_t length_;
- u_int32_t real_length_;
+ uint8_t* buf_;
+ uint32_t length_;
+ uint32_t real_length_;
bool allow_realloc_;
- static const u_int32_t OVER_SIZE_ = 100;
+ static const uint32_t OVER_SIZE_ = 100;
};
#endif
diff --git a/src/cipher.cpp b/src/cipher.cpp
index ee77001..a10e6c4 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -44,7 +44,7 @@
void Cipher::encrypt(KeyDerivation& kd, PlainPacket& in, EncryptedPacket& out, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
- u_int32_t len = cipher(kd, in, in.getLength(), out.getPayload(), out.getPayloadLength(), seq_nr, sender_id, mux);
+ uint32_t len = cipher(kd, in, in.getLength(), out.getPayload(), out.getPayloadLength(), seq_nr, sender_id, mux);
out.setSenderId(sender_id);
out.setSeqNr(seq_nr);
out.setMux(mux);
@@ -53,20 +53,20 @@ void Cipher::encrypt(KeyDerivation& kd, PlainPacket& in, EncryptedPacket& out, s
void Cipher::decrypt(KeyDerivation& kd, EncryptedPacket& in, PlainPacket& out)
{
- u_int32_t len = decipher(kd, in.getPayload() , in.getPayloadLength(), out, out.getLength(), in.getSeqNr(), in.getSenderId(), in.getMux());
+ uint32_t len = decipher(kd, in.getPayload() , in.getPayloadLength(), out, out.getLength(), in.getSeqNr(), in.getSenderId(), in.getMux());
out.setLength(len);
}
//******* NullCipher *******
-u_int32_t NullCipher::cipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
+uint32_t NullCipher::cipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
std::memcpy(out, in, (ilen < olen) ? ilen : olen);
return (ilen < olen) ? ilen : olen;
}
-u_int32_t NullCipher::decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
+uint32_t NullCipher::decipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
std::memcpy(out, in, (ilen < olen) ? ilen : olen);
return (ilen < olen) ? ilen : olen;
@@ -75,17 +75,17 @@ u_int32_t NullCipher::decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen,
#ifndef NO_CRYPT
//****** AesIcmCipher ******
-AesIcmCipher::AesIcmCipher(kd_dir_t d) : Cipher(d), key_(u_int32_t(DEFAULT_KEY_LENGTH/8)), salt_(u_int32_t(SALT_LENGTH))
+AesIcmCipher::AesIcmCipher(kd_dir_t d) : Cipher(d), key_(uint32_t(DEFAULT_KEY_LENGTH/8)), salt_(uint32_t(SALT_LENGTH))
{
init();
}
-AesIcmCipher::AesIcmCipher(kd_dir_t d, u_int16_t key_length) : Cipher(d), key_(u_int32_t(key_length/8)), salt_(u_int32_t(SALT_LENGTH))
+AesIcmCipher::AesIcmCipher(kd_dir_t d, uint16_t key_length) : Cipher(d), key_(uint32_t(key_length/8)), salt_(uint32_t(SALT_LENGTH))
{
init(key_length);
}
-void AesIcmCipher::init(u_int16_t key_length)
+void AesIcmCipher::init(uint16_t key_length)
{
#ifndef USE_SSL_CRYPTO
handle_ = NULL;
@@ -123,13 +123,13 @@ AesIcmCipher::~AesIcmCipher()
#endif
}
-u_int32_t AesIcmCipher::cipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
+uint32_t AesIcmCipher::cipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
calc(kd, in, ilen, out, olen, seq_nr, sender_id, mux);
return (ilen < olen) ? ilen : olen;
}
-u_int32_t AesIcmCipher::decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
+uint32_t AesIcmCipher::decipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
calc(kd, in, ilen, out, olen, seq_nr, sender_id, mux);
return (ilen < olen) ? ilen : olen;
@@ -148,7 +148,7 @@ void AesIcmCipher::calcCtr(KeyDerivation& kd, seq_nr_t seq_nr, sender_id_t sende
return;
}
-void AesIcmCipher::calc(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
+void AesIcmCipher::calc(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux)
{
#ifndef USE_SSL_CRYPTO
if(!handle_) {
diff --git a/src/cipher.h b/src/cipher.h
index 20f4a69..97d941c 100644
--- a/src/cipher.h
+++ b/src/cipher.h
@@ -57,8 +57,8 @@ public:
void decrypt(KeyDerivation& kd, EncryptedPacket& in, PlainPacket& out);
protected:
- virtual u_int32_t cipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux) = 0;
- virtual u_int32_t decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux) = 0;
+ virtual uint32_t cipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux) = 0;
+ virtual uint32_t decipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux) = 0;
kd_dir_t dir_;
};
@@ -68,8 +68,8 @@ protected:
class NullCipher : public Cipher
{
protected:
- u_int32_t cipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
- u_int32_t decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
+ uint32_t cipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
+ uint32_t decipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
};
#ifndef NO_CRYPT
@@ -79,28 +79,28 @@ class AesIcmCipher : public Cipher
{
public:
AesIcmCipher(kd_dir_t d);
- AesIcmCipher(kd_dir_t d, u_int16_t key_length);
+ AesIcmCipher(kd_dir_t d, uint16_t key_length);
~AesIcmCipher();
- static const u_int16_t DEFAULT_KEY_LENGTH = 128;
- static const u_int16_t CTR_LENGTH = 16;
- static const u_int16_t SALT_LENGTH = 14;
+ static const uint16_t DEFAULT_KEY_LENGTH = 128;
+ static const uint16_t CTR_LENGTH = 16;
+ static const uint16_t SALT_LENGTH = 14;
protected:
- u_int32_t cipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
- u_int32_t decipher(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
+ uint32_t cipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
+ uint32_t decipher(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
private:
- void init(u_int16_t key_length = DEFAULT_KEY_LENGTH);
+ void init(uint16_t key_length = DEFAULT_KEY_LENGTH);
void calcCtr(KeyDerivation& kd, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
- void calc(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
+ void calc(KeyDerivation& kd, uint8_t* in, uint32_t ilen, uint8_t* out, uint32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
#ifndef USE_SSL_CRYPTO
gcry_cipher_hd_t handle_;
#else
AES_KEY aes_key_;
- u_int8_t ecount_buf_[AES_BLOCK_SIZE];
+ uint8_t ecount_buf_[AES_BLOCK_SIZE];
#endif
Buffer key_;
Buffer salt_;
@@ -109,18 +109,18 @@ private:
#pragma pack(push, 1)
#endif
union ATTR_PACKED cipher_aesctr_ctr_union {
- u_int8_t buf_[CTR_LENGTH];
+ uint8_t buf_[CTR_LENGTH];
struct ATTR_PACKED {
- u_int8_t buf_[SALT_LENGTH];
- u_int16_t zero_;
+ uint8_t buf_[SALT_LENGTH];
+ uint16_t zero_;
} salt_;
struct ATTR_PACKED {
- u_int8_t fill_[SALT_LENGTH - sizeof(mux_t) - sizeof(sender_id_t) - 2*sizeof(u_int8_t) - sizeof(seq_nr_t)];
+ uint8_t fill_[SALT_LENGTH - sizeof(mux_t) - sizeof(sender_id_t) - 2*sizeof(uint8_t) - sizeof(seq_nr_t)];
mux_t mux_;
sender_id_t sender_id_;
- u_int8_t empty_[2];
+ uint8_t empty_[2];
seq_nr_t seq_nr_;
- u_int16_t zero_;
+ uint16_t zero_;
} params_;
} ctr_;
#ifdef _MSC_VER
diff --git a/src/connectionList.cpp b/src/connectionList.cpp
index 2893dc2..4287a21 100644
--- a/src/connectionList.cpp
+++ b/src/connectionList.cpp
@@ -69,7 +69,7 @@ ConnectionList::~ConnectionList()
// }
}
-void ConnectionList::addConnection(ConnectionParam& conn, u_int16_t mux)
+void ConnectionList::addConnection(ConnectionParam& conn, uint16_t mux)
{
Lock lock(mutex_);
@@ -103,7 +103,7 @@ ConnectionMap::iterator ConnectionList::getEndUnlocked()
return connections_.end();
}
-const ConnectionMap::iterator ConnectionList::getConnection(u_int16_t mux)
+const ConnectionMap::iterator ConnectionList::getConnection(uint16_t mux)
{
Lock lock(mutex_);
ConnectionMap::iterator it = connections_.find(mux);
@@ -111,19 +111,19 @@ const ConnectionMap::iterator ConnectionList::getConnection(u_int16_t mux)
}
-ConnectionParam& ConnectionList::getOrNewConnectionUnlocked(u_int16_t mux)
+ConnectionParam& ConnectionList::getOrNewConnectionUnlocked(uint16_t mux)
{
ConnectionMap::iterator it = connections_.find(mux);
if(it!=connections_.end()) {
return it->second;
}
- u_int8_t key[] = {
+ uint8_t key[] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'
};
- u_int8_t salt[] = {
+ uint8_t salt[] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n'
};
diff --git a/src/connectionList.h b/src/connectionList.h
index 949889d..750a142 100644
--- a/src/connectionList.h
+++ b/src/connectionList.h
@@ -40,7 +40,7 @@
#include "datatypes.h"
#include "connectionParam.h"
#include "networkAddress.h"
-typedef std::map<u_int16_t, ConnectionParam> ConnectionMap;
+typedef std::map<uint16_t, ConnectionParam> ConnectionMap;
class ConnectionList
{
@@ -48,13 +48,13 @@ public:
ConnectionList();
~ConnectionList();
static ConnectionList& instance();
- void addConnection(ConnectionParam& conn, u_int16_t mux);
- const ConnectionMap::iterator getConnection(u_int16_t mux);
+ void addConnection(ConnectionParam& conn, uint16_t mux);
+ const ConnectionMap::iterator getConnection(uint16_t mux);
const ConnectionMap::iterator getEnd();
ConnectionMap::iterator getEndUnlocked();
ConnectionMap::iterator getBeginUnlocked();
const ConnectionMap::iterator getBegin();
- ConnectionParam& getOrNewConnectionUnlocked(u_int16_t mux);
+ ConnectionParam& getOrNewConnectionUnlocked(uint16_t mux);
bool empty();
void clear();
Mutex& getMutex();
diff --git a/src/connectionParam.h b/src/connectionParam.h
index 072d0a1..563391c 100644
--- a/src/connectionParam.h
+++ b/src/connectionParam.h
@@ -60,7 +60,7 @@ private:
void serialize(Archive& ar, const unsigned int version) {
Lock lock(mutex_);
std::string remote_host(remote_end_.address().to_string());
- u_int16_t remote_port = remote_end_.port();
+ uint16_t remote_port = remote_end_.port();
ar& kd_;
ar& seq_window_;
ar& seq_nr_;
diff --git a/src/datatypes.h b/src/datatypes.h
index 3364fe3..cc13fb1 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -36,23 +36,24 @@
#include <boost/cstdint.hpp>
#include <boost/integer_traits.hpp>
-typedef boost::uint8_t u_int8_t;
-typedef boost::uint16_t u_int16_t;
-typedef boost::uint32_t u_int32_t;
-typedef boost::uint64_t u_int64_t;
-typedef boost::int8_t int8_t;
-typedef boost::int16_t int16_t;
-typedef boost::int32_t int32_t;
-typedef boost::int64_t int64_t;
+// should not be necessary on GCC, #ifdef + #include <stdint.h> should do the job; still required on MS VC++9, though.
+using boost::int8_t;
+using boost::uint8_t;
+using boost::int16_t;
+using boost::uint16_t;
+using boost::int32_t;
+using boost::uint32_t;
+using boost::int64_t;
+using boost::uint64_t;
-typedef u_int32_t window_size_t;
+typedef uint32_t window_size_t;
-typedef u_int32_t seq_nr_t;
+typedef uint32_t seq_nr_t;
#define SEQ_NR_MAX 0xFFFFFFFF
-typedef u_int16_t sender_id_t;
-typedef u_int16_t payload_type_t;
-typedef u_int16_t mux_t;
-typedef u_int32_t satp_prf_label_t;
+typedef uint16_t sender_id_t;
+typedef uint16_t payload_type_t;
+typedef uint16_t mux_t;
+typedef uint32_t satp_prf_label_t;
typedef enum { ANY, IPV4_ONLY, IPV6_ONLY } ResolvAddrType;
diff --git a/src/deviceConfig.hpp b/src/deviceConfig.hpp
index fa882b5..ede6f34 100644
--- a/src/deviceConfig.hpp
+++ b/src/deviceConfig.hpp
@@ -44,7 +44,7 @@ enum device_type_t { TYPE_UNDEF, TYPE_TUN, TYPE_TAP };
class DeviceConfig
{
public:
- DeviceConfig(std::string dev_name ,std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix, u_int16_t mtu) {
+ DeviceConfig(std::string dev_name ,std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix, uint16_t mtu) {
mtu_ = mtu;
type_ = TYPE_UNDEF;
#ifndef _MSC_VER
@@ -81,8 +81,8 @@ public:
addr_.setNetworkAddress(ipv4, ifcfg_addr.c_str());
}
prefix_ = ifcfg_prefix;
- u_int32_t mask = 0;
- for(u_int16_t i = 0; i < prefix_; ++i) {
+ uint32_t mask = 0;
+ for(uint16_t i = 0; i < prefix_; ++i) {
mask = mask >> 1;
mask |= 0x80000000L;
}
@@ -93,8 +93,8 @@ private:
device_type_t type_;
NetworkAddress addr_;
NetworkAddress netmask_;
- u_int16_t prefix_;
- u_int16_t mtu_;
+ uint16_t prefix_;
+ uint16_t mtu_;
friend class TunDevice;
};
diff --git a/src/encryptedPacket.cpp b/src/encryptedPacket.cpp
index 731074b..466378a 100644
--- a/src/encryptedPacket.cpp
+++ b/src/encryptedPacket.cpp
@@ -40,7 +40,7 @@
#include "log.h"
#include "anytunError.h"
-EncryptedPacket::EncryptedPacket(u_int32_t payload_length, u_int32_t auth_tag_length, bool allow_realloc)
+EncryptedPacket::EncryptedPacket(uint32_t payload_length, uint32_t auth_tag_length, bool allow_realloc)
: Buffer(payload_length + sizeof(struct HeaderStruct), allow_realloc), auth_tag_length_(auth_tag_length)
{
header_ = reinterpret_cast<struct HeaderStruct*>(buf_);
@@ -53,7 +53,7 @@ EncryptedPacket::EncryptedPacket(u_int32_t payload_length, u_int32_t auth_tag_le
}
}
-u_int32_t EncryptedPacket::getHeaderLength()
+uint32_t EncryptedPacket::getHeaderLength()
{
return sizeof(struct HeaderStruct);
}
@@ -117,7 +117,7 @@ void EncryptedPacket::setHeader(seq_nr_t seq_nr, sender_id_t sender_id, mux_t mu
header_->mux = MUX_T_HTON(mux);
}
-u_int32_t EncryptedPacket::getPayloadLength() const
+uint32_t EncryptedPacket::getPayloadLength() const
{
if(!payload_) {
return 0;
@@ -130,7 +130,7 @@ u_int32_t EncryptedPacket::getPayloadLength() const
return (length_ > (sizeof(struct HeaderStruct) + auth_tag_length_)) ? (length_ - sizeof(struct HeaderStruct) - auth_tag_length_) : 0;
}
-void EncryptedPacket::setPayloadLength(u_int32_t payload_length)
+void EncryptedPacket::setPayloadLength(uint32_t payload_length)
{
Buffer::setLength(payload_length + sizeof(struct HeaderStruct));
// depending on allow_realloc buf_ may point to another address
@@ -160,17 +160,17 @@ void EncryptedPacket::reinit()
}
}
-u_int8_t* EncryptedPacket::getPayload()
+uint8_t* EncryptedPacket::getPayload()
{
return payload_;
}
-u_int8_t* EncryptedPacket::getAuthenticatedPortion()
+uint8_t* EncryptedPacket::getAuthenticatedPortion()
{
return buf_;
}
-u_int32_t EncryptedPacket::getAuthenticatedPortionLength()
+uint32_t EncryptedPacket::getAuthenticatedPortionLength()
{
if(!buf_) {
return 0;
@@ -223,12 +223,12 @@ void EncryptedPacket::removeAuthTag()
setLength(length_ - auth_tag_length_);
}
-u_int8_t* EncryptedPacket::getAuthTag()
+uint8_t* EncryptedPacket::getAuthTag()
{
return auth_tag_;
}
-u_int32_t EncryptedPacket::getAuthTagLength()
+uint32_t EncryptedPacket::getAuthTagLength()
{
if(auth_tag_) {
return auth_tag_length_;
diff --git a/src/encryptedPacket.h b/src/encryptedPacket.h
index c73dea8..221c534 100644
--- a/src/encryptedPacket.h
+++ b/src/encryptedPacket.h
@@ -46,7 +46,7 @@ public:
* @param the length of the payload
* @param allow reallocation of buffer
*/
- EncryptedPacket(u_int32_t payload_length, u_int32_t auth_tag_length, bool allow_realloc = false);
+ EncryptedPacket(uint32_t payload_length, uint32_t auth_tag_length, bool allow_realloc = false);
/**
* Packet destructor
@@ -57,7 +57,7 @@ public:
* Get the length of the header
* @return the length of the header
*/
- static u_int32_t getHeaderLength();
+ static uint32_t getHeaderLength();
/**
* Get the sequence number
@@ -107,29 +107,29 @@ public:
* Get the length of the payload
* @return the length of the payload
*/
- u_int32_t getPayloadLength() const;
+ uint32_t getPayloadLength() const;
/**
* Set the length of the payload
* @param length length of the payload
*/
- void setPayloadLength(u_int32_t payload_length);
+ void setPayloadLength(uint32_t payload_length);
/**
* Get the the payload
* @return the Pointer to the payload
*/
- u_int8_t* getPayload();
+ uint8_t* getPayload();
- u_int8_t* getAuthenticatedPortion();
- u_int32_t getAuthenticatedPortionLength();
+ uint8_t* getAuthenticatedPortion();
+ uint32_t getAuthenticatedPortionLength();
void withAuthTag(bool b);
void addAuthTag();
void removeAuthTag();
- u_int8_t* getAuthTag();
- u_int32_t getAuthTagLength();
+ uint8_t* getAuthTag();
+ uint32_t getAuthTagLength();
private:
EncryptedPacket();
@@ -150,9 +150,9 @@ private:
#endif
struct HeaderStruct* header_;
- u_int8_t* payload_;
- u_int8_t* auth_tag_;
- u_int32_t auth_tag_length_;
+ uint8_t* payload_;
+ uint8_t* auth_tag_;
+ uint32_t auth_tag_length_;
};
#endif
diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp
index fac1da6..17d2a7c 100644
--- a/src/keyDerivation.cpp
+++ b/src/keyDerivation.cpp
@@ -61,7 +61,7 @@ void KeyDerivation::setRole(const role_t role)
#ifndef NO_CRYPT
#ifndef NO_PASSPHRASE
-void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length)
+void KeyDerivation::calcMasterKey(std::string passphrase, uint16_t length)
{
cLog.msg(Log::PRIO_NOTICE) << "KeyDerivation: calculating master key from passphrase";
if(!length) {
@@ -79,10 +79,10 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length)
}
#ifndef USE_SSL_CRYPTO
- Buffer digest(static_cast<u_int32_t>(gcry_md_get_algo_dlen(GCRY_MD_SHA256)));
+ Buffer digest(static_cast<uint32_t>(gcry_md_get_algo_dlen(GCRY_MD_SHA256)));
gcry_md_hash_buffer(GCRY_MD_SHA256, digest.getBuf(), passphrase.c_str(), passphrase.length());
#else
- Buffer digest(u_int32_t(SHA256_DIGEST_LENGTH));
+ Buffer digest(uint32_t(SHA256_DIGEST_LENGTH));
SHA256(reinterpret_cast<const unsigned char*>(passphrase.c_str()), passphrase.length(), digest.getBuf());
#endif
master_key_.setLength(length);
@@ -90,7 +90,7 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length)
std::memcpy(master_key_.getBuf(), &digest.getBuf()[digest.getLength() - master_key_.getLength()], master_key_.getLength());
}
-void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length)
+void KeyDerivation::calcMasterSalt(std::string passphrase, uint16_t length)
{
cLog.msg(Log::PRIO_NOTICE) << "KeyDerivation: calculating master salt from passphrase";
if(!length) {
@@ -108,10 +108,10 @@ void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length)
}
#ifndef USE_SSL_CRYPTO
- Buffer digest(static_cast<u_int32_t>(gcry_md_get_algo_dlen(GCRY_MD_SHA1)));
+ Buffer digest(static_cast<uint32_t>(gcry_md_get_algo_dlen(GCRY_MD_SHA1)));
gcry_md_hash_buffer(GCRY_MD_SHA1, digest.getBuf(), passphrase.c_str(), passphrase.length());
#else
- Buffer digest(u_int32_t(SHA_DIGEST_LENGTH));
+ Buffer digest(uint32_t(SHA_DIGEST_LENGTH));
SHA1(reinterpret_cast<const unsigned char*>(passphrase.c_str()), passphrase.length(), digest.getBuf());
#endif
master_salt_.setLength(length);
@@ -179,7 +179,7 @@ AesIcmKeyDerivation::AesIcmKeyDerivation() : KeyDerivation(DEFAULT_KEY_LENGTH)
#endif
}
-AesIcmKeyDerivation::AesIcmKeyDerivation(u_int16_t key_length) : KeyDerivation(key_length)
+AesIcmKeyDerivation::AesIcmKeyDerivation(uint16_t key_length) : KeyDerivation(key_length)
{
#ifndef USE_SSL_CRYPTO
for(int i=0; i<2; i++) {
diff --git a/src/keyDerivation.h b/src/keyDerivation.h
index 15d4988..f34499c 100644
--- a/src/keyDerivation.h
+++ b/src/keyDerivation.h
@@ -67,7 +67,7 @@ class KeyDerivation
{
public:
KeyDerivation() : is_initialized_(false), role_(ROLE_LEFT), key_length_(0), master_salt_(0), master_key_(0) {};
- KeyDerivation(u_int16_t key_length) : is_initialized_(false), role_(ROLE_LEFT), key_length_(key_length), master_salt_(0), master_key_(0) {};
+ KeyDerivation(uint16_t key_length) : is_initialized_(false), role_(ROLE_LEFT), key_length_(key_length), master_salt_(0), master_key_(0) {};
virtual ~KeyDerivation() {};
void setRole(const role_t role);
@@ -83,8 +83,8 @@ protected:
virtual void updateMasterKey() = 0;
#ifndef NO_PASSPHRASE
- void calcMasterKey(std::string passphrase, u_int16_t length);
- void calcMasterSalt(std::string passphrase, u_int16_t length);
+ void calcMasterKey(std::string passphrase, uint16_t length);
+ void calcMasterSalt(std::string passphrase, uint16_t length);
#endif
KeyDerivation(const KeyDerivation& src);
@@ -101,7 +101,7 @@ protected:
bool is_initialized_;
role_t role_;
- u_int16_t key_length_;
+ uint16_t key_length_;
SyncBuffer master_salt_;
SyncBuffer master_key_;
@@ -145,12 +145,12 @@ class AesIcmKeyDerivation : public KeyDerivation
{
public:
AesIcmKeyDerivation();
- AesIcmKeyDerivation(u_int16_t key_length);
+ AesIcmKeyDerivation(uint16_t key_length);
~AesIcmKeyDerivation();
- static const u_int16_t DEFAULT_KEY_LENGTH = 128;
- static const u_int16_t CTR_LENGTH = 16;
- static const u_int16_t SALT_LENGTH = 14;
+ static const uint16_t DEFAULT_KEY_LENGTH = 128;
+ static const uint16_t CTR_LENGTH = 16;
+ static const uint16_t SALT_LENGTH = 14;
void init(Buffer key, Buffer salt, std::string passphrase = "");
bool generate(kd_dir_t dir, satp_prf_label_t label, seq_nr_t seq_nr, Buffer& key);
@@ -172,23 +172,23 @@ private:
gcry_cipher_hd_t handle_[2];
#else
AES_KEY aes_key_[2];
- u_int8_t ecount_buf_[2][AES_BLOCK_SIZE];
+ uint8_t ecount_buf_[2][AES_BLOCK_SIZE];
#endif
#ifdef _MSC_VER
#pragma pack(push, 1)
#endif
union ATTR_PACKED key_derivation_aesctr_ctr_union {
- u_int8_t buf_[CTR_LENGTH];
+ uint8_t buf_[CTR_LENGTH];
struct ATTR_PACKED {
- u_int8_t buf_[SALT_LENGTH];
- u_int16_t zero_;
+ uint8_t buf_[SALT_LENGTH];
+ uint16_t zero_;
} salt_;
struct ATTR_PACKED {
- u_int8_t fill_[SALT_LENGTH - sizeof(satp_prf_label_t) - sizeof(seq_nr_t)];
+ uint8_t fill_[SALT_LENGTH - sizeof(satp_prf_label_t) - sizeof(seq_nr_t)];
satp_prf_label_t label_;
seq_nr_t seq_;
- u_int16_t zero_;
+ uint16_t zero_;
} params_;
} ctr_[2];
#ifdef _MSC_VER
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index 85f90e1..94c2e27 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -50,7 +50,7 @@
#include "anytunError.h"
#include "sysExec.h"
-TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400), sys_exec_(NULL)
+TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400), sys_exec_(NULL)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
@@ -105,7 +105,7 @@ int TunDevice::fix_return(int ret, size_t pi_length) const
return (static_cast<size_t>(ret) > pi_length ? (ret - pi_length) : 0);
}
-int TunDevice::read(u_int8_t* buf, u_int32_t len)
+int TunDevice::read(uint8_t* buf, uint32_t len)
{
if(fd_ < 0) {
return -1;
@@ -125,7 +125,7 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
}
}
-int TunDevice::write(u_int8_t* buf, u_int32_t len)
+int TunDevice::write(uint8_t* buf, uint32_t len)
{
if(fd_ < 0) {
return -1;
diff --git a/src/networkAddress.cpp b/src/networkAddress.cpp
index f3b7544..d489342 100644
--- a/src/networkAddress.cpp
+++ b/src/networkAddress.cpp
@@ -70,7 +70,7 @@ NetworkAddress::NetworkAddress(boost::asio::ip::address_v4 ipv4_address)
ipv4_address_ = ipv4_address;
}
-NetworkAddress::NetworkAddress(u_int64_t ethernet_address)
+NetworkAddress::NetworkAddress(uint64_t ethernet_address)
{
network_address_type_=ethernet;
ethernet_address_=ethernet_address;
@@ -112,7 +112,7 @@ void NetworkAddress::setNetworkAddress(boost::asio::ip::address_v6 addr)
ipv6_address_ = addr;
}
-void NetworkAddress::setNetworkAddress(u_int64_t addr)
+void NetworkAddress::setNetworkAddress(uint64_t addr)
{
network_address_type_=ethernet;
ethernet_address_=addr;
@@ -141,7 +141,7 @@ const boost::asio::ip::address_v6& NetworkAddress::getNetworkAddressV6() const
return ipv6_address_;
}
-const u_int64_t NetworkAddress::getNetworkAdrressEther() const
+const uint64_t NetworkAddress::getNetworkAdrressEther() const
{
if(network_address_type_ != ethernet) {
AnytunError::throwErr() << "wrong address type";
@@ -175,7 +175,7 @@ ipv6_bytes_type NetworkAddress::to_bytes_v6() const
ethernet_bytes_type NetworkAddress::to_bytes_ethernet() const
{
boost::array<unsigned char,6> result;
- u_int64_t ether=ethernet_address_;
+ uint64_t ether=ethernet_address_;
for(int i = 0; i < 6; i++) {
result[i] = (unsigned char)(ether && 0xff);
ether >>= 8;
diff --git a/src/networkAddress.h b/src/networkAddress.h
index df4f788..1d4c602 100644
--- a/src/networkAddress.h
+++ b/src/networkAddress.h
@@ -62,13 +62,13 @@ public:
NetworkAddress(const std::string&);
NetworkAddress(boost::asio::ip::address_v6);
NetworkAddress(boost::asio::ip::address_v4);
- NetworkAddress(u_int64_t);
+ NetworkAddress(uint64_t);
NetworkAddress(const network_address_type_t type, const std::string& address);
~NetworkAddress();
void setNetworkAddress(const network_address_type_t type, const std::string& address);
void setNetworkAddress(boost::asio::ip::address_v4);
void setNetworkAddress(boost::asio::ip::address_v6);
- void setNetworkAddress(u_int64_t);
+ void setNetworkAddress(uint64_t);
network_address_type_t getNetworkAddressType() const;
std::string toString() const;
bool operator<(const NetworkAddress& s) const;
@@ -77,12 +77,12 @@ public:
ethernet_bytes_type to_bytes_ethernet() const;
const boost::asio::ip::address_v4& getNetworkAddressV4() const;
const boost::asio::ip::address_v6& getNetworkAddressV6() const;
- const u_int64_t getNetworkAdrressEther() const;
+ const uint64_t getNetworkAdrressEther() const;
protected:
Mutex mutex_;
boost::asio::ip::address_v4 ipv4_address_;
boost::asio::ip::address_v6 ipv6_address_;
- u_int64_t ethernet_address_;
+ uint64_t ethernet_address_;
network_address_type_t network_address_type_;
private:
NetworkAddress operator=(const NetworkAddress& s);
diff --git a/src/networkPrefix.cpp b/src/networkPrefix.cpp
index a6a2ef4..85b687d 100644
--- a/src/networkPrefix.cpp
+++ b/src/networkPrefix.cpp
@@ -40,7 +40,7 @@ NetworkPrefix::NetworkPrefix(): NetworkAddress(),length_(0)
{
}
-NetworkPrefix::NetworkPrefix(const NetworkAddress& src,u_int8_t length): NetworkAddress(src),length_(length)
+NetworkPrefix::NetworkPrefix(const NetworkAddress& src,uint8_t length): NetworkAddress(src),length_(length)
{
}
@@ -48,12 +48,12 @@ NetworkPrefix::NetworkPrefix(const NetworkPrefix& src): NetworkAddress(src),leng
{
}
-void NetworkPrefix::setNetworkPrefixLength(u_int8_t length)
+void NetworkPrefix::setNetworkPrefixLength(uint8_t length)
{
length_ = length;
}
-u_int8_t NetworkPrefix::getNetworkPrefixLength() const
+uint8_t NetworkPrefix::getNetworkPrefixLength() const
{
return length_;
}
diff --git a/src/networkPrefix.h b/src/networkPrefix.h
index 43adb8c..2c328a7 100644
--- a/src/networkPrefix.h
+++ b/src/networkPrefix.h
@@ -44,16 +44,16 @@ class NetworkPrefix : public NetworkAddress
{
public:
NetworkPrefix();
- NetworkPrefix(const NetworkAddress&, u_int8_t length);
+ NetworkPrefix(const NetworkAddress&, uint8_t length);
NetworkPrefix(const NetworkPrefix&);
- void setNetworkPrefixLength(u_int8_t length);
- u_int8_t getNetworkPrefixLength() const;
+ void setNetworkPrefixLength(uint8_t length);
+ uint8_t getNetworkPrefixLength() const;
bool operator<(const NetworkPrefix& s) const;
private:
operator NetworkAddress();
void operator=(const NetworkPrefix& s);
- u_int8_t length_;
+ uint8_t length_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version) {
diff --git a/src/options.cpp b/src/options.cpp
index 863d457..9682873 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -165,7 +165,7 @@ Options& Options::instance()
return *inst;
}
-Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
+Options::Options() : key_(uint32_t(0)), salt_(uint32_t(0))
{
#if defined(ANYCTR_OPTIONS)
progname_ = "anytun-controld";
@@ -265,7 +265,7 @@ Options::~Options()
if(argc < 1) \
throw syntax_error(str, str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
std::stringstream tmp; \
@@ -284,11 +284,11 @@ Options::~Options()
if(argc < 2) \
throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
if(argv[i+2][0] == '-') { \
- u_int32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
+ uint32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
} \
std::stringstream tmp; \
@@ -306,7 +306,7 @@ Options::~Options()
if(argc < 1) \
throw syntax_error(str, str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
std::stringstream tmp(argv[i+1]); \
@@ -327,7 +327,7 @@ Options::~Options()
if(argc < 1) \
throw syntax_error(str, str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
VALUE = Buffer(std::string(argv[i+1])); \
@@ -344,7 +344,7 @@ Options::~Options()
if(argc < 1) \
throw syntax_error(str, str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
VALUE = argv[i+1]; \
@@ -361,7 +361,7 @@ Options::~Options()
if(argc < 1) \
throw syntax_error(str, str.length()); \
if(argv[i+1][0] == '-') { \
- u_int32_t pos = str.length() + 1; \
+ uint32_t pos = str.length() + 1; \
throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
} \
LIST.push_back(argv[i+1]); \
@@ -530,7 +530,7 @@ void Options::parse_post()
cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
}
- u_int32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
+ uint32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
if(!tag_len_max) { auth_tag_length_ = 0; }
else if(tag_len_max < auth_tag_length_) {
cLog.msg(Log::PRIO_WARNING) << auth_algo_ << " auth algo can't generate tags of length " << auth_tag_length_ << ", using maximum tag length(" << tag_len_max << ")";
@@ -1110,13 +1110,13 @@ Options& Options::setAuthAlgo(std::string a)
return *this;
}
-u_int32_t Options::getAuthTagLength()
+uint32_t Options::getAuthTagLength()
{
ReadersLock lock(mutex);
return auth_tag_length_;
}
-Options& Options::setAuthTagLength(u_int32_t a)
+Options& Options::setAuthTagLength(uint32_t a)
{
WritersLock lock(mutex);
auth_tag_length_ = a;
diff --git a/src/options.h b/src/options.h
index 02b0c1b..70458d5 100644
--- a/src/options.h
+++ b/src/options.h
@@ -66,12 +66,12 @@ class OptionNetwork
public:
OptionNetwork() : net_addr(""), prefix_length(0) {};
OptionNetwork(std::string network) { init(network); };
- OptionNetwork(std::string n, u_int16_t p) : net_addr(n), prefix_length(p) {};
+ OptionNetwork(std::string n, uint16_t p) : net_addr(n), prefix_length(p) {};
void init(std::string network);
std::string net_addr;
- u_int16_t prefix_length;
+ uint16_t prefix_length;
};
typedef std::list<OptionNetwork> NetworkList;
std::istream& operator>>(std::istream& stream, OptionNetwork& network);
@@ -154,8 +154,8 @@ public:
Options& setCipher(std::string c);
std::string getAuthAlgo();
Options& setAuthAlgo(std::string a);
- u_int32_t getAuthTagLength();
- Options& setAuthTagLength(u_int32_t a);
+ uint32_t getAuthTagLength();
+ Options& setAuthTagLength(uint32_t a);
std::string getKdPrf();
Options& setKdPrf(std::string k);
role_t getRole();
@@ -225,7 +225,7 @@ private:
std::string cipher_;
std::string auth_algo_;
- u_int32_t auth_tag_length_;
+ uint32_t auth_tag_length_;
std::string kd_prf_;
role_t role_;
std::string passphrase_;
diff --git a/src/packetSource.cpp b/src/packetSource.cpp
index 9a86ef4..bd3590d 100644
--- a/src/packetSource.cpp
+++ b/src/packetSource.cpp
@@ -95,7 +95,7 @@ void UDPPacketSource::onResolve(PacketSourceResolverIt& it)
std::list<SocketsElement>::iterator it = sockets_.begin();
for(; it != sockets_.end(); ++it) {
it->len_ = MAX_PACKET_LENGTH;
- it->buf_ = new u_int8_t[it->len_];
+ it->buf_ = new uint8_t[it->len_];
if(!it->buf_) {
AnytunError::throwErr() << "memory error";
}
@@ -128,7 +128,7 @@ void UDPPacketSource::recv_thread(std::list<SocketsElement>::iterator it)
result.it_ = it;
for(;;) {
it->sem_->down();
- result.len_ = static_cast<u_int32_t>(it->sock_->receive_from(boost::asio::buffer(it->buf_, it->len_), result.remote_));
+ result.len_ = static_cast<uint32_t>(it->sock_->receive_from(boost::asio::buffer(it->buf_, it->len_), result.remote_));
{
Lock lock(thread_result_mutex_);
thread_result_queue_.push(result);
@@ -137,10 +137,10 @@ void UDPPacketSource::recv_thread(std::list<SocketsElement>::iterator it)
}
}
-u_int32_t UDPPacketSource::recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint& remote)
+uint32_t UDPPacketSource::recv(uint8_t* buf, uint32_t len, PacketSourceEndpoint& remote)
{
if(sockets_.size() == 1) {
- return static_cast<u_int32_t>(sockets_.front().sock_->receive_from(boost::asio::buffer(buf, len), remote));
+ return static_cast<uint32_t>(sockets_.front().sock_->receive_from(boost::asio::buffer(buf, len), remote));
}
thread_result_sem_.down();
@@ -158,7 +158,7 @@ u_int32_t UDPPacketSource::recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoi
return len;
}
-void UDPPacketSource::send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint remote)
+void UDPPacketSource::send(uint8_t* buf, uint32_t len, PacketSourceEndpoint remote)
{
std::list<SocketsElement>::iterator it = sockets_.begin();
for(; it != sockets_.end(); ++it) {
diff --git a/src/packetSource.h b/src/packetSource.h
index 286c9df..bd75be2 100644
--- a/src/packetSource.h
+++ b/src/packetSource.h
@@ -50,8 +50,8 @@ class PacketSource
public:
virtual ~PacketSource() {}
- virtual u_int32_t recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint& remote) = 0;
- virtual void send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint remote) = 0;
+ virtual uint32_t recv(uint8_t* buf, uint32_t len, PacketSourceEndpoint& remote) = 0;
+ virtual void send(uint8_t* buf, uint32_t len, PacketSourceEndpoint remote) = 0;
void waitUntilReady();
@@ -67,8 +67,8 @@ public:
UDPPacketSource(std::string localaddr, std::string port);
~UDPPacketSource();
- u_int32_t recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint& remote);
- void send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint remote);
+ uint32_t recv(uint8_t* buf, uint32_t len, PacketSourceEndpoint& remote);
+ void send(uint8_t* buf, uint32_t len, PacketSourceEndpoint remote);
void onResolve(PacketSourceResolverIt& it);
void onError(const std::runtime_error& e);
@@ -77,8 +77,8 @@ private:
boost::asio::io_service io_service_;
typedef struct {
- u_int8_t* buf_;
- u_int32_t len_;
+ uint8_t* buf_;
+ uint32_t len_;
proto::socket* sock_;
Semaphore* sem_;
} SocketsElement;
@@ -86,7 +86,7 @@ private:
void recv_thread(std::list<SocketsElement>::iterator it);
typedef struct {
- u_int32_t len_;
+ uint32_t len_;
PacketSourceEndpoint remote_;
std::list<SocketsElement>::iterator it_;
} ThreadResult;
diff --git a/src/plainPacket.cpp b/src/plainPacket.cpp
index 0fa21e6..ad37263 100644
--- a/src/plainPacket.cpp
+++ b/src/plainPacket.cpp
@@ -37,14 +37,14 @@
#include "plainPacket.h"
#include "anytunError.h"
-PlainPacket::PlainPacket(u_int32_t payload_length, bool allow_realloc) : Buffer(payload_length + sizeof(payload_type_t), allow_realloc)
+PlainPacket::PlainPacket(uint32_t payload_length, bool allow_realloc) : Buffer(payload_length + sizeof(payload_type_t), allow_realloc)
{
payload_type_ = reinterpret_cast<payload_type_t*>(buf_);
payload_ = buf_ + sizeof(payload_type_t);
*payload_type_ = 0;
}
-u_int32_t PlainPacket::getHeaderLength()
+uint32_t PlainPacket::getHeaderLength()
{
return sizeof(payload_type_t);
}
@@ -83,7 +83,7 @@ void PlainPacket::setPayloadType(payload_type_t payload_type)
}
}
-u_int32_t PlainPacket::getPayloadLength() const
+uint32_t PlainPacket::getPayloadLength() const
{
if(!payload_) {
return 0;
@@ -92,7 +92,7 @@ u_int32_t PlainPacket::getPayloadLength() const
return (length_ > sizeof(payload_type_t)) ? (length_ - sizeof(payload_type_t)) : 0;
}
-void PlainPacket::setPayloadLength(u_int32_t payload_length)
+void PlainPacket::setPayloadLength(uint32_t payload_length)
{
Buffer::setLength(payload_length + sizeof(payload_type_t));
// depending on allow_realloc buf_ may point to another address
@@ -115,7 +115,7 @@ void PlainPacket::reinit()
}
-u_int8_t* PlainPacket::getPayload()
+uint8_t* PlainPacket::getPayload()
{
return payload_;
}
diff --git a/src/plainPacket.h b/src/plainPacket.h
index 2aa7115..6a1396f 100644
--- a/src/plainPacket.h
+++ b/src/plainPacket.h
@@ -57,7 +57,7 @@ public:
* @param the length of the payload
* @param allow reallocation of buffer
*/
- PlainPacket(u_int32_t payload_length, bool allow_realloc = false);
+ PlainPacket(uint32_t payload_length, bool allow_realloc = false);
/**
* Packet destructor
@@ -68,7 +68,7 @@ public:
* Get the length of the header
* @return the length of the header
*/
- static u_int32_t getHeaderLength();
+ static uint32_t getHeaderLength();
/**
* Get the payload type
@@ -86,19 +86,19 @@ public:
* Get the length of the payload
* @return the length of the payload
*/
- u_int32_t getPayloadLength() const;
+ uint32_t getPayloadLength() const;
/**
* Set the length of the payload
* @param length length of the payload
*/
- void setPayloadLength(u_int32_t payload_length);
+ void setPayloadLength(uint32_t payload_length);
/**
* Get the the payload
* @return the Pointer to the payload
*/
- u_int8_t* getPayload();
+ uint8_t* getPayload();
// NetworkAddress getSrcAddr() const;
NetworkAddress getDstAddr() const;
@@ -110,7 +110,7 @@ private:
void reinit();
payload_type_t* payload_type_;
- u_int8_t* payload_;
+ uint8_t* payload_;
};
#endif
diff --git a/src/resolver.cpp b/src/resolver.cpp
index 26ffc72..6a17cde 100644
--- a/src/resolver.cpp
+++ b/src/resolver.cpp
@@ -40,20 +40,20 @@ using ::boost::asio::ip::udp;
using ::boost::asio::ip::tcp;
template<class Proto>
-void waitAndEnqueue(u_int32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<Proto>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
+void waitAndEnqueue(uint32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<Proto>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
{
cLog.msg(Log::PRIO_ERROR) << "the resolver only supports udp and tcp";
}
template<>
-void waitAndEnqueue(u_int32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<udp>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
+void waitAndEnqueue(uint32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<udp>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(s * 1000));
gResolver.resolveUdp(addr, port, onResolve, onError, r);
}
template<>
-void waitAndEnqueue(u_int32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<tcp>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
+void waitAndEnqueue(uint32_t s, const std::string& addr, const std::string& port, boost::function<void(boost::asio::ip::basic_resolver_iterator<tcp>)> const& onResolve, ErrorCallback const& onError, ResolvAddrType r)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(s * 1000));
gResolver.resolveTcp(addr, port, onResolve, onError, r);
diff --git a/src/routingTable.cpp b/src/routingTable.cpp
index 3cfe6f6..ab2515d 100644
--- a/src/routingTable.cpp
+++ b/src/routingTable.cpp
@@ -65,9 +65,9 @@ void RoutingTable::updateRouteTreeUnlocked(const NetworkPrefix& pref)
{
//Lock lock(mutex_); //deadlock
- u_int8_t length=pref.getNetworkPrefixLength();
+ uint8_t length=pref.getNetworkPrefixLength();
network_address_type_t type=pref.getNetworkAddressType();
- u_int16_t mux = routes_[pref.getNetworkAddressType()].find(pref)->second;
+ uint16_t mux = routes_[pref.getNetworkAddressType()].find(pref)->second;
RoutingTreeNode* node = &(root_[type]);
if(type==ipv4) {
ipv4_bytes_type bytes(pref.to_bytes_v4());
@@ -93,7 +93,7 @@ void RoutingTable::updateRouteTreeUnlocked(const NetworkPrefix& pref)
//root_[type].print(0);
}
-void RoutingTable::addRoute(const NetworkPrefix& pref, u_int16_t mux)
+void RoutingTable::addRoute(const NetworkPrefix& pref, uint16_t mux)
{
Lock lock(mutex_);
@@ -125,7 +125,7 @@ void RoutingTable::delRoute(const NetworkPrefix& pref)
routes_[pref.getNetworkAddressType()].erase(routes_[pref.getNetworkAddressType()].find(pref));
}
-u_int16_t RoutingTable::getRoute(const NetworkAddress& addr)
+uint16_t RoutingTable::getRoute(const NetworkAddress& addr)
{
Lock lock(mutex_);
network_address_type_t type=addr.getNetworkAddressType();
@@ -151,7 +151,7 @@ u_int16_t RoutingTable::getRoute(const NetworkAddress& addr)
return 0;
}
-u_int16_t* RoutingTable::getOrNewRoutingTEUnlocked(const NetworkPrefix& addr)
+uint16_t* RoutingTable::getOrNewRoutingTEUnlocked(const NetworkPrefix& addr)
{
RoutingMap::iterator it = routes_[addr.getNetworkAddressType()].find(addr);
if(it!=routes_[addr.getNetworkAddressType()].end()) {
@@ -163,10 +163,10 @@ u_int16_t* RoutingTable::getOrNewRoutingTEUnlocked(const NetworkPrefix& addr)
return &(it->second);
}
-u_int16_t RoutingTable::getCountUnlocked(network_address_type_t type)
+uint16_t RoutingTable::getCountUnlocked(network_address_type_t type)
{
RoutingMap::iterator it = routes_[type].begin();
- u_int16_t routes=0;
+ uint16_t routes=0;
for(; it!=routes_[type].end(); ++it) {
routes++;
}
diff --git a/src/routingTable.h b/src/routingTable.h
index 8fb1f64..48e7617 100644
--- a/src/routingTable.h
+++ b/src/routingTable.h
@@ -42,7 +42,7 @@
#include "networkPrefix.h"
#include "routingTreeNode.h"
#include "boost/array.hpp"
-typedef std::map<NetworkPrefix,u_int16_t> RoutingMap;
+typedef std::map<NetworkPrefix,uint16_t> RoutingMap;
class RoutingTable
{
@@ -50,15 +50,15 @@ public:
static RoutingTable& instance();
RoutingTable();
~RoutingTable();
- void addRoute(const NetworkPrefix& ,u_int16_t);
+ void addRoute(const NetworkPrefix& ,uint16_t);
void updateRouteTreeUnlocked(const NetworkPrefix& pref);
void delRoute(const NetworkPrefix&);
- u_int16_t getRoute(const NetworkAddress&);
+ uint16_t getRoute(const NetworkAddress&);
bool empty(network_address_type_t type);
void clear(network_address_type_t type);
Mutex& getMutex();
- u_int16_t* getOrNewRoutingTEUnlocked(const NetworkPrefix& addr);
- u_int16_t getCountUnlocked(network_address_type_t type);
+ uint16_t* getOrNewRoutingTEUnlocked(const NetworkPrefix& addr);
+ uint16_t getCountUnlocked(network_address_type_t type);
RoutingMap::iterator getBeginUnlocked(network_address_type_t type);
RoutingMap::iterator getEndUnlocked(network_address_type_t type);
diff --git a/src/routingTree.hpp b/src/routingTree.hpp
index a2a5312..9a55886 100644
--- a/src/routingTree.hpp
+++ b/src/routingTree.hpp
@@ -40,7 +40,7 @@ class RoutingTree
public:
template <class BinaryType>
- static void walk(BinaryType bytes ,RoutingTreeNode* node,u_int8_t length,u_int16_t mux) {
+ static void walk(BinaryType bytes ,RoutingTreeNode* node,uint8_t length,uint16_t mux) {
for(int i=0; i<(length/8); i++) {
if(!node->nodes_[bytes[i]]) {
node->nodes_[bytes[i]] = new RoutingTreeNode;
@@ -68,9 +68,9 @@ public:
}
template <class BinaryType>
- static u_int16_t find(BinaryType bytes ,RoutingTreeNode& root) {
+ static uint16_t find(BinaryType bytes ,RoutingTreeNode& root) {
bool valid=0;
- u_int16_t mux=0;
+ uint16_t mux=0;
RoutingTreeNode* node = &root;
if(root.valid_) {
mux=root.mux_;
diff --git a/src/routingTreeNode.h b/src/routingTreeNode.h
index 56e76cf..a16f8de 100644
--- a/src/routingTreeNode.h
+++ b/src/routingTreeNode.h
@@ -49,7 +49,7 @@ public:
private:
// Mutex mutex_;
- u_int16_t mux_;
+ uint16_t mux_;
bool valid_;
boost::array<RoutingTreeNode*,256> nodes_;
diff --git a/src/seqWindow.cpp b/src/seqWindow.cpp
index e860464..992a71c 100644
--- a/src/seqWindow.cpp
+++ b/src/seqWindow.cpp
@@ -54,7 +54,7 @@ void SeqWindowElement::init(window_size_t w, seq_nr_t m)
if(window_) {
delete[] window_;
}
- window_ = new u_int8_t[w];
+ window_ = new uint8_t[w];
memset(window_, 0, w);
pos_ = 0;
max_ = m;
diff --git a/src/seqWindow.h b/src/seqWindow.h
index a8b8700..fa6adaa 100644
--- a/src/seqWindow.h
+++ b/src/seqWindow.h
@@ -52,7 +52,7 @@ public:
seq_nr_t max_;
window_size_t pos_;
- u_int8_t* window_;
+ uint8_t* window_;
};
class SeqWindow
diff --git a/src/syncBuffer.h b/src/syncBuffer.h
index 8723d70..b68e9f5 100644
--- a/src/syncBuffer.h
+++ b/src/syncBuffer.h
@@ -44,9 +44,9 @@ class SyncBuffer : public Buffer
{
public:
SyncBuffer() : Buffer() {};
- SyncBuffer(u_int32_t length) : Buffer(length) {};
+ SyncBuffer(uint32_t length) : Buffer(length) {};
SyncBuffer(Buffer b): Buffer(b) {};
- SyncBuffer(u_int8_t* data, u_int32_t length): Buffer(data,length) {};
+ SyncBuffer(uint8_t* data, uint32_t length): Buffer(data,length) {};
SyncBuffer(const SyncBuffer& src) : Buffer(src) {};
private:
//TODO check if this is ok
@@ -56,7 +56,7 @@ private:
void serialize(Archive& ar, const unsigned int version) {
// Lock lock(mutex_);
ar& length_;
- for(u_int32_t i = 0; i < length_; i++) {
+ for(uint32_t i = 0; i < length_; i++) {
ar & (*this)[i];
}
}
diff --git a/src/syncCommand.cpp b/src/syncCommand.cpp
index 1f7548e..22dede8 100644
--- a/src/syncCommand.cpp
+++ b/src/syncCommand.cpp
@@ -37,7 +37,7 @@ SyncCommand::SyncCommand(ConnectionList& cl)
src_ = new SyncRouteCommand();
}
-SyncCommand::SyncCommand(ConnectionList& cl, u_int16_t mux)
+SyncCommand::SyncCommand(ConnectionList& cl, uint16_t mux)
{
scc_ = new SyncConnectionCommand(cl,mux);
src_=NULL;
diff --git a/src/syncCommand.h b/src/syncCommand.h
index f72a029..5179ae6 100644
--- a/src/syncCommand.h
+++ b/src/syncCommand.h
@@ -46,7 +46,7 @@ class SyncCommand
{
public:
SyncCommand(ConnectionList& cl);
- SyncCommand(ConnectionList& cl ,u_int16_t mux);
+ SyncCommand(ConnectionList& cl ,uint16_t mux);
SyncCommand(NetworkPrefix);
~SyncCommand();
diff --git a/src/syncConnectionCommand.cpp b/src/syncConnectionCommand.cpp
index 533cab3..90df43e 100644
--- a/src/syncConnectionCommand.cpp
+++ b/src/syncConnectionCommand.cpp
@@ -36,12 +36,12 @@ SyncConnectionCommand::SyncConnectionCommand(ConnectionList& cl)
{
}
-SyncConnectionCommand::SyncConnectionCommand(ConnectionList& cl, u_int16_t mux)
+SyncConnectionCommand::SyncConnectionCommand(ConnectionList& cl, uint16_t mux)
:cl_(cl),mux_(mux)
{
}
-u_int16_t SyncConnectionCommand::getMux() const
+uint16_t SyncConnectionCommand::getMux() const
{
return mux_;
}
diff --git a/src/syncConnectionCommand.h b/src/syncConnectionCommand.h
index c95d34e..282f392 100644
--- a/src/syncConnectionCommand.h
+++ b/src/syncConnectionCommand.h
@@ -43,13 +43,13 @@ class SyncConnectionCommand
{
public:
SyncConnectionCommand(ConnectionList& cl);
- SyncConnectionCommand(ConnectionList& cl ,u_int16_t mux);
- u_int16_t getMux() const;
+ SyncConnectionCommand(ConnectionList& cl ,uint16_t mux);
+ uint16_t getMux() const;
private:
SyncConnectionCommand(const SyncConnectionCommand&);
ConnectionList& cl_;
- u_int16_t mux_;
+ uint16_t mux_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version) {
diff --git a/src/syncRouteCommand.h b/src/syncRouteCommand.h
index 6ad87ae..0d66ef3 100644
--- a/src/syncRouteCommand.h
+++ b/src/syncRouteCommand.h
@@ -48,14 +48,14 @@ public:
private:
SyncRouteCommand(const SyncRouteCommand&);
- u_int16_t count_;
+ uint16_t count_;
NetworkPrefix addr_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int version) {
Lock lock(gRoutingTable.getMutex());
ar& addr_;
- // u_int16_t & mux (gRoutingTable.getOrNewRoutingTEUnlocked(addr_));
+ // uint16_t & mux (gRoutingTable.getOrNewRoutingTEUnlocked(addr_));
// ar & mux;
ar & (*(gRoutingTable.getOrNewRoutingTEUnlocked(addr_)));
gRoutingTable.updateRouteTreeUnlocked(addr_);
diff --git a/src/tunDevice.h b/src/tunDevice.h
index cb9b76f..8b2d613 100644
--- a/src/tunDevice.h
+++ b/src/tunDevice.h
@@ -45,11 +45,11 @@
class TunDevice
{
public:
- TunDevice(std::string dev,std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix);
+ TunDevice(std::string dev,std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix);
~TunDevice();
- int read(u_int8_t* buf, u_int32_t len);
- int write(u_int8_t* buf, u_int32_t len);
+ int read(uint8_t* buf, uint32_t len);
+ int write(uint8_t* buf, uint32_t len);
const char* getActualName() const { return actual_name_.c_str(); }
const char* getActualNode() const { return actual_node_.c_str(); }
diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp
index 810e094..bd7794f 100644
--- a/src/win32/tunDevice.cpp
+++ b/src/win32/tunDevice.cpp
@@ -47,7 +47,7 @@
#define MIN_TAP_VER_MAJOR 8
#define MIN_TAP_VER_MINOR 2
-TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400)
+TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, uint16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400)
{
if(conf_.type_ != TYPE_TUN && conf_.type_ != TYPE_TAP) {
AnytunError::throwErr() << "unable to recognize type of device (tun or tap)";
@@ -209,7 +209,7 @@ int TunDevice::fix_return(int ret, size_t pi_length) const
return 0;
}
-int TunDevice::read(u_int8_t* buf, u_int32_t len)
+int TunDevice::read(uint8_t* buf, uint32_t len)
{
DWORD lenout;
roverlapped_.Offset = 0;
@@ -232,7 +232,7 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
return lenout;
}
-int TunDevice::write(u_int8_t* buf, u_int32_t len)
+int TunDevice::write(uint8_t* buf, uint32_t len)
{
DWORD lenout;
woverlapped_.Offset = 0;
@@ -279,7 +279,7 @@ void TunDevice::do_ifconfig()
CloseHandle(handle_);
AnytunError::throwErr() << "Unable to get device mtu: " << AnytunErrno(err);
}
- conf_.mtu_ = static_cast<u_int16_t>(mtu);
+ conf_.mtu_ = static_cast<uint16_t>(mtu);
}
void TunDevice::waitUntilReady()