Help with my IPC
Help with my IPC
- Subject: Help with my IPC
- From: Matt Jaffa <email@hidden>
- Date: Mon, 16 Feb 2004 20:39:34 -0700
Hi,
So I am trying to communicate between my NKE and Daemon,
I have tried everything. I tried all different kinds of Sockets but I
can't get the
KEXT to connect with my listening socket(daemon) and send message and
then receive,
So I went back to my sysctlbyname way of doing it, but there are
still problems with it cause it goes into Deadlock. Here is the code
of the function that spins in a while loop till the daemon is done with
its work.
any suggestions?
int vi_send2(struct socket *so, struct sockaddr **addr, struct uio
**uio,
struct mbuf **top, struct mbuf **control, int *flags,
register struct kextcb *kp) {
int funnel_state;
funnel_state = thread_funnel_set(network_flock, TRUE);
if(somo.the_value != NULL) {
//int errordd = soconnect2(soed3, somo.the_value);
//printf("This is the error from send2 error: %d\n", errordd);
char thiscmd[MAXCOMLEN + 1];
struct proc * testing;
//unsigned long length;
testing = current_proc();
printf("This process is communicating: %d\n",testing->p_pid);
//somo2.p_pid = testing->p_pid;
//strncopy(thiscmd, testing->p_comm, MAXCOMLEN);
sprintf(thiscmd, "%s", testing->p_comm);
//copyinstr(testing->p_comm, thiscmd, MAXCOMLEN, &length);
thiscmd[MAXCOMLEN] = '\0';
printf("This is the proccess name: %s\n",thiscmd);
struct ip * ipHeader;
ipHeader = mtod(*top,struct ip *);
u_short port;
struct tcphdr * header = NULL;
header = (struct tcphdr *)&((int32_t *)ipHeader)[ipHeader->ip_hl];
port = header->th_dport;
printf("IP TCP :- TCP attempt by PID(%d) to %s (port %d)\n
",testing->p_pid,inet_ntoa(ipHeader->ip_dst),port);
printf("\nIP SRC : %s\n", inet_ntoa(ipHeader->ip_src));
printf("IP DEST: %s\n\n", inet_ntoa(ipHeader->ip_dst));
work_to_do = 1;
//int stuff = 0;
while(conditional_val == 0) {
(void) tsleep((caddr_t) & so->so_timeo, PSOCK, "Testing", 2 * hz);
printf("IP DEST: %s\n\n", inet_ntoa(ipHeader->ip_dst));
//sleep(1);
}
//sbunlock(&so->so_snd);
//*top = NULL;
conditional_val = 0;
//return EACCES;
work_to_do = 0;
if(somo2.block == 1) {
thread_funnel_set(network_flock, funnel_state);
return EACCES;
}
}
thread_funnel_set(network_flock, funnel_state);
return 0;
}
conditional_val == to the var that controls the while loop, daemon
will signal 1 when done with the work
work_to_do == lets the daemon know to ask for the info from KEXT so
it can process it. Since dameon is spinning in a loop until it detects
work_to_do == 1;
See any problems with this implementation. I know that when multiple
things are going, and say a process is switched during the while loop
where it sleeps, then it starts to go into deadlock.
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.