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/gsup_server.c b/src/gsup_server.c
index a6cca81..053151f 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;