Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 26025bf1d7f3e580c1d1396250bdc2c038a2a53b Author: Marek Lindner lindner_marek@yahoo.de Date: Sun May 26 06:15:20 2013 +0800
batctl: properly align tvlv infrastructure
4bytes long members must start at an address multiple of 4 in order to avoid unaligned memory access.
Therefore, the tvlv short type is eliminated in favor of tvlv long and that distinction removed from the code.
Introduced by 0b6aa0d43767889eeda43a132cf5e73df4e63bf2 "batman-adv: tvlv - basic infrastructure"
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
26025bf1d7f3e580c1d1396250bdc2c038a2a53b packet.h | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-)
diff --git a/packet.h b/packet.h index 8b8b03f..2bc60fb 100644 --- a/packet.h +++ b/packet.h @@ -345,53 +345,27 @@ struct batadv_coded_packet { * @src: address of the source * @dst: address of the destination * @tvlv_len: length of tvlv data following the unicast tvlv header + * @align: 2 bytes to align the header to a 4 byte boundry */ struct batadv_unicast_tvlv_packet { struct batadv_header header; - uint8_t reserved; - uint8_t dst[ETH_ALEN]; - uint8_t src[ETH_ALEN]; - __be16 tvlv_len; + uint8_t reserved; + uint8_t dst[ETH_ALEN]; + uint8_t src[ETH_ALEN]; + __be16 tvlv_len; + uint16_t align; };
/** * struct batadv_tvlv_hdr - base tvlv header struct - * @long_tvlv: flag indicating whether this is a short tvlv container (max 256 - * bytes) or a long tvlv one (up to ETH_DATA_LEN) * @type: tvlv container type (see batadv_tvlv_type) * @version: tvlv container version + * @len: tvlv container length */ struct batadv_tvlv_hdr { -#if defined(__BIG_ENDIAN_BITFIELD) - uint8_t long_tvlv:1; - uint8_t type:7; -#elif defined(__LITTLE_ENDIAN_BITFIELD) - uint8_t type:7; - uint8_t long_tvlv:1; -#else -#error "unknown bitfield endianess" -#endif + uint8_t type; uint8_t version; -}; - -/** - * struct batadv_tvlv_short - short tvlv header struct - * @tvlv_hdr: base tvlv header - * @len: tvlv container length (limited to 255 bytes) - */ -struct batadv_tvlv_short { - struct batadv_tvlv_hdr tvlv_hdr; - uint8_t len; -}; - -/** - * struct batadv_tvlv_long - long tvlv header struct - * @tvlv_hdr: base tvlv header - * @len: tvlv container length - */ -struct batadv_tvlv_long { - struct batadv_tvlv_hdr tvlv_hdr; - __be16 len; + __be16 len; };
/**