2/2: fixup: add osmo_gsup_peer_id with type enum and union
During code review it was requested to insert an ability to handle different
kinds of peer id, in order to be able to add a Global Title in the future.
Add this, but only in the publicly visible API. For osmo-hlr internal code, I
intend to push implementing this into the future, when a different peer
identification actually gets introduced.
This way we don't need to implement it now in all osmo-hlr code paths (save
time now), but still make all API users aware that this type may be extended in
the future.
Change-Id: Ide9dcdca283ab989240cfc6e53e9211862a199c5
diff --git a/src/Makefile.am b/src/Makefile.am
index bfbe775..7841d42 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,7 +72,7 @@
logging.c \
rand_urandom.c \
dbd_decode_binary.c \
- $(srcdir)/gsupclient/ipa_name.c \
+ $(srcdir)/gsupclient/gsup_peer_id.c \
$(NULL)
osmo_hlr_db_tool_LDADD = \
diff --git a/src/db_hlr.c b/src/db_hlr.c
index fdac75f..ba13324 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -37,7 +37,7 @@
#include <osmocom/hlr/logging.h>
#include <osmocom/hlr/hlr.h>
#include <osmocom/hlr/db.h>
-#include <osmocom/gsupclient/ipa_name.h>
+#include <osmocom/gsupclient/gsup_peer_id.h>
#define LOGHLR(imsi, level, fmt, args ...) LOGP(DAUC, level, "IMSI='%s': " fmt, imsi, ## args)
diff --git a/src/gsup_server.c b/src/gsup_server.c
index ba2d456..d4cdcca 100644
--- a/src/gsup_server.c
+++ b/src/gsup_server.c
@@ -65,13 +65,21 @@
static void gsup_server_send_req_response(struct osmo_gsup_req *req, struct osmo_gsup_message *response)
{
struct osmo_gsup_server *server = req->cb_data;
- struct osmo_gsup_conn *conn;
+ struct osmo_gsup_conn *conn = NULL;
struct msgb *msg = osmo_gsup_msgb_alloc("GSUP Tx");
int rc;
- conn = gsup_route_find_by_ipa_name(server, &req->source_name);
+ switch (req->source_name.type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ conn = gsup_route_find_by_ipa_name(server, &req->source_name.ipa_name);
+ break;
+ default:
+ LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP peer id kind not supported: %s\n",
+ osmo_gsup_peer_id_type_name(req->source_name.type));
+ break;
+ }
if (!conn) {
- LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP client that sent this request was disconnected, cannot respond\n");
+ LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP client that sent this request not found, cannot respond\n");
msgb_free(msg);
return;
}
@@ -91,19 +99,34 @@
struct osmo_gsup_req *osmo_gsup_conn_rx(struct osmo_gsup_conn *conn, struct msgb *msg)
{
- struct osmo_gsup_req *req = osmo_gsup_req_new(conn->server, &conn->peer_name, msg, gsup_server_send_req_response,
- conn->server, NULL);
+ struct osmo_gsup_req *req;
+ struct osmo_gsup_peer_id gpi = {
+ .type = OSMO_GSUP_PEER_ID_IPA_NAME,
+ .ipa_name = conn->peer_name,
+ };
+
+ req = osmo_gsup_req_new(conn->server, &gpi, msg, gsup_server_send_req_response, conn->server, NULL);
if (!req)
return NULL;
- if (req->via_proxy.len) {
+ if (!osmo_gsup_peer_id_is_empty(&req->via_proxy)) {
+ switch (req->via_proxy.type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ break;
+ default:
+ LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP peer id kind not supported: %s\n",
+ osmo_gsup_peer_id_type_name(req->source_name.type));
+ osmo_gsup_req_respond_msgt(req, OSMO_GSUP_MSGT_ROUTING_ERROR, true);
+ return NULL;
+ }
+
/* The source of the GSUP message is not the immediate GSUP peer, but that peer is our proxy for that
* source. Add it to the routes for this conn (so we can route responses back). */
- if (gsup_route_add_ipa_name(conn, &req->source_name)) {
+ if (gsup_route_add_ipa_name(conn, &req->source_name.ipa_name)) {
LOG_GSUP_REQ(req, LOGL_ERROR,
"GSUP message received from %s via peer %s, but there already exists a"
" different route to this source, message is not routable\n",
- osmo_ipa_name_to_str(&req->source_name),
+ osmo_gsup_peer_id_to_str(&req->source_name),
osmo_ipa_name_to_str(&conn->peer_name));
osmo_gsup_req_respond_msgt(req, OSMO_GSUP_MSGT_ROUTING_ERROR, true);
return NULL;
diff --git a/src/gsupclient/Makefile.am b/src/gsupclient/Makefile.am
index 38b1582..a8674e4 100644
--- a/src/gsupclient/Makefile.am
+++ b/src/gsupclient/Makefile.am
@@ -9,7 +9,7 @@
lib_LTLIBRARIES = libosmo-gsup-client.la
libosmo_gsup_client_la_SOURCES = \
- ipa_name.c \
+ gsup_peer_id.c \
gsup_client.c \
gsup_req.c \
$(NULL)
diff --git a/src/gsupclient/gsup_peer_id.c b/src/gsupclient/gsup_peer_id.c
new file mode 100644
index 0000000..7b3efd5
--- /dev/null
+++ b/src/gsupclient/gsup_peer_id.c
@@ -0,0 +1,187 @@
+/* Copyright 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsupclient/gsup_peer_id.h>
+
+bool osmo_ipa_name_is_empty(struct osmo_ipa_name *ipa_name)
+{
+ return (!ipa_name) || (!ipa_name->len);
+}
+
+int osmo_ipa_name_set(struct osmo_ipa_name *ipa_name, const uint8_t *val, size_t len)
+{
+ if (!val || !len) {
+ *ipa_name = (struct osmo_ipa_name){};
+ return 0;
+ }
+ if (len > sizeof(ipa_name->val))
+ return -ENOSPC;
+ ipa_name->len = len;
+ memcpy(ipa_name->val, val, len);
+ return 0;
+}
+
+static int osmo_ipa_name_set_str_va(struct osmo_ipa_name *ipa_name, const char *str_fmt, va_list ap)
+{
+ if (!str_fmt)
+ return osmo_ipa_name_set(ipa_name, NULL, 0);
+ vsnprintf((char*)(ipa_name->val), sizeof(ipa_name->val), str_fmt, ap);
+ ipa_name->len = strlen((char*)(ipa_name->val))+1;
+ return 0;
+}
+
+int osmo_ipa_name_set_str(struct osmo_ipa_name *ipa_name, const char *str_fmt, ...)
+{
+ va_list ap;
+ int rc;
+ va_start(ap, str_fmt);
+ rc = osmo_ipa_name_set_str_va(ipa_name, str_fmt, ap);
+ va_end(ap);
+ return rc;
+}
+
+int osmo_ipa_name_cmp(const struct osmo_ipa_name *a, const struct osmo_ipa_name *b)
+{
+ int cmp;
+ if (a == b)
+ return 0;
+ if (!a)
+ return -1;
+ if (!b)
+ return 1;
+ if (!a->len && !b->len)
+ return 0;
+ if (!a->len && b->len)
+ return -1;
+ if (!b->len && a->len)
+ return 1;
+
+ if (a->len == b->len)
+ return memcmp(a->val, b->val, a->len);
+ else if (a->len < b->len) {
+ cmp = memcmp(a->val, b->val, a->len);
+ if (!cmp)
+ cmp = -1;
+ return cmp;
+ } else {
+ /* a->len > b->len */
+ cmp = memcmp(a->val, b->val, b->len);
+ if (!cmp)
+ cmp = 1;
+ return cmp;
+ }
+}
+
+/* Call osmo_ipa_name_to_str_c with OTC_SELECT. */
+const char *osmo_ipa_name_to_str(const struct osmo_ipa_name *ipa_name)
+{
+ return osmo_ipa_name_to_str_c(OTC_SELECT, ipa_name);
+}
+
+/* Return an unquoted string, not including the terminating zero. Used for writing VTY config. */
+const char *osmo_ipa_name_to_str_c(void *ctx, const struct osmo_ipa_name *ipa_name)
+{
+ size_t len = ipa_name->len;
+ if (!len)
+ return talloc_strdup(ctx, "");
+ if (ipa_name->val[len-1] == '\0')
+ len--;
+ return osmo_escape_str_c(ctx, (char*)ipa_name->val, len);
+}
+
+bool osmo_gsup_peer_id_is_empty(struct osmo_gsup_peer_id *gsup_peer_id)
+{
+ if (!gsup_peer_id)
+ return true;
+ switch (gsup_peer_id->type) {
+ case OSMO_GSUP_PEER_ID_EMPTY:
+ return true;
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ return osmo_ipa_name_is_empty(&gsup_peer_id->ipa_name);
+ default:
+ return false;
+ }
+}
+int osmo_gsup_peer_id_set(struct osmo_gsup_peer_id *gsup_peer_id, enum osmo_gsup_peer_id_type type,
+ const uint8_t *val, size_t len)
+{
+ gsup_peer_id->type = type;
+ switch (type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ return osmo_ipa_name_set(&gsup_peer_id->ipa_name, val, len);
+ default:
+ return -EINVAL;
+ }
+}
+
+int osmo_gsup_peer_id_set_str(struct osmo_gsup_peer_id *gsup_peer_id, enum osmo_gsup_peer_id_type type,
+ const char *str_fmt, ...)
+{
+ va_list ap;
+ int rc;
+
+ *gsup_peer_id = (struct osmo_gsup_peer_id){};
+
+ switch (type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ gsup_peer_id->type = OSMO_GSUP_PEER_ID_IPA_NAME;
+ va_start(ap, str_fmt);
+ rc = osmo_ipa_name_set_str_va(&gsup_peer_id->ipa_name, str_fmt, ap);
+ va_end(ap);
+ return rc;
+ default:
+ return -EINVAL;
+ }
+}
+
+int osmo_gsup_peer_id_cmp(const struct osmo_gsup_peer_id *a, const struct osmo_gsup_peer_id *b)
+{
+ if (a->type != b->type)
+ return OSMO_CMP(a->type, b->type);
+ switch (a->type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ return osmo_ipa_name_cmp(&a->ipa_name, &b->ipa_name);
+ default:
+ return -EINVAL;
+ }
+}
+
+const struct value_string osmo_gsup_peer_id_type_names[] = {
+ { OSMO_GSUP_PEER_ID_IPA_NAME, "IPA-name" },
+ {}
+};
+
+/* Call osmo_gsup_peer_id_to_str_c with OTC_SELECT */
+const char *osmo_gsup_peer_id_to_str(const struct osmo_gsup_peer_id *gpi)
+{
+ return osmo_gsup_peer_id_to_str_c(OTC_SELECT, gpi);
+}
+
+/* Return an unquoted string, not including the terminating zero. Used for writing VTY config. */
+const char *osmo_gsup_peer_id_to_str_c(void *ctx, const struct osmo_gsup_peer_id *gpi)
+{
+ switch (gpi->type) {
+ case OSMO_GSUP_PEER_ID_IPA_NAME:
+ return osmo_ipa_name_to_str_c(ctx, &gpi->ipa_name);
+ default:
+ return talloc_strdup(ctx, osmo_gsup_peer_id_type_name(gpi->type));
+ }
+}
diff --git a/src/gsupclient/gsup_req.c b/src/gsupclient/gsup_req.c
index df834eb..7cefbdf 100644
--- a/src/gsupclient/gsup_req.c
+++ b/src/gsupclient/gsup_req.c
@@ -44,7 +44,7 @@
* \param[inout] add_to_list List to which to append this request, or NULL for no list.
* \return a newly allocated osmo_gsup_req, or NULL on error.
*/
-struct osmo_gsup_req *osmo_gsup_req_new(void *ctx, const struct osmo_ipa_name *from_peer, struct msgb *msg,
+struct osmo_gsup_req *osmo_gsup_req_new(void *ctx, const struct osmo_gsup_peer_id *from_peer, struct msgb *msg,
osmo_gsup_req_send_response_t send_response_cb, void *cb_data,
struct llist_head *add_to_list)
{
@@ -54,7 +54,7 @@
if (!msgb_l2(msg) || !msgb_l2len(msg)) {
LOGP(DLGSUP, LOGL_ERROR, "Rx GSUP from %s: missing or empty L2 data\n",
- osmo_ipa_name_to_str(from_peer));
+ osmo_gsup_peer_id_to_str(from_peer));
msgb_free(msg);
return NULL;
}
@@ -70,7 +70,7 @@
req->source_name = *from_peer;
rc = osmo_gsup_decode(msgb_l2(req->msg), msgb_l2len(req->msg), (struct osmo_gsup_message*)&req->gsup);
if (rc < 0) {
- LOGP(DLGSUP, LOGL_ERROR, "Rx GSUP from %s: cannot decode (rc=%d)\n", osmo_ipa_name_to_str(from_peer), rc);
+ LOGP(DLGSUP, LOGL_ERROR, "Rx GSUP from %s: cannot decode (rc=%d)\n", osmo_gsup_peer_id_to_str(from_peer), rc);
osmo_gsup_req_free(req);
return NULL;
}
@@ -78,17 +78,18 @@
LOG_GSUP_REQ(req, LOGL_DEBUG, "new request: {%s}\n", osmo_gsup_message_to_str_c(OTC_SELECT, &req->gsup));
if (req->gsup.source_name_len) {
- if (osmo_ipa_name_set(&req->source_name, req->gsup.source_name, req->gsup.source_name_len)) {
+ if (osmo_gsup_peer_id_set(&req->source_name, OSMO_GSUP_PEER_ID_IPA_NAME,
+ req->gsup.source_name, req->gsup.source_name_len)) {
LOGP(DLGSUP, LOGL_ERROR,
"Rx GSUP from %s: failed to decode source_name, message is not routable\n",
- osmo_ipa_name_to_str(from_peer));
+ osmo_gsup_peer_id_to_str(from_peer));
osmo_gsup_req_respond_msgt(req, OSMO_GSUP_MSGT_ROUTING_ERROR, true);
return NULL;
}
/* The source of the GSUP message is not the immediate GSUP peer; the peer is our proxy for that source.
*/
- if (osmo_ipa_name_cmp(&req->source_name, from_peer))
+ if (osmo_gsup_peer_id_cmp(&req->source_name, from_peer))
req->via_proxy = *from_peer;
}
diff --git a/src/gsupclient/ipa_name.c b/src/gsupclient/ipa_name.c
deleted file mode 100644
index 2db069f..0000000
--- a/src/gsupclient/ipa_name.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <errno.h>
-#include <string.h>
-#include <osmocom/core/utils.h>
-#include <osmocom/gsupclient/ipa_name.h>
-
-int osmo_ipa_name_set(struct osmo_ipa_name *ipa_name, const uint8_t *val, size_t len)
-{
- if (!val || !len) {
- *ipa_name = (struct osmo_ipa_name){};
- return 0;
- }
- if (len > sizeof(ipa_name->val))
- return -ENOSPC;
- ipa_name->len = len;
- memcpy(ipa_name->val, val, len);
- return 0;
-}
-
-int osmo_ipa_name_set_str(struct osmo_ipa_name *ipa_name, const char *str_fmt, ...)
-{
- va_list ap;
- if (!str_fmt)
- return osmo_ipa_name_set(ipa_name, NULL, 0);
-
- va_start(ap, str_fmt);
- vsnprintf((char*)(ipa_name->val), sizeof(ipa_name->val), str_fmt, ap);
- va_end(ap);
- ipa_name->len = strlen((char*)(ipa_name->val))+1;
- return 0;
-}
-
-int osmo_ipa_name_cmp(const struct osmo_ipa_name *a, const struct osmo_ipa_name *b)
-{
- int cmp;
- if (a == b)
- return 0;
- if (!a)
- return -1;
- if (!b)
- return 1;
- if (!a->len && !b->len)
- return 0;
- if (!a->len && b->len)
- return -1;
- if (!b->len && a->len)
- return 1;
-
- if (a->len == b->len)
- return memcmp(a->val, b->val, a->len);
- else if (a->len < b->len) {
- cmp = memcmp(a->val, b->val, a->len);
- if (!cmp)
- cmp = -1;
- return cmp;
- } else {
- /* a->len > b->len */
- cmp = memcmp(a->val, b->val, b->len);
- if (!cmp)
- cmp = 1;
- return cmp;
- }
-}
-
-/* Call osmo_ipa_name_to_str_c with OTC_SELECT. */
-const char *osmo_ipa_name_to_str(const struct osmo_ipa_name *ipa_name)
-{
- return osmo_ipa_name_to_str_c(OTC_SELECT, ipa_name);
-}
-
-/* Return an unquoted string, not including the terminating zero. Used for writing VTY config. */
-const char *osmo_ipa_name_to_str_c(void *ctx, const struct osmo_ipa_name *ipa_name)
-{
- size_t len = ipa_name->len;
- if (!len)
- return talloc_strdup(ctx, "");
- if (ipa_name->val[len-1] == '\0')
- len--;
- return osmo_escape_str_c(ctx, (char*)ipa_name->val, len);
-}
diff --git a/src/hlr.c b/src/hlr.c
index 47b3211..30d56f8 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -37,7 +37,7 @@
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/gsm23003.h>
-#include <osmocom/gsupclient/ipa_name.h>
+#include <osmocom/gsupclient/gsup_peer_id.h>
#include <osmocom/hlr/db.h>
#include <osmocom/hlr/hlr.h>
#include <osmocom/hlr/ctrl.h>
diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index aa7614e..36b3022 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -416,22 +416,24 @@
}
/* is this GSUP connection an EUSE (true) or not (false)? */
-static bool peer_name_is_euse(const struct osmo_ipa_name *peer_name)
+static bool peer_name_is_euse(const struct osmo_gsup_peer_id *peer_name)
{
- if (peer_name->len <= 5)
+ if (peer_name->type != OSMO_GSUP_PEER_ID_IPA_NAME)
return false;
- if (!strncmp((char *)(peer_name->val), "EUSE-", 5))
- return true;
- else
+ if (peer_name->ipa_name.len <= 5)
return false;
+ return strncmp((char *)(peer_name->ipa_name.val), "EUSE-", 5) == 0;
}
-static struct hlr_euse *euse_by_name(const struct osmo_ipa_name *peer_name)
+static struct hlr_euse *euse_by_name(const struct osmo_gsup_peer_id *peer_name)
{
if (!peer_name_is_euse(peer_name))
return NULL;
- return euse_find(g_hlr, (const char*)(peer_name->val)+5);
+ /* above peer_name_is_euse() ensures this: */
+ OSMO_ASSERT(peer_name->type == OSMO_GSUP_PEER_ID_IPA_NAME);
+
+ return euse_find(g_hlr, (const char*)(peer_name->ipa_name.val)+5);
}
static int handle_ss(struct ss_session *ss, bool is_euse_originated, const struct osmo_gsup_message *gsup,
@@ -519,6 +521,14 @@
LOGP(DSS, LOGL_DEBUG, "%s/0x%08x: Process SS (%s)\n", gsup->imsi, gsup->session_id,
osmo_gsup_session_state_name(gsup->session_state));
+ if (gsup_req->source_name.type != OSMO_GSUP_PEER_ID_IPA_NAME) {
+ LOGP(DSS, LOGL_ERROR, "%s/0x%082x: Unable to process SS request: Unsupported GSUP peer id type%s\n",
+ gsup->imsi, gsup->session_id,
+ osmo_gsup_peer_id_type_name(gsup_req->source_name.type));
+ osmo_gsup_req_respond_err(gsup_req, GMM_CAUSE_PROTO_ERR_UNSPEC, "error processing SS request");
+ return;
+ }
+
/* decode and find out what kind of SS message it is */
if (gsup->ss_info && gsup->ss_info_len) {
if (gsm0480_parse_facility_ie(gsup->ss_info, gsup->ss_info_len, &req)) {
@@ -556,7 +566,8 @@
if (!is_euse_originated) {
ss->initial_req_from_ms = gsup_req;
free_gsup_req = NULL;
- ss->vlr_name = gsup_req->source_name;
+ OSMO_ASSERT(gsup_req->source_name.type == OSMO_GSUP_PEER_ID_IPA_NAME); /* checked above */
+ ss->vlr_name = gsup_req->source_name.ipa_name;
} else {
ss->initial_req_from_euse = gsup_req;
free_gsup_req = NULL;
diff --git a/src/lu_fsm.c b/src/lu_fsm.c
index bded4ef..e54e9c6 100644
--- a/src/lu_fsm.c
+++ b/src/lu_fsm.c
@@ -26,7 +26,7 @@
#include <osmocom/gsm/apn.h>
#include <osmocom/gsm/gsm48_ie.h>
-#include <osmocom/gsupclient/ipa_name.h>
+#include <osmocom/gsupclient/gsup_peer_id.h>
#include <osmocom/gsupclient/gsup_req.h>
#include <osmocom/hlr/logging.h>
#include <osmocom/hlr/hlr.h>
@@ -52,11 +52,11 @@
bool is_ps;
/* VLR requesting the LU. */
- struct osmo_ipa_name vlr_name;
+ struct osmo_gsup_peer_id vlr_name;
/* If the LU request was received via a proxy and not immediately from a local VLR, this indicates the closest
* peer that forwarded the GSUP message. */
- struct osmo_ipa_name via_proxy;
+ struct osmo_gsup_peer_id via_proxy;
};
LLIST_HEAD(g_all_lu);
@@ -130,7 +130,7 @@
osmo_fsm_inst_update_id_f_sanitize(fi, '_', "%s:IMSI-%s", lu->is_ps ? "PS" : "CS", update_location_req->gsup.imsi);
- if (!lu->vlr_name.len) {
+ if (osmo_gsup_peer_id_is_empty(&lu->vlr_name)) {
lu_failure(lu, GMM_CAUSE_NET_FAIL, "LU without a VLR");
return;
}
@@ -163,18 +163,30 @@
#endif
/* Store the VLR / SGSN number with the subscriber, so we know where it was last seen. */
- if (lu->via_proxy.len) {
+ if (!osmo_gsup_peer_id_is_empty(&lu->via_proxy)) {
LOG_GSUP_REQ(update_location_req, LOGL_DEBUG, "storing %s = %s, via proxy %s\n",
lu->is_ps ? "SGSN number" : "VLR number",
- osmo_ipa_name_to_str(&lu->vlr_name),
- osmo_ipa_name_to_str(&lu->via_proxy));
+ osmo_gsup_peer_id_to_str(&lu->vlr_name),
+ osmo_gsup_peer_id_to_str(&lu->via_proxy));
} else {
LOG_GSUP_REQ(update_location_req, LOGL_DEBUG, "storing %s = %s\n",
lu->is_ps ? "SGSN number" : "VLR number",
- osmo_ipa_name_to_str(&lu->vlr_name));
+ osmo_gsup_peer_id_to_str(&lu->vlr_name));
}
- if (db_subscr_lu(g_hlr->dbc, lu->subscr.id, &lu->vlr_name, lu->is_ps, &lu->via_proxy)) {
+ if (osmo_gsup_peer_id_is_empty(&lu->vlr_name)
+ || (lu->vlr_name.type != OSMO_GSUP_PEER_ID_IPA_NAME)) {
+ lu_failure(lu, GMM_CAUSE_PROTO_ERR_UNSPEC, "Unsupported GSUP peer id type for vlr_name: %s",
+ osmo_gsup_peer_id_type_name(lu->vlr_name.type));
+ return;
+ }
+ if (!osmo_gsup_peer_id_is_empty(&lu->via_proxy) && (lu->via_proxy.type != OSMO_GSUP_PEER_ID_IPA_NAME)) {
+ lu_failure(lu, GMM_CAUSE_PROTO_ERR_UNSPEC, "Unsupported GSUP peer id type for via_proxy: %s",
+ osmo_gsup_peer_id_type_name(lu->via_proxy.type));
+ return;
+ }
+ if (db_subscr_lu(g_hlr->dbc, lu->subscr.id, &lu->vlr_name.ipa_name, lu->is_ps,
+ osmo_gsup_peer_id_is_empty(&lu->via_proxy)? NULL : &lu->via_proxy.ipa_name)) {
lu_failure(lu, GMM_CAUSE_NET_FAIL, "Cannot update %s in the database",
lu->is_ps ? "SGSN number" : "VLR number");
return;