📄 test-tirdwr.c
字号:
ic.ic_cmd = O_TI_GETINFO; ic.ic_len = sizeof(p->info_ack); p->info_req.PRIM_type = T_INFO_REQ; goto do_ioctl; case __TEST_O_TI_OPTMGMT: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | O_TI_OPTMGMT | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = O_TI_OPTMGMT; ic.ic_len = sizeof(p->optmgmt_ack); p->optmgmt_req.PRIM_type = T_OPTMGMT_REQ; p->optmgmt_req.OPT_length = 0; p->optmgmt_req.OPT_offset = 0; p->optmgmt_req.MGMT_flags = T_NEGOTIATE; goto do_ioctl; case __TEST_O_TI_BIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | O_TI_BIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = O_TI_BIND; ic.ic_len = sizeof(p->bind_ack); p->bind_req.PRIM_type = T_BIND_REQ; p->bind_req.ADDR_length = 0; p->bind_req.ADDR_offset = 0; p->bind_req.CONIND_number = 0; goto do_ioctl; case __TEST_O_TI_UNBIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | O_TI_UNBIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = O_TI_UNBIND; ic.ic_len = sizeof(p->ok_ack); p->unbind_req.PRIM_type = T_UNBIND_REQ; goto do_ioctl; case __TEST__O_TI_GETINFO: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_GETINFO | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_GETINFO; ic.ic_len = sizeof(p->info_ack); p->info_req.PRIM_type = T_INFO_REQ; goto do_ioctl; case __TEST__O_TI_OPTMGMT: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_OPTMGMT | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_OPTMGMT; ic.ic_len = sizeof(p->optmgmt_ack); p->optmgmt_req.PRIM_type = T_OPTMGMT_REQ; p->optmgmt_req.OPT_length = 0; p->optmgmt_req.OPT_offset = 0; p->optmgmt_req.MGMT_flags = T_NEGOTIATE; goto do_ioctl; case __TEST__O_TI_BIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_BIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_BIND; ic.ic_len = sizeof(p->bind_ack); p->bind_req.PRIM_type = T_BIND_REQ; p->bind_req.ADDR_length = 0; p->bind_req.ADDR_offset = 0; p->bind_req.CONIND_number = 0; goto do_ioctl; case __TEST__O_TI_UNBIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_UNBIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_UNBIND; ic.ic_len = sizeof(p->ok_ack); p->unbind_req.PRIM_type = T_UNBIND_REQ; goto do_ioctl; case __TEST__O_TI_GETMYNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_GETMYNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_GETMYNAME; ic.ic_len = sizeof(p->addr_ack); p->addr_req.PRIM_type = T_ADDR_REQ; goto do_ioctl; case __TEST__O_TI_GETPEERNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_GETPEERNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_GETPEERNAME; ic.ic_len = sizeof(p->addr_ack); p->addr_req.PRIM_type = T_ADDR_REQ; goto do_ioctl; case __TEST__O_TI_XTI_HELLO: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_XTI_HELLO | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_XTI_HELLO; ic.ic_len = 0; goto do_ioctl; case __TEST__O_TI_XTI_GET_STATE: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_XTI_GET_STATE | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_XTI_GET_STATE; ic.ic_len = 0; goto do_ioctl; case __TEST__O_TI_XTI_CLEAR_EVENT: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_XTI_CLEAR_EVENT | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_XTI_CLEAR_EVENT; ic.ic_len = 0; goto do_ioctl; case __TEST__O_TI_XTI_MODE: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_XTI_MODE | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_XTI_MODE; ic.ic_len = 0; goto do_ioctl; case __TEST__O_TI_TLI_MODE: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | _O_TI_TLI_MODE | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = _O_TI_TLI_MODE; ic.ic_len = 0; goto do_ioctl; case __TEST_TI_GETINFO: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_GETINFO | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_GETINFO; ic.ic_len = sizeof(p->info_ack); p->info_req.PRIM_type = T_INFO_REQ; goto do_ioctl; case __TEST_TI_OPTMGMT: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_OPTMGMT | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_OPTMGMT; ic.ic_len = sizeof(p->optmgmt_ack); p->optmgmt_req.PRIM_type = T_OPTMGMT_REQ; p->optmgmt_req.OPT_length = 0; p->optmgmt_req.OPT_offset = 0; p->optmgmt_req.MGMT_flags = T_NEGOTIATE; goto do_ioctl; case __TEST_TI_BIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_BIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_BIND; ic.ic_len = sizeof(p->bind_ack); p->bind_req.PRIM_type = T_BIND_REQ; p->bind_req.ADDR_length = 0; p->bind_req.ADDR_offset = 0; p->bind_req.CONIND_number = 0; goto do_ioctl; case __TEST_TI_UNBIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_UNBIND | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_UNBIND; ic.ic_len = sizeof(p->ok_ack); p->unbind_req.PRIM_type = T_UNBIND_REQ; goto do_ioctl; case __TEST_TI_GETMYNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_GETMYNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_GETMYNAME; ic.ic_len = sizeof(p->addr_ack); p->addr_req.PRIM_type = T_ADDR_REQ; goto do_ioctl; case __TEST_TI_GETPEERNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_GETPEERNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_GETPEERNAME; ic.ic_len = sizeof(p->addr_ack); p->addr_req.PRIM_type = T_ADDR_REQ; goto do_ioctl; case __TEST_TI_SETMYNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_SETMYNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_SETMYNAME; ic.ic_len = sizeof(p->conn_res); p->conn_res.PRIM_type = T_CONN_RES; p->conn_res.ACCEPTOR_id = 0; p->conn_res.OPT_length = 0; p->conn_res.OPT_offset = 0; p->conn_res.SEQ_number = 0; goto do_ioctl; case __TEST_TI_SETPEERNAME: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_SETPEERNAME | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_SETPEERNAME; ic.ic_len = sizeof(p->conn_req); p->conn_req.PRIM_type = T_CONN_REQ; p->conn_req.DEST_length = 0; p->conn_req.DEST_offset = 0; p->conn_req.OPT_length = 0; p->conn_req.OPT_offset = 0; goto do_ioctl; case __TEST_TI_SYNC: { union { struct ti_sync_req req; struct ti_sync_ack ack; } *s = (typeof(s)) p; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_SYNC | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_SYNC; ic.ic_len = sizeof(*s); s->req.tsr_flags = TSRF_INFO_REQ | TSRF_IS_EXP_IN_RCVBUF | TSRF_QLEN_REQ; goto do_ioctl; } case __TEST_TI_GETADDRS: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_GETADDRS | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_GETADDRS; ic.ic_len = sizeof(p->addr_ack); p->addr_req.PRIM_type = T_ADDR_REQ; goto do_ioctl; case __TEST_TI_CAPABILITY: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--ioctl(2)--------->| | TI_CAPABILITY | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ic.ic_cmd = TI_CAPABILITY; ic.ic_len = sizeof(p->capability_ack); p->capability_req.PRIM_type = T_CAPABILITY_REQ; p->capability_req.CAP_bits1 = TC1_INFO | TC1_ACCEPTOR_ID; goto do_ioctl; default: return SCRIPTERROR; } if (putpmsg(top_fd, ctrl, data, band, flags) < 0) { last_errno = errno; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "***************ERROR: putpmsg failed\n"); fprintf(stdout, " : %s; %s\n", __FUNCTION__, strerror(last_errno)); lockf(fileno(stdout), F_ULOCK, 0); fflush(stdout); } return FAILURE; } return SUCCESS; do_ioctl: if (ioctl(top_fd, I_STR, &ic) == -1) { last_errno = errno & 0x00ff; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "***************ERROR: ioctl failed\n"); fprintf(stdout, " : %s; %s\n", __FUNCTION__, strerror(last_errno)); lockf(fileno(stdout), F_ULOCK, 0); fflush(stdout); } return FAILURE; } return SUCCESS; } if (fd == bot_fd) { switch (action) { case __TEST_WRITE: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " | |< - - - - - - - - - - - - - - -|<-write(2)----------(%d)\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } data->len = sprintf(dbuf, "Write test data."); if (write(bot_fd, dbuf, data->len) < 0) { last_errno = errno; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " ****ERROR: write failed\n"); fprintf(stdout, " ****ERROR: %s; %s\n", __FUNCTION__, strerror(last_errno)); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return FAILURE; } return SUCCESS; case __TEST_WRITEV: { struct iovec vector[4]; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " | |< - - - - - - - - - - - - - - -|<-writev(2)---------(%d)\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } vector[0].iov_base = dbuf; vector[0].iov_len = sprintf(vector[0].iov_base, "Writev test datum for vector 0."); vector[1].iov_base = dbuf + vector[0].iov_len; vector[1].iov_len = sprintf(vector[1].iov_base, "Writev test datum for vector 1."); vector[2].iov_base = dbuf + vector[1].iov_len; vector[2].iov_len = sprintf(vector[2].iov_base, "Writev test datum for vector 2."); vector[3].iov_base = dbuf + vector[2].iov_len; vector[3].iov_len = sprintf(vector[3].iov_base, "Writev test datum for vector 3."); if (writev(bot_fd, vector, 4) < 0) { last_errno = errno; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " ****ERROR: writev failed\n"); fprintf(stdout, " ****ERROR: %s; %s\n", __FUNCTION__, strerror(last_errno)); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return FAILURE; } return SUCCESS; } case __TEST_PUTMSG_DATA: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " | |< - - - - - - - - - - - - - - -|<-putmsg(2)---------(%d)\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } ctrl = NULL; data->len = sprintf(dbuf, "Putmsg test data."); flags = MSG_BAND;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -