From: Balazs Scheidler <bazsi@balabit.hu>
To: "Wilson Padovani Júnior" <admin@netsun.com.br>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Problem using REDIRECT and SO_ORIGINAL_DST
Date: Wed, 6 Nov 2002 20:06:50 +0100 [thread overview]
Message-ID: <20021106190650.GC2985@balabit.hu> (raw)
In-Reply-To: <20021106.15222917@w-laptop.localnet>
On Wed, Nov 06, 2002 at 03:22:29PM +0000, Wilson Padovani Júnior wrote:
> Hi.
>
> I trying to write a transparent proxy program, but I having
> trouble to retrieve the original destination address of the redirected
> connections.
> SLen = sizeof(peer);
> memset(&peer, 0, SLen);
> getsockopt(new_sock, SOL_IP, SO_ORIGINAL_DST, &peer, &SLen);
> printf( "Client: %s:%hu\nMe: %s:%hu\nPeer: %s:%hu\n",
> inet_ntoa(client.sin_addr), ntohs(client.sin_port),
> inet_ntoa(me.sin_addr), ntohs(me.sin_port),
> inet_ntoa(peer.sin_addr), ntohs(peer.sin_port) );
inet_ntoa() uses a static buffer to format its result, you are calling
inet_ntoa three times which all work on the same buffer -> the result of the
last invocation will be used three times.
try writing 3 printf() statements, or copy the result of inet_ntoa() to a
private buffer, or create your own inet_ntoa() function.
--
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1
next prev parent reply other threads:[~2002-11-06 19:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-06 15:22 Problem using REDIRECT and SO_ORIGINAL_DST Wilson Padovani Júnior
2002-11-06 19:06 ` Balazs Scheidler [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-11-07 17:49 Wilson Padovani Júnior
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=20021106190650.GC2985@balabit.hu \
--to=bazsi@balabit.hu \
--cc=admin@netsun.com.br \
--cc=netfilter-devel@lists.netfilter.org \
/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.