rem: status = core->set_socket_event_callback(cookie->socket, NULL, NULL, 0);
add: status = core->socket_set_event_callback(cookie->socket, NULL, NULL, 0);
context: connection_runner(void *_cookie){	connection_cookie *cookie = (connection_cookie *)_cookie;	bool run = true;	while (run) {		net_area_info area[MAX_NET_AREAS];		net_command *command;		status_t status = B_OK;		uint8 *data;		int32 index;		ssize_t bytes = read_port(cookie->localPort,&index,NULL,0);		if (bytes < B_OK)			break;		if (index >= NUM_COMMANDS || index < 0) {			printf("got bad command index: %lx\n",index);			continue;		}		command = cookie->commands + index;		if (clone_command_areas(area,command) < B_OK) {			printf("could not clone command areas!\n");			continue;		}		data = convert_to_local(&command->area[0],&area[0],command->data);		printf("command %lx (index = %ld), buffer = %p, length = %ld, result = %ld\n",command->op,index,data,command->length,command->result);		switch (command->op) {			case NET_STACK_OPEN:			{				struct int_args *args = (struct int_args *)data;				cookie->openFlags = args->value;				printf("opening socket, mode = %lx!\n",cookie->openFlags);				break;			}			case NET_STACK_CLOSE:				printf("closing socket...\n");				run = false;				break;			case NET_STACK_SOCKET:			{				struct socket_args *args = (struct socket_args *)data;				printf("open a socket... family = %d, type = %d, proto = %d\n",args->family,args->type,args->proto);				status = core->initsocket(&cookie->socket);				if (status == 0)					status = core->socreate(args->family,cookie->socket,args->type,args->proto);				break;			}			case NET_STACK_GETSOCKOPT:			case NET_STACK_SETSOCKOPT:			{				struct sockopt_args *sockopt = (struct sockopt_args *)data;				if (command->op == NET_STACK_GETSOCKOPT) {					status = core->sogetopt(cookie->socket,sockopt->level,sockopt->option,						convert_to_local(&command->area[1],&area[1],sockopt->optval),						(size_t *)&sockopt->optlen);				} else {					status = core->sosetopt(cookie->socket,sockopt->level,sockopt->option,						(const void *)convert_to_local(&command->area[1],&area[1],sockopt->optval),						sockopt->optlen);				}				break;			}			case NET_STACK_CONNECT:			case NET_STACK_BIND:			case NET_STACK_GETSOCKNAME:			case NET_STACK_GETPEERNAME:			{				struct sockaddr_args *args = (struct sockaddr_args *)data;				caddr_t addr = (caddr_t)convert_to_local(&command->area[1],&area[1],args->addr);				switch (command->op) {					case NET_STACK_CONNECT:						status = core->soconnect(cookie->socket,addr,args->addrlen);						break;					case NET_STACK_BIND:						status = core->sobind(cookie->socket,addr,args->addrlen);						break;					case NET_STACK_GETSOCKNAME:						status = core->sogetsockname(cookie->socket,(struct sockaddr *)addr,&args->addrlen);						break;					case NET_STACK_GETPEERNAME:						status = core->sogetpeername(cookie->socket,(struct sockaddr *)addr,&args->addrlen);						break;				}				break;			}			case NET_STACK_LISTEN:				status = core->solisten(cookie->socket,((struct int_args *)data)->value);				break;			case NET_STACK_GET_COOKIE:				/* this is needed by accept() call, to be able to pass back				 * in NET_STACK_ACCEPT opcode the cookie of the filedescriptor to 				 * use for the new accepted socket				 */				*((void **)data) = cookie;				break;			case NET_STACK_ACCEPT:			{				struct accept_args *args = (struct accept_args *)data;				connection_cookie *otherCookie = (connection_cookie *)args->cookie;				status = core->soaccept(cookie->socket,&otherCookie->socket,					convert_to_local(&command->area[1],&area[1],args->addr),					&args->addrlen);			}			case NET_STACK_SEND:			{				struct data_xfer_args *args = (struct data_xfer_args *)data;				struct iovec iov;				int flags = 0;				iov.iov_base = convert_to_local(&command->area[1],&area[1],args->data);				iov.iov_len = args->datalen;				status = core->writeit(cookie->socket,&iov,flags);				break;			}			case NET_STACK_RECV:			{				struct data_xfer_args *args = (struct data_xfer_args *)data;				struct iovec iov;				int flags = 0;				iov.iov_base = convert_to_local(&command->area[1],&area[1],args->data);				iov.iov_len = args->datalen;				/* flags gets ignored here... */				status = core->readit(cookie->socket,&iov,&flags);				break;			}			case NET_STACK_RECVFROM:			{				struct msghdr *msg = (struct msghdr *)data;				int received;				msg->msg_name = convert_to_local(&command->area[1],&area[1],msg->msg_name);				msg->msg_iov = convert_to_local(&command->area[2],&area[2],msg->msg_iov);				msg->msg_control = convert_to_local(&command->area[3],&area[3],msg->msg_control);				status = core->recvit(cookie->socket, msg, (caddr_t)&msg->msg_namelen,&received);				if (status == 0)					status = received;				msg->msg_name = convert_to_foreign(&command->area[1],&area[1],msg->msg_name);				msg->msg_iov = convert_to_foreign(&command->area[2],&area[2],msg->msg_iov);				msg->msg_control = convert_to_foreign(&command->area[3],&area[3],msg->msg_control);				break;			}			case NET_STACK_SENDTO:			{				struct msghdr *msg = (struct msghdr *)data;				int sent;				msg->msg_name = convert_to_local(&command->area[1],&area[1],msg->msg_name);				msg->msg_iov = convert_to_local(&command->area[2],&area[2],msg->msg_iov);				msg->msg_control = convert_to_local(&command->area[3],&area[3],msg->msg_control);					status = core->sendit(cookie->socket,msg,msg->msg_flags,&sent);				if (status == 0)					status = sent;				msg->msg_name = convert_to_foreign(&command->area[1],&area[1],msg->msg_name);				msg->msg_iov = convert_to_foreign(&command->area[2],&area[2],msg->msg_iov);				msg->msg_control = convert_to_foreign(&command->area[3],&area[3],msg->msg_control);				break;			}			case NET_STACK_NOTIFY_SOCKET_EVENT:			{				struct notify_socket_event_args *args = (struct notify_socket_event_args *)data;				cookie->socket_event_port = args->notify_port;				cookie->notify_cookie = args->cookie;						if (cookie->socket_event_port != -1)					// start notify socket event					status = core->set_socket_event_callback(cookie->socket, on_socket_event, cookie, 0);				else					// stop notify socket event					status = core->set_socket_event_callback(cookie->socket, NULL, NULL, 0);				break;			}			case NET_STACK_SYSCTL:			{				struct sysctl_args *args = (struct sysctl_args *)data;								status = core->net_sysctl(convert_to_local(&command->area[1],&area[1],args->name),					args->namelen,convert_to_local(&command->area[2],&area[2],args->oldp),					convert_to_local(&command->area[3],&area[3],args->oldlenp),					convert_to_local(&command->area[4],&area[4],args->newp),					args->newlen);				break;			}			case NET_STACK_STOP:				core->stop();				break;			case B_SET_BLOCKING_IO:				cookie->openFlags &= ~O_NONBLOCK;				break;			case B_SET_NONBLOCKING_IO:				cookie->openFlags |= O_NONBLOCK;				break;			case OSIOCGIFCONF:			case SIOCGIFCONF:			{				struct ifconf *ifc = (struct ifconf *)data;				ifc->ifc_buf = convert_to_local(&command->area[1],&area[1],ifc->ifc_buf);				status = core->soo_ioctl(cookie->socket,command->op,(char *)data);				ifc->ifc_buf = convert_to_foreign(&command->area[1],&area[1],ifc->ifc_buf);				break;			}			default:				status = core->soo_ioctl(cookie->socket,command->op,(char *)data);				break;		}		// mark the command as done		command->result = status;		command->op = 0;		delete_cloned_areas(area);		// notify the command pipeline that we're done with the command		release_sem(cookie->commandSemaphore);	}	cookie->runner = -1;	shutdown_connection(cookie);	return 0;}