split off osmo-mgw: remove files, apply build, rename
Add vty and logging previously used from libcommon
Rename libmgcp to libosmo-legacy-mgcp and install.
Use DLMGCP, not DMGCP.
Slim down the public mgcpgw_client API, move all elements not actually used by
current callers to private headers / static c.
Depends: libosmocore I09c587e2d59472cbde852d467d457254746d9e67
Change-Id: I71a0a16ebaaef881c34235849601fc40aa12cfd7
diff --git a/src/osmo-bsc_mgcp/mgcp_main.c b/src/osmo-bsc_mgcp/mgcp_main.c
index 6cf9ab7..48241a6 100644
--- a/src/osmo-bsc_mgcp/mgcp_main.c
+++ b/src/osmo-bsc_mgcp/mgcp_main.c
@@ -28,14 +28,13 @@
#include <time.h>
#include <limits.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/socket.h>
-#include <openbsc/debug.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/mgcp.h>
-#include <openbsc/mgcp_internal.h>
-#include <openbsc/vty.h>
+#include <osmocom/legacy_mgcp/mgcp.h>
+#include <osmocom/legacy_mgcp/mgcp_internal.h>
+#include <osmocom/legacy_mgcp/vty.h>
#include <osmocom/core/application.h>
#include <osmocom/core/msgb.h>
@@ -43,6 +42,7 @@
#include <osmocom/core/select.h>
#include <osmocom/core/stats.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/logging.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
@@ -53,7 +53,7 @@
#include "../../bscconfig.h"
#ifdef BUILD_MGCP_TRANSCODING
-#include "openbsc/mgcp_transcode.h"
+#include <osmocom/legacy_mgcp/mgcp_transcode.h>
#endif
#define _GNU_SOURCE
@@ -174,7 +174,7 @@
}
if (reset_endpoints) {
- LOGP(DMGCP, LOGL_NOTICE,
+ LOGP(DLMGCP, LOGL_NOTICE,
"Asked to reset endpoints: %d/%d\n",
reset_trunk->trunk_nr, reset_trunk->trunk_type);
reset_endpoints = 0;
@@ -187,18 +187,56 @@
return 0;
}
-extern int bsc_vty_go_parent(struct vty *vty);
+int mgcp_vty_is_config_node(struct vty *vty, int node)
+{
+ switch (node) {
+ case CONFIG_NODE:
+ return 0;
+
+ default:
+ return 1;
+ }
+}
+
+int mgcp_vty_go_parent(struct vty *vty)
+{
+ switch (vty->node) {
+ case TRUNK_NODE:
+ vty->node = MGCP_NODE;
+ vty->index = NULL;
+ break;
+ case MGCP_NODE:
+ default:
+ if (mgcp_vty_is_config_node(vty, vty->node))
+ vty->node = CONFIG_NODE;
+ else
+ vty->node = ENABLE_NODE;
+
+ vty->index = NULL;
+ }
+
+ return vty->node;
+}
+
static struct vty_app_info vty_info = {
.name = "OpenBSC MGCP",
.version = PACKAGE_VERSION,
- .go_parent_cb = bsc_vty_go_parent,
- .is_config_node = bsc_vty_is_config_node,
+ .go_parent_cb = mgcp_vty_go_parent,
+ .is_config_node = mgcp_vty_is_config_node,
+};
+
+static const struct log_info_cat log_categories[] = {
+ /* DLMGCP is provided by the MGCP library */
+};
+
+const struct log_info log_info = {
+ .cat = log_categories,
+ .num_cat = ARRAY_SIZE(log_categories),
};
int main(int argc, char **argv)
{
- struct gsm_network dummy_network;
struct sockaddr_in addr;
int on = 1, rc;
@@ -236,7 +274,7 @@
return rc;
/* start telnet after reading config for vty_get_bind_addr() */
- rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network,
+ rc = telnet_init_dynif(tall_bsc_ctx, NULL,
vty_get_bind_addr(), OSMO_VTY_PORT_BSC_MGCP);
if (rc < 0)
return rc;
@@ -276,7 +314,7 @@
addr.sin_port = htons(2727);
inet_aton(cfg->call_agent_addr, &addr.sin_addr);
if (connect(cfg->gw_fd.bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- LOGP(DMGCP, LOGL_ERROR, "Failed to connect to: '%s'. errno: %d\n",
+ LOGP(DLMGCP, LOGL_ERROR, "Failed to connect to: '%s'. errno: %d\n",
cfg->call_agent_addr, errno);
close(cfg->gw_fd.bfd.fd);
cfg->gw_fd.bfd.fd = -1;
@@ -285,11 +323,11 @@
}
if (osmo_fd_register(&cfg->gw_fd.bfd) != 0) {
- LOGP(DMGCP, LOGL_FATAL, "Failed to register the fd\n");
+ LOGP(DLMGCP, LOGL_FATAL, "Failed to register the fd\n");
return -1;
}
- LOGP(DMGCP, LOGL_NOTICE, "Configured for MGCP.\n");
+ LOGP(DLMGCP, LOGL_NOTICE, "Configured for MGCP.\n");
}
/* initialisation */