--- batman-adv_next.packet.h 2013-12-14 00:15:01.324909048 +0100 +++ batctl_next.packet.h 2013-12-14 00:15:01.480919356 +0100 @@ -164,18 +164,23 @@ __be16 group; /* group id */ };
+struct batadv_header { + uint8_t packet_type; + uint8_t version; /* batman version field */ + uint8_t ttl; + /* the parent struct has to add a byte after the header to make + * everything 4 bytes aligned again + */ +}; + /** * struct batadv_ogm_packet - ogm (routing protocol) packet - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header + * @header: common batman packet header * @flags: contains routing relevant flags - see enum batadv_iv_flags * @tvlv_len: length of tvlv data following the ogm header */ struct batadv_ogm_packet { - uint8_t packet_type; - uint8_t version; - uint8_t ttl; + struct batadv_header header; uint8_t flags; __be32 seqno; uint8_t orig[ETH_ALEN]; @@ -192,18 +197,14 @@
/** * batadv_icmp_header - common ICMP header - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header + * @header: common batman header * @msg_type: ICMP packet type * @dst: address of the destination node * @orig: address of the source node * @uid: local ICMP socket identifier */ struct batadv_icmp_header { - uint8_t packet_type; - uint8_t version; - uint8_t ttl; + struct batadv_header header; uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[ETH_ALEN]; uint8_t orig[ETH_ALEN]; @@ -252,18 +253,8 @@ */ #pragma pack(2)
-/** - * struct batadv_unicast_packet - unicast packet for network payload - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header - * @ttvn: translation table version number - * @dest: originator destination of the unicast packet - */ struct batadv_unicast_packet { - uint8_t packet_type; - uint8_t version; - uint8_t ttl; + struct batadv_header header; uint8_t ttvn; /* destination translation table version number */ uint8_t dest[ETH_ALEN]; /* "4 bytes boundary + 2 bytes" long to make the payload after the @@ -289,9 +280,7 @@
/** * struct batadv_frag_packet - fragmented packet - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header + * @header: common batman packet header with type, compatversion, and ttl * @dest: final destination used when routing fragments * @orig: originator of the fragment used when merging the packet * @no: fragment number within this sequence @@ -300,9 +289,7 @@ * @total_size: size of the merged packet */ struct batadv_frag_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batadv_header header; #if defined(__BIG_ENDIAN_BITFIELD) uint8_t no:4; uint8_t reserved:4; @@ -318,19 +305,8 @@ __be16 total_size; };
-/** - * struct batadv_bcast_packet - broadcast packet for network payload - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header - * @reserved: reserved byte for alignment - * @seqno: sequence identification - * @orig: originator of the broadcast packet - */ struct batadv_bcast_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batadv_header header; uint8_t reserved; __be32 seqno; uint8_t orig[ETH_ALEN]; @@ -339,11 +315,11 @@ */ };
+#pragma pack() + /** * struct batadv_coded_packet - network coded packet - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header + * @header: common batman packet header and ttl of first included packet * @reserved: Align following fields to 2-byte boundaries * @first_source: original source of first included packet * @first_orig_dest: original destinal of first included packet @@ -358,9 +334,7 @@ * @coded_len: length of network coded part of the payload */ struct batadv_coded_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batadv_header header; uint8_t first_ttvn; /* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */ uint8_t first_source[ETH_ALEN]; @@ -375,13 +349,9 @@ __be16 coded_len; };
-#pragma pack() - /** * struct batadv_unicast_tvlv - generic unicast packet with tvlv payload - * @packet_type: batman-adv packet type, part of the general header - * @version: batman-adv protocol version, part of the genereal header - * @ttl: time to live for this packet, part of the genereal header + * @header: common batman packet header * @reserved: reserved field (for packet alignment) * @src: address of the source * @dst: address of the destination @@ -389,9 +359,7 @@ * @align: 2 bytes to align the header to a 4 byte boundry */ struct batadv_unicast_tvlv_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batadv_header header; uint8_t reserved; uint8_t dst[ETH_ALEN]; uint8_t src[ETH_ALEN];