Hi
I am declaring following variables
unsigned long dstAddr;
unsigned long gateWay;
unsigned long mask;
These variables contains ipaddresses in network byte order. So when I am trying to print the dot notation using inet_ntoa function for mask variable sometimes it is printing strange values. The below code is in a while loop .. which loops for n times.
printf("%s\t%s\t%s\t",inet_ntoa(dstAddr),inet_ntoa(gateWay),inet_ntoa(mask));
192.168.122.0 0.0.0.0 0.255.255.255
but it should be
192.168.122.0 0.0.0.0 255.255.255.0
I printed the HEX values of the variables and it shows ..
007aa8c0 00000000 ffffff00
So is this because of inet_ntoa ??
Actually I am trying to get the values of the declared variables from 254 routing table in kernel via NETLINKS. I guess I should still use inet_ntoa function to convert the value into dot notation .. ??