<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12199">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm29118: add generator functions for GSM29118 messages<br><br>We already have some GSM29118 related definitions and functions in<br>libosmocore. Lets also add some functions to generate GSM29118 messages<br>(similar to those we have for GSM0808).<br><br>Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a<br>Related: OS#3615<br>---<br>M include/Makefile.am<br>A include/osmocom/gsm/gsm29118.h<br>M include/osmocom/gsm/protocol/gsm_29_118.h<br>M src/gsm/gsm29118.c<br>M src/gsm/libosmogsm.map<br>5 files changed, 344 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/99/12199/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/Makefile.am b/include/Makefile.am</span><br><span>index 59a5fed..366fd70 100644</span><br><span>--- a/include/Makefile.am</span><br><span>+++ b/include/Makefile.am</span><br><span>@@ -88,6 +88,7 @@</span><br><span>                        osmocom/gsm/gsm0808.h \</span><br><span>                        osmocom/gsm/gsm0808_utils.h \</span><br><span>                        osmocom/gsm/gsm23003.h \</span><br><span style="color: hsl(120, 100%, 40%);">+                       osmocom/gsm/gsm29118.h \</span><br><span>                        osmocom/gsm/gsm48.h \</span><br><span>                        osmocom/gsm/gsm48_ie.h \</span><br><span>                        osmocom/gsm/gsm_utils.h \</span><br><span>diff --git a/include/osmocom/gsm/gsm29118.h b/include/osmocom/gsm/gsm29118.h</span><br><span>new file mode 100644</span><br><span>index 0000000..e81cce4</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/gsm/gsm29118.h</span><br><span>@@ -0,0 +1,65 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \file gsm23003.h */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom s.f.m.c. GmbH</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Harald Welte, Philipp Maier</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-2.0+</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License along</span><br><span style="color: hsl(120, 100%, 40%);">+ * with this program; if not, write to the Free Software Foundation, Inc.,</span><br><span style="color: hsl(120, 100%, 40%);">+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/msgb.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm23003.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_29_118.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_04_08.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! 3GPP TS 3GPP TS 29.018 8.14 SGsAP-PAGING-REQUEST. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm29118_paging_req {</span><br><span style="color: hsl(120, 100%, 40%);">+  char imsi[GSM48_MI_SIZE];</span><br><span style="color: hsl(120, 100%, 40%);">+     char vlr_name[SGS_VLR_NAME_MAXLEN + 1];</span><br><span style="color: hsl(120, 100%, 40%);">+       uint8_t serv_ind;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   bool lai_present;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct osmo_location_area_id lai;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! 3GPP TS 3GPP TS 29.018 8.15 SGsAP-RESET-ACK and 8.16 SGsAP-RESET-INDICATION. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm29118_reset_msg {</span><br><span style="color: hsl(120, 100%, 40%);">+     bool vlr_name_present;</span><br><span style="color: hsl(120, 100%, 40%);">+        char vlr_name[SGS_VLR_NAME_MAXLEN + 1];</span><br><span style="color: hsl(120, 100%, 40%);">+       bool mme_name_present;</span><br><span style="color: hsl(120, 100%, 40%);">+        char mme_name[SGS_MME_NAME_LEN + 1];</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_msgb_alloc(void);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_alert_req(const char *imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_dl_ud(const char *imsi, struct msgb *nas_msg);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_eps_det_ack(const char *imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_imsi_det_ack(const char *imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_lu_ack(const char *imsi, const struct osmo_location_area_id *lai, const uint8_t *new_id,</span><br><span style="color: hsl(120, 100%, 40%);">+                             unsigned int new_id_len);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_lu_rej(const char *imsi, uint8_t rej_cause, const struct osmo_location_area_id *lai);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_mm_info_req(const char *imsi, const uint8_t *mm_info, uint8_t mm_info_len);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_paging_req(struct gsm29118_paging_req *params);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_reset_ack(struct gsm29118_reset_msg *params);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_reset_ind(struct gsm29118_reset_msg *params);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_status(const char *imsi, enum sgsap_sgs_cause cause, const struct msgb *err_msg);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_release_req(const char *imsi, const uint8_t sgs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_service_abort_req(const char *imsi);</span><br><span>diff --git a/include/osmocom/gsm/protocol/gsm_29_118.h b/include/osmocom/gsm/protocol/gsm_29_118.h</span><br><span>index 70f1500..cfe772a 100644</span><br><span>--- a/include/osmocom/gsm/protocol/gsm_29_118.h</span><br><span>+++ b/include/osmocom/gsm/protocol/gsm_29_118.h</span><br><span>@@ -173,4 +173,11 @@</span><br><span> /* TS 29.118 Section 6.3 */</span><br><span> #define SGS_PORT_DEFAULT 29118</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* TS 29.118 Section 9.4.13 MME Name */</span><br><span style="color: hsl(120, 100%, 40%);">+#define SGS_MME_NAME_LEN 55</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* TS 29.118 Section 9.4.22 VLR name</span><br><span style="color: hsl(120, 100%, 40%);">+ * See also: RFC1123 Section 2.1 Host Names and Numbers */</span><br><span style="color: hsl(120, 100%, 40%);">+#define SGS_VLR_NAME_MAXLEN 255</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> const struct tlv_definition sgsap_ie_tlvdef;</span><br><span>diff --git a/src/gsm/gsm29118.c b/src/gsm/gsm29118.c</span><br><span>index 3898be6..17456b6 100644</span><br><span>--- a/src/gsm/gsm29118.c</span><br><span>+++ b/src/gsm/gsm29118.c</span><br><span>@@ -1,7 +1,32 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom s.f.m.c. GmbH</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Harald Welte, Philipp Maier</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-2.0+</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License along</span><br><span style="color: hsl(120, 100%, 40%);">+ * with this program; if not, write to the Free Software Foundation, Inc.,</span><br><span style="color: hsl(120, 100%, 40%);">+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #include <osmocom/core/utils.h></span><br><span> #include <osmocom/gsm/tlv.h></span><br><span> </span><br><span> #include <osmocom/gsm/protocol/gsm_29_118.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm29118.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/apn.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm48.h></span><br><span> </span><br><span> const struct value_string sgsap_msg_type_names[] = {</span><br><span>       { SGSAP_MSGT_PAGING_REQ,        "PAGING-REQUEST" },</span><br><span>@@ -156,3 +181,234 @@</span><br><span>                [SGSAP_IE_TMSI_BASED_NRI_CONT]  = { TLV_TYPE_TLV },</span><br><span>  },</span><br><span> };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Allocate an empty message buffer, suitable to hold a complite SGsAP msg. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_msgb_alloc(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       /* by far sufficient for the maximum size message of 298 bytes</span><br><span style="color: hsl(120, 100%, 40%);">+         * (9+7+5+3+10+253+10+1) SGsAP-UP-UD */</span><br><span style="color: hsl(120, 100%, 40%);">+       return msgb_alloc_headroom(1024, 128, "SGsAP");</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Encode VLR/MME name from string and append to SGsAP msg */</span><br><span style="color: hsl(120, 100%, 40%);">+static void msgb_sgsap_name_put(struct msgb *msg, enum sgsap_iei iei, const char *name)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t buf[APN_MAXLEN];</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t len;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* encoding is like DNS names, which is like APN fields */</span><br><span style="color: hsl(120, 100%, 40%);">+    memset(buf, 0, sizeof(buf));</span><br><span style="color: hsl(120, 100%, 40%);">+  len = osmo_apn_from_str(buf, sizeof(buf), name);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Note: While the VLR-Name (see 3GPP TS 29.118, chapter 9.4.22) has</span><br><span style="color: hsl(120, 100%, 40%);">+   * a flexible length, the MME-Name has a fixed size of 55 octets. (see</span><br><span style="color: hsl(120, 100%, 40%);">+         * 3GPP TS 29.118, chapter 9.4.13). */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (iei == SGSAP_IE_MME_NAME)</span><br><span style="color: hsl(120, 100%, 40%);">+         len = 55;</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_tlv_put(msg, iei, len, buf);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Encode IMSI from string representation and append to SGSaAP msg */</span><br><span style="color: hsl(120, 100%, 40%);">+static void msgb_sgsap_imsi_put(struct msgb *msg, const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t buf[16];</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t len;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* encoding is just like TS 04.08 */</span><br><span style="color: hsl(120, 100%, 40%);">+  len = gsm48_generate_mid_from_imsi(buf, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+        /* skip first two bytes (tag+length) so we can use msgb_tlv_put */</span><br><span style="color: hsl(120, 100%, 40%);">+    msgb_tlv_put(msg, SGSAP_IE_IMSI, len - 2, buf + 2);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Encode LAI from struct representation and append to SGSaAP msg */</span><br><span style="color: hsl(120, 100%, 40%);">+static void msgb_sgsap_lai_put(struct msgb *msg, const struct osmo_location_area_id *lai)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct gsm48_loc_area_id lai_enc;</span><br><span style="color: hsl(120, 100%, 40%);">+     gsm48_generate_lai2(&lai_enc, lai);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_tlv_put(msg, SGSAP_IE_LAI, 5, (uint8_t *) & lai_enc);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Many messages consist only of a message type and an imsi */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct msgb *create_simple_msg(enum sgsap_msg_type msg_type, const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_push_u8(msg, msg_type);</span><br><span style="color: hsl(120, 100%, 40%);">+  return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.3 SGsAP-ALERT-REQUEST.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message.*/</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_alert_req(const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       return create_simple_msg(SGSAP_MSGT_ALERT_REQ, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.4 SGsAP-DOWNLINK-UNITDATA.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] nas_msg user provided message buffer with L3 message.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_dl_ud(const char *imsi, struct msgb *nas_msg)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_tlv_put(msg, SGSAP_IE_NAS_MSG_CONTAINER, nas_msg->len, nas_msg->data);</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_push_u8(msg, SGSAP_MSGT_DL_UD);</span><br><span style="color: hsl(120, 100%, 40%);">+  return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.5 SGsAP-EPS-DETACH-ACK.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_eps_det_ack(const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   return create_simple_msg(SGSAP_MSGT_EPS_DET_ACK, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.7 SGsAP-IMSI-DETACH-ACK.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_imsi_det_ack(const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     return create_simple_msg(SGSAP_MSGT_IMSI_DET_ACK, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! 8.9 SGsAP-LOCATION-UPDATE-ACCEPT.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] lai Location Area Identity (optional, may be NULL).</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] new_id value part of new Mobile Identity (optional, may be NULL).</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] new_id_len length of \a new_id in octets.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_lu_ack(const char *imsi, const struct osmo_location_area_id *lai, const uint8_t *new_id,</span><br><span style="color: hsl(120, 100%, 40%);">+                                  unsigned int new_id_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_sgsap_lai_put(msg, lai);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (new_id && new_id_len)</span><br><span style="color: hsl(120, 100%, 40%);">+             msgb_tlv_put(msg, SGSAP_IE_MOBILE_ID, new_id_len, new_id);</span><br><span style="color: hsl(120, 100%, 40%);">+    msgb_push_u8(msg, SGSAP_MSGT_LOC_UPD_ACK);</span><br><span style="color: hsl(120, 100%, 40%);">+    return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.10 SGsAP-LOCATION-UPDATE-REJECT.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] rej_cause LU cause code, see also 3GPP TS 29.018, subclause 18.4.21.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] lai location area identifier.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_lu_rej(const char *imsi, uint8_t rej_cause, const struct osmo_location_area_id *lai)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_tlv_put(msg, SGSAP_IE_REJECT_CAUSE, 1, &rej_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (lai)</span><br><span style="color: hsl(120, 100%, 40%);">+              msgb_sgsap_lai_put(msg, lai);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_push_u8(msg, SGSAP_MSGT_LOC_UPD_REJ);</span><br><span style="color: hsl(120, 100%, 40%);">+    return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.12 SGsAP-MM-INFORMATION-REQUEST.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] mm_info MM information, see also 3GPP TS 29.018, subclause 18.4.16.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] mm_info_len length of \a mm_info in octets.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_mm_info_req(const char *imsi, const uint8_t *mm_info, uint8_t mm_info_len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       msgb_tlv_put(msg, SGSAP_IE_MM_INFO, mm_info_len, mm_info);</span><br><span style="color: hsl(120, 100%, 40%);">+    msgb_push_u8(msg, SGSAP_MSGT_MM_INFO_REQ);</span><br><span style="color: hsl(120, 100%, 40%);">+    return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.14 SGsAP-PAGING-REQUEST.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] params user provided memory with message contents to encode.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_paging_req(struct gsm29118_paging_req *params)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, params->imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+    msgb_sgsap_name_put(msg, SGSAP_IE_VLR_NAME, params->vlr_name);</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_tlv_put(msg, SGSAP_IE_SERVICE_INDICATOR, 1, &params->serv_ind);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (params->lai_present)</span><br><span style="color: hsl(120, 100%, 40%);">+           msgb_sgsap_lai_put(msg, &params->lai);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_push_u8(msg, SGSAP_MSGT_PAGING_REQ);</span><br><span style="color: hsl(120, 100%, 40%);">+     return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.15 SGsAP-RESET-ACK.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] params user provided memory with message contents to encode.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_reset_ack(struct gsm29118_reset_msg *params)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     if (params->vlr_name_present && params->mme_name_present == false)</span><br><span style="color: hsl(120, 100%, 40%);">+              msgb_sgsap_name_put(msg, SGSAP_IE_VLR_NAME, params->vlr_name);</span><br><span style="color: hsl(120, 100%, 40%);">+     else if (params->mme_name_present && params->vlr_name_present == false)</span><br><span style="color: hsl(120, 100%, 40%);">+         msgb_sgsap_name_put(msg, SGSAP_IE_MME_NAME, params->mme_name);</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          OSMO_ASSERT(false);</span><br><span style="color: hsl(120, 100%, 40%);">+   msgb_push_u8(msg, SGSAP_MSGT_RESET_ACK);</span><br><span style="color: hsl(120, 100%, 40%);">+      return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.16 SGsAP-RESET-INDICATION.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] params user provided memory with message contents to encode.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_reset_ind(struct gsm29118_reset_msg *params)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     if (params->vlr_name_present && params->mme_name_present == false)</span><br><span style="color: hsl(120, 100%, 40%);">+              msgb_sgsap_name_put(msg, SGSAP_IE_VLR_NAME, params->vlr_name);</span><br><span style="color: hsl(120, 100%, 40%);">+     else if (params->mme_name_present && params->vlr_name_present == false)</span><br><span style="color: hsl(120, 100%, 40%);">+         msgb_sgsap_name_put(msg, SGSAP_IE_MME_NAME, params->mme_name);</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          OSMO_ASSERT(false);</span><br><span style="color: hsl(120, 100%, 40%);">+   msgb_push_u8(msg, SGSAP_MSGT_RESET_IND);</span><br><span style="color: hsl(120, 100%, 40%);">+      return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.18 SGsAP-STATUS.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] cause sgs related cause code.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] err_msg user provided message buffer containing the errornous message.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_status(const char *imsi, enum sgsap_sgs_cause cause, const struct msgb *err_msg)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t c8 = cause;</span><br><span style="color: hsl(120, 100%, 40%);">+   unsigned int err_msg_len;</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_tlv_put(msg, SGSAP_IE_SGS_CAUSE, 1, &c8);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+             msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (err_msg) {</span><br><span style="color: hsl(120, 100%, 40%);">+                err_msg_len = msgb_l2len(err_msg);</span><br><span style="color: hsl(120, 100%, 40%);">+            if (err_msg_len > 255)</span><br><span style="color: hsl(120, 100%, 40%);">+                     err_msg_len = 255;</span><br><span style="color: hsl(120, 100%, 40%);">+            msgb_tlv_put(msg, SGSAP_IE_ERR_MSG, err_msg_len, msgb_l2(err_msg));</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_push_u8(msg, SGSAP_MSGT_STATUS);</span><br><span style="color: hsl(120, 100%, 40%);">+ return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.23 SGsAP-RELEASE-REQUEST.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] cause sgs related cause code.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_release_req(const char *imsi, const uint8_t sgs_cause)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct msgb *msg = gsm29118_msgb_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_sgsap_imsi_put(msg, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (sgs_cause)</span><br><span style="color: hsl(120, 100%, 40%);">+                msgb_tlv_put(msg, SGSAP_IE_SGS_CAUSE, 1, &sgs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_push_u8(msg, SGSAP_MSGT_RELEASE_REQ);</span><br><span style="color: hsl(120, 100%, 40%);">+    return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* 8.24 SGsAP-SERVICE-ABORT-REQUEST.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] imsi IMSI of the subscriber.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns callee-allocated msgb with the encoded message. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm29118_create_service_abort_req(const char *imsi)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     return create_simple_msg(SGSAP_MSGT_SERVICE_ABORT_REQ, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map</span><br><span>index 04a9826..e9a9e4f 100644</span><br><span>--- a/src/gsm/libosmogsm.map</span><br><span>+++ b/src/gsm/libosmogsm.map</span><br><span>@@ -219,6 +219,21 @@</span><br><span> gsm0808_lcls_control_names;</span><br><span> gsm0808_lcls_status_names;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_msgb_alloc;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_alert_req;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_dl_ud;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_eps_det_ack;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_imsi_det_ack;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_lu_ack;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_lu_rej;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_mm_info_req;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_paging_req;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_reset_ack;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_reset_ind;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_status;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_release_req;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm29118_create_service_abort_req;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> gsm0858_rsl_ul_meas_enc;</span><br><span> </span><br><span> gsm338_get_sms_alphabet;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12199">change 12199</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12199"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a </div>
<div style="display:none"> Gerrit-Change-Number: 12199 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>