mirror of
https://gerrit.osmocom.org/osmo-gbproxy
synced 2024-08-18 17:06:31 +00:00
[VTY] restructure sms and silent sms commands
This commit is contained in:
parent
9ee8ee9afc
commit
194ef7b443
1 changed files with 35 additions and 66 deletions
|
@ -205,89 +205,60 @@ static int _send_sms_buffer(struct gsm_subscriber *receiver,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(sms_send_ext,
|
static struct gsm_subscriber *get_subscr_by_argv(const char *type,
|
||||||
sms_send_ext_cmd,
|
const char *id)
|
||||||
"sms send extension EXTEN .LINE",
|
|
||||||
"Send a message to a subscriber identified by EXTEN")
|
|
||||||
{
|
{
|
||||||
struct gsm_subscriber *receiver;
|
if (!strcmp(type, "extension"))
|
||||||
|
return subscr_get_by_extension(gsmnet, id);
|
||||||
|
else if (!strcmp(type, "imsi"))
|
||||||
|
return subscr_get_by_imsi(gsmnet, id);
|
||||||
|
else if (!strcmp(type, "tmsi"))
|
||||||
|
return subscr_get_by_tmsi(gsmnet, atoi(id));
|
||||||
|
else if (!strcmp(type, "id"))
|
||||||
|
return subscr_get_by_id(gsmnet, atoi(id));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#define SUBSCR_TYPES "(extension|imsi|tmsi|id)"
|
||||||
|
|
||||||
|
DEFUN(subscriber_send_sms,
|
||||||
|
subscriber_send_sms_cmd,
|
||||||
|
"subscriber " SUBSCR_TYPES " EXTEN sms send .LINE",
|
||||||
|
"Select subscriber based on extension")
|
||||||
|
{
|
||||||
|
struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
|
||||||
struct buffer *b;
|
struct buffer *b;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
receiver = subscr_get_by_extension(gsmnet, argv[0]);
|
if (!subscr)
|
||||||
if (!receiver)
|
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
b = argv_to_buffer(argc, argv, 1);
|
b = argv_to_buffer(argc, argv, 2);
|
||||||
rc = _send_sms_buffer(receiver, b, 0);
|
rc = _send_sms_buffer(subscr, b, 0);
|
||||||
buffer_free(b);
|
buffer_free(b);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(sms_send_silent_ext,
|
DEFUN(subscriber_silent_sms,
|
||||||
sms_send_silent_ext_cmd,
|
subscriber_silent_sms_cmd,
|
||||||
"sms send silent extension EXTEN .LINE",
|
"subscriber " SUBSCR_TYPES " EXTEN silent sms send .LINE",
|
||||||
"Send a silent message to a subscriber identified by EXTEN")
|
"Select subscriber based on extension")
|
||||||
{
|
{
|
||||||
struct gsm_subscriber *receiver;
|
struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
|
||||||
struct buffer *b;
|
struct buffer *b;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
receiver = subscr_get_by_extension(gsmnet, argv[0]);
|
if (!subscr)
|
||||||
if (!receiver)
|
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
b = argv_to_buffer(argc, argv, 1);
|
b = argv_to_buffer(argc, argv, 2);
|
||||||
rc = _send_sms_buffer(receiver, b, 64);
|
rc = _send_sms_buffer(subscr, b, 0);
|
||||||
buffer_free(b);
|
|
||||||
subscr_put(receiver);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN(sms_send_imsi,
|
|
||||||
sms_send_imsi_cmd,
|
|
||||||
"sms send imsi IMSI .LINE",
|
|
||||||
"Send a message to a subscriber identified by IMSI")
|
|
||||||
{
|
|
||||||
struct gsm_subscriber *receiver;
|
|
||||||
struct buffer *b;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
receiver = subscr_get_by_imsi(gsmnet, argv[0]);
|
|
||||||
if (!receiver)
|
|
||||||
return CMD_WARNING;
|
|
||||||
|
|
||||||
b = argv_to_buffer(argc, argv, 1);
|
|
||||||
rc = _send_sms_buffer(receiver, b, 0);
|
|
||||||
buffer_free(b);
|
buffer_free(b);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(sms_send_silent_imsi,
|
|
||||||
sms_send_silent_imsi_cmd,
|
|
||||||
"sms send silent imsi IMSI .LINE",
|
|
||||||
"Send a silent message to a subscriber identified by IMSI")
|
|
||||||
{
|
|
||||||
struct gsm_subscriber *receiver;
|
|
||||||
struct buffer *b;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
receiver = subscr_get_by_imsi(gsmnet, argv[0]);
|
|
||||||
if (!receiver)
|
|
||||||
return CMD_WARNING;
|
|
||||||
|
|
||||||
b = argv_to_buffer(argc, argv, 1);
|
|
||||||
rc = _send_sms_buffer(receiver, b, 64);
|
|
||||||
buffer_free(b);
|
|
||||||
subscr_put(receiver);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DEFUN(cfg_subscr_name,
|
DEFUN(cfg_subscr_name,
|
||||||
cfg_subscr_name_cmd,
|
cfg_subscr_name_cmd,
|
||||||
"name NAME",
|
"name NAME",
|
||||||
|
@ -336,7 +307,6 @@ DEFUN(cfg_subscr_authorized,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int bsc_vty_init_extra(struct gsm_network *net)
|
int bsc_vty_init_extra(struct gsm_network *net)
|
||||||
{
|
{
|
||||||
gsmnet = net;
|
gsmnet = net;
|
||||||
|
@ -345,10 +315,9 @@ int bsc_vty_init_extra(struct gsm_network *net)
|
||||||
install_element(VIEW_NODE, &show_subscr_cache_cmd);
|
install_element(VIEW_NODE, &show_subscr_cache_cmd);
|
||||||
|
|
||||||
install_element(VIEW_NODE, &sms_send_pend_cmd);
|
install_element(VIEW_NODE, &sms_send_pend_cmd);
|
||||||
install_element(VIEW_NODE, &sms_send_ext_cmd);
|
|
||||||
install_element(VIEW_NODE, &sms_send_imsi_cmd);
|
install_element(VIEW_NODE, &subscriber_send_sms_cmd);
|
||||||
install_element(VIEW_NODE, &sms_send_silent_ext_cmd);
|
install_element(VIEW_NODE, &subscriber_silent_sms_cmd);
|
||||||
install_element(VIEW_NODE, &sms_send_silent_imsi_cmd);
|
|
||||||
|
|
||||||
install_element(CONFIG_NODE, &cfg_subscr_cmd);
|
install_element(CONFIG_NODE, &cfg_subscr_cmd);
|
||||||
install_node(&subscr_node, dummy_config_write);
|
install_node(&subscr_node, dummy_config_write);
|
||||||
|
|
Loading…
Reference in a new issue