diff options
author | Jake McGinty <me@jake.su> | 2018-02-18 00:42:14 +0000 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-02-18 00:42:14 +0000 |
commit | 5bc730bcb3559a0c88f74a00be20251ba4cd918b (patch) | |
tree | 1bfdff6d5475df90b21331b81b69ea56b82ba7a6 /src/ip_packet.rs | |
parent | just keep noise functions in module not struct (diff) | |
download | wireguard-rs-5bc730bcb3559a0c88f74a00be20251ba4cd918b.tar.xz wireguard-rs-5bc730bcb3559a0c88f74a00be20251ba4cd918b.zip |
add and strip padding to transport messages
Diffstat (limited to 'src/ip_packet.rs')
-rw-r--r-- | src/ip_packet.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ip_packet.rs b/src/ip_packet.rs index 67ec7d4..ad67f3f 100644 --- a/src/ip_packet.rs +++ b/src/ip_packet.rs @@ -20,17 +20,25 @@ impl<'a> IpPacket<'a> { } } - pub fn get_source(&self) -> IpAddr { + pub fn source(&self) -> IpAddr { match *self { IpPacket::V4(ref packet) => packet.get_source().into(), IpPacket::V6(ref packet) => packet.get_source().into(), } } - pub fn get_destination(&self) -> IpAddr { + pub fn destination(&self) -> IpAddr { match *self { IpPacket::V4(ref packet) => packet.get_destination().into(), IpPacket::V6(ref packet) => packet.get_destination().into(), } } + + pub fn length(&self) -> u16 { + match *self { + IpPacket::V4(ref packet) => packet.get_total_length(), + IpPacket::V6(ref packet) => packet.get_payload_length(), + } + + } } |