aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/messages.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-03 04:14:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-03 04:14:14 +0200
commit9a93bd7a398acd6f693f6a8332fc0dc6e410a2e5 (patch)
treec96fe103355fc01ee483061a956f9872a44b09fb /src/messages.h
parentcurve25519-neon-arm: force ARM encoding, since this is unrepresentable in Thumb (diff)
downloadwireguard-linux-compat-9a93bd7a398acd6f693f6a8332fc0dc6e410a2e5.tar.xz
wireguard-linux-compat-9a93bd7a398acd6f693f6a8332fc0dc6e410a2e5.zip
receive: simplify message type validation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/messages.h')
-rw-r--r--src/messages.h23
1 files changed, 0 insertions, 23 deletions
diff --git a/src/messages.h b/src/messages.h
index 6da04e5..acf248c 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -125,27 +125,4 @@ enum {
HANDSHAKE_DSCP = 0b10001000 /* AF41, plus 00 ECN */
};
-static const unsigned int message_header_sizes[MESSAGE_TOTAL] = {
- [MESSAGE_HANDSHAKE_INITIATION] = sizeof(struct message_handshake_initiation),
- [MESSAGE_HANDSHAKE_RESPONSE] = sizeof(struct message_handshake_response),
- [MESSAGE_HANDSHAKE_COOKIE] = sizeof(struct message_handshake_cookie),
- [MESSAGE_DATA] = sizeof(struct message_data)
-};
-
-static inline enum message_type message_determine_type(struct sk_buff *skb)
-{
- struct message_header *header = (struct message_header *)skb->data;
- if (unlikely(skb->len < sizeof(struct message_header)))
- return MESSAGE_INVALID;
- if (header->type == cpu_to_le32(MESSAGE_DATA) && skb->len >= MESSAGE_MINIMUM_LENGTH)
- return MESSAGE_DATA;
- if (header->type == cpu_to_le32(MESSAGE_HANDSHAKE_INITIATION) && skb->len == sizeof(struct message_handshake_initiation))
- return MESSAGE_HANDSHAKE_INITIATION;
- if (header->type == cpu_to_le32(MESSAGE_HANDSHAKE_RESPONSE) && skb->len == sizeof(struct message_handshake_response))
- return MESSAGE_HANDSHAKE_RESPONSE;
- if (header->type == cpu_to_le32(MESSAGE_HANDSHAKE_COOKIE) && skb->len == sizeof(struct message_handshake_cookie))
- return MESSAGE_HANDSHAKE_COOKIE;
- return MESSAGE_INVALID;
-}
-
#endif