From a7650de412009e8cb43dab29e56cb8f2411fcd6d Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 8 Dec 2023 16:29:30 +0100 Subject: [PATCH] netif: sctp.h: Introduce value_string for enum sctp_sstat_state This can be used by apps retrieving struct sctp_status through getsockopt(SCTP_STATUS). The relevant field is spinfo_state: osmo_sctp_sstat_state_str(st.sstat_state); Change-Id: Id7d8a9ad7b32406ac603e520b33809d7ae5c762f Related: SYS#6636 --- include/osmocom/netif/sctp.h | 5 +++++ src/sctp.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/osmocom/netif/sctp.h b/include/osmocom/netif/sctp.h index 374cf6e..9dcb6dd 100644 --- a/include/osmocom/netif/sctp.h +++ b/include/osmocom/netif/sctp.h @@ -53,3 +53,8 @@ enum sctp_spinfo_state; extern const struct value_string osmo_sctp_spinfo_state_strs[]; static inline const char *osmo_sctp_spinfo_state_str(enum sctp_spinfo_state val) { return get_value_string(osmo_sctp_spinfo_state_strs, val); } + +enum sctp_sstat_state; +extern const struct value_string osmo_sctp_sstat_state_strs[]; +static inline const char *osmo_sctp_sstat_state_str(enum sctp_sstat_state val) +{ return get_value_string(osmo_sctp_sstat_state_strs, val); } diff --git a/src/sctp.c b/src/sctp.c index c97ff97..807bdac 100644 --- a/src/sctp.c +++ b/src/sctp.c @@ -79,3 +79,17 @@ const struct value_string osmo_sctp_spinfo_state_strs[] = { { SCTP_UNKNOWN, "UNKNOWN" }, { 0, NULL } }; + +/* linux/sctp.h enum sctp_sstat_state */ +const struct value_string osmo_sctp_sstat_state_strs[] = { + { SCTP_EMPTY, "EMPTY" }, + { SCTP_CLOSED, "CLOSED" }, + { SCTP_COOKIE_WAIT, "COOKIE_WAIT" }, + { SCTP_COOKIE_ECHOED, "COOKIE_ECHOED" }, + { SCTP_ESTABLISHED, "ESTABLISHED" }, + { SCTP_SHUTDOWN_PENDING, "SHUTDOWN_PENDING" }, + { SCTP_SHUTDOWN_SENT, "SHUTDOWN_SENT" }, + { SCTP_SHUTDOWN_RECEIVED, "SHUTDOWN_RECEIVED" }, + { SCTP_SHUTDOWN_ACK_SENT, "SHUTDOWN_ACK_SENT" }, + { 0, NULL } +};