ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / net / sctp / debug.c
1 /* SCTP kernel reference Implementation
2  * (C) Copyright IBM Corp. 2001, 2004
3  * Copyright (c) 1999-2000 Cisco, Inc.
4  * Copyright (c) 1999-2001 Motorola, Inc.
5  * Copyright (c) 2001 Intel Corp.
6  * 
7  * This file is part of the SCTP kernel reference Implementation
8  * 
9  * This file is part of the implementation of the add-IP extension,
10  * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
11  * for the SCTP kernel reference Implementation.
12  * 
13  * This file converts numerical ID value to alphabetical names for SCTP
14  * terms such as chunk type, parameter time, event type, etc.
15  * 
16  * The SCTP reference implementation is free software; 
17  * you can redistribute it and/or modify it under the terms of 
18  * the GNU General Public License as published by
19  * the Free Software Foundation; either version 2, or (at your option)
20  * any later version.
21  * 
22  * The SCTP reference implementation is distributed in the hope that it 
23  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
24  *                 ************************
25  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26  * See the GNU General Public License for more details.
27  * 
28  * You should have received a copy of the GNU General Public License
29  * along with GNU CC; see the file COPYING.  If not, write to
30  * the Free Software Foundation, 59 Temple Place - Suite 330,
31  * Boston, MA 02111-1307, USA.  
32  * 
33  * Please send any bug reports or fixes you make to the
34  * email address(es):
35  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
36  * 
37  * Or submit a bug report through the following website:
38  *    http://www.sf.net/projects/lksctp
39  *
40  * Written or modified by: 
41  *    La Monte H.P. Yarroll <piggy@acm.org>
42  *    Karl Knutson          <karl@athena.chicago.il.us>
43  *    Xingang Guo           <xingang.guo@intel.com>
44  *    Jon Grimm             <jgrimm@us.ibm.com>
45  *    Daisy Chang           <daisyc@us.ibm.com>
46  *    Sridhar Samudrala     <sri@us.ibm.com>
47  * 
48  * Any bugs reported given to us we will try to fix... any fixes shared will
49  * be incorporated into the next SCTP release.
50  */
51
52 #include <net/sctp/sctp.h>
53
54 #if SCTP_DEBUG
55 int sctp_debug_flag = 1;        /* Initially enable DEBUG */
56 #endif  /* SCTP_DEBUG */
57
58 /* These are printable forms of Chunk ID's from section 3.1.  */
59 static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
60         "DATA",
61         "INIT",
62         "INIT_ACK",
63         "SACK",
64         "HEARTBEAT",
65         "HEARTBEAT_ACK",
66         "ABORT",
67         "SHUTDOWN",
68         "SHUTDOWN_ACK",
69         "ERROR",
70         "COOKIE_ECHO",
71         "COOKIE_ACK",
72         "ECN_ECNE",
73         "ECN_CWR",
74         "SHUTDOWN_COMPLETE",
75 };
76
77 /* Lookup "chunk type" debug name. */
78 const char *sctp_cname(const sctp_subtype_t cid)
79 {
80         if (cid.chunk < 0)
81                 return "illegal chunk id";
82         if (cid.chunk <= SCTP_CID_BASE_MAX)
83                 return sctp_cid_tbl[cid.chunk];
84         
85         switch (cid.chunk) {
86         case SCTP_CID_ASCONF:
87                 return "ASCONF";
88
89         case SCTP_CID_ASCONF_ACK:
90                 return "ASCONF_ACK";
91
92         case SCTP_CID_FWD_TSN:
93                 return "FWD_TSN";
94
95         default:
96                 return "unknown chunk";
97         };
98         return "unknown chunk";
99 }
100
101 /* These are printable form of variable-length parameters. */
102 const char *sctp_param_tbl[SCTP_PARAM_ECN_CAPABLE + 1] = {
103         "",
104         "PARAM_HEARTBEAT_INFO",
105         "",
106         "",
107         "",
108         "PARAM_IPV4_ADDRESS",
109         "PARAM_IPV6_ADDRESS",
110         "PARAM_STATE_COOKIE",
111         "PARAM_UNRECOGNIZED_PARAMETERS",
112         "PARAM_COOKIE_PRESERVATIVE",
113         "",
114         "PARAM_HOST_NAME_ADDRESS",
115         "PARAM_SUPPORTED_ADDRESS_TYPES",
116 };
117
118 /* These are printable forms of the states.  */
119 const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
120         "STATE_EMPTY",
121         "STATE_CLOSED",
122         "STATE_COOKIE_WAIT",
123         "STATE_COOKIE_ECHOED",
124         "STATE_ESTABLISHED",
125         "STATE_SHUTDOWN_PENDING",
126         "STATE_SHUTDOWN_SENT",
127         "STATE_SHUTDOWN_RECEIVED",
128         "STATE_SHUTDOWN_ACK_SENT",
129 };
130
131 /* Events that could change the state of an association.  */
132 const char *sctp_evttype_tbl[] = {
133         "EVENT_T_unknown",
134         "EVENT_T_CHUNK",
135         "EVENT_T_TIMEOUT",
136         "EVENT_T_OTHER",
137         "EVENT_T_PRIMITIVE"
138 };
139
140 /* Return value of a state function */
141 const char *sctp_status_tbl[] = {
142         "DISPOSITION_DISCARD",
143         "DISPOSITION_CONSUME",
144         "DISPOSITION_NOMEM",
145         "DISPOSITION_DELETE_TCB",
146         "DISPOSITION_ABORT",
147         "DISPOSITION_VIOLATION",
148         "DISPOSITION_NOT_IMPL",
149         "DISPOSITION_ERROR",
150         "DISPOSITION_BUG"
151 };
152
153 /* Printable forms of primitives */
154 static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
155         "PRIMITIVE_ASSOCIATE",
156         "PRIMITIVE_SHUTDOWN",
157         "PRIMITIVE_ABORT",
158         "PRIMITIVE_SEND",
159         "PRIMITIVE_REQUESTHEARTBEAT",
160 };
161
162 /* Lookup primitive debug name. */
163 const char *sctp_pname(const sctp_subtype_t id)
164 {
165         if (id.primitive < 0)
166                 return "illegal primitive";
167         if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
168                 return sctp_primitive_tbl[id.primitive];
169         return "unknown_primitive";
170 }
171
172 static const char *sctp_other_tbl[] = {
173         "NO_PENDING_TSN",
174 };
175
176 /* Lookup "other" debug name. */
177 const char *sctp_oname(const sctp_subtype_t id)
178 {
179         if (id.other < 0)
180                 return "illegal 'other' event";
181         if (id.other < SCTP_EVENT_OTHER_MAX)
182                 return sctp_other_tbl[id.other];
183         return "unknown 'other' event";
184 }
185
186 static const char *sctp_timer_tbl[] = {
187         "TIMEOUT_NONE",
188         "TIMEOUT_T1_COOKIE",
189         "TIMEOUT_T1_INIT",
190         "TIMEOUT_T2_SHUTDOWN",
191         "TIMEOUT_T3_RTX",
192         "TIMEOUT_T4_RTO",
193         "TIMEOUT_T5_SHUTDOWN_GUARD",
194         "TIMEOUT_HEARTBEAT",
195         "TIMEOUT_SACK",
196         "TIMEOUT_AUTOCLOSE",
197 };
198
199 /* Lookup timer debug name. */
200 const char *sctp_tname(const sctp_subtype_t id)
201 {
202         if (id.timeout < 0)
203                 return "illegal 'timer' event";
204         if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
205                 return sctp_timer_tbl[id.timeout];
206         return "unknown_timer";
207 }