summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2007-06-21 00:42:47 +0000
committerChristian Pointner <equinox@anytun.org>2007-06-21 00:42:47 +0000
commit034fee969a22278b2d7bd93a2ad48664ebe69ac0 (patch)
tree5a307484b5b62d72da69147f1957ee993e8757fe
parentlittle bugfix (diff)
first working version
lacks still some features
-rw-r--r--anytun.cpp15
-rw-r--r--packetSource.cpp4
-rw-r--r--packetSource.h8
3 files changed, 14 insertions, 13 deletions
diff --git a/anytun.cpp b/anytun.cpp
index 372d2e1..c32c134 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -107,22 +107,23 @@ void* receiver(void* p)
string remote_host;
u_int16_t remote_port;
Packet pack(1600);
-
// read packet from socket
- int len = param->src->recv(pack, remote_host, remote_port);
+ u_int32_t len = param->src->recv(pack, remote_host, remote_port);
pack.resizeBack(len);
+ pack.withPayloadType(true).withHeader(true).withAuthTag(true);
// check auth_tag and remove it
- auth_tag_t at = param->a->calc(pack);
- if(at != pack.getAuthTag())
+ auth_tag_t at = pack.getAuthTag();
+ pack.removeAuthTag();
+ if(at != param->a->calc(pack))
continue;
-
+
// compare sender_id and seq with window
pack.removeHeader();
-
+
// decypher the packet
param->c->cypher(pack);
-
+
// check payload_type and remove it
if((param->dev->getType() == TunDevice::TYPE_TUN && pack.getPayloadType() != PAYLOAD_TYPE_TUN) ||
(param->dev->getType() == TunDevice::TYPE_TAP && pack.getPayloadType() != PAYLOAD_TYPE_TAP))
diff --git a/packetSource.cpp b/packetSource.cpp
index 8ef122d..a20d7bb 100644
--- a/packetSource.cpp
+++ b/packetSource.cpp
@@ -46,12 +46,12 @@ UDPPacketSource::UDPPacketSource(std::string localaddr, u_int16_t port) : UDPSoc
{
}
-u_int32_t UDPPacketSource::recv(Buffer buf, std::string addr, u_int16_t &port)
+u_int32_t UDPPacketSource::recv(Buffer& buf, std::string addr, u_int16_t &port)
{
return recvFrom(buf, buf.getLength(), addr, port);
}
-void UDPPacketSource::send(Buffer buf, std::string addr, u_int16_t port)
+void UDPPacketSource::send(Buffer& buf, std::string addr, u_int16_t port)
{
sendTo(buf, buf.getLength(), addr, port);
}
diff --git a/packetSource.h b/packetSource.h
index 3cd4fb5..d2902d9 100644
--- a/packetSource.h
+++ b/packetSource.h
@@ -37,8 +37,8 @@ class PacketSource
public:
virtual ~PacketSource() {}
- virtual u_int32_t recv(Buffer buf, std::string addr, u_int16_t &port) = 0;
- virtual void send(Buffer buf, std::string addr, u_int16_t port) = 0;
+ virtual u_int32_t recv(Buffer& buf, std::string addr, u_int16_t &port) = 0;
+ virtual void send(Buffer& buf, std::string addr, u_int16_t port) = 0;
};
class UDPPacketSource : public PacketSource, public UDPSocket
@@ -48,7 +48,7 @@ public:
UDPPacketSource(u_int16_t port);
UDPPacketSource(std::string localaddr, u_int16_t port);
- u_int32_t recv(Buffer buf, std::string addr, u_int16_t &port);
- void send(Buffer buf, std::string addr, u_int16_t port);
+ u_int32_t recv(Buffer& buf, std::string addr, u_int16_t &port);
+ void send(Buffer& buf, std::string addr, u_int16_t port);
};