📄 test-xnet.c
字号:
return (SUCCESS); case __TEST_T_RCVCONNECT: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvconnect(3)-->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvconnect(top_fd, &test_rcvcall) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", test_rcvcall.udata.len, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVDIS: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvdis(3)------>| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvdis(fd, &test_rcvdis) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", test_rcvdis.udata.len, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVREL: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvrel(3)------>| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvrel(fd) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", 0, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVRELDATA: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvreldata(3)-->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvreldata(fd, &test_rcvdis) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", test_rcvdis.udata.len, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVUDATA: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvudata(3)---->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvudata(fd, &test_rcvudata, &test_rcvflags) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", test_rcvudata.udata.len, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVUDERR: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvuderr(3)---->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvuderr(fd, &test_uderr) == -1) goto do_terror; return (SUCCESS); case __TEST_T_RCVV: test_t_iov[0].iov_base = test_udata; test_t_iov[0].iov_len = 64; test_t_iov[1].iov_base = test_udata + 64; test_t_iov[1].iov_len = 64; test_t_iov[2].iov_base = test_udata + 64 + 64; test_t_iov[2].iov_len = 64; test_t_iov[3].iov_base = test_udata + 64 + 64 + 64; test_t_iov[3].iov_len = 64; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvv(3)-------->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if ((result = t_rcvv(fd, test_t_iov, test_iovcount, &test_rcvflags)) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", result, test_rcvflags & T_MORE ? '+' : '$', test_rcvflags & T_EXPEDITED ? '!' : ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_RCVVUDATA: test_t_iov[0].iov_base = test_udata; test_t_iov[0].iov_len = 64; test_t_iov[1].iov_base = test_udata + 64; test_t_iov[1].iov_len = 64; test_t_iov[2].iov_base = test_udata + 64 + 64; test_t_iov[2].iov_len = 64; test_t_iov[3].iov_base = test_udata + 64 + 64 + 64; test_t_iov[3].iov_len = 64; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_rcvvudata(3)--->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_rcvvudata(fd, &test_rcvudata, test_t_iov, test_iovcount, &test_rcvflags) == -1) goto do_terror; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, " %4d bytes%c%c | | | [%d]\n", test_rcvudata.udata.len, ' ', ' ', state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } return (SUCCESS); case __TEST_T_SND: { int nbytes = sprintf(test_udata, "Test t_snd data for transmission."); if (verbose && show_data || verbose > 1) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_snd(3)--------->| | %4d bytes | [%d]\n", nbytes, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_snd(fd, test_udata, nbytes, test_sndflags) == -1) goto do_terror; return (SUCCESS); } case __TEST_T_SNDDIS: test_discall.sequence = last_sequence; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_snddis(3)------>| | %4d bytes | [%d]\n", test_discall.udata.len > 0 ? test_discall.udata.len : 0, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_snddis(top_fd, &test_discall) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SNDREL: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sndrel(3)------>| | %4d bytes | [%d]\n", 0, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sndrel(fd) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SNDRELDATA: test_snddis.udata.len = sprintf(test_udata, "Test t_sndreldata data."); test_snddis.sequence = last_sequence; if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sndreldata(3)-->| | %4d bytes | [%d]\n", test_snddis.udata.len > 0 ? test_snddis.udata.len : 0, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sndreldata(fd, &test_snddis) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SNDUDATA: test_sndudata.udata.len = sprintf(test_udata, "Test t_sndudata data."); if (verbose && show_data || verbose > 1) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sndudata(3)---->| | %4d bytes | [%d]\n", test_sndudata.udata.len, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sndudata(fd, &test_sndudata) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SNDV: test_t_iov[0].iov_base = dbuf; test_t_iov[0].iov_len = sprintf(test_t_iov[0].iov_base, "Writev test datum for vector 0."); test_t_iov[1].iov_base = dbuf + test_t_iov[0].iov_len; test_t_iov[1].iov_len = sprintf(test_t_iov[1].iov_base, "Writev test datum for vector 1."); test_t_iov[2].iov_base = dbuf + test_t_iov[1].iov_len; test_t_iov[2].iov_len = sprintf(test_t_iov[2].iov_base, "Writev test datum for vector 2."); test_t_iov[3].iov_base = dbuf + test_t_iov[2].iov_len; test_t_iov[3].iov_len = sprintf(test_t_iov[3].iov_base, "Writev test datum for vector 3."); if (verbose && show_data || verbose > 1) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sndv(3)-------->| | %2d x %4d bytes | [%d]\n", test_iovcount, test_t_iov[0].iov_len, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sndv(fd, test_t_iov, test_iovcount, test_sndflags) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SNDVUDATA: test_t_iov[0].iov_base = dbuf; test_t_iov[0].iov_len = sprintf(test_t_iov[0].iov_base, "Writev test datum for vector 0."); test_t_iov[1].iov_base = dbuf + test_t_iov[0].iov_len; test_t_iov[1].iov_len = sprintf(test_t_iov[1].iov_base, "Writev test datum for vector 1."); test_t_iov[2].iov_base = dbuf + test_t_iov[1].iov_len; test_t_iov[2].iov_len = sprintf(test_t_iov[2].iov_base, "Writev test datum for vector 2."); test_t_iov[3].iov_base = dbuf + test_t_iov[2].iov_len; test_t_iov[3].iov_len = sprintf(test_t_iov[3].iov_base, "Writev test datum for vector 3."); test_sndudata.udata.len = 0; if (verbose && show_data || verbose > 1) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sndvudata(3)--->| | %2d x %4d bytes | [%d]\n", test_iovcount, test_t_iov[0].iov_len, state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sndvudata(fd, &test_sndudata, test_t_iov, test_iovcount) == -1) goto do_terror; return (SUCCESS); case __TEST_T_SYNC: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_sync(3)-------->| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_sync(top_fd) == -1) goto do_terror; return (SUCCESS); case __TEST_T_UNBIND: if (verbose) { lockf(fileno(stdout), F_LOCK, 0); fprintf(stdout, "--t_unbind(3)------>| | | [%d]\n", state); fflush(stdout); lockf(fileno(stdout), F_ULOCK, 0); } if (t_unbind(top_fd) == -1) goto do_terror; return (SUCCESS); 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 = last_qlen; 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 = last_qlen; 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -