📄 test-sctp_t.c
字号:
continue; } if ( expect(fd3, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 3; case 3: if ( sctp_close(fd1) == FAILURE ) failed = state; if ( sctp_close(fd2) == FAILURE ) failed = state; if ( sctp_close(fd3) == FAILURE ) failed = state; } opt_data.sid_val = 0; opt_optm.mac_val = SCTP_HMAC_NONE; opt_optm.dbg_val = 0; opt_optm.rcv_val = T_NO; opt_optm.ist_val = 1; opt_optm.ost_val = 1; opt_conn.ist_val = 1; opt_conn.ost_val = 1; if ( failed != -1 ) { state = failed; return(FAILURE); } return(SUCCESS); }}int postamble_2(void){ uint failed = -1; state = 0; for ( ;; ) { switch ( state ) { case 0: if ( sctp_discon_req(fd1, 0) == FAILURE ) { failed = state; state = 4; continue; } state = 1; case 1: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) { failed = state; state = 4; continue; } state = 2; case 2: if ( expect(fd3, LONG_WAIT, T_DISCON_IND) == FAILURE ) { failed = state; state = 4; continue; } state = 6; continue; case 4: if ( sctp_discon_req(fd3, 0) == FAILURE ) { failed = state; state = 6; continue; } state = 5; case 5: if ( expect(fd3, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 6; case 6: if ( sctp_unbind_req(fd1) == FAILURE ) failed = state; else if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 7; case 7: if ( sctp_unbind_req(fd2) == FAILURE ) failed = state; else if ( expect(fd2, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 8; case 8: if ( sctp_unbind_req(fd3) == FAILURE ) failed = state; else if ( expect(fd3, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 9; case 9: if ( sctp_close(fd1) == FAILURE ) failed = state; if ( sctp_close(fd2) == FAILURE ) failed = state; if ( sctp_close(fd3) == FAILURE ) failed = state; } opt_data.sid_val = 0; opt_optm.mac_val = SCTP_HMAC_NONE; opt_optm.dbg_val = 0; opt_optm.rcv_val = T_NO; opt_optm.ist_val = 1; opt_optm.ost_val = 1; opt_conn.ist_val = 1; opt_conn.ost_val = 1; if ( failed != -1 ) { state = failed; return(FAILURE); } return(SUCCESS); }}int postamble_3(void){ uint failed = -1; state = 0; for ( ;; ) { switch ( state ) { case 0: if ( sctp_ordrel_req(fd1) == FAILURE ) { failed = state; state = 4; continue; } state = 1; case 1: if ( expect(fd3, LONG_WAIT, T_ORDREL_IND) == FAILURE ) { failed = state; state = 4; continue; } state = 2; case 2: if ( sctp_ordrel_req(fd3) == FAILURE ) { failed = state; state = 4; continue; } state = 3; case 3: if ( expect(fd1, LONG_WAIT, T_ORDREL_IND) == FAILURE ) { failed = state; state = 4; continue; } state = 6; continue; case 4: if ( postamble_2() == FAILURE ) failed = state; break; case 6: if ( sctp_unbind_req(fd1) == FAILURE ) failed = state; else if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 7; case 7: if ( sctp_unbind_req(fd2) == FAILURE ) failed = state; else if ( expect(fd2, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 8; case 8: if ( sctp_unbind_req(fd3) == FAILURE ) failed = state; else if ( expect(fd3, SHORT_WAIT, T_OK_ACK) == FAILURE ) failed = state; state = 9; case 9: if ( sctp_close(fd1) == FAILURE ) failed = state; if ( sctp_close(fd2) == FAILURE ) failed = state; if ( sctp_close(fd3) == FAILURE ) failed = state; } opt_data.sid_val = 0; opt_optm.mac_val = SCTP_HMAC_NONE; opt_optm.dbg_val = 0; opt_optm.rcv_val = T_NO; opt_optm.ist_val = 1; opt_optm.ost_val = 1; opt_conn.ist_val = 1; opt_conn.ost_val = 1; if ( failed != -1 ) { state = failed; return(FAILURE); } return(SUCCESS); }}/* * Do options management. */#define desc_case_1 "\Test Case 1(a):\n\Checks that options management can be performed on several streams\n\and that one stream can be bound and unbound."int test_case_1(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_optmgmt_req(fd1, T_NEGOTIATE); if ( expect(fd1, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 1; case 1: sctp_info_req(fd1); if ( expect(fd1, NORMAL_WAIT, T_INFO_ACK) == FAILURE ) break; state = 2; case 2: sctp_optmgmt_req(fd1, T_CURRENT); if ( expect(fd1, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 3; case 3: sctp_optmgmt_req(fd2, T_NEGOTIATE); if ( expect(fd2, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 4; case 4: sctp_info_req(fd2); if ( expect(fd2, NORMAL_WAIT, T_INFO_ACK) == FAILURE ) break; state = 5; case 5: sctp_optmgmt_req(fd2, T_CURRENT); if ( expect(fd2, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 6; case 6: sctp_optmgmt_req(fd3, T_NEGOTIATE); if ( expect(fd3, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 7; case 7: sctp_info_req(fd3); if ( expect(fd3, NORMAL_WAIT, T_INFO_ACK) == FAILURE ) break; state = 8; case 8: sctp_optmgmt_req(fd3, T_CURRENT); if ( expect(fd3, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Bind and unbind three streams. */#define desc_case_1b "\Test Case 1(b):\n\Checks that three streams can be bound and unbound with\n\on stream as listener."int test_case_1b(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_bind_req(fd1, &addr1, 0); if ( expect(fd1, NORMAL_WAIT, T_BIND_ACK) == FAILURE ) break; state = 1; case 1: sctp_bind_req(fd2, &addr2, 5); if ( expect(fd2, NORMAL_WAIT, T_BIND_ACK) == FAILURE ) break; state = 2; case 2: sctp_bind_req(fd3, &addr3, 0); if ( expect(fd3, NORMAL_WAIT, T_BIND_ACK) == FAILURE ) break; state = 3; case 3: sctp_unbind_req(fd1); if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 4; case 4: sctp_unbind_req(fd2); if ( expect(fd2, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 5; case 5: sctp_unbind_req(fd3); if ( expect(fd3, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Attempt a connection with no listener. */#define desc_case_2 "\Test Case 2:\n\Attempts a connection with no listener. The connection attempt\n\should time out."int test_case_2(void){ int i; state = 0; for ( ;; ) { switch ( state ) { case 0: if ( sctp_optmgmt_req(fd1, T_NEGOTIATE) == FAILURE ) break; state = 1; case 1: if ( expect(fd1, SHORT_WAIT, T_OPTMGMT_ACK) == FAILURE ) break; state = 2; case 2: if ( sctp_bind_req(fd1, &addr1, 0) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, NORMAL_WAIT, T_BIND_ACK) == FAILURE ) break; state = 4; case 4: if ( sctp_conn_req(fd1, &addr2, NULL) == FAILURE ) break; state = 5; case 5: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 6; case 6: for ( i = 0; i < 25; i++ ) if ( expect(fd1, LONG_WAIT, T_DISCON_IND) == SUCCESS ) break; else sctp_sleep((opt_optm.rmx_val*opt_optm.irt_val+999)/1000); if ( i == 25 ) break; state = 7; case 7: if ( sctp_unbind_req(fd1) == FAILURE ) break; state = 8; case 8: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Attempt and withdraw a connection request. */#define desc_case_2a "\Test Case 2(a):\n\Attempts and then withdraws a connection request. The connection\n\should disconnect at both ends."int test_case_2a(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: if ( sctp_conn_req(fd1, &addr2, NULL) == FAILURE ) break; state = 1; case 1: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 2; case 2: if ( expect(fd2, LONG_WAIT, T_CONN_IND) == FAILURE ) break; state = 3; case 3: if ( sctp_discon_req(fd1, 0) == FAILURE ) break; state = 4; case 4: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 5; case 5: if ( expect(fd2, LONG_WAIT, T_DISCON_IND) == FAILURE ) break; state = 6; case 6: return(SUCCESS); } return(FAILURE); }}/* * Attempt and refuse a connection request. */#define desc_case_3 "\Test Case 3:\n\Attempts a connection which is refused by the receiving end.\n\The connection should disconnect at the attempting end."int test_case_3(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, T_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_discon_req(fd2, seq[fd2]); if ( expect(fd2, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, T_DISCON_IND) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Attempt and delayed refuse a connection request. */#define desc_case_3b "\Test Case 3(b):\n\Attempts a delayed refusal of a connection requrest. This delayed\n\refusal should come after the connector has already timed out."int test_case_3b(void){ int i; state = 0; for ( ;; ) { switch ( state ) { case 0: if ( sctp_conn_req(fd1, &addr2, NULL) == FAILURE ) break; state = 1; case 1: if ( expect(fd1, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; state = 2; case 2: if ( expect(fd2, LONG_WAIT, T_CONN_IND) == FAILURE ) break; state = 3; case 3: for ( i = 0; i < 25; i++ ) if ( expect(fd1, LONG_WAIT, T_DISCON_IND) == SUCCESS ) break; else sctp_sleep((opt_optm.rmx_val*opt_optm.irt_val+999)/1000); if ( i == 25 ) break; state = 4; case 4: if ( sctp_discon_req(fd2, seq[fd2]) == FAILURE ) break; state = 5; case 5: if ( expect(fd2, SHORT_WAIT, T_OK_ACK) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Accept a connection. */#define desc_case_4 "\Test Case 4:\n\Accept a connection and then disconnect. This connection attempt\n\should be successf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -