Hello,

Currently am working on a project which creates a fake ip package and transmits that packet to a second copy of the same program with a different address. My goal is is to create a fake TCP struct and transmit that over the ip packet.

as of now for testing my struct is define as this

Code:
struct tcp
{
   string message;
};
an ip struct is define as this.

Code:
struct ip_packet
{ byte source_addr[6];
  byte dest_addr[6];
  short int protocol;
  short int length;
  byte content[0]; };
where the byte content[0] is where you store the data. Byte is declare like this "typedef unsigned char byte;"

my idea is to piggy back the tcp struct inside the ip packet by using typecast like this

Code:
tcp a;
ip_packet * x;

x->content[0] = (byte)&a;
it compiles just fine, but gives me a warning that states
warning: cast from pointer to integer of different size

when the program runs on and the second copy of the program gets the ip packet I just get a segmentation fault.

on the receiving end of the code I have it like this

Code:
   byte b;
    tcp rev;
        b = p->content[0];
     
      rev = (faketcp &)b;

any idea of how to properly typecast this?