debug.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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, write to
  26. * the Free Software Foundation, 59 Temple Place - Suite 330,
  27. * Boston, MA 02111-1307, USA.
  28. *
  29. * Please send any bug reports or fixes you make to the
  30. * email address(es):
  31. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  32. *
  33. * Or submit a bug report through the following website:
  34. * http://www.sf.net/projects/lksctp
  35. *
  36. * Written or modified by:
  37. * La Monte H.P. Yarroll <piggy@acm.org>
  38. * Karl Knutson <karl@athena.chicago.il.us>
  39. * Xingang Guo <xingang.guo@intel.com>
  40. * Jon Grimm <jgrimm@us.ibm.com>
  41. * Daisy Chang <daisyc@us.ibm.com>
  42. * Sridhar Samudrala <sri@us.ibm.com>
  43. *
  44. * Any bugs reported given to us we will try to fix... any fixes shared will
  45. * be incorporated into the next SCTP release.
  46. */
  47. #include <net/sctp/sctp.h>
  48. #if SCTP_DEBUG
  49. int sctp_debug_flag = 1; /* Initially enable DEBUG */
  50. #endif /* SCTP_DEBUG */
  51. /* These are printable forms of Chunk ID's from section 3.1. */
  52. static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
  53. "DATA",
  54. "INIT",
  55. "INIT_ACK",
  56. "SACK",
  57. "HEARTBEAT",
  58. "HEARTBEAT_ACK",
  59. "ABORT",
  60. "SHUTDOWN",
  61. "SHUTDOWN_ACK",
  62. "ERROR",
  63. "COOKIE_ECHO",
  64. "COOKIE_ACK",
  65. "ECN_ECNE",
  66. "ECN_CWR",
  67. "SHUTDOWN_COMPLETE",
  68. };
  69. /* Lookup "chunk type" debug name. */
  70. const char *sctp_cname(const sctp_subtype_t cid)
  71. {
  72. if (cid.chunk <= SCTP_CID_BASE_MAX)
  73. return sctp_cid_tbl[cid.chunk];
  74. switch (cid.chunk) {
  75. case SCTP_CID_ASCONF:
  76. return "ASCONF";
  77. case SCTP_CID_ASCONF_ACK:
  78. return "ASCONF_ACK";
  79. case SCTP_CID_FWD_TSN:
  80. return "FWD_TSN";
  81. case SCTP_CID_AUTH:
  82. return "AUTH";
  83. default:
  84. break;
  85. }
  86. return "unknown chunk";
  87. }
  88. /* These are printable forms of the states. */
  89. const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  90. "STATE_CLOSED",
  91. "STATE_COOKIE_WAIT",
  92. "STATE_COOKIE_ECHOED",
  93. "STATE_ESTABLISHED",
  94. "STATE_SHUTDOWN_PENDING",
  95. "STATE_SHUTDOWN_SENT",
  96. "STATE_SHUTDOWN_RECEIVED",
  97. "STATE_SHUTDOWN_ACK_SENT",
  98. };
  99. /* Events that could change the state of an association. */
  100. const char *const sctp_evttype_tbl[] = {
  101. "EVENT_T_unknown",
  102. "EVENT_T_CHUNK",
  103. "EVENT_T_TIMEOUT",
  104. "EVENT_T_OTHER",
  105. "EVENT_T_PRIMITIVE"
  106. };
  107. /* Return value of a state function */
  108. const char *const sctp_status_tbl[] = {
  109. "DISPOSITION_DISCARD",
  110. "DISPOSITION_CONSUME",
  111. "DISPOSITION_NOMEM",
  112. "DISPOSITION_DELETE_TCB",
  113. "DISPOSITION_ABORT",
  114. "DISPOSITION_VIOLATION",
  115. "DISPOSITION_NOT_IMPL",
  116. "DISPOSITION_ERROR",
  117. "DISPOSITION_BUG"
  118. };
  119. /* Printable forms of primitives */
  120. static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  121. "PRIMITIVE_ASSOCIATE",
  122. "PRIMITIVE_SHUTDOWN",
  123. "PRIMITIVE_ABORT",
  124. "PRIMITIVE_SEND",
  125. "PRIMITIVE_REQUESTHEARTBEAT",
  126. "PRIMITIVE_ASCONF",
  127. };
  128. /* Lookup primitive debug name. */
  129. const char *sctp_pname(const sctp_subtype_t id)
  130. {
  131. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  132. return sctp_primitive_tbl[id.primitive];
  133. return "unknown_primitive";
  134. }
  135. static const char *const sctp_other_tbl[] = {
  136. "NO_PENDING_TSN",
  137. "ICMP_PROTO_UNREACH",
  138. };
  139. /* Lookup "other" debug name. */
  140. const char *sctp_oname(const sctp_subtype_t id)
  141. {
  142. if (id.other <= SCTP_EVENT_OTHER_MAX)
  143. return sctp_other_tbl[id.other];
  144. return "unknown 'other' event";
  145. }
  146. static const char *const sctp_timer_tbl[] = {
  147. "TIMEOUT_NONE",
  148. "TIMEOUT_T1_COOKIE",
  149. "TIMEOUT_T1_INIT",
  150. "TIMEOUT_T2_SHUTDOWN",
  151. "TIMEOUT_T3_RTX",
  152. "TIMEOUT_T4_RTO",
  153. "TIMEOUT_T5_SHUTDOWN_GUARD",
  154. "TIMEOUT_HEARTBEAT",
  155. "TIMEOUT_SACK",
  156. "TIMEOUT_AUTOCLOSE",
  157. };
  158. /* Lookup timer debug name. */
  159. const char *sctp_tname(const sctp_subtype_t id)
  160. {
  161. if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
  162. return sctp_timer_tbl[id.timeout];
  163. return "unknown_timer";
  164. }