Dilceu, são muitos números que você quer bloquear? Se não poderia fazer com o próprio DB do asterisk, acredito que será mais prático...
2009/11/26 Dilceu Pazinatto <[email protected]> > Olá Pessoal, > > Peço ajuda novamente para o meu problema com ação por numero de origem > (${CALLERID(num)}). Estou fazendo uma consulta no mysql para ver se o > numero existe ou não, se retornar 0, chamada deve entrar, se voltar > diferente de 0, deve dar um playback e um hangup. Nos meus testes, que > tem o numero na tabela (mysql retorna 1), da o playback e desliga > normal, beleza. porém quando o numero não existe (mysql retorna 0), nao > volta para fazer o dial para o dgv/g2. Abaixo o meu extensions.ael, > saidas do CLI e retorno do mysql nos dois casos. > > Se alguém puder me dar uma dica de onde estou errado.... > > Grato > > Dilceu > > > > Chamada de entrada pelo DGV/g1 para DGV/g2 contexto vem-pstn > > extensions.ael > > globals { > SAIDAE1=DGV; > GRUPO1=g1; > GRUPO2=g2; > } > > macro externas (TERMINACAO, DESTINO) { > Set(ORIGEM=${CALLERID(num)}); > &proibidos (${ORIGEM}); > Dial(${TERMINACAO}${DESTINO},,tT); > Return; > > } > > macro proibidos (ORIGEM) { > > MYSQL (Connect connid localhost USUARIO SENHA proibidos); > MYSQL (Query resultid ${connid} SELECT count(callerid) FROM > telefones where callerid = '${ORIGEM}'); > MYSQL (Fetch fetchid ${resultid} ACHOU); > MYSQL (Clear ${fetchid}); > MYSQL (Clear ${resultid}); > MYSQL (Disconnect ${connid}); > MYSQL (Clear ${connid}); > if (${ACHOU} > 0) { > PlayBack (invalid); > HangUp; > } > Return; > } > > > > context vem-pstn { > includes { > parkedcalls; > } > > _80XX => { > &externas(${SAIDAE1}/${GRUPO2},${EXTEN}); > HangUp; > } > } > > > SAIDAS DE CONSOLE > > > CHAMADA COM ORIGEM DE UM NUMERO QUE DEVE SER PERMITIDO. (4988178028) > > > -- Ringing on port 3 - callstate=0 > -- Answering port 3 > -- Executing [8...@vem-pstn:1] Macro("DGV/3", > "externas|DGV/g2|8023") in new stack > -- Executing [...@macro-externas:1] Set("DGV/3", "TERMINACAO=DGV/g2") > in new stack > -- Executing [...@macro-externas:2] Set("DGV/3", "DESTINO=8023") in > new stack > -- Executing [...@macro-externas:3] Set("DGV/3", "ORIGEM=4988178028") > in new stack > -- Executing [...@macro-externas:4] Macro("DGV/3", > "proibidos|4988178028") in new stack > -- Executing [...@macro-proibidos:1] Set("DGV/3", "ORIGEM=4988178028") > in new stack > -- Executing [...@macro-proibidos:2] MYSQL("DGV/3", "Connect connid > localhost USUARIO SENHA proibidos") in new stack > -- Executing [...@macro-proibidos:3] MYSQL("DGV/3", "Query resultid 1 > SELECT count(callerid) FROM telefones where callerid = '4988178028'") in > new stack > -- Executing [...@macro-proibidos:4] MYSQL("DGV/3", "Fetch fetchid 2 > ACHOU") in new stack > -- Executing [...@macro-proibidos:5] MYSQL("DGV/3", "Clear 1") in new > stack > [Nov 26 00:08:43] WARNING[19579]: app_addon_sql_mysql.c:180 > find_identifier: Identifier 1, identifier_type 2 not found in identifier > list > [Nov 26 00:08:43] WARNING[19579]: app_addon_sql_mysql.c:420 > aMYSQL_clear: Invalid result identifier 1 passed in aMYSQL_clear > -- Executing [...@macro-proibidos:6] MYSQL("DGV/3", "Clear 2") in new > stack > -- Executing [...@macro-proibidos:7] MYSQL("DGV/3", "Disconnect 1") in > new stack > -- Executing [...@macro-proibidos:8] MYSQL("DGV/3", "Clear 1") in new > stack > [Nov 26 00:08:43] WARNING[19579]: app_addon_sql_mysql.c:180 > find_identifier: Identifier 1, identifier_type 2 not found in identifier > list > [Nov 26 00:08:43] WARNING[19579]: app_addon_sql_mysql.c:420 > aMYSQL_clear: Invalid result identifier 1 passed in aMYSQL_clear > -- Executing [...@macro-proibidos:9] GotoIf("DGV/3", "0?10:12") in new > stack > -- Goto (macro-proibidos,s,12) > -- Executing [...@macro-proibidos:12] NoOp("DGV/3", "Finish > if-proibidos-17") in new stack > -- Executing [...@macro-proibidos:13] Return("DGV/3", "") in new stack > [Nov 26 00:08:43] ERROR[19579]: app_stack.c:86 return_exec: Return > without Gosub: stack is empty > == Spawn extension (vem-pstn, 8023, 1) exited non-zero on 'DGV/3' > [Nov 26 00:08:43] NOTICE[19579]: chan_dgv.c:14951 dgv_hangup: Calling > dg_HangUp on port 3 > gw-voz-coperio*CLI> > > SAIDA CONSOLE MYSQL > 091126 00:08:42 38 Connect r...@localhost on proibidos > 38 Query SELECT count(callerid) FROM > telefones where callerid = '4988178028' > 38 Quit > > Resultado do mysql digitando o comando na linha: > > mysql> SELECT count(callerid) FROM telefones where callerid = > '4988178028'; > +-----------------+ > | count(callerid) | > +-----------------+ > | 0 | > +-----------------+ > 1 row in set (0.00 sec) > > > > > > CHAMADA DE UM NUMERO QUE DEVE SER NEGADO > > -- Ringing on port 4 - callstate=0 > -- Answering port 4 > -- Executing [8...@vem-pstn:1] Macro("DGV/4", > "externas|DGV/g2|8023") in new stack > -- Executing [...@macro-externas:1] Set("DGV/4", "TERMINACAO=DGV/g2") > in new stack > -- Executing [...@macro-externas:2] Set("DGV/4", "DESTINO=8023") in > new stack > -- Executing [...@macro-externas:3] Set("DGV/4", "ORIGEM=4935223153") > in new stack > -- Executing [...@macro-externas:4] Macro("DGV/4", > "proibidos|4935223153") in new stack > -- Executing [...@macro-proibidos:1] Set("DGV/4", "ORIGEM=4935223153") > in new stack > -- Executing [...@macro-proibidos:2] MYSQL("DGV/4", "Connect connid > localhost USUARIO SENHA proibidos") in new stack > -- Executing [...@macro-proibidos:3] MYSQL("DGV/4", "Query resultid 1 > SELECT count(callerid) FROM telefones where callerid = '4935223153'") in > new stack > -- Executing [...@macro-proibidos:4] MYSQL("DGV/4", "Fetch fetchid 2 > ACHOU") in new stack > -- Executing [...@macro-proibidos:5] MYSQL("DGV/4", "Clear 1") in new > stack > [Nov 26 00:10:11] WARNING[19595]: app_addon_sql_mysql.c:180 > find_identifier: Identifier 1, identifier_type 2 not found in identifier > list > [Nov 26 00:10:11] WARNING[19595]: app_addon_sql_mysql.c:420 > aMYSQL_clear: Invalid result identifier 1 passed in aMYSQL_clear > -- Executing [...@macro-proibidos:6] MYSQL("DGV/4", "Clear 2") in new > stack > -- Executing [...@macro-proibidos:7] MYSQL("DGV/4", "Disconnect 1") in > new stack > -- Executing [...@macro-proibidos:8] MYSQL("DGV/4", "Clear 1") in new > stack > [Nov 26 00:10:11] WARNING[19595]: app_addon_sql_mysql.c:180 > find_identifier: Identifier 1, identifier_type 2 not found in identifier > list > [Nov 26 00:10:11] WARNING[19595]: app_addon_sql_mysql.c:420 > aMYSQL_clear: Invalid result identifier 1 passed in aMYSQL_clear > -- Executing [...@macro-proibidos:9] GotoIf("DGV/4", "1?10:12") in new > stack > -- Goto (macro-proibidos,s,10) > -- Executing [...@macro-proibidos:10] Playback("DGV/4", "invalid") in > new stack > -- <DGV/4> Playing 'invalid' (language 'pt_BR') > Really destroying SIP dialog > '[email protected]' Method: OPTIONS > [Nov 26 00:10:12] NOTICE[2768]: chan_dgv.c:11956 event_handler: > dialplan_echo_thread Created(3) - port 4 > == Spawn extension (vem-pstn, 8023, 1) exited non-zero on 'DGV/4' > [Nov 26 00:10:14] NOTICE[19595]: chan_dgv.c:14951 dgv_hangup: Calling > dg_HangUp on port 4 > Really destroying SIP dialog > '[email protected]' Method: OPTIONS > gw-voz-coperio*CLI> > > SAIDA CONSOLE MYSQL > 091126 00:10:14 39 Connect r...@localhost on proibidos > 39 Query SELECT count(callerid) FROM > telefones where callerid = '4935223153' > 39 Quit > > > Resultado do mysql digitando o comando na linha: > > mysql> SELECT count(callerid) FROM telefones where callerid = > '4935223153'; > +-----------------+ > | count(callerid) | > +-----------------+ > | 1 | > +-----------------+ > 1 row in set (0.00 sec) > > Estrutura da tabela proibidos: > > mysql> use proibidos; > Reading table information for completion of table and column names > You can turn off this feature to get a quicker startup with -A > > Database changed > mysql> show tables; > +---------------------+ > | Tables_in_proibidos | > +---------------------+ > | telefones | > +---------------------+ > 1 row in set (0.00 sec) > > mysql> desc telefones; > +----------+-------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +----------+-------------+------+-----+---------+----------------+ > | id | int(11) | NO | PRI | NULL | auto_increment | > | callerid | varchar(20) | NO | | NULL | | > +----------+-------------+------+-----+---------+----------------+ > 2 rows in set (0.00 sec) > > > > _______________________________________________ > A Redfone é líder no fornecimento de bridges TDMoE <-> E1 > - Valor similar ao de placas E1 PCI; > - Não há problemas de compatibilidade com barramento PCI; > - Possibilitam a construção de soluções de alta disponibilidade(dois > servidores compartilham o mesmo E1) > Conheça mais sobre este produto em www.red-fone.com > _______________________________________________ > Lista de discussões AsteriskBrasil.org > [email protected] > http://listas.asteriskbrasil.org/mailman/listinfo/asteriskbrasil > -- Rodrigo F. Lang Amd. de Redes em Telecom
_______________________________________________ A Redfone é líder no fornecimento de bridges TDMoE <-> E1 - Valor similar ao de placas E1 PCI; - Não há problemas de compatibilidade com barramento PCI; - Possibilitam a construção de soluções de alta disponibilidade(dois servidores compartilham o mesmo E1) Conheça mais sobre este produto em www.red-fone.com _______________________________________________ Lista de discussões AsteriskBrasil.org [email protected] http://listas.asteriskbrasil.org/mailman/listinfo/asteriskbrasil

