debug.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* SCTP kernel implementation
  3. * (C) Copyright IBM Corp. 2001, 2004
  4. * Copyright (c) 1999-2000 Cisco, Inc.
  5. * Copyright (c) 1999-2001 Motorola, Inc.
  6. * Copyright (c) 2001 Intel Corp.
  7. *
  8. * This file is part of the SCTP kernel implementation
  9. *
  10. * This file converts numerical ID value to alphabetical names for SCTP
  11. * terms such as chunk type, parameter time, event type, etc.
  12. *
  13. * Please send any bug reports or fixes you make to the
  14. * email address(es):
  15. * lksctp developers <[email protected]>
  16. *
  17. * Written or modified by:
  18. * La Monte H.P. Yarroll <[email protected]>
  19. * Karl Knutson <[email protected]>
  20. * Xingang Guo <[email protected]>
  21. * Jon Grimm <[email protected]>
  22. * Daisy Chang <[email protected]>
  23. * Sridhar Samudrala <[email protected]>
  24. */
  25. #include <net/sctp/sctp.h>
  26. /* These are printable forms of Chunk ID's from section 3.1. */
  27. static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
  28. "DATA",
  29. "INIT",
  30. "INIT_ACK",
  31. "SACK",
  32. "HEARTBEAT",
  33. "HEARTBEAT_ACK",
  34. "ABORT",
  35. "SHUTDOWN",
  36. "SHUTDOWN_ACK",
  37. "ERROR",
  38. "COOKIE_ECHO",
  39. "COOKIE_ACK",
  40. "ECN_ECNE",
  41. "ECN_CWR",
  42. "SHUTDOWN_COMPLETE",
  43. };
  44. /* Lookup "chunk type" debug name. */
  45. const char *sctp_cname(const union sctp_subtype cid)
  46. {
  47. if (cid.chunk <= SCTP_CID_BASE_MAX)
  48. return sctp_cid_tbl[cid.chunk];
  49. switch (cid.chunk) {
  50. case SCTP_CID_ASCONF:
  51. return "ASCONF";
  52. case SCTP_CID_ASCONF_ACK:
  53. return "ASCONF_ACK";
  54. case SCTP_CID_FWD_TSN:
  55. return "FWD_TSN";
  56. case SCTP_CID_AUTH:
  57. return "AUTH";
  58. case SCTP_CID_RECONF:
  59. return "RECONF";
  60. case SCTP_CID_I_DATA:
  61. return "I_DATA";
  62. case SCTP_CID_I_FWD_TSN:
  63. return "I_FWD_TSN";
  64. default:
  65. break;
  66. }
  67. return "unknown chunk";
  68. }
  69. /* These are printable forms of the states. */
  70. const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
  71. "STATE_CLOSED",
  72. "STATE_COOKIE_WAIT",
  73. "STATE_COOKIE_ECHOED",
  74. "STATE_ESTABLISHED",
  75. "STATE_SHUTDOWN_PENDING",
  76. "STATE_SHUTDOWN_SENT",
  77. "STATE_SHUTDOWN_RECEIVED",
  78. "STATE_SHUTDOWN_ACK_SENT",
  79. };
  80. /* Events that could change the state of an association. */
  81. const char *const sctp_evttype_tbl[] = {
  82. "EVENT_T_unknown",
  83. "EVENT_T_CHUNK",
  84. "EVENT_T_TIMEOUT",
  85. "EVENT_T_OTHER",
  86. "EVENT_T_PRIMITIVE"
  87. };
  88. /* Return value of a state function */
  89. const char *const sctp_status_tbl[] = {
  90. "DISPOSITION_DISCARD",
  91. "DISPOSITION_CONSUME",
  92. "DISPOSITION_NOMEM",
  93. "DISPOSITION_DELETE_TCB",
  94. "DISPOSITION_ABORT",
  95. "DISPOSITION_VIOLATION",
  96. "DISPOSITION_NOT_IMPL",
  97. "DISPOSITION_ERROR",
  98. "DISPOSITION_BUG"
  99. };
  100. /* Printable forms of primitives */
  101. static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
  102. "PRIMITIVE_ASSOCIATE",
  103. "PRIMITIVE_SHUTDOWN",
  104. "PRIMITIVE_ABORT",
  105. "PRIMITIVE_SEND",
  106. "PRIMITIVE_REQUESTHEARTBEAT",
  107. "PRIMITIVE_ASCONF",
  108. };
  109. /* Lookup primitive debug name. */
  110. const char *sctp_pname(const union sctp_subtype id)
  111. {
  112. if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
  113. return sctp_primitive_tbl[id.primitive];
  114. return "unknown_primitive";
  115. }
  116. static const char *const sctp_other_tbl[] = {
  117. "NO_PENDING_TSN",
  118. "ICMP_PROTO_UNREACH",
  119. };
  120. /* Lookup "other" debug name. */
  121. const char *sctp_oname(const union sctp_subtype id)
  122. {
  123. if (id.other <= SCTP_EVENT_OTHER_MAX)
  124. return sctp_other_tbl[id.other];
  125. return "unknown 'other' event";
  126. }
  127. static const char *const sctp_timer_tbl[] = {
  128. "TIMEOUT_NONE",
  129. "TIMEOUT_T1_COOKIE",
  130. "TIMEOUT_T1_INIT",
  131. "TIMEOUT_T2_SHUTDOWN",
  132. "TIMEOUT_T3_RTX",
  133. "TIMEOUT_T4_RTO",
  134. "TIMEOUT_T5_SHUTDOWN_GUARD",
  135. "TIMEOUT_HEARTBEAT",
  136. "TIMEOUT_RECONF",
  137. "TIMEOUT_PROBE",
  138. "TIMEOUT_SACK",
  139. "TIMEOUT_AUTOCLOSE",
  140. };
  141. /* Lookup timer debug name. */
  142. const char *sctp_tname(const union sctp_subtype id)
  143. {
  144. BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl));
  145. if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
  146. return sctp_timer_tbl[id.timeout];
  147. return "unknown_timer";
  148. }