summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/datatypes.h15
-rw-r--r--src/encryptedPacket.cpp2
-rw-r--r--src/endian.h54
-rw-r--r--src/plainPacket.cpp11
4 files changed, 56 insertions, 26 deletions
diff --git a/src/datatypes.h b/src/datatypes.h
index 0fc9ae2..f4c661a 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -46,25 +46,10 @@ typedef boost::int64_t int64_t;
typedef u_int32_t window_size_t;
typedef u_int32_t seq_nr_t;
-#define SEQ_NR_T_NTOH(a) ntohl(a)
-#define SEQ_NR_T_HTON(a) htonl(a)
-
typedef u_int16_t sender_id_t;
-#define SENDER_ID_T_NTOH(a) ntohs(a)
-#define SENDER_ID_T_HTON(a) htons(a)
-
typedef u_int16_t payload_type_t;
-#define PAYLOAD_TYPE_T_NTOH(a) ntohs(a)
-#define PAYLOAD_TYPE_T_HTON(a) htons(a)
-
typedef u_int16_t mux_t;
-#define MUX_T_NTOH(a) ntohs(a)
-#define MUX_T_HTON(a) htons(a)
-
//typedef u_int32_t auth_tag_t;
-//#define AUTH_TAG_T_NTOH(a) ntohl(a)
-//#define AUTH_TAG_T_HTON(a) htonl(a)
-//
#define STERROR_TEXT_MAX 100
#endif
diff --git a/src/encryptedPacket.cpp b/src/encryptedPacket.cpp
index 1562f71..b580a8a 100644
--- a/src/encryptedPacket.cpp
+++ b/src/encryptedPacket.cpp
@@ -31,10 +31,10 @@
#include <stdexcept>
#include <iostream>
-#include <arpa/inet.h>
#include <cstdio> // for std::memcpy
#include "encryptedPacket.h"
+#include "endian.h"
#include "datatypes.h"
#include "log.h"
diff --git a/src/endian.h b/src/endian.h
new file mode 100644
index 0000000..a5ad2f9
--- /dev/null
+++ b/src/endian.h
@@ -0,0 +1,54 @@
+/*
+ * 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-2008 Othmar Gsenger, Erwin Nindl,
+ * Christian Pointner <satp@wirdorange.org>
+ *
+ * This file is part of Anytun.
+ *
+ * Anytun is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Anytun 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 anytun. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _ENDIAN_HPP_
+#define _ENDIAN_HPP_
+
+#ifndef _WIN32
+#include <arpa/inet.h>
+#endif
+
+#define SEQ_NR_T_NTOH(a) ntohl(a)
+#define SEQ_NR_T_HTON(a) htonl(a)
+
+#define SENDER_ID_T_NTOH(a) ntohs(a)
+#define SENDER_ID_T_HTON(a) htons(a)
+
+#define PAYLOAD_TYPE_T_NTOH(a) ntohs(a)
+#define PAYLOAD_TYPE_T_HTON(a) htons(a)
+
+#define MUX_T_NTOH(a) ntohs(a)
+#define MUX_T_HTON(a) htons(a)
+
+//#define AUTH_TAG_T_NTOH(a) ntohl(a)
+//#define AUTH_TAG_T_HTON(a) htonl(a)
+
+#endif
diff --git a/src/plainPacket.cpp b/src/plainPacket.cpp
index 5ada650..a12a7c8 100644
--- a/src/plainPacket.cpp
+++ b/src/plainPacket.cpp
@@ -31,17 +31,8 @@
#include <stdexcept>
#include <iostream>
-//#include <arpa/inet.h>
-//#include <sys/socket.h>
-//#include <netinet/in_systm.h>
-//#include <netinet/in.h>
-//#include <netinet/ip.h>
-//#include <netinet/ip6.h>
-//#include <net/if.h>
-//#include <net/if_arp.h>
-//#include <netinet/if_ether.h>
-
#include "datatypes.h"
+#include "endian.h"
#include "plainPacket.h"
PlainPacket::PlainPacket(u_int32_t payload_length, bool allow_realloc) : Buffer(payload_length + sizeof(payload_type_t), allow_realloc)