Index: chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.119 diff -u -r1.119 chan_zap.c --- chan_zap.c 5 Nov 2003 22:32:20 -0000 1.119 +++ chan_zap.c 6 Nov 2003 01:00:22 -0000 @@ -130,6 +130,8 @@ #define CHAN_PSEUDO -2 static char context[AST_MAX_EXTENSION] = "default"; +static char dnid1[AST_MAX_EXTENSION] = "s"; /* preserve old behaviour if dnid not configured */ +static char dnid2[AST_MAX_EXTENSION] = "s"; static char callerid[256] = ""; static char language[MAX_LANGUAGE] = ""; @@ -367,6 +369,8 @@ struct zt_pvt *next; /* Next channel in list */ struct zt_pvt *prev; /* Prev channel in list */ char context[AST_MAX_EXTENSION]; + char dnid1[AST_MAX_EXTENSION]; + char dnid2[AST_MAX_EXTENSION]; char exten[AST_MAX_EXTENSION]; char language[MAX_LANGUAGE]; char musicclass[MAX_LANGUAGE]; @@ -4354,6 +4358,10 @@ case SIG_FXSLS: case SIG_FXSGS: case SIG_FXSKS: + /* + Allow us to hard code the extension using dnid in the config file + */ + strncpy(exten, p->dnid1, sizeof(exten)-1); if (p->use_callerid) { cs = callerid_new(); if (cs) { @@ -4374,6 +4382,11 @@ if (i & ZT_IOMUX_SIGEVENT) { res = zt_get_event(p->subs[index].zfd); ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res)); + /* + Since we got a distinctive ring, fill in the + extension for our second number + */ + strncpy(exten, p->dnid2, sizeof(exten)-1); res = 0; /* Let us detect callerid when the telco uses distinctive ring */ if (p->ringt < RINGT/2) @@ -4440,12 +4453,30 @@ chan->rings = 1; p->ringt = RINGT; zt_enable_ec(p); - res = ast_pbx_run(chan); - if (res) { + if (ast_exists_extension(chan, chan->context, exten, 1, chan->callerid)) { + strncpy(chan->exten, exten, sizeof(chan->exten)-1); + res = ast_pbx_run(chan); + if (res) { + ast_log(LOG_WARNING, "PBX exited non-zero\n"); + res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION); + } + return NULL; + } else { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_2 "Unknown extension '%s' in context '%s' requested\n", exten, chan->context); + sleep(2); + res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_INFO); + if (res < 0) + ast_log(LOG_WARNING, "Unable to start special tone on %d\n", p->channel); + else + sleep(1); + res = ast_streamfile(chan, "ss-noservice", chan->language); + if (res >= 0) + ast_waitstream(chan, ""); + res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION); ast_hangup(chan); - ast_log(LOG_WARNING, "PBX exited non-zero\n"); + return NULL; } - return NULL; default: ast_log(LOG_WARNING, "Don't know how to handle simple switch with signalling %s on channel %d\n", sig2str(p->sig), p->channel); res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION); @@ -5222,6 +5253,8 @@ strncpy(tmp->musicclass, musicclass, sizeof(tmp->musicclass)-1); strncpy(tmp->context, context, sizeof(tmp->context)-1); strncpy(tmp->callerid, callerid, sizeof(tmp->callerid)-1); + strncpy(tmp->dnid1, dnid1, sizeof(tmp->dnid1)-1); + strncpy(tmp->dnid2, dnid2, sizeof(tmp->dnid2)-1); strncpy(tmp->mailbox, mailbox, sizeof(tmp->mailbox)-1); tmp->msgstate = -1; tmp->group = cur_group; @@ -6596,6 +6629,8 @@ ast_cli(fd, "Extension: %s\n", tmp->exten); ast_cli(fd, "Context: %s\n", tmp->context); ast_cli(fd, "Caller ID string: %s\n", tmp->callerid); + ast_cli(fd, "First DNID: %s\n", tmp->dnid1); + ast_cli(fd, "Second DNID: %s\n", tmp->dnid2); ast_cli(fd, "Destroy: %d\n", tmp->destroy); ast_cli(fd, "Signalling Type: %s\n", sig2str(tmp->sig)); ast_cli(fd, "Owner: %s\n", tmp->owner ? tmp->owner->name : ""); @@ -6833,6 +6868,10 @@ callwaitingcallerid = ast_true(v->value); } else if (!strcasecmp(v->name, "context")) { strncpy(context, v->value, sizeof(context)-1); + } else if (!strcasecmp(v->name, "dnid1")) { + strncpy(dnid1, v->value, sizeof(dnid1)-1); + } else if (!strcasecmp(v->name, "dnid2")) { + strncpy(dnid2, v->value, sizeof(dnid2)-1); } else if (!strcasecmp(v->name, "language")) { strncpy(language, v->value, sizeof(language)-1); } else if (!strcasecmp(v->name, "musiconhold")) { @@ -7162,6 +7201,8 @@ /* Some crap that needs to be reinitialized on the reload */ strcpy(context, "default"); + dnid1[0] = '\0'; + dnid2[0] = '\0'; language[0] = '\0'; musicclass[0] = '\0'; use_callerid = 1; @@ -7300,6 +7341,10 @@ callwaitingcallerid = ast_true(v->value); } else if (!strcasecmp(v->name, "context")) { strncpy(context, v->value, sizeof(context)-1); + } else if (!strcasecmp(v->name, "dnid1")) { + strncpy(dnid1, v->value, sizeof(dnid1)-1); + } else if (!strcasecmp(v->name, "dnid2")) { + strncpy(dnid2, v->value, sizeof(dnid2)-1); } else if (!strcasecmp(v->name, "language")) { strncpy(language, v->value, sizeof(language)-1); } else if (!strcasecmp(v->name, "musiconhold")) {