~ubuntu-branches/ubuntu/utopic/lksctp-tools/utopic-proposed

« back to all changes in this revision

Viewing changes to test/ft_frame_t4_timer.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2006-10-19 20:23:28 UTC
  • mfrom: (2.1.6 edgy)
  • Revision ID: james.westby@ubuntu.com-20061019202328-ts63rxlpp07yl2nc
Tags: 1.0.6.dfsg-4
Update maintainer email address to biebl@debian.org. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* SCTP kernel reference Implementation
 
2
 * (C) Copyright IBM Corp. 2003
 
3
 * Copyright (c) 2003 Intel Corp.
 
4
 *
 
5
 * This file is part of the SCTP kernel reference Implementation
 
6
 * 
 
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)
 
11
 * any later version.
 
12
 * 
 
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.
 
18
 * 
 
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.  
 
23
 * 
 
24
 * Please send any bug reports or fixes you make to the
 
25
 * email address(es):
 
26
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 
27
 * 
 
28
 * Or submit a bug report through the following website:
 
29
 *    http://www.sf.net/projects/lksctp
 
30
 *
 
31
 * Written or modified by: 
 
32
 *    Gao, Kevin        <kevin.gao@intel.com> 
 
33
 * 
 
34
 * Any bugs reported given to us we will try to fix... any fixes shared will
 
35
 * be incorporated into the next SCTP release.
 
36
 */
 
37
 
 
38
/*
 
39
 * This is a Functional Test to verify  basic functionality of
 
40
 * the SCTP T4-RTO support.
 
41
 * 
 
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.
 
48
 */
 
49
 
 
50
#include <net/sctp/sm.h>
 
51
#include <funtest.h>
 
52
 
 
53
int main(int argc, char *argv[])
 
54
{
 
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;
 
61
        
 
62
        int     i;
 
63
        int     rto;
 
64
        char    *messages = "I love the world!";
 
65
        int     pf_class;
 
66
        int     addr_len, addr_param_len;
 
67
 
 
68
        init_Internet();
 
69
        sctp_init();
 
70
        sctp_addip_enable = 1;
 
71
 
 
72
#if TEST_V6
 
73
        pf_class = PF_INET6;
 
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);
 
85
#else
 
86
        pf_class = PF_INET;
 
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);
 
98
#endif
 
99
 
 
100
        sk1 = sctp_socket(pf_class, SOCK_SEQPACKET);
 
101
        sk2 = sctp_socket(pf_class, SOCK_SEQPACKET);
 
102
 
 
103
        if (test_bind(sk1, (struct sockaddr *)&addr1, sizeof(addr1))) {
 
104
                DUMP_CORE;
 
105
        }
 
106
 
 
107
        if (test_bind(sk2, (struct sockaddr *)&addr2, sizeof(addr2))) {
 
108
                DUMP_CORE;
 
109
        }
 
110
 
 
111
        if (0 != sctp_seqpacket_listen(sk2, 1)) {
 
112
                DUMP_CORE;
 
113
        }
 
114
 
 
115
        test_frame_send_message(sk1, (struct sockaddr *)&addr2, messages);
 
116
 
 
117
        if (test_run_network()) {
 
118
                DUMP_CORE;
 
119
        }
 
120
 
 
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);
 
124
 
 
125
        if (test_bindx(sk1, (struct sockaddr *)&bindx_addr1, addr_len,
 
126
                       SCTP_BINDX_ADD_ADDR)) {
 
127
                DUMP_CORE;
 
128
        }
 
129
 
 
130
        ep1 = sctp_sk(sk1)->ep;
 
131
        asoc1 = test_ep_first_asoc(ep1);
 
132
        tp1 = asoc1->peer.active_path;
 
133
 
 
134
        if (tp1->state == SCTP_INACTIVE) {
 
135
                DUMP_CORE;
 
136
        }
 
137
 
 
138
        tp1->error_count = tp1->pathmaxrxt - 2;
 
139
        i = tp1->error_count;
 
140
        while (i <= tp1->pathmaxrxt) {
 
141
                rto = tp1->rto;
 
142
                
 
143
                printf("##*******************%d\n", asoc1->peer.active_path->error_count);
 
144
                test_kill_next_packet(SCTP_CID_ASCONF);
 
145
        
 
146
                if (test_run_network()) { 
 
147
                        DUMP_CORE;
 
148
                }
 
149
 
 
150
                jiffies += rto + 1;
 
151
                test_run_timeout();
 
152
                i++;
 
153
        }
 
154
 
 
155
        if (tp1->state != SCTP_INACTIVE) {
 
156
                DUMP_CORE;
 
157
        }
 
158
 
 
159
        sctp_close(sk1, 0);
 
160
        if (test_run_network()) {
 
161
                DUMP_CORE;
 
162
        }
 
163
        sctp_close(sk2, 0);
 
164
 
 
165
        printk("\n\n%s Case 1 passed\n\n\n", argv[0]);  
 
166
 
 
167
        sk1 = sctp_socket(pf_class, SOCK_SEQPACKET);
 
168
        sk2 = sctp_socket(pf_class, SOCK_SEQPACKET);
 
169
 
 
170
        if (test_bind(sk1, (struct sockaddr *)&addr1, sizeof(addr1))) {
 
171
                DUMP_CORE;
 
172
        }
 
173
 
 
174
        if (test_bind(sk2, (struct sockaddr *)&addr2, sizeof(addr2))) {
 
175
                DUMP_CORE;
 
176
        }
 
177
 
 
178
        if (0 != sctp_seqpacket_listen(sk2, 1)) {
 
179
                DUMP_CORE;
 
180
        }
 
181
 
 
182
        test_frame_send_message(sk1, (struct sockaddr *)&addr2, messages);
 
183
 
 
184
        if (test_run_network()) {
 
185
                DUMP_CORE;
 
186
        }
 
187
 
 
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);
 
191
 
 
192
        if (test_bindx(sk1, (struct sockaddr *)&bindx_addr1, addr_len,
 
193
                       SCTP_BINDX_ADD_ADDR)) {
 
194
                DUMP_CORE;
 
195
        }
 
196
 
 
197
        ep1 = sctp_sk(sk1)->ep;
 
198
        asoc1 = test_ep_first_asoc(ep1);
 
199
        tp1 = asoc1->peer.active_path;
 
200
 
 
201
        asoc1->overall_error_count = asoc1->max_retrans - 2;
 
202
        i = asoc1->overall_error_count;
 
203
        while (i <= asoc1->max_retrans) {
 
204
                rto = tp1->rto;
 
205
                
 
206
                printf("##*******************%d\n", asoc1->overall_error_count);
 
207
                test_kill_next_packet(SCTP_CID_ASCONF);
 
208
        
 
209
                if (test_run_network()) { 
 
210
                        DUMP_CORE;
 
211
                }
 
212
 
 
213
                jiffies += rto + 1;
 
214
                test_run_timeout();
 
215
                i++;
 
216
        }
 
217
 
 
218
        if (!sctp_state(asoc1, CLOSED)) {
 
219
                DUMP_CORE;
 
220
        }
 
221
 
 
222
        sctp_close(sk1, 0);
 
223
        sctp_close(sk2, 0);
 
224
 
 
225
        printk("\n\n%s Case 2 passed\n\n\n", argv[0]);  
 
226
 
 
227
        return 0;       
 
228
}