X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.h;h=dcc99a4a6055c44d6f33bf016f30958432f90e64;hb=266afc6c63d3d02584feb24b69063f97057daac8;hp=b570d5e1c584e7dcfa17a8a0fc892f89bd3fde06;hpb=111040d7d1993c67246c52cbfd073183818655f9;p=tinc diff --git a/src/net.h b/src/net.h index b570d5e1..dcc99a4a 100644 --- a/src/net.h +++ b/src/net.h @@ -57,6 +57,7 @@ typedef struct node_id_t { } node_id_t; typedef short length_t; +typedef uint32_t seqno_t; #define AF_UNKNOWN 255 @@ -84,12 +85,16 @@ typedef union sockaddr_t { #define SALEN(s) (s.sa_family==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)) #endif +#define SEQNO(x) ((x)->data + (x)->offset - 4) +#define SRCID(x) ((node_id_t *)((x)->data + (x)->offset - 6)) +#define DSTID(x) ((node_id_t *)((x)->data + (x)->offset - 12)) +#define DATA(x) ((x)->data + (x)->offset) +#define DEFAULT_PACKET_OFFSET 12 + typedef struct vpn_packet_t { - length_t len; /* the actual number of bytes in the `data' field */ + length_t len; /* The actual number of valid bytes in the `data' field (including seqno or dstid/srcid) */ + length_t offset; /* Offset in the buffer where the packet data starts (righter after seqno or dstid/srcid) */ int priority; /* priority or TOS */ - node_id_t dstid; /* node ID of the final recipient */ - node_id_t srcid; /* node ID of the original sender */ - uint8_t seqno[4]; /* 32 bits sequence number (network byte order of course) */ uint8_t data[MAXSIZE]; } vpn_packet_t; @@ -178,8 +183,8 @@ extern void handle_new_meta_connection(void *, int); extern void handle_new_unix_connection(void *, int); extern int setup_listen_socket(const sockaddr_t *); extern int setup_vpn_in_socket(const sockaddr_t *); -extern bool send_sptps_data(void *handle, uint8_t type, const char *data, size_t len); -extern bool receive_sptps_record(void *handle, uint8_t type, const char *data, uint16_t len); +extern bool send_sptps_data(void *handle, uint8_t type, const void *data, size_t len); +extern bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t len); extern void send_packet(struct node_t *, vpn_packet_t *); extern void receive_tcppacket(struct connection_t *, const char *, int); extern void broadcast_packet(const struct node_t *, vpn_packet_t *);