1
/* SCTP kernel reference Implementation
2
* (C) Copyright IBM Corp. 2003
3
* Copyright (c) 2003 Intel Corp.
5
* This file is part of the SCTP kernel reference Implementation
7
* The SCTP reference implementation is free software;
8
* you can redistribute it and/or modify it under the terms of
9
* the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* The SCTP reference implementation is distributed in the hope that it
14
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
15
* ************************
16
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
* See the GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with GNU CC; see the file COPYING. If not, write to
21
* the Free Software Foundation, 59 Temple Place - Suite 330,
22
* Boston, MA 02111-1307, USA.
24
* Please send any bug reports or fixes you make to the
26
* lksctp developers <lksctp-developers@lists.sourceforge.net>
28
* Or submit a bug report through the following website:
29
* http://www.sf.net/projects/lksctp
31
* Written or modified by:
32
* Gao, Kevin <kevin.gao@intel.com>
34
* Any bugs reported given to us we will try to fix... any fixes shared will
35
* be incorporated into the next SCTP release.
39
* This is a Functional Test to verify basic functionality of
40
* the SCTP T4-RTO support.
42
* - Bind 1 address after association is created, delete the ASCONF packet
43
* Then see whether the T4 timer support functionality is available. And
44
* when error count above error threshold of transport, check whether
45
* the transport will be inactived.
46
* - When error count of association above error threshold of association,
47
* see wheter the association will aborted.
50
#include <net/sctp/sm.h>
53
int main(int argc, char *argv[])
55
struct sock *sk1, *sk2;
56
struct sctp_endpoint *ep1;
57
struct sctp_association *asoc1;
58
struct sctp_transport *tp1;
59
union sctp_addr addr1, addr2;
60
union sctp_addr bindx_addr1;
64
char *messages = "I love the world!";
66
int addr_len, addr_param_len;
70
sctp_addip_enable = 1;
74
addr1.v6.sin6_family = AF_INET6;
75
addr1.v6.sin6_addr = (struct in6_addr) SCTP_ADDR6_GLOBAL_ETH0;
76
addr1.v6.sin6_port = htons(SCTP_TESTPORT_1);
77
addr2.v6.sin6_family = AF_INET6;
78
addr2.v6.sin6_addr = (struct in6_addr) SCTP_ADDR6_GLOBAL_ETH0;
79
addr2.v6.sin6_port = htons(SCTP_TESTPORT_2);
80
bindx_addr1.v6.sin6_family = AF_INET6;
81
bindx_addr1.v6.sin6_addr = (struct in6_addr)SCTP_ADDR6_GLOBAL_ETH1;
82
bindx_addr1.v6.sin6_port = htons(SCTP_TESTPORT_1);
83
addr_len = sizeof(struct sockaddr_in6);
84
addr_param_len = sizeof(sctp_ipv6addr_param_t);
87
addr1.v4.sin_family = AF_INET;
88
addr1.v4.sin_addr.s_addr = SCTP_ADDR_ETH0;
89
addr1.v4.sin_port = htons(SCTP_TESTPORT_1);
90
addr2.v4.sin_family = AF_INET;
91
addr2.v4.sin_addr.s_addr = SCTP_ADDR_ETH0;
92
addr2.v4.sin_port = htons(SCTP_TESTPORT_2);
93
bindx_addr1.v4.sin_family = AF_INET;
94
bindx_addr1.v4.sin_addr.s_addr = SCTP_ADDR_ETH1;
95
bindx_addr1.v4.sin_port = htons(SCTP_TESTPORT_1);
96
addr_len = sizeof(struct sockaddr_in);
97
addr_param_len = sizeof(sctp_ipv4addr_param_t);
100
sk1 = sctp_socket(pf_class, SOCK_SEQPACKET);
101
sk2 = sctp_socket(pf_class, SOCK_SEQPACKET);
103
if (test_bind(sk1, (struct sockaddr *)&addr1, sizeof(addr1))) {
107
if (test_bind(sk2, (struct sockaddr *)&addr2, sizeof(addr2))) {
111
if (0 != sctp_seqpacket_listen(sk2, 1)) {
115
test_frame_send_message(sk1, (struct sockaddr *)&addr2, messages);
117
if (test_run_network()) {
121
test_frame_get_event(sk2, SCTP_ASSOC_CHANGE, SCTP_COMM_UP);
122
test_frame_get_event(sk1, SCTP_ASSOC_CHANGE, SCTP_COMM_UP);
123
test_frame_get_message(sk2, messages);
125
if (test_bindx(sk1, (struct sockaddr *)&bindx_addr1, addr_len,
126
SCTP_BINDX_ADD_ADDR)) {
130
ep1 = sctp_sk(sk1)->ep;
131
asoc1 = test_ep_first_asoc(ep1);
132
tp1 = asoc1->peer.active_path;
134
if (tp1->state == SCTP_INACTIVE) {
138
tp1->error_count = tp1->pathmaxrxt - 2;
139
i = tp1->error_count;
140
while (i <= tp1->pathmaxrxt) {
143
printf("##*******************%d\n", asoc1->peer.active_path->error_count);
144
test_kill_next_packet(SCTP_CID_ASCONF);
146
if (test_run_network()) {
155
if (tp1->state != SCTP_INACTIVE) {
160
if (test_run_network()) {
165
printk("\n\n%s Case 1 passed\n\n\n", argv[0]);
167
sk1 = sctp_socket(pf_class, SOCK_SEQPACKET);
168
sk2 = sctp_socket(pf_class, SOCK_SEQPACKET);
170
if (test_bind(sk1, (struct sockaddr *)&addr1, sizeof(addr1))) {
174
if (test_bind(sk2, (struct sockaddr *)&addr2, sizeof(addr2))) {
178
if (0 != sctp_seqpacket_listen(sk2, 1)) {
182
test_frame_send_message(sk1, (struct sockaddr *)&addr2, messages);
184
if (test_run_network()) {
188
test_frame_get_event(sk2, SCTP_ASSOC_CHANGE, SCTP_COMM_UP);
189
test_frame_get_event(sk1, SCTP_ASSOC_CHANGE, SCTP_COMM_UP);
190
test_frame_get_message(sk2, messages);
192
if (test_bindx(sk1, (struct sockaddr *)&bindx_addr1, addr_len,
193
SCTP_BINDX_ADD_ADDR)) {
197
ep1 = sctp_sk(sk1)->ep;
198
asoc1 = test_ep_first_asoc(ep1);
199
tp1 = asoc1->peer.active_path;
201
asoc1->overall_error_count = asoc1->max_retrans - 2;
202
i = asoc1->overall_error_count;
203
while (i <= asoc1->max_retrans) {
206
printf("##*******************%d\n", asoc1->overall_error_count);
207
test_kill_next_packet(SCTP_CID_ASCONF);
209
if (test_run_network()) {
218
if (!sctp_state(asoc1, CLOSED)) {
225
printk("\n\n%s Case 2 passed\n\n\n", argv[0]);