Re: Destination_IP Field in packets coming from QUEUE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux