Blame view

net/sctp/debug.c 4.62 KB
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
1
  /* SCTP kernel implementation
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
   * (C) Copyright IBM Corp. 2001, 2004
   * Copyright (c) 1999-2000 Cisco, Inc.
   * Copyright (c) 1999-2001 Motorola, Inc.
   * Copyright (c) 2001 Intel Corp.
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
6
   *
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
7
   * This file is part of the SCTP kernel implementation
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
8
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
   * This file converts numerical ID value to alphabetical names for SCTP
   * terms such as chunk type, parameter time, event type, etc.
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
11
   *
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
12
   * This SCTP implementation is free software;
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
13
   * you can redistribute it and/or modify it under the terms of
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
   * the GNU General Public License as published by
   * the Free Software Foundation; either version 2, or (at your option)
   * any later version.
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
17
   *
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
18
   * This SCTP implementation is distributed in the hope that it
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
   * will be useful, but WITHOUT ANY WARRANTY; without even the implied
   *                 ************************
   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   * See the GNU General Public License for more details.
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
23
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
26
   * You should have received a copy of the GNU General Public License
   * along with GNU CC; see the file COPYING.  If not, write to
   * the Free Software Foundation, 59 Temple Place - Suite 330,
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
27
28
   * Boston, MA 02111-1307, USA.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
30
31
   * Please send any bug reports or fixes you make to the
   * email address(es):
   *    lksctp developers <lksctp-developers@lists.sourceforge.net>
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
32
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
35
   * Or submit a bug report through the following website:
   *    http://www.sf.net/projects/lksctp
   *
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
36
   * Written or modified by:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
42
   *    La Monte H.P. Yarroll <piggy@acm.org>
   *    Karl Knutson          <karl@athena.chicago.il.us>
   *    Xingang Guo           <xingang.guo@intel.com>
   *    Jon Grimm             <jgrimm@us.ibm.com>
   *    Daisy Chang	    <daisyc@us.ibm.com>
   *    Sridhar Samudrala	    <sri@us.ibm.com>
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
43
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
46
47
48
49
50
51
52
53
54
   * Any bugs reported given to us we will try to fix... any fixes shared will
   * be incorporated into the next SCTP release.
   */
  
  #include <net/sctp/sctp.h>
  
  #if SCTP_DEBUG
  int sctp_debug_flag = 1;	/* Initially enable DEBUG */
  #endif	/* SCTP_DEBUG */
  
  /* These are printable forms of Chunk ID's from section 3.1.  */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
55
  static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  	"DATA",
  	"INIT",
  	"INIT_ACK",
  	"SACK",
  	"HEARTBEAT",
  	"HEARTBEAT_ACK",
  	"ABORT",
  	"SHUTDOWN",
  	"SHUTDOWN_ACK",
  	"ERROR",
  	"COOKIE_ECHO",
  	"COOKIE_ACK",
  	"ECN_ECNE",
  	"ECN_CWR",
  	"SHUTDOWN_COMPLETE",
  };
  
  /* Lookup "chunk type" debug name. */
  const char *sctp_cname(const sctp_subtype_t cid)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
77
  	if (cid.chunk <= SCTP_CID_BASE_MAX)
  		return sctp_cid_tbl[cid.chunk];
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
78

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
80
81
82
83
84
85
86
87
  	switch (cid.chunk) {
  	case SCTP_CID_ASCONF:
  		return "ASCONF";
  
  	case SCTP_CID_ASCONF_ACK:
  		return "ASCONF_ACK";
  
  	case SCTP_CID_FWD_TSN:
  		return "FWD_TSN";
906f8257e   Wei Yongjun   sctp: Add some mi...
88
89
  	case SCTP_CID_AUTH:
  		return "AUTH";
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
  	default:
3ff50b799   Stephen Hemminger   [NET]: cleanup ex...
91
92
  		break;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
94
95
96
  	return "unknown chunk";
  }
  
  /* These are printable forms of the states.  */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
97
  const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
100
101
102
103
104
105
106
107
108
  	"STATE_CLOSED",
  	"STATE_COOKIE_WAIT",
  	"STATE_COOKIE_ECHOED",
  	"STATE_ESTABLISHED",
  	"STATE_SHUTDOWN_PENDING",
  	"STATE_SHUTDOWN_SENT",
  	"STATE_SHUTDOWN_RECEIVED",
  	"STATE_SHUTDOWN_ACK_SENT",
  };
  
  /* Events that could change the state of an association.  */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
109
  const char *const sctp_evttype_tbl[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
117
  	"EVENT_T_unknown",
  	"EVENT_T_CHUNK",
  	"EVENT_T_TIMEOUT",
  	"EVENT_T_OTHER",
  	"EVENT_T_PRIMITIVE"
  };
  
  /* Return value of a state function */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
118
  const char *const sctp_status_tbl[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
121
122
123
124
125
126
127
128
129
130
  	"DISPOSITION_DISCARD",
  	"DISPOSITION_CONSUME",
  	"DISPOSITION_NOMEM",
  	"DISPOSITION_DELETE_TCB",
  	"DISPOSITION_ABORT",
  	"DISPOSITION_VIOLATION",
  	"DISPOSITION_NOT_IMPL",
  	"DISPOSITION_ERROR",
  	"DISPOSITION_BUG"
  };
  
  /* Printable forms of primitives */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
131
  static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
133
134
135
136
  	"PRIMITIVE_ASSOCIATE",
  	"PRIMITIVE_SHUTDOWN",
  	"PRIMITIVE_ABORT",
  	"PRIMITIVE_SEND",
  	"PRIMITIVE_REQUESTHEARTBEAT",
906f8257e   Wei Yongjun   sctp: Add some mi...
137
  	"PRIMITIVE_ASCONF",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
139
140
141
142
  };
  
  /* Lookup primitive debug name. */
  const char *sctp_pname(const sctp_subtype_t id)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
143
144
145
146
  	if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  		return sctp_primitive_tbl[id.primitive];
  	return "unknown_primitive";
  }
36cbd3dcc   Jan Engelhardt   net: mark read-on...
147
  static const char *const sctp_other_tbl[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148
  	"NO_PENDING_TSN",
d808ad9ab   YOSHIFUJI Hideaki   [NET] SCTP: Fix w...
149
  	"ICMP_PROTO_UNREACH",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
151
152
153
154
  };
  
  /* Lookup "other" debug name. */
  const char *sctp_oname(const sctp_subtype_t id)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
156
157
158
  	if (id.other <= SCTP_EVENT_OTHER_MAX)
  		return sctp_other_tbl[id.other];
  	return "unknown 'other' event";
  }
36cbd3dcc   Jan Engelhardt   net: mark read-on...
159
  static const char *const sctp_timer_tbl[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  	"TIMEOUT_NONE",
  	"TIMEOUT_T1_COOKIE",
  	"TIMEOUT_T1_INIT",
  	"TIMEOUT_T2_SHUTDOWN",
  	"TIMEOUT_T3_RTX",
  	"TIMEOUT_T4_RTO",
  	"TIMEOUT_T5_SHUTDOWN_GUARD",
  	"TIMEOUT_HEARTBEAT",
  	"TIMEOUT_SACK",
  	"TIMEOUT_AUTOCLOSE",
  };
  
  /* Lookup timer debug name. */
  const char *sctp_tname(const sctp_subtype_t id)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
175
176
177
178
  	if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
  		return sctp_timer_tbl[id.timeout];
  	return "unknown_timer";
  }