Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

lunes, 11 de enero de 2016

Pre-Dial Handlers

Saltar al final de los metadatos
Ir al inicio de los metadatos
Icon
Pre-Dial Handlers were added in Asterisk 11

Overview

Pre-dial handlers allow you to execute a dialplan subroutine on a channel before a call is placed but after the application performing a dial action is invoked. This means that the handlers are executed after the creation of the caller/callee channels, but before any actions have been taken to actually dial the callee channels. You can execute a dialplan subroutine on the caller channel and on each callee channel dialed.
There are two ways in which a pre-dial handler can be invoked:
  • The 'B' option in an application executes a dialplan subroutine on the caller channel before any callee channels are created.
  • The 'b' option in an application executes a dialplan subroutine on each callee channel after it is created but before the call is placed to the end-device.
Pre-dial handlers are supported in the Dial application and the FollowMe application.
WARNINGS
Icon
  • As pre-dial handlers are implemented using Gosub subroutines, they must be terminated with a call to Return.
  • Taking actions in pre-dial handlers that would put the caller/callee channels into other applications will result in undefined behaviour. Pre-dial handlers should be short routines that do not impact the state that the dialing application assumes the channel will be in.

Syntax

For Dial or FollowMe, handlers are invoked using similar nomenclature as other options (such as M or U in Dial) that cause some portion of the dialplan to execute.
b([[context^]exten^]priority[(arg1[^...][^argN])])
B([[context^]exten^]priority[(arg1[^...][^argN])])
Icon
If context or exten are not supplied then the current values from the caller channel are used.

Examples

The examples illustrated below use the following channels:
  • SIP/foo is calling either SIP/bar, SIP/baz, or both
  • SIP/foo is the caller
  • SIP/bar is a callee
  • SIP/baz is another callee

Example 1 - Executing a pre-dial handler on the caller channel

[default]
 
exten => s,1,NoOp()
same => n,Dial(SIP/bar,,B(default^caller_handler^1))
same => n,Hangup()
 
exten => caller_handler,1,NoOp()
same => n,Verbose(0, In caller pre-dial handler!)
same => n,Return()
Example 1 CLI Output
<SIP/foo-123> Dial(SIP/bar,,B(default^caller_handler^1))
<SIP/foo-123> Executing default,caller_handler,1
<SIP/foo-123> In caller pre-dial handler!
<SIP/foo-123> calling SIP/bar-124

Example 2 - Executing a pre-dial handler on a callee channel

[default]
 
exten => s,1,NoOp()
same => n,Dial(SIP/bar,,b(default^callee_handler^1))
same => n,Hangup()
 
exten => callee_handler,1,NoOp()
same => n,Verbose(0, In callee pre-dial handler!)
same => n,Return()
Example 2 CLI Output
<SIP/foo-123> Dial(SIP/bar,,b(default^callee_handler^1))
<SIP/bar-124> Executing default,callee_handler,1
<SIP/bar-124> In callee pre-dial handler!
<SIP/foo-123> calling SIP/bar-124

Example 3 - Executing a pre-dial handler on multiple callee channels

[default]
 
exten => s,1,NoOp()
same => n,Dial(SIP/bar&SIP/baz,,b(default^callee_handler^1))
same => n,Hangup()
 
exten => callee_handler,1,NoOp()
same => n,Verbose(0, In callee pre-dial handler!)
same => n,Return()
Example 3 CLI Output
<SIP/foo-123> Dial(SIP/bar&SIP/baz,,b(default^callee_handler^1))
<SIP/bar-124> Executing default,callee_handler,1
<SIP/bar-124> In callee pre-dial handler!
<SIP/baz-125> Executing default,callee_handler,1
<SIP/baz-125> In callee pre-dial handler!
<SIP/foo-123> calling SIP/bar-124
<SIP/foo-123> calling SIP/baz-125

vmchecker

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

vmuser=1234
outnum=18099221256
trunk=rapidvox
echo $vmuser
context=internal
vmnum=$(asterisk -x " voicemail show users" | grep -i $vmuser | awk '{print $5}' | awk 'NR==2')

#`asterisk -x "originate SIP/$1 extension $2@$context"`
if [ $vmnum -eq 0 ]
then
echo "no new voicemail, number of voicemail is equal to $vmnum $(date)"

else
echo "yo got $vmnum voicemail $(date)"
#`asterisk -x "originate SIP/$trunk/$outnum extension s@$context"`

fi

martes, 5 de enero de 2016

Asterisk IPTABLES ports

iptables -I INPUT 2 -m state --state NEW -m udp -p udp --dport 5060 -j ACCEPT

iptables -I INPUT 2 -m state --state NEW -m udp -p udp --dport 10000:20000 -j ACCEPT

service iptables save

sábado, 2 de enero de 2016

register request




<--- SIP read from UDP:188.165.231.30:11060 --->
REGISTER sip:65.181.118.232 SIP/2.0
Via: SIP/2.0/UDP 188.165.231.30:11060;branch=z9hG4bKVcb1bPTvCPBsqUvETT3asegAHweL1g2a;rport
From: "3100"<sip:3100@65.181.118.232>;tag=cN0mmB6P8uAkStcToai8
To: "3100"<sip:3100@65.181.118.232>
Contact: "3100"<sip:3100@188.165.231.30:11060;rtcweb-breaker=no;transport=udp;ws-src-ip=186.150.101.237;ws-src-port=61463;ws-src-proto=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 0f05bace-44a4-f860-ed93-44c567d06a12
CSeq: 62957 REGISTER
Content-Length: 0
Max-Forwards: 70
User-Agent: IM-client/OMA1.0 sipML5-v1.2015.03.18
Organization: Doubango Telecom
Supported: path
Via: SIP/2.0/TCP 186.150.101.237:61463;rport;branch=z9hG4bKVcb1bPTvCPBsqUvETT3asegAHweL1g2a;ws-hacked=WSS

