#include "cipher.h"
#include "digest.h"
#include "event.h"
+#include "sockaddr.h"
#ifdef ENABLE_JUMBOGRAMS
#define MTU 9018 /* 9000 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */
#define MAXSOCKETS 8 /* Probably overkill... */
-typedef short length_t;
-
-#define AF_UNKNOWN 255
-
-struct sockaddr_unknown {
- uint16_t family;
- uint16_t pad1;
- uint32_t pad2;
- char *address;
- char *port;
-};
-
-typedef union sockaddr_t {
- struct sockaddr sa;
- struct sockaddr_in in;
- struct sockaddr_in6 in6;
- struct sockaddr_unknown unknown;
-#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
- struct sockaddr_storage storage;
-#endif
-} sockaddr_t;
-
-#ifdef SA_LEN
-#define SALEN(s) SA_LEN(&s)
-#else
-#define SALEN(s) (s.sa_family==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6))
-#endif
-
typedef struct vpn_packet_t {
struct {
unsigned int probe:1;
unsigned int tcp:1;
};
- length_t len; /* the actual number of bytes in the `data' field */
+ uint16_t len; /* the actual number of bytes in the `data' field */
uint8_t data[MAXSIZE];
} vpn_packet_t;
send_mtu_probe_handler(n);
}
-static void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
+static void mtu_probe_h(node_t *n, vpn_packet_t *packet, uint16_t len) {
logger(DEBUG_TRAFFIC, LOG_INFO, "Got MTU probe length %d from %s (%s)", packet->len, n->name, n->hostname);
if(!packet->data[0]) {
}
}
-static length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level) {
+static uint16_t compress_packet(uint8_t *dest, const uint8_t *source, uint16_t len, int level) {
if(level == 0) {
memcpy(dest, source, len);
return len;
return -1;
}
-static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level) {
+static uint16_t uncompress_packet(uint8_t *dest, const uint8_t *source, uint16_t len, int level) {
if(level == 0) {
memcpy(dest, source, len);
return len;
}
if(type & PKT_COMPRESSED) {
- length_t ulen = uncompress_packet(inpkt.data, (const uint8_t *)data, len, from->incompression);
+ uint16_t ulen = uncompress_packet(inpkt.data, (const uint8_t *)data, len, from->incompression);
if(ulen < 0) {
return false;
} else {
#ifndef __TINC_NODE_H__
#define __TINC_NODE_H__
-#include "splay_tree.h"
-#include "cipher.h"
-#include "connection.h"
-#include "digest.h"
#include "event.h"
+#include "sockaddr.h"
+#include "sptps.h"
typedef struct node_status_t {
unsigned int unused_active:1; /* 1 if active (not used for nodes) */
time_t last_state_change;
time_t last_req_key;
- ecdsa_t *ecdsa; /* His public ECDSA key */
+ struct ecdsa_t *ecdsa; /* His public ECDSA key */
sptps_t sptps;
int incompression; /* Compressionlevel, 0 = no compression */
uint32_t prev_received;
unsigned char* late; /* Bitfield marking late packets */
- length_t mtu; /* Maximum size of packets to send to this node */
- length_t minmtu; /* Probed minimum MTU */
- length_t maxmtu; /* Probed maximum MTU */
+ uint16_t mtu; /* Maximum size of packets to send to this node */
+ uint16_t minmtu; /* Probed minimum MTU */
+ uint16_t maxmtu; /* Probed maximum MTU */
int mtuprobes; /* Number of probes */
timeout_t mtutimeout; /* Probe event */
struct timeval probe_time; /* Time the last probe was sent or received */
return false;
}
-static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) {
+static bool checklength(node_t *source, vpn_packet_t *packet, uint16_t length) {
if(packet->len < length) {
logger(DEBUG_TRAFFIC, LOG_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname);
return false;
--- /dev/null
+#ifndef SOCKADDR_H
+#define SOCKADDR_H
+
+#define AF_UNKNOWN 255
+
+#ifdef SA_LEN
+#define SALEN(s) SA_LEN(&s)
+#else
+#define SALEN(s) (s.sa_family==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6))
+#endif
+
+struct sockaddr_unknown {
+ uint16_t family;
+ uint16_t pad1;
+ uint32_t pad2;
+ char *address;
+ char *port;
+};
+
+typedef union sockaddr_t {
+ struct sockaddr sa;
+ struct sockaddr_in in;
+ struct sockaddr_in6 in6;
+ struct sockaddr_unknown unknown;
+#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
+ struct sockaddr_storage storage;
+#endif
+} sockaddr_t;
+
+#endif // SOCKADDR_H