diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-11-23 13:49:20 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-11-23 14:18:40 +0100 |
commit | d4a1107586e8fefb18de10b9d68d63a2d3f1fe0d (patch) | |
tree | 6f0e7a33e262d2d95e3e040f37ddc0f23d27bb7e | |
parent | 5967fa00580f07ddb428df0558e4d49aa1b7a7d1 (diff) |
Introduce sctp.h to provide SCTP related functionalities
These value_strings are taken from existing private ones in
libosmo-sccp.git osmo_ss7.c, and are moved here in order to be
reused by other projects, such as osmo-hnodeb.
Change-Id: Ica6f01851fb94e31f4ef097494bb1b8a95597ba6
-rw-r--r-- | TODO-RELEASE | 1 | ||||
-rw-r--r-- | include/osmocom/netif/Makefile.am | 4 | ||||
-rw-r--r-- | include/osmocom/netif/sctp.h | 13 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/sctp.c | 28 |
5 files changed, 50 insertions, 0 deletions
diff --git a/TODO-RELEASE b/TODO-RELEASE index d0852fc..1c9a2a6 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +sctp.h new APIs diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am index 39df08a..d9d030b 100644 --- a/include/osmocom/netif/Makefile.am +++ b/include/osmocom/netif/Makefile.am @@ -8,4 +8,8 @@ osmonetif_HEADERS = amr.h \ rtp.h \ stream.h +if ENABLE_LIBSCTP +osmonetif_HEADERS += sctp.h +endif + osmonetifdir = $(includedir)/osmocom/netif diff --git a/include/osmocom/netif/sctp.h b/include/osmocom/netif/sctp.h new file mode 100644 index 0000000..2b2e072 --- /dev/null +++ b/include/osmocom/netif/sctp.h @@ -0,0 +1,13 @@ +#pragma once + +#include <osmocom/core/utils.h> + +enum sctp_sac_state; +extern const struct value_string osmo_sctp_assoc_chg_strs[]; +static inline const char *osmo_sctp_assoc_chg_str(enum sctp_sac_state val) +{ return get_value_string(osmo_sctp_assoc_chg_strs, val); } + +enum sctp_sn_type; +extern const struct value_string osmo_sctp_sn_type_strs[]; +static inline const char *osmo_sctp_sn_type_str(enum sctp_sn_type val) +{ return get_value_string(osmo_sctp_sn_type_strs, val); } diff --git a/src/Makefile.am b/src/Makefile.am index 7e71c71..438b58e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,3 +20,7 @@ libosmonetif_la_SOURCES = amr.c \ rs232.c \ rtp.c \ stream.c + +if ENABLE_LIBSCTP +libosmonetif_la_SOURCES += sctp.c +endif diff --git a/src/sctp.c b/src/sctp.c new file mode 100644 index 0000000..c24e0f7 --- /dev/null +++ b/src/sctp.c @@ -0,0 +1,28 @@ +#include <netinet/sctp.h> +#include <osmocom/netif/sctp.h> + +const struct value_string osmo_sctp_assoc_chg_strs[] = { + { SCTP_COMM_UP, "COMM_UP" }, + { SCTP_COMM_LOST, "COMM_LOST" }, + { SCTP_RESTART, "RESTART" }, + { SCTP_SHUTDOWN_COMP, "SHUTDOWN_COMP" }, + { SCTP_CANT_STR_ASSOC, "CANT_STR_ASSOC" }, + { 0, NULL } +}; + +const struct value_string osmo_sctp_sn_type_strs[] = { + { SCTP_ASSOC_CHANGE, "ASSOC_CHANGE" }, + { SCTP_PEER_ADDR_CHANGE, "PEER_ADDR_CHANGE" }, + { SCTP_SHUTDOWN_EVENT, "SHUTDOWN_EVENT" }, + { SCTP_SEND_FAILED, "SEND_FAILED" }, + { SCTP_REMOTE_ERROR, "REMOTE_ERROR" }, + { SCTP_PARTIAL_DELIVERY_EVENT, "PARTIAL_DELIVERY_EVENT" }, + { SCTP_ADAPTATION_INDICATION, "ADAPTATION_INDICATION" }, +#ifdef SCTP_AUTHENTICATION_INDICATION + { SCTP_AUTHENTICATION_INDICATION, "AUTHENTICATION_INDICATION" }, +#endif +#ifdef SCTP_SENDER_DRY_EVENT + { SCTP_SENDER_DRY_EVENT, "SENDER_DRY_EVENT" }, +#endif + { 0, NULL } +}; |