Set up Iuh conn params through VTY
Change-Id: Id5a17742643e8f02c22228e3055bcc213423a416
This commit is contained in:
parent
5e3098d56a
commit
bf3cb41af5
|
@ -70,8 +70,12 @@ struct hnb_chan {
|
|||
};
|
||||
|
||||
struct hnb {
|
||||
const char *gw_addr;
|
||||
uint16_t gw_port;
|
||||
struct {
|
||||
char *local_addr;
|
||||
uint16_t local_port;
|
||||
char *remote_addr;
|
||||
uint16_t remote_port;
|
||||
} iuh;
|
||||
/*! SCTP listen socket for incoming connections */
|
||||
struct osmo_fd conn_fd;
|
||||
|
||||
|
@ -91,8 +95,6 @@ struct hnb {
|
|||
|
||||
uint32_t ctx_id;
|
||||
|
||||
int ues;
|
||||
|
||||
struct {
|
||||
struct hnb_chan *chan;
|
||||
} cs;
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
#include <osmocom/vty/command.h>
|
||||
|
||||
enum hnb_vty_nodes {
|
||||
CHAN_NODE = _LAST_OSMOVTY_NODE,
|
||||
HNODEB_NODE = _LAST_OSMOVTY_NODE,
|
||||
IUH_NODE,
|
||||
CHAN_NODE,
|
||||
};
|
||||
|
||||
void hnb_vty_init(void);
|
||||
int hnb_vty_go_parent(struct vty *vty);
|
||||
|
|
|
@ -137,8 +137,10 @@ struct hnb *hnb_alloc(void *tall_ctx)
|
|||
if (!hnb)
|
||||
return NULL;
|
||||
|
||||
hnb->gw_addr = "127.0.0.1",
|
||||
hnb->gw_port = IUH_DEFAULT_SCTP_PORT,
|
||||
hnb->iuh.local_addr = NULL;
|
||||
hnb->iuh.local_port = 0;
|
||||
hnb->iuh.remote_addr = talloc_strdup(hnb, "127.0.0.1");
|
||||
hnb->iuh.remote_port = IUH_DEFAULT_SCTP_PORT;
|
||||
|
||||
osmo_wqueue_init(&hnb->wqueue, 16);
|
||||
hnb->wqueue.bfd.data = hnb;
|
||||
|
@ -151,9 +153,14 @@ struct hnb *hnb_alloc(void *tall_ctx)
|
|||
int hnb_connect(struct hnb *hnb)
|
||||
{
|
||||
int rc;
|
||||
rc = osmo_sock_init_ofd(&hnb->wqueue.bfd, AF_INET, SOCK_STREAM,
|
||||
IPPROTO_SCTP, hnb->gw_addr,
|
||||
hnb->gw_port, OSMO_SOCK_F_CONNECT);
|
||||
|
||||
LOGP(DMAIN, LOGL_INFO, "Iuh Connect: %s[:%u] => %s[:%u]\n",
|
||||
hnb->iuh.local_addr, hnb->iuh.local_port, hnb->iuh.remote_addr, hnb->iuh.remote_port);
|
||||
|
||||
rc = osmo_sock_init2_ofd(&hnb->wqueue.bfd, AF_INET, SOCK_STREAM, IPPROTO_SCTP,
|
||||
hnb->iuh.local_addr, hnb->iuh.local_port,
|
||||
hnb->iuh.remote_addr, hnb->iuh.remote_port,
|
||||
OSMO_SOCK_F_BIND |OSMO_SOCK_F_CONNECT);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
sctp_sock_init(hnb->wqueue.bfd.fd);
|
||||
|
|
|
@ -75,6 +75,7 @@ static struct {
|
|||
static struct vty_app_info vty_info = {
|
||||
.name = "OsmoHNodeB",
|
||||
.version = PACKAGE_VERSION,
|
||||
.go_parent_cb = hnb_vty_go_parent,
|
||||
};
|
||||
|
||||
static void print_usage()
|
||||
|
@ -140,12 +141,10 @@ static void handle_options(int argc, char **argv)
|
|||
{"log-level", 1, 0, 'e'},
|
||||
{"vty-ref-mode", 1, &long_option, 1},
|
||||
{"vty-ref-xml", 0, &long_option, 2},
|
||||
{ "ues", 1, 0, 'u' },
|
||||
{ "gw-addr", 1, 0, 'g' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hd:Dc:sTVe:u:g:", long_options, &idx);
|
||||
c = getopt_long(argc, argv, "hd:Dc:sTVe:", long_options, &idx);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -180,12 +179,6 @@ static void handle_options(int argc, char **argv)
|
|||
case 'e':
|
||||
log_set_log_level(osmo_stderr_target, atoi(optarg));
|
||||
break;
|
||||
case 'u':
|
||||
g_hnb->ues = atoi(optarg);
|
||||
break;
|
||||
case 'g':
|
||||
g_hnb->gw_addr = optarg;
|
||||
break;
|
||||
default:
|
||||
/* catch unknown options *as well as* missing arguments. */
|
||||
fprintf(stderr, "Error in command line options. Exiting.\n");
|
||||
|
|
|
@ -37,6 +37,119 @@
|
|||
#include <osmocom/hnodeb/vty.h>
|
||||
#include <osmocom/hnodeb/hnodeb.h>
|
||||
|
||||
int hnb_vty_go_parent(struct vty *vty)
|
||||
{
|
||||
switch (vty->node) {
|
||||
case IUH_NODE:
|
||||
vty->node = HNODEB_NODE;
|
||||
vty->index = g_hnb;
|
||||
break;
|
||||
case HNODEB_NODE:
|
||||
vty->node = CONFIG_NODE;
|
||||
vty->index = g_hnb;
|
||||
break;
|
||||
case CONFIG_NODE:
|
||||
vty->node = ENABLE_NODE;
|
||||
vty->index = NULL;
|
||||
break;
|
||||
default:
|
||||
vty->node = CONFIG_NODE;
|
||||
vty->index = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return vty->node;
|
||||
}
|
||||
|
||||
static struct cmd_node hnodeb_node = {
|
||||
HNODEB_NODE,
|
||||
"%s(config-hnodeb)# ",
|
||||
1,
|
||||
};
|
||||
|
||||
#define HNODEB_STR "Configure the HNodeB\n"
|
||||
|
||||
DEFUN(cfg_hnodeb,
|
||||
cfg_hnodeb_cmd,
|
||||
"hnodeb", HNODEB_STR)
|
||||
{
|
||||
OSMO_ASSERT(g_hnb);
|
||||
vty->index = g_hnb;
|
||||
vty->node = HNODEB_NODE;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static struct cmd_node iuh_node = {
|
||||
IUH_NODE,
|
||||
"%s(config-iuh)# ",
|
||||
1,
|
||||
};
|
||||
|
||||
DEFUN(cfg_hnodeb_iuh,
|
||||
cfg_hnodeb_iuh_cmd,
|
||||
"iuh", "Configure Iuh options\n")
|
||||
{
|
||||
OSMO_ASSERT(g_hnb);
|
||||
vty->index = g_hnb;
|
||||
vty->node = IUH_NODE;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_hnodeb_iuh_local_ip, cfg_hnodeb_iuh_local_ip_cmd,
|
||||
"local-ip " VTY_IPV46_CMD,
|
||||
"Bind Iuh connection on local IP address\n"
|
||||
"Local interface IPv4 address\n"
|
||||
"Local interface IPv6 address\n")
|
||||
{
|
||||
osmo_talloc_replace_string(g_hnb, &g_hnb->iuh.local_addr, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_hnodeb_iuh_local_port, cfg_hnodeb_iuh_local_port_cmd,
|
||||
"local-port <1-65535>",
|
||||
"Bind Iuh connection on local SCTP port\n"
|
||||
"Local interface port\n")
|
||||
{
|
||||
g_hnb->iuh.local_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_hnodeb_iuh_remote_ip, cfg_hnodeb_iuh_remote_ip_cmd,
|
||||
"remote-ip " VTY_IPV46_CMD,
|
||||
"Connect to HNBGW over Iuh on remote IP address\n"
|
||||
"Remote interface IPv4 address\n"
|
||||
"Remote interface IPv6 address\n")
|
||||
{
|
||||
osmo_talloc_replace_string(g_hnb, &g_hnb->iuh.remote_addr, argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN(cfg_hnodeb_iuh_remote_port, cfg_hnodeb_iuh_remote_port_cmd,
|
||||
"remote-port <1-65535>",
|
||||
"Connect to HNBGW over Iuh on remote SCTP port\n"
|
||||
"Remote interface port (default: "OSMO_STRINGIFY_VAL(IUH_DEFAULT_SCTP_PORT) ")\n")
|
||||
{
|
||||
g_hnb->iuh.remote_port = atoi(argv[0]);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int config_write_hnodeb(struct vty *vty)
|
||||
{
|
||||
vty_out(vty, "hnodeb%s", VTY_NEWLINE);
|
||||
vty_out(vty, " iuh%s", VTY_NEWLINE);
|
||||
if (g_hnb->iuh.local_addr)
|
||||
vty_out(vty, " local-ip %s%s", g_hnb->iuh.local_addr, VTY_NEWLINE);
|
||||
if (g_hnb->iuh.local_port)
|
||||
vty_out(vty, " local-port %u%s", g_hnb->iuh.local_port, VTY_NEWLINE);
|
||||
vty_out(vty, " remote-ip %s%s", g_hnb->iuh.remote_addr, VTY_NEWLINE);
|
||||
vty_out(vty, " remote-port %u%s", g_hnb->iuh.remote_port, VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static struct cmd_node chan_node = {
|
||||
CHAN_NODE,
|
||||
"%s(chan)> ",
|
||||
|
@ -139,6 +252,15 @@ DEFUN(chan, chan_cmd,
|
|||
|
||||
void hnb_vty_init(void)
|
||||
{
|
||||
install_element(CONFIG_NODE, &cfg_hnodeb_cmd);
|
||||
install_node(&hnodeb_node, config_write_hnodeb);
|
||||
install_element(HNODEB_NODE, &cfg_hnodeb_iuh_cmd);
|
||||
install_node(&iuh_node, NULL);
|
||||
install_element(IUH_NODE, &cfg_hnodeb_iuh_local_ip_cmd);
|
||||
install_element(IUH_NODE, &cfg_hnodeb_iuh_local_port_cmd);
|
||||
install_element(IUH_NODE, &cfg_hnodeb_iuh_remote_ip_cmd);
|
||||
install_element(IUH_NODE, &cfg_hnodeb_iuh_remote_port_cmd);
|
||||
|
||||
install_element_ve(&asn_dbg_cmd);
|
||||
install_element_ve(&hnb_register_cmd);
|
||||
install_element_ve(&hnb_deregister_cmd);
|
||||
|
|
Loading…
Reference in New Issue