Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
ambiorixg12 / BYE.log
Created December 19, 2018 02:48
SESSION TERMINATION
sip BYE
BYE sip:172.18.15.132:5060 SIP/2.0
Via: SIP/2.0/UDP 45.77.203.6:5066;rport;branch=z9hG4bKPja4d691b6-4605-459d-bc88-ca811b33084a
From: "Ambiorix" <sip:[email protected]>;tag=f14b225b-58b4-48de-8254-78d939e6141b
To: <sip:[email protected]>;tag=18426641_6772d868_e74bb600-520d-46de-ad77-822985dec5dc
Call-ID: 9834c53d-54a3-497f-92d5-f9ae0f94bf2d
CSeq: 15065 BYE
Route: <sip:54.172.60.3:5060;lr;ftag=f14b225b-58b4-48de-8254-78d939e6141b>
Reason: Q.850;cause=16
Max-Forwards: 70
@ambiorixg12
ambiorixg12 / option.log
Last active April 2, 2020 23:20
OPTION REQUEST LOG
<--- Transmitting SIP request (462 bytes) to UDP:54.172.60.3:5060 --->
OPTIONS sip:asteriskpjsip.pstn.us1.twilio.com:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.101.99:5066;rport;branch=z9hG4bKPj6280c4e9-e1e3-4231-9690-757d3902a9d3
From: <sip:[email protected]>;tag=7d6268d8-ac8c-44e4-aa9c-83a30558c19c
To: <sip:asteriskpjsip.pstn.us1.twilio.com>
Contact: <sip:[email protected]:5066>
Call-ID: 70d477f6-c823-4293-8b95-91deff2c7030
CSeq: 48289 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 16.1.0
@ambiorixg12
ambiorixg12 / Asterisk 16 installation on Centos 7
Last active April 21, 2023 22:38
Asterisk 16 installation on Centos 7
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux
sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
reboot
MAKE SURE SELINUX IS DISABLED running the next command
sestatus
yum -y update
yum -y groupinstall core base "Development Tools"
yum install -y make wget openssl-devel ncurses-devel newt-devel libxml2-devel kernel-devel gcc gcc-c++ sqlite-devel
cd /usr/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
sudo yum install epel-release
Install dependencies
yum install unixODBC-devel
yum install unixODBC
yum install python-devel
yum install python-pip
yum install MySQL-python
https://community.asterisk.org/t/call-detail-records-are-not-saving-in-cdr/76743/6
Install packages
apt-get install unixodbc-dev unixodbc-bin unixodbc
/etc/odbc.ini
[asterisk-mysql]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = asterisk
Server = localhost
@ambiorixg12
ambiorixg12 / asterisk expressions
Last active December 19, 2018 20:44
asterisk expressions
same=>n,GotoIf($[$["${profile_id:0:-1}"= "6"] & $["${version:0:-1}"<"7"]]?from-internal,970040015,1)
same=>n,GotoIf($[$["${profile_id:0:-1}"= "6"] & $["${version:0:-1}">="7"] & $["${version:0:-1}"<="8"]]?from-internal,970040010,1)
@ambiorixg12
ambiorixg12 / recording context
Created December 19, 2018 03:14
Recording context with confirmation
[recording]
exten=>_x.,1,Answer()
same=>n,Set(path=/var/www/html/surf/)
same =>n(2),read(edit,${path}${EXTEN:1},1,,)
same=>n,GotoIf($["${edit}"="5"]?auth)
same=>n,hangup()
same=>n(auth),authenticate(1973)
same=>n(rec),playback(pls-enter-num-message-after-tone)
same=>n,Record(${path}${EXTEN:1}.wav,,,k)
same=>n,playback(${path}${EXTEN:1})
@ambiorixg12
ambiorixg12 / Len and Execif
Created December 19, 2018 03:16
Setting caller id to ramdom
exten=>001,1,Answer()
same=>n,Noop(${CALLERID(num)})
same=>n,Set(ARG1=${CALLERID(num)})
same=>n,Noop( len of ${LEN(${ARG1})})
same=>n,ExecIf($[${LEN(${ARG1})}= 11]?Set(CALLERID(num)=${ARG1:0:7}${RAND(1000,9999)}))
same=>n,ExecIf($[${LEN(${ARG1})}> 11]?Set(CALLERID(num)=${ARG1:0:7}))
@ambiorixg12
ambiorixg12 / writting data
Created December 19, 2018 03:18
writting data from Asterisk file
<?php
$file="/etc/asterisk/data.txt";
$data=$argv[1]."\n";
$data.="$argv[2]";
file_put_contents("$file", $data,FILE_APPEND);
?>
Dial paln
[writting]
exten=>_1011,1,Noop()
@ambiorixg12
ambiorixg12 / ${EXTEN} MANIPULATION
Created December 19, 2018 03:20
manipulation of ${EXTEN} variable
The ${EXTEN} variable properly has the syntax ${EXTEN:x:y}, where x is the starting position and y is the number of digits to return. Given the following dial string:
94169671111
we can extract the following digit strings using the ${EXTEN:x:y} construct:
${EXTEN:1:3} would contain 416
${EXTEN:4:7} would contain 9671111
${EXTEN:-4:4} would start four digits from the end and return four digits, giving us 1111
${EXTEN:2:-4} would start two digits in and exclude the last four digits, giving us 16967
${EXTEN:-6:-4} would start six digits from the end and exclude the last four digits, giving us 67
${EXTEN:1} would give us everything after the first digit, or 4169671111 (if the number of digits to return is left blank, it will return the entire remaining string)
This is a very powerful construct, but most of these variations are not very common in normal use. For the most part, you will be using ${EXTEN} (or perhaps ${EXTEN:1} if you need to strip off an external access code).