Refactoring validity check and prefix processing of dialed number
Command line help shows how many digits and what prefixes can be dialed. Giving a station ID via command line will be checked for being valid. The number to call the mobile statione will be checked for being valid. Prefixes that are defined for a nework will be removed from station ID automatically. Multiple station ID lengths are supported: * C-Netz: 7 or 8 digits, depending on area code length * A-Netz: 5 or 7 digits; number is truncated to last 5 digits. * IMTS/MTS: 5 or 7 digits, depending on phone's selector switch.
This commit is contained in:
@@ -93,8 +93,7 @@ void print_help(const char *arg0)
|
||||
printf(" Message Service Center). (default = '%s')\n", smsc_number);
|
||||
printf(" -I --caller-id 1 | 0\n");
|
||||
printf(" If set, the caller ID is sent while ringing the phone. (default = '%d')\n", send_callerid);
|
||||
printf("\nstation-id: Give 7 digits of station-id, you don't need to enter it\n");
|
||||
printf(" for every start of this program.\n");
|
||||
main_mobile_print_station_id();
|
||||
main_mobile_print_hotkeys();
|
||||
}
|
||||
|
||||
@@ -258,6 +257,11 @@ int submit_sms(const char *sms)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct number_lengths number_lengths[] = {
|
||||
{ 7, "NMT number (1st digit country code)" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, argi;
|
||||
@@ -269,7 +273,8 @@ int main(int argc, char *argv[])
|
||||
init_nmt_tones();
|
||||
init_announcement();
|
||||
|
||||
main_mobile_init();
|
||||
/* init mobile interface */
|
||||
main_mobile_init("0123456789", number_lengths, NULL, NULL);
|
||||
|
||||
/* handle options / config file */
|
||||
add_options();
|
||||
@@ -282,10 +287,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argi < argc) {
|
||||
station_id = argv[argi];
|
||||
if (strlen(station_id) != 7) {
|
||||
printf("Given station ID '%s' does not have 7 digits\n", station_id);
|
||||
return 0;
|
||||
}
|
||||
rc = main_mobile_number_ask(station_id, "station ID");
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!num_kanal) {
|
||||
@@ -407,7 +411,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
nmt_check_channels(nmt_system);
|
||||
|
||||
main_mobile("nmt", &quit, myhandler, station_id, 7);
|
||||
main_mobile_loop("nmt", &quit, myhandler, station_id);
|
||||
|
||||
fail:
|
||||
/* fifo */
|
||||
|
@@ -1712,22 +1712,16 @@ int _out_setup(int callref, const char *caller_id, enum number_type caller_type,
|
||||
{
|
||||
sender_t *sender;
|
||||
nmt_t *nmt;
|
||||
int i;
|
||||
nmt_subscriber_t subscr;
|
||||
transaction_t *trans;
|
||||
|
||||
memset(&subscr, 0, sizeof(subscr));
|
||||
|
||||
/* 1. check if number is invalid, return INVALNUMBER */
|
||||
/* 1. split number into country and subscriber parts */
|
||||
if (dialstring2number(dialing, &subscr.country, subscr.number)) {
|
||||
inval:
|
||||
PDEBUG(DNMT, DEBUG_NOTICE, "Outgoing call to invalid number '%s', rejecting!\n", dialing);
|
||||
return -CAUSE_INVALNUMBER;
|
||||
}
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (subscr.number[i] < '0' || subscr.number[i] > '9')
|
||||
goto inval;
|
||||
}
|
||||
|
||||
/* 2. check if given number is already in a call, return BUSY */
|
||||
trans = get_transaction_by_number(&subscr);
|
||||
|
Reference in New Issue
Block a user