147505b8bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
260c778b2SVlad Yasevich /* SCTP kernel implementation
31da177e4SLinus Torvalds * (C) Copyright IBM Corp. 2001, 2004
41da177e4SLinus Torvalds * Copyright (c) 1999-2000 Cisco, Inc.
51da177e4SLinus Torvalds * Copyright (c) 1999-2001 Motorola, Inc.
61da177e4SLinus Torvalds * Copyright (c) 2001 Intel Corp.
71da177e4SLinus Torvalds *
860c778b2SVlad Yasevich * This file is part of the SCTP kernel implementation
91da177e4SLinus Torvalds *
101da177e4SLinus Torvalds * This file converts numerical ID value to alphabetical names for SCTP
111da177e4SLinus Torvalds * terms such as chunk type, parameter time, event type, etc.
121da177e4SLinus Torvalds *
131da177e4SLinus Torvalds * Please send any bug reports or fixes you make to the
141da177e4SLinus Torvalds * email address(es):
1591705c61SDaniel Borkmann * lksctp developers <linux-sctp@vger.kernel.org>
161da177e4SLinus Torvalds *
171da177e4SLinus Torvalds * Written or modified by:
181da177e4SLinus Torvalds * La Monte H.P. Yarroll <piggy@acm.org>
191da177e4SLinus Torvalds * Karl Knutson <karl@athena.chicago.il.us>
201da177e4SLinus Torvalds * Xingang Guo <xingang.guo@intel.com>
211da177e4SLinus Torvalds * Jon Grimm <jgrimm@us.ibm.com>
221da177e4SLinus Torvalds * Daisy Chang <daisyc@us.ibm.com>
231da177e4SLinus Torvalds * Sridhar Samudrala <sri@us.ibm.com>
241da177e4SLinus Torvalds */
251da177e4SLinus Torvalds
261da177e4SLinus Torvalds #include <net/sctp/sctp.h>
271da177e4SLinus Torvalds
281da177e4SLinus Torvalds /* These are printable forms of Chunk ID's from section 3.1. */
2936cbd3dcSJan Engelhardt static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
301da177e4SLinus Torvalds "DATA",
311da177e4SLinus Torvalds "INIT",
321da177e4SLinus Torvalds "INIT_ACK",
331da177e4SLinus Torvalds "SACK",
341da177e4SLinus Torvalds "HEARTBEAT",
351da177e4SLinus Torvalds "HEARTBEAT_ACK",
361da177e4SLinus Torvalds "ABORT",
371da177e4SLinus Torvalds "SHUTDOWN",
381da177e4SLinus Torvalds "SHUTDOWN_ACK",
391da177e4SLinus Torvalds "ERROR",
401da177e4SLinus Torvalds "COOKIE_ECHO",
411da177e4SLinus Torvalds "COOKIE_ACK",
421da177e4SLinus Torvalds "ECN_ECNE",
431da177e4SLinus Torvalds "ECN_CWR",
441da177e4SLinus Torvalds "SHUTDOWN_COMPLETE",
451da177e4SLinus Torvalds };
461da177e4SLinus Torvalds
471da177e4SLinus Torvalds /* Lookup "chunk type" debug name. */
sctp_cname(const union sctp_subtype cid)48bfc6f827SXin Long const char *sctp_cname(const union sctp_subtype cid)
491da177e4SLinus Torvalds {
501da177e4SLinus Torvalds if (cid.chunk <= SCTP_CID_BASE_MAX)
511da177e4SLinus Torvalds return sctp_cid_tbl[cid.chunk];
521da177e4SLinus Torvalds
531da177e4SLinus Torvalds switch (cid.chunk) {
541da177e4SLinus Torvalds case SCTP_CID_ASCONF:
551da177e4SLinus Torvalds return "ASCONF";
561da177e4SLinus Torvalds
571da177e4SLinus Torvalds case SCTP_CID_ASCONF_ACK:
581da177e4SLinus Torvalds return "ASCONF_ACK";
591da177e4SLinus Torvalds
601da177e4SLinus Torvalds case SCTP_CID_FWD_TSN:
611da177e4SLinus Torvalds return "FWD_TSN";
621da177e4SLinus Torvalds
63906f8257SWei Yongjun case SCTP_CID_AUTH:
64906f8257SWei Yongjun return "AUTH";
65906f8257SWei Yongjun
66d1969759SXin Long case SCTP_CID_RECONF:
67d1969759SXin Long return "RECONF";
68d1969759SXin Long
69947820b9SXin Long case SCTP_CID_I_DATA:
70947820b9SXin Long return "I_DATA";
71947820b9SXin Long
72947820b9SXin Long case SCTP_CID_I_FWD_TSN:
73947820b9SXin Long return "I_FWD_TSN";
74947820b9SXin Long
751da177e4SLinus Torvalds default:
763ff50b79SStephen Hemminger break;
773ff50b79SStephen Hemminger }
783ff50b79SStephen Hemminger
791da177e4SLinus Torvalds return "unknown chunk";
801da177e4SLinus Torvalds }
811da177e4SLinus Torvalds
821da177e4SLinus Torvalds /* These are printable forms of the states. */
8336cbd3dcSJan Engelhardt const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
841da177e4SLinus Torvalds "STATE_CLOSED",
851da177e4SLinus Torvalds "STATE_COOKIE_WAIT",
861da177e4SLinus Torvalds "STATE_COOKIE_ECHOED",
871da177e4SLinus Torvalds "STATE_ESTABLISHED",
881da177e4SLinus Torvalds "STATE_SHUTDOWN_PENDING",
891da177e4SLinus Torvalds "STATE_SHUTDOWN_SENT",
901da177e4SLinus Torvalds "STATE_SHUTDOWN_RECEIVED",
911da177e4SLinus Torvalds "STATE_SHUTDOWN_ACK_SENT",
921da177e4SLinus Torvalds };
931da177e4SLinus Torvalds
941da177e4SLinus Torvalds /* Events that could change the state of an association. */
9536cbd3dcSJan Engelhardt const char *const sctp_evttype_tbl[] = {
961da177e4SLinus Torvalds "EVENT_T_unknown",
971da177e4SLinus Torvalds "EVENT_T_CHUNK",
981da177e4SLinus Torvalds "EVENT_T_TIMEOUT",
991da177e4SLinus Torvalds "EVENT_T_OTHER",
1001da177e4SLinus Torvalds "EVENT_T_PRIMITIVE"
1011da177e4SLinus Torvalds };
1021da177e4SLinus Torvalds
1031da177e4SLinus Torvalds /* Return value of a state function */
10436cbd3dcSJan Engelhardt const char *const sctp_status_tbl[] = {
1051da177e4SLinus Torvalds "DISPOSITION_DISCARD",
1061da177e4SLinus Torvalds "DISPOSITION_CONSUME",
1071da177e4SLinus Torvalds "DISPOSITION_NOMEM",
1081da177e4SLinus Torvalds "DISPOSITION_DELETE_TCB",
1091da177e4SLinus Torvalds "DISPOSITION_ABORT",
1101da177e4SLinus Torvalds "DISPOSITION_VIOLATION",
1111da177e4SLinus Torvalds "DISPOSITION_NOT_IMPL",
1121da177e4SLinus Torvalds "DISPOSITION_ERROR",
1131da177e4SLinus Torvalds "DISPOSITION_BUG"
1141da177e4SLinus Torvalds };
1151da177e4SLinus Torvalds
1161da177e4SLinus Torvalds /* Printable forms of primitives */
11736cbd3dcSJan Engelhardt static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
1181da177e4SLinus Torvalds "PRIMITIVE_ASSOCIATE",
1191da177e4SLinus Torvalds "PRIMITIVE_SHUTDOWN",
1201da177e4SLinus Torvalds "PRIMITIVE_ABORT",
1211da177e4SLinus Torvalds "PRIMITIVE_SEND",
1221da177e4SLinus Torvalds "PRIMITIVE_REQUESTHEARTBEAT",
123906f8257SWei Yongjun "PRIMITIVE_ASCONF",
1241da177e4SLinus Torvalds };
1251da177e4SLinus Torvalds
1261da177e4SLinus Torvalds /* Lookup primitive debug name. */
sctp_pname(const union sctp_subtype id)127bfc6f827SXin Long const char *sctp_pname(const union sctp_subtype id)
1281da177e4SLinus Torvalds {
1291da177e4SLinus Torvalds if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
1301da177e4SLinus Torvalds return sctp_primitive_tbl[id.primitive];
1311da177e4SLinus Torvalds return "unknown_primitive";
1321da177e4SLinus Torvalds }
1331da177e4SLinus Torvalds
13436cbd3dcSJan Engelhardt static const char *const sctp_other_tbl[] = {
1351da177e4SLinus Torvalds "NO_PENDING_TSN",
1361da177e4SLinus Torvalds "ICMP_PROTO_UNREACH",
1371da177e4SLinus Torvalds };
1381da177e4SLinus Torvalds
1391da177e4SLinus Torvalds /* Lookup "other" debug name. */
sctp_oname(const union sctp_subtype id)140bfc6f827SXin Long const char *sctp_oname(const union sctp_subtype id)
1411da177e4SLinus Torvalds {
1421da177e4SLinus Torvalds if (id.other <= SCTP_EVENT_OTHER_MAX)
1431da177e4SLinus Torvalds return sctp_other_tbl[id.other];
1441da177e4SLinus Torvalds return "unknown 'other' event";
1451da177e4SLinus Torvalds }
1461da177e4SLinus Torvalds
14736cbd3dcSJan Engelhardt static const char *const sctp_timer_tbl[] = {
1481da177e4SLinus Torvalds "TIMEOUT_NONE",
1491da177e4SLinus Torvalds "TIMEOUT_T1_COOKIE",
1501da177e4SLinus Torvalds "TIMEOUT_T1_INIT",
1511da177e4SLinus Torvalds "TIMEOUT_T2_SHUTDOWN",
1521da177e4SLinus Torvalds "TIMEOUT_T3_RTX",
1531da177e4SLinus Torvalds "TIMEOUT_T4_RTO",
1541da177e4SLinus Torvalds "TIMEOUT_T5_SHUTDOWN_GUARD",
1551da177e4SLinus Torvalds "TIMEOUT_HEARTBEAT",
15614640869SColin Ian King "TIMEOUT_RECONF",
157*92548ec2SXin Long "TIMEOUT_PROBE",
1581da177e4SLinus Torvalds "TIMEOUT_SACK",
1591da177e4SLinus Torvalds "TIMEOUT_AUTOCLOSE",
1601da177e4SLinus Torvalds };
1611da177e4SLinus Torvalds
1621da177e4SLinus Torvalds /* Lookup timer debug name. */
sctp_tname(const union sctp_subtype id)163bfc6f827SXin Long const char *sctp_tname(const union sctp_subtype id)
1641da177e4SLinus Torvalds {
16514640869SColin Ian King BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl));
16614640869SColin Ian King
16714640869SColin Ian King if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
1681da177e4SLinus Torvalds return sctp_timer_tbl[id.timeout];
1691da177e4SLinus Torvalds return "unknown_timer";
1701da177e4SLinus Torvalds }
171