Re: Function to read IP address in dot format

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

 



On Apr 11, 2005 11:34 AM, linux lover <linux_lover2004@xxxxxxxxx> wrote:
> 
> Hello,
>           what is the function to read IP address in
> kernel code as human readable dot quad format? IP
> address are unsigned int's in ip.h file as
>         __u32   saddr;
>         __u32   daddr;
>          In ip_build_xmit ip header gets IP addresses
> from rtable struct as
> iph->saddr=rt->rt_src;
> iph->daddr=rt->rt_dst;
>            Now if i want to know to which ip current
> packet is being sent i am using printks but it prints
> iph->saddr in int format not in user readable format.
> how to do that?
use printk(KERN_NOTICE "%u.%u.%u.%u", NIPQUAD(iph->saddr));

HTH,
Vinay Reddy

> regards,
> linux_lover
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
> 


-- 
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux