typedefunsignedchar MacAddr[6];
/* structure of an ethernet pkt */
typedefstruct __etherpkt
{
/* destination address in net order */
MacAddr dst;
/* source address in net order */
MacAddr src;
/************************************/
/* payload type in host order */
/* type = 0 : ARP frame */
/* type = 1 : IP frame */
/************************************/
short type;
/* size of the data in host order */
short size;
/* actual payload */
char * dat;
} EtherPkt;
Now If I am not wrong then during ARP request we will encapsulate the ARP packet into this ethernet packet as it's payload right? If yes, then why we have given the payload type of ethernet packet as char *. Shouldn't it be void * so that we can point it to ARP type?
Please guide me through this guys, this is annoying me since forever.
void* came along well after C was established. Many implementations use char* for untyped blocks of data. You can do pointer arithmetic on char*, but not on void*.