summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/include/osmocom/bb/common
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-05-18 18:51:03 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-05-22 16:12:04 +0200
commit3348f491792788974c6bb3ee75f3a4f1d159aef9 (patch)
tree815af8fd65748bb4792edf2a6cebeec52a2a428c /src/host/layer23/include/osmocom/bb/common
parent554e7cfb56ff61e83c7321b7737baf4476bf8280 (diff)
Migrate network identifier fields to modern osmocom structures
This allows using well tested standarized API to print, compare, etc. usual identifiers like PLMN, LAI, etc. It also simplifies code by avoiding passing lots of parameters and making it easier to identify which fields go packed together. This is specially important since in the future more of those identifiers will be added for GPRS. Change-Id: I07a9289825c09ed748e53d36a746ea164c8a5d7f
Diffstat (limited to 'src/host/layer23/include/osmocom/bb/common')
-rw-r--r--src/host/layer23/include/osmocom/bb/common/networks.h23
-rw-r--r--src/host/layer23/include/osmocom/bb/common/settings.h3
-rw-r--r--src/host/layer23/include/osmocom/bb/common/subscriber.h18
-rw-r--r--src/host/layer23/include/osmocom/bb/common/sysinfo.h7
4 files changed, 25 insertions, 26 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/networks.h b/src/host/layer23/include/osmocom/bb/common/networks.h
index d34f3162..408e17d0 100644
--- a/src/host/layer23/include/osmocom/bb/common/networks.h
+++ b/src/host/layer23/include/osmocom/bb/common/networks.h
@@ -1,24 +1,27 @@
#ifndef _NETWORKS_H
#define _NETWORKS_H
+#include <osmocom/gsm/gsm23003.h>
-#define GSM_INPUT_INVALID 0xffff
-
+/* Instead of handling numerical MCC and MNC, they stored and handled
+ * hexadecimal. This makes it possible
+ * to correctly handle 2 and 3 digits MNC. Internally 2 digit MNCs are stored
+ * as 0xXXf, and 3 digits MNC are stored as 0xXXX, where X is the digit 0..9.
+*/
struct gsm_networks {
- uint16_t mcc;
- int16_t mnc;
+ uint16_t mcc_hex;
+ int16_t mnc_hex;
const char *name;
};
int gsm_match_mcc(uint16_t mcc, char *imsi);
-int gsm_match_mnc(uint16_t mcc, uint16_t mnc, char *imsi);
-const char *gsm_print_mcc(uint16_t mcc);
-const char *gsm_print_mnc(uint16_t mcc);
+int gsm_match_mnc(uint16_t mcc, uint16_t mnc, bool mnc_3_digits, char *imsi);
const char *gsm_get_mcc(uint16_t mcc);
-const char *gsm_get_mnc(uint16_t mcc, uint16_t mnc);
+const char *gsm_get_mnc(const struct osmo_plmn_id *plmn);
const char *gsm_imsi_mcc(char *imsi);
const char *gsm_imsi_mnc(char *imsi);
-const uint16_t gsm_input_mcc(char *string);
-const uint16_t gsm_input_mnc(char *string);
+
+uint16_t gsm_mcc_to_hex(uint16_t mcc);
+uint16_t gsm_mnc_to_hex(uint16_t mnc, bool mnc_3_digits);
#endif /* _NETWORKS_H */
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h
index e312a1c1..f66874c1 100644
--- a/src/host/layer23/include/osmocom/bb/common/settings.h
+++ b/src/host/layer23/include/osmocom/bb/common/settings.h
@@ -4,6 +4,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
+#include <osmocom/gsm/gsm23003.h>
struct osmocom_ms;
struct osmobb_apn;
@@ -64,7 +65,7 @@ struct test_sim_settings {
uint8_t ki[16]; /* 128 bit max */
uint8_t barr;
uint8_t rplmn_valid;
- uint16_t rplmn_mcc, rplmn_mnc;
+ struct osmo_plmn_id rplmn;
uint16_t lac;
uint8_t imsi_attached;
uint8_t always; /* ...search hplmn... */
diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h
index 972f6133..e2a8dab4 100644
--- a/src/host/layer23/include/osmocom/bb/common/subscriber.h
+++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h
@@ -5,6 +5,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
+#include <osmocom/gsm/gsm23003.h>
/* GSM 04.08 4.1.2.2 SIM update status */
enum gsm_sub_sim_ustate {
@@ -22,12 +23,12 @@ static inline const char *gsm_sub_sim_ustate_name(enum gsm_sub_sim_ustate val)
struct gsm_sub_plmn_list {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
};
struct gsm_sub_plmn_na {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
uint8_t cause;
};
@@ -58,7 +59,7 @@ struct gsm_subscriber {
/* TMSI / LAI */
uint32_t tmsi; /* invalid tmsi: GSM_RESERVED_TMSI */
uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */
- uint16_t mcc, mnc, lac; /* invalid lac: 0x0000 */
+ struct osmo_location_area_id lai; /* invalid lac: 0x0000 */
/* key */
@@ -80,7 +81,7 @@ struct gsm_subscriber {
/* PLMN last registered */
uint8_t plmn_valid;
- uint16_t plmn_mcc, plmn_mnc;
+ struct osmo_plmn_id plmn;
/* our access */
uint8_t acc_barr; /* if we may access, if cell barred */
@@ -111,12 +112,9 @@ int gsm_subscr_write_loci(struct osmocom_ms *ms);
int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, const uint8_t *rand,
bool no_sim);
void new_sim_ustate(struct gsm_subscriber *subscr, int state);
-int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc);
-int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc, uint8_t cause);
-int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc);
+int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn);
+int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn, uint8_t cause);
+int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn);
int gsm_subscr_dump_forbidden_plmn(struct osmocom_ms *ms,
void (*print)(void *, const char *, ...), void *priv);
void gsm_subscr_dump(struct gsm_subscriber *subscr,
diff --git a/src/host/layer23/include/osmocom/bb/common/sysinfo.h b/src/host/layer23/include/osmocom/bb/common/sysinfo.h
index 75cbcd94..0368901f 100644
--- a/src/host/layer23/include/osmocom/bb/common/sysinfo.h
+++ b/src/host/layer23/include/osmocom/bb/common/sysinfo.h
@@ -2,6 +2,7 @@
#define _SYSINFO_H
#include <osmocom/gsm/gsm48_ie.h>
+#include <osmocom/gsm/gsm23003.h>
/* collection of system information of the current cell */
@@ -44,7 +45,7 @@ struct gsm48_sysinfo {
/* serving cell */
uint8_t bsic;
uint16_t cell_id;
- uint16_t mcc, mnc, lac; /* LAI */
+ struct osmo_location_area_id lai;
uint8_t max_retrans; /* decoded */
uint8_t tx_integer; /* decoded */
uint8_t reest_denied; /* 1 = denied */
@@ -195,9 +196,5 @@ int gsm48_decode_sysinfo13(struct gsm48_sysinfo *s,
int gsm48_decode_mobile_alloc(struct gsm_sysinfo_freq *freq,
const uint8_t *ma, uint8_t len,
uint16_t *hopping, uint8_t *hopp_len, int si4);
-int gsm48_encode_lai_hex(struct gsm48_loc_area_id *lai,
- uint16_t mcc, uint16_t mnc, uint16_t lac);
-int gsm48_decode_lai_hex(const struct gsm48_loc_area_id *lai,
- uint16_t *mcc, uint16_t *mnc, uint16_t *lac);
#endif /* _SYSINFO_H */