pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmocom-bb/+/32416 )
Change subject: layer23: Move vty_notify() to common/
......................................................................
layer23: Move vty_notify() to common/
Change-Id: Ic0a98e66adffa9fefeee6e69a4b5c691e0e9c789
---
M src/host/layer23/include/osmocom/bb/common/vty.h
M src/host/layer23/include/osmocom/bb/mobile/vty.h
M src/host/layer23/src/common/subscriber.c
M src/host/layer23/src/common/vty.c
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/gsm322.c
M src/host/layer23/src/mobile/gsm411_sms.c
M src/host/layer23/src/mobile/gsm480_ss.c
M src/host/layer23/src/mobile/gsm48_mm.c
M src/host/layer23/src/mobile/gsm48_rr.c
M src/host/layer23/src/mobile/mnccms.c
M src/host/layer23/src/mobile/vty_interface.c
12 files changed, 183 insertions(+), 174 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/src/host/layer23/include/osmocom/bb/common/vty.h
b/src/host/layer23/include/osmocom/bb/common/vty.h
index 4ff96fe..517db95 100644
--- a/src/host/layer23/include/osmocom/bb/common/vty.h
+++ b/src/host/layer23/include/osmocom/bb/common/vty.h
@@ -22,6 +22,8 @@
void l23_vty_config_write_ms_node_contents(struct vty *vty, const struct osmocom_ms *ms,
const char *prefix);
void l23_vty_config_write_ms_node_contents_final(struct vty *vty, const struct osmocom_ms
*ms, const char *prefix);
+extern void l23_vty_ms_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__
((format (printf, 2, 3)));
+
extern bool l23_vty_reading;
extern struct llist_head ms_list;
diff --git a/src/host/layer23/include/osmocom/bb/mobile/vty.h
b/src/host/layer23/include/osmocom/bb/mobile/vty.h
index 6bd1b37..8ca51d4 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/vty.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/vty.h
@@ -15,7 +15,5 @@
};
int ms_vty_init(void);
-extern void vty_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__
((format (printf, 2, 3)));
-
#endif
diff --git a/src/host/layer23/src/common/subscriber.c
b/src/host/layer23/src/common/subscriber.c
index 89cacb7..05771ff 100644
--- a/src/host/layer23/src/common/subscriber.c
+++ b/src/host/layer23/src/common/subscriber.c
@@ -29,7 +29,7 @@
#include <osmocom/bb/common/sap_proto.h>
#include <osmocom/bb/common/networks.h>
#include <osmocom/bb/common/subscriber.h>
-#include <osmocom/bb/mobile/vty.h>
+#include <osmocom/bb/common/vty.h>
/* enable to get an empty list of forbidden PLMNs, even if stored on SIM.
* if list is changed, the result is not written back to SIM */
@@ -621,18 +621,18 @@
LOGP(DMM, LOGL_INFO, "PIN is required, %d tries left\n",
payload[1]);
- vty_notify(ms, NULL);
- vty_notify(ms, "Please give PIN for ICCID %s (you have "
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Please give PIN for ICCID %s (you have "
"%d tries left)\n", subscr->iccid, payload[1]);
subscr->sim_pin_required = 1;
break;
case SIM_CAUSE_PIN1_BLOCKED:
LOGP(DMM, LOGL_NOTICE, "PIN is blocked\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "PIN is blocked\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "PIN is blocked\n");
if (payload[1]) {
- vty_notify(ms, "Please give PUC for ICCID %s "
+ l23_vty_ms_notify(ms, "Please give PUC for ICCID %s "
"(you have %d tries left)\n",
subscr->iccid, payload[1]);
}
@@ -641,8 +641,8 @@
case SIM_CAUSE_PUC_BLOCKED:
LOGP(DMM, LOGL_NOTICE, "PUC is blocked\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "PUC is blocked\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "PUC is blocked\n");
subscr->sim_pin_required = 1;
break;
default:
@@ -653,8 +653,8 @@
}
LOGP(DMM, LOGL_NOTICE, "SIM reading failed\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "SIM failed, replace SIM!\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "SIM failed, replace SIM!\n");
/* detach simcard */
subscr->sim_valid = 0;
@@ -684,8 +684,8 @@
if (rc) {
LOGP(DMM, LOGL_NOTICE, "SIM reading failed, file invalid\n");
if (subscr_sim_files[subscr->sim_file_index].mandatory) {
- vty_notify(ms, NULL);
- vty_notify(ms, "SIM failed, data invalid, replace "
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "SIM failed, data invalid, replace "
"SIM!\n");
msgb_free(msg);
@@ -1279,12 +1279,12 @@
subscr->sim_valid = 1;
/* Try to connect to the SAP interface */
- vty_notify(ms, NULL);
- vty_notify(ms, "Connecting to the SAP interface...\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Connecting to the SAP interface...\n");
rc = sap_open(ms);
if (rc < 0) {
LOGP(DSAP, LOGL_ERROR, "Failed during sap_open(), no SAP based SIM
reader\n");
- vty_notify(ms, "SAP connection error!\n");
+ l23_vty_ms_notify(ms, "SAP connection error!\n");
ms->sap_wq.bfd.fd = -1;
/* Detach SIM */
diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c
index 5985fb1..f28b6eb 100644
--- a/src/host/layer23/src/common/vty.c
+++ b/src/host/layer23/src/common/vty.c
@@ -48,6 +48,8 @@
#include <osmocom/bb/mobile/gsm480_ss.h>
#include <osmocom/bb/mobile/gsm411_sms.h>
+extern struct llist_head active_connections; /* libosmocore */
+
bool l23_vty_reading = false;
static struct cmd_node ms_node = {
@@ -91,6 +93,41 @@
return NULL;
}
+void l23_vty_ms_notify(struct osmocom_ms *ms, const char *fmt, ...)
+{
+ struct telnet_connection *connection;
+ char buffer[1000];
+ va_list args;
+ struct vty *vty;
+
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
+ buffer[sizeof(buffer) - 1] = '\0';
+ va_end(args);
+
+ if (!buffer[0])
+ return;
+ }
+
+ llist_for_each_entry(connection, &active_connections, entry) {
+ vty = connection->vty;
+ if (!vty)
+ continue;
+ if (!fmt) {
+ vty_out(vty, "%s%% (MS %s)%s", VTY_NEWLINE, ms->name,
+ VTY_NEWLINE);
+ continue;
+ }
+ if (buffer[strlen(buffer) - 1] == '\n') {
+ buffer[strlen(buffer) - 1] = '\0';
+ vty_out(vty, "%% %s%s", buffer, VTY_NEWLINE);
+ buffer[strlen(buffer)] = '\n';
+ } else
+ vty_out(vty, "%% %s", buffer);
+ }
+}
+
/* placeholder for layer23 shared MS info to be dumped */
void l23_ms_dump(struct osmocom_ms *ms, struct vty *vty)
{
diff --git a/src/host/layer23/src/mobile/app_mobile.c
b/src/host/layer23/src/mobile/app_mobile.c
index a0d2546..8befc80 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -191,8 +191,8 @@
} else {
mobile_set_shutdown(ms, MS_SHUTDOWN_COMPL); /* being down */
}
- vty_notify(ms, NULL);
- vty_notify(ms, "Power off!\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Power off!\n");
LOGP(DMOB, LOGL_NOTICE, "Power off! (MS %s)\n", ms->name);
return 0;
diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c
index 80cb342..d7b4154 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -1515,24 +1515,24 @@
/* generate list */
gsm322_sort_list(ms);
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
switch (msg_type) {
case GSM322_EVENT_REG_FAILED:
- vty_notify(ms, "Failed to register to network %s, %s "
+ l23_vty_ms_notify(ms, "Failed to register to network %s, %s "
"(%s, %s)\n",
gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
gsm_get_mcc(plmn->mcc),
gsm_get_mnc(plmn->mcc, plmn->mnc));
break;
case GSM322_EVENT_NO_CELL_FOUND:
- vty_notify(ms, "No cell found for network %s, %s "
+ l23_vty_ms_notify(ms, "No cell found for network %s, %s "
"(%s, %s)\n",
gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
gsm_get_mcc(plmn->mcc),
gsm_get_mnc(plmn->mcc, plmn->mnc));
break;
case GSM322_EVENT_ROAMING_NA:
- vty_notify(ms, "Roaming not allowed to network %s, %s "
+ l23_vty_ms_notify(ms, "Roaming not allowed to network %s, %s "
"(%s, %s)\n",
gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
gsm_get_mcc(plmn->mcc),
@@ -1541,11 +1541,11 @@
}
if (llist_empty(&plmn->sorted_plmn))
- vty_notify(ms, "Search network!\n");
+ l23_vty_ms_notify(ms, "Search network!\n");
else {
- vty_notify(ms, "Search or select from network:\n");
+ l23_vty_ms_notify(ms, "Search or select from network:\n");
llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
- vty_notify(ms, " Network %s, %s (%s, %s)\n",
+ l23_vty_ms_notify(ms, " Network %s, %s (%s, %s)\n",
gsm_print_mcc(temp->mcc),
gsm_print_mnc(temp->mnc),
gsm_get_mcc(temp->mcc),
@@ -2442,7 +2442,7 @@
cs->sel_lac = cs->si->lac;
cs->sel_id = cs->si->cell_id;
if (ms->rrlayer.monitor) {
- vty_notify(ms, "MON: %scell selected ARFCN=%s MCC=%s MNC=%s "
+ l23_vty_ms_notify(ms, "MON: %scell selected ARFCN=%s MCC=%s MNC=%s "
"LAC=0x%04x cellid=0x%04x (%s %s)\n",
(any) ? "any " : "", gsm_print_arfcn(cs->sel_arfcn),
gsm_print_mcc(cs->sel_mcc), gsm_print_mnc(cs->sel_mnc),
@@ -2627,7 +2627,7 @@
&& cs->list[cs->arfci].sysinfo->sp_cbq)) {
LOGP(DCS, LOGL_INFO, "Cell becomes barred.\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell re-selection"
+ l23_vty_ms_notify(ms, "MON: trigger cell re-selection"
": cell becomes barred\n");
trigger_resel:
/* mark cell as unscanned */
@@ -2657,7 +2657,7 @@
& (s->class_barr ^ 0xffff))) {
LOGP(DCS, LOGL_INFO, "Cell access becomes barred.\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell re-selection"
+ l23_vty_ms_notify(ms, "MON: trigger cell re-selection"
": access to cell becomes barred\n");
goto trigger_resel;
}
@@ -2669,7 +2669,7 @@
LOGP(DCS, LOGL_NOTICE, "Cell changes location area. "
"This is not good!\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell re-selection: "
+ l23_vty_ms_notify(ms, "MON: trigger cell re-selection: "
"cell changes LAI\n");
goto trigger_resel;
}
@@ -2677,7 +2677,7 @@
LOGP(DCS, LOGL_NOTICE, "Cell changes cell ID. "
"This is not good!\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell re-selection: "
+ l23_vty_ms_notify(ms, "MON: trigger cell re-selection: "
"cell changes cell ID\n");
goto trigger_resel;
}
@@ -3095,7 +3095,7 @@
LOGP(DCS, LOGL_INFO, "Loss of CCCH, Trigger "
"re-selection.\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell "
+ l23_vty_ms_notify(ms, "MON: trigger cell "
"re-selection: loss of signal\n");
nmsg = gsm322_msgb_alloc(GSM322_EVENT_CELL_RESEL);
@@ -4155,12 +4155,12 @@
}
if (ms->rrlayer.monitor) {
- vty_notify(ms, "MON: cell ARFCN LAC C1 C2 CRH RLA_C "
+ l23_vty_ms_notify(ms, "MON: cell ARFCN LAC C1 C2 CRH RLA_C "
"bargraph\n");
snprintf(arfcn_text, 10, "%s ",
gsm_print_arfcn(cs->sel_arfcn));
arfcn_text[9] = '\0';
- vty_notify(ms, "MON: serving %s 0x%04x %3d %3d %4d "
+ l23_vty_ms_notify(ms, "MON: serving %s 0x%04x %3d %3d %4d "
"%s\n", arfcn_text, cs->sel_lac, cs->c1, cs->c2,
cs->rla_c_dbm, bargraph(cs->rla_c_dbm / 2, -55, -24));
}
@@ -4182,7 +4182,7 @@
snprintf(arfcn_text, 10, "%s ",
gsm_print_arfcn(nb->arfcn));
arfcn_text[9] = '\0';
- vty_notify(ms, "MON: nb %2d %s ARFCN not "
+ l23_vty_ms_notify(ms, "MON: nb %2d %s ARFCN not "
"supported\n", i + 1, arfcn_text);
}
goto cont;
@@ -4195,7 +4195,7 @@
snprintf(arfcn_text, 10, "%s ",
gsm_print_arfcn(nb->arfcn));
arfcn_text[9] = '\0';
- vty_notify(ms, "MON: nb %2d %s "
+ l23_vty_ms_notify(ms, "MON: nb %2d %s "
" %4d %s\n",
i + 1, arfcn_text, nb->rla_c_dbm,
bargraph(nb->rla_c_dbm / 2, -55, -24));
@@ -4244,7 +4244,7 @@
snprintf(arfcn_text, 10, "%s ",
gsm_print_arfcn(nb->arfcn));
arfcn_text[9] = '\0';
- vty_notify(ms, "MON: nb %2d %s 0x%04x %3d %3d %2d"
+ l23_vty_ms_notify(ms, "MON: nb %2d %s 0x%04x %3d %3d %2d"
" %4d %s\n", i + 1, arfcn_text, s->lac,
nb->c1, nb->c2, nb->crh, nb->rla_c_dbm,
bargraph(nb->rla_c_dbm / 2, -55, -24));
@@ -4320,7 +4320,7 @@
if (!i) {
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: no neighbour cells\n");
+ l23_vty_ms_notify(ms, "MON: no neighbour cells\n");
}
if (cs->resel_when + GSM58_RESEL_THRESHOLD >= now) {
@@ -4629,7 +4629,7 @@
"reselection.\n");
if (ms->rrlayer.monitor)
- vty_notify(ms, "MON: trigger cell re-selection: "
+ l23_vty_ms_notify(ms, "MON: trigger cell re-selection: "
"better cell\n");
cs->resel_when = now;
diff --git a/src/host/layer23/src/mobile/gsm411_sms.c
b/src/host/layer23/src/mobile/gsm411_sms.c
index d00e94d..64d098c 100644
--- a/src/host/layer23/src/mobile/gsm411_sms.c
+++ b/src/host/layer23/src/mobile/gsm411_sms.c
@@ -120,11 +120,11 @@
static int gsm411_sms_report(struct osmocom_ms *ms, struct gsm_sms *sms,
uint8_t cause)
{
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
if (!cause)
- vty_notify(ms, "SMS to %s successful\n", sms->address);
+ l23_vty_ms_notify(ms, "SMS to %s successful\n", sms->address);
else
- vty_notify(ms, "SMS to %s failed: %s\n", sms->address,
+ l23_vty_ms_notify(ms, "SMS to %s failed: %s\n", sms->address,
get_value_string(gsm411_rp_cause_strs, cause));
mobile_prim_ntfy_sms_status(ms, sms, cause);
@@ -190,8 +190,8 @@
if (*p == '\n' || *p == '\r')
*p = ' ';
}
- vty_notify(ms, NULL);
- vty_notify(ms, "SMS from %s: '%s'\n", gsms->address, vty_text);
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "SMS from %s: '%s'\n", gsms->address,
vty_text);
home = getenv("HOME");
if (!home) {
diff --git a/src/host/layer23/src/mobile/gsm480_ss.c
b/src/host/layer23/src/mobile/gsm480_ss.c
index 139b45b..202e1e7 100644
--- a/src/host/layer23/src/mobile/gsm480_ss.c
+++ b/src/host/layer23/src/mobile/gsm480_ss.c
@@ -193,7 +193,7 @@
static int gsm480_ss_result(struct osmocom_ms *ms, const char *response,
uint8_t error)
{
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
if (response) {
char text[256], *t = text, *s;
@@ -201,13 +201,13 @@
while ((s = strchr(text, '\r')))
*s = '\n';
while ((s = strsep(&t, "\n"))) {
- vty_notify(ms, "Service response: %s\n", s);
+ l23_vty_ms_notify(ms, "Service response: %s\n", s);
}
} else if (error)
- vty_notify(ms, "Service request failed: %s\n",
+ l23_vty_ms_notify(ms, "Service request failed: %s\n",
get_value_string(gsm480_err_names, error));
else
- vty_notify(ms, "Service request failed.\n");
+ l23_vty_ms_notify(ms, "Service request failed.\n");
return 0;
}
@@ -260,8 +260,8 @@
msgb_free(trans->ss.msg);
trans->ss.msg = NULL;
}
- vty_notify(trans->ms, NULL);
- vty_notify(trans->ms, "Service connection terminated.\n");
+ l23_vty_ms_notify(trans->ms, NULL);
+ l23_vty_ms_notify(trans->ms, "Service connection terminated.\n");
}
/* release MM connection, free transaction */
@@ -786,7 +786,7 @@
LOGP(DSS, LOGL_INFO, "call forwarding reply: len %d data %s\n", len,
osmo_hexdump(data, len));
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
/* forwarding feature list */
if (parse_tag_asn1(data, len, &tag_data, &tag_len) < 0) {
@@ -795,9 +795,9 @@
}
if (data[0] == 0x80) {
if ((tag_data[0] & 0x01))
- vty_notify(ms, "Status: activated\n");
+ l23_vty_ms_notify(ms, "Status: activated\n");
else
- vty_notify(ms, "Status: deactivated\n");
+ l23_vty_ms_notify(ms, "Status: deactivated\n");
return 0;
}
@@ -816,7 +816,7 @@
/* check for SS code */
if (data[0] != 0x04)
break;
- vty_notify(ms, "Reply for %s\n", decode_ss_code(tag_data[0]));
+ l23_vty_ms_notify(ms, "Reply for %s\n", decode_ss_code(tag_data[0]));
len -= tag_data - data + tag_len;
data = tag_data + tag_len;
/* sequence tag */
@@ -832,7 +832,7 @@
data = tag_data;
break;
default:
- vty_notify(ms, "Call Forwarding reply unsupported.\n");
+ l23_vty_ms_notify(ms, "Call Forwarding reply unsupported.\n");
return 0;
}
@@ -864,20 +864,20 @@
osmo_hexdump(tag_data, tag_len));
switch (data2[0]) {
case 0x82:
- vty_notify(ms, "Bearer Service: %s\n",
+ l23_vty_ms_notify(ms, "Bearer Service: %s\n",
get_value_string(Bearerservice_vals,
tag_data[0]));
break;
case 0x83:
- vty_notify(ms, "Teleservice: %s\n",
+ l23_vty_ms_notify(ms, "Teleservice: %s\n",
get_value_string(Teleservice_vals,
tag_data[0]));
break;
case 0x84:
if ((tag_data[0] & 0x01))
- vty_notify(ms, "Status: activated\n");
+ l23_vty_ms_notify(ms, "Status: activated\n");
else
- vty_notify(ms, "Status: deactivated\n");
+ l23_vty_ms_notify(ms, "Status: deactivated\n");
break;
case 0x85:
if (((tag_data[0] & 0x70) >> 4) == 1)
@@ -889,7 +889,7 @@
gsm48_decode_bcd_number2(number + strlen(number),
sizeof(number) - strlen(number),
tag_data - 1, tag_len + 1, 1);
- vty_notify(ms, "Destination: %s\n", number);
+ l23_vty_ms_notify(ms, "Destination: %s\n", number);
break;
}
len2 -= tag_data - data2 + tag_len;
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c
b/src/host/layer23/src/mobile/gsm48_mm.c
index 265b720..6c5a860 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -926,33 +926,33 @@
&& (mm->state != GSM48_MM_ST_MM_IDLE || mm->substate != substate)) {
switch (substate) {
case GSM48_MM_SST_NORMAL_SERVICE:
- vty_notify(ms, NULL);
- vty_notify(ms, "On Network, normal service: %s, %s\n",
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "On Network, normal service: %s, %s\n",
gsm_get_mcc(plmn->mcc),
gsm_get_mnc(plmn->mcc, plmn->mnc));
break;
case GSM48_MM_SST_LIMITED_SERVICE:
- vty_notify(ms, NULL);
- vty_notify(ms, "Limited service, emergency calls are "
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Limited service, emergency calls are "
"possible.\n");
break;
case GSM48_MM_SST_PLMN_SEARCH_NORMAL:
case GSM48_MM_SST_PLMN_SEARCH:
- vty_notify(ms, NULL);
- vty_notify(ms, "Searching network...\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Searching network...\n");
break;
case GSM48_MM_SST_NO_IMSI:
- vty_notify(ms, NULL);
- vty_notify(ms, "No SIM, emergency calls are "
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No SIM, emergency calls are "
"possible.\n");
break;
case GSM48_MM_SST_NO_CELL_AVAIL:
- vty_notify(ms, NULL);
- vty_notify(ms, "No service.\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No service.\n");
break;
case GSM48_MM_SST_ATTEMPT_UPDATE:
- vty_notify(ms, NULL);
- vty_notify(ms, "Trying to register with network %s, %s...\n",
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Trying to register with network %s, %s...\n",
gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
break;
}
diff --git a/src/host/layer23/src/mobile/gsm48_rr.c
b/src/host/layer23/src/mobile/gsm48_rr.c
index 7cf222f..231bea0 100644
--- a/src/host/layer23/src/mobile/gsm48_rr.c
+++ b/src/host/layer23/src/mobile/gsm48_rr.c
@@ -679,7 +679,7 @@
}
LOGP(DRR, LOGL_INFO, "%s\n", text);
if (rr->monitor)
- vty_notify(rr->ms, "%s\n", text);
+ l23_vty_ms_notify(rr->ms, "%s\n", text);
if (rr->dm_est)
gsm48_rr_tx_meas_rep(rr->ms);
diff --git a/src/host/layer23/src/mobile/mnccms.c b/src/host/layer23/src/mobile/mnccms.c
index bfc95e4..60d2e55 100644
--- a/src/host/layer23/src/mobile/mnccms.c
+++ b/src/host/layer23/src/mobile/mnccms.c
@@ -296,62 +296,62 @@
switch (msg_type) {
case MNCC_DISC_IND:
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
switch (data->cause.value) {
case GSM48_CC_CAUSE_UNASSIGNED_NR:
- vty_notify(ms, "Call: Number not assigned\n");
+ l23_vty_ms_notify(ms, "Call: Number not assigned\n");
break;
case GSM48_CC_CAUSE_NO_ROUTE:
- vty_notify(ms, "Call: Destination unreachable\n");
+ l23_vty_ms_notify(ms, "Call: Destination unreachable\n");
break;
case GSM48_CC_CAUSE_NORM_CALL_CLEAR:
- vty_notify(ms, "Call: Remote hangs up\n");
+ l23_vty_ms_notify(ms, "Call: Remote hangs up\n");
break;
case GSM48_CC_CAUSE_USER_BUSY:
- vty_notify(ms, "Call: Remote busy\n");
+ l23_vty_ms_notify(ms, "Call: Remote busy\n");
break;
case GSM48_CC_CAUSE_USER_NOTRESPOND:
- vty_notify(ms, "Call: Remote not responding\n");
+ l23_vty_ms_notify(ms, "Call: Remote not responding\n");
break;
case GSM48_CC_CAUSE_USER_ALERTING_NA:
- vty_notify(ms, "Call: Remote not answering\n");
+ l23_vty_ms_notify(ms, "Call: Remote not answering\n");
break;
case GSM48_CC_CAUSE_CALL_REJECTED:
- vty_notify(ms, "Call has been rejected\n");
+ l23_vty_ms_notify(ms, "Call has been rejected\n");
break;
case GSM48_CC_CAUSE_NUMBER_CHANGED:
- vty_notify(ms, "Call: Number changed\n");
+ l23_vty_ms_notify(ms, "Call: Number changed\n");
break;
case GSM48_CC_CAUSE_PRE_EMPTION:
- vty_notify(ms, "Call: Cleared due to pre-emption\n");
+ l23_vty_ms_notify(ms, "Call: Cleared due to pre-emption\n");
break;
case GSM48_CC_CAUSE_DEST_OOO:
- vty_notify(ms, "Call: Remote out of order\n");
+ l23_vty_ms_notify(ms, "Call: Remote out of order\n");
break;
case GSM48_CC_CAUSE_INV_NR_FORMAT:
- vty_notify(ms, "Call: Number invalid or incomplete\n");
+ l23_vty_ms_notify(ms, "Call: Number invalid or incomplete\n");
break;
case GSM48_CC_CAUSE_NO_CIRCUIT_CHAN:
- vty_notify(ms, "Call: No channel available\n");
+ l23_vty_ms_notify(ms, "Call: No channel available\n");
break;
case GSM48_CC_CAUSE_NETWORK_OOO:
- vty_notify(ms, "Call: Network out of order\n");
+ l23_vty_ms_notify(ms, "Call: Network out of order\n");
break;
case GSM48_CC_CAUSE_TEMP_FAILURE:
- vty_notify(ms, "Call: Temporary failure\n");
+ l23_vty_ms_notify(ms, "Call: Temporary failure\n");
break;
case GSM48_CC_CAUSE_SWITCH_CONG:
- vty_notify(ms, "Congestion\n");
+ l23_vty_ms_notify(ms, "Congestion\n");
break;
default:
- vty_notify(ms, "Call has been disconnected "
+ l23_vty_ms_notify(ms, "Call has been disconnected "
"(clear cause %d)\n", data->cause.value);
}
LOGP(DMNCC, LOGL_INFO, "Call has been disconnected "
"(cause %d)\n", data->cause.value);
if ((data->fields & MNCC_F_PROGRESS)
&& data->progress.descr == 8) {
- vty_notify(ms, "Please hang up!\n");
+ l23_vty_ms_notify(ms, "Please hang up!\n");
break;
}
free_call(call);
@@ -359,18 +359,18 @@
goto release;
case MNCC_REL_IND:
case MNCC_REL_CNF:
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
if (data->cause.value == GSM48_CC_CAUSE_CALL_REJECTED)
- vty_notify(ms, "Call has been rejected\n");
+ l23_vty_ms_notify(ms, "Call has been rejected\n");
else
- vty_notify(ms, "Call has been released\n");
+ l23_vty_ms_notify(ms, "Call has been released\n");
LOGP(DMNCC, LOGL_INFO, "Call has been released (cause %d)\n",
data->cause.value);
free_call(call);
break;
case MNCC_CALL_PROC_IND:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is proceeding\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is proceeding\n");
LOGP(DMNCC, LOGL_INFO, "Call is proceeding\n");
if ((data->fields & MNCC_F_BEARER_CAP)
&& data->bearer_cap.speech_ver[0] >= 0) {
@@ -378,19 +378,19 @@
}
break;
case MNCC_ALERT_IND:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is alerting\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is alerting\n");
LOGP(DMNCC, LOGL_INFO, "Call is alerting\n");
break;
case MNCC_SETUP_CNF:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is answered\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is answered\n");
LOGP(DMNCC, LOGL_INFO, "Call is answered\n");
break;
case MNCC_SETUP_IND:
- vty_notify(ms, NULL);
+ l23_vty_ms_notify(ms, NULL);
if (!first_call && !ms->settings.cw) {
- vty_notify(ms, "Incoming call rejected while busy\n");
+ l23_vty_ms_notify(ms, "Incoming call rejected while busy\n");
LOGP(DMNCC, LOGL_INFO, "Incoming call but busy\n");
cause = GSM48_CC_CAUSE_USER_BUSY;
goto release;
@@ -442,15 +442,15 @@
}
/* presentation allowed if present == 0 */
if (data->calling.present || !data->calling.number[0])
- vty_notify(ms, "Incoming call (anonymous)\n");
+ l23_vty_ms_notify(ms, "Incoming call (anonymous)\n");
else if (data->calling.type == 1)
- vty_notify(ms, "Incoming call (from +%s)\n",
+ l23_vty_ms_notify(ms, "Incoming call (from +%s)\n",
data->calling.number);
else if (data->calling.type == 2)
- vty_notify(ms, "Incoming call (from 0-%s)\n",
+ l23_vty_ms_notify(ms, "Incoming call (from 0-%s)\n",
data->calling.number);
else
- vty_notify(ms, "Incoming call (from %s)\n",
+ l23_vty_ms_notify(ms, "Incoming call (from %s)\n",
data->calling.number);
LOGP(DMNCC, LOGL_INFO, "Incoming call (from %s callref %x)\n",
data->calling.number, call->callref);
@@ -488,30 +488,30 @@
}
break;
case MNCC_SETUP_COMPL_IND:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is connected\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is connected\n");
LOGP(DMNCC, LOGL_INFO, "Call is connected\n");
break;
case MNCC_HOLD_CNF:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is on hold\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is on hold\n");
LOGP(DMNCC, LOGL_INFO, "Call is on hold\n");
call->hold = true;
break;
case MNCC_HOLD_REJ:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call hold was rejected\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call hold was rejected\n");
LOGP(DMNCC, LOGL_INFO, "Call hold was rejected\n");
break;
case MNCC_RETRIEVE_CNF:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call is retrieved\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call is retrieved\n");
LOGP(DMNCC, LOGL_INFO, "Call is retrieved\n");
call->hold = false;
break;
case MNCC_RETRIEVE_REJ:
- vty_notify(ms, NULL);
- vty_notify(ms, "Call retrieve was rejected\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Call retrieve was rejected\n");
LOGP(DMNCC, LOGL_INFO, "Call retrieve was rejected\n");
break;
case MNCC_FACILITY_IND:
@@ -539,8 +539,8 @@
llist_for_each_entry(call, &call_list, entry) {
if (!call->hold) {
- vty_notify(ms, NULL);
- vty_notify(ms, "Please put active call on hold "
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Please put active call on hold "
"first!\n");
LOGP(DMNCC, LOGL_INFO, "Cannot make a call, busy!\n");
return -EBUSY;
@@ -607,8 +607,8 @@
}
if (!found) {
LOGP(DMNCC, LOGL_INFO, "No active call to hangup\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "No active call\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No active call\n");
return -EINVAL;
}
@@ -634,14 +634,14 @@
}
if (!alerting) {
LOGP(DMNCC, LOGL_INFO, "No call alerting\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "No alerting call\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No alerting call\n");
return -EBUSY;
}
if (active) {
LOGP(DMNCC, LOGL_INFO, "Answer but we have an active call\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "Please put active call on hold first!\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Please put active call on hold first!\n");
return -EBUSY;
}
alerting->ring = false;
@@ -665,8 +665,8 @@
}
if (!found) {
LOGP(DMNCC, LOGL_INFO, "No active call to hold\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "No active call\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No active call\n");
return -EINVAL;
}
@@ -689,26 +689,26 @@
}
if (active) {
LOGP(DMNCC, LOGL_INFO, "Cannot retrieve during active call\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "Hold active call first!\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Hold active call first!\n");
return -EINVAL;
}
if (holdnum == 0) {
- vty_notify(ms, NULL);
- vty_notify(ms, "No call on hold!\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No call on hold!\n");
return -EINVAL;
}
if (holdnum > 1 && number <= 0) {
- vty_notify(ms, NULL);
- vty_notify(ms, "Select call 1..%d\n", holdnum);
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Select call 1..%d\n", holdnum);
return -EINVAL;
}
if (holdnum == 1 && number <= 0)
number = 1;
if (number > holdnum) {
- vty_notify(ms, NULL);
- vty_notify(ms, "Given number %d out of range!\n", number);
- vty_notify(ms, "Select call 1..%d\n", holdnum);
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "Given number %d out of range!\n", number);
+ l23_vty_ms_notify(ms, "Select call 1..%d\n", holdnum);
return -EINVAL;
}
@@ -793,8 +793,8 @@
}
if (!found) {
LOGP(DMNCC, LOGL_INFO, "No active call to send DTMF\n");
- vty_notify(ms, NULL);
- vty_notify(ms, "No active call\n");
+ l23_vty_ms_notify(ms, NULL);
+ l23_vty_ms_notify(ms, "No active call\n");
return -EINVAL;
}
diff --git a/src/host/layer23/src/mobile/vty_interface.c
b/src/host/layer23/src/mobile/vty_interface.c
index 05690ab..f4dc8a9 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -41,8 +41,6 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
-extern struct llist_head active_connections;
-
struct cmd_node testsim_node = {
TESTSIM_NODE,
"%s(test-sim)# ",
@@ -3147,38 +3145,3 @@
return 0;
}
-void vty_notify(struct osmocom_ms *ms, const char *fmt, ...)
-{
- struct telnet_connection *connection;
- char buffer[1000];
- va_list args;
- struct vty *vty;
-
- if (fmt) {
- va_start(args, fmt);
- vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
- buffer[sizeof(buffer) - 1] = '\0';
- va_end(args);
-
- if (!buffer[0])
- return;
- }
-
- llist_for_each_entry(connection, &active_connections, entry) {
- vty = connection->vty;
- if (!vty)
- continue;
- if (!fmt) {
- vty_out(vty, "%s%% (MS %s)%s", VTY_NEWLINE, ms->name,
- VTY_NEWLINE);
- continue;
- }
- if (buffer[strlen(buffer) - 1] == '\n') {
- buffer[strlen(buffer) - 1] = '\0';
- vty_out(vty, "%% %s%s", buffer, VTY_NEWLINE);
- buffer[strlen(buffer)] = '\n';
- } else
- vty_out(vty, "%% %s", buffer);
- }
-}
-
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/32416
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ic0a98e66adffa9fefeee6e69a4b5c691e0e9c789
Gerrit-Change-Number: 32416
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged