I have a C program that reads custom icmp packets off a socket. The program has been used for years on Solaris, but I am now having to port it to Linux.
Got it all compliled on Linux and when I ran it and sent in a test icmp packet, the size of the packet appears to be quite larger on Linux than it was on Solaris.
On both Linux and Solaris, when I print out "rc", I get about the same size of bytes read, which is 276.
1 2 3 4 5 6 7 8 9 10 11
|
char recv_buffer[8184];
if ((rc = recvfrom(sd, recv_buffer, 8184, iFlag, &sFrom, &iFromLen)) == -1)
{
do something
}
else
{
ip_recv_ptr = (struct ip *) recv_buffer;
printf("Length of data received %d\n", ip_recv_ptr->ip_len);
}
|
I cast recv_buffer to a pointer of type struct ip and then print out the size of the data received.
On Solaris, ip_recv_ptr->ip_len prints out
248
On Linux, ip_recv_ptr->ip_len prints out
5113
Now this is a really big difference. I am reading the same packet of size 270`ish off the socket on both Solaris and Linux, but the amount of data in recv_buffer is 248 on Solaris and 5113 on Linux.
So, I am really lost as to what is happening. The source code is that same and the test packet is the same. Any ideas? on what's going on here?
Thanks