[PATCH] osmo-bsc[master]: libcommon_cs: move gsm48 bits to libbsc

2018-02-14 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6440

to look at the new patch set (#4).

libcommon_cs: move gsm48 bits to libbsc

These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
---
M include/osmocom/bsc/common_cs.h
M include/osmocom/bsc/gsm_04_08_utils.h
M src/libbsc/gsm_04_08_utils.c
M src/libcommon-cs/common_cs.c
M src/libfilter/bsc_msg_filter.c
M src/osmo-bsc/osmo_bsc_filter.c
6 files changed, 65 insertions(+), 63 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/40/6440/4

diff --git a/include/osmocom/bsc/common_cs.h b/include/osmocom/bsc/common_cs.h
index 432d4d5..dccc7b5 100644
--- a/include/osmocom/bsc/common_cs.h
+++ b/include/osmocom/bsc/common_cs.h
@@ -19,9 +19,3 @@
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
 struct gsm_network *gsmnet_from_vty(struct vty *v);
-
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
-int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
-int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
-   char *mi_string, uint8_t *mi_type);
-struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
diff --git a/include/osmocom/bsc/gsm_04_08_utils.h 
b/include/osmocom/bsc/gsm_04_08_utils.h
index 625f173..34979ab 100644
--- a/include/osmocom/bsc/gsm_04_08_utils.h
+++ b/include/osmocom/bsc/gsm_04_08_utils.h
@@ -22,6 +22,12 @@
 int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
 enum gsm48_reject_value value);
 
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type);
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
+
 #define GSM48_ALLOC_SIZE2048
 #define GSM48_ALLOC_HEADROOM256
 
diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index 85eb7b5..3004e5d 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -636,3 +636,60 @@
 
return gsm0808_submit_dtap(conn, msg, 0, 0);
 }
+
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
+{
+   struct msgb *msg;
+   struct gsm48_hdr *gh;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
+   gh->data[0] = value;
+
+   return msg;
+}
+
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
+{
+   struct gsm48_hdr *gh;
+   struct msgb *msg;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
+   gh->data[0] = cause;
+   return msg;
+}
+
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type)
+{
+   /* Check the size for the classmark */
+   if (length < 1 + *classmark2_lv)
+   return -1;
+
+   uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
+   if (length < 2 + *classmark2_lv + mi_lv[0])
+   return -2;
+
+   *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
+   return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
+}
+
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type)
+{
+   static const uint32_t classmark_offset =
+   offsetof(struct gsm48_pag_resp, classmark2);
+   uint8_t *classmark2_lv = (uint8_t *) >classmark2;
+   return gsm48_extract_mi(classmark2_lv, length - classmark_offset,
+   mi_string, mi_type);
+}
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index 0520e96..9307f63 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -30,59 +30,3 @@
 #include 
 #include 
 
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
-{
-   struct msgb *msg;
-   struct gsm48_hdr *gh;
-
-   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
-   if (!msg)
-   return NULL;
-
-   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
-   gh->proto_discr = GSM48_PDISC_MM;
-   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
-   gh->data[0] = value;
-
-   return msg;
-}
-
-struct 

[MERGED] osmo-bsc[master]: libcommon_cs: move gsm48 bits to libbsc

2018-02-14 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged.

Change subject: libcommon_cs: move gsm48 bits to libbsc
..


libcommon_cs: move gsm48 bits to libbsc

These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
---
M include/osmocom/bsc/common_cs.h
M include/osmocom/bsc/gsm_04_08_utils.h
M src/libbsc/gsm_04_08_utils.c
M src/libcommon-cs/common_cs.c
M src/libfilter/bsc_msg_filter.c
M src/osmo-bsc/osmo_bsc_filter.c
6 files changed, 65 insertions(+), 63 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/bsc/common_cs.h b/include/osmocom/bsc/common_cs.h
index 432d4d5..dccc7b5 100644
--- a/include/osmocom/bsc/common_cs.h
+++ b/include/osmocom/bsc/common_cs.h
@@ -19,9 +19,3 @@
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
 struct gsm_network *gsmnet_from_vty(struct vty *v);
