Move existing vty code to its own vty.c/h file
Change-Id: I88107e9ed03ff8f807b57a3ea0d189fd70864861
This commit is contained in:
parent
67a3c4a7c6
commit
8125fd0d95
|
@ -2,4 +2,5 @@ noinst_HEADERS = \
|
||||||
hnodeb.h \
|
hnodeb.h \
|
||||||
ranap.h \
|
ranap.h \
|
||||||
rua.h \
|
rua.h \
|
||||||
|
vty.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <asn1c/asn1helpers.h>
|
||||||
|
|
||||||
#include <osmocom/core/select.h>
|
#include <osmocom/core/select.h>
|
||||||
#include <osmocom/core/linuxlist.h>
|
#include <osmocom/core/linuxlist.h>
|
||||||
#include <osmocom/core/write_queue.h>
|
#include <osmocom/core/write_queue.h>
|
||||||
|
@ -101,4 +103,10 @@ void hnb_rx_paging(struct hnb *hnb, const char *imsi);
|
||||||
void hnb_nas_rx_dtap(struct hnb *hnb, void *data, int len);
|
void hnb_nas_rx_dtap(struct hnb *hnb, void *data, int len);
|
||||||
void hnb_rx_secmode_cmd(struct hnb *hnb, long ip_alg);
|
void hnb_rx_secmode_cmd(struct hnb *hnb, long ip_alg);
|
||||||
|
|
||||||
|
int hnb_ue_register_tx(struct hnb *hnb, const char *imsi_str);
|
||||||
|
void hnb_send_register_req(struct hnb *hnb);
|
||||||
|
void hnb_send_deregister_req(struct hnb *hnb);
|
||||||
|
struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi);
|
||||||
|
|
||||||
|
extern void *tall_hnb_ctx;
|
||||||
extern struct hnb g_hnb;
|
extern struct hnb g_hnb;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* (C) 2015 by Daniel Willmann <dwillmann@sysmocom.de>
|
||||||
|
* (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||||
|
* Author: Pau Espin Pedrol <pespin@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/lienses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <osmocom/vty/vty.h>
|
||||||
|
#include <osmocom/vty/buffer.h>
|
||||||
|
#include <osmocom/vty/command.h>
|
||||||
|
|
||||||
|
enum hnb_vty_nodes {
|
||||||
|
CHAN_NODE = _LAST_OSMOVTY_NODE,
|
||||||
|
};
|
||||||
|
|
||||||
|
void hnb_vty_init(void);
|
|
@ -33,6 +33,7 @@ osmo_hnodeb_SOURCES = \
|
||||||
debug.c \
|
debug.c \
|
||||||
ranap.c \
|
ranap.c \
|
||||||
rua.c \
|
rua.c \
|
||||||
|
vty.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
osmo_hnodeb_LDADD = \
|
osmo_hnodeb_LDADD = \
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
#include <osmocom/hnbap/hnbap_common.h>
|
#include <osmocom/hnbap/hnbap_common.h>
|
||||||
#include <osmocom/hnbap/hnbap_ies_defs.h>
|
#include <osmocom/hnbap/hnbap_ies_defs.h>
|
||||||
#include <osmocom/rua/rua_msg_factory.h>
|
#include <osmocom/rua/rua_msg_factory.h>
|
||||||
#include "asn1helpers.h"
|
|
||||||
#include <osmocom/ranap/iu_helpers.h>
|
#include <osmocom/ranap/iu_helpers.h>
|
||||||
|
|
||||||
#include <osmocom/ranap/ranap_msg_factory.h>
|
#include <osmocom/ranap/ranap_msg_factory.h>
|
||||||
|
@ -70,9 +69,10 @@
|
||||||
|
|
||||||
#include <osmocom/hnodeb/rua.h>
|
#include <osmocom/hnodeb/rua.h>
|
||||||
#include <osmocom/hnodeb/ranap.h>
|
#include <osmocom/hnodeb/ranap.h>
|
||||||
|
#include <osmocom/hnodeb/vty.h>
|
||||||
#include <osmocom/hnodeb/hnodeb.h>
|
#include <osmocom/hnodeb/hnodeb.h>
|
||||||
|
|
||||||
static void *tall_hnb_ctx;
|
void *tall_hnb_ctx;
|
||||||
|
|
||||||
struct hnb g_hnb = {
|
struct hnb g_hnb = {
|
||||||
.gw_addr = "127.0.0.1",
|
.gw_addr = "127.0.0.1",
|
||||||
|
@ -113,7 +113,7 @@ static int hnb_ue_de_register_tx(struct hnb *hnb)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int hnb_ue_register_tx(struct hnb *hnb, const char *imsi_str)
|
int hnb_ue_register_tx(struct hnb *hnb, const char *imsi_str)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
int rc, imsi_len;
|
int rc, imsi_len;
|
||||||
|
@ -649,7 +649,7 @@ static int hnb_write_cb(struct osmo_fd *fd, struct msgb *msg)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hnb_send_register_req(struct hnb *hnb)
|
void hnb_send_register_req(struct hnb *hnb)
|
||||||
{
|
{
|
||||||
HNBAP_HNBRegisterRequest_t request_out;
|
HNBAP_HNBRegisterRequest_t request_out;
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
@ -698,7 +698,7 @@ static void hnb_send_register_req(struct hnb *hnb)
|
||||||
osmo_wqueue_enqueue(&hnb->wqueue, msg);
|
osmo_wqueue_enqueue(&hnb->wqueue, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hnb_send_deregister_req(struct hnb *hnb)
|
void hnb_send_deregister_req(struct hnb *hnb)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -744,79 +744,8 @@ static int sctp_sock_init(int fd)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HNBAP_STR "HNBAP related commands\n"
|
|
||||||
#define HNB_STR "HomeNodeB commands\n"
|
|
||||||
#define UE_STR "User Equipment commands\n"
|
|
||||||
#define RANAP_STR "RANAP related commands\n"
|
|
||||||
#define CSPS_STR "Circuit Switched\n" "Packet Switched\n"
|
|
||||||
|
|
||||||
DEFUN(hnb_register, hnb_register_cmd,
|
struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi)
|
||||||
"hnbap hnb register", HNBAP_STR HNB_STR "Send HNB-REGISTER REQUEST")
|
|
||||||
{
|
|
||||||
hnb_send_register_req(&g_hnb);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN(hnb_deregister, hnb_deregister_cmd,
|
|
||||||
"hnbap hnb deregister", HNBAP_STR HNB_STR "Send HNB-DEREGISTER REQUEST")
|
|
||||||
{
|
|
||||||
hnb_send_deregister_req(&g_hnb);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN(ue_register, ue_register_cmd,
|
|
||||||
"hnbap ue register IMSI", HNBAP_STR UE_STR "Send UE-REGISTER REQUEST")
|
|
||||||
{
|
|
||||||
hnb_ue_register_tx(&g_hnb, argv[0]);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN(asn_dbg, asn_dbg_cmd,
|
|
||||||
"asn-debug (1|0)", "Enable or disable libasn1c debugging")
|
|
||||||
{
|
|
||||||
asn_debug = atoi(argv[0]);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN(ranap_reset, ranap_reset_cmd,
|
|
||||||
"ranap reset (cs|ps)", RANAP_STR "Send RANAP RESET\n" CSPS_STR)
|
|
||||||
{
|
|
||||||
int is_ps = 0;
|
|
||||||
struct msgb *msg, *rua;
|
|
||||||
|
|
||||||
RANAP_Cause_t cause = {
|
|
||||||
.present = RANAP_Cause_PR_transmissionNetwork,
|
|
||||||
.choice.transmissionNetwork = RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!strcmp(argv[0], "ps"))
|
|
||||||
is_ps = 1;
|
|
||||||
|
|
||||||
msg = ranap_new_msg_reset(is_ps, &cause);
|
|
||||||
rua = rua_new_udt(msg);
|
|
||||||
//msgb_free(msg);
|
|
||||||
osmo_wqueue_enqueue(&g_hnb.wqueue, rua);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum my_vty_nodes {
|
|
||||||
CHAN_NODE = _LAST_OSMOVTY_NODE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct cmd_node chan_node = {
|
|
||||||
CHAN_NODE,
|
|
||||||
"%s(chan)> ",
|
|
||||||
1,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi)
|
|
||||||
{
|
{
|
||||||
uint8_t lu[] = { GSM48_PDISC_MM, GSM48_MT_MM_LOC_UPD_REQUEST,
|
uint8_t lu[] = { GSM48_PDISC_MM, GSM48_MT_MM_LOC_UPD_REQUEST,
|
||||||
0x70, 0x62, 0xf2, 0x30, 0xff, 0xf3, 0x57,
|
0x70, 0x62, 0xf2, 0x30, 0xff, 0xf3, 0x57,
|
||||||
|
@ -848,52 +777,6 @@ static struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi)
|
||||||
return ranap_new_msg_initial_ue(conn_id, is_ps, &rnc_id, lu, sizeof(lu));
|
return ranap_new_msg_initial_ue(conn_id, is_ps, &rnc_id, lu, sizeof(lu));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(chan, chan_cmd,
|
|
||||||
"channel (cs|ps) lu imsi IMSI",
|
|
||||||
"Open a new Signalling Connection\n"
|
|
||||||
"To Circuit-Switched CN\n"
|
|
||||||
"To Packet-Switched CN\n"
|
|
||||||
"Performing a Location Update\n"
|
|
||||||
)
|
|
||||||
{
|
|
||||||
struct hnb_chan *chan;
|
|
||||||
struct msgb *msg, *rua;
|
|
||||||
static uint16_t conn_id = 42;
|
|
||||||
|
|
||||||
chan = talloc_zero(tall_hnb_ctx, struct hnb_chan);
|
|
||||||
if (!strcmp(argv[0], "ps"))
|
|
||||||
chan->is_ps = 1;
|
|
||||||
chan->imsi = talloc_strdup(chan, argv[1]);
|
|
||||||
chan->conn_id = conn_id;
|
|
||||||
conn_id++;
|
|
||||||
|
|
||||||
msg = gen_initue_lu(chan->is_ps, chan->conn_id, chan->imsi);
|
|
||||||
rua = rua_new_conn(chan->is_ps, chan->conn_id, msg);
|
|
||||||
|
|
||||||
osmo_wqueue_enqueue(&g_hnb.wqueue, rua);
|
|
||||||
|
|
||||||
vty->index = chan;
|
|
||||||
vty->node = CHAN_NODE;
|
|
||||||
|
|
||||||
if (!chan->is_ps)
|
|
||||||
g_hnb.cs.chan = chan;
|
|
||||||
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void hnb_vty_init(void)
|
|
||||||
{
|
|
||||||
install_element_ve(&asn_dbg_cmd);
|
|
||||||
install_element_ve(&hnb_register_cmd);
|
|
||||||
install_element_ve(&hnb_deregister_cmd);
|
|
||||||
install_element_ve(&ue_register_cmd);
|
|
||||||
install_element_ve(&ranap_reset_cmd);
|
|
||||||
install_element_ve(&chan_cmd);
|
|
||||||
|
|
||||||
install_node(&chan_node, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_options(int argc, char **argv)
|
static void handle_options(int argc, char **argv)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
/* (C) 2015 by Daniel Willmann <dwillmann@sysmocom.de>
|
||||||
|
* (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||||
|
* Author: Pau Espin Pedrol <pespin@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/lienses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <osmocom/vty/telnet_interface.h>
|
||||||
|
#include <osmocom/vty/logging.h>
|
||||||
|
#include <osmocom/vty/command.h>
|
||||||
|
#include <osmocom/core/msgb.h>
|
||||||
|
|
||||||
|
#include <osmocom/rua/rua_msg_factory.h>
|
||||||
|
|
||||||
|
#include <osmocom/ranap/ranap_common.h>
|
||||||
|
#include <osmocom/ranap/ranap_msg_factory.h>
|
||||||
|
|
||||||
|
#include <osmocom/hnodeb/vty.h>
|
||||||
|
#include <osmocom/hnodeb/hnodeb.h>
|
||||||
|
|
||||||
|
static struct cmd_node chan_node = {
|
||||||
|
CHAN_NODE,
|
||||||
|
"%s(chan)> ",
|
||||||
|
1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define HNBAP_STR "HNBAP related commands\n"
|
||||||
|
#define HNB_STR "HomeNodeB commands\n"
|
||||||
|
#define UE_STR "User Equipment commands\n"
|
||||||
|
#define RANAP_STR "RANAP related commands\n"
|
||||||
|
#define CSPS_STR "Circuit Switched\n" "Packet Switched\n"
|
||||||
|
|
||||||
|
DEFUN(hnb_register, hnb_register_cmd,
|
||||||
|
"hnbap hnb register", HNBAP_STR HNB_STR "Send HNB-REGISTER REQUEST")
|
||||||
|
{
|
||||||
|
hnb_send_register_req(&g_hnb);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(hnb_deregister, hnb_deregister_cmd,
|
||||||
|
"hnbap hnb deregister", HNBAP_STR HNB_STR "Send HNB-DEREGISTER REQUEST")
|
||||||
|
{
|
||||||
|
hnb_send_deregister_req(&g_hnb);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(ue_register, ue_register_cmd,
|
||||||
|
"hnbap ue register IMSI", HNBAP_STR UE_STR "Send UE-REGISTER REQUEST")
|
||||||
|
{
|
||||||
|
hnb_ue_register_tx(&g_hnb, argv[0]);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(asn_dbg, asn_dbg_cmd,
|
||||||
|
"asn-debug (1|0)", "Enable or disable libasn1c debugging")
|
||||||
|
{
|
||||||
|
asn_debug = atoi(argv[0]);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(ranap_reset, ranap_reset_cmd,
|
||||||
|
"ranap reset (cs|ps)", RANAP_STR "Send RANAP RESET\n" CSPS_STR)
|
||||||
|
{
|
||||||
|
int is_ps = 0;
|
||||||
|
struct msgb *msg, *rua;
|
||||||
|
|
||||||
|
RANAP_Cause_t cause = {
|
||||||
|
.present = RANAP_Cause_PR_transmissionNetwork,
|
||||||
|
.choice.transmissionNetwork = RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!strcmp(argv[0], "ps"))
|
||||||
|
is_ps = 1;
|
||||||
|
|
||||||
|
msg = ranap_new_msg_reset(is_ps, &cause);
|
||||||
|
rua = rua_new_udt(msg);
|
||||||
|
//msgb_free(msg);
|
||||||
|
osmo_wqueue_enqueue(&g_hnb.wqueue, rua);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN(chan, chan_cmd,
|
||||||
|
"channel (cs|ps) lu imsi IMSI",
|
||||||
|
"Open a new Signalling Connection\n"
|
||||||
|
"To Circuit-Switched CN\n"
|
||||||
|
"To Packet-Switched CN\n"
|
||||||
|
"Performing a Location Update\n"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct hnb_chan *chan;
|
||||||
|
struct msgb *msg, *rua;
|
||||||
|
static uint16_t conn_id = 42;
|
||||||
|
|
||||||
|
chan = talloc_zero(tall_hnb_ctx, struct hnb_chan);
|
||||||
|
if (!strcmp(argv[0], "ps"))
|
||||||
|
chan->is_ps = 1;
|
||||||
|
chan->imsi = talloc_strdup(chan, argv[1]);
|
||||||
|
chan->conn_id = conn_id;
|
||||||
|
conn_id++;
|
||||||
|
|
||||||
|
msg = gen_initue_lu(chan->is_ps, chan->conn_id, chan->imsi);
|
||||||
|
rua = rua_new_conn(chan->is_ps, chan->conn_id, msg);
|
||||||
|
|
||||||
|
osmo_wqueue_enqueue(&g_hnb.wqueue, rua);
|
||||||
|
|
||||||
|
vty->index = chan;
|
||||||
|
vty->node = CHAN_NODE;
|
||||||
|
|
||||||
|
if (!chan->is_ps)
|
||||||
|
g_hnb.cs.chan = chan;
|
||||||
|
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hnb_vty_init(void)
|
||||||
|
{
|
||||||
|
install_element_ve(&asn_dbg_cmd);
|
||||||
|
install_element_ve(&hnb_register_cmd);
|
||||||
|
install_element_ve(&hnb_deregister_cmd);
|
||||||
|
install_element_ve(&ue_register_cmd);
|
||||||
|
install_element_ve(&ranap_reset_cmd);
|
||||||
|
install_element_ve(&chan_cmd);
|
||||||
|
|
||||||
|
install_node(&chan_node, NULL);
|
||||||
|
}
|
Loading…
Reference in New Issue