SVCXPRT * svcfd_create(int fd, u_int sendsize, u_int recvsize) { return svc_fd_create(fd, sendsize, recvsize); }
SVCXPRT * svcfd_create(int fd, uint_t sendsize, uint_t recvsize) { return (svc_fd_create(fd, sendsize, recvsize)); }
/* * Like svunix_create(), except the routine takes any *open* UNIX file * descriptor as its first input. Obsoleted by svc_fd_create(); */ SVCXPRT * svcunixfd_create(int fd, u_int sendsize, u_int recvsize) { return (svc_fd_create(fd, sendsize, recvsize)); }
int main (int argc, char *argv[]) { register SVCXPRT *transp; int sockfds[MAX_ICBINN_SOCKETS]; struct sockaddr_in saddrs[MAX_ICBINN_SOCKETS]; pid_t chld; int len, i; #ifndef HAVE_LIBV4V int tflag = 1; #else int tflag = 0; #endif int port[MAX_ICBINN_SOCKETS]; int num_icbinn_sockets = 0; port[0] = ICBINN_PROT_PORT; while ((i = getopt (argc, argv, "p:s:th")) != EOF) { switch (i) { case 'p': case 's': if (num_icbinn_sockets == MAX_ICBINN_SOCKETS) fatal ("attempting to listen to too many sockets - maximum is %d\n", MAX_ICBINN_SOCKETS); if (!optarg) usage (argv[0]); port[num_icbinn_sockets++] = atoi (optarg); break; case 't': tflag++; break; default: usage (argv[0]); } } if (!num_icbinn_sockets) num_icbinn_sockets = 1; if (signal (SIGCHLD, SIG_IGN) == SIG_ERR) fatal ("signal failed: errno %d", errno); for (i = 0; i < num_icbinn_sockets; ++i) { sockfds[i] = svc_create_socket (&saddrs[i], port[i], tflag); if (sockfds[i] < 0) fatal ("Failed to open listening socket tcp=%d port=%d\n", tflag, port[i]); } for (;;) { struct sockaddr_in cl_addr; unsigned long cl_ipaddr; int cl_domid; int socket_index = 0; int svfd; svfd = svc_accept_one_connexion (sockfds, num_icbinn_sockets, &socket_index, &cl_addr); if (svfd < 0) continue; #ifndef DONT_FORK_AND_MAKE_IT_POSSIBLE_TO_DEBUG switch ((chld = fork ())) { case -1: fatal ("fork failed: errno %d", errno); case 0: break; default: close (svfd); svfd = -1; continue; } info ("in child, index of accepted connection = %d", socket_index); for (i = 0; i < num_icbinn_sockets; i++) close (sockfds[i]); #endif cl_ipaddr = ntohl (cl_addr.sin_addr.s_addr); cl_domid = cl_ipaddr & 0xffff; info ("client dom_id = %d", cl_domid); init_rand (); { char icbinn_path[ICBINN_PROT_MAXPATHLEN]; struct stat st; memset (icbinn_path, 0, sizeof (icbinn_path)); if (get_icbinn_path (cl_domid, icbinn_path, ICBINN_PROT_MAXPATHLEN, socket_index) < 0) fatal ("failed to get icbinn-path number %d for domid %d\n", socket_index, cl_domid); info ("icbinn-path number %d is %s", socket_index, icbinn_path); if (stat(icbinn_path, &st) < 0 && errno == ENOENT) { mkdir(icbinn_path, S_IRWXU); } if (chdir (icbinn_path) < 0) fatal ("chdir to icbinn-path %s failed: errno %d", icbinn_path, errno); if (chroot (icbinn_path) < 0) fatal ("chroot to icbinn-path %s failed: errno %d", icbinn_path, errno); } transp = svc_fd_create (svfd, 0, 0); if (!transp) fatal ("cannot create server fd"); /* the last 0 in arg list guarantees that it won't try to connect to a portmap/rpcbind */ if (!svc_register (transp, ICBINN_PROT_PROGRAM, ICBINN_PROT_VERSION, icbinn_prot_program_1, 0)) { fatal ("unable to register (ICBINN_PROT_PROGRAM, ICBINN_PROT_VERSION, 0)."); } /* This function never returns */ svc_input_loop (svfd); } /* NOTREACHED */ }