From: "Phoebe Buckheister" <phoebe.buckheister@itwm.fraunhofer.de>
To: "David Miller" <davem@davemloft.net>
Cc: phoebe.buckheister@itwm.fraunhofer.de, netdev@vger.kernel.org,
linux-zigbee-devel@lists.sourceforge.net
Subject: Re: [PATCH net-next v4 1/4] ieee802154: add generic header handling routines
Date: Tue, 4 Mar 2014 23:16:31 +0100 [thread overview]
Message-ID: <cc9ba7943aebff9ba87b60778b62f1a8.squirrel@webmail.itwm.fhg.de> (raw)
In-Reply-To: <20140304.170050.2058599034902221847.davem@davemloft.net>
>> +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.
next prev parent reply other threads:[~2014-03-04 22:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 14:34 [PATCH net-next v4 0/4] ieee802154: clean up header handling Phoebe Buckheister
2014-03-04 14:34 ` [PATCH net-next v4 2/4] mac802154: use new header ops in wpan devices Phoebe Buckheister
[not found] ` <1393943688-24221-1-git-send-email-phoebe.buckheister-mPn0NPGs4xGatNDF+KUbs4QuADTiUCJX@public.gmane.org>
2014-03-04 14:34 ` [PATCH net-next v4 1/4] ieee802154: add generic header handling routines Phoebe Buckheister
2014-03-04 22:00 ` David Miller
2014-03-04 22:16 ` Phoebe Buckheister [this message]
2014-03-04 22:20 ` David Miller
2014-03-04 22:49 ` Phoebe Buckheister
2014-03-05 0:23 ` David Miller
[not found] ` <20140304.192309.337489223683931299.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-03-05 1:01 ` Phoebe Buckheister
2014-03-05 1:09 ` David Miller
2014-03-09 17:59 ` Ben Hutchings
[not found] ` <1394387943.15968.1.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
2014-03-09 22:49 ` David Miller
2014-03-05 19:15 ` Phoebe Buckheister
2014-03-06 0:39 ` David Miller
2014-03-06 10:11 ` Phoebe Buckheister
2014-03-06 18:07 ` David Miller
2014-03-06 18:28 ` Phoebe Buckheister
2014-03-04 14:34 ` [PATCH net-next v4 3/4] ieee802154: remove addresses from mac_cb Phoebe Buckheister
2014-03-04 14:34 ` [PATCH net-next v4 4/4] ieee802154: remove seq member of mac_cb Phoebe Buckheister
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc9ba7943aebff9ba87b60778b62f1a8.squirrel@webmail.itwm.fhg.de \
--to=phoebe.buckheister@itwm.fraunhofer.de \
--cc=davem@davemloft.net \
--cc=linux-zigbee-devel@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).