On Wed, Jul 9, 2008 at 8:15 PM, jiwen zhang <[EMAIL PROTECTED]> wrote:
> Hello Omprakash  :
>
>     I have a question about the code in the file CtpForwardingEngineP.nc
>
>     In the implementation of Send.send , you use "hdr = getHeader(msg)" to
> make hdr point to the payload field of the msg in order to inset the ctp
> header before the "user's data"  , and then you give the values to the
> fields of the  data structure of ctp_data_header_t . does these operations
> will destroy the "user's data" ?
> becase the CTP works well , so i think the "user's data" is not destroied ,
> i don't know why .
> because the function of getHeader is :
>   ctp_data_header_t* getHeader(message_t* m) {
>     return (ctp_data_header_t*)call SubPacket.getPayload(m,
> sizeof(ctp_data_header_t));
>   }
> so the returned pointer points to the user's data , so when you evaluate to
> the fields , it shoud destroy the original datas according to my
> understanding to the pointer . why ? can you give me an explain ?

CTP data header is in the payload section of the link layer packet.
What the code fragment above does is get a pointer to the link layer
payload (SubPacket gives you access to the link layer packet) and cast
the return value as a ctp_data_header_t. The user data would appear
immediately after the CTP data header in the link layer payload
section so by assigning values to the fields of CTP data header, we
are not touching the user data.

- om_p
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to