layer23: Added VTY messages to call application.
VTY now shows the process of call establishment, incomming call, and release.
This commit is contained in:
parent
22f4e35243
commit
f479eff3d5
|
@ -39,6 +39,6 @@ extern int telnet_init(struct osmocom_ms *ms, int port);
|
|||
|
||||
extern int ms_vty_init(struct osmocom_ms *ms);
|
||||
|
||||
extern void vty_notify(struct osmocom_ms *ms, const char *fmt, ...);
|
||||
extern void vty_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
#endif
|
||||
|
|
|
@ -715,6 +715,7 @@ static int gsm322_a_indicate_selected(struct osmocom_ms *ms, struct msgb *msg)
|
|||
{
|
||||
struct gsm322_plmn *plmn = &ms->plmn;
|
||||
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Selected Network: %s, %s\n",
|
||||
gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
|
||||
|
||||
|
@ -1165,6 +1166,7 @@ static int gsm322_m_display_plmns(struct osmocom_ms *ms, struct msgb *msg)
|
|||
/* generate list */
|
||||
gsm322_sort_list(ms);
|
||||
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Select from Network:\n");
|
||||
|
||||
llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
|
||||
|
@ -1195,6 +1197,7 @@ static int gsm322_m_user_resel(struct osmocom_ms *ms, struct msgb *msg)
|
|||
}
|
||||
|
||||
/* initiate search at cell selection */
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Searching Network, please wait...\n");
|
||||
LOGP(DPLMN, LOGL_INFO, "User re-select, start PLMN search first.\n");
|
||||
|
||||
|
@ -1252,6 +1255,7 @@ static int gsm322_m_switch_on(struct osmocom_ms *ms, struct msgb *msg)
|
|||
/* initiate search at cell selection */
|
||||
LOGP(DSUM, LOGL_INFO, "Search for network\n");
|
||||
LOGP(DPLMN, LOGL_INFO, "Switch on, start PLMN search first.\n");
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Searching Network, please wait...\n");
|
||||
|
||||
nmsg = gsm322_msgb_alloc(GSM322_EVENT_PLMN_SEARCH_START);
|
||||
|
@ -1324,6 +1328,7 @@ static int gsm322_m_indicate_selected(struct osmocom_ms *ms, struct msgb *msg)
|
|||
{
|
||||
struct gsm322_plmn *plmn = &ms->plmn;
|
||||
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Selected Network: %s, %s\n",
|
||||
gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
|
||||
|
||||
|
@ -1365,6 +1370,7 @@ static int gsm322_m_choose_plmn(struct osmocom_ms *ms, struct msgb *msg)
|
|||
plmn->mcc = gm->mcc;
|
||||
plmn->mnc = gm->mnc;
|
||||
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Selected Network: %s, %s\n",
|
||||
gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
|
||||
LOGP(DPLMN, LOGL_INFO, "User selects PLMN. (mcc=%03d mnc=%02d "
|
||||
|
|
|
@ -3149,10 +3149,8 @@ static int gsm48_mm_abort_mm_con(struct osmocom_ms *ms, struct msgb *msg)
|
|||
switch(rrh->cause) {
|
||||
case RR_REL_CAUSE_NOT_AUTHORIZED:
|
||||
case RR_REL_CAUSE_EMERGENCY_ONLY:
|
||||
cause = 21;
|
||||
break;
|
||||
case RR_REL_CAUSE_TRY_LATER:
|
||||
cause = 34;
|
||||
cause = 21;
|
||||
break;
|
||||
case RR_REL_CAUSE_NORMAL:
|
||||
cause = 16;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <osmocom/logging.h>
|
||||
#include <osmocom/osmocom_data.h>
|
||||
#include <osmocom/mncc.h>
|
||||
#include <osmocom/telnet_interface.h>
|
||||
|
||||
void *l23_ctx;
|
||||
static int new_callref = 1;
|
||||
|
@ -121,38 +122,115 @@ int mncc_recv_mobile(struct osmocom_ms *ms, int msg_type, void *arg)
|
|||
|
||||
switch (msg_type) {
|
||||
case MNCC_DISC_IND:
|
||||
LOGP(DMNCC, LOGL_INFO, "Call has been disconnected\n");
|
||||
vty_notify(ms, NULL);
|
||||
switch (data->cause.value) {
|
||||
case GSM48_CC_CAUSE_UNASSIGNED_NR:
|
||||
vty_notify(ms, "Call: Number not assigned\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_NO_ROUTE:
|
||||
vty_notify(ms, "Call: Destination unreachable\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_NORM_CALL_CLEAR:
|
||||
vty_notify(ms, "Call: Remote hangs up\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_USER_BUSY:
|
||||
vty_notify(ms, "Call: Remote busy\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_USER_NOTRESPOND:
|
||||
vty_notify(ms, "Call: Remote not responding\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_USER_ALERTING_NA:
|
||||
vty_notify(ms, "Call: Remote not answering\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_CALL_REJECTED:
|
||||
vty_notify(ms, "Call has been rejected\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_NUMBER_CHANGED:
|
||||
vty_notify(ms, "Call: Number changed\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_PRE_EMPTION:
|
||||
vty_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");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_INV_NR_FORMAT:
|
||||
vty_notify(ms, "Call: Number invalid or imcomplete\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_NO_CIRCUIT_CHAN:
|
||||
vty_notify(ms, "Call: No channel available\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_NETWORK_OOO:
|
||||
vty_notify(ms, "Call: Network out of order\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_TEMP_FAILURE:
|
||||
vty_notify(ms, "Call: Temporary failure\n");
|
||||
break;
|
||||
case GSM48_CC_CAUSE_SWITCH_CONG:
|
||||
vty_notify(ms, "Congestion\n");
|
||||
break;
|
||||
default:
|
||||
vty_notify(ms, "Call has been disconnected\n");
|
||||
}
|
||||
LOGP(DMNCC, LOGL_INFO, "Call has been disconnected "
|
||||
"(cause %d)\n", data->cause.value);
|
||||
if ((data->fields & MNCC_F_PROGRESS)
|
||||
&& data->progress.descr == 8)
|
||||
&& data->progress.descr == 8) {
|
||||
vty_notify(ms, "Please hang up!\n");
|
||||
break;
|
||||
}
|
||||
free_call(call);
|
||||
cause = GSM48_CC_CAUSE_NORM_CALL_CLEAR;
|
||||
goto release;
|
||||
case MNCC_REL_IND:
|
||||
case MNCC_REL_CNF:
|
||||
LOGP(DMNCC, LOGL_INFO, "Call has been released\n");
|
||||
vty_notify(ms, NULL);
|
||||
if (data->cause.value == GSM48_CC_CAUSE_CALL_REJECTED)
|
||||
vty_notify(ms, "Call has been rejected\n");
|
||||
else
|
||||
vty_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");
|
||||
LOGP(DMNCC, LOGL_INFO, "Call is proceeding\n");
|
||||
break;
|
||||
case MNCC_ALERT_IND:
|
||||
vty_notify(ms, NULL);
|
||||
vty_notify(ms, "Call is aleriting\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");
|
||||
LOGP(DMNCC, LOGL_INFO, "Call is answered\n");
|
||||
break;
|
||||
case MNCC_SETUP_IND:
|
||||
vty_notify(ms, NULL);
|
||||
if (!llist_empty(&call_list)) {
|
||||
vty_notify(ms, "Incomming call rejected\n");
|
||||
LOGP(DMNCC, LOGL_INFO, "Incomming call but busy\n");
|
||||
cause = GSM48_CC_CAUSE_NORM_CALL_CLEAR;
|
||||
goto release;
|
||||
}
|
||||
if (!data->calling.present || !data->calling.number[0])
|
||||
vty_notify(ms, "Incomming call\n");
|
||||
else if (data->calling.type == 1)
|
||||
vty_notify(ms, "Incomming call from +%s\n",
|
||||
data->calling.number);
|
||||
else if (data->calling.type == 2)
|
||||
vty_notify(ms, "Incomming call from 0-%s\n",
|
||||
data->calling.number);
|
||||
else
|
||||
vty_notify(ms, "Incomming call from %s\n",
|
||||
data->calling.number);
|
||||
LOGP(DMNCC, LOGL_INFO, "Incomming call\n");
|
||||
memset(&mncc, 0, sizeof(struct gsm_mncc));
|
||||
mncc.callref = call->callref;
|
||||
mncc_send(ms, MNCC_CALL_CONF_REQ, &mncc);
|
||||
break;
|
||||
LOGP(DMNCC, LOGL_INFO, "Ring!\n");
|
||||
memset(&mncc, 0, sizeof(struct gsm_mncc));
|
||||
mncc.callref = call->callref;
|
||||
|
|
|
@ -208,26 +208,33 @@ void vty_notify(struct osmocom_ms *ms, const char *fmt, ...)
|
|||
struct telnet_connection *connection;
|
||||
char buffer[1000];
|
||||
va_list args;
|
||||
struct vty *vty;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
va_end(args);
|
||||
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;
|
||||
if (!buffer[0])
|
||||
return;
|
||||
}
|
||||
|
||||
llist_for_each_entry(connection, &active_connections, entry) {
|
||||
struct vty *vty = connection->vty;
|
||||
if (vty) {
|
||||
if (buffer[strlen(buffer) - 1] == '\n') {
|
||||
buffer[strlen(buffer) - 1] = '\0';
|
||||
vty_out(vty, "%% (MS %s) %s%s", ms->name,
|
||||
buffer, VTY_NEWLINE);
|
||||
buffer[strlen(buffer)] = '\n';
|
||||
} else
|
||||
vty_out(vty, "%% (MS %s) %s", ms->name, buffer);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue