public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* Function to read IP address in dot format
@ 2005-04-11  6:05 linux lover
  2005-04-11 14:07 ` Randy.Dunlap
  2005-04-11 14:07 ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 3+ messages in thread
From: linux lover @ 2005-04-11  6:05 UTC (permalink / raw)
  To: netdev


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?
regards,
linux_lover



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Function to read IP address in dot format
  2005-04-11  6:05 Function to read IP address in dot format linux lover
@ 2005-04-11 14:07 ` Randy.Dunlap
  2005-04-11 14:07 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Randy.Dunlap @ 2005-04-11 14:07 UTC (permalink / raw)
  To: linux lover; +Cc: netdev

On Sun, 10 Apr 2005 23:05:10 -0700 (PDT) linux lover 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?

Look at the NIPQUAD() macro in include/linux/kernel.h
and at some example uses of it.

---
~Randy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Function to read IP address in dot format
  2005-04-11  6:05 Function to read IP address in dot format linux lover
  2005-04-11 14:07 ` Randy.Dunlap
@ 2005-04-11 14:07 ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2005-04-11 14:07 UTC (permalink / raw)
  To: linux lover; +Cc: netdev

On Apr 11, 2005 3:05 AM, linux lover <linux_lover2004@yahoo•com> 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?
> regards,

Use NIPQUAD, as in the example below:

        printk(KERN_DEBUG "dccp rx: packet=%s, "
                          "source=%u.%u.%u.%u@%d, "
                          "dest=%u.%u.%u.%u@%d\n",
               dccp_packet_name(dh->dccph_type),
               NIPQUAD(skb->nh.iph->saddr),
               ntohs(dh->dccph_sport),
               NIPQUAD(skb->nh.iph->daddr),
               ntohs(dh->dccph_dport));

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-04-11 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-11  6:05 Function to read IP address in dot format linux lover
2005-04-11 14:07 ` Randy.Dunlap
2005-04-11 14:07 ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox