/// start the client for the usb device 'dev' void start_client(char const *dev) { // on the server instead could create many char tun_name[IFNAMSIZ]; tun_setup(TUNTAP_INTERFACE); // a new device should be opened! tun_name[0] = 0; // create the tap-device // it will exit abruptly if it doesn't open it correctly tun_open(DEFAULT_CLIENT_NO, tun_name); fflush(stdout); setup_routes(tun_name); // wrapper for select fdglue_t fdg; mcp_t *mcp; serialif_t *sif; if (dev) { sif = create_serial_connection(dev, &mcp); } else { sif = create_fifo_connection(&mcp); } init_glue(&fdg,sif,mcp,DEFAULT_CLIENT_NO); main_loop(&fdg); }
int main() { int i = 0; int is_main = 1; int ret; // fork ipc helper for (i = 1; i < IPC_HELPER_NUM; ++i) { pid_t pid = fork(); if (pid == 0) { // child is_main = 0; } else if (pid < 0) { fprintf(stderr, "Failed to fork IPC helper, exiting\n"); return -1; } } if ((ret = init_binder_ipc())) { fprintf(stderr, "Cannot intialize binder IPC channel, ret=%d\n", ret); return 1; } if ((ret = init_glue())) { fprintf(stderr, "Cannot initialize glue, ret=%d\n", ret); return 1; } if ((ret = init_workers())) { fprintf(stderr, "Cannot initialize worker threads, ret=%d\n", ret); return 1; } printf("[%d] Venus ready\n", getpid()); dispatcher_loop(); printf("Venus exited.\n"); return 0; }