i want to use my code like that:
Code:
/*globals*/
#define BUFFER_MAX 2048
char DATA_BUFFER[BUFFER_MAX];
struct headers
{
int i_size;
int e_size;
} headersizes;
struct headersizes = {sizeof(iphdr), sizeof(ethhdr)};
struct iphdr *ip;
ip = (struct iphdr *) (DATA_BUFFER + headersizes.e_size + headersizes.i_size);
//protos
void print_ip(struct iphdr *ip);
...
...
int main(int argc, char **argv)
{
...
...
read(sockfd, DATA_BUFFER, sizeof(DATA_BUFFER)-1);
//i read everything into the DATA_BUFFER var
//now i want to call a function to print out the ip header
print_ip(ip);
return 0;
}
void print_ip(struct iphdr *ip)
{
printf("length: %d\n", ip->lenght);
printf("......the common ip header infos\n");
...
...
}
is there anything wrong with this initialization/assignment of ip?
thanks