Skip to main content

Modify base-dialout script

Posted by aleivag on Wed, 10/06/2010

Hello:

i had the same problem than lvejar had on topic http://www.thirdlane.com/forum/sip-trunk-callerid-missing

i could not pass the caller id from an incoming call to a siptrunk if this use username/password/host to authenticate.

so after some debug i realise that the script "nl-dialout-base" what the problem. so i change i clone that script and change it, basicaly all i did was comment out every line where something like Set(CALLERID(num)=... apear..

it work but i will like to know if i did not break anything..

in the next post i will append the modified version of the script


Submitted by aleivag on Wed, 10/06/2010 Permalink

MODIFIED VERSION

; first argument is the timeout, second is the first trunk
exten => s,1,Set(status=${DB(TL/TENANT/${tenant}/status)})
exten => s,n,GotoIf($["${status}" != "0"]?enabled)
exten => s,n,Congestion(10)
exten => s,n,Hangup

exten => s,n(enabled),GotoIf($["${TL_ENABLE_MAXCALLS_CHECK}" != "1"]?allclear)
exten => s,n,Set(MAXCALLS=${DB(TL/TENANT/${tenant}/maxcalls)})
exten => s,n,GotoIf($["${MAXCALLS}" = ""]?allclear)
exten => s,n,Set(GROUP(callpaths)=${tenant})
exten => s,n,NoOp(GROUP_COUNT = ${GROUP_COUNT(${tenant}@callpaths)})
exten => s,n,GotoIf($[${GROUP_COUNT(${tenant}@callpaths)} > ${MAXCALLS}]?allbusy:allclear)
exten => s,n(allbusy),Playback(tl/all-circuits-busy)
exten => s,n,Hangup

exten => s,n(allclear),Set(i=2)
;;; username on the originating trunk or device is required for this to work

exten => s,n,Macro(tl-set-myvariables)

exten => s,n,SetAMAFlags(billing)

;; call recording
exten => s,n,Set(RECORD=${DB(TL/${MYID}/RECORD)})
exten => s,n,GotoIf($["${RECORD}" = ""]?done_checkrecord)
exten => s,n,GotoIf($["${RECORD}" = "2"]?check_onetouch)
exten => s,n,GotoIf($["${RECORDING_FORMAT}" != ""]?record)
exten => s,n,Set(RECORDING_FORMAT=wav)
exten => s,n(record),MixMonitor(out-${DIALED_NUMBER}-${STRFTIME(,,%F-%T)}-${MYEXTENSION}${TL_DASH}${tenant}.${RECORDING_FORMAT},b)
exten => s,n,Goto(done_checkrecord)
exten => s,n(check_onetouch),Set(RECORD_OPTIONS=W)
exten => s,n,Set(TOUCH_MONITOR_FORMAT=${RECORDING_FORMAT})
exten => s,n,Set(TOUCH_MONITOR=out-${DIALED_NUMBER}-${STRFTIME(,,%F-%T)}-${MYEXTENSION}${TL_DASH}${tenant})

exten => s,n(done_checkrecord),NoOp(RECORD=${RECORD})
exten => s,n,NoOp(TOUCH_MONITOR=${TOUCH_MONITOR})
exten => s,n,NoOp(RECORD_OPTIONS=${RECORD_OPTIONS})
exten => s,n,NoOp(RECORDING_FORMAT=${RECORDING_FORMAT})

;; check which caller id to use - tenant/company level or individual
exten => s,n,Set(CALLERID(name)=${DB(TL/TENANT/${tenant}/calleridname)})
;;; if not multi-tenant - bypass some code
exten => s,n,GotoIf($["${tenant}" = ""]?calleridallowed)
exten => s,n,Set(temp=${DB(TL/TENANT/${tenant}/allowaccountcode)})
exten => s,n,GotoIf($["${temp}" != "0"]?accountcodeallowed)
exten => s,n,Set(CDR(accountcode)=${DB(TL/TENANT/${tenant}/accountcode)})
;; set using tenant level caller id

exten => s,n(accountcodeallowed),NoOp(${CALLERID(all)})

;;exten => s,n(accountcodeallowed),Set(CALLERID(num)=${DB(TL/TENANT/${tenant}/callerid)})

;; now check if override is allowed
exten => s,n,Set(temp=${DB(TL/TENANT/${tenant}/allowcallerid)})
exten => s,n,GotoIf($["${temp}" != "0"]?calleridallowed)
exten => s,n,Goto(onetrunk,1)
;; individual external caller id
exten => s,n(calleridallowed),NoOp(CLIMYID=${CLIMYID})
exten => s,n,NoOp(MYID=${MYID})
exten => s,n,Set(CLI=${DB(TL/${CLIMYID}/callerid)})
exten => s,n,GotoIf($["${CLI}" != ""]?chkcallfwd)
exten => s,n,Set(CLI=${DB(TL/${MYID}/callerid)})
exten => s,n,GotoIf($["${CLI}" != ""]?chkcallfwd)
exten => s,n,Set(CLI=${DB(TL/TENANT/${tenant}/callerid)})
exten => s,n,NoOp(CLI=${CLI})

exten => s,n(chkcallfwd),NoOp(MYID=${MYID})

exten => s,n,NoOp(INCOMINGCLI=${INCOMINGCLI})
exten => s,n,NoOp(CALLFWD=${CALLFWD})

exten => s,n,GotoIf($["${CALLFWD}" = "" & "${FOLLOWME}" != "1"]?setcalleridasabove)
exten => s,n,Set(CDR(accountcode)=${tenant})
exten => s,n,NoOp(CFRETAINCLI=TL/${tenant}${TL_DASH}${ORIG_EXTEN}/CFRETAINCLI)

exten => s,n,GotoIf($["${DB(TL/${tenant}${TL_DASH}${ORIG_EXTEN}/CFRETAINCLI)}" = ""]?setcalleridasabove)

;;; check if globally allowed to set caller id to original
exten => s,n,Set(ALLOW_INCOMINGCLI=${DB(TL/allow_original_callerid)})
exten => s,n,GotoIf($["${ALLOW_INCOMINGCLI}" = "0"]?setcalleridasabove)
exten => s,n,GotoIf($["${INCOMINGCLI}" = ""]?setcalleridasabove)
exten => s,n,Set(CLI=${INCOMINGCLI})

exten => s,n(setcalleridasabove),GotoIf($["${CLI}" = ""]?nocallerid)
;;exten => s,n,Set(CALLERID(num)=${CLI})

exten => s,n(nocallerid),Set(temp=${DB(TL/${MYID}/calleridname)})
exten => s,n,GotoIf($["${temp}" = ""]?onetrunk,1)

exten => s,n,Set(CALLERID(name)=${temp})
exten => s,n,Goto(onetrunk,1)

exten => onetrunk,1,Set(FULLNAME=${ARG${i}})
exten => onetrunk,n,Set(TRUNK=${CUT(FULLNAME,/,2)})
exten => onetrunk,n,GotoIf($["${LEN(${TRUNK})}" = "0"]?failed,1)
exten => onetrunk,n,Set(TRUNK_STATUS=${TRUNK_STATUS_${TRUNK}})
exten => onetrunk,n,GotoIf($["${TRUNK_STATUS}" = "0"]?next,1)
exten => onetrunk,n,Set(ROUTE_PREPEND=${ARG$[${i} + 1]})
exten => onetrunk,n,Set(ROUTE_STRIP=${ARG$[${i} + 2]})
exten => onetrunk,n,Set(ROUTE_OPTIONS=${ARG$[${i} + 3]}${RECORD_OPTIONS})
exten => onetrunk,n,Set(NUMBER_TO_DIAL=${ROUTE_PREPEND}${DIALED_NUMBER:${ROUTE_STRIP}})
exten => onetrunk,n,Set(TRUNK_DIALSTRING=${TRUNK_DIALSTRING_${TRUNK}})
exten => onetrunk,n,Set(TRUNK_NAME=${TRUNK_NAME_${TRUNK}})
exten => onetrunk,n,Set(TRUNK_PROTOCOL=${TRUNK_PROTOCOL_${TRUNK}})
exten => onetrunk,n,Set(TRUNK_STRIP=${TRUNK_STRIP_${TRUNK}})
exten => onetrunk,n,Set(TRUNK_PREPEND=${TRUNK_PREPEND_${TRUNK}})
;;exten => onetrunk,n,Set(CALLERID(num)=${TRUNK_CLI_PREPEND_${TRUNK}}${CALLERID(num):${TRUNK_CLI_STRIP_${TRUNK}}})

exten => onetrunk,n,GotoIf($["${TRUNK_DIALSTRING}" != ""]?dial-CUSTOM,1)
exten => onetrunk,n,Goto(dial-${TRUNK_PROTOCOL},1)

;;SIP
;;;; add SIP headers
exten => dial-SIP,1,Set(headernum=1)
exten => dial-SIP,n(getoneheader),GotoIf(${DB_EXISTS(TL/${TRUNK}/headers/${headernum})}?:routeoptions)
exten => dial-SIP,n,Set(HEADER=${DB(TL/${TRUNK}/headers/${headernum})})
exten => dial-SIP,n,SipAddHeader(${EVAL(${HEADER})})
exten => dial-SIP,n,Set(headernum=$[${headernum} + 1])
exten => dial-SIP,n,Goto(getoneheader)

exten => dial-SIP,n(routeoptions),Dial(SIP/${TRUNK_PREPEND}${NUMBER_TO_DIAL:${TRUNK_STRIP}}@${TRUNK_NAME},${ARG1},${ROUTE_OPTIONS})
exten => dial-SIP,n,Goto(dial-${DIALSTATUS},1)
;;IAX
exten => dial-IAX,1,Dial(IAX2/${TRUNK_NAME}/${TRUNK_PREPEND}${NUMBER_TO_DIAL:${TRUNK_STRIP}},${ARG1},${ROUTE_OPTIONS})
exten => dial-IAX,n,Goto(dial-${DIALSTATUS},1)
;;ZAP
exten => dial-ZAP,1,Set(CIDNAME=${CALLERID(name)})
exten => dial-ZAP,n,Set(CALLERID(name)=)
exten => dial-ZAP,n,Dial(ZAP/${TRUNK_NAME}/${TRUNK_PREPEND}${NUMBER_TO_DIAL:${TRUNK_STRIP}},${ARG1},${ROUTE_OPTIONS})
exten => dial-ZAP,n,Set(CALLERID(name)=${CIDNAME})
exten => dial-ZAP,n,Goto(dial-${DIALSTATUS},1)
;;DAHDI
exten => dial-DAHDI,1,Set(CIDNAME=${CALLERID(name)})
exten => dial-DAHDI,n,Set(CALLERID(name)=)
exten => dial-DAHDI,n,Dial(DAHDI/${TRUNK_NAME}/${TRUNK_PREPEND}${NUMBER_TO_DIAL:${TRUNK_STRIP}},${ARG1},${ROUTE_OPTIONS})
exten => dial-DAHDI,n,Set(CALLERID(name)=${CIDNAME})
exten => dial-DAHDI,n,Goto(dial-${DIALSTATUS},1)
;;CUSTOM
exten => dial-CUSTOM,1,Set(DS1=${CUT(TRUNK_DIALSTRING,$,1)})
exten => dial-CUSTOM,n,Set(DS2=${CUT(TRUNK_DIALSTRING,$,2)})
exten => dial-CUSTOM,n,Dial(${DS1}${NUMBER_TO_DIAL}${DS2},${ARG1},${ROUTE_OPTIONS})
exten => dial-CUSTOM,n,Goto(dial-${DIALSTATUS},1)

exten => dial-CHANUNAVAIL,1,Goto(next,1)
exten => dial-CONGESTION,1,Goto(next,1)
exten => dial-BUSY,1,Goto(busy,1)
exten => dial-CANCEL,1,Goto(done,1)
exten => dial-NOANSWER,1,Goto(done,1)
exten => dial-ANSWER,1,Goto(done,1)

exten => next,1,Set(i=$[${i} + 4])
exten => next,2,Goto(onetrunk,1)

exten => done,1,NoOp(done)
exten => busy,1,PlayTones(busy)
exten => busy,2,Busy(10)
exten => busy,3,Hangup

exten => failed,1,PlayTones(congestion)
exten => failed,2,Congestion(10)
exten => failed,3,Hangup

Submitted by aleivag on Wed, 10/06/2010 Permalink

the diff between the my file and the original (in that orden)

48,53c48
<
< exten => s,n(accountcodeallowed),NoOp(${CALLERID(all)})
<
< ;;exten => s,n(accountcodeallowed),Set(CALLERID(num)=${DB(TL/TENANT/${tenant}/callerid)})
<
<
---
> exten => s,n(accountcodeallowed),Set(CALLERID(num)=${DB(TL/TENANT/${tenant}/callerid)})
87c82
< ;;exten => s,n,Set(CALLERID(num)=${CLI})
---
> exten => s,n,Set(CALLERID(num)=${CLI})
109c104
< ;;exten => onetrunk,n,Set(CALLERID(num)=${TRUNK_CLI_PREPEND_${TRUNK}}${CALLERID(num):${TRUNK_CLI_STRIP_${TRUNK}}})
---
> exten => onetrunk,n,Set(CALLERID(num)=${TRUNK_CLI_PREPEND_${TRUNK}}${CALLERID(num):${TRUNK_CLI_STRIP_${TRUNK}}})
164a160
>

Submitted by aleivag on Sat, 10/09/2010 Permalink

thank you for your powerfull insight, and your perfect lack of an answer.... actualy lvejar post the same problem and you left him in a cliff-hanger...

my question was... ¿did i break something?.. and my new question is "how do i use this not-stupid-pretty-obvious-script, that you talk about?

Submitted by eeman on Sat, 10/09/2010 Permalink

the script has nearly the same name and it even says exactly what it does. if you want people to give you every answer without any effort on your part this probably isnt going to be the best venue for you. The free support subscribers give on this forum is more of a nudge in the right direction. If you're looking for more hand holding that usually requires paid support. Since you seem to be able to modify dialplan it seems odd that you are unable to find a script with practically the exact same name and describes keeping original callerid.

Submitted by aleivag on Sun, 10/10/2010 Permalink

let me start by saying you are right, "free support subscribers give on this forum is more of a nudge in the right direction" i understand that, but you must agree with me that "That was fairly stupid..." does qualify more as a troll actitude than as "nudge in the right direction".

it may be "free support", but is still customer support, you are the visible face of thirdlane, not some random google-public forum, so calling people stupid, is not aceptable, and in some places of the world (like USA) illegal.

as this is a waste of time, i won't be posting any more...

Submitted by eeman on Mon, 10/11/2010 Permalink

no one called you stupid. Let me start by giving you some advice on getting feedback on just about every internet forum known to man. You need to grow some tougher skin. Every forum has obvious flames, and plenty of cases where people read WAY too much into what is said. You're going to see yourself insulted every where you go if you don't man up and deal with it. When I insult you its going to be obvious, no passive voice simile's or vague metaphors. For example:

I think your a hyper-sensitive little baby who needs to put his Big-Girl Panties on before posting on the internet and stop whining about how his labia is swollen and sore.

See the difference?