debug.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* SCTP kernel 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 implementation
  8. *
  9. * This file converts numerical ID value to alphabetical names for SCTP
  10. * terms such as chunk type, parameter time, event type, etc.
  11. *
  12. * This SCTP implementation is free software;
  13. * you can redistribute it and/or modify it under the terms of
  14. * the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2, or (at your option)
  16. * any later version.
  17. *
  18. * This SCTP implementation is distributed in the hope that it
  19. * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  20. * ************************
  21. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22. * See the GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with GNU CC; see the file COPYING. If not, see
  26. * <http://www.gnu.org/licenses/>.
  27. *
  28. * Please send any bug reports or fixes you make to the
  29. * email address(es):
  30. * lksctp developers <linux-sctp@vger.kernel.org>
  31. *
  32. * Written or modified by:
  33. * La Monte H.P. Yarroll <piggy@acm.org>
  34. * Karl Knutson <karl@athena.chicago.il.us>
  35. * Xingang Guo <xingang.guo@intel.com>
  36. * Jon Grimm <jgrimm@us.ibm.com>
  37. * Daisy Chang <daisyc@us.ibm.com>
  38. * Sridhar Samudrala <sri@us.ibm.com>
  39. */
  40. #include <net/sctp/sctp.h>
  41. /* These are printable forms of Chunk ID's from section 3.1. */
  42. static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
  43. "DATA",
  44. "INIT",
  45. "INIT_ACK",
  46. "SACK",
  47. "HEARTBEAT",
  48. "HEARTBEAT_ACK",
  49. "ABORT",
  50. "SHUTDOWN",
  51. "SHUTDOWN_ACK",
  52. "ERROR",
  53. "COOKIE_ECHO",
  54. "COOKIE_ACK",
  55. "ECN_ECNE",
  56. "ECN_CWR",
  57. "SHUTDOWN_COMPLETE",
  58. };
  59. /* Lookup "chunk type" debug name. */
  60. const char *sctp_cname(const union sctp_subtype cid)
  61. {
  62. if (cid.chunk <= SCTP_CID_BASE_MAX)
  63. return sctp_cid_tbl[cid.chunk];
  64. switch (cid.chunk) {
  65. case SCTP_CID_ASCONF:
  66. return "ASCONF";
  67. case SCTP_CID_ASCONF_ACK:
  68. return "ASCONF_ACK";
  69. case SCTP_CID_FWD_TSN:
  70. return "FWD_TSN";
  71. case SCTP_CID_AUTH:
  72. return "AUTH";
  73. case SCTP_CID_RECONF:
  74. return "RECONF";
  75. case SCTP_CID_I_DATA:
  76. return "I_DATA";
  77. case SCTP_CID_I_FWD_TSN:
  78. return "I_FWD_TSN";
  79. default:
  80. break;
  81. }
  82. return "unknown chunk";
  83. }
  84. /* These are printable forms of the states. */
  85. const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  86. "STATE_CLOSED",
  87. "STATE_COOKIE_WAIT",
  88. "STATE_COOKIE_ECHOED",
  89. "STATE_ESTABLISHED",
  90. "STATE_SHUTDOWN_PENDING",
  91. "STATE_SHUTDOWN_SENT",
  92. "STATE_SHUTDOWN_RECEIVED",
  93. "STATE_SHUTDOWN_ACK_SENT",
  94. };
  95. /* Events that could change the state of an association. */
  96. const char *const sctp_evttype_tbl[] = {
  97. "EVENT_T_unknown",
  98. "EVENT_T_CHUNK",
  99. "EVENT_T_TIMEOUT",
  100. "EVENT_T_OTHER",
  101. "EVENT_T_PRIMITIVE"
  102. };
  103. /* Return value of a state function */
  104. const char *const sctp_status_tbl[] = {
  105. "DISPOSITION_DISCARD",
  106. "DISPOSITION_CONSUME",
  107. "DISPOSITION_NOMEM",
  108. "DISPOSITION_DELETE_TCB",
  109. "DISPOSITION_ABORT",
  110. "DISPOSITION_VIOLATION",
  111. "DISPOSITION_NOT_IMPL",
  112. "DISPOSITION_ERROR",
  113. "DISPOSITION_BUG"
  114. };
  115. /* Printable forms of primitives */
  116. static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  117. "PRIMITIVE_ASSOCIATE",
  118. "PRIMITIVE_SHUTDOWN",
  119. "PRIMITIVE_ABORT",
  120. "PRIMITIVE_SEND",
  121. "PRIMITIVE_REQUESTHEARTBEAT",
  122. "PRIMITIVE_ASCONF",
  123. };
  124. /* Lookup primitive debug name. */
  125. const char *sctp_pname(const union sctp_subtype id)
  126. {
  127. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  128. return sctp_primitive_tbl[id.primitive];
  129. return "unknown_primitive";
  130. }
  131. static const char *const sctp_other_tbl[] = {
  132. "NO_PENDING_TSN",
  133. "ICMP_PROTO_UNREACH",
  134. };
  135. /* Lookup "other" debug name. */
  136. const char *sctp_oname(const union sctp_subtype id)
  137. {
  138. if (id.other <= SCTP_EVENT_OTHER_MAX)
  139. return sctp_other_tbl[id.other];
  140. return "unknown 'other' event";
  141. }
  142. static const char *const sctp_timer_tbl[] = {
  143. "TIMEOUT_NONE",
  144. "TIMEOUT_T1_COOKIE",
  145. "TIMEOUT_T1_INIT",
  146. "TIMEOUT_T2_SHUTDOWN",
  147. "TIMEOUT_T3_RTX",
  148. "TIMEOUT_T4_RTO",
  149. "TIMEOUT_T5_SHUTDOWN_GUARD",
  150. "TIMEOUT_HEARTBEAT",
  151. "TIMEOUT_RECONF",
  152. "TIMEOUT_SACK",
  153. "TIMEOUT_AUTOCLOSE",
  154. };
  155. /* Lookup timer debug name. */
  156. const char *sctp_tname(const union sctp_subtype id)
  157. {
  158. BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl));
  159. if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
  160. return sctp_timer_tbl[id.timeout];
  161. return "unknown_timer";
  162. }