aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-12-14 00:23:59 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-12-14 03:24:51 +0700
commit5a513317292280aad8b9f81e1e1159153bd5ed4d (patch)
treec6f2e1dbe547a996fcaac372d168cd4f33b3fa19 /include/osmocom/gsm
parentc2f1ed1dd098ea2fe3e285ed8fe15a06b0a5f01a (diff)
gsm0808: add gsm0808_enc_speech_codec[_list]2()
The problem with most of the existing gsm0808_* functions in this file is that they assert() too much, assuming that their callers always pass perfectly valid input parameters. But this is impossible on practice, as there can be bugs in complex projects using them, liks osmo-bsc. It was reported by a customer that a heavily loaded osmo-bsc crashed a few times, dropping more than 100 sites without network coverage for a few minutes. As was revealed during the investigaion, it crashed due to a failing assert at the end of enc_speech_codec(): OSMO_ASSERT(sc->cfg == 0); The problem is that somehow osmo-bsc is passing an unexpected sc->cfg value to gsm0808_create_ass_compl2(), in particular 0x02, while the given sc->type value (GSM0808_SCT_HR1) implies that there cannot be any configuration bits on the wire. The reason why and under which circumstances this can be happening is not clear yet, but what we agreed on so far is that the library API should be enforcing correctness of the input parameters in a less agressive way, rather than aborting the process without letting it any chance to recover. Modify the original gsm0808_enc_speech_codec[_list]() functions, so that a negative value is returned in case of an error. Rename them and add backwards compatibility wrappers, because it's public API. A separate patch making use of the new API follows next. Change-Id: I199ffa0ba4a64813238519178155dfc767aa3975 Related: SYS#6229
Diffstat (limited to 'include/osmocom/gsm')
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index 6abfeecc..18f3ebe5 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -111,12 +111,17 @@ uint8_t gsm0808_enc_lcls(struct msgb *msg, const struct osmo_lcls *lcls);
int gsm0808_dec_lcls(struct osmo_lcls *lcls, const struct tlv_parsed *tp);
uint8_t gsm0808_enc_speech_codec(struct msgb *msg,
- const struct gsm0808_speech_codec *sc);
+ const struct gsm0808_speech_codec *sc)
+ OSMO_DEPRECATED("use gsm0808_enc_speech_codec2() instead");
+int gsm0808_enc_speech_codec2(struct msgb *msg,
+ const struct gsm0808_speech_codec *sc);
int gsm0808_dec_speech_codec(struct gsm0808_speech_codec *sc,
const uint8_t *elem, uint8_t len);
uint8_t gsm0808_enc_speech_codec_list(struct msgb *msg,
- const struct gsm0808_speech_codec_list
- *scl);
+ const struct gsm0808_speech_codec_list *scl)
+ OSMO_DEPRECATED("use gsm0808_enc_speech_codec_list2() instead");
+int gsm0808_enc_speech_codec_list2(struct msgb *msg,
+ const struct gsm0808_speech_codec_list *scl);
int gsm0808_dec_speech_codec_list(struct gsm0808_speech_codec_list *scl,
const uint8_t *elem, uint8_t len);
uint8_t gsm0808_enc_channel_type(struct msgb *msg,