aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm
diff options
context:
space:
mode:
Diffstat (limited to 'include/osmocom/gsm')
-rw-r--r--include/osmocom/gsm/gsm0808.h3
-rw-r--r--include/osmocom/gsm/gsm48.h30
2 files changed, 29 insertions, 4 deletions
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 5127c003..553f10d1 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -21,10 +21,11 @@
#define OSMOCORE_GSM0808_H
#include "tlv.h"
+#include "gsm48.h"
struct msgb;
-struct msgb *gsm0808_create_layer3(struct msgb *msg, uint16_t netcode, uint16_t countrycode, int lac, uint16_t ci);
+struct msgb *gsm0808_create_layer3(struct msgb *msg, gsm_mnc_t netcode, uint16_t countrycode, int lac, uint16_t ci);
struct msgb *gsm0808_create_reset(void);
struct msgb *gsm0808_create_reset_ack(void);
struct msgb *gsm0808_create_clear_command(uint8_t reason);
diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index 1e7498a9..37054b81 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -1,14 +1,22 @@
#ifndef _OSMOCORE_GSM48_H
#define _OSMOCORE_GSM48_H
+#include <stdbool.h>
+#include <stdlib.h>
+
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/gsm48_ie.h>
+typedef struct {
+ int16_t network_code:15; /**< MNC, 00-999. Signed to allow -1 as invalid placeholder. */
+ bool two_digits:1; /**< If true, MNC is 2 digits, otherwise 3. */
+} gsm_mnc_t;
+
/* A parsed GPRS routing area */
struct gprs_ra_id {
- uint16_t mnc;
uint16_t mcc;
+ gsm_mnc_t mnc;
uint16_t lac;
uint8_t rac;
};
@@ -21,9 +29,9 @@ const char *gsm48_cc_msg_name(uint8_t msgtype);
const char *rr_cause_name(uint8_t cause);
int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
- uint16_t *mnc, uint16_t *lac);
+ gsm_mnc_t *mnc, uint16_t *lac);
void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
- uint16_t mnc, uint16_t lac);
+ gsm_mnc_t mnc, uint16_t lac);
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi);
int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi);
@@ -37,4 +45,20 @@ int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid);
int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc);
+static inline gsm_mnc_t gsm48_str_to_mnc(const char *s)
+{
+ gsm_mnc_t r;
+
+ r.two_digits = strlen(s) <= 2;
+ r.network_code = atoi(s);
+
+ return r;
+}
+
+static inline int gsm48_mnc_are_equal(gsm_mnc_t a, gsm_mnc_t b)
+{
+ return a.network_code == b.network_code &&
+ a.two_digits == b.two_digits;
+}
+
#endif