debug.c 4.5 KB

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