📄 test-sctp_n.c
字号:
sctp_bind_req(fd1, &addr1, 3); if ( expect(fd1, NORMAL_WAIT, N_BIND_ACK) == FAILURE ) break; state = 2; case 2: sctp_optmgmt_req(fd1, 0); if ( expect(fd1, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; sctp_info_req(fd1); if ( expect(fd1, NORMAL_WAIT, N_INFO_ACK) == FAILURE ) break; state = 3; case 3: sctp_unbind_req(fd1); if ( expect(fd1, SHORT_WAIT, N_OK_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, N_BIND_ACK) == FAILURE ) break; state = 1; case 1: sctp_bind_req(fd2, &addr2, 5); if ( expect(fd2, NORMAL_WAIT, N_BIND_ACK) == FAILURE ) break; state = 2; case 2: sctp_bind_req(fd3, &addr3, 0); if ( expect(fd3, NORMAL_WAIT, N_BIND_ACK) == FAILURE ) break; state = 3; case 3: sctp_unbind_req(fd1); if ( expect(fd1, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 4; case 4: sctp_unbind_req(fd2); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 5; case 5: sctp_unbind_req(fd3); if ( expect(fd3, SHORT_WAIT, N_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, 0) == FAILURE ) break; state = 1; case 1: if ( expect(fd1, SHORT_WAIT, N_OK_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, N_BIND_ACK) == FAILURE ) break; state = 4; case 4: if ( sctp_conn_req(fd1, &addr2, NULL) == FAILURE ) break; state = 5; case 5: for ( i = 0; i < 25; i++ ) if ( expect(fd1, LONG_WAIT, N_DISCON_IND) == SUCCESS ) break; else sctp_sleep(qos_info.rto_max*(qos_info.max_inits+1)/100); if ( i == 25 ) break; state = 6; case 6: if ( sctp_unbind_req(fd1) == FAILURE ) break; state = 7; case 7: if ( expect(fd1, SHORT_WAIT, N_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: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_discon_req(fd1, 0); if ( expect(fd1, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd2, LONG_WAIT, N_DISCON_IND) == FAILURE ) break; 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, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_discon_req(fd2, seq[fd2]); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, N_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: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: for ( i = 0; i < 25; i++ ) if ( expect(fd1, LONG_WAIT, N_DISCON_IND) == SUCCESS ) break; else sctp_sleep(qos_info.rto_max*(qos_info.max_inits+1)/100); if ( i == 25 ) break; state = 3; case 3: sctp_discon_req(fd2, seq[fd2]); if ( expect(fd2, SHORT_WAIT, N_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 successful."int test_case_4(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_conn_res(fd2, fd3, NULL); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, N_CONN_CON) == FAILURE ) break; state = 4; case 4: sctp_discon_req(fd3, 0); if ( expect(fd3, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 5; case 5: if ( expect(fd1, LONG_WAIT, N_DISCON_IND) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Attempt and delayed accept a connection request. */#define desc_case_4b "\Test Case 4(b):\n\Attempt a connection and delay the acceptance of the connection request.\n\This should result in a disconnection indication after the connection is\n\accepted. "int test_case_4b(void){ int i; state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: for ( i = 0; i < 25; i++ ) if ( expect(fd1, LONG_WAIT, N_DISCON_IND) == SUCCESS ) break; else sctp_sleep(qos_info.rto_max*(qos_info.max_inits+1)/100+1); if ( i == 25 ) break; state = 3; case 3: sctp_conn_res(fd2, fd3, NULL); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 4; case 4: if ( expect(fd3, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 5; case 5: if ( sctp_data_req(fd3, 0, "Hello!", 0) == FAILURE ) break; if ( expect(fd3, LONG_WAIT, N_DISCON_IND) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Accept a connection. */#define desc_case_5 "\Test Case 5:\n\Attempt and accept a connection. This should be successful. The\n\accepting stream uses the SCTP_HMAC_NONE signature on its cookie."int test_case_5(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_conn_res(fd2, fd3, NULL); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, N_CONN_CON) == FAILURE ) break; state = 4; case 4: sctp_discon_req(fd1, 0); if ( expect(fd1, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 5; case 5: if ( expect(fd3, LONG_WAIT, N_DISCON_IND) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Accept a connection (MD5 hashed cookie) */#define desc_case_5b "\Test Case 5(b):\n\Attempt and accept a connection. This should be successful. The\n\accepting stream uses the SCTP_HMAC_MD5 signature on its cookie."int test_case_5b(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_conn_res(fd2, fd3, NULL); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, N_CONN_CON) == FAILURE ) break; state = 4; case 4: sctp_discon_req(fd1, 0); if ( expect(fd1, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 5; case 5: if ( expect(fd3, LONG_WAIT, N_DISCON_IND) == FAILURE ) break; return(SUCCESS); } return(FAILURE); }}/* * Accept a connection (SHA1 hashed cookie) */#define desc_case_5c "\Test Case 5(c):\n\Attempt and accept a connection. This should be successful. The\n\accepting stream uses the SCTP_HMAC_SHA_1 signature on its cookie."int test_case_5c(void){ state = 0; for ( ;; ) { switch ( state ) { case 0: sctp_conn_req(fd1, &addr2, NULL); if ( expect(fd1, SHORT_WAIT, FAILURE) == FAILURE ) break; state = 1; case 1: if ( expect(fd2, LONG_WAIT, N_CONN_IND) == FAILURE ) break; state = 2; case 2: sctp_conn_res(fd2, fd3, NULL); if ( expect(fd2, SHORT_WAIT, N_OK_ACK) == FAILURE ) break; state = 3; case 3: if ( expect(fd1, LONG_WAIT, N_CONN_CON) == FAILURE ) break; state = 4; case 4: sctp_discon_req(fd1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -