TEP111 has a lot of detail on message_t's; basically it's because messages
are shared across different stacks and so the cc2420_header_t might actually
be smaller then a message_header_t.  TEP111 specifies the alignment of data
& headers, and so you have to do this computation to find where the header
should begin.

Steve

On Tue, Jan 6, 2009 at 6:21 PM, Ali Shah <[email protected]> wrote:

> Hi list, CC2420PacketP defines this command:
>
>   async command cc2420_header_t * ONE CC2420PacketBody.getHeader(
> message_t* ONE msg ) {
>     return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t,
> data) - sizeof( cc2420_header_t ));
>   }
> My question is: why use the offsetof() macro when we know where the header
> begins as message_t has a field devoted exactly for the message header:
>
> tos/types/message.h:
> typedef nx_struct message_t {
>   nx_uint8_t header[sizeof(message_header_t)];
>   nx_uint8_t data[TOSH_DATA_LENGTH];
>   nx_uint8_t footer[sizeof(message_footer_t)];
>   nx_uint8_t metadata[sizeof(message_metadata_t)];
> } message_t;
>
> Thanks,
> Ali
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to