All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: linux lover <linux_lover2004@yahoo.com>
Cc: netdev@oss.sgi.com
Subject: Re: Function to read IP address in dot format
Date: Mon, 11 Apr 2005 11:07:46 -0300	[thread overview]
Message-ID: <39e6f6c7050411070779ddcb07@mail.gmail.com> (raw)
In-Reply-To: <20050411060510.12208.qmail@web52201.mail.yahoo.com>

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

      parent reply	other threads:[~2005-04-11 14:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39e6f6c7050411070779ddcb07@mail.gmail.com \
    --to=arnaldo.melo@gmail.com \
    --cc=acme@conectiva.com.br \
    --cc=linux_lover2004@yahoo.com \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.