Home > Back-end >  Pointer to a fixed location assignment
Pointer to a fixed location assignment

Time:10-14

U_char * data;
Struct iphead * iphead;
I want to pay data IPHead values
* (data + 14)=(u_char) IPHead;

I just changed my IPHead source IP, but the assignment after changed the protocol version and head length and other values,

CodePudding user response:

Only when everyone a great god, and have a good way to assign a value change source IP and the rest are not affected!

CodePudding user response:

With memcpy, be careful not to cross.

CodePudding user response:

 memcpy (data + 14, IPHead, sizeof (struct IPHead)); 


You have to ensure that the data buffer length enough struct iphead added 14 and

CodePudding user response:

Or will change the value

CodePudding user response:

What kind of is struct iphead inside?
Write out what you want to change
Similar
 memcpy (data + 14, IPHead - & gt; IP, 50); 

CodePudding user response:

* (data + 14)=(u_char) IPHead;
IPHead is a pointer to a pointer (32 bit or 64 bit) forced into u_char, feel there is a problem, never know the original poster is a slip of the pen or a program like this,
  • Related