But there is a nx_union field in "your_header_t", which makes
sizeof(your_header_t)
to be the header length when it contains the longest member in the union.
And when header comes without the longest member, your approach is likely to
be problematic, right?

On Wed, Dec 8, 2010 at 2:07 PM, wasif masood <[email protected]> wrote:

> your header should be the part of the actual payload, then it could look
> like this:
>
>   command void* Packet.getPayload(message_t* msg, uint8_t len) {
>     void* payload = call SubPacket.getPayload(msg, len +
> sizeof(your_header_t)*no_of_entries);
>
>     if (payload != NULL) {
>       payload +=  sizeof(your_header_t)*no_of_entries
>     }
>     return payload;
>   }
>
>
> On Wed, Dec 8, 2010 at 7:19 PM, Xiaohui Liu <[email protected]> wrote:
>
>> Hi everyone,
>>
>> My packet has the following format:
>> lower-layer header | my header | payload
>>
>> There exists a nx_union filed in the header, thus the header length is not
>> fixed and the typical implementation of Packet.getPayload() may not work:
>>
>> command void* Packet.getPayload(message_t* msg, uint8_t len) {
>> uint8_t* payload = call SubPacket.getPayload(msg, len +
>> sizeof(data_header_t));
>>  if (payload != NULL) {
>>   payload += sizeof(data_header_t);
>>  }
>> return payload;
>> }
>>
>> Can anyone give me some suggestion on how Packet.getPayload() can be
>> implemented on variable length header? Thanks.
>>
>> --
>> -Xiaohui Liu
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> [email protected]
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>
>
>
> --
> Wasif Masood
>
>


-- 
-Xiaohui Liu
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to