📄 test-sctp_n.c
字号:
case __TEST_UNITDATA_REQ: return ("N_UNITDATA_REQ"); case __TEST_OPTMGMT_REQ: return ("N_OPTMGMT_REQ"); case __TEST_CONN_IND: return ("N_CONN_IND"); case __TEST_CONN_CON: return ("N_CONN_CON"); case __TEST_DISCON_IND: return ("N_DISCON_IND"); case __TEST_DATA_IND: return ("N_DATA_IND"); case __TEST_EXDATA_IND: return ("N_EXDATA_IND"); case __TEST_INFO_ACK: return ("N_INFO_ACK"); case __TEST_BIND_ACK: return ("N_BIND_ACK"); case __TEST_ERROR_ACK: return ("N_ERROR_ACK"); case __TEST_OK_ACK: return ("N_OK_ACK"); case __TEST_UNITDATA_IND: return ("N_UNITDATA_IND"); case __TEST_UDERROR_IND: return ("N_UDERROR_IND"); case __TEST_DATACK_REQ: return ("N_DATACK_REQ"); case __TEST_DATACK_IND: return ("N_DATACK_IND"); case __TEST_RESET_REQ: return ("N_RESET_REQ"); case __TEST_RESET_IND: return ("N_RESET_IND"); case __TEST_RESET_RES: return ("N_RESET_RES"); case __TEST_RESET_CON: return ("N_RESET_CON"); } return ("(unexpected)");}const char *ioctl_string(int cmd, intptr_t arg){ switch (cmd) { case I_NREAD: return ("I_NREAD"); case I_PUSH: return ("I_PUSH"); case I_POP: return ("I_POP"); case I_LOOK: return ("I_LOOK"); case I_FLUSH: return ("I_FLUSH"); case I_SRDOPT: return ("I_SRDOPT"); case I_GRDOPT: return ("I_GRDOPT"); case I_STR: if (arg) { struct strioctl *icp = (struct strioctl *) arg; switch (icp->ic_cmd) {#if 0 case _O_TI_BIND: return ("_O_TI_BIND"); case O_TI_BIND: return ("O_TI_BIND"); case _O_TI_GETINFO: return ("_O_TI_GETINFO"); case O_TI_GETINFO: return ("O_TI_GETINFO"); case _O_TI_GETMYNAME: return ("_O_TI_GETMYNAME"); case _O_TI_GETPEERNAME: return ("_O_TI_GETPEERNAME"); case _O_TI_OPTMGMT: return ("_O_TI_OPTMGMT"); case O_TI_OPTMGMT: return ("O_TI_OPTMGMT"); case _O_TI_TLI_MODE: return ("_O_TI_TLI_MODE"); case _O_TI_UNBIND: return ("_O_TI_UNBIND"); case O_TI_UNBIND: return ("O_TI_UNBIND"); case _O_TI_XTI_CLEAR_EVENT: return ("_O_TI_XTI_CLEAR_EVENT"); case _O_TI_XTI_GET_STATE: return ("_O_TI_XTI_GET_STATE"); case _O_TI_XTI_HELLO: return ("_O_TI_XTI_HELLO"); case _O_TI_XTI_MODE: return ("_O_TI_XTI_MODE"); case TI_BIND: return ("TI_BIND"); case TI_CAPABILITY: return ("TI_CAPABILITY"); case TI_GETADDRS: return ("TI_GETADDRS"); case TI_GETINFO: return ("TI_GETINFO"); case TI_GETMYNAME: return ("TI_GETMYNAME"); case TI_GETPEERNAME: return ("TI_GETPEERNAME"); case TI_OPTMGMT: return ("TI_OPTMGMT"); case TI_SETMYNAME: return ("TI_SETMYNAME"); case TI_SETPEERNAME: return ("TI_SETPEERNAME"); case TI_SYNC: return ("TI_SYNC"); case TI_UNBIND: return ("TI_UNBIND");#endif } } return ("I_STR"); case I_SETSIG: return ("I_SETSIG"); case I_GETSIG: return ("I_GETSIG"); case I_FIND: return ("I_FIND"); case I_LINK: return ("I_LINK"); case I_UNLINK: return ("I_UNLINK"); case I_RECVFD: return ("I_RECVFD"); case I_PEEK: return ("I_PEEK"); case I_FDINSERT: return ("I_FDINSERT"); case I_SENDFD: return ("I_SENDFD");#if 0 case I_E_RECVFD: return ("I_E_RECVFD");#endif case I_SWROPT: return ("I_SWROPT"); case I_GWROPT: return ("I_GWROPT"); case I_LIST: return ("I_LIST"); case I_PLINK: return ("I_PLINK"); case I_PUNLINK: return ("I_PUNLINK"); case I_FLUSHBAND: return ("I_FLUSHBAND"); case I_CKBAND: return ("I_CKBAND"); case I_GETBAND: return ("I_GETBAND"); case I_ATMARK: return ("I_ATMARK"); case I_SETCLTIME: return ("I_SETCLTIME"); case I_GETCLTIME: return ("I_GETCLTIME"); case I_CANPUT: return ("I_CANPUT");#if 0 case I_SERROPT: return ("I_SERROPT"); case I_GERROPT: return ("I_GERROPT"); case I_ANCHOR: return ("I_ANCHOR");#endif#if 0 case I_S_RECVFD: return ("I_S_RECVFD"); case I_STATS: return ("I_STATS"); case I_BIGPIPE: return ("I_BIGPIPE");#endif#if 0 case I_GETTP: return ("I_GETTP"); case I_AUTOPUSH: return ("I_AUTOPUSH"); case I_HEAP_REPORT: return ("I_HEAP_REPORT"); case I_FIFO: return ("I_FIFO"); case I_PUTPMSG: return ("I_PUTPMSG"); case I_GETPMSG: return ("I_GETPMSG"); case I_FATTACH: return ("I_FATTACH"); case I_FDETACH: return ("I_FDETACH"); case I_PIPE: return ("I_PIPE");#endif default: return ("(unexpected)"); }}const char *signal_string(int signum){ switch (signum) { case SIGHUP: return ("SIGHUP"); case SIGINT: return ("SIGINT"); case SIGQUIT: return ("SIGQUIT"); case SIGILL: return ("SIGILL"); case SIGABRT: return ("SIGABRT"); case SIGFPE: return ("SIGFPE"); case SIGKILL: return ("SIGKILL"); case SIGSEGV: return ("SIGSEGV"); case SIGPIPE: return ("SIGPIPE"); case SIGALRM: return ("SIGALRM"); case SIGTERM: return ("SIGTERM"); case SIGUSR1: return ("SIGUSR1"); case SIGUSR2: return ("SIGUSR2"); case SIGCHLD: return ("SIGCHLD"); case SIGCONT: return ("SIGCONT"); case SIGSTOP: return ("SIGSTOP"); case SIGTSTP: return ("SIGTSTP"); case SIGTTIN: return ("SIGTTIN"); case SIGTTOU: return ("SIGTTOU"); case SIGBUS: return ("SIGBUS"); case SIGPOLL: return ("SIGPOLL"); case SIGPROF: return ("SIGPROF"); case SIGSYS: return ("SIGSYS"); case SIGTRAP: return ("SIGTRAP"); case SIGURG: return ("SIGURG"); case SIGVTALRM: return ("SIGVTALRM"); case SIGXCPU: return ("SIGXCPU"); case SIGXFSZ: return ("SIGXFSZ"); default: return ("unknown"); }}const char *poll_string(short events){ if (events & POLLIN) return ("POLLIN"); if (events & POLLPRI) return ("POLLPRI"); if (events & POLLOUT) return ("POLLOUT"); if (events & POLLRDNORM) return ("POLLRDNORM"); if (events & POLLRDBAND) return ("POLLRDBAND"); if (events & POLLWRNORM) return ("POLLWRNORM"); if (events & POLLWRBAND) return ("POLLWRBAND"); if (events & POLLERR) return ("POLLERR"); if (events & POLLHUP) return ("POLLHUP"); if (events & POLLNVAL) return ("POLLNVAL"); if (events & POLLMSG) return ("POLLMSG"); return ("none");}const char *poll_events_string(short events){ static char string[256] = ""; int offset = 0, size = 256, len = 0; if (events & POLLIN) { len = snprintf(string + offset, size, "POLLIN|"); offset += len; size -= len; } if (events & POLLPRI) { len = snprintf(string + offset, size, "POLLPRI|"); offset += len; size -= len; } if (events & POLLOUT) { len = snprintf(string + offset, size, "POLLOUT|"); offset += len; size -= len; } if (events & POLLRDNORM) { len = snprintf(string + offset, size, "POLLRDNORM|"); offset += len; size -= len; } if (events & POLLRDBAND) { len = snprintf(string + offset, size, "POLLRDBAND|"); offset += len; size -= len; } if (events & POLLWRNORM) { len = snprintf(string + offset, size, "POLLWRNORM|"); offset += len; size -= len; } if (events & POLLWRBAND) { len = snprintf(string + offset, size, "POLLWRBAND|"); offset += len; size -= len; } if (events & POLLERR) { len = snprintf(string + offset, size, "POLLERR|"); offset += len; size -= len; } if (events & POLLHUP) { len = snprintf(string + offset, size, "POLLHUP|"); offset += len; size -= len; } if (events & POLLNVAL) { len = snprintf(string + offset, size, "POLLNVAL|"); offset += len; size -= len; } if (events & POLLMSG) { len = snprintf(string + offset, size, "POLLMSG|"); offset += len; size -= len; } return (string);}const char *service_type(np_ulong type){ switch (type) { case 0: return ("(none)"); case N_CLNS: return ("N_CLNS"); case N_CONS: return ("N_CONS"); case N_CLNS | N_CONS: return ("N_CLNS|N_CONS"); default: return ("(unknown)"); }}const char *provider_type(np_ulong type){ switch (type) { case N_SUBNET: return ("N_SUBNET"); case N_SNICFP: return ("N_SNICFP"); default: return ("(unknown)"); }}const char *state_string(np_ulong state){ switch (state) { case NS_UNBND: return ("NS_UNBND"); case NS_WACK_BREQ: return ("NS_WACK_BREQ"); case NS_WACK_UREQ: return ("NS_WACK_UREQ"); case NS_IDLE: return ("NS_IDLE"); case NS_WACK_OPTREQ: return ("NS_WACK_OPTREQ"); case NS_WACK_RRES: return ("NS_WACK_RRES"); case NS_WCON_CREQ: return ("NS_WCON_CREQ"); case NS_WRES_CIND: return ("NS_WRES_CIND"); case NS_WACK_CRES: return ("NS_WACK_CRES"); case NS_DATA_XFER: return ("NS_DATA_XFER"); case NS_WCON_RREQ: return ("NS_WCON_RREQ"); case NS_WRES_RIND: return ("NS_WRES_RIND"); case NS_WACK_DREQ6: return ("NS_WACK_DREQ6"); case NS_WACK_DREQ7: return ("NS_WACK_DREQ7"); case NS_WACK_DREQ9: return ("NS_WACK_DREQ9"); case NS_WACK_DREQ10: return ("NS_WACK_DREQ10"); case NS_WACK_DREQ11: return ("NS_WACK_DREQ11"); default: return ("(unknown)"); }}#ifndef SCTP_VERSION_2voidprint_addr(char *add_ptr, size_t add_len){ sctp_addr_t *a = (sctp_addr_t *) add_ptr; size_t anum = add_len >= sizeof(a->port) ? (add_len - sizeof(a->port)) / sizeof(a->addr[0]) : 0; dummy = lockf(fileno(stdout), F_LOCK, 0); if (add_len) { int i; if (add_len != sizeof(a->port) + anum * sizeof(a->addr[0])) fprintf(stdout, "Aaarrg! add_len = %d, anum = %d, ", add_len, anum); fprintf(stdout, "[%d]", ntohs(a->port)); for (i = 0; i < anum; i++) { fprintf(stdout, "%s%d.%d.%d.%d", i ? "," : "", (a->addr[i] >> 0) & 0xff, (a->addr[i] >> 8) & 0xff, (a->addr[i] >> 16) & 0xff, (a->addr[i] >> 24) & 0xff); } } else fprintf(stdout, "(no address)"); fprintf(stdout, "\n"); fflush(stdout); dummy = lockf(fileno(stdout), F_ULOCK, 0);}char *addr_string(char *add_ptr, size_t add_len){ static char buf[128]; size_t len = 0; sctp_addr_t *a = (sctp_addr_t *) add_ptr; size_t anum = add_len >= sizeof(a->port) ? (add_len - sizeof(a->port)) / sizeof(a->addr[0]) : 0; if (add_len) { int i; if (add_len != sizeof(a->port) + anum * sizeof(a->addr[0])) len += snprintf(buf + len, sizeof(buf) - len, "Aaarrg! add_len = %d, anum = %d, ", add_len, anum); len += snprintf(buf + len, sizeof(buf) - len, "[%d]", ntohs(a->port)); for (i = 0; i < anum; i++) { len += snprintf(buf + len, sizeof(buf) - len, "%s%d.%d.%d.%d", i ? "," : "", (a->addr[i] >> 0) & 0xff, (a->addr[i] >> 8) & 0xff, (a->addr[i] >> 16) & 0xff, (a->addr[i] >> 24) & 0xff); } } else len += snprintf(buf + len, sizeof(buf) - len, "(no address)"); /* len += snprintf(buf + len, sizeof(buf) - len, "\0"); */ return buf;}voidprint_addrs(int fd, char *add_ptr, size_t add_len){ fprintf(stdout, "Stupid!\n");}#else /* SCTP_VERSION_2 */voidprint_addr(char *add_ptr, size_t add_len){ struct sockaddr_in *a = (struct sockaddr_in *) add_ptr; size_t anum = add_len / sizeof(*a); dummy = lockf(fileno(stdout), F_LOCK, 0); if (add_len > 0) { int i; if (add_len != anum * sizeof(*a)) fprintf(stdout, "Aaarrg! add_len = %lu, anum = %lu, ", (ulong) add_len, (ulong) anum); fprintf(stdout, "[%d]", ntohs(a[0].sin_port)); for (i = 0; i < anum; i++) { uint32_t addr = a[i].sin_addr.s_addr; fprintf(stdout, "%s%d.%d.%d.%d", i ? "," : "", (addr >> 0) & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, (addr >> 24) & 0xff); } } else fprintf(stdout, "(no address)"); fprintf(stdout, "\n"); fflush(stdout); dummy = lockf(fileno(stdout), F_ULOCK, 0);}char *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -