debug.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 <linux-sctp@vger.kernel.org>
  32. *
  33. * Written or modified by:
  34. * La Monte H.P. Yarroll <piggy@acm.org>
  35. * Karl Knutson <karl@athena.chicago.il.us>
  36. * Xingang Guo <xingang.guo@intel.com>
  37. * Jon Grimm <jgrimm@us.ibm.com>
  38. * Daisy Chang <daisyc@us.ibm.com>
  39. * Sridhar Samudrala <sri@us.ibm.com>
  40. */
  41. #include <net/sctp/sctp.h>
  42. /* These are printable forms of Chunk ID's from section 3.1. */
  43. static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
  44. "DATA",
  45. "INIT",
  46. "INIT_ACK",
  47. "SACK",
  48. "HEARTBEAT",
  49. "HEARTBEAT_ACK",
  50. "ABORT",
  51. "SHUTDOWN",
  52. "SHUTDOWN_ACK",
  53. "ERROR",
  54. "COOKIE_ECHO",
  55. "COOKIE_ACK",
  56. "ECN_ECNE",
  57. "ECN_CWR",
  58. "SHUTDOWN_COMPLETE",
  59. };
  60. /* Lookup "chunk type" debug name. */
  61. const char *sctp_cname(const sctp_subtype_t cid)
  62. {
  63. if (cid.chunk <= SCTP_CID_BASE_MAX)
  64. return sctp_cid_tbl[cid.chunk];
  65. switch (cid.chunk) {
  66. case SCTP_CID_ASCONF:
  67. return "ASCONF";
  68. case SCTP_CID_ASCONF_ACK:
  69. return "ASCONF_ACK";
  70. case SCTP_CID_FWD_TSN:
  71. return "FWD_TSN";
  72. case SCTP_CID_AUTH:
  73. return "AUTH";
  74. default:
  75. break;
  76. }
  77. return "unknown chunk";
  78. }
  79. /* These are printable forms of the states. */
  80. const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  81. "STATE_CLOSED",
  82. "STATE_COOKIE_WAIT",
  83. "STATE_COOKIE_ECHOED",
  84. "STATE_ESTABLISHED",
  85. "STATE_SHUTDOWN_PENDING",
  86. "STATE_SHUTDOWN_SENT",
  87. "STATE_SHUTDOWN_RECEIVED",
  88. "STATE_SHUTDOWN_ACK_SENT",
  89. };
  90. /* Events that could change the state of an association. */
  91. const char *const sctp_evttype_tbl[] = {
  92. "EVENT_T_unknown",
  93. "EVENT_T_CHUNK",
  94. "EVENT_T_TIMEOUT",
  95. "EVENT_T_OTHER",
  96. "EVENT_T_PRIMITIVE"
  97. };
  98. /* Return value of a state function */
  99. const char *const sctp_status_tbl[] = {
  100. "DISPOSITION_DISCARD",
  101. "DISPOSITION_CONSUME",
  102. "DISPOSITION_NOMEM",
  103. "DISPOSITION_DELETE_TCB",
  104. "DISPOSITION_ABORT",
  105. "DISPOSITION_VIOLATION",
  106. "DISPOSITION_NOT_IMPL",
  107. "DISPOSITION_ERROR",
  108. "DISPOSITION_BUG"
  109. };
  110. /* Printable forms of primitives */
  111. static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  112. "PRIMITIVE_ASSOCIATE",
  113. "PRIMITIVE_SHUTDOWN",
  114. "PRIMITIVE_ABORT",
  115. "PRIMITIVE_SEND",
  116. "PRIMITIVE_REQUESTHEARTBEAT",
  117. "PRIMITIVE_ASCONF",
  118. };
  119. /* Lookup primitive debug name. */
  120. const char *sctp_pname(const sctp_subtype_t id)
  121. {
  122. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  123. return sctp_primitive_tbl[id.primitive];
  124. return "unknown_primitive";
  125. }
  126. static const char *const sctp_other_tbl[] = {
  127. "NO_PENDING_TSN",
  128. "ICMP_PROTO_UNREACH",
  129. };
  130. /* Lookup "other" debug name. */
  131. const char *sctp_oname(const sctp_subtype_t id)
  132. {
  133. if (id.other <= SCTP_EVENT_OTHER_MAX)
  134. return sctp_other_tbl[id.other];
  135. return "unknown 'other' event";
  136. }
  137. static const char *const sctp_timer_tbl[] = {
  138. "TIMEOUT_NONE",
  139. "TIMEOUT_T1_COOKIE",
  140. "TIMEOUT_T1_INIT",
  141. "TIMEOUT_T2_SHUTDOWN",
  142. "TIMEOUT_T3_RTX",
  143. "TIMEOUT_T4_RTO",
  144. "TIMEOUT_T5_SHUTDOWN_GUARD",
  145. "TIMEOUT_HEARTBEAT",
  146. "TIMEOUT_SACK",
  147. "TIMEOUT_AUTOCLOSE",
  148. };
  149. /* Lookup timer debug name. */
  150. const char *sctp_tname(const sctp_subtype_t id)
  151. {
  152. if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
  153. return sctp_timer_tbl[id.timeout];
  154. return "unknown_timer";
  155. }