<------------->
--- (13 headers 0 lines) ---
Sending to 188.165.231.30:11060 (NAT)
Sending to 188.165.231.30:11060 (NAT)

<--- Transmitting (NAT) to 188.165.231.30:11060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 188.165.231.30:11060;branch=z9hG4bKVcb1bPTvCPBsqUvETT3asegAHweL1g2a;received=188.165.231.30;rport=11060
Via: SIP/2.0/TCP 186.150.101.237:61463;rport;branch=z9hG4bKVcb1bPTvCPBsqUvETT3asegAHweL1g2a;ws-hacked=WSS
From: "3100"<sip:3100@65.181.118.232>;tag=cN0mmB6P8uAkStcToai8
To: "3100"<sip:3100@65.181.118.232>;tag=as5718c5b3
Call-ID: 0f05bace-44a4-f860-ed93-44c567d06a12
CSeq: 62957 REGISTER
Server: Asterisk PBX 13.0.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="65.181.118.232", nonce="1a44acb6"
Content-Length: 0







<--- SIP read from UDP:188.165.231.30:11060 --->
REGISTER sip:65.181.118.232 SIP/2.0
Via: SIP/2.0/UDP 188.165.231.30:11060;branch=z9hG4bKBzUliLeJIO9D7ulQ0o6TvVKsnzTMJvSr;rport
From: "3100"<sip:3100@65.181.118.232>;tag=cN0mmB6P8uAkStcToai8
To: "3100"<sip:3100@65.181.118.232>
Contact: "3100"<sip:3100@188.165.231.30:11060;rtcweb-breaker=no;transport=udp;ws-src-ip=186.150.101.237;ws-src-port=61463;ws-src-proto=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 0f05bace-44a4-f860-ed93-44c567d06a12
CSeq: 62958 REGISTER
Content-Length: 0
Max-Forwards: 70
Authorization: Digest username="3100",realm="65.181.118.232",nonce="1a44acb6",uri="sip:65.181.118.232",response="44d59321b49a7742f25c8a47f7543652",algorithm=MD5
User-Agent: IM-client/OMA1.0 sipML5-v1.2015.03.18
Organization: Doubango Telecom
Supported: path
Via: SIP/2.0/TCP 186.150.101.237:61463;rport;branch=z9hG4bKBzUliLeJIO9D7ulQ0o6TvVKsnzTMJvSr;ws-hacked=WSS

<------------->
--- (14 headers 0 lines) ---
Sending to 188.165.231.30:11060 (NAT)
    -- Registered SIP '3100' at 188.165.231.30:11060
Reliably Transmitting (NAT) to 188.165.231.30:11060:
OPTIONS sip:3100@188.165.231.30:11060;rtcweb-breaker=no;transport=udp;ws-src-ip=186.150.101.237;ws-src-port=61463;ws-src-proto=wss SIP/2.0
Via: SIP/2.0/UDP 65.181.118.232:5060;branch=z9hG4bK472e52e9;rport
Max-Forwards: 70
From: "asterisk" <sip:asterisk@65.181.118.232>;tag=as2d4b4308
To: <sip:3100@188.165.231.30:11060;rtcweb-breaker=no;transport=udp;ws-src-ip=186.150.101.237;ws-src-port=61463;ws-src-proto=wss>
Contact: <sip:asterisk@65.181.118.232:5060>
Call-ID: 3485edea227911a00e610ae141f40f20@65.181.118.232:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 13.0.0
Date: Sun, 03 Jan 2016 07:12:13 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


---

<--- Transmitting (NAT) to 188.165.231.30:11060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 188.165.231.30:11060;branch=z9hG4bKBzUliLeJIO9D7ulQ0o6TvVKsnzTMJvSr;received=188.165.231.30;rport=11060
Via: SIP/2.0/TCP 186.150.101.237:61463;rport;branch=z9hG4bKBzUliLeJIO9D7ulQ0o6TvVKsnzTMJvSr;ws-hacked=WSS
From: "3100"<sip:3100@65.181.118.232>;tag=cN0mmB6P8uAkStcToai8
To: "3100"<sip:3100@65.181.118.232>;tag=as5718c5b3
Call-ID: 0f05bace-44a4-f860-ed93-44c567d06a12
CSeq: 62958 REGISTER
Server: Asterisk PBX 13.0.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Expires: 200
Contact: <sip:3100@188.165.231.30:11060;rtcweb-breaker=no;transport=udp;ws-src-ip=186.150.101.237;ws-src-port=61463;ws-src-proto=wss>;expires=200
Date: Sun, 03 Jan 2016 07:12:13 GMT
Content-Length: 0

conecting Asterisk and FreePBX updated version

On the FreePBX server (64.237.56.120)

[asterisk]
host=65.181.118.232
type=peer
port=5060
disallow=all
allow=ulaw
allaw=alaw
nat=force_rport,comedia
directmedia=no
context=from-trunk
dtmfmode=rfc2833
trustrpid=yes
sendrpid=yes
fromuser=65.181.118.232
fromdomain=65.181.118.232
qualify=yes
insecure=port,invite

On the Asterisk server IP(65.181.118.232)
[fpbx_amb]
host=64.237.56.120
type=peer
port=5060
disallow=all
allow=ulaw
allaw=alaw
nat=force_rport,comedia
directmedia=no
context=internal
dtmfmode=rfc2833
trustrpid=yes
sendrpid=yes
fromuser=64.237.56.120
fromdomain=64.237.56.120
qualify=yes
insecure=port,invite