2017-10-31 00:15:45 +00:00
|
|
|
/* MGCP client interface to quagga VTY */
|
2016-05-20 19:59:55 +00:00
|
|
|
/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
|
|
|
|
* Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c)
|
|
|
|
* (C) 2009 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
* (C) 2009-2011 by Holger Hans Peter Freyther
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2018-02-04 08:04:16 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2016-05-20 19:59:55 +00:00
|
|
|
* (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
|
2018-02-04 08:04:16 +00:00
|
|
|
* GNU General Public License for more details.
|
2016-05-20 19:59:55 +00:00
|
|
|
*
|
2018-02-04 08:04:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-05-20 19:59:55 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <talloc.h>
|
|
|
|
|
|
|
|
#include <osmocom/vty/command.h>
|
2018-02-22 17:09:28 +00:00
|
|
|
#include <osmocom/vty/misc.h>
|
2017-07-10 13:07:22 +00:00
|
|
|
#include <osmocom/core/utils.h>
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
#include <osmocom/mgcp_client/mgcp_client.h>
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2018-08-23 14:36:48 +00:00
|
|
|
#define MGW_STR MGCP_CLIENT_MGW_STR
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
void *global_mgcp_client_ctx = NULL;
|
|
|
|
struct mgcp_client_conf *global_mgcp_client_conf = NULL;
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-10-31 00:15:45 +00:00
|
|
|
DEFUN(cfg_mgw_local_ip, cfg_mgw_local_ip_cmd,
|
|
|
|
"mgw local-ip A.B.C.D",
|
2017-10-31 00:18:33 +00:00
|
|
|
MGW_STR "local bind to connect to MGW from\n"
|
2016-05-20 19:59:55 +00:00
|
|
|
"local bind IP address\n")
|
|
|
|
{
|
2017-09-03 23:02:56 +00:00
|
|
|
if (!global_mgcp_client_conf)
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_ERR_NOTHING_TODO;
|
2017-09-03 23:02:56 +00:00
|
|
|
OSMO_ASSERT(global_mgcp_client_ctx);
|
2018-12-18 23:30:34 +00:00
|
|
|
osmo_talloc_replace_string(global_mgcp_client_ctx,
|
|
|
|
(char**)&global_mgcp_client_conf->local_addr,
|
|
|
|
argv[0]);
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-10-31 00:15:45 +00:00
|
|
|
ALIAS_DEPRECATED(cfg_mgw_local_ip, cfg_mgcpgw_local_ip_cmd,
|
|
|
|
"mgcpgw local-ip A.B.C.D",
|
|
|
|
MGW_STR "local bind to connect to MGCP gateway with\n"
|
|
|
|
"local bind IP address\n")
|
|
|
|
|
|
|
|
DEFUN(cfg_mgw_local_port, cfg_mgw_local_port_cmd,
|
|
|
|
"mgw local-port <0-65535>",
|
2017-10-31 00:18:33 +00:00
|
|
|
MGW_STR "local port to connect to MGW from\n"
|
2016-05-20 19:59:55 +00:00
|
|
|
"local bind port\n")
|
|
|
|
{
|
2017-09-03 23:02:56 +00:00
|
|
|
if (!global_mgcp_client_conf)
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_ERR_NOTHING_TODO;
|
2017-09-03 23:02:56 +00:00
|
|
|
global_mgcp_client_conf->local_port = atoi(argv[0]);
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-10-31 00:15:45 +00:00
|
|
|
ALIAS_DEPRECATED(cfg_mgw_local_port, cfg_mgcpgw_local_port_cmd,
|
|
|
|
"mgcpgw local-port <0-65535>",
|
|
|
|
MGW_STR "local bind to connect to MGCP gateway with\n"
|
|
|
|
"local bind port\n")
|
|
|
|
|
|
|
|
DEFUN(cfg_mgw_remote_ip, cfg_mgw_remote_ip_cmd,
|
|
|
|
"mgw remote-ip A.B.C.D",
|
2017-10-31 00:18:33 +00:00
|
|
|
MGW_STR "remote IP address to reach the MGW at\n"
|
|
|
|
"remote IP address\n")
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
2017-09-03 23:02:56 +00:00
|
|
|
if (!global_mgcp_client_conf)
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_ERR_NOTHING_TODO;
|
2017-09-03 23:02:56 +00:00
|
|
|
OSMO_ASSERT(global_mgcp_client_ctx);
|
2018-12-18 23:30:34 +00:00
|
|
|
osmo_talloc_replace_string(global_mgcp_client_ctx,
|
|
|
|
(char**)&global_mgcp_client_conf->remote_addr,
|
|
|
|
argv[0]);
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-10-31 00:15:45 +00:00
|
|
|
ALIAS_DEPRECATED(cfg_mgw_remote_ip, cfg_mgcpgw_remote_ip_cmd,
|
|
|
|
"mgcpgw remote-ip A.B.C.D",
|
|
|
|
MGW_STR "remote bind to connect to MGCP gateway with\n"
|
|
|
|
"remote bind IP address\n")
|
|
|
|
|
|
|
|
DEFUN(cfg_mgw_remote_port, cfg_mgw_remote_port_cmd,
|
|
|
|
"mgw remote-port <0-65535>",
|
2017-10-31 00:18:33 +00:00
|
|
|
MGW_STR "remote port to reach the MGW at\n"
|
|
|
|
"remote port\n")
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
2017-09-03 23:02:56 +00:00
|
|
|
if (!global_mgcp_client_conf)
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_ERR_NOTHING_TODO;
|
2017-09-03 23:02:56 +00:00
|
|
|
global_mgcp_client_conf->remote_port = atoi(argv[0]);
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-10-31 00:15:45 +00:00
|
|
|
ALIAS_DEPRECATED(cfg_mgw_remote_port, cfg_mgcpgw_remote_port_cmd,
|
|
|
|
"mgcpgw remote-port <0-65535>",
|
|
|
|
MGW_STR "remote bind to connect to MGCP gateway with\n"
|
|
|
|
"remote bind port\n")
|
|
|
|
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
DEFUN_DEPRECATED(cfg_mgw_endpoint_range, cfg_mgw_endpoint_range_cmd,
|
2017-10-31 00:15:45 +00:00
|
|
|
"mgw endpoint-range <1-65534> <1-65534>",
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
MGW_STR "DEPRECATED: the endpoint range cannot be defined by the client\n"
|
|
|
|
"-\n" "-\n")
|
2017-04-09 10:32:51 +00:00
|
|
|
{
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
vty_out(vty, "Please do not use legacy config 'mgw endpoint-range'"
|
|
|
|
" (the range can no longer be defined by the MGCP client)%s",
|
|
|
|
VTY_NEWLINE);
|
2017-04-09 10:32:51 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-10-31 00:15:45 +00:00
|
|
|
ALIAS_DEPRECATED(cfg_mgw_endpoint_range, cfg_mgcpgw_endpoint_range_cmd,
|
|
|
|
"mgcpgw endpoint-range <1-65534> <1-65534>",
|
|
|
|
MGW_STR "usable range of endpoint identifiers\n"
|
|
|
|
"set first useable endpoint identifier\n"
|
|
|
|
"set the last useable endpoint identifier\n")
|
2017-04-09 10:32:51 +00:00
|
|
|
|
2017-12-02 18:31:34 +00:00
|
|
|
#define BTS_START_STR "First UDP port allocated for the BTS side\n"
|
|
|
|
#define UDP_PORT_STR "UDP Port number\n"
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
DEFUN_DEPRECATED(cfg_mgw_rtp_bts_base_port,
|
2017-12-02 18:31:34 +00:00
|
|
|
cfg_mgw_rtp_bts_base_port_cmd,
|
|
|
|
"mgw bts-base <0-65534>",
|
|
|
|
MGW_STR
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
"DEPRECATED: there is no explicit BTS side in current osmo-mgw\n" "-\n")
|
2017-12-02 18:31:34 +00:00
|
|
|
{
|
mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.
I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.
It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.
Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.
Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-18 23:44:37 +00:00
|
|
|
vty_out(vty, "Please do not use legacy config 'mgw bts-base'"
|
|
|
|
" (there is no explicit BTS side in an MGW anymore)%s",
|
|
|
|
VTY_NEWLINE);
|
2017-12-02 18:31:34 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
ALIAS_DEPRECATED(cfg_mgw_rtp_bts_base_port,
|
|
|
|
cfg_mgcpgw_rtp_bts_base_port_cmd,
|
|
|
|
"mgcpgw bts-base <0-65534>",
|
|
|
|
MGW_STR
|
|
|
|
BTS_START_STR
|
|
|
|
UDP_PORT_STR)
|
|
|
|
|
2018-12-18 23:27:50 +00:00
|
|
|
DEFUN(cfg_mgw_endpoint_domain_name,
|
|
|
|
cfg_mgw_endpoint_domain_name_cmd,
|
|
|
|
"mgw endpoint-domain NAME",
|
|
|
|
MGW_STR "Set the domain name to send in MGCP messages, e.g. the part 'foo' in 'rtpbridge/*@foo'.\n"
|
|
|
|
"Domain name, should be alphanumeric.\n")
|
|
|
|
{
|
|
|
|
if (osmo_strlcpy(global_mgcp_client_conf->endpoint_domain_name, argv[0],
|
|
|
|
sizeof(global_mgcp_client_conf->endpoint_domain_name))
|
|
|
|
>= sizeof(global_mgcp_client_conf->endpoint_domain_name)) {
|
|
|
|
vty_out(vty, "%% Error: 'mgw endpoint-domain' name too long, max length is %zu: '%s'%s",
|
|
|
|
sizeof(global_mgcp_client_conf->endpoint_domain_name) - 1, argv[0], VTY_NEWLINE);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
int mgcp_client_config_write(struct vty *vty, const char *indent)
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
|
|
|
const char *addr;
|
|
|
|
int port;
|
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
addr = global_mgcp_client_conf->local_addr;
|
2016-05-20 19:59:55 +00:00
|
|
|
if (addr)
|
2017-10-31 00:15:45 +00:00
|
|
|
vty_out(vty, "%smgw local-ip %s%s", indent, addr,
|
2016-05-20 19:59:55 +00:00
|
|
|
VTY_NEWLINE);
|
2017-09-03 23:02:56 +00:00
|
|
|
port = global_mgcp_client_conf->local_port;
|
2016-05-20 19:59:55 +00:00
|
|
|
if (port >= 0)
|
2017-10-31 00:15:45 +00:00
|
|
|
vty_out(vty, "%smgw local-port %u%s", indent,
|
2016-05-20 19:59:55 +00:00
|
|
|
(uint16_t)port, VTY_NEWLINE);
|
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
addr = global_mgcp_client_conf->remote_addr;
|
2016-05-20 19:59:55 +00:00
|
|
|
if (addr)
|
2017-10-31 00:15:45 +00:00
|
|
|
vty_out(vty, "%smgw remote-ip %s%s", indent, addr,
|
2016-05-20 19:59:55 +00:00
|
|
|
VTY_NEWLINE);
|
2017-09-03 23:02:56 +00:00
|
|
|
port = global_mgcp_client_conf->remote_port;
|
2016-05-20 19:59:55 +00:00
|
|
|
if (port >= 0)
|
2017-10-31 00:15:45 +00:00
|
|
|
vty_out(vty, "%smgw remote-port %u%s", indent,
|
2016-05-20 19:59:55 +00:00
|
|
|
(uint16_t)port, VTY_NEWLINE);
|
|
|
|
|
2018-12-18 23:27:50 +00:00
|
|
|
if (global_mgcp_client_conf->endpoint_domain_name[0])
|
|
|
|
vty_out(vty, "%smgw endpoint-domain %s%s", indent,
|
|
|
|
global_mgcp_client_conf->endpoint_domain_name, VTY_NEWLINE);
|
|
|
|
|
2016-05-20 19:59:55 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2017-09-03 23:02:56 +00:00
|
|
|
void mgcp_client_vty_init(void *talloc_ctx, int node, struct mgcp_client_conf *conf)
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
2017-09-03 23:02:56 +00:00
|
|
|
global_mgcp_client_ctx = talloc_ctx;
|
|
|
|
global_mgcp_client_conf = conf;
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-10-31 00:15:45 +00:00
|
|
|
install_element(node, &cfg_mgw_local_ip_cmd);
|
|
|
|
install_element(node, &cfg_mgw_local_port_cmd);
|
|
|
|
install_element(node, &cfg_mgw_remote_ip_cmd);
|
|
|
|
install_element(node, &cfg_mgw_remote_port_cmd);
|
|
|
|
install_element(node, &cfg_mgw_endpoint_range_cmd);
|
2017-12-02 18:31:34 +00:00
|
|
|
install_element(node, &cfg_mgw_rtp_bts_base_port_cmd);
|
2018-12-18 23:27:50 +00:00
|
|
|
install_element(node, &cfg_mgw_endpoint_domain_name_cmd);
|
2017-10-31 00:15:45 +00:00
|
|
|
|
|
|
|
/* deprecated 'mgcpgw' commands */
|
2016-05-20 19:59:55 +00:00
|
|
|
install_element(node, &cfg_mgcpgw_local_ip_cmd);
|
|
|
|
install_element(node, &cfg_mgcpgw_local_port_cmd);
|
|
|
|
install_element(node, &cfg_mgcpgw_remote_ip_cmd);
|
|
|
|
install_element(node, &cfg_mgcpgw_remote_port_cmd);
|
2017-04-09 10:32:51 +00:00
|
|
|
install_element(node, &cfg_mgcpgw_endpoint_range_cmd);
|
2017-12-02 18:31:34 +00:00
|
|
|
install_element(node, &cfg_mgcpgw_rtp_bts_base_port_cmd);
|
2018-02-22 17:09:28 +00:00
|
|
|
|
|
|
|
osmo_fsm_vty_add_cmds();
|
2016-05-20 19:59:55 +00:00
|
|
|
}
|