2 * (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
28 #include <osmocore/utils.h>
29 #include <osmocore/gsm48.h>
30 #include <osmocore/talloc.h>
31 #include <osmocore/signal.h>
33 #include <osmocom/bb/common/osmocom_data.h>
34 #include <osmocom/bb/common/networks.h>
35 #include <osmocom/bb/common/gps.h>
36 #include <osmocom/bb/mobile/mncc.h>
37 #include <osmocom/bb/mobile/transaction.h>
38 #include <osmocom/bb/mobile/vty.h>
39 #include <osmocom/vty/telnet_interface.h>
42 extern int l23_app_init(struct osmocom_ms *ms);
43 extern int (*l23_app_exit) (struct osmocom_ms *ms, int force);
44 extern struct osmocom_ms *mobile_new(char *name);
45 extern int mobile_delete(struct osmocom_ms *ms, int force);
47 int mncc_call(struct osmocom_ms *ms, char *number);
48 int mncc_hangup(struct osmocom_ms *ms);
49 int mncc_answer(struct osmocom_ms *ms);
50 int mncc_hold(struct osmocom_ms *ms);
51 int mncc_retrieve(struct osmocom_ms *ms, int number);
52 int mncc_dtmf(struct osmocom_ms *ms, char *dtmf);
54 extern struct llist_head ms_list;
55 extern struct llist_head active_connections;
57 struct cmd_node ms_node = {
63 struct cmd_node testsim_node = {
69 struct cmd_node support_node = {
75 static void print_vty(void *priv, const char *fmt, ...)
78 struct vty *vty = priv;
82 vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
83 buffer[sizeof(buffer) - 1] = '\0';
87 if (buffer[strlen(buffer) - 1] == '\n') {
88 buffer[strlen(buffer) - 1] = '\0';
89 vty_out(vty, "%s%s", buffer, VTY_NEWLINE);
91 vty_out(vty, "%s", buffer);
95 int vty_check_number(struct vty *vty, const char *number)
99 for (i = 0; i < strlen(number); i++) {
100 /* allow international notation with + */
101 if (i == 0 && number[i] == '+')
103 if (!(number[i] >= '0' && number[i] <= '9')
106 && !(number[i] >= 'a' && number[i] <= 'c')) {
107 vty_out(vty, "Invalid digit '%c' of number!%s",
108 number[i], VTY_NEWLINE);
112 if (number[0] == '\0' || (number[0] == '+' && number[1] == '\0')) {
113 vty_out(vty, "Given number has no digits!%s", VTY_NEWLINE);
122 static void vty_restart(struct vty *vty, struct osmocom_ms *ms)
126 if (ms->shutdown != 0)
128 vty_out(vty, "You must restart MS '%s' ('shutdown / no shutdown') for "
129 "change to take effect!%s", ms->name, VTY_NEWLINE);
132 static struct osmocom_ms *get_ms(const char *name, struct vty *vty)
134 struct osmocom_ms *ms;
136 llist_for_each_entry(ms, &ms_list, entity) {
137 if (!strcmp(ms->name, name))
139 vty_out(vty, "MS '%s' is admin down.%s", name,
144 vty_out(vty, "MS name '%s' does not exits.%s", name, VTY_NEWLINE);
149 DEFUN(show_ms, show_ms_cmd, "show ms",
150 SHOW_STR "Display available MS entities\n")
152 struct osmocom_ms *ms;
154 llist_for_each_entry(ms, &ms_list, entity) {
155 struct gsm_settings *set = &ms->settings;
157 vty_out(vty, "MS NAME: %s%s", ms->name, VTY_NEWLINE);
158 vty_out(vty, " IMEI: %s%s", set->imei, VTY_NEWLINE);
159 vty_out(vty, " IMEISV: %s%s", set->imeisv, VTY_NEWLINE);
160 if (set->imei_random)
161 vty_out(vty, " IMEI generation: random (%d trailing "
162 "digits)%s", set->imei_random, VTY_NEWLINE);
164 vty_out(vty, " IMEI generation: fixed%s", VTY_NEWLINE);
165 vty_out(vty, " network selection mode: %s%s",
166 (set->plmn_mode == PLMN_MODE_AUTO)
167 ? "automatic" : "manual", VTY_NEWLINE);
173 DEFUN(show_support, show_support_cmd, "show support [ms_name]",
174 SHOW_STR "Display information about MS support\n"
175 "Name of MS (see \"show ms\")")
177 struct osmocom_ms *ms;
180 ms = get_ms(argv[0], vty);
183 gsm_support_dump(ms, print_vty, vty);
185 llist_for_each_entry(ms, &ms_list, entity) {
186 gsm_support_dump(ms, print_vty, vty);
187 vty_out(vty, "%s", VTY_NEWLINE);
194 static void gsm_states_dump(struct osmocom_ms *ms, struct vty *vty)
196 struct gsm_settings *set = &ms->settings;
197 struct gsm_trans *trans;
199 vty_out(vty, "Current state of MS '%s'%s", ms->name, VTY_NEWLINE);
200 if (set->plmn_mode == PLMN_MODE_AUTO)
201 vty_out(vty, " automatic network selection: %s%s",
202 plmn_a_state_names[ms->plmn.state], VTY_NEWLINE);
204 vty_out(vty, " manual network selection: %s%s",
205 plmn_m_state_names[ms->plmn.state], VTY_NEWLINE);
206 vty_out(vty, " cell selection: %s",
207 cs_state_names[ms->cellsel.state]);
208 if (ms->rrlayer.state == GSM48_RR_ST_IDLE && ms->cellsel.selected)
209 vty_out(vty, " (ARFCN %d)", ms->cellsel.sel_arfcn);
210 vty_out(vty, "%s", VTY_NEWLINE);
211 vty_out(vty, " radio ressource layer: %s%s",
212 gsm48_rr_state_names[ms->rrlayer.state], VTY_NEWLINE);
213 vty_out(vty, " mobility management layer: %s",
214 gsm48_mm_state_names[ms->mmlayer.state]);
215 if (ms->mmlayer.state == GSM48_MM_ST_MM_IDLE)
217 gsm48_mm_substate_names[ms->mmlayer.substate]);
218 vty_out(vty, "%s", VTY_NEWLINE);
219 llist_for_each_entry(trans, &ms->trans_list, entry) {
220 vty_out(vty, " call control: %s%s",
221 gsm48_cc_state_name(trans->cc.state), VTY_NEWLINE);
225 DEFUN(show_states, show_states_cmd, "show states [ms_name]",
226 SHOW_STR "Display current states of given MS\n"
227 "Name of MS (see \"show ms\")")
229 struct osmocom_ms *ms;
232 ms = get_ms(argv[0], vty);
235 gsm_states_dump(ms, vty);
237 llist_for_each_entry(ms, &ms_list, entity) {
239 gsm_states_dump(ms, vty);
240 vty_out(vty, "%s", VTY_NEWLINE);
248 DEFUN(show_subscr, show_subscr_cmd, "show subscriber [ms_name]",
249 SHOW_STR "Display information about subscriber\n"
250 "Name of MS (see \"show ms\")")
252 struct osmocom_ms *ms;
255 ms = get_ms(argv[0], vty);
258 gsm_subscr_dump(&ms->subscr, print_vty, vty);
260 llist_for_each_entry(ms, &ms_list, entity) {
262 gsm_subscr_dump(&ms->subscr, print_vty, vty);
263 vty_out(vty, "%s", VTY_NEWLINE);
271 DEFUN(show_cell, show_cell_cmd, "show cell MS_NAME",
272 SHOW_STR "Display information about received cells\n"
273 "Name of MS (see \"show ms\")")
275 struct osmocom_ms *ms;
277 ms = get_ms(argv[0], vty);
281 gsm322_dump_cs_list(&ms->cellsel, GSM322_CS_FLAG_SYSINFO, print_vty,
287 DEFUN(show_cell_si, show_cell_si_cmd, "show cell MS_NAME <0-1023>",
288 SHOW_STR "Display information about received cell\n"
289 "Name of MS (see \"show ms\")\nRadio frequency number")
291 struct osmocom_ms *ms;
293 struct gsm48_sysinfo *s;
295 ms = get_ms(argv[0], vty);
300 if (i < 0 || i > 1023) {
301 vty_out(vty, "Given ARFCN '%s' not in range (0..1023)%s",
302 argv[1], VTY_NEWLINE);
305 s = ms->cellsel.list[i].sysinfo;
307 vty_out(vty, "Given ARFCN '%s' has no sysinfo available%s",
308 argv[1], VTY_NEWLINE);
312 gsm48_sysinfo_dump(s, i, print_vty, vty);
317 DEFUN(show_ba, show_ba_cmd, "show ba MS_NAME [mcc] [mnc]",
318 SHOW_STR "Display information about band allocations\n"
319 "Name of MS (see \"show ms\")\nMobile Country Code\n"
320 "Mobile Network Code")
322 struct osmocom_ms *ms;
323 uint16_t mcc = 0, mnc = 0;
325 ms = get_ms(argv[0], vty);
330 mcc = gsm_input_mcc((char *)argv[1]);
331 mnc = gsm_input_mnc((char *)argv[2]);
333 vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
337 vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
342 gsm322_dump_ba_list(&ms->cellsel, mcc, mnc, print_vty, vty);
347 DEFUN(show_forb_plmn, show_forb_plmn_cmd, "show forbidden plmn MS_NAME",
348 SHOW_STR "Display information about forbidden cells / networks\n"
349 "Display forbidden PLMNs\nName of MS (see \"show ms\")")
351 struct osmocom_ms *ms;
353 ms = get_ms(argv[0], vty);
357 gsm_subscr_dump_forbidden_plmn(ms, print_vty, vty);
362 DEFUN(show_forb_la, show_forb_la_cmd, "show forbidden location-area MS_NAME",
363 SHOW_STR "Display information about forbidden cells / networks\n"
364 "Display forbidden location areas\nName of MS (see \"show ms\")")
366 struct osmocom_ms *ms;
368 ms = get_ms(argv[0], vty);
372 gsm322_dump_forbidden_la(ms, print_vty, vty);
377 DEFUN(monitor_network, monitor_network_cmd, "monitor network MS_NAME",
378 "Monitor...\nMonitor network information\nName of MS (see \"show ms\")")
380 struct osmocom_ms *ms;
382 ms = get_ms(argv[0], vty);
386 gsm48_rr_start_monitor(ms);
391 DEFUN(no_monitor_network, no_monitor_network_cmd, "no monitor network MS_NAME",
392 NO_STR "Monitor...\nDeactivate monitor of network information\n"
393 "Name of MS (see \"show ms\")")
395 struct osmocom_ms *ms;
397 ms = get_ms(argv[0], vty);
401 gsm48_rr_stop_monitor(ms);
406 DEFUN(sim_test, sim_test_cmd, "sim testcard MS_NAME [mcc] [mnc]",
407 "SIM actions\nInsert test card\nName of MS (see \"show ms\")\n"
408 "Mobile Country Code of RPLMN\nMobile Network Code of RPLMN")
410 struct osmocom_ms *ms;
411 uint16_t mcc = 0x001, mnc = 0x01f;
413 ms = get_ms(argv[0], vty);
417 if (ms->subscr.sim_valid) {
418 vty_out(vty, "SIM already presend, remove first!%s",
424 mcc = gsm_input_mcc((char *)argv[1]);
425 mnc = gsm_input_mnc((char *)argv[2]);
427 vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
431 vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
436 gsm_subscr_testcard(ms, mcc, mnc);
441 DEFUN(sim_reader, sim_reader_cmd, "sim reader MS_NAME",
442 "SIM actions\nSelect SIM from reader\nName of MS (see \"show ms\")")
444 struct osmocom_ms *ms;
446 ms = get_ms(argv[0], vty);
450 if (ms->subscr.sim_valid) {
451 vty_out(vty, "SIM already presend, remove first!%s",
456 gsm_subscr_simcard(ms);
461 DEFUN(sim_remove, sim_remove_cmd, "sim remove MS_NAME",
462 "SIM actions\nRemove SIM card\nName of MS (see \"show ms\")")
464 struct osmocom_ms *ms;
466 ms = get_ms(argv[0], vty);
470 if (!ms->subscr.sim_valid) {
471 vty_out(vty, "No Sim inserted!%s", VTY_NEWLINE);
475 gsm_subscr_remove(ms);
480 DEFUN(sim_pin, sim_pin_cmd, "sim pin MS_NAME PIN",
481 "SIM actions\nEnter PIN for SIM card\nName of MS (see \"show ms\")\n"
484 struct osmocom_ms *ms;
486 ms = get_ms(argv[0], vty);
490 if (strlen(argv[1]) < 4 || strlen(argv[1]) > 8) {
491 vty_out(vty, "PIN must be in range 4..8!%s", VTY_NEWLINE);
495 if (!ms->subscr.sim_pin_required) {
496 vty_out(vty, "No PIN is required at this time!%s", VTY_NEWLINE);
500 gsm_subscr_sim_pin(ms, (char *)argv[1], "", 0);
505 DEFUN(sim_disable_pin, sim_disable_pin_cmd, "sim disable-pin MS_NAME PIN",
506 "SIM actions\nDisable PIN of SIM card\nName of MS (see \"show ms\")\n"
509 struct osmocom_ms *ms;
511 ms = get_ms(argv[0], vty);
515 if (strlen(argv[1]) < 4 || strlen(argv[1]) > 8) {
516 vty_out(vty, "PIN must be in range 4..8!%s", VTY_NEWLINE);
520 gsm_subscr_sim_pin(ms, (char *)argv[1], "", -1);
525 DEFUN(sim_enable_pin, sim_enable_pin_cmd, "sim enable-pin MS_NAME PIN",
526 "SIM actions\nEnable PIN of SIM card\nName of MS (see \"show ms\")\n"
529 struct osmocom_ms *ms;
531 ms = get_ms(argv[0], vty);
535 if (strlen(argv[1]) < 4 || strlen(argv[1]) > 8) {
536 vty_out(vty, "PIN must be in range 4..8!%s", VTY_NEWLINE);
540 gsm_subscr_sim_pin(ms, (char *)argv[1], "", 1);
545 DEFUN(sim_change_pin, sim_change_pin_cmd, "sim change-pin MS_NAME OLD NEW",
546 "SIM actions\nChange PIN of SIM card\nName of MS (see \"show ms\")\n"
547 "Old PIN number\nNew PIN number")
549 struct osmocom_ms *ms;
551 ms = get_ms(argv[0], vty);
555 if (strlen(argv[1]) < 4 || strlen(argv[1]) > 8) {
556 vty_out(vty, "Old PIN must be in range 4..8!%s", VTY_NEWLINE);
559 if (strlen(argv[2]) < 4 || strlen(argv[2]) > 8) {
560 vty_out(vty, "New PIN must be in range 4..8!%s", VTY_NEWLINE);
564 gsm_subscr_sim_pin(ms, (char *)argv[1], (char *)argv[2], 2);
569 DEFUN(sim_unblock_pin, sim_unblock_pin_cmd, "sim unblock-pin MS_NAME PUC NEW",
570 "SIM actions\nChange PIN of SIM card\nName of MS (see \"show ms\")\n"
571 "Personal Unblock Key\nNew PIN number")
573 struct osmocom_ms *ms;
575 ms = get_ms(argv[0], vty);
579 if (strlen(argv[1]) != 8) {
580 vty_out(vty, "PUC must be 8 digits!%s", VTY_NEWLINE);
583 if (strlen(argv[2]) < 4 || strlen(argv[2]) > 8) {
584 vty_out(vty, "PIN must be in range 4..8!%s", VTY_NEWLINE);
588 gsm_subscr_sim_pin(ms, (char *)argv[1], (char *)argv[2], 99);
593 DEFUN(sim_lai, sim_lai_cmd, "sim lai MS_NAME MCC MNC LAC",
594 "SIM actions\nChange LAI of SIM card\nName of MS (see \"show ms\")\n"
595 "Mobile Country Code\nMobile Network Code\nLocation Area Code "
596 " (use 0000 to remove LAI)")
598 struct osmocom_ms *ms;
599 uint16_t mcc = gsm_input_mcc((char *)argv[1]),
600 mnc = gsm_input_mnc((char *)argv[2]),
601 lac = strtoul(argv[3], NULL, 16);
603 ms = get_ms(argv[0], vty);
608 vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
612 vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
616 ms->subscr.mcc = mcc;
617 ms->subscr.mnc = mnc;
618 ms->subscr.lac = lac;
619 ms->subscr.tmsi = 0xffffffff;
621 gsm_subscr_write_loci(ms);
626 DEFUN(network_select, network_select_cmd, "network select MS_NAME MCC MNC",
627 "Select ...\nSelect Network\nName of MS (see \"show ms\")\n"
628 "Mobile Country Code\nMobile Network Code")
630 struct osmocom_ms *ms;
631 struct gsm322_plmn *plmn;
633 struct gsm322_msg *ngm;
634 struct gsm322_plmn_list *temp;
635 uint16_t mcc = gsm_input_mcc((char *)argv[1]),
636 mnc = gsm_input_mnc((char *)argv[2]);
639 ms = get_ms(argv[0], vty);
645 vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
649 vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
653 llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
654 if (temp->mcc == mcc && temp->mnc == mnc)
657 vty_out(vty, "Network not in list!%s", VTY_NEWLINE);
661 nmsg = gsm322_msgb_alloc(GSM322_EVENT_CHOOSE_PLMN);
664 ngm = (struct gsm322_msg *) nmsg->data;
667 gsm322_plmn_sendmsg(ms, nmsg);
672 DEFUN(call, call_cmd, "call MS_NAME (NUMBER|emergency|answer|hangup|hold)",
673 "Make a call\nName of MS (see \"show ms\")\nPhone number to call "
674 "(Use digits '0123456789*#abc', and '+' to dial international)\n"
675 "Make an emergency call\nAnswer an incomming call\nHangup a call\n"
676 "Hold current active call\n")
678 struct osmocom_ms *ms;
679 struct gsm_settings *set;
680 struct gsm_settings_abbrev *abbrev;
683 ms = get_ms(argv[0], vty);
688 if (set->ch_cap == GSM_CAP_SDCCH) {
689 vty_out(vty, "Basic call is not supported for SDCCH only "
690 "mobile%s", VTY_NEWLINE);
694 number = (char *)argv[1];
695 if (!strcmp(number, "emergency"))
696 mncc_call(ms, number);
697 else if (!strcmp(number, "answer"))
699 else if (!strcmp(number, "hangup"))
701 else if (!strcmp(number, "hold"))
704 llist_for_each_entry(abbrev, &set->abbrev, list) {
705 if (!strcmp(number, abbrev->abbrev)) {
706 number = abbrev->number;
707 vty_out(vty, "Dialing number '%s'%s", number,
712 if (vty_check_number(vty, number))
714 mncc_call(ms, number);
720 DEFUN(call_retr, call_retr_cmd, "call MS_NAME retrieve [number]",
721 "Make a call\nName of MS (see \"show ms\")\n"
722 "Retrieve call on hold\nNumber of call to retrieve")
724 struct osmocom_ms *ms;
726 ms = get_ms(argv[0], vty);
730 mncc_retrieve(ms, (argc > 1) ? atoi(argv[1]) : 0);
735 DEFUN(call_dtmf, call_dtmf_cmd, "call MS_NAME dtmf DIGITS",
736 "Make a call\nName of MS (see \"show ms\")\n"
737 "One or more DTMF digits to transmit")
739 struct osmocom_ms *ms;
740 struct gsm_settings *set;
742 ms = get_ms(argv[0], vty);
748 vty_out(vty, "DTMF not supported, please enable!%s",
753 mncc_dtmf(ms, (char *)argv[1]);
758 DEFUN(network_show, network_show_cmd, "network show MS_NAME",
759 "Network ...\nShow results of network search (again)\n"
760 "Name of MS (see \"show ms\")")
762 struct osmocom_ms *ms;
763 struct gsm_settings *set;
764 struct gsm322_plmn *plmn;
765 struct gsm322_plmn_list *temp;
767 ms = get_ms(argv[0], vty);
773 if (set->plmn_mode != PLMN_MODE_AUTO
774 && plmn->state != GSM322_M3_NOT_ON_PLMN) {
775 vty_out(vty, "Start network search first!%s", VTY_NEWLINE);
779 llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
780 vty_out(vty, " Network %s, %s (%s, %s)%s",
781 gsm_print_mcc(temp->mcc), gsm_print_mnc(temp->mnc),
782 gsm_get_mcc(temp->mcc),
783 gsm_get_mnc(temp->mcc, temp->mnc), VTY_NEWLINE);
788 DEFUN(network_search, network_search_cmd, "network search MS_NAME",
789 "Network ...\nTrigger network search\nName of MS (see \"show ms\")")
791 struct osmocom_ms *ms;
794 ms = get_ms(argv[0], vty);
798 nmsg = gsm322_msgb_alloc(GSM322_EVENT_USER_RESEL);
801 gsm322_plmn_sendmsg(ms, nmsg);
806 DEFUN(cfg_gps_enable, cfg_gps_enable_cmd, "gps enable",
811 vty_out(vty, "Failed to open GPS device!%s", VTY_NEWLINE);
819 DEFUN(cfg_no_gps_enable, cfg_no_gps_enable_cmd, "no gps enable",
820 NO_STR "Disable GPS receiver")
829 DEFUN(cfg_gps_device, cfg_gps_device_cmd, "gps device DEVICE",
830 "GPS receiver\nSelect serial device\n"
831 "Full path of serial device including /dev/")
833 strncpy(gps.device, argv[0], sizeof(gps.device));
834 gps.device[sizeof(gps.device) - 1] = '\0';
838 vty_out(vty, "Failed to open GPS device!%s",
847 DEFUN(cfg_gps_baud, cfg_gps_baud_cmd, "gps baudrate "
848 "(default|4800|""9600|19200|38400|57600|115200)",
849 "GPS receiver\nSelect baud rate\nDefault, don't modify\n\n\n\n\n\n")
851 if (argv[0][0] == 'd')
854 gps.baud = atoi(argv[0]);
859 vty_out(vty, "Failed to open GPS device!%s",
869 DEFUN(cfg_ms, cfg_ms_cmd, "ms MS_NAME",
870 "Select a mobile station to configure\nName of MS (see \"show ms\")")
872 struct osmocom_ms *ms;
875 llist_for_each_entry(ms, &ms_list, entity) {
876 if (!strcmp(ms->name, argv[0])) {
884 vty_out(vty, "MS name '%s' does not exits, try "
885 "'ms %s create'%s", argv[0], argv[0],
889 ms = mobile_new((char *)argv[0]);
891 vty_out(vty, "Failed to add MS name '%s'%s", argv[0],
903 DEFUN(cfg_ms_create, cfg_ms_create_cmd, "ms MS_NAME create",
904 "Select a mobile station to configure\nName of MS (see \"show ms\")\n"
905 "Create if MS does not exists")
907 struct osmocom_ms *ms;
910 llist_for_each_entry(ms, &ms_list, entity) {
911 if (!strcmp(ms->name, argv[0])) {
918 ms = mobile_new((char *)argv[0]);
920 vty_out(vty, "Failed to add MS name '%s'%s", argv[0],
929 vty_out(vty, "MS '%s' created, after configuration, do 'no shutdown'%s",
930 argv[0], VTY_NEWLINE);
934 DEFUN(cfg_ms_rename, cfg_ms_rename_cmd, "ms MS_NAME rename MS_NAME",
935 "Select a mobile station to configure\nName of MS (see \"show ms\")\n"
936 "Rename MS\nNew name of MS")
938 struct osmocom_ms *ms;
941 llist_for_each_entry(ms, &ms_list, entity) {
942 if (!strcmp(ms->name, argv[0])) {
949 vty_out(vty, "MS name '%s' does not exist%s", argv[0],
954 strncpy(ms->name, argv[1], sizeof(ms->name) - 1);
959 DEFUN(cfg_no_ms, cfg_no_ms_cmd, "no ms MS_NAME",
960 NO_STR "Select a mobile station to remove\n"
961 "Name of MS (see \"show ms\")")
963 struct osmocom_ms *ms;
966 llist_for_each_entry(ms, &ms_list, entity) {
967 if (!strcmp(ms->name, argv[0])) {
974 vty_out(vty, "MS name '%s' does not exist%s", argv[0],
979 mobile_delete(ms, 1);
984 #define SUP_WRITE(item, cmd) \
986 vty_out(vty, " %s%s%s", (set->item) ? "" : "no ", cmd, \
989 static void config_write_ms_single(struct vty *vty, struct osmocom_ms *ms)
991 struct gsm_settings *set = &ms->settings;
992 struct gsm_support *sup = &ms->support;
993 struct gsm_settings_abbrev *abbrev;
995 vty_out(vty, "ms %s%s", ms->name, VTY_NEWLINE);
996 vty_out(vty, " layer2-socket %s%s", set->layer2_socket_path,
998 vty_out(vty, " sap-socket %s%s", set->sap_socket_path, VTY_NEWLINE);
999 switch(set->sim_type) {
1000 case GSM_SIM_TYPE_NONE:
1001 vty_out(vty, " sim none%s", VTY_NEWLINE);
1003 case GSM_SIM_TYPE_READER:
1004 vty_out(vty, " sim reader%s", VTY_NEWLINE);
1006 case GSM_SIM_TYPE_TEST:
1007 vty_out(vty, " sim test%s", VTY_NEWLINE);
1010 vty_out(vty, " network-selection-mode %s%s", (set->plmn_mode
1011 == PLMN_MODE_AUTO) ? "auto" : "manual", VTY_NEWLINE);
1012 vty_out(vty, " imei %s %s%s", set->imei,
1013 set->imeisv + strlen(set->imei), VTY_NEWLINE);
1014 if (set->imei_random)
1015 vty_out(vty, " imei-random %d%s", set->imei_random,
1018 vty_out(vty, " imei-fixed%s", VTY_NEWLINE);
1019 if (set->emergency_imsi[0])
1020 vty_out(vty, " emergency-imsi %s%s", set->emergency_imsi,
1023 vty_out(vty, " no emergency-imsi%s", VTY_NEWLINE);
1024 vty_out(vty, " %scall-waiting%s", (set->cw) ? "" : "no ", VTY_NEWLINE);
1025 vty_out(vty, " %sauto-answer%s", (set->auto_answer) ? "" : "no ",
1027 vty_out(vty, " %sclip%s", (set->clip) ? "" : "no ", VTY_NEWLINE);
1028 vty_out(vty, " %sclir%s", (set->clir) ? "" : "no ", VTY_NEWLINE);
1029 if (set->alter_tx_power)
1030 if (set->alter_tx_power_value)
1031 vty_out(vty, " tx-power %d%s",
1032 set->alter_tx_power_value, VTY_NEWLINE);
1034 vty_out(vty, " tx-power full%s", VTY_NEWLINE);
1036 vty_out(vty, " tx-power auto%s", VTY_NEWLINE);
1037 if (set->alter_delay)
1038 vty_out(vty, " simulated-delay %d%s", set->alter_delay,
1041 vty_out(vty, " no simulated-delay%s", VTY_NEWLINE);
1043 vty_out(vty, " stick %d%s", set->stick_arfcn,
1046 vty_out(vty, " no stick%s", VTY_NEWLINE);
1048 vty_out(vty, " no location-updating%s", VTY_NEWLINE);
1050 vty_out(vty, " location-updating%s", VTY_NEWLINE);
1051 if (set->full_v1 || set->full_v2 || set->full_v3) {
1052 /* mandatory anyway */
1053 vty_out(vty, " codec full-speed%s%s",
1054 (!set->half_prefer) ? " prefer" : "",
1057 if (set->half_v1 || set->half_v3) {
1059 vty_out(vty, " codec half-speed%s%s",
1060 (set->half_prefer) ? " prefer" : "",
1063 vty_out(vty, " no codec half-speed%s", VTY_NEWLINE);
1065 if (llist_empty(&set->abbrev))
1066 vty_out(vty, " no abbrev%s", VTY_NEWLINE);
1068 llist_for_each_entry(abbrev, &set->abbrev, list)
1069 vty_out(vty, " abbrev %s %s%s%s%s", abbrev->abbrev,
1070 abbrev->number, (abbrev->name[0]) ? " " : "",
1071 abbrev->name, VTY_NEWLINE);
1073 vty_out(vty, " support%s", VTY_NEWLINE);
1074 SUP_WRITE(sms_ptp, "sms");
1075 SUP_WRITE(a5_1, "a5/1");
1076 SUP_WRITE(a5_2, "a5/2");
1077 SUP_WRITE(a5_3, "a5/3");
1078 SUP_WRITE(a5_4, "a5/4");
1079 SUP_WRITE(a5_5, "a5/5");
1080 SUP_WRITE(a5_6, "a5/6");
1081 SUP_WRITE(a5_7, "a5/7");
1082 SUP_WRITE(p_gsm, "p-gsm");
1083 SUP_WRITE(e_gsm, "e-gsm");
1084 SUP_WRITE(r_gsm, "r-gsm");
1085 SUP_WRITE(dcs, "dcs");
1086 vty_out(vty, " class-900 %d%s", set->class_900, VTY_NEWLINE);
1087 vty_out(vty, " class-dcs %d%s", set->class_dcs, VTY_NEWLINE);
1088 switch (set->ch_cap) {
1090 vty_out(vty, " channel-capability sdcch%s", VTY_NEWLINE);
1092 case GSM_CAP_SDCCH_TCHF:
1093 vty_out(vty, " channel-capability sdcch+tchf%s", VTY_NEWLINE);
1095 case GSM_CAP_SDCCH_TCHF_TCHH:
1096 vty_out(vty, " channel-capability sdcch+tchf+tchh%s",
1100 SUP_WRITE(full_v1, "full-speech-v1");
1101 SUP_WRITE(full_v2, "full-speech-v2");
1102 SUP_WRITE(full_v3, "full-speech-v3");
1103 SUP_WRITE(half_v1, "half-speech-v1");
1104 SUP_WRITE(half_v3, "half-speech-v3");
1105 vty_out(vty, " min-rxlev %d%s", set->min_rxlev_db, VTY_NEWLINE);
1106 vty_out(vty, " dsc-max %d%s", set->dsc_max, VTY_NEWLINE);
1107 vty_out(vty, " exit%s", VTY_NEWLINE);
1108 vty_out(vty, " test-sim%s", VTY_NEWLINE);
1109 vty_out(vty, " imsi %s%s", set->test_imsi, VTY_NEWLINE);
1110 switch (set->test_ki_type) {
1111 case GSM_SIM_KEY_XOR:
1112 vty_out(vty, " ki xor %s%s", hexdump(set->test_ki, 12),
1115 case GSM_SIM_KEY_COMP128:
1116 vty_out(vty, " ki comp128 %s%s", hexdump(set->test_ki, 16),
1120 vty_out(vty, " %sbarred-access%s", (set->test_barr) ? "" : "no ",
1122 if (set->test_rplmn_valid)
1123 vty_out(vty, " rplmn %s %s%s",
1124 gsm_print_mcc(set->test_rplmn_mcc),
1125 gsm_print_mnc(set->test_rplmn_mnc),
1128 vty_out(vty, " no rplmn%s", VTY_NEWLINE);
1129 vty_out(vty, " hplmn-search %s%s", (set->test_always) ? "everywhere"
1130 : "foreign-country", VTY_NEWLINE);
1131 vty_out(vty, " exit%s", VTY_NEWLINE);
1132 vty_out(vty, " %sshutdown%s", (ms->shutdown) ? "" : "no ",
1134 vty_out(vty, "exit%s", VTY_NEWLINE);
1135 vty_out(vty, "!%s", VTY_NEWLINE);
1138 static int config_write_ms(struct vty *vty)
1140 struct osmocom_ms *ms;
1142 vty_out(vty, "gps device %s%s", gps.device, VTY_NEWLINE);
1144 vty_out(vty, "gps baudrate %d%s", gps.baud, VTY_NEWLINE);
1146 vty_out(vty, "gps baudrate default%s", VTY_NEWLINE);
1147 vty_out(vty, "%sgps enable%s", (gps.enable) ? "" : "no ", VTY_NEWLINE);
1148 vty_out(vty, "!%s", VTY_NEWLINE);
1150 llist_for_each_entry(ms, &ms_list, entity)
1151 config_write_ms_single(vty, ms);
1156 DEFUN(cfg_ms_layer2, cfg_ms_layer2_cmd, "layer2-socket PATH",
1157 "Define socket path to connect between layer 2 and layer 1\n"
1158 "Unix socket, default '/tmp/osmocom_l2'")
1160 struct osmocom_ms *ms = vty->index;
1161 struct gsm_settings *set = &ms->settings;
1163 strncpy(set->layer2_socket_path, argv[0],
1164 sizeof(set->layer2_socket_path) - 1);
1166 vty_restart(vty, ms);
1170 DEFUN(cfg_ms_sap, cfg_ms_sap_cmd, "sap-socket PATH",
1171 "Define socket path to connect to SIM reader\n"
1172 "Unix socket, default '/tmp/osmocom_sap'")
1174 struct osmocom_ms *ms = vty->index;
1175 struct gsm_settings *set = &ms->settings;
1177 strncpy(set->sap_socket_path, argv[0],
1178 sizeof(set->sap_socket_path) - 1);
1180 vty_restart(vty, ms);
1184 DEFUN(cfg_ms_sim, cfg_ms_sim_cmd, "sim (none|reader|test)",
1185 "Set SIM card type when powering on\nNo SIM interted\n"
1186 "Use SIM from reader\nTest SIM inserted")
1188 struct osmocom_ms *ms = vty->index;
1189 struct gsm_settings *set = &ms->settings;
1191 switch (argv[0][0]) {
1193 set->sim_type = GSM_SIM_TYPE_NONE;
1196 set->sim_type = GSM_SIM_TYPE_READER;
1199 set->sim_type = GSM_SIM_TYPE_TEST;
1202 vty_out(vty, "unknown SIM type%s", VTY_NEWLINE);
1206 vty_restart(vty, ms);
1210 DEFUN(cfg_ms_mode, cfg_ms_mode_cmd, "network-selection-mode (auto|manual)",
1211 "Set network selection mode\nAutomatic network selection\n"
1212 "Manual network selection")
1214 struct osmocom_ms *ms = vty->index;
1215 struct gsm_settings *set = &ms->settings;
1218 if (!ms->plmn.state) {
1219 if (argv[0][0] == 'a')
1220 set->plmn_mode = PLMN_MODE_AUTO;
1222 set->plmn_mode = PLMN_MODE_MANUAL;
1226 if (argv[0][0] == 'a')
1227 nmsg = gsm322_msgb_alloc(GSM322_EVENT_SEL_AUTO);
1229 nmsg = gsm322_msgb_alloc(GSM322_EVENT_SEL_MANUAL);
1232 gsm322_plmn_sendmsg(ms, nmsg);
1237 DEFUN(cfg_ms_imei, cfg_ms_imei_cmd, "imei IMEI [SV]",
1238 "Set IMEI (enter without control digit)\n15 Digits IMEI\n"
1239 "Software version digit")
1241 struct osmocom_ms *ms = vty->index;
1242 struct gsm_settings *set = &ms->settings;
1243 char *error, *sv = "0";
1246 sv = (char *)argv[1];
1248 error = gsm_check_imei(argv[0], sv);
1250 vty_out(vty, "%s%s", error, VTY_NEWLINE);
1254 strcpy(set->imei, argv[0]);
1255 strcpy(set->imeisv, argv[0]);
1256 strcpy(set->imeisv + 15, sv);
1261 DEFUN(cfg_ms_imei_fixed, cfg_ms_imei_fixed_cmd, "imei-fixed",
1262 "Use fixed IMEI on every power on")
1264 struct osmocom_ms *ms = vty->index;
1265 struct gsm_settings *set = &ms->settings;
1267 set->imei_random = 0;
1269 vty_restart(vty, ms);
1273 DEFUN(cfg_ms_imei_random, cfg_ms_imei_random_cmd, "imei-random <0-15>",
1274 "Use random IMEI on every power on\n"
1275 "Number of trailing digits to randomize")
1277 struct osmocom_ms *ms = vty->index;
1278 struct gsm_settings *set = &ms->settings;
1280 set->imei_random = atoi(argv[0]);
1282 vty_restart(vty, ms);
1286 DEFUN(cfg_ms_emerg_imsi, cfg_ms_emerg_imsi_cmd, "emergency-imsi IMSI",
1287 "Use special IMSI for emergency calls\n15 digits IMSI")
1289 struct osmocom_ms *ms = vty->index;
1290 struct gsm_settings *set = &ms->settings;
1293 error = gsm_check_imsi(argv[0]);
1295 vty_out(vty, "%s%s", error, VTY_NEWLINE);
1298 strcpy(set->emergency_imsi, argv[0]);
1303 DEFUN(cfg_ms_no_emerg_imsi, cfg_ms_no_emerg_imsi_cmd, "no emergency-imsi",
1304 NO_STR "Use IMSI of SIM or IMEI for emergency calls")
1306 struct osmocom_ms *ms = vty->index;
1307 struct gsm_settings *set = &ms->settings;
1309 set->emergency_imsi[0] = '\0';
1314 DEFUN(cfg_no_cw, cfg_ms_no_cw_cmd, "no call-waiting",
1315 NO_STR "Disallow waiting calls")
1317 struct osmocom_ms *ms = vty->index;
1318 struct gsm_settings *set = &ms->settings;
1325 DEFUN(cfg_cw, cfg_ms_cw_cmd, "call-waiting",
1326 "Allow waiting calls")
1328 struct osmocom_ms *ms = vty->index;
1329 struct gsm_settings *set = &ms->settings;
1336 DEFUN(cfg_no_auto_answer, cfg_ms_no_auto_answer_cmd, "no auto-answer",
1337 NO_STR "Disable auto-answering calls")
1339 struct osmocom_ms *ms = vty->index;
1340 struct gsm_settings *set = &ms->settings;
1342 set->auto_answer = 0;
1347 DEFUN(cfg_auto_answer, cfg_ms_auto_answer_cmd, "auto-answer",
1348 "Enable auto-answering calls")
1350 struct osmocom_ms *ms = vty->index;
1351 struct gsm_settings *set = &ms->settings;
1353 set->auto_answer = 1;
1358 DEFUN(cfg_clip, cfg_ms_clip_cmd, "clip",
1359 "Force caller ID presentation")
1361 struct osmocom_ms *ms = vty->index;
1362 struct gsm_settings *set = &ms->settings;
1370 DEFUN(cfg_clir, cfg_ms_clir_cmd, "clir",
1371 "Force caller ID restriction")
1373 struct osmocom_ms *ms = vty->index;
1374 struct gsm_settings *set = &ms->settings;
1382 DEFUN(cfg_no_clip, cfg_ms_no_clip_cmd, "no clip",
1383 NO_STR "Disable forcing of caller ID presentation")
1385 struct osmocom_ms *ms = vty->index;
1386 struct gsm_settings *set = &ms->settings;
1393 DEFUN(cfg_no_clir, cfg_ms_no_clir_cmd, "no clir",
1394 NO_STR "Disable forcing of caller ID restriction")
1396 struct osmocom_ms *ms = vty->index;
1397 struct gsm_settings *set = &ms->settings;
1404 DEFUN(cfg_ms_tx_power, cfg_ms_tx_power_cmd, "tx-power (auto|full)",
1405 "Set the way to choose transmit power\nControlled by BTS\n"
1406 "Always full power\nFixed GSM power value if supported")
1408 struct osmocom_ms *ms = vty->index;
1409 struct gsm_settings *set = &ms->settings;
1411 switch (argv[0][0]) {
1413 set->alter_tx_power = 0;
1416 set->alter_tx_power = 1;
1417 set->alter_tx_power_value = 0;
1424 DEFUN(cfg_ms_tx_power_val, cfg_ms_tx_power_val_cmd, "tx-power <0-31>",
1425 "Set the way to choose transmit power\n"
1426 "Fixed GSM power value if supported")
1428 struct osmocom_ms *ms = vty->index;
1429 struct gsm_settings *set = &ms->settings;
1431 set->alter_tx_power = 1;
1432 set->alter_tx_power_value = atoi(argv[0]);
1437 DEFUN(cfg_ms_sim_delay, cfg_ms_sim_delay_cmd, "simulated-delay <-128-127>",
1438 "Simulate a lower or higher distance from the BTS\n"
1439 "Delay in half bits (distance in 553.85 meter steps)")
1441 struct osmocom_ms *ms = vty->index;
1442 struct gsm_settings *set = &ms->settings;
1444 set->alter_delay = atoi(argv[0]);
1445 gsm48_rr_alter_delay(ms);
1450 DEFUN(cfg_ms_no_sim_delay, cfg_ms_no_sim_delay_cmd, "no simulated-delay",
1451 NO_STR "Do not simulate a lower or higher distance from the BTS")
1453 struct osmocom_ms *ms = vty->index;
1454 struct gsm_settings *set = &ms->settings;
1456 set->alter_delay = 0;
1457 gsm48_rr_alter_delay(ms);
1462 DEFUN(cfg_ms_stick, cfg_ms_stick_cmd, "stick <0-1023>",
1463 "Stick to the given cell\nARFCN of the cell to stick to")
1465 struct osmocom_ms *ms = vty->index;
1466 struct gsm_settings *set = &ms->settings;
1469 set->stick_arfcn = atoi(argv[0]);
1474 DEFUN(cfg_ms_no_stick, cfg_ms_no_stick_cmd, "no stick",
1475 NO_STR "Do not stick to any cell")
1477 struct osmocom_ms *ms = vty->index;
1478 struct gsm_settings *set = &ms->settings;
1485 DEFUN(cfg_ms_lupd, cfg_ms_lupd_cmd, "location-updating",
1486 "Allow location updating")
1488 struct osmocom_ms *ms = vty->index;
1489 struct gsm_settings *set = &ms->settings;
1496 DEFUN(cfg_ms_no_lupd, cfg_ms_no_lupd_cmd, "no location-updating",
1497 NO_STR "Do not allow location updating")
1499 struct osmocom_ms *ms = vty->index;
1500 struct gsm_settings *set = &ms->settings;
1507 DEFUN(cfg_codec_full, cfg_ms_codec_full_cmd, "codec full-speed",
1508 "Enable codec\nFull speed speech codec")
1510 struct osmocom_ms *ms = vty->index;
1511 struct gsm_settings *set = &ms->settings;
1513 if (!set->full_v1 && !set->full_v2 && !set->full_v3) {
1514 vty_out(vty, "Full-rate codec not supported%s", VTY_NEWLINE);
1521 DEFUN(cfg_codec_full_pref, cfg_ms_codec_full_pref_cmd, "codec full-speed "
1523 "Enable codec\nFull speed speech codec\nPrefer this codec")
1525 struct osmocom_ms *ms = vty->index;
1526 struct gsm_settings *set = &ms->settings;
1528 if (!set->full_v1 && !set->full_v2 && !set->full_v3) {
1529 vty_out(vty, "Full-rate codec not supported%s", VTY_NEWLINE);
1533 set->half_prefer = 0;
1538 DEFUN(cfg_codec_half, cfg_ms_codec_half_cmd, "codec half-speed",
1539 "Enable codec\nHalf speed speech codec")
1541 struct osmocom_ms *ms = vty->index;
1542 struct gsm_settings *set = &ms->settings;
1544 if (!set->half_v1 && !set->half_v3) {
1545 vty_out(vty, "Half-rate codec not supported%s", VTY_NEWLINE);
1554 DEFUN(cfg_codec_half_pref, cfg_ms_codec_half_pref_cmd, "codec half-speed "
1556 "Enable codec\nHalf speed speech codec\nPrefer this codec")
1558 struct osmocom_ms *ms = vty->index;
1559 struct gsm_settings *set = &ms->settings;
1561 if (!set->half_v1 && !set->half_v3) {
1562 vty_out(vty, "Half-rate codec not supported%s", VTY_NEWLINE);
1567 set->half_prefer = 1;
1572 DEFUN(cfg_no_codec_half, cfg_ms_no_codec_half_cmd, "no codec half-speed",
1573 NO_STR "Disable codec\nHalf speed speech codec")
1575 struct osmocom_ms *ms = vty->index;
1576 struct gsm_settings *set = &ms->settings;
1578 if (!set->half_v1 && !set->half_v3) {
1579 vty_out(vty, "Half-rate codec not supported%s", VTY_NEWLINE);
1584 set->half_prefer = 0;
1589 DEFUN(cfg_abbrev, cfg_ms_abbrev_cmd, "abbrev ABBREVIATION NUMBER [name]",
1590 "Store given abbreviation number\n1-3 digits abbreviation\n"
1591 "Number to store for the abbreviation "
1592 "(Use digits '0123456789*#abc', and '+' to dial international)\n"
1593 "Name of the abbreviation")
1595 struct osmocom_ms *ms = vty->index;
1596 struct gsm_settings *set = &ms->settings;
1597 struct gsm_settings_abbrev *abbrev;
1600 llist_for_each_entry(abbrev, &set->abbrev, list) {
1601 if (!strcmp(argv[0], abbrev->abbrev)) {
1602 vty_out(vty, "Given abbreviation '%s' already stored, "
1603 "delete first!%s", argv[0], VTY_NEWLINE);
1608 if (strlen(argv[0]) >= sizeof(abbrev->abbrev)) {
1609 vty_out(vty, "Given abbreviation too long%s", VTY_NEWLINE);
1613 for (i = 0; i < strlen(argv[0]); i++) {
1614 if (argv[0][i] < '0' || argv[0][i] > '9') {
1615 vty_out(vty, "Given abbreviation must have digits "
1616 "0..9 only!%s", VTY_NEWLINE);
1621 if (vty_check_number(vty, argv[1]))
1624 abbrev = talloc_zero(l23_ctx, struct gsm_settings_abbrev);
1626 vty_out(vty, "No Memory!%s", VTY_NEWLINE);
1629 llist_add_tail(&abbrev->list, &set->abbrev);
1630 strncpy(abbrev->abbrev, argv[0], sizeof(abbrev->abbrev) - 1);
1631 strncpy(abbrev->number, argv[1], sizeof(abbrev->number) - 1);
1633 strncpy(abbrev->name, argv[2], sizeof(abbrev->name) - 1);
1638 DEFUN(cfg_no_abbrev, cfg_ms_no_abbrev_cmd, "no abbrev [abbreviation]",
1639 NO_STR "Remove given abbreviation number or all numbers\n"
1640 "Abbreviation number to remove")
1642 struct osmocom_ms *ms = vty->index;
1643 struct gsm_settings *set = &ms->settings;
1644 struct gsm_settings_abbrev *abbrev, *abbrev2;
1645 uint8_t deleted = 0;
1647 llist_for_each_entry_safe(abbrev, abbrev2, &set->abbrev, list) {
1648 if (argc < 1 || !strcmp(argv[0], abbrev->abbrev)) {
1649 llist_del(&abbrev->list);
1654 if (argc >= 1 && !deleted) {
1655 vty_out(vty, "Given abbreviation '%s' not found!%s",
1656 argv[0], VTY_NEWLINE);
1663 static int config_write_dummy(struct vty *vty)
1668 /* per support config */
1669 DEFUN(cfg_ms_support, cfg_ms_support_cmd, "support",
1670 "Define supported features")
1672 vty->node = SUPPORT_NODE;
1677 #define SUP_EN(cfg, cfg_cmd, item, cmd, desc, restart) \
1678 DEFUN(cfg, cfg_cmd, cmd, "Enable " desc "support") \
1680 struct osmocom_ms *ms = vty->index; \
1681 struct gsm_settings *set = &ms->settings; \
1682 struct gsm_support *sup = &ms->support; \
1684 vty_out(vty, desc " not supported%s", VTY_NEWLINE); \
1686 return CMD_SUCCESS; \
1687 return CMD_WARNING; \
1690 vty_restart(vty, ms); \
1692 return CMD_SUCCESS; \
1695 #define SUP_DI(cfg, cfg_cmd, item, cmd, desc, restart) \
1696 DEFUN(cfg, cfg_cmd, "no " cmd, NO_STR "Disable " desc " support") \
1698 struct osmocom_ms *ms = vty->index; \
1699 struct gsm_settings *set = &ms->settings; \
1700 struct gsm_support *sup = &ms->support; \
1702 vty_out(vty, desc " not supported%s", VTY_NEWLINE); \
1704 return CMD_SUCCESS; \
1705 return CMD_WARNING; \
1708 vty_restart(vty, ms); \
1710 return CMD_SUCCESS; \
1713 #define SET_EN(cfg, cfg_cmd, item, cmd, desc, restart) \
1714 DEFUN(cfg, cfg_cmd, cmd, "Enable " desc "support") \
1716 struct osmocom_ms *ms = vty->index; \
1717 struct gsm_settings *set = &ms->settings; \
1719 vty_restart(vty, ms); \
1721 return CMD_SUCCESS; \
1724 #define SET_DI(cfg, cfg_cmd, item, cmd, desc, restart) \
1725 DEFUN(cfg, cfg_cmd, "no " cmd, NO_STR "Disable " desc " support") \
1727 struct osmocom_ms *ms = vty->index; \
1728 struct gsm_settings *set = &ms->settings; \
1730 vty_restart(vty, ms); \
1732 return CMD_SUCCESS; \
1735 SET_EN(cfg_ms_sup_dtmf, cfg_ms_sup_dtmf_cmd, cc_dtmf, "dtmf", "DTMF", 0);
1736 SET_DI(cfg_ms_sup_no_dtmf, cfg_ms_sup_no_dtmf_cmd, cc_dtmf, "dtmf", "DTMF", 0);
1737 SUP_EN(cfg_ms_sup_sms, cfg_ms_sup_sms_cmd, sms_ptp, "sms", "SMS", 0);
1738 SUP_DI(cfg_ms_sup_no_sms, cfg_ms_sup_no_sms_cmd, sms_ptp, "sms", "SMS", 0);
1739 SUP_EN(cfg_ms_sup_a5_1, cfg_ms_sup_a5_1_cmd, a5_1, "a5/1", "A5/1", 0);
1740 SUP_DI(cfg_ms_sup_no_a5_1, cfg_ms_sup_no_a5_1_cmd, a5_1, "a5/1", "A5/1", 0);
1741 SUP_EN(cfg_ms_sup_a5_2, cfg_ms_sup_a5_2_cmd, a5_2, "a5/2", "A5/2", 0);
1742 SUP_DI(cfg_ms_sup_no_a5_2, cfg_ms_sup_no_a5_2_cmd, a5_2, "a5/2", "A5/2", 0);
1743 SUP_EN(cfg_ms_sup_a5_3, cfg_ms_sup_a5_3_cmd, a5_3, "a5/3", "A5/3", 0);
1744 SUP_DI(cfg_ms_sup_no_a5_3, cfg_ms_sup_no_a5_3_cmd, a5_3, "a5/3", "A5/3", 0);
1745 SUP_EN(cfg_ms_sup_a5_4, cfg_ms_sup_a5_4_cmd, a5_4, "a5/4", "A5/4", 0);
1746 SUP_DI(cfg_ms_sup_no_a5_4, cfg_ms_sup_no_a5_4_cmd, a5_4, "a5/4", "A5/4", 0);
1747 SUP_EN(cfg_ms_sup_a5_5, cfg_ms_sup_a5_5_cmd, a5_5, "a5/5", "A5/5", 0);
1748 SUP_DI(cfg_ms_sup_no_a5_5, cfg_ms_sup_no_a5_5_cmd, a5_5, "a5/5", "A5/5", 0);
1749 SUP_EN(cfg_ms_sup_a5_6, cfg_ms_sup_a5_6_cmd, a5_6, "a5/6", "A5/6", 0);
1750 SUP_DI(cfg_ms_sup_no_a5_6, cfg_ms_sup_no_a5_6_cmd, a5_6, "a5/6", "A5/6", 0);
1751 SUP_EN(cfg_ms_sup_a5_7, cfg_ms_sup_a5_7_cmd, a5_7, "a5/7", "A5/7", 0);
1752 SUP_DI(cfg_ms_sup_no_a5_7, cfg_ms_sup_no_a5_7_cmd, a5_7, "a5/7", "A5/7", 1);
1753 SUP_EN(cfg_ms_sup_p_gsm, cfg_ms_sup_p_gsm_cmd, p_gsm, "p-gsm", "P-GSM (900)",
1755 SUP_DI(cfg_ms_sup_no_p_gsm, cfg_ms_sup_no_p_gsm_cmd, p_gsm, "p-gsm",
1757 SUP_EN(cfg_ms_sup_e_gsm, cfg_ms_sup_e_gsm_cmd, e_gsm, "e-gsm", "E-GSM (850)",
1759 SUP_DI(cfg_ms_sup_no_e_gsm, cfg_ms_sup_no_e_gsm_cmd, e_gsm, "e-gsm",
1761 SUP_EN(cfg_ms_sup_r_gsm, cfg_ms_sup_r_gsm_cmd, r_gsm, "r-gsm", "R-GSM (850)",
1763 SUP_DI(cfg_ms_sup_no_r_gsm, cfg_ms_sup_no_r_gsm_cmd, r_gsm, "r-gsm",
1765 SUP_EN(cfg_ms_sup_dcs, cfg_ms_sup_dcs_cmd, dcs, "dcs", "DCS (1800)", 0);
1766 SUP_DI(cfg_ms_sup_no_dcs, cfg_ms_sup_no_dcs_cmd, dcs, "dcs", "DCS (1800)", 0);
1768 DEFUN(cfg_ms_sup_class_900, cfg_ms_sup_class_900_cmd, "class-900 (1|2|3|4|5)",
1769 "Select power class for GSM 850/900\n"
1776 struct osmocom_ms *ms = vty->index;
1777 struct gsm_settings *set = &ms->settings;
1778 struct gsm_support *sup = &ms->support;
1780 set->class_900 = atoi(argv[0]);
1782 if (set->class_900 < sup->class_900 && !vty_reading)
1783 vty_out(vty, "You selected an higher class than supported "
1784 " by hardware!%s", VTY_NEWLINE);
1789 DEFUN(cfg_ms_sup_class_dcs, cfg_ms_sup_class_dcs_cmd, "class-dcs (1|2|3)",
1790 "Select power class for DCS 1800\n"
1795 struct osmocom_ms *ms = vty->index;
1796 struct gsm_settings *set = &ms->settings;
1797 struct gsm_support *sup = &ms->support;
1799 set->class_dcs = atoi(argv[0]);
1801 if (((set->class_dcs + 1) & 3) < ((sup->class_dcs + 1) & 3)
1803 vty_out(vty, "You selected an higher class than supported "
1804 " by hardware!%s", VTY_NEWLINE);
1809 DEFUN(cfg_ms_sup_ch_cap, cfg_ms_sup_ch_cap_cmd, "channel-capability "
1810 "(sdcch|sdcch+tchf|sdcch+tchf+tchh)",
1811 "Select channel capability\nSDCCH only\nSDCCH + TCH/F\nSDCCH + TCH/H")
1813 struct osmocom_ms *ms = vty->index;
1814 struct gsm_settings *set = &ms->settings;
1815 struct gsm_support *sup = &ms->support;
1818 if (!strcmp(argv[0], "sdcch+tchf+tchh"))
1819 ch_cap = GSM_CAP_SDCCH_TCHF_TCHH;
1820 else if (!strcmp(argv[0], "sdcch+tchf"))
1821 ch_cap = GSM_CAP_SDCCH_TCHF;
1823 ch_cap = GSM_CAP_SDCCH;
1825 if (ch_cap > sup->ch_cap && !vty_reading) {
1826 vty_out(vty, "You selected an higher capability than supported "
1827 " by hardware!%s", VTY_NEWLINE);
1831 if (ch_cap != set->ch_cap
1832 && (ch_cap == GSM_CAP_SDCCH || set->ch_cap == GSM_CAP_SDCCH))
1833 vty_restart(vty, ms);
1835 set->ch_cap = ch_cap;
1840 SUP_EN(cfg_ms_sup_full_v1, cfg_ms_sup_full_v1_cmd, full_v1, "full-speech-v1",
1841 "Full rate speech V1", 0);
1842 SUP_DI(cfg_ms_sup_no_full_v1, cfg_ms_sup_no_full_v1_cmd, full_v1,
1843 "full-speech-v1", "Full rate speech V1", 0);
1844 SUP_EN(cfg_ms_sup_full_v2, cfg_ms_sup_full_v2_cmd, full_v2, "full-speech-v2",
1845 "Full rate speech V2 (EFR)", 0);
1846 SUP_DI(cfg_ms_sup_no_full_v2, cfg_ms_sup_no_full_v2_cmd, full_v2,
1847 "full-speech-v2", "Full rate speech V2 (EFR)", 0);
1848 SUP_EN(cfg_ms_sup_full_v3, cfg_ms_sup_full_v3_cmd, full_v3, "full-speech-v3",
1849 "Full rate speech V3 (AMR)", 0);
1850 SUP_DI(cfg_ms_sup_no_full_v3, cfg_ms_sup_no_full_v3_cmd, full_v3,
1851 "full-speech-v3", "Full rate speech V3 (AMR)", 0);
1852 SUP_EN(cfg_ms_sup_half_v1, cfg_ms_sup_half_v1_cmd, half_v1, "half-speech-v1",
1853 "Half rate speech V1", 0);
1854 SUP_DI(cfg_ms_sup_no_half_v1, cfg_ms_sup_no_half_v1_cmd, half_v1,
1855 "half-speech-v1", "Half rate speech V1", 0);
1856 SUP_EN(cfg_ms_sup_half_v3, cfg_ms_sup_half_v3_cmd, half_v3, "half-speech-v3",
1857 "Half rate speech V3 (AMR)", 0);
1858 SUP_DI(cfg_ms_sup_no_half_v3, cfg_ms_sup_no_half_v3_cmd, half_v3,
1859 "half-speech-v3", "Half rate speech V3 (AMR)", 0);
1861 DEFUN(cfg_ms_sup_min_rxlev, cfg_ms_sup_min_rxlev_cmd, "min-rxlev <-110--47>",
1862 "Set the minimum receive level to select a cell\n"
1863 "Minimum receive level from -110 dBm to -47 dBm")
1865 struct osmocom_ms *ms = vty->index;
1866 struct gsm_settings *set = &ms->settings;
1868 set->min_rxlev_db = atoi(argv[0]);
1873 DEFUN(cfg_ms_sup_dsc_max, cfg_ms_sup_dsc_max_cmd, "dsc-max <90-500>",
1874 "Set the maximum DSC value. Standard is 90. Increase to make mobile "
1875 "more reliable against bad RX signal. This increase the propability "
1876 "of missing a paging requests\n"
1877 "DSC initial and maximum value (standard is 90)")
1879 struct osmocom_ms *ms = vty->index;
1880 struct gsm_settings *set = &ms->settings;
1882 set->dsc_max = atoi(argv[0]);
1887 /* per testsim config */
1888 DEFUN(cfg_ms_testsim, cfg_ms_testsim_cmd, "test-sim",
1889 "Configure test SIM emulation")
1891 vty->node = TESTSIM_NODE;
1896 DEFUN(cfg_test_imsi, cfg_test_imsi_cmd, "imsi IMSI",
1897 "Set IMSI on test card\n15 digits IMSI")
1899 struct osmocom_ms *ms = vty->index;
1900 struct gsm_settings *set = &ms->settings;
1901 char *error = gsm_check_imsi(argv[0]);
1904 vty_out(vty, "%s%s", error, VTY_NEWLINE);
1908 strcpy(set->test_imsi, argv[0]);
1910 vty_restart(vty, ms);
1914 #define HEX_STR "\nByte as two digits hexadecimal"
1915 DEFUN(cfg_test_ki_xor, cfg_test_ki_xor_cmd, "ki xor HEX HEX HEX HEX HEX HEX "
1916 "HEX HEX HEX HEX HEX HEX",
1917 "Set Key (Kc) on test card\nUse XOR algorithm" HEX_STR HEX_STR HEX_STR
1918 HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR)
1920 struct osmocom_ms *ms = vty->index;
1921 struct gsm_settings *set = &ms->settings;
1926 for (i = 0; i < 12; i++) {
1928 if (!strncmp(p, "0x", 2))
1930 if (strlen(p) != 2) {
1931 vty_out(vty, "Expecting two digits hex value (with or "
1932 "without 0x in front)%s", VTY_NEWLINE);
1935 ki[i] = strtoul(p, NULL, 16);
1938 set->test_ki_type = GSM_SIM_KEY_XOR;
1939 memcpy(set->test_ki, ki, 12);
1943 DEFUN(cfg_test_ki_comp128, cfg_test_ki_comp128_cmd, "ki comp128 HEX HEX HEX "
1944 "HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX HEX",
1945 "Set Key (Kc) on test card\nUse XOR algorithm" HEX_STR HEX_STR HEX_STR
1946 HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR HEX_STR
1947 HEX_STR HEX_STR HEX_STR HEX_STR)
1949 struct osmocom_ms *ms = vty->index;
1950 struct gsm_settings *set = &ms->settings;
1955 for (i = 0; i < 16; i++) {
1957 if (!strncmp(p, "0x", 2))
1959 if (strlen(p) != 2) {
1960 vty_out(vty, "Expecting two digits hex value (with or "
1961 "without 0x in front)%s", VTY_NEWLINE);
1964 ki[i] = strtoul(p, NULL, 16);
1967 set->test_ki_type = GSM_SIM_KEY_COMP128;
1968 memcpy(set->test_ki, ki, 16);
1972 DEFUN(cfg_test_barr, cfg_test_barr_cmd, "barred-access",
1973 "Allow access to barred cells")
1975 struct osmocom_ms *ms = vty->index;
1976 struct gsm_settings *set = &ms->settings;
1983 DEFUN(cfg_test_no_barr, cfg_test_no_barr_cmd, "no barred-access",
1984 NO_STR "Deny access to barred cells")
1986 struct osmocom_ms *ms = vty->index;
1987 struct gsm_settings *set = &ms->settings;
1994 DEFUN(cfg_test_no_rplmn, cfg_test_no_rplmn_cmd, "no rplmn",
1995 NO_STR "Unset Registered PLMN")
1997 struct osmocom_ms *ms = vty->index;
1998 struct gsm_settings *set = &ms->settings;
2000 set->test_rplmn_valid = 0;
2002 vty_restart(vty, ms);
2006 DEFUN(cfg_test_rplmn, cfg_test_rplmn_cmd, "rplmn MCC MNC",
2007 "Set Registered PLMN\nMobile Country Code\nMobile Network Code")
2009 struct osmocom_ms *ms = vty->index;
2010 struct gsm_settings *set = &ms->settings;
2011 uint16_t mcc = gsm_input_mcc((char *)argv[0]),
2012 mnc = gsm_input_mnc((char *)argv[1]);
2015 vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
2019 vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
2022 set->test_rplmn_valid = 1;
2023 set->test_rplmn_mcc = mcc;
2024 set->test_rplmn_mnc = mnc;
2026 vty_restart(vty, ms);
2030 DEFUN(cfg_test_hplmn, cfg_test_hplmn_cmd, "hplmn-search (everywhere|foreign-country)",
2031 "Set Home PLMN search mode\n"
2032 "Search for HPLMN when on any other network\n"
2033 "Search for HPLMN when in a different country")
2035 struct osmocom_ms *ms = vty->index;
2036 struct gsm_settings *set = &ms->settings;
2038 switch (argv[0][0]) {
2040 set->test_always = 1;
2043 set->test_always = 0;
2047 vty_restart(vty, ms);
2051 DEFUN(cfg_no_shutdown, cfg_ms_no_shutdown_cmd, "no shutdown",
2052 NO_STR "Activate and run MS")
2054 struct osmocom_ms *ms = vty->index, *tmp;
2057 if (ms->shutdown != 2)
2060 llist_for_each_entry(tmp, &ms_list, entity) {
2061 if (tmp->shutdown == 2)
2063 if (!strcmp(ms->settings.layer2_socket_path,
2064 tmp->settings.layer2_socket_path)) {
2065 vty_out(vty, "Cannot start MS '%s', because MS '%s' "
2066 "use the same layer2-socket.%sPlease shutdown "
2067 "MS '%s' first.%s", ms->name, tmp->name,
2068 VTY_NEWLINE, tmp->name, VTY_NEWLINE);
2071 if (!strcmp(ms->settings.sap_socket_path,
2072 tmp->settings.sap_socket_path)) {
2073 vty_out(vty, "Cannot start MS '%s', because MS '%s' "
2074 "use the same sap-socket.%sPlease shutdown "
2075 "MS '%s' first.%s", ms->name, tmp->name,
2076 VTY_NEWLINE, tmp->name, VTY_NEWLINE);
2081 rc = l23_app_init(ms);
2083 vty_out(vty, "Connection to layer 1 failed!%s",
2091 DEFUN(cfg_shutdown, cfg_ms_shutdown_cmd, "shutdown",
2092 "Shut down and deactivate MS")
2094 struct osmocom_ms *ms = vty->index;
2096 if (ms->shutdown == 0)
2097 l23_app_exit(ms, 0);
2102 DEFUN(cfg_shutdown_force, cfg_ms_shutdown_force_cmd, "shutdown force",
2103 "Shut down and deactivate MS\nDo not perform IMSI detach")
2105 struct osmocom_ms *ms = vty->index;
2107 if (ms->shutdown <= 1)
2108 l23_app_exit(ms, 1);
2113 enum node_type ms_vty_go_parent(struct vty *vty)
2115 switch (vty->node) {
2117 vty->node = CONFIG_NODE;
2122 vty->node = MS_NODE;
2125 vty->node = CONFIG_NODE;
2131 /* Down vty node level. */
2132 gDEFUN(ournode_exit,
2133 ournode_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
2135 switch (vty->node) {
2137 vty->node = CONFIG_NODE;
2142 vty->node = MS_NODE;
2150 /* End of configuration. */
2152 ournode_end_cmd, "end", "End current mode and change to enable mode.")
2154 switch (vty->node) {
2157 /* Nothing to do. */
2164 vty_config_unlock(vty);
2165 vty->node = ENABLE_NODE;
2167 vty->index_sub = NULL;
2175 DEFUN(off, off_cmd, "off",
2176 "Turn mobiles off (shutdown) and exit")
2178 dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
2183 #define SUP_NODE(item) \
2184 install_element(SUPPORT_NODE, &cfg_ms_sup_item_cmd);
2186 int ms_vty_init(void)
2188 install_element_ve(&show_ms_cmd);
2189 install_element_ve(&show_subscr_cmd);
2190 install_element_ve(&show_support_cmd);
2191 install_element_ve(&show_states_cmd);
2192 install_element_ve(&show_cell_cmd);
2193 install_element_ve(&show_cell_si_cmd);
2194 install_element_ve(&show_ba_cmd);
2195 install_element_ve(&show_forb_la_cmd);
2196 install_element_ve(&show_forb_plmn_cmd);
2197 install_element_ve(&monitor_network_cmd);
2198 install_element_ve(&no_monitor_network_cmd);
2199 install_element(ENABLE_NODE, &off_cmd);
2201 install_element(ENABLE_NODE, &sim_test_cmd);
2202 install_element(ENABLE_NODE, &sim_reader_cmd);
2203 install_element(ENABLE_NODE, &sim_remove_cmd);
2204 install_element(ENABLE_NODE, &sim_pin_cmd);
2205 install_element(ENABLE_NODE, &sim_disable_pin_cmd);
2206 install_element(ENABLE_NODE, &sim_enable_pin_cmd);
2207 install_element(ENABLE_NODE, &sim_change_pin_cmd);
2208 install_element(ENABLE_NODE, &sim_unblock_pin_cmd);
2209 install_element(ENABLE_NODE, &sim_lai_cmd);
2210 install_element(ENABLE_NODE, &network_search_cmd);
2211 install_element(ENABLE_NODE, &network_show_cmd);
2212 install_element(ENABLE_NODE, &network_select_cmd);
2213 install_element(ENABLE_NODE, &call_cmd);
2214 install_element(ENABLE_NODE, &call_retr_cmd);
2215 install_element(ENABLE_NODE, &call_dtmf_cmd);
2217 install_element(CONFIG_NODE, &cfg_gps_device_cmd);
2218 install_element(CONFIG_NODE, &cfg_gps_baud_cmd);
2219 install_element(CONFIG_NODE, &cfg_gps_enable_cmd);
2220 install_element(CONFIG_NODE, &cfg_no_gps_enable_cmd);
2222 install_element(CONFIG_NODE, &cfg_ms_cmd);
2223 install_element(CONFIG_NODE, &cfg_ms_create_cmd);
2224 install_element(CONFIG_NODE, &cfg_ms_rename_cmd);
2225 install_element(CONFIG_NODE, &cfg_no_ms_cmd);
2226 install_element(CONFIG_NODE, &ournode_end_cmd);
2227 install_node(&ms_node, config_write_ms);
2228 install_default(MS_NODE);
2229 install_element(MS_NODE, &ournode_exit_cmd);
2230 install_element(MS_NODE, &ournode_end_cmd);
2231 install_element(MS_NODE, &cfg_ms_layer2_cmd);
2232 install_element(MS_NODE, &cfg_ms_sap_cmd);
2233 install_element(MS_NODE, &cfg_ms_sim_cmd);
2234 install_element(MS_NODE, &cfg_ms_mode_cmd);
2235 install_element(MS_NODE, &cfg_ms_imei_cmd);
2236 install_element(MS_NODE, &cfg_ms_imei_fixed_cmd);
2237 install_element(MS_NODE, &cfg_ms_imei_random_cmd);
2238 install_element(MS_NODE, &cfg_ms_no_emerg_imsi_cmd);
2239 install_element(MS_NODE, &cfg_ms_emerg_imsi_cmd);
2240 install_element(MS_NODE, &cfg_ms_cw_cmd);
2241 install_element(MS_NODE, &cfg_ms_no_cw_cmd);
2242 install_element(MS_NODE, &cfg_ms_auto_answer_cmd);
2243 install_element(MS_NODE, &cfg_ms_no_auto_answer_cmd);
2244 install_element(MS_NODE, &cfg_ms_clip_cmd);
2245 install_element(MS_NODE, &cfg_ms_clir_cmd);
2246 install_element(MS_NODE, &cfg_ms_no_clip_cmd);
2247 install_element(MS_NODE, &cfg_ms_no_clir_cmd);
2248 install_element(MS_NODE, &cfg_ms_tx_power_cmd);
2249 install_element(MS_NODE, &cfg_ms_tx_power_val_cmd);
2250 install_element(MS_NODE, &cfg_ms_sim_delay_cmd);
2251 install_element(MS_NODE, &cfg_ms_no_sim_delay_cmd);
2252 install_element(MS_NODE, &cfg_ms_stick_cmd);
2253 install_element(MS_NODE, &cfg_ms_no_stick_cmd);
2254 install_element(MS_NODE, &cfg_ms_lupd_cmd);
2255 install_element(MS_NODE, &cfg_ms_no_lupd_cmd);
2256 install_element(MS_NODE, &cfg_ms_codec_full_cmd);
2257 install_element(MS_NODE, &cfg_ms_codec_full_pref_cmd);
2258 install_element(MS_NODE, &cfg_ms_codec_half_cmd);
2259 install_element(MS_NODE, &cfg_ms_codec_half_pref_cmd);
2260 install_element(MS_NODE, &cfg_ms_no_codec_half_cmd);
2261 install_element(MS_NODE, &cfg_ms_abbrev_cmd);
2262 install_element(MS_NODE, &cfg_ms_no_abbrev_cmd);
2263 install_element(MS_NODE, &cfg_ms_testsim_cmd);
2264 install_element(MS_NODE, &cfg_ms_support_cmd);
2265 install_node(&support_node, config_write_dummy);
2266 install_default(SUPPORT_NODE);
2267 install_element(SUPPORT_NODE, &ournode_exit_cmd);
2268 install_element(SUPPORT_NODE, &ournode_end_cmd);
2269 install_element(SUPPORT_NODE, &cfg_ms_sup_dtmf_cmd);
2270 install_element(SUPPORT_NODE, &cfg_ms_sup_no_dtmf_cmd);
2271 install_element(SUPPORT_NODE, &cfg_ms_sup_sms_cmd);
2272 install_element(SUPPORT_NODE, &cfg_ms_sup_no_sms_cmd);
2273 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_1_cmd);
2274 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_1_cmd);
2275 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_2_cmd);
2276 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_2_cmd);
2277 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_3_cmd);
2278 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_3_cmd);
2279 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_4_cmd);
2280 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_4_cmd);
2281 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_5_cmd);
2282 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_5_cmd);
2283 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_6_cmd);
2284 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_6_cmd);
2285 install_element(SUPPORT_NODE, &cfg_ms_sup_a5_7_cmd);
2286 install_element(SUPPORT_NODE, &cfg_ms_sup_no_a5_7_cmd);
2287 install_element(SUPPORT_NODE, &cfg_ms_sup_p_gsm_cmd);
2288 install_element(SUPPORT_NODE, &cfg_ms_sup_no_p_gsm_cmd);
2289 install_element(SUPPORT_NODE, &cfg_ms_sup_e_gsm_cmd);
2290 install_element(SUPPORT_NODE, &cfg_ms_sup_no_e_gsm_cmd);
2291 install_element(SUPPORT_NODE, &cfg_ms_sup_r_gsm_cmd);
2292 install_element(SUPPORT_NODE, &cfg_ms_sup_no_r_gsm_cmd);
2293 install_element(SUPPORT_NODE, &cfg_ms_sup_dcs_cmd);
2294 install_element(SUPPORT_NODE, &cfg_ms_sup_no_dcs_cmd);
2295 install_element(SUPPORT_NODE, &cfg_ms_sup_class_900_cmd);
2296 install_element(SUPPORT_NODE, &cfg_ms_sup_class_dcs_cmd);
2297 install_element(SUPPORT_NODE, &cfg_ms_sup_ch_cap_cmd);
2298 install_element(SUPPORT_NODE, &cfg_ms_sup_full_v1_cmd);
2299 install_element(SUPPORT_NODE, &cfg_ms_sup_no_full_v1_cmd);
2300 install_element(SUPPORT_NODE, &cfg_ms_sup_full_v2_cmd);
2301 install_element(SUPPORT_NODE, &cfg_ms_sup_no_full_v2_cmd);
2302 install_element(SUPPORT_NODE, &cfg_ms_sup_full_v3_cmd);
2303 install_element(SUPPORT_NODE, &cfg_ms_sup_no_full_v3_cmd);
2304 install_element(SUPPORT_NODE, &cfg_ms_sup_half_v1_cmd);
2305 install_element(SUPPORT_NODE, &cfg_ms_sup_no_half_v1_cmd);
2306 install_element(SUPPORT_NODE, &cfg_ms_sup_half_v3_cmd);
2307 install_element(SUPPORT_NODE, &cfg_ms_sup_no_half_v3_cmd);
2308 install_element(SUPPORT_NODE, &cfg_ms_sup_min_rxlev_cmd);
2309 install_element(SUPPORT_NODE, &cfg_ms_sup_dsc_max_cmd);
2310 install_node(&testsim_node, config_write_dummy);
2311 install_default(TESTSIM_NODE);
2312 install_element(TESTSIM_NODE, &ournode_exit_cmd);
2313 install_element(TESTSIM_NODE, &ournode_end_cmd);
2314 install_element(TESTSIM_NODE, &cfg_test_imsi_cmd);
2315 install_element(TESTSIM_NODE, &cfg_test_ki_xor_cmd);
2316 install_element(TESTSIM_NODE, &cfg_test_ki_comp128_cmd);
2317 install_element(TESTSIM_NODE, &cfg_test_barr_cmd);
2318 install_element(TESTSIM_NODE, &cfg_test_no_barr_cmd);
2319 install_element(TESTSIM_NODE, &cfg_test_no_rplmn_cmd);
2320 install_element(TESTSIM_NODE, &cfg_test_rplmn_cmd);
2321 install_element(TESTSIM_NODE, &cfg_test_hplmn_cmd);
2322 install_element(MS_NODE, &cfg_ms_shutdown_cmd);
2323 install_element(MS_NODE, &cfg_ms_shutdown_force_cmd);
2324 install_element(MS_NODE, &cfg_ms_no_shutdown_cmd);
2329 void vty_notify(struct osmocom_ms *ms, const char *fmt, ...)
2331 struct telnet_connection *connection;
2337 va_start(args, fmt);
2338 vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
2339 buffer[sizeof(buffer) - 1] = '\0';
2346 llist_for_each_entry(connection, &active_connections, entry) {
2347 vty = connection->vty;
2351 vty_out(vty, "%s%% (MS %s)%s", VTY_NEWLINE, ms->name,
2355 if (buffer[strlen(buffer) - 1] == '\n') {
2356 buffer[strlen(buffer) - 1] = '\0';
2357 vty_out(vty, "%% %s%s", buffer, VTY_NEWLINE);
2358 buffer[strlen(buffer)] = '\n';
2360 vty_out(vty, "%% %s", buffer);