-
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
-int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
-int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
-   char *mi_string, uint8_t *mi_type);
-struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
diff --git a/include/osmocom/bsc/gsm_04_08_utils.h 
b/include/osmocom/bsc/gsm_04_08_utils.h
index 625f173..34979ab 100644
--- a/include/osmocom/bsc/gsm_04_08_utils.h
+++ b/include/osmocom/bsc/gsm_04_08_utils.h
@@ -22,6 +22,12 @@
 int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
 enum gsm48_reject_value value);
 
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type);
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
+
 #define GSM48_ALLOC_SIZE2048
 #define GSM48_ALLOC_HEADROOM256
 
diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index 85eb7b5..3004e5d 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -636,3 +636,60 @@
 
return gsm0808_submit_dtap(conn, msg, 0, 0);
 }
+
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
+{
+   struct msgb *msg;
+   struct gsm48_hdr *gh;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
+   gh->data[0] = value;
+
+   return msg;
+}
+
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
+{
+   struct gsm48_hdr *gh;
+   struct msgb *msg;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
+   gh->data[0] = cause;
+   return msg;
+}
+
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type)
+{
+   /* Check the size for the classmark */
+   if (length < 1 + *classmark2_lv)
+   return -1;
+
+   uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
+   if (length < 2 + *classmark2_lv + mi_lv[0])
+   return -2;
+
+   *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
+   return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
+}
+
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type)
+{
+   static const uint32_t classmark_offset =
+   offsetof(struct gsm48_pag_resp, classmark2);
+   uint8_t *classmark2_lv = (uint8_t *) >classmark2;
+   return gsm48_extract_mi(classmark2_lv, length - classmark_offset,
+   mi_string, mi_type);
+}
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index 0520e96..9307f63 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -30,59 +30,3 @@
 #include 
 #include 
 
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
-{
-   struct msgb *msg;
-   struct gsm48_hdr *gh;
-
-   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
-   if (!msg)
-   return NULL;
-
-   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
-   gh->proto_discr = GSM48_PDISC_MM;
-   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
-   gh->data[0] = value;

osmo-bsc[master]: libcommon_cs: move gsm48 bits to libbsc

2018-02-14 Thread Harald Welte

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6440
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-bsc[master]: libcommon_cs: move gsm48 bits to libbsc

2018-02-14 Thread Neels Hofmeyr
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6440

to look at the new patch set (#3).

libcommon_cs: move gsm48 bits to libbsc

These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
---
M include/osmocom/bsc/common_cs.h
M include/osmocom/bsc/gsm_04_08_utils.h
M src/libbsc/gsm_04_08_utils.c
M src/libcommon-cs/common_cs.c
M src/libfilter/bsc_msg_filter.c
M src/osmo-bsc/osmo_bsc_filter.c
6 files changed, 65 insertions(+), 63 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/40/6440/3

diff --git a/include/osmocom/bsc/common_cs.h b/include/osmocom/bsc/common_cs.h
index 432d4d5..dccc7b5 100644
--- a/include/osmocom/bsc/common_cs.h
+++ b/include/osmocom/bsc/common_cs.h
@@ -19,9 +19,3 @@
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
 struct gsm_network *gsmnet_from_vty(struct vty *v);
-
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
-int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
-int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
-   char *mi_string, uint8_t *mi_type);
-struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
diff --git a/include/osmocom/bsc/gsm_04_08_utils.h 
b/include/osmocom/bsc/gsm_04_08_utils.h
index 625f173..34979ab 100644
--- a/include/osmocom/bsc/gsm_04_08_utils.h
+++ b/include/osmocom/bsc/gsm_04_08_utils.h
@@ -22,6 +22,12 @@
 int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
 enum gsm48_reject_value value);
 
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type);
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
+
 #define GSM48_ALLOC_SIZE2048
 #define GSM48_ALLOC_HEADROOM256
 
diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index 85eb7b5..3004e5d 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -636,3 +636,60 @@
 
return gsm0808_submit_dtap(conn, msg, 0, 0);
 }
