diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 04:14:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 04:14:14 +0200 |
commit | 1c9a5bd0107ed2124e379c250610fa30e3761c84 (patch) | |
tree | e20d02870b1513b6bd3c94c2aeeabda826067561 /src/messages.h | |
parent | curve25519-neon-arm: force ARM encoding, since this is unrepresentable in Thumb (diff) | |
download | wireguard-monolithic-historical-1c9a5bd0107ed2124e379c250610fa30e3761c84.tar.xz wireguard-monolithic-historical-1c9a5bd0107ed2124e379c250610fa30e3761c84.zip |
receive: simplify message type validation
Diffstat (limited to 'src/messages.h')
-rw-r--r-- | src/messages.h | 23 |
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 |