NKE - Socket filter - get local address problem.
NKE - Socket filter - get local address problem.
- Subject: NKE - Socket filter - get local address problem.
- From: Ryan McGann <email@hidden>
- Date: Sun, 3 Jun 2007 13:30:06 -0700
HOWEVER - I am unable to obtain the local address at this point.
I have used
err = sock_getsockname(so, (struct sockaddr *) &local, (int)&len);
but I keep getting <0.0.0.0> as a result.
optionally is there another call back where I can examine both
addresses and change the <to> prior to bind?
Erez,
The problem is that the kernel performs an implicit bind when the
socket is connected if no local name is assigned to the socket
already. Your NKE connect_out callback is being called when the
client application calls connect() (inside the syscall basically), so
unless the client application performs a bind() first (which is
rarely done for outbound connects) the socket will not have a local
address assigned to it. The kernel will assign one later during the
actual connect. You can obtain the local address later inside of
sf_notify, when you get a notification that the socket has gone into
the connected state, but not before (as far as I know).
In short, there is no way to both redirect the socket (which can only
be done in the connect_out callback) and use the source ip:port. Can
you explain why you need the source ip:port?
Ryan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden