diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-10-13 22:26:12 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-10-13 22:26:12 +0200 |
commit | a08fd4002bfae92072f64f8d5e0084e6f248f139 (patch) | |
tree | a50315318549056627adb05bdd0a4f1a02f8541d /src/wireguard/router/ip.rs | |
parent | Port timer.c from WireGuard (diff) | |
download | wireguard-rs-a08fd4002bfae92072f64f8d5e0084e6f248f139.tar.xz wireguard-rs-a08fd4002bfae92072f64f8d5e0084e6f248f139.zip |
Work on Linux platform code
Diffstat (limited to 'src/wireguard/router/ip.rs')
-rw-r--r-- | src/wireguard/router/ip.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/wireguard/router/ip.rs b/src/wireguard/router/ip.rs new file mode 100644 index 0000000..e66144f --- /dev/null +++ b/src/wireguard/router/ip.rs @@ -0,0 +1,26 @@ +use byteorder::BigEndian; +use zerocopy::byteorder::U16; +use zerocopy::{AsBytes, FromBytes}; + +pub const VERSION_IP4: u8 = 4; +pub const VERSION_IP6: u8 = 6; + +#[repr(packed)] +#[derive(Copy, Clone, FromBytes, AsBytes)] +pub struct IPv4Header { + _f_space1: [u8; 2], + pub f_total_len: U16<BigEndian>, + _f_space2: [u8; 8], + pub f_source: [u8; 4], + pub f_destination: [u8; 4], +} + +#[repr(packed)] +#[derive(Copy, Clone, FromBytes, AsBytes)] +pub struct IPv6Header { + _f_space1: [u8; 4], + pub f_len: U16<BigEndian>, + _f_space2: [u8; 2], + pub f_source: [u8; 16], + pub f_destination: [u8; 16], +} |