Re: Sockets Closing Unexpectedly
Re: Sockets Closing Unexpectedly
- Subject: Re: Sockets Closing Unexpectedly
- From: Jones Curtis <email@hidden>
- Date: Fri, 6 Apr 2007 21:13:22 -0400
On Mar 15, 2007, at 22.34.28, Josh Graessley wrote:
The best solution is to write a filter that runs in a process in
user space. Your in kernel kext is responsible for intercepting the
outbound connection via the connect out filter. If the socket is a
synchronous/blocking socket, call sock_connect with the loopback
address and the port your user space process is listening on. Send
the address and port the connect was initially trying to reach to
your user space process. Have your user space process connect to
that destination and then relay the connect result back to your
kext. If the result was success, return EJUSTRETURN from your out
filter function. Otherwise, call sock_shutdown on the socket and
return the error. If the socket is a non-blocking socket, things
may be a little trickier. I can't remember the exact details, but
it can be made to work. Anyhow, once you have done this, the client
thinks their connected to some remote server when they're really
connected to your process. Your process is responsible for
forwarding data between the two sockets. When the remote socket
closes, you can finish writing your data before closing the socket
between your transparent proxy app and the app that initiated the
connection. There are some other tricky things related to TCP half
closes and whatnot.
I think I have this just about 95% done ... and I'm stuck. Unless I'm
doing something tragically wrong ... it appears that the data_out
callback is never called for the socket for which EJUSTRETURN is
returned from connect_out - that is, the socket that some process is
trying to create, for which I want to usher the data through another
socket.
I've primarily been using telnet to test. The service to which I'm
connecting immediately sends data which is properly received by my
second socket and is successfully injected into the process's socket
and received by the process and printed to the terminal while sending
data never amounts to the data_out callback being called.
Any ideas? Is there anything special that I need to do to the
"EJUSTRETURN socket"?
Thanks.
--
Curtis Jones
email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden