Thread (10 messages) flat view 10 messages, 5 authors, 2004-06-12

Re: UDP sockets bound to ANY send answers with wrong src ip address

From: Denis Vlasenko <hidden>
Date: 2004-06-12 22:08:51

On Friday 11 June 2004 16:53, Julian Anastasov wrote:
	Hello,

On Fri, 11 Jun 2004, Denis Vlasenko wrote:
quoted
Hmmm... do I have to set a *routing dest address* field
to set src ip address of my UDP packet?
	Try such function:

[snip]
Thanks for your excellent help Julian.
It helped me to finally make my code work.

Pity I did not keep it that way, because 
it wouldn't be portable. I converted it
to 'man cmsg' compliant way.

On Friday 11 June 2004 17:14, Henrik Nordstrom wrote:
[snip]
quoted
I am trying to figure it out, currently I'm getting
-EINVAL in sendmsg in this code:

# define SRCADDR_SOCKOPT IP_PKTINFO
# define SRCADDR_DATASIZE (CMSG_SPACE(sizeof(struct in_pktinfo)))
# define srcaddr(x) (&(((struct in_pktinfo
*)(CMSG_DATA(x)))->ipi_spec_dst))
Drop the defines. These are only obfuscating your code and the source to
your error. You need to pass a in_pktinfo structure in the message, and
They were there in the example recv code from the Net. That code tried
to use IP_DSTADDR (IIRC) option (a BSDism or something) if it is #defined.

Dropped #defines.

I ended up with following patch for djbdns. Run tested.

Thanks again for your help guys.
--
vda

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help