[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cc9ba7943aebff9ba87b60778b62f1a8.squirrel@webmail.itwm.fhg.de>
Date: Tue, 4 Mar 2014 23:16:31 +0100
From: "Phoebe Buckheister" <phoebe.buckheister@...m.fraunhofer.de>
To: "David Miller" <davem@...emloft.net>
Cc: phoebe.buckheister@...m.fraunhofer.de, netdev@...r.kernel.org,
linux-zigbee-devel@...ts.sourceforge.net
Subject: Re: [PATCH net-next v4 1/4] ieee802154: add generic header
handling routines
>> +struct ieee802154_sechdr {
>> + u8 sc;
>> + u32 frame_ctr;
>> + union {
>> + struct {
>> + u16 pan_id;
>> + u16 short_addr;
>> + } pan;
>> + u8 hw[IEEE802154_ADDR_LEN];
>> + } key_source;
>> + u8 key_id;
>> +};
>> +
>> +struct ieee802154_hdr {
>> + u16 fc;
>> + u8 seq;
>> + struct ieee802154_addr source;
>> + struct ieee802154_addr dest;
>> + struct ieee802154_sechdr sec;
>> +};
>
> You're going to have to address endianness both in these structure
> definitions and the code.
>
> For types larger than u8 you'll need to use __be16, __le16, __be32,
> __le32 etc. as appropriate.
>
> When setting/loading values, you'll need to use cpu_to_be16(),
> cpu_to_le16() etc. as appropriate.
The intention here was to explicitly not do that, and have this
representation of the header be completely in host byte order. This is due
to the fact that an easily accessible (i.e. no bitshifts/pointer
arithmetic all over the place) representation will differ wildly from the
actual packet MAC header contents, so I went with host byte order there
instead. The header operations will convert them to/from the correct byte
order for the actual MAC header.
I see some value in being able to memcpy() to/from those fields directly
when building/reading headers, but I also think that not having to do
endianness conversion everywhere for a struct that cannot ever be a valid
header as is outweighs this.
If explicit endianness is required for this case nonetheless, I will of
course change it.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists