On Sat, 1 Oct 2005, Lore wrote:
Hi, At the moment I'm not able to run the program as root. But what follow is the code that shows me the wrong IP.
printf("S_ADDR:%s,D_ADDR:%s\n", inet_ntoa(iph->saddr), inet_ntoa(iph->daddr));
inet_ntoa can not be used like this. Each call to inet_ntoa overwrites the result string. (see man inet_ntoa)
The following will give better results: printf("S_ADDR:%s", inet_ntoa(iph->saddr)); printf(",D_ADDR:%s\n", inet_ntoa(iph->daddr)); Regards Henrik