[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] [Q]how to handle the AppData of Packet class



Hi,
 
First I am a beginner of C++ language.
 
I want to handle the application data of Packet class(AppData * data_)
 
to insert other information and then send to the target.
 
In change history, I found that data_ was changed from unsigned char * to AppData*.
 
In ns manual, there was no update explanation of this variable.
 
If it was previous version, I counld handle the data_ well.
 
But I can handle the AppData * type variable.
 
Please let me know how to handle AppData * type variable
 
such as the functions like to get data_ or to set my application data(unsigned char * type variable)
 
to data_.
 
In change history, they said, "thus we are able to avoid marshalling of application-level data. To provide backward compatibility, PacketData is derived from AppData and is the default packet data to be created when Packet::allocdata() is called. It provides the same unsigned char array as before. "
 
I can not understand the memeber function "accessdata()"  of Packet class.
******************************************
inline unsigned char* accessdata() const {
      if (data_ == 0)
           return 0;
      assert(data_->type() == PACKET_DATA);
      return (((PacketData*)data_)->data());
******************************************
Could you explain this more? Or Is there any manual of this?
 
I already use the member function "allocdata" to assigned the address to data_ which may be the member data of PacketData class.
 
 
Your prompt response will be very appreciated.
 
Reguards,
 
Byeongsoo Yun.