// Copyright (c) 2015 Robert Clipsham // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(custom_attribute, plugin, slice_bytes, vec_push_all)] #![plugin(pnet_macros_plugin)] extern crate pnet; extern crate pnet_macros_support; use pnet_macros_support::types::*; #[packet] pub struct WithVariableLengthField { banana: u32be, #[length = "3"] var_length: Vec, #[payload] payload: Vec, } fn main() { let data = [1, 1, 1, 1, 2, 3, 4, 5, 6]; let packet = WithVariableLengthFieldPacket::new(&data[..]).unwrap(); assert_eq!(packet.get_var_length(), vec![2, 3, 4]); }