From: "Li YanBo" <dreamfly281@gmail.com>
To: linux-c-programming@vger.kernel.org
Cc: kernelnewbies@nl.linux.org
Subject: Confuse with big endian bitwise field
Date: Tue, 26 Jun 2007 18:20:35 +0800 [thread overview]
Message-ID: <1197ff4c0706260320t648dba53ga7e3eed745293e9a@mail.gmail.com> (raw)
hi all,
I am try to define a hardware specific struct, it is like below:
struct xxx {
__be32 pdu_cnt:6;
__be32 y:3;
__be32 wep_key:2;
__be32 uses_wep_key:1;
__be32 keep_alive:1;
__be32 buff_tail_addr:19;
__be32 cts_11g:1;
__be32 rts_11g:1;
__be32 x:2;
__be32 frag_size:12;
__be32 payload_len:12;
__be32 frag_num:4;
}
but I am confuse with how to assign the values to the fields
"buff_tail_addr" and "payload_len", I think there are two ways to
assign values to them, but I don't know which is right?
eg: I declare a variable struct xxx X;
1: X.buff_tail_addr = 0x3456; X.payload_len = 0x20;
2: X.buff_tail_addr = cpu_to_be32(0x3456); X.payload_len = cpu_to_be16(0x20);
There are two way I think to assign values. Could anyone tell me which
is right or both are wrong? I will be appreciate for any hints, thanks
in advance!
BR
lyb
next reply other threads:[~2007-06-26 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 10:20 Li YanBo [this message]
2007-06-26 18:09 ` Confuse with big endian bitwise field Kristof Provost
2007-06-28 14:39 ` Arjan van de Ven
2007-06-28 14:59 ` Li YanBo
2007-06-28 15:25 ` Ranjan Sinha
2007-07-03 4:12 ` Li YanBo
2007-07-10 3:58 ` Li YanBo
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=1197ff4c0706260320t648dba53ga7e3eed745293e9a@mail.gmail.com \
--to=dreamfly281@gmail.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-c-programming@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).