D-GSM 2/n: implement mDNS method of mslookup server
Implement the mslookup server's mDNS responder, to actually service remote
mslookup requests:
- VTY mslookup/server config with service names,
- the mslookup_mdns_server listening for mslookup requests,
For a detailed overview of the D-GSM and mslookup related files, please see the
elaborate comment at the top of mslookup.c (already added in an earlier patch).
Change-Id: I5cae6459090588b4dd292be90a5e8903432669d2
diff --git a/include/osmocom/hlr/Makefile.am b/include/osmocom/hlr/Makefile.am
index 5c96ec8..b24f084 100644
--- a/include/osmocom/hlr/Makefile.am
+++ b/include/osmocom/hlr/Makefile.am
@@ -11,6 +11,7 @@
logging.h \
lu_fsm.h \
mslookup_server.h \
+ mslookup_server_mdns.h \
rand.h \
timestamp.h \
$(NULL)
diff --git a/include/osmocom/hlr/hlr.h b/include/osmocom/hlr/hlr.h
index 1269994..8f26704 100644
--- a/include/osmocom/hlr/hlr.h
+++ b/include/osmocom/hlr/hlr.h
@@ -26,6 +26,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/ipa.h>
#include <osmocom/core/tdef.h>
+#include <osmocom/core/sockaddr_str.h>
#define HLR_DEFAULT_DB_FILE_PATH "hlr.db"
@@ -69,9 +70,20 @@
unsigned int subscr_create_on_demand_rand_msisdn_len;
struct {
+ bool allow_startup;
struct {
+ /* Whether the mslookup server should be active in general (all lookup methods) */
+ bool enable;
uint32_t local_attach_max_age;
struct llist_head local_site_services;
+ struct {
+ /* Whether the mDNS method of the mslookup server should be active. */
+ bool enable;
+ /* The mDNS bind address and domain suffix as set by the VTY, not necessarily in use. */
+ struct osmo_sockaddr_str bind_addr;
+ char *domain_suffix;
+ struct osmo_mslookup_server_mdns *running;
+ } mdns;
} server;
} mslookup;
};
diff --git a/include/osmocom/hlr/hlr_vty.h b/include/osmocom/hlr/hlr_vty.h
index acd6510..0ba9821 100644
--- a/include/osmocom/hlr/hlr_vty.h
+++ b/include/osmocom/hlr/hlr_vty.h
@@ -31,8 +31,12 @@
HLR_NODE = _LAST_OSMOVTY_NODE + 1,
GSUP_NODE,
EUSE_NODE,
+ MSLOOKUP_NODE,
+ MSLOOKUP_SERVER_NODE,
+ MSLOOKUP_SERVER_MSC_NODE,
};
int hlr_vty_is_config_node(struct vty *vty, int node);
int hlr_vty_go_parent(struct vty *vty);
void hlr_vty_init(void);
+void dgsm_vty_init(void);
diff --git a/include/osmocom/hlr/mslookup_server.h b/include/osmocom/hlr/mslookup_server.h
index 5425328..93b419d 100644
--- a/include/osmocom/hlr/mslookup_server.h
+++ b/include/osmocom/hlr/mslookup_server.h
@@ -19,6 +19,9 @@
#pragma once
+#include <osmocom/gsupclient/gsup_peer_id.h>
+#include <osmocom/mslookup/mslookup.h>
+
struct osmo_mslookup_query;
struct osmo_mslookup_result;
diff --git a/include/osmocom/hlr/mslookup_server_mdns.h b/include/osmocom/hlr/mslookup_server_mdns.h
new file mode 100644
index 0000000..ef16e88
--- /dev/null
+++ b/include/osmocom/hlr/mslookup_server_mdns.h
@@ -0,0 +1,36 @@
+/* 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 Affero General Public License as published by
+ * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <osmocom/core/sockaddr_str.h>
+#include <osmocom/mslookup/mdns_sock.h>
+
+struct osmo_mslookup_server_mdns {
+ struct osmo_mslookup_server *mslookup;
+ struct osmo_sockaddr_str bind_addr;
+ char *domain_suffix;
+ struct osmo_mdns_sock *sock;
+};
+
+struct osmo_mslookup_server_mdns *osmo_mslookup_server_mdns_start(void *ctx, const struct osmo_sockaddr_str *bind_addr,
+ const char *domain_suffix);
+void osmo_mslookup_server_mdns_stop(struct osmo_mslookup_server_mdns *server);
+void mslookup_server_mdns_config_apply();