aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/packets.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2015-06-05 15:58:00 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-06-25 16:48:39 +0200
commit99d303ac2739e65a02fbbc325b74ad6fcac63cc2 (patch)
tree6f4095f42d3d298cdd5ab8bc6f8ed89d9673b38b /src/packets.h
downloadwireguard-monolithic-historical-99d303ac2739e65a02fbbc325b74ad6fcac63cc2.tar.xz
wireguard-monolithic-historical-99d303ac2739e65a02fbbc325b74ad6fcac63cc2.zip
Initial commit
Diffstat (limited to 'src/packets.h')
-rw-r--r--src/packets.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/packets.h b/src/packets.h
new file mode 100644
index 0000000..a34acb9
--- /dev/null
+++ b/src/packets.h
@@ -0,0 +1,61 @@
+/* Copyright 2015-2016 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
+
+#ifndef PACKETS_H
+#define PACKETS_H
+
+#include "noise.h"
+#include "messages.h"
+#include "socket.h"
+
+#include <linux/types.h>
+
+enum {
+ MAX_QUEUED_HANDSHAKES = 4096,
+ MAX_BURST_HANDSHAKES = 16
+};
+
+/* AF41, plus 00 ECN */
+#define HANDSHAKE_DSCP 0b10001000
+
+struct wireguard_device;
+struct wireguard_peer;
+struct sk_buff;
+
+/* receive.c */
+void packet_receive(struct wireguard_device *wg, struct sk_buff *skb);
+
+/* send.c */
+int packet_send_queue(struct wireguard_peer *peer);
+void packet_send_keepalive(struct wireguard_peer *peer);
+void packet_send_handshake_initiation(struct wireguard_peer *peer);
+void packet_send_handshake_response(struct wireguard_peer *peer);
+void packet_send_handshake_cookie(struct wireguard_device *wg, struct sk_buff *initiating_skb, void *data, size_t data_len, __le32 sender_index);
+
+void packet_queue_send_handshake_initiation(struct wireguard_peer *peer);
+void packet_process_queued_handshake_packets(struct work_struct *work);
+void packet_send_queued_handshakes(struct work_struct *work);
+
+
+/* data.c */
+struct packet_data_encryption_ctx {
+ struct padata_priv padata;
+ struct sk_buff *skb;
+ void (*callback)(struct sk_buff *, struct wireguard_peer *);
+ struct wireguard_peer *peer;
+ size_t plaintext_len, trailer_len;
+ unsigned int num_frags;
+ struct sk_buff *trailer;
+ struct noise_keypair *keypair;
+ uint64_t nonce;
+};
+
+int packet_create_data(struct sk_buff *skb, struct wireguard_peer *peer, void(*callback)(struct sk_buff *, struct wireguard_peer *), bool parallel);
+void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *, struct wireguard_peer *, struct sockaddr_storage *, bool used_new_key, int err));
+
+#define DATA_PACKET_HEAD_ROOM ALIGN(sizeof(struct message_data) + max(sizeof(struct packet_data_encryption_ctx), SKB_HEADER_LEN), 4)
+
+#ifdef DEBUG
+void packet_counter_selftest(void);
+#endif
+
+#endif