Re: Redirecting Sockets using NKE
Re: Redirecting Sockets using NKE
- Subject: Re: Redirecting Sockets using NKE
- From: Joshua Graessley <email@hidden>
- Date: Mon, 7 Jun 2004 07:53:49 -0700
Are you closing the socket that was passed in to your filter function
and creating a new one? That won't work. The socket is associated with
a file descriptor. There are two things you can do here. Either try and
modify the original connect so the socket really gets connected to your
daemon and patch everything else so the client process will never know
or create another socket that you send data to your daemon through and
then inject the response in to the original socket.
-josh
On Jun 7, 2004, at 12:21 AM, Matt Jaffa wrote:
>
Hi,
>
>
I have successfully created a NKE and I am particularily interested in
>
the send function that I am using.
>
>
In the send function I detect if the outgoing message is a GET request
>
if so I do this:
>
>
if( is a GET request) {
>
>
struct sockaddr_in server; /* the information structure for the server
>
(to be filled out) */
>
bzero(&server, sizeof(struct sockaddr_in));
>
struct in_addr s_addr;
>
s_addr.s_addr = 2130706433;
>
server.sin_len = sizeof(server);
>
memcpy(&server.sin_addr, &s_addr, sizeof(struct in_addr));
>
server.sin_family = AF_INET; // Set the server's family
>
server.sin_port = htons((unsigned short) 48080); /* Set the port to
>
connect to... */
>
int threeerror = sodisconnect(so);
>
printf("threeerror: %d\n", threeerror);
>
int shuterror = soshutdown(so,2);
>
printf("shuterror: %d\n", shuterror);
>
//int mosterror = soclose(so);
>
//printf("mosterror: %d\n", mosterror);
>
int testerror = socreate(AF_INET, &so,SOCK_STREAM,0);
>
printf("testerror: %d\n", testerror);
>
int theerrors = soconnect(so, (struct sockaddr*)&server);
>
printf("theerrors: %d\n", theerrors);
>
>
>
}
>
>
>
And then I have a daemon that is listening on 127.0.0.1 with port
>
48080. In the daemon it successfully gets past the accept, but spins
>
on recv(....,...,....,....) forever. So I am assuming that in the
>
Kernel after I have redirected the socket to my daemon, and then when
>
the send function returns it sends that GET request instead to my
>
daemon, where I can look at the information.
>
>
But in my daemon the accept works, but it doesn't get past
>
recv(,,,,,,,,,);
>
>
What to do?
>
>
thanks,
>
Matt
>
_______________________________________________
>
darwin-kernel mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
>
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.