You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The size (in bytes) of a Tcp instance when converted into/// a byte-array#[inline]pubfnpacket_size(_packet:&Tcp) -> usize{20 + _packet.options.len() + _packet.payload.len()}
Instead of calculating actual size in bytes, it just returns a number of TCP options, which is wrong.
The text was updated successfully, but these errors were encountered:
"variable length field must have #[length = \"\"] or \
#[length_fn = \"\"] attribute",
));
}
}
Something roughly like _packet.{}.iter().map(|x| x.packet_size()).sum(), except you can't actually write it this way... I somehow think this macro system shows its inherent limitations. It would be simpler if trait like PacketSize was be defined for primitive types, and it was also defined for Vec<T> where T: PacketSize. This way packet size calculation would be also achieved without ugly macro code generation as well.
packet_size
is supposed to return "The size (in bytes) of an instance when converted into a byte-array".However, this doesn't work correctly when complex variable length fields are present.
Consider the following test:
The test will fail:
I took a look at how these macros were expanded:
Instead of calculating actual size in bytes, it just returns a number of TCP options, which is wrong.
The text was updated successfully, but these errors were encountered: