Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /* SCTP kernel implementation
0003  * (C) Copyright IBM Corp. 2001, 2004
0004  * Copyright (c) 1999-2000 Cisco, Inc.
0005  * Copyright (c) 1999-2001 Motorola, Inc.
0006  * Copyright (c) 2001 Intel Corp.
0007  *
0008  * This file is part of the SCTP kernel implementation
0009  *
0010  * This file converts numerical ID value to alphabetical names for SCTP
0011  * terms such as chunk type, parameter time, event type, etc.
0012  *
0013  * Please send any bug reports or fixes you make to the
0014  * email address(es):
0015  *    lksctp developers <linux-sctp@vger.kernel.org>
0016  *
0017  * Written or modified by:
0018  *    La Monte H.P. Yarroll <piggy@acm.org>
0019  *    Karl Knutson          <karl@athena.chicago.il.us>
0020  *    Xingang Guo           <xingang.guo@intel.com>
0021  *    Jon Grimm             <jgrimm@us.ibm.com>
0022  *    Daisy Chang       <daisyc@us.ibm.com>
0023  *    Sridhar Samudrala     <sri@us.ibm.com>
0024  */
0025 
0026 #include <net/sctp/sctp.h>
0027 
0028 /* These are printable forms of Chunk ID's from section 3.1.  */
0029 static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
0030     "DATA",
0031     "INIT",
0032     "INIT_ACK",
0033     "SACK",
0034     "HEARTBEAT",
0035     "HEARTBEAT_ACK",
0036     "ABORT",
0037     "SHUTDOWN",
0038     "SHUTDOWN_ACK",
0039     "ERROR",
0040     "COOKIE_ECHO",
0041     "COOKIE_ACK",
0042     "ECN_ECNE",
0043     "ECN_CWR",
0044     "SHUTDOWN_COMPLETE",
0045 };
0046 
0047 /* Lookup "chunk type" debug name. */
0048 const char *sctp_cname(const union sctp_subtype cid)
0049 {
0050     if (cid.chunk <= SCTP_CID_BASE_MAX)
0051         return sctp_cid_tbl[cid.chunk];
0052 
0053     switch (cid.chunk) {
0054     case SCTP_CID_ASCONF:
0055         return "ASCONF";
0056 
0057     case SCTP_CID_ASCONF_ACK:
0058         return "ASCONF_ACK";
0059 
0060     case SCTP_CID_FWD_TSN:
0061         return "FWD_TSN";
0062 
0063     case SCTP_CID_AUTH:
0064         return "AUTH";
0065 
0066     case SCTP_CID_RECONF:
0067         return "RECONF";
0068 
0069     case SCTP_CID_I_DATA:
0070         return "I_DATA";
0071 
0072     case SCTP_CID_I_FWD_TSN:
0073         return "I_FWD_TSN";
0074 
0075     default:
0076         break;
0077     }
0078 
0079     return "unknown chunk";
0080 }
0081 
0082 /* These are printable forms of the states.  */
0083 const char *const sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
0084     "STATE_CLOSED",
0085     "STATE_COOKIE_WAIT",
0086     "STATE_COOKIE_ECHOED",
0087     "STATE_ESTABLISHED",
0088     "STATE_SHUTDOWN_PENDING",
0089     "STATE_SHUTDOWN_SENT",
0090     "STATE_SHUTDOWN_RECEIVED",
0091     "STATE_SHUTDOWN_ACK_SENT",
0092 };
0093 
0094 /* Events that could change the state of an association.  */
0095 const char *const sctp_evttype_tbl[] = {
0096     "EVENT_T_unknown",
0097     "EVENT_T_CHUNK",
0098     "EVENT_T_TIMEOUT",
0099     "EVENT_T_OTHER",
0100     "EVENT_T_PRIMITIVE"
0101 };
0102 
0103 /* Return value of a state function */
0104 const char *const sctp_status_tbl[] = {
0105     "DISPOSITION_DISCARD",
0106     "DISPOSITION_CONSUME",
0107     "DISPOSITION_NOMEM",
0108     "DISPOSITION_DELETE_TCB",
0109     "DISPOSITION_ABORT",
0110     "DISPOSITION_VIOLATION",
0111     "DISPOSITION_NOT_IMPL",
0112     "DISPOSITION_ERROR",
0113     "DISPOSITION_BUG"
0114 };
0115 
0116 /* Printable forms of primitives */
0117 static const char *const sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
0118     "PRIMITIVE_ASSOCIATE",
0119     "PRIMITIVE_SHUTDOWN",
0120     "PRIMITIVE_ABORT",
0121     "PRIMITIVE_SEND",
0122     "PRIMITIVE_REQUESTHEARTBEAT",
0123     "PRIMITIVE_ASCONF",
0124 };
0125 
0126 /* Lookup primitive debug name. */
0127 const char *sctp_pname(const union sctp_subtype id)
0128 {
0129     if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
0130         return sctp_primitive_tbl[id.primitive];
0131     return "unknown_primitive";
0132 }
0133 
0134 static const char *const sctp_other_tbl[] = {
0135     "NO_PENDING_TSN",
0136     "ICMP_PROTO_UNREACH",
0137 };
0138 
0139 /* Lookup "other" debug name. */
0140 const char *sctp_oname(const union sctp_subtype id)
0141 {
0142     if (id.other <= SCTP_EVENT_OTHER_MAX)
0143         return sctp_other_tbl[id.other];
0144     return "unknown 'other' event";
0145 }
0146 
0147 static const char *const sctp_timer_tbl[] = {
0148     "TIMEOUT_NONE",
0149     "TIMEOUT_T1_COOKIE",
0150     "TIMEOUT_T1_INIT",
0151     "TIMEOUT_T2_SHUTDOWN",
0152     "TIMEOUT_T3_RTX",
0153     "TIMEOUT_T4_RTO",
0154     "TIMEOUT_T5_SHUTDOWN_GUARD",
0155     "TIMEOUT_HEARTBEAT",
0156     "TIMEOUT_RECONF",
0157     "TIMEOUT_PROBE",
0158     "TIMEOUT_SACK",
0159     "TIMEOUT_AUTOCLOSE",
0160 };
0161 
0162 /* Lookup timer debug name. */
0163 const char *sctp_tname(const union sctp_subtype id)
0164 {
0165     BUILD_BUG_ON(SCTP_EVENT_TIMEOUT_MAX + 1 != ARRAY_SIZE(sctp_timer_tbl));
0166 
0167     if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
0168         return sctp_timer_tbl[id.timeout];
0169     return "unknown_timer";
0170 }