aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-05 19:36:48 +0100
committerlaforge <laforge@osmocom.org>2021-01-11 14:22:21 +0000
commitca33a71ca8eeaee98b1b53d5394b147a4ff0b429 (patch)
tree57e39ef752e0db8968619b891ca2a496493893e7
parente2ad6ebb7a411d0854d123d35584c79e14005eba (diff)
Intoduce Packet Switch CGI
This structure is needed in order to identify a given cell within the BSS during RIM transactions. The naming was made up by myself since I couldn't find any naming reference for this kind of data (RAI + CI). Since LAI + CI = CGI, then RAI + CI = CGI-PS osmo_rai_name2 family of functions get a "2" suffix due to already existing functions handling struct struct gprs_ra_id in gsm48.h Change-Id: If48f412c32e8e5a3e604a78d12b74787a4786374
-rw-r--r--include/osmocom/gsm/gsm0808_utils.h1
-rw-r--r--include/osmocom/gsm/gsm23003.h13
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_08.h3
-rw-r--r--src/gsm/gsm0808_utils.c31
-rw-r--r--src/gsm/gsm23003.c81
-rw-r--r--src/gsm/libosmogsm.map7
6 files changed, 136 insertions, 0 deletions
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index 59db6edc..76e90645 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -44,6 +44,7 @@ union gsm0808_cell_id_u {
uint16_t ci;
struct osmo_location_area_id lai_and_lac;
uint16_t lac;
+ struct osmo_cell_global_id_ps global_ps;
};
/*! Parsed representation of Cell Identifier IE (3GPP TS 48.008 3.2.2.17) */
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 69f00f68..fbe0ca0f 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -30,6 +30,11 @@ struct osmo_cell_global_id {
uint16_t cell_identity;
};
+struct osmo_cell_global_id_ps {
+ struct osmo_routing_area_id rai;
+ uint16_t cell_identity;
+};
+
/*! Bitmask of items contained in a struct osmo_cell_global_id.
* See also gsm0808_cell_id_to_cgi().
*/
@@ -37,6 +42,7 @@ enum osmo_cgi_part {
OSMO_CGI_PART_PLMN = 1,
OSMO_CGI_PART_LAC = 2,
OSMO_CGI_PART_CI = 4,
+ OSMO_CGI_PART_RAC = 8,
};
/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,
@@ -117,10 +123,17 @@ char *osmo_plmn_name_c(const void *ctx, const struct osmo_plmn_id *plmn);
const char *osmo_lai_name(const struct osmo_location_area_id *lai);
char *osmo_lai_name_buf(char *buf, size_t buf_len, const struct osmo_location_area_id *lai);
char *osmo_lai_name_c(const void *ctx, const struct osmo_location_area_id *lai);
+const char *osmo_rai_name2(const struct osmo_routing_area_id *rai);
+char *osmo_rai_name2_buf(char *buf, size_t buf_len, const struct osmo_routing_area_id *rai);
+char *osmo_rai_name2_c(const void *ctx, const struct osmo_routing_area_id *rai);
const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi);
const char *osmo_cgi_name2(const struct osmo_cell_global_id *cgi);
char *osmo_cgi_name_buf(char *buf, size_t buf_len, const struct osmo_cell_global_id *cgi);
char *osmo_cgi_name_c(const void *ctx, const struct osmo_cell_global_id *cgi);
+const char *osmo_cgi_ps_name(const struct osmo_cell_global_id_ps *cgi_ps);
+const char *osmo_cgi_ps_name2(const struct osmo_cell_global_id_ps *cgi_ps);
+char *osmo_cgi_ps_name_buf(char *buf, size_t buf_len, const struct osmo_cell_global_id_ps *cgi_ps);
+char *osmo_cgi_ps_name_c(const void *ctx, const struct osmo_cell_global_id_ps *cgi_ps);
const char *osmo_gummei_name(const struct osmo_gummei *gummei);
char *osmo_gummei_name_buf(char *buf, size_t buf_len, const struct osmo_gummei *gummei);
char *osmo_gummei_name_c(const void *ctx, const struct osmo_gummei *gummei);
diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h b/include/osmocom/gsm/protocol/gsm_08_08.h
index 1390f0e8..fe7776b2 100644
--- a/include/osmocom/gsm/protocol/gsm_08_08.h
+++ b/include/osmocom/gsm/protocol/gsm_08_08.h
@@ -25,6 +25,9 @@ enum CELL_IDENT {
CELL_IDENT_UTRAN_PLMN_LAC_RNC = 8,
CELL_IDENT_UTRAN_RNC = 9,
CELL_IDENT_UTRAN_LAC_RNC = 10,
+
+ /* Not in 03.03 nor 08.08 */
+ CELL_IDENT_WHOLE_GLOBAL_PS = 11, /* CGI with + RAC */
};
/* Keep this misnamed CELL_IDENT for API backwards compatibility (see OS#3124). */
#define CELL_IDENT_LAI_AND_LAC CELL_IDENT_LAI
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 6bf771f8..c1b0a001 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -784,6 +784,8 @@ int gsm0808_cell_id_size(enum CELL_IDENT discr)
case CELL_IDENT_BSS:
case CELL_IDENT_NO_CELL:
return 0;
+ case CELL_IDENT_WHOLE_GLOBAL_PS:
+ return 8;
default:
return -EINVAL;
}
@@ -828,6 +830,13 @@ int gsm0808_decode_cell_id_u(union gsm0808_cell_id_u *out, enum CELL_IDENT discr
case CELL_IDENT_NO_CELL:
/* Does not have any list items */
break;
+ case CELL_IDENT_WHOLE_GLOBAL_PS:
+ if (len < 8)
+ return -EINVAL;
+ decode_lai(buf, (struct osmo_location_area_id *)&out->global_ps.rai); /* rai contains lai + non-decoded rac */
+ out->global_ps.rai.rac = *(buf + sizeof(struct gsm48_loc_area_id));
+ out->global_ps.cell_identity = osmo_load16be(buf + sizeof(struct gsm48_loc_area_id) + 1);
+ break;
default:
/* Remaining cell identification types are not implemented. */
return -EINVAL;
@@ -869,6 +878,15 @@ void gsm0808_msgb_put_cell_id_u(struct msgb *msg, enum CELL_IDENT id_discr, cons
case CELL_IDENT_NO_CELL:
/* Does not have any list items */
break;
+ case CELL_IDENT_WHOLE_GLOBAL_PS: {
+ const struct osmo_cell_global_id_ps *id = &u->global_ps;
+ struct gsm48_loc_area_id lai;
+ gsm48_generate_lai2(&lai, &id->rai.lac);
+ memcpy(msgb_put(msg, sizeof(lai)), &lai, sizeof(lai));
+ memcpy(msgb_put(msg, 1), &id->rai.rac, 1);
+ msgb_put_u16(msg, id->cell_identity);
+ break;
+ }
default:
/* Support for other identifier list types is not implemented. */
OSMO_ASSERT(false);
@@ -1592,6 +1610,8 @@ int gsm0808_cell_id_u_name(char *buf, size_t buflen,
return snprintf(buf, buflen, "%s", osmo_lai_name(&u->lai_and_lac));
case CELL_IDENT_WHOLE_GLOBAL:
return snprintf(buf, buflen, "%s", osmo_cgi_name(&u->global));
+ case CELL_IDENT_WHOLE_GLOBAL_PS:
+ return snprintf(buf, buflen, "%s", osmo_cgi_ps_name(&u->global_ps));
default:
/* For CELL_IDENT_BSS and CELL_IDENT_NO_CELL, just print the discriminator.
* Same for kinds we have no string representation of yet. */
@@ -1613,6 +1633,11 @@ static void cell_id_to_cgi(struct osmo_cell_global_id *dst,
*dst = u->global;
return;
+ case CELL_IDENT_WHOLE_GLOBAL_PS:
+ dst->lai = u->global_ps.rai.lac;
+ dst->cell_identity = u->global_ps.cell_identity;
+ return;
+
case CELL_IDENT_LAC_AND_CI:
dst->lai.lac = u->lac_and_ci.lac;
dst->cell_identity = u->lac_and_ci.ci;
@@ -1805,6 +1830,11 @@ int gsm0808_cell_id_to_cgi(struct osmo_cell_global_id *cgi, const struct gsm0808
*cgi = cid->id.global;
return OSMO_CGI_PART_PLMN | OSMO_CGI_PART_LAC | OSMO_CGI_PART_CI;
+ case CELL_IDENT_WHOLE_GLOBAL_PS:
+ cgi->lai = cid->id.global_ps.rai.lac;
+ cgi->cell_identity = cid->id.global_ps.cell_identity;
+ return OSMO_CGI_PART_PLMN | OSMO_CGI_PART_LAC | OSMO_CGI_PART_CI;
+
case CELL_IDENT_LAC_AND_CI:
cgi->lai.lac = cid->id.lac_and_ci.lac;
cgi->cell_identity = cid->id.lac_and_ci.ci;
@@ -1844,6 +1874,7 @@ const struct value_string gsm0808_cell_id_discr_names[] = {
{ CELL_IDENT_UTRAN_PLMN_LAC_RNC, "UTRAN-PLMN-LAC-RNC" },
{ CELL_IDENT_UTRAN_RNC, "UTRAN-RNC" },
{ CELL_IDENT_UTRAN_LAC_RNC, "UTRAN-LAC-RNC" },
+ { CELL_IDENT_WHOLE_GLOBAL_PS, "CGI-PS"},
{ 0, NULL }
};
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index e20afcbc..ae498fa8 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -247,6 +247,43 @@ char *osmo_lai_name_c(const void *ctx, const struct osmo_location_area_id *lai)
return osmo_lai_name_buf(buf, 32, lai);
}
+/*! Return MCC-MNC-LAC-RAC as string, in caller-provided output buffer.
+ * \param[out] buf caller-allocated output buffer
+ * \param[in] buf_len size of buf in bytes
+ * \param[in] rai RAI to encode, the rac member is ignored.
+ * \returns buf
+ */
+char *osmo_rai_name2_buf(char *buf, size_t buf_len, const struct osmo_routing_area_id *rai)
+{
+ char plmn[16];
+ snprintf(buf, buf_len, "%s-%u-%u", osmo_plmn_name_buf(plmn, sizeof(plmn),
+ &rai->lac.plmn), rai->lac.lac, rai->rac);
+ return buf;
+}
+
+/*! Return MCC-MNC-LAC-RAC as string, in a static buffer.
+ * \param[in] rai RAI to encode, the rac member is ignored.
+ * \returns Static string buffer.
+ */
+const char *osmo_rai_name2(const struct osmo_routing_area_id *rai)
+{
+ static __thread char buf[32];
+ return osmo_rai_name2_buf(buf, sizeof(buf), rai);
+}
+
+/*! Return MCC-MNC-LAC-RAC as string, in a talloc-allocated output buffer.
+ * \param[in] ctx talloc context from which to allocate output buffer
+ * \param[in] rai RAI to encode, the rac member is ignored.
+ * \returns string representation of lai in dynamically allocated buffer.
+ */
+char *osmo_rai_name2_c(const void *ctx, const struct osmo_routing_area_id *rai)
+{
+ char *buf = talloc_size(ctx, 32);
+ if (!buf)
+ return NULL;
+ return osmo_rai_name2_buf(buf, 32, rai);
+}
+
/*! Return MCC-MNC-LAC-CI as string, in caller-provided output buffer.
* \param[out] buf caller-allocated output buffer
* \param[in] buf_len size of buf in bytes
@@ -291,6 +328,50 @@ char *osmo_cgi_name_c(const void *ctx, const struct osmo_cell_global_id *cgi)
return osmo_cgi_name_buf(buf, 32, cgi);
}
+/*! Return MCC-MNC-LAC-RAC-CI as string, in caller-provided output buffer.
+ * \param[out] buf caller-allocated output buffer
+ * \param[in] buf_len size of buf in bytes
+ * \param[in] cgi_ps CGI-PS to encode.
+ * \returns buf
+ */
+char *osmo_cgi_ps_name_buf(char *buf, size_t buf_len, const struct osmo_cell_global_id_ps *cgi_ps)
+{
+ snprintf(buf, buf_len, "%s-%u", osmo_rai_name2(&cgi_ps->rai), cgi_ps->cell_identity);
+ return buf;
+}
+
+/*! Return MCC-MNC-LAC-RAC-CI as string, in a static buffer.
+ * \param[in] cgi_ps CGI-PS to encode.
+ * \returns Static string buffer.
+ */
+const char *osmo_cgi_ps_name(const struct osmo_cell_global_id_ps *cgi_ps)
+{
+ static __thread char buf[32];
+ return osmo_cgi_ps_name_buf(buf, sizeof(buf), cgi_ps);
+}
+
+/*! Same as osmo_cgi_ps_name(), but uses a different static buffer.
+ * Useful for printing two distinct CGI-PSs in the same printf format.
+ * \param[in] cgi CGI-PS to encode.
+ * \returns Static string buffer.
+ */
+const char *osmo_cgi_ps_name2(const struct osmo_cell_global_id_ps *cgi_ps)
+{
+ static __thread char buf[32];
+ return osmo_cgi_ps_name_buf(buf, sizeof(buf), cgi_ps);
+}
+
+/*! Return MCC-MNC-LAC-RAC-CI as string, in a talloc-allocated output buffer.
+ * \param[in] ctx talloc context from which to allocate output buffer
+ * \param[in] cgi_ps CGI-PS to encode.
+ * \returns string representation of CGI in dynamically-allocated buffer.
+ */
+char *osmo_cgi_ps_name_c(const void *ctx, const struct osmo_cell_global_id_ps *cgi_ps)
+{
+ char *buf = talloc_size(ctx, 32);
+ return osmo_cgi_ps_name_buf(buf, 32, cgi_ps);
+}
+
static void to_bcd(uint8_t *bcd, uint16_t val)
{
bcd[2] = val % 10;
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index bcded1ce..eceb1c10 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -412,10 +412,17 @@ osmo_lai_name_c;
osmo_rai_name;
osmo_rai_name_buf;
osmo_rai_name_c;
+osmo_rai_name2;
+osmo_rai_name2_buf;
+osmo_rai_name2_c;
osmo_cgi_name;
osmo_cgi_name_buf;
osmo_cgi_name_c;
osmo_cgi_name2;
+osmo_cgi_ps_name;
+osmo_cgi_ps_name_buf;
+osmo_cgi_ps_name_c;
+osmo_cgi_ps_name2;
osmo_gummei_name;
osmo_gummei_name_buf;
osmo_gummei_name_c;