Re: How to get src and dest IP from packet

Linux Advanced Routing and Traffic Control

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

 



> Dear All,
>
> I am trying to get src and dest IP from packet send from IP to TC via
> struct sk_buff *skb;
>
> In enqueue function in sch_myqueue, I get my IP like this
>
> struct iphdr* iph=skb->nh.iph;
> printk(KERN_ALERT "%u::%u\n",iph->saddr,iph->daddr);
>
> but it turned out to be that I always get the same number and it's not
> an IP. The following are some of my result
>
> Mar 25 04:07:26 darth kernel: 1250891393::1194021458
> Mar 25 04:07:26 darth kernel: 1250891393::1194021458
> Mar 25 04:07:26 darth kernel: 1250891393::1194021458
>
> Please feel free to contribute any ideas you guys have got. Any sources
> should I consult? Thank you very much in advance for your help.


It is an IP, but not in a way you want it to be. Try:
printk (KERN_INFO "%u.%u.%u.%u -> %u.%u.%u.%u\n",
	NIPQUAD (iph -> saddr), NIPQUAD (iph -> daddr));

Good luck!

>
> Sincerely,
>
> Sipat Triukose
> --
>
> _______________________________________________
> LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
> http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
>

---
Catalin(ux) BOIE
catab@xxxxxxxxxxxxxxx
_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux