debug.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #include <net/sctp/sctp.h>
  52. #if SCTP_DEBUG
  53. int sctp_debug_flag = 1; /* Initially enable DEBUG */
  54. #endif /* SCTP_DEBUG */
  55. /* These are printable forms of Chunk ID's from section 3.1. */
  56. static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
  57. "DATA",
  58. "INIT",
  59. "INIT_ACK",
  60. "SACK",
  61. "HEARTBEAT",
  62. "HEARTBEAT_ACK",
  63. "ABORT",
  64. "SHUTDOWN",
  65. "SHUTDOWN_ACK",
  66. "ERROR",
  67. "COOKIE_ECHO",
  68. "COOKIE_ACK",
  69. "ECN_ECNE",
  70. "ECN_CWR",
  71. "SHUTDOWN_COMPLETE",
  72. };
  73. /* Lookup "chunk type" debug name. */
  74. const char *sctp_cname(const sctp_subtype_t cid)
  75. {
  76. if (cid.chunk <= SCTP_CID_BASE_MAX)
  77. return sctp_cid_tbl[cid.chunk];
  78. switch (cid.chunk) {
  79. case SCTP_CID_ASCONF:
  80. return "ASCONF";
  81. case SCTP_CID_ASCONF_ACK:
  82. return "ASCONF_ACK";
  83. case SCTP_CID_FWD_TSN:
  84. return "FWD_TSN";
  85. default:
  86. break;
  87. }
  88. return "unknown chunk";
  89. }
  90. /* These are printable forms of the states. */
  91. const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  92. "STATE_EMPTY",
  93. "STATE_CLOSED",
  94. "STATE_COOKIE_WAIT",
  95. "STATE_COOKIE_ECHOED",
  96. "STATE_ESTABLISHED",
  97. "STATE_SHUTDOWN_PENDING",
  98. "STATE_SHUTDOWN_SENT",
  99. "STATE_SHUTDOWN_RECEIVED",
  100. "STATE_SHUTDOWN_ACK_SENT",
  101. };
  102. /* Events that could change the state of an association. */
  103. const char *sctp_evttype_tbl[] = {
  104. "EVENT_T_unknown",
  105. "EVENT_T_CHUNK",
  106. "EVENT_T_TIMEOUT",
  107. "EVENT_T_OTHER",
  108. "EVENT_T_PRIMITIVE"
  109. };
  110. /* Return value of a state function */
  111. const char *sctp_status_tbl[] = {
  112. "DISPOSITION_DISCARD",
  113. "DISPOSITION_CONSUME",
  114. "DISPOSITION_NOMEM",
  115. "DISPOSITION_DELETE_TCB",
  116. "DISPOSITION_ABORT",
  117. "DISPOSITION_VIOLATION",
  118. "DISPOSITION_NOT_IMPL",
  119. "DISPOSITION_ERROR",
  120. "DISPOSITION_BUG"
  121. };
  122. /* Printable forms of primitives */
  123. static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  124. "PRIMITIVE_ASSOCIATE",
  125. "PRIMITIVE_SHUTDOWN",
  126. "PRIMITIVE_ABORT",
  127. "PRIMITIVE_SEND",
  128. "PRIMITIVE_REQUESTHEARTBEAT",
  129. };
  130. /* Lookup primitive debug name. */
  131. const char *sctp_pname(const sctp_subtype_t id)
  132. {
  133. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  134. return sctp_primitive_tbl[id.primitive];
  135. return "unknown_primitive";
  136. }
  137. static const char *sctp_other_tbl[] = {
  138. "NO_PENDING_TSN",
  139. "ICMP_PROTO_UNREACH",
  140. };
  141. /* Lookup "other" debug name. */
  142. const char *sctp_oname(const sctp_subtype_t id)
  143. {
  144. if (id.other <= SCTP_EVENT_OTHER_MAX)
  145. return sctp_other_tbl[id.other];
  146. return "unknown 'other' event";
  147. }
  148. static const char *sctp_timer_tbl[] = {
  149. "TIMEOUT_NONE",
  150. "TIMEOUT_T1_COOKIE",
  151. "TIMEOUT_T1_INIT",
  152. "TIMEOUT_T2_SHUTDOWN",
  153. "TIMEOUT_T3_RTX",
  154. "TIMEOUT_T4_RTO",
  155. "TIMEOUT_T5_SHUTDOWN_GUARD",
  156. "TIMEOUT_HEARTBEAT",
  157. "TIMEOUT_SACK",
  158. "TIMEOUT_AUTOCLOSE",
  159. };
  160. /* Lookup timer debug name. */
  161. const char *sctp_tname(const sctp_subtype_t id)
  162. {
  163. if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
  164. return sctp_timer_tbl[id.timeout];
  165. return "unknown_timer";
  166. }