+
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
+{
+   struct msgb *msg;
+   struct gsm48_hdr *gh;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
+   gh->data[0] = value;
+
+   return msg;
+}
+
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
+{
+   struct gsm48_hdr *gh;
+   struct msgb *msg;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
+   gh->data[0] = cause;
+   return msg;
+}
+
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type)
+{
+   /* Check the size for the classmark */
+   if (length < 1 + *classmark2_lv)
+   return -1;
+
+   uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
+   if (length < 2 + *classmark2_lv + mi_lv[0])
+   return -2;
+
+   *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
+   return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
+}
+
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type)
+{
+   static const uint32_t classmark_offset =
+   offsetof(struct gsm48_pag_resp, classmark2);
+   uint8_t *classmark2_lv = (uint8_t *) >classmark2;
+   return gsm48_extract_mi(classmark2_lv, length - classmark_offset,
+   mi_string, mi_type);
+}
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index 0520e96..9307f63 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -30,59 +30,3 @@
 #include 
 #include 
 
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
-{
-   struct msgb *msg;
-   struct gsm48_hdr *gh;
-
-   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
-   if (!msg)
-   return NULL;
-
-   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
-   gh->proto_discr = GSM48_PDISC_MM;
-   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
-   gh->data[0] = value;
-
-   return msg;
-}
-
-struct msgb 

[PATCH] osmo-bsc[master]: libcommon_cs: move gsm48 bits to libbsc

2018-02-13 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/6440

libcommon_cs: move gsm48 bits to libbsc

These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
---
M include/osmocom/bsc/common_cs.h
M include/osmocom/bsc/gsm_04_08_utils.h
M src/libbsc/gsm_04_08_utils.c
M src/libcommon-cs/common_cs.c
4 files changed, 63 insertions(+), 62 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/40/6440/1

diff --git a/include/osmocom/bsc/common_cs.h b/include/osmocom/bsc/common_cs.h
index 432d4d5..dccc7b5 100644
--- a/include/osmocom/bsc/common_cs.h
+++ b/include/osmocom/bsc/common_cs.h
@@ -19,9 +19,3 @@
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
 struct gsm_network *gsmnet_from_vty(struct vty *v);
-
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
-int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
-int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
-   char *mi_string, uint8_t *mi_type);
-struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
diff --git a/include/osmocom/bsc/gsm_04_08_utils.h 
b/include/osmocom/bsc/gsm_04_08_utils.h
index 625f173..34979ab 100644
--- a/include/osmocom/bsc/gsm_04_08_utils.h
+++ b/include/osmocom/bsc/gsm_04_08_utils.h
@@ -22,6 +22,12 @@
 int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
 enum gsm48_reject_value value);
 
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type);
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type);
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
+
 #define GSM48_ALLOC_SIZE2048
 #define GSM48_ALLOC_HEADROOM256
 
diff --git a/src/libbsc/gsm_04_08_utils.c b/src/libbsc/gsm_04_08_utils.c
index 85eb7b5..3004e5d 100644
--- a/src/libbsc/gsm_04_08_utils.c
+++ b/src/libbsc/gsm_04_08_utils.c
@@ -636,3 +636,60 @@
 
return gsm0808_submit_dtap(conn, msg, 0, 0);
 }
+
+struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
+{
+   struct msgb *msg;
+   struct gsm48_hdr *gh;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
+   gh->data[0] = value;
+
+   return msg;
+}
+
+struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
+{
+   struct gsm48_hdr *gh;
+   struct msgb *msg;
+
+   msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ");
+   if (!msg)
+   return NULL;
+
+   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
+   gh->proto_discr = GSM48_PDISC_MM;
+   gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT;
+   gh->data[0] = cause;
+   return msg;
+}
+
+int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, 
uint8_t *mi_type)
+{
+   /* Check the size for the classmark */
+   if (length < 1 + *classmark2_lv)
+   return -1;
+
+   uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
+   if (length < 2 + *classmark2_lv + mi_lv[0])
+   return -2;
+
+   *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
+   return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
+}
+
+int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length,
+   char *mi_string, uint8_t *mi_type)
+{
+   static const uint32_t classmark_offset =
+   offsetof(struct gsm48_pag_resp, classmark2);
+   uint8_t *classmark2_lv = (uint8_t *) >classmark2;
+   return gsm48_extract_mi(classmark2_lv, length - classmark_offset,
+   mi_string, mi_type);
+}
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index 0520e96..9307f63 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -30,59 +30,3 @@
 #include 
 #include 
 
-struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
-{
-   struct msgb *msg;
-   struct gsm48_hdr *gh;
-
-   msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ");
-   if (!msg)
-   return NULL;
-
-   gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
-   gh->proto_discr = GSM48_PDISC_MM;
-   gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
-   gh->data[0] = value;
-
-   return msg;
-}
-
-struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
-{
-   struct gsm48_hdr *gh;
-   struct msgb *msg;
-
-   msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ");
-   if