debug.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 sctp_subtype_t 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. default:
  74. break;
  75. }
  76. return "unknown chunk";
  77. }
  78. /* These are printable forms of the states. */
  79. const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  80. "STATE_CLOSED",
  81. "STATE_COOKIE_WAIT",
  82. "STATE_COOKIE_ECHOED",
  83. "STATE_ESTABLISHED",
  84. "STATE_SHUTDOWN_PENDING",
  85. "STATE_SHUTDOWN_SENT",
  86. "STATE_SHUTDOWN_RECEIVED",
  87. "STATE_SHUTDOWN_ACK_SENT",
  88. };
  89. /* Events that could change the state of an association. */
  90. const char *const sctp_evttype_tbl[] = {
  91. "EVENT_T_unknown",
  92. "EVENT_T_CHUNK",
  93. "EVENT_T_TIMEOUT",
  94. "EVENT_T_OTHER",
  95. "EVENT_T_PRIMITIVE"
  96. };
  97. /* Return value of a state function */
  98. const char *const sctp_status_tbl[] = {
  99. "DISPOSITION_DISCARD",
  100. "DISPOSITION_CONSUME",
  101. "DISPOSITION_NOMEM",
  102. "DISPOSITION_DELETE_TCB",
  103. "DISPOSITION_ABORT",
  104. "DISPOSITION_VIOLATION",
  105. "DISPOSITION_NOT_IMPL",
  106. "DISPOSITION_ERROR",
  107. "DISPOSITION_BUG"
  108. };
  109. /* Printable forms of primitives */
  110. static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  111. "PRIMITIVE_ASSOCIATE",
  112. "PRIMITIVE_SHUTDOWN",
  113. "PRIMITIVE_ABORT",
  114. "PRIMITIVE_SEND",
  115. "PRIMITIVE_REQUESTHEARTBEAT",
  116. "PRIMITIVE_ASCONF",
  117. };
  118. /* Lookup primitive debug name. */
  119. const char *sctp_pname(const sctp_subtype_t id)
  120. {
  121. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  122. return sctp_primitive_tbl[id.primitive];
  123. return "unknown_primitive";
  124. }
  125. static const char *const sctp_other_tbl[] = {
  126. "NO_PENDING_TSN",
  127. "ICMP_PROTO_UNREACH",
  128. };
  129. /* Lookup "other" debug name. */
  130. const char *sctp_oname(const sctp_subtype_t id)
  131. {
  132. if (id.other <= SCTP_EVENT_OTHER_MAX)
  133. return sctp_other_tbl[id.other];
  134. return "unknown 'other' event";
  135. }
  136. static const char *const sctp_timer_tbl[] = {
  137. "TIMEOUT_NONE",
  138. "TIMEOUT_T1_COOKIE",
  139. "TIMEOUT_T1_INIT",
  140. "TIMEOUT_T2_SHUTDOWN",
  141. "TIMEOUT_T3_RTX",
  142. "TIMEOUT_T4_RTO",
  143. "TIMEOUT_T5_SHUTDOWN_GUARD",
  144. "TIMEOUT_HEARTBEAT",
  145. "TIMEOUT_SACK",
  146. "TIMEOUT_AUTOCLOSE",
  147. };
  148. /* Lookup timer debug name. */
  149. const char *sctp_tname(const sctp_subtype_t id)
  150. {
  151. if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
  152. return sctp_timer_tbl[id.timeout];
  153. return "unknown_timer";
  154. }