From 0ee798a0172a009cec4fb27c427b8f1d66fca749 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 10 Apr 2019 19:13:19 +0200 Subject: add OSMO_IMSI_BUF_SIZE Various places in our code base figure out how many chars they need to safely store an IMSI. An IMSI can have a checksum digit, which is not reflected by GSM23003_IMSI_MAX_DIGITS. And we usually need a terminating \0. Instead of having a magic +2 repeated every so often, rather define OSMO_IMSI_BUF_SIZE to contain both checksum digit and nul char, and have the explanatory comment with it here in libosmocore. Change-Id: Id11ada4c96b79f7f0ad58185ab7dbf24622fb770 --- include/osmocom/gsm/protocol/gsm_23_003.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/osmocom/gsm/protocol') diff --git a/include/osmocom/gsm/protocol/gsm_23_003.h b/include/osmocom/gsm/protocol/gsm_23_003.h index babd0f4b..be1b157b 100644 --- a/include/osmocom/gsm/protocol/gsm_23_003.h +++ b/include/osmocom/gsm/protocol/gsm_23_003.h @@ -5,6 +5,9 @@ /* Chapter 2.2 */ #define GSM23003_IMSI_MAX_DIGITS 15 #define GSM23003_IMSI_MIN_DIGITS 6 +/*! The char[] buffer size to completely contain an IMSI including the optional checksum digit as well as the + * terminating nul character. */ +#define OSMO_IMSI_BUF_SIZE (GSM23003_IMSI_MAX_DIGITS+2) /* Chapter 2.4 */ #define GSM23003_TMSI_NUM_BYTES 4 /* Chapter 2.5 */ -- cgit v1.2.3