XMLification (wave 1)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1401 d0543943-73ff-0310-b7d9-9358b9ac24b2v1.2.stable
parent
d9e8100737
commit
93666f6dd7
|
@ -44,6 +44,7 @@ AM_CFLAGS += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
|
|||
AM_CFLAGS += -DSWITCH_DB_DIR=\"$(PREFIX)/db\"
|
||||
AM_CFLAGS += -DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
|
||||
AM_CFLAGS += -DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
|
||||
AM_CFLAGS += -DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
|
||||
|
||||
|
||||
libfreeswitch_la_SOURCES = \
|
||||
|
@ -204,8 +205,8 @@ modwipe:
|
|||
|
||||
install_mod: modules
|
||||
@echo Installing $(NAME)
|
||||
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
|
||||
@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
|
||||
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
|
||||
@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
|
||||
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
|
||||
@echo Installing Modules
|
||||
@rm -f build/freeswitch.env
|
||||
|
|
|
@ -253,7 +253,8 @@ AM_CFLAGS = -I$(PREFIX)/include $(shell $(APR_CONFIG) --cflags \
|
|||
-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
|
||||
-DSWITCH_DB_DIR=\"$(PREFIX)/db\" \
|
||||
-DSWITCH_LOG_DIR=\"$(PREFIX)/log\" \
|
||||
-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
|
||||
-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\" \
|
||||
-DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
|
||||
AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
|
||||
$(shell $(APU_CONFIG) --link-ld --libs ) -lm \
|
||||
-L/usr/local/lib/db42 -L/usr/local/lib $(am__append_1)
|
||||
|
@ -1111,8 +1112,8 @@ modwipe:
|
|||
|
||||
install_mod: modules
|
||||
@echo Installing $(NAME)
|
||||
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
|
||||
@if [ ! -f $(PREFIX)/conf/freeswitch.conf ] ; then /bin/cp -p conf/freeswitch.conf $(PREFIX)/conf/; fi
|
||||
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts $(PREFIX)/htdocs
|
||||
@if [ ! -f $(PREFIX)/conf/freeswitch.xml ] ; then /bin/cp -p conf/freeswitch.xml $(PREFIX)/conf/; fi
|
||||
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
|
||||
@echo Installing Modules
|
||||
@rm -f build/freeswitch.env
|
||||
|
|
|
@ -1,275 +0,0 @@
|
|||
; Unified Config file
|
||||
; each section denoted with a + could also be in it's own file
|
||||
|
||||
;---- CONSOLE LOGGER
|
||||
;--------------------------------------------------------------------------------
|
||||
[+console.conf]
|
||||
[mappings]
|
||||
; pick a file name, a function name or 'all'
|
||||
; map as many as you need for specific debugging
|
||||
;mod_exosip.c => DEBUG
|
||||
;log_event => DEBUG
|
||||
;all => DEBUG
|
||||
|
||||
;---- MODULES
|
||||
;--------------------------------------------------------------------------------
|
||||
[+modules.conf]
|
||||
[modules]
|
||||
|
||||
; Loggers (I'd load these first)
|
||||
load => mod_console
|
||||
;load => mod_syslog
|
||||
|
||||
; Event Handlers
|
||||
;load => mod_event_multicast
|
||||
;load => mod_event_test
|
||||
;load => mod_zeroconf
|
||||
;load => mod_xmpp_event
|
||||
|
||||
; Directory Interfaces
|
||||
;load => mod_ldap
|
||||
|
||||
; Endpoints
|
||||
load => mod_exosip
|
||||
load => mod_iax
|
||||
;load => mod_portaudio
|
||||
;load => mod_woomera
|
||||
;load => mod_wanpipe
|
||||
;load => mod_dingaling
|
||||
|
||||
; Applications
|
||||
load => mod_bridgecall
|
||||
load => mod_echo
|
||||
;load => mod_ivrtest
|
||||
load => mod_playback
|
||||
load => mod_commands
|
||||
;load => mod_commands
|
||||
|
||||
; Dialplan Interfaces
|
||||
load => mod_dialplan_flatfile
|
||||
;load => mod_dialplan_directory
|
||||
load => mod_pcre
|
||||
|
||||
; Codec Interfaces
|
||||
load => mod_g711
|
||||
load => mod_gsm
|
||||
load => mod_l16
|
||||
;load => mod_speex
|
||||
;load => mod_ilbc
|
||||
|
||||
; File Format Interfaces
|
||||
load => mod_sndfile
|
||||
|
||||
; Timers
|
||||
load => mod_softtimer
|
||||
|
||||
; Languages
|
||||
;load => mod_spidermonkey
|
||||
;load => mod_perl
|
||||
|
||||
; ASR /TTS
|
||||
;load => mod_cepstral
|
||||
|
||||
;---- SYSLOG
|
||||
;--------------------------------------------------------------------------------
|
||||
; emerg - system is unusable
|
||||
; alert - action must be taken immediately
|
||||
; crit - critical conditions
|
||||
; err - error conditions
|
||||
; warning - warning conditions
|
||||
; notice - normal, but significant, condition
|
||||
; info - informational message
|
||||
; debug - debug-level message
|
||||
;
|
||||
[+syslog.conf]
|
||||
[settings]
|
||||
ident => freeswitch
|
||||
facility => user
|
||||
format => ${time} - ${message}
|
||||
level => debug,info,warning-alert
|
||||
|
||||
|
||||
;---- IAX PROTOCOL
|
||||
;--------------------------------------------------------------------------------
|
||||
[+iax.conf]
|
||||
[settings]
|
||||
debug => 0
|
||||
;ip => 1.2.3.4
|
||||
port => 4569
|
||||
dialplan => flatfile
|
||||
codec_prefs => PCMU,PCMA,speex,L16
|
||||
codec_master => us
|
||||
codec_rates=8
|
||||
|
||||
;---- SIP PROTOCOL
|
||||
;--------------------------------------------------------------------------------
|
||||
[+exosip.conf]
|
||||
[settings]
|
||||
port => 5060
|
||||
dialplan => pcre
|
||||
dtmf_duration => 100
|
||||
; pick one (default if not specified is 'guess');
|
||||
rtp-ip => guess
|
||||
;rtp-ip => 10.0.0.1
|
||||
; leave commented or 0.0.0.0 for all ip
|
||||
;sip-ip => 127.0.0.1
|
||||
|
||||
; optional ;
|
||||
;ext-rtp-ip => stun:stun.server.com
|
||||
;ext-rtp-ip => 100.101.102.103
|
||||
|
||||
; specify 'myrealm' with certian key
|
||||
; use !myrealm! at beginning of url to activate
|
||||
; exosip/!myrealm!1000@dest
|
||||
;srtp:myrealm => ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
|
||||
; VAD choose one (out is a good choice);
|
||||
; vad => in
|
||||
; vad => out
|
||||
; vad => both
|
||||
|
||||
;---- WOOMERA PROTOCOL
|
||||
;--------------------------------------------------------------------------------
|
||||
[+woomera.conf]
|
||||
[settings]
|
||||
debug=0
|
||||
|
||||
;---- WANPIPE PRI
|
||||
;--------------------------------------------------------------------------------
|
||||
[+wanpipe.conf]
|
||||
[settings]
|
||||
debug => 1
|
||||
dialplan => pcre
|
||||
mtu => 160
|
||||
dtmf_on => 800
|
||||
dtmf_off => 100
|
||||
supress_dtmf_tone => yes
|
||||
|
||||
[span]
|
||||
span => 1
|
||||
node => cpe
|
||||
|
||||
;switch => ni2
|
||||
switch => dms100
|
||||
;switch => lucent5e
|
||||
;switch => att4ess
|
||||
;switch => euroisdn
|
||||
;switch => gr303eoc
|
||||
;switch => gr303tmc
|
||||
|
||||
dp => national
|
||||
;dp => international
|
||||
;dp => local
|
||||
;dp => private
|
||||
;dp => unknown
|
||||
|
||||
l1 => ulaw
|
||||
;l1 => alaw
|
||||
|
||||
bchan => 1-23
|
||||
dchan => 24
|
||||
dialplan => pcre
|
||||
|
||||
|
||||
;---- SOUND CARD CHANNEL
|
||||
;--------------------------------------------------------------------------------
|
||||
[+portaudio.conf]
|
||||
[settings]
|
||||
debug => 2
|
||||
dialplan => flatfile
|
||||
|
||||
; partial string match on something in the name or the device #
|
||||
indev => USB
|
||||
outdev => USB
|
||||
|
||||
cid_name => FreeSwitch
|
||||
cid_num => 5555551212
|
||||
|
||||
;--- ZEROCONF
|
||||
;--------------------------------------------------------------------------------
|
||||
[+zeroconf.conf]
|
||||
[settings]
|
||||
|
||||
publish => yes
|
||||
browse => _sip._udp
|
||||
|
||||
;---- XMPP EVENT
|
||||
;--------------------------------------------------------------------------------
|
||||
[+xmpp_event.conf]
|
||||
[settings]
|
||||
|
||||
#debug => 1
|
||||
jid => freeswitch@my.jabber.com/me
|
||||
passwd => mypass
|
||||
|
||||
target_jid => freeswitch@reader.org/him
|
||||
|
||||
;---- LDAP DIALPLAN
|
||||
;--------------------------------------------------------------------------------
|
||||
[+dialplan_directory.conf]
|
||||
[settings]
|
||||
|
||||
directory_name => ldap
|
||||
host => ldap.freeswitch.org
|
||||
dn => cn=Manager,dc=freeswitch,dc=org
|
||||
pass => test
|
||||
base => dc=freeswitch,dc=org
|
||||
|
||||
;----REGULAR EXPRESSION DIALPLAN
|
||||
;--------------------------------------------------------------------------------
|
||||
[+regextensions.conf]
|
||||
|
||||
; any extension starting with a '4'
|
||||
; strip the '4' and consider the rest a numeric filename
|
||||
[playfile]
|
||||
regex => ^4(\d+)
|
||||
match => playback /var/sounds/$1.raw
|
||||
|
||||
; send everything to wanpipe isdn
|
||||
[gateway]
|
||||
regex => (.*)
|
||||
match => bridge wanpipe/a/a/$1
|
||||
|
||||
; ordniary extension
|
||||
[plain_old_extension]
|
||||
regex => 9999
|
||||
match => playback /var/sounds/beep.gsm
|
||||
|
||||
;---- BASIC EXTENSIONS
|
||||
;--------------------------------------------------------------------------------
|
||||
[+extensions.conf]
|
||||
[default]
|
||||
|
||||
1000 => playback /var/sounds/beep.raw
|
||||
|
||||
; to time from a timer instead of from the input stream use
|
||||
; 1000 => playback /var/sounds/beep.raw soft
|
||||
|
||||
; call the freeswitch conference
|
||||
888 => bridge iax/guest@66.250.68.194/888
|
||||
|
||||
[+dingaling.conf]
|
||||
[settings]
|
||||
debug => 0
|
||||
codec_prefs => PCMU
|
||||
|
||||
; *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok)
|
||||
; *NOTE* as of May 2 2006 you must set auto-login => true if you want to be able to auto-login on startup
|
||||
|
||||
[interface]
|
||||
name => google
|
||||
login => myjabberid@myjabberserver.com/talk
|
||||
password => mypass
|
||||
dialplan => flatfile
|
||||
message => Jingle all the way
|
||||
rtp-ip => 0.0.0.0
|
||||
auto-login => true
|
||||
; or ;
|
||||
;rtp-ip => my_lan_ip
|
||||
;ext-rtp-ip => stun:stun.server.com
|
||||
exten => 1000
|
||||
|
||||
; VAD choose one
|
||||
; vad => in
|
||||
; vad => out
|
||||
; vad => both
|
|
@ -0,0 +1,312 @@
|
|||
<?xml version="1.0"?>
|
||||
<document type="freeswitch/xml">
|
||||
<section name="configuration">
|
||||
<configuration name="modules.conf" description="Modules">
|
||||
<modules>
|
||||
<!-- Loggers (I'd load these first) -->
|
||||
<load module="mod_console"/>
|
||||
<!-- <load module="mod_syslog"/> -->
|
||||
|
||||
<!-- XML Interfaces -->
|
||||
<!-- <load module="mod_xml_rpc"/> -->
|
||||
|
||||
<!-- Event Handlers -->
|
||||
<!-- <load module="mod_event_multicast"/> -->
|
||||
<!-- <load module="mod_event_test"/> -->
|
||||
<!-- <load module="mod_zeroconf"/> -->
|
||||
<!-- <load module="mod_xmpp_event"/> -->
|
||||
|
||||
<!-- Directory Interfaces -->
|
||||
<!-- <load module="mod_ldap"/> -->
|
||||
|
||||
<!-- Endpoints -->
|
||||
<load module="mod_exosip"/>
|
||||
<!--<load module="mod_iax"/>-->
|
||||
<!-- <load module="mod_portaudio"/> -->
|
||||
<!-- <load module="mod_woomera"/> -->
|
||||
<!-- <load module="mod_wanpipe"/> -->
|
||||
<!-- <load module="mod_dingaling"/> -->
|
||||
|
||||
<!-- Applications -->
|
||||
<load module="mod_bridgecall"/>
|
||||
<load module="mod_echo"/>
|
||||
<!-- <load module="mod_ivrtest"/> -->
|
||||
<load module="mod_playback"/>
|
||||
<load module="mod_commands"/>
|
||||
<!-- <load module="mod_commands"/> -->
|
||||
|
||||
<!-- Dialplan Interfaces -->
|
||||
<load module="mod_dialplan_xml"/>
|
||||
<!-- <load module="mod_dialplan_directory"/> -->
|
||||
|
||||
<!-- Codec Interfaces -->
|
||||
<load module="mod_g711"/>
|
||||
<load module="mod_gsm"/>
|
||||
<load module="mod_l16"/>
|
||||
<!-- <load module="mod_speex"/> -->
|
||||
<!-- <load module="mod_ilbc"/> -->
|
||||
|
||||
<!-- File Format Interfaces -->
|
||||
<load module="mod_sndfile"/>
|
||||
|
||||
<!-- Timers -->
|
||||
<load module="mod_softtimer"/>
|
||||
|
||||
<!-- Languages -->
|
||||
<!-- <load module="mod_spidermonkey"/> -->
|
||||
<!-- <load module="mod_perl"/> -->
|
||||
|
||||
<!-- ASR /TTS -->
|
||||
<!-- <load module="mod_cepstral"/> -->
|
||||
</modules>
|
||||
</configuration>
|
||||
|
||||
<configuration name="iax.conf" description="IAX Configuration">
|
||||
<settings>
|
||||
<param name="debug" value="0"/>
|
||||
<!-- <param name="ip" value="1.2.3.4"> -->
|
||||
<param name="port" value="4569"/>
|
||||
<param name="dialplan" value="flatfile"/>
|
||||
<param name="codec_prefs" value="PCMU,PCMA,speex,L16"/>
|
||||
<param name="codec_master" value="us"/>
|
||||
<param name="codec_rates" value="8"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="console.conf" description="Console Logger">
|
||||
<!-- pick a file name, a function name or 'all' -->
|
||||
<!-- map as many as you need for specific debugging -->
|
||||
<mappings>
|
||||
<!-- <param name="log_event" value="DEBUG"/> -->
|
||||
<param name="all" value="DEBUG"/>
|
||||
</mappings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="syslog.conf" description="Syslog Logger">
|
||||
<!-- SYSLOG -->
|
||||
<!-- emerg - system is unusable -->
|
||||
<!-- alert - action must be taken immediately -->
|
||||
<!-- crit - critical conditions -->
|
||||
<!-- err - error conditions -->
|
||||
<!-- warning - warning conditions -->
|
||||
<!-- notice - normal, but significant, condition -->
|
||||
<!-- info - informational message -->
|
||||
<!-- debug - debug-level message -->
|
||||
<settings>
|
||||
<param name="ident" value="freeswitch"/>
|
||||
<param name="facility" value="user"/>
|
||||
<param name="format" value="${time} - ${message}"/>
|
||||
<param name="level" value="debug,info,warning-alert"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="exosip.conf" description="Exosip Endpoint">
|
||||
<settings>
|
||||
<param name="port" value="5060"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
<param name="dtmf_duration" value="100"/>
|
||||
<!-- pick one (default if not specified is 'guess'); -->
|
||||
<param name="rtp-ip" value="guess"/>
|
||||
<!-- <param name-"rtp-ip" value="10.0.0.1"/> -->
|
||||
<!-- leave commented or 0.0.0.0 for all ip -->
|
||||
<!-- <param name="sip-ip" value="127.0.0.1"/> -->
|
||||
|
||||
<!-- optional ; -->
|
||||
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
|
||||
<!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
|
||||
|
||||
<!-- specify 'myrealm' with certian key -->
|
||||
<!-- use !myrealm! at beginning of url to activate -->
|
||||
<!-- exosip/!myrealm!1000@dest -->
|
||||
<!-- srtp:<param name="myrealm" value="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"/> -->
|
||||
|
||||
<!-- VAD choose one (out is a good choice); -->
|
||||
<!-- <param name="vad" value="in"/> -->
|
||||
<!-- <param name="vad" value="out"/> -->
|
||||
<!-- <param name="vad" value="both"/> -->
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="woomera.conf" description="Woomera Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="0"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="1"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
<param name="mtu" value="160"/>
|
||||
<param name="dtmf_on" value="800"/>
|
||||
<param name="dtmf_off" value="100"/>
|
||||
<param name="supress_dtmf_tone" value="yes"/>
|
||||
</settings>
|
||||
<span>
|
||||
<param name="span" value="1"/>
|
||||
<param name="node" value="cpe"/>
|
||||
<!-- <param name="switch" value="ni2"/> -->
|
||||
<param name="switch" value="dms100"/>
|
||||
<!-- <param name="switch" value="lucent5e"/> -->
|
||||
<!-- <param name="switch" value="att4ess"/> -->
|
||||
<!-- <param name="switch" value="euroisdn"/> -->
|
||||
<!-- <param name="switch" value="gr303eoc"/> -->
|
||||
<!-- <param name="switch" value="gr303tmc"/> -->
|
||||
<param name="dp" value="national"/>
|
||||
<!-- <param name="dp" value="international"/> -->
|
||||
<!-- <param name="dp" value="local"/> -->
|
||||
<!-- <param name="dp" value="private"/> -->
|
||||
<!-- <param name="dp" value="unknown"/> -->
|
||||
<param name="l1" value="ulaw"/>
|
||||
<!-- <param name="l1" value="alaw"/> -->
|
||||
<param name="bchan" value="1-23"/>
|
||||
<param name="dchan" value="24"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
</span>
|
||||
</configuration>
|
||||
|
||||
<configuration name="portaudio.conf" description="Soundcard Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="2"/>
|
||||
<param name="dialplan" value="flatfile"/>
|
||||
|
||||
<!-- partial string match on something in the name or the device # -->
|
||||
<param name="indev" value="USB"/>
|
||||
<param name="outdev" value="USB"/>
|
||||
|
||||
<param name="cid_name" value="FreeSwitch"/>
|
||||
<param name="cid_num" value="5555551212"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="zeroconf.conf" description="Zeroconf Event Handler">
|
||||
<settings>
|
||||
<param name="publish" value="yes"/>
|
||||
<param name="browse" value="_sip._udp"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="xmpp_event.conf" description="XMPP Event Handler">
|
||||
<settings>
|
||||
<param name="#debug" value="1"/>
|
||||
<param name="jid" value="freeswitch@my.jabber.com/me"/>
|
||||
<param name="passwd" value="mypass"/>
|
||||
<param name="target_jid" value="freeswitch@reader.org/him"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="dialplan_directory.conf" description="Dialplan Directory">
|
||||
<settings>
|
||||
<param name="directory_name" value="ldap"/>
|
||||
<param name="host" value="ldap.freeswitch.org"/>
|
||||
<param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/>
|
||||
<param name="pass" value="test"/>
|
||||
<param name="base" value="dc=freeswitch,dc=org"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="extensions.conf" description="Regex/XML Dialplan">
|
||||
<!-- any extension starting with a '4' -->
|
||||
<!-- strip the '4' and consider the rest a numeric filename -->
|
||||
<!-- Valid fields in conditions:
|
||||
"dialplan, caller_id_name, ani, ani2, caller_id_number,
|
||||
network_addr, rdnis, destination_number, uuid, source,
|
||||
context, chan_name" -->
|
||||
|
||||
<context name="default">
|
||||
<extension name="devconf">
|
||||
<condition field="destination_number" expression="888">
|
||||
<action application="bridge" data="exosip/888@66.250.68.194"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<!-- extensions starting with 4, all the numbers after 4 form a numeric filename
|
||||
continue=true means keep looking for more extensions to match
|
||||
*NOTE* The entire dialplan is parsed ONCE when the call starts
|
||||
so any call info acquired after the various actions cannot
|
||||
be taken into consideration.
|
||||
|
||||
The first match will play a beep and the second one plays
|
||||
the desired file. This is for demo purposes both actions
|
||||
could have been under the same <extension> tag as well.
|
||||
-->
|
||||
<extension name="playsound1" continue="true">
|
||||
<condition field="source" expression="mod_exosip"/>
|
||||
<condition field="destination_number" expression="^4(\d+)">
|
||||
<action application="playback" data="/var/sounds/beep.gsm"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<extension name="playsound2">
|
||||
<condition field="source" expression="mod_exosip"/>
|
||||
<condition field="destination_number" expression="^4(\d+)">
|
||||
<action application="playback" data="/root/$1.raw"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<!-- send everything with a certian RDNIS to Wanpipe ISDN -->
|
||||
<extension name="To PRI">
|
||||
<condition field="rdnis" expression="8881231234"/>
|
||||
<condition field="destination_number" expression="(.*)">
|
||||
<action application="bridge" data="wanpipe/a/a/$1"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<!-- Call *MUST* originate from mod_iax and also be dialing ext 9999-->
|
||||
<extension name="9999">
|
||||
<condition field="source" expresion="mod_iax"/>
|
||||
<condition field="destination_number" expression="9999">
|
||||
<action application="playback" data="/var/sounds/beep.gsm"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<!-- Call the FreeSWITCH conference via SIP -->
|
||||
<extension name="FreeSWITCH Conference SIP">
|
||||
<condition field="destination_number" expression="888">
|
||||
<action application="bridge" data="exosip/888@66.250.68.194"/>
|
||||
</condition>
|
||||
</extension>
|
||||
<!-- Call the FreeSWITCH conference via IAX -->
|
||||
<extension name="FreeSWITCH Conference IAX">
|
||||
<condition field="destination_number" expression="8888">
|
||||
<action application="bridge" data="iax/guest@66.250.68.194/888"/>
|
||||
</condition>
|
||||
</extension>
|
||||
</context>
|
||||
</configuration>
|
||||
|
||||
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="0"/>
|
||||
<param name="codec_prefs" value="PCMU"/>
|
||||
</settings>
|
||||
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
|
||||
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
|
||||
<interface>
|
||||
<param name="name" value="jingle"/>
|
||||
<param name="login" value="myjid@myserver.com/talk"/>
|
||||
<param name="password" value="mypass"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
<param name="message" value="Jingle all the way"/>
|
||||
<param name="rtp-ip" value="10.0.0.1"/>
|
||||
<param name="auto-login" value="true"/>
|
||||
<!-- or -->
|
||||
<!-- rtp-<param name="ip" value="my_lan_ip"/> -->
|
||||
<!-- ext-rtp-<param name="ip" value="stun:stun.server.com"/> -->
|
||||
<!-- default extension (if one cannot be determined) -->
|
||||
<param name="exten" value="888"/>
|
||||
<!-- VAD choose one -->
|
||||
<!-- <param name="vad" value="in"/> -->
|
||||
<!-- <param name="vad" value="out"/> -->
|
||||
<param name="vad" value="both"/>
|
||||
</interface>
|
||||
</configuration>
|
||||
<configuration name="xml_rpc.conf" description="XML RPC">
|
||||
<settings>
|
||||
<!-- The port where you want to run the http service (default 8080) -->
|
||||
<param name="http_port" value="8080">
|
||||
<!-- The url to a gateway cgi that can generate xml similar to
|
||||
what's in this file only on-the-fly (leave it commented if you dont
|
||||
need it) -->
|
||||
<!-- <param name="gateway_url" value="http://www.server.com/gateway.cgi"/> -->
|
||||
</configuration>
|
||||
|
||||
</section>
|
||||
</document>
|
||||
|
||||
|
|
@ -14,9 +14,8 @@ codecs/mod_gsm
|
|||
#codecs/mod_ilbc
|
||||
codecs/mod_l16
|
||||
#codecs/mod_speex
|
||||
dialplans/mod_dialplan_flatfile
|
||||
#dialplans/mod_dialplan_directory
|
||||
dialplans/mod_pcre
|
||||
dialplans/mod_dialplan_xml
|
||||
#directories/mod_ldap
|
||||
endpoints/mod_exosip
|
||||
endpoints/mod_iax
|
||||
|
@ -33,5 +32,4 @@ formats/mod_sndfile
|
|||
languages/mod_perl
|
||||
#languages/mod_spidermonkey
|
||||
timers/mod_softtimer
|
||||
|
||||
|
||||
#xml_int/mod_xml_rpc
|
||||
|
|
|
@ -137,6 +137,14 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
|
|||
char *extra_data);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Get the value of a field in a caller profile based on it's name
|
||||
\param caller_profile The caller profile
|
||||
\param name the name
|
||||
\note this function is meant for situations where the name paramater is the contents of the variable
|
||||
*/
|
||||
SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, char *name);
|
||||
|
||||
/*!
|
||||
\brief Create a new caller profile object
|
||||
\param pool memory pool to use
|
||||
|
|
|
@ -45,6 +45,16 @@ BEGIN_EXTERN_C
|
|||
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
|
||||
#define SWITCH_MAX_STREAMS 128
|
||||
|
||||
struct switch_core_time_duration {
|
||||
uint32_t mms;
|
||||
uint32_t ms;
|
||||
uint32_t sec;
|
||||
uint32_t min;
|
||||
uint32_t hr;
|
||||
uint32_t day;
|
||||
uint32_t yr;
|
||||
};
|
||||
|
||||
/*! \brief A message object designed to allow unlike technologies to exchange data */
|
||||
struct switch_core_session_message {
|
||||
/*! uuid of the sender (for replies)*/
|
||||
|
@ -954,6 +964,19 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
|
|||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_set_console(char *console);
|
||||
|
||||
/*!
|
||||
\brief Breakdown a number of milliseconds into various time spec
|
||||
\param total_ms a number of milliseconds
|
||||
\param duration an object to store the results
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration);
|
||||
|
||||
/*!
|
||||
\brief Number of microseconds the system has been up
|
||||
\return a number of microseconds
|
||||
*/
|
||||
SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
|
||||
|
||||
/*!
|
||||
\brief Get the output console
|
||||
\return the FILE stream
|
||||
|
|
|
@ -76,6 +76,7 @@ struct switch_directories {
|
|||
char *db_dir;
|
||||
char *script_dir;
|
||||
char *temp_dir;
|
||||
char *htdocs_dir;
|
||||
};
|
||||
|
||||
typedef struct switch_directories switch_directories;
|
||||
|
@ -166,7 +167,7 @@ typedef enum {
|
|||
SWITCH_IVR_OPTION_ASYNC = (1 << 0),
|
||||
SWITCH_IVR_OPTION_FILE = (1 << 1)
|
||||
} switch_ivr_option_t;
|
||||
|
||||
|
||||
/*!
|
||||
\enum switch_core_session_message_types_t
|
||||
\brief Possible types of messages for inter-session communication
|
||||
|
@ -676,7 +677,12 @@ typedef switch_status_t (*switch_module_resume_t) (void);
|
|||
typedef switch_status_t (*switch_module_status_t) (void);
|
||||
typedef switch_status_t (*switch_module_runtime_t) (void);
|
||||
typedef switch_status_t (*switch_module_shutdown_t) (void);
|
||||
|
||||
typedef struct switch_xml *switch_xml_t;
|
||||
typedef struct switch_core_time_duration switch_core_time_duration_t;
|
||||
typedef switch_xml_t (*switch_xml_search_function_t)(char *section,
|
||||
char *tag_name,
|
||||
char *key_name,
|
||||
char *key_value);
|
||||
|
||||
/* things we don't deserve to know about */
|
||||
|
||||
|
|
|
@ -1,4 +1,35 @@
|
|||
/* switch_xml.h
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
*
|
||||
* switch_xml.h -- XML PARSER
|
||||
*
|
||||
* Derived from EZXML http://ezxml.sourceforge.net
|
||||
* Original Copyright
|
||||
*
|
||||
* Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
|
||||
*
|
||||
|
@ -24,7 +55,7 @@
|
|||
|
||||
#ifndef _SWITCH_XML_H
|
||||
#define _SWITCH_XML_H
|
||||
|
||||
#include <switch_types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -34,11 +65,14 @@ BEGIN_EXTERN_C
|
|||
|
||||
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
|
||||
|
||||
#define SWITCH_XML_NAMEM 0x80 // name is malloced
|
||||
#define SWITCH_XML_TXTM 0x40 // txt is malloced
|
||||
#define SWITCH_XML_DUP 0x20 // attribute name and value are strduped
|
||||
typedef enum {
|
||||
SWITCH_XML_ROOT = (1 << 0), // root
|
||||
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
|
||||
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
|
||||
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
|
||||
} switch_xml_flag_t;
|
||||
|
||||
|
||||
typedef struct switch_xml *switch_xml_t;
|
||||
struct switch_xml {
|
||||
char *name; // tag name
|
||||
char **attr; // tag attributes { name, value, name, value, ... NULL }
|
||||
|
@ -49,31 +83,33 @@ struct switch_xml {
|
|||
switch_xml_t ordered; // next tag, same section and depth, in original order
|
||||
switch_xml_t child; // head of sub tag list, NULL if none
|
||||
switch_xml_t parent; // parent tag, NULL if current tag is root tag
|
||||
short flags; // additional information
|
||||
uint32_t flags; // additional information
|
||||
};
|
||||
|
||||
// Given a string of xml data and its length, parses it and creates an switch_xml
|
||||
// structure. For efficiency, modifies the data by adding null terminators
|
||||
// and decoding ampersand sequences. If you don't want this, copy the data and
|
||||
// pass in the copy. Returns NULL on failure.
|
||||
switch_xml_t switch_xml_parse_str(char *s, switch_size_t len);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len);
|
||||
|
||||
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
|
||||
// attempts to mem map the file. Failing that, reads the file into memory.
|
||||
// Returns NULL on failure.
|
||||
switch_xml_t switch_xml_parse_fd(int fd);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd);
|
||||
|
||||
// a wrapper for switch_xml_parse_fd() that accepts a file name
|
||||
switch_xml_t switch_xml_parse_file(const char *file);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file);
|
||||
|
||||
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
|
||||
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
|
||||
// or switch_xml_parse_fd()
|
||||
switch_xml_t switch_xml_parse_fp(FILE *fp);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp);
|
||||
|
||||
// returns the first child tag (one level deeper) with the given name or NULL
|
||||
// if not found
|
||||
switch_xml_t switch_xml_child(switch_xml_t xml, const char *name);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name);
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *childname, char *attrname, char *value);
|
||||
|
||||
// returns the next tag of the same name in the same section and depth or NULL
|
||||
// if not found
|
||||
|
@ -90,7 +126,7 @@ switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
|
|||
#define switch_xml_txt(xml) ((xml) ? xml->txt : "")
|
||||
|
||||
// returns the value of the requested tag attribute, or NULL if not found
|
||||
const char *switch_xml_attr(switch_xml_t xml, const char *attr);
|
||||
SWITCH_DECLARE(const char *) switch_xml_attr(switch_xml_t xml, const char *attr);
|
||||
|
||||
// Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a
|
||||
// variable length list of tag names and indexes. The argument list must be
|
||||
|
@ -98,24 +134,24 @@ const char *switch_xml_attr(switch_xml_t xml, const char *attr);
|
|||
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
|
||||
// This retrieves the title of the 3rd book on the 1st shelf of library.
|
||||
// Returns NULL if not found.
|
||||
switch_xml_t switch_xml_get(switch_xml_t xml, ...);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...);
|
||||
|
||||
// Converts an switch_xml structure back to xml. Returns a string of xml data that
|
||||
// must be freed.
|
||||
char *switch_xml_toxml(switch_xml_t xml);
|
||||
SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml);
|
||||
|
||||
// returns a NULL terminated array of processing instructions for the given
|
||||
// target
|
||||
const char **switch_xml_pi(switch_xml_t xml, const char *target);
|
||||
SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target);
|
||||
|
||||
// frees the memory allocated for an switch_xml structure
|
||||
void switch_xml_free(switch_xml_t xml);
|
||||
|
||||
// returns parser error message or empty string if none
|
||||
const char *switch_xml_error(switch_xml_t xml);
|
||||
SWITCH_DECLARE(const char *) switch_xml_error(switch_xml_t xml);
|
||||
|
||||
// returns a new empty switch_xml structure with the given root tag name
|
||||
switch_xml_t switch_xml_new(const char *name);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name);
|
||||
|
||||
// wrapper for switch_xml_new() that strdup()s name
|
||||
#define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
|
||||
|
@ -137,17 +173,33 @@ switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
|
|||
|
||||
// Sets the given tag attribute or adds a new attribute if not found. A value
|
||||
// of NULL will remove the specified attribute.
|
||||
void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
|
||||
SWITCH_DECLARE(void) switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
|
||||
|
||||
// Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
|
||||
#define switch_xml_set_attr_d(xml, name, value) \
|
||||
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
|
||||
|
||||
// sets a flag for the given tag and returns the tag
|
||||
switch_xml_t switch_xml_set_flag(switch_xml_t xml, short flag);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_set_flag(switch_xml_t xml, switch_xml_flag_t flag);
|
||||
|
||||
|
||||
// removes a tag along with all its subtags
|
||||
void switch_xml_remove(switch_xml_t xml);
|
||||
SWITCH_DECLARE(void) switch_xml_remove(switch_xml_t xml);
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload);
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_root(void);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
|
||||
char *tag_name,
|
||||
char *key_name,
|
||||
char *key_value,
|
||||
switch_xml_t *root,
|
||||
switch_xml_t *node);
|
||||
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(char *file_path, switch_xml_t *node);
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function);
|
||||
|
||||
END_EXTERN_C
|
||||
|
||||
|
|
|
@ -139,8 +139,6 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
|
|||
char temp[1024];
|
||||
size_t len;
|
||||
|
||||
printf("%s\n", argv[1]);
|
||||
|
||||
sprintf(temp, "%s\n", argv[1]);
|
||||
len = strlen(temp);
|
||||
|
||||
|
@ -152,6 +150,23 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
|
|||
return 0;
|
||||
}
|
||||
|
||||
static switch_status_t status_function(char *cmd, char *out, size_t outlen)
|
||||
{
|
||||
switch_core_time_duration_t duration;
|
||||
switch_core_measure_time(switch_core_uptime(), &duration);
|
||||
|
||||
snprintf(out, outlen, "<b>UP %u year(s), %u day(s), %u hour(s), %u minute(s), %u second(s), %u millisecond(s), %u microsecond(s)</b>\n",
|
||||
duration.yr,
|
||||
duration.day,
|
||||
duration.hr,
|
||||
duration.min,
|
||||
duration.sec,
|
||||
duration.ms,
|
||||
duration.mms
|
||||
);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t show_function(char *cmd, char *out, size_t outlen)
|
||||
{
|
||||
char sql[1024];
|
||||
|
@ -176,12 +191,20 @@ static switch_status_t show_function(char *cmd, char *out, size_t outlen)
|
|||
}
|
||||
|
||||
|
||||
static switch_api_interface_t status_api_interface = {
|
||||
/*.interface_name */ "status",
|
||||
/*.desc */ "status",
|
||||
/*.function */ status_function,
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
static switch_api_interface_t show_api_interface = {
|
||||
/*.interface_name */ "show",
|
||||
/*.desc */ "Show",
|
||||
/*.function */ show_function,
|
||||
/*.next */ NULL
|
||||
/*.next */ &status_api_interface
|
||||
};
|
||||
|
||||
static switch_api_interface_t pause_api_interface = {
|
||||
/*.interface_name */ "pause",
|
||||
/*.desc */ "Pause",
|
||||
|
|
|
@ -54,16 +54,19 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
|
|||
static void load_config(void)
|
||||
{
|
||||
char *cf = "dialplan_directory.conf";
|
||||
switch_config_t cfg;
|
||||
char *var, *val;
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
|
||||
if (!switch_config_open_file(&cfg, cf)) {
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
return;
|
||||
}
|
||||
|
||||
while (switch_config_next_pair(&cfg, &var, &val)) {
|
||||
if (!strcasecmp(cfg.category, "settings")) {
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr(param, "name");
|
||||
char *val = (char *) switch_xml_attr(param, "value");
|
||||
|
||||
if (!strcmp(var, "directory_name") && val) {
|
||||
set_global_directory_name(val);
|
||||
} else if (!strcmp(var, "directory_name") && val) {
|
||||
|
@ -79,7 +82,7 @@ static void load_config(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
switch_config_close_file(&cfg);
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t *session)
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
*
|
||||
* mod_dialplan_flatfile.c -- Example Dialplan Module
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
static const char modname[] = "mod_dialplan_flatfile";
|
||||
|
||||
|
||||
static switch_caller_extension_t *flatfile_dialplan_hunt(switch_core_session_t *session)
|
||||
{
|
||||
switch_caller_profile_t *caller_profile = NULL;
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
switch_channel_t *channel;
|
||||
char *cf = "extensions.conf";
|
||||
switch_config_t cfg;
|
||||
char *var, *val;
|
||||
char app[1024];
|
||||
char *context = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
if ((caller_profile = switch_channel_get_caller_profile(channel))) {
|
||||
context = caller_profile->context ? caller_profile->context : "default";
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
|
||||
if (!switch_config_open_file(&cfg, cf)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (switch_config_next_pair(&cfg, &var, &val)) {
|
||||
if (!strcasecmp(cfg.category, context)) {
|
||||
if (!strcmp(var, caller_profile->destination_number) && val) {
|
||||
char *data;
|
||||
|
||||
memset(app, 0, sizeof(app));
|
||||
strncpy(app, val, sizeof(app));
|
||||
|
||||
if ((data = strchr(app, ' ')) != 0) {
|
||||
*data = '\0';
|
||||
data++;
|
||||
} else {
|
||||
data = "";
|
||||
}
|
||||
|
||||
if (!extension) {
|
||||
if ((extension =
|
||||
switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_caller_extension_add_application(session, extension, app, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_config_close_file(&cfg);
|
||||
|
||||
if (extension) {
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Cannot locate extension %s in context %s\n", caller_profile->destination_number, context);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
|
||||
}
|
||||
|
||||
return extension;
|
||||
}
|
||||
|
||||
|
||||
static const switch_dialplan_interface_t flatfile_dialplan_interface = {
|
||||
/*.interface_name = */ "flatfile",
|
||||
/*.hunt_function = */ flatfile_dialplan_hunt
|
||||
/*.next = NULL */
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t flatfile_dialplan_module_interface = {
|
||||
/*.module_name = */ modname,
|
||||
/*.endpoint_interface = */ NULL,
|
||||
/*.timer_interface = */ NULL,
|
||||
/*.dialplan_interface = */ &flatfile_dialplan_interface,
|
||||
/*.codec_interface = */ NULL,
|
||||
/*.application_interface = */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &flatfile_dialplan_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
LDFLAGS += -lpcre -L/usr/local/lib
|
||||
|
||||
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
|
||||
|
||||
depends:
|
||||
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install pcre-6.4.tar.gz --prefix=$(PREFIX)
|
||||
|
||||
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
|
||||
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
|
||||
$(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(LDFLAGS)
|
||||
|
||||
|
||||
clean:
|
||||
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
|
||||
|
||||
install:
|
||||
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
|
|
@ -1,224 +0,0 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthmct@yahoo.com>
|
||||
*
|
||||
*
|
||||
* mod_pcre.c -- Regex Dialplan Module
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <pcre.h>
|
||||
|
||||
static const char modname[] = "mod_pcre";
|
||||
|
||||
#define cleanre() if (re) {\
|
||||
pcre_free(re);\
|
||||
re = NULL;\
|
||||
}
|
||||
|
||||
static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
|
||||
{
|
||||
switch_caller_profile_t *caller_profile;
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
switch_channel_t *channel;
|
||||
char *cf = "regextensions.conf";
|
||||
switch_config_t cfg;
|
||||
char *var, *val;
|
||||
char app[1024] = "";
|
||||
int catno = -1;
|
||||
char *exten_name = NULL;
|
||||
pcre *re = NULL;
|
||||
int match_count = 0;
|
||||
int ovector[30];
|
||||
int skip = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
|
||||
if (!switch_config_open_file(&cfg, cf)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (switch_config_next_pair(&cfg, &var, &val)) {
|
||||
if (cfg.catno != catno) { /* new category */
|
||||
catno = cfg.catno;
|
||||
exten_name = cfg.category;
|
||||
cleanre();
|
||||
match_count = 0;
|
||||
skip = 0;
|
||||
|
||||
if (!strcasecmp(exten_name, "outbound") && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
|
||||
skip = 1;
|
||||
} else if (!strcasecmp(exten_name, "inbound") && switch_channel_test_flag(channel, CF_OUTBOUND)) {
|
||||
skip = 1;
|
||||
} else if (*exten_name == 's' && *(exten_name+1) == ':') {
|
||||
exten_name += 2;
|
||||
if (strcasecmp(exten_name, caller_profile->source)) {
|
||||
skip = 1;
|
||||
}
|
||||
} else if (*exten_name == 'c' && *(exten_name+1) == ':') {
|
||||
exten_name += 2;
|
||||
if (strcasecmp(exten_name, caller_profile->context)) {
|
||||
skip = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(var, "regex")) {
|
||||
const char *error = NULL;
|
||||
int erroffset = 0;
|
||||
|
||||
cleanre();
|
||||
re = pcre_compile(val, /* the pattern */
|
||||
0, /* default options */
|
||||
&error, /* for error message */
|
||||
&erroffset, /* for error offset */
|
||||
NULL); /* use default character tables */
|
||||
if (error) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "COMPILE ERROR: %d [%s]\n", erroffset, error);
|
||||
cleanre();
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
match_count = pcre_exec(re, /* result of pcre_compile() */
|
||||
NULL, /* we didn't study the pattern */
|
||||
caller_profile->destination_number, /* the subject string */
|
||||
(int) strlen(caller_profile->destination_number), /* the length of the subject string */
|
||||
0, /* start at offset 0 in the subject */
|
||||
0, /* default options */
|
||||
ovector, /* vector of integers for substring information */
|
||||
sizeof(ovector) / sizeof(ovector[0])); /* number of elements (NOT size in bytes) */
|
||||
} else if (match_count > 0 && !strcasecmp(var, "match")) {
|
||||
if (!re) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: match without regex in %s line %d\n", cfg.path,
|
||||
cfg.lineno);
|
||||
continue;
|
||||
} else {
|
||||
char newval[1024] = "";
|
||||
char index[10] = "";
|
||||
char replace[128] = "";
|
||||
unsigned int x, y = 0, z = 0, num = 0;
|
||||
char *data;
|
||||
|
||||
for (x = 0; x < sizeof(newval) && x < strlen(val);) {
|
||||
if (val[x] == '$') {
|
||||
x++;
|
||||
|
||||
while (val[x] > 47 && val[x] < 58) {
|
||||
index[z++] = val[x];
|
||||
x++;
|
||||
}
|
||||
index[z++] = '\0';
|
||||
z = 0;
|
||||
num = atoi(index);
|
||||
|
||||
if (pcre_copy_substring
|
||||
(caller_profile->destination_number, ovector, match_count, num, replace,
|
||||
sizeof(replace)) > 0) {
|
||||
unsigned int r;
|
||||
for (r = 0; r < strlen(replace); r++) {
|
||||
newval[y++] = replace[r];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newval[y++] = val[x];
|
||||
x++;
|
||||
}
|
||||
}
|
||||
newval[y++] = '\0';
|
||||
|
||||
memset(app, 0, sizeof(app));
|
||||
switch_copy_string(app, newval, sizeof(app));
|
||||
|
||||
if ((data = strchr(app, ' ')) != 0) {
|
||||
*data = '\0';
|
||||
data++;
|
||||
}
|
||||
|
||||
if (!extension) {
|
||||
if ((extension =
|
||||
switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_caller_extension_add_application(session, extension, app, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_config_close_file(&cfg);
|
||||
|
||||
if (extension) {
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
} else {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
|
||||
}
|
||||
|
||||
cleanre();
|
||||
return extension;
|
||||
}
|
||||
|
||||
|
||||
static const switch_dialplan_interface_t dialplan_interface = {
|
||||
/*.interface_name = */ "pcre",
|
||||
/*.hunt_function = */ dialplan_hunt
|
||||
/*.next = NULL */
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t dialplan_module_interface = {
|
||||
/*.module_name = */ modname,
|
||||
/*.endpoint_interface = */ NULL,
|
||||
/*.timer_interface = */ NULL,
|
||||
/*.dialplan_interface = */ &dialplan_interface,
|
||||
/*.codec_interface = */ NULL,
|
||||
/*.application_interface = */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &dialplan_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
|
@ -1,212 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="mod_pcre"
|
||||
ProjectGUID="{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
|
||||
RootNamespace="mod_pcre"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_pcre Debug"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(InputDir)..\..\..\include";"$(InputDir)include";"$(InputDir)..\..\..\..\libs\include";"$(InputDir)..\..\..\..\libs\pcre";"$(InputDir)..\..\..\..\libs\pcre\win32""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS;PCRE_STATIC"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
WarnAsError="true"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libpcre.lib"
|
||||
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_pcre.dll"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="$(InputDir)..\..\..\..\libs\pcre\win32\$(OutDir);..\..\..\..\w32\vsnet\$(OutDir)"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/mod_pcre.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/mod_pcre.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||