diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index b368ad995..7b95099ca 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -226,4 +226,6 @@ struct ns_signal_data { void gprs_ns_set_log_ss(int ss); +char *gprs_nsvc_state_append(char *s, struct gprs_nsvc *nsvc); + /*! @} */ diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 47d170df0..75c314158 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -1705,4 +1705,26 @@ void gprs_ns_set_log_ss(int ss) DNS = ss; } +/*! Append the nsvc state to a talloc string + * \param s The string to append to (allocated with talloc) + * \param[in] nsvc The NS-VC to print the state of + * \returns The new string with state information appended to it + * + * This function will append a comma-separated state of the NS-VC to the + * string. The string needs to be allocated with talloc (e.g. talloc_strdup) + */ +char *gprs_nsvc_state_append(char *s, struct gprs_nsvc *nsvc) +{ + s = talloc_asprintf_append(s, + "%u,%u,%s,%s,%s,%s,%s\n", + nsvc->nsei, nsvc->nsvci, + NS_DESC_A(nsvc->state), + NS_DESC_B(nsvc->state), + nsvc->remote_end_is_sgsn ? "SGSN" : "BSS", + NS_DESC_A(nsvc->remote_state), + NS_DESC_B(nsvc->remote_state)); + + return s; +} + /*! @} */ diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index 83a36213c..d56e65143 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -70,6 +70,7 @@ gprs_nsvc_delete; gprs_nsvc_reset; gprs_nsvc_by_nsvci; gprs_nsvc_by_nsei; +gprs_nsvc_state_append; gprs_log_filter_fn;