I've been reading through a book and see this typecast a lot:
[code]
struct ip *pip = (struct ip *) pep->ep_data;
[/code]
What I don't understand is how this works. The two structures are completely different. What I'm wondering is how this turns out. For instance, what would the members of the structure pip hold based on what pep holds.
The structs are as follows:
[code]
struct ip {
u_char ip_verlen;
u_char ip_tos;
u_short ip_len;
short ip_id;
short ip_fragoff;
u_char ip_ttl;
u_char ip_proto;
short ip_cksum;
IPaddr ip_src;
IPaddr ip_dst;
u_char ip_data[1];
};
struct ep {
u_long ep_nexthop;
short ep_ifn;
short ep_len;
short ep_order;
struct eh ep_eh;
char ep_data[EP_DLEN];
};
[/code]
Comments
:
So what you're saying is the character array will hold the contents of the entire ip struct?
:
Got it. Thanks