Asterisk 18 - Sip / PJSip

Hi Asterisk Community, Before you flame me about im using old asterisk and not PJSIP and only SIP, yes i know im working on it. but for now im trying to figure out if it is even possible to either in sip or pjsip to add stuff in the exten and then pick it up in the dialplan. for instance.
Sip.conf
[1000]
defaultuser=1000
secret=whocaresitsold
context=default
disallow=all
allow=g729
variable1=1
variable2=2

in pjsip
[1000]
type=endpoint
transport=transport-udp
context=default
disallow=all
allow=g729
auth=1000
aors=1000
direct_media=no
rtp_symmetric=yes
force_rport=yes
variable1=1
variable2=2

[1000]
type=auth
auth_type=userpass
password=whocarespjsipsucks
username=1000

[1000]
type=aor
max_contacts=2

so when loading pjsip or sip it does not give an error but i have no clue on how to NoOp it in the dialplan to see if i actually see that variables.

and to make it worse, i cant get phones to work right on pjsip but sip works fine.

It does give an error in PJSIP at configuration load time, it won’t allow invalid configuration options like that.

What exactly are you trying to achieve? Do you want to retrieve such things arbitrarily from other channels/endpoints in the dialplan? Do you just want the information to be available in the dialplan when a call from that endpoint occurs?

Hi, thanks for the msg. So the idea is, to avoid having multiple context’s in extensions.conf, i want to say in the extension itself that if the call should be recorder it should do a jump to that recording context. instead of just forcing it to that context from the sip.

So currently i use the callgroup=0 and callgroup=1 to specify if the person can make international calls or not. and then i just set that per extension. but now i want to see if i can do the same for recordings.

You can use set_var on the PJSIP endpoint or setvar on the SIP user/peer/friend to configure a dialplan variable that gets set on channels for them. Example:

set_var=RECORDING=yes

Would cause the dialplan variable RECORDING to be set to yes:

${RECORDING}

I also taught that would work. I tried set_var setvar nothing. It does not give an error. loads fine on sip and dialplan but when dialing it just shows blank for that variable.

i wonder if this would work. if i say sip show peers i get a list of options.
now i wonder if i can not manipulate some other settings and use that. like all those that are blank.
Like this: SIP Options : (none) or Named Callgr : or Parkinglot :

Not sure what they used for. but let me see if i can find the documents on sip and their stuff.

  • Name : 1000
    Description : 1000
    Secret :
    MD5Secret :
    Remote Secret:
    Context : default
    Record On feature : automon
    Record Off feature : automon
    Subscr.Cont. :
    Language :
    Tonezone :
    AMA flags : Unknown
    Transfer mode: open
    CallingPres : Presentation Allowed, Not Screened
    Callgroup : 0
    Pickupgroup :
    Named Callgr :
    Nam. Pickupgr:
    MOH Suggest :
    Mailbox : 1000
    VM Extension : asterisk
    LastMsgsSent : 3/0
    Call limit : 10
    Max forwards : 0
    Dynamic : Yes
    Callerid : “1000” <1000>
    MaxCallBR : 384 kbps
    Expire : 69
    Insecure : no
    Force rport : No
    Symmetric RTP: No
    ACL : No
    ContactACL : No
    DirectMedACL : No
    T.38 support : Yes
    T.38 EC mode : FEC
    T.38 MaxDtgrm: 4294967295
    DirectMedia : No
    PromiscRedir : No
    User=Phone : No
    Video Support: No
    Text Support : No
    Ign SDP ver : No
    Trust RPID : No
    Send RPID : No
    Path support : No
    Path : N/A
    TrustIDOutbnd: Legacy
    Subscriptions: Yes
    Overlap dial : No
    DTMFmode : rfc2833
    Timer T1 : 500
    Timer B : 32000
    ToHost :
    Addr->IP :
    Defaddr->IP : (null)
    Prim.Transp. : UDP
    Allowed.Trsp : UDP
    Def. Username: 1000
    SIP Options : (none)
    Codecs : (gsm)
    Auto-Framing : No
    Status : UNREACHABLE
    Useragent : 3CXPhone 6.0.26523.0
    Reg. Contact : sip:
    Qualify Freq : 60000 ms
    Keepalive : 0 ms
    Sess-Timers : Accept
    Sess-Refresh : uas
    Sess-Expires : 1800 secs
    Min-Sess : 90 secs
    RTP Engine : asterisk
    Parkinglot :
    Use Reason : No
    Encryption : No
    RTCP Mux : No

Did you actually use “setvar” in the configuration for chan_sip for the correct device and reload? It will appear in that output if configured.

Sorry for the late late late reply. Was quite busy with other stuff. So i tried the following.
setvar=Record0=yes
set_var=Record1=yes
Set_Var=Record2=yes
SET_VAR=Record3=yes
SETVAR=Record4=yes

In dialplan i tried:
exten=> _X.,1,NoOp(Record0 is: $(Record0))
exten=> _X.,n,NoOp(Record1 is: $(Record1))
exten=> _X.,n,NoOp(Record2 is: $(Record2))
exten=> _X.,n,NoOp(Record3 is: $(Record3))
exten=> _X.,n,NoOp(Record4 is: $(Record4))

The output i can see is all is blank not a single 1 of them show yes

And i did do a sip reload, dialplan reload even core restart now and nothing.

So not sure whats up with that. Even tried it in PJSIP and still did not read it.

Because this is incorrect, if what you’ve provided is what you’re actually using.

It should be:

exten=> _X.,n,NoOp(Record4 is: ${Record4})

{ and }, not ( and )

sorry that was a typo, it should have been ${Record0} but it did not want to copy and past so typed it and typed it wrong. my bad.

I would suggest providing a log of console output then.

but i taught of another idea on how to set this. a bit different but getting the result i need.

I made a file rec.conf which has just EXT’s in it like 6000, 6100, 1111 and so on, then if the EXT that is making the call or receiving the call is within that file it just runs an extra few lines to start the recording.

This is the current context i made. I believe there is alot of improvements to be made and its not complete as of yet.

[defaultout]

exten => 1,1,Goto(time,${EXTEN},1)
exten => _X.,1,Answer()

exten => _X.,n,Set(my_callgroup=${CHANNEL(callgroup)})
exten => _X.,n,Set(pickupgroup=${CHANNEL(Pickupgroup)})
exten => _X.,n,Set(callerExtension=${CALLERID(num)})
exten => _X.,n,NoOp(Callgroup assigned to this channel is ${my_callgroup})
exten => _X.,n,NoOp(Pickupgroup : ${pickupgroup})
exten => _X.,n,GotoIf($[${LEN(${EXTEN})} > 4]?CheckExclusion:NoAuth)
exten => _X.,n(CheckExclusion),Set(ExcludedNumberFile=/etc/asterisk/exclude.conf)
exten => _X.,n,Set(ExcludedNumber=${EXTEN})
exten => _X.,n,Set(ExcludedNumber=${CUT(ExcludedNumber,/,1)})
exten => _X.,n,Set(ExcludedNumberFound=0)
exten => _X.,n,System(cat ${ExcludedNumberFile} | grep -q “^${ExcludedNumber}$”)
exten => _X.,n,GotoIf($[${SYSTEMSTATUS} = SUCCESS]?Exclude:Auth)
exten => _X.,n(Exclude),Dial(IAX2/vm40100/0${EXTEN:2})
exten => _X.,n,Hangup()

exten => _X.,n(NoAuth),Goto(defaultin,+2711560${EXTEN},1)
exten => _X.,n,Hangup()

exten => _X.,n(Auth),Authenticate(/etc/asterisk/pwds,am,6)
exten => _X.,n,Set(RecNumberFile=/etc/asterisk/recordext.conf)
exten => _X.,n,Set(RecNumber=${callerExtension})
exten => _X.,n,Set(RecNumber=${CUT(RecNumber,/,1)})
exten => _X.,n,Set(RecNumberFound=0)
exten => _X.,n,System(cat ${RecNumberFile} | grep -q “^${RecNumber}$”)
exten => _X.,n,GotoIf($[${SYSTEMSTATUS} = SUCCESS]?Rec:Cont)
exten => _X.,n,Hangup()

exten => _X.,n(Cont),GotoIf($[${my_callgroup} = 0]?Norm:Inter)
exten => _X.,n,Hangup()

exten => _X.,n(Norm),NoOp(Extension should not be recorded : ${pickupgroup})
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “80”]?dial_vodacom)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “81”]?dial_mtn)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “82”]?dial_liquid)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “83”]?dial_vox)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “84”]?dial_tforge:dial_default)
exten => _X.,n,Hangup()
exten => _X.,n(dial_default),Dial(IAX2/vm40100/${EXTEN})
exten => _X.,n,Hangup()
exten => _X.,n(dial_vodacom),Dial(IAX2/vodacom/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(dial_mtn),Dial(IAX2/mtn/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(dial_liquid),Dial(IAX2/liquid/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(dial_vox),Dial(IAX2/vox/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(dial_tforge),Dial(IAX2/tforge/${EXTEN:2})
exten => _X.,n,Hangup()

exten => _X.,n(Inter),NoOp(International Call Made : ${my_callgroup})
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN})
exten => _X.,n,Hangup()

exten => _X.,n(Rec),NoOp(Extension should be recorded : ${callerExtension})
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “80”]?rec_vodacom)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “81”]?rec_mtn)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “82”]?rec_liquid)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “83”]?rec_vox)
exten => _X.,n,GotoIf($[“${EXTEN:0:2}” = “84”]?rec_tforge:rec_default)
exten => _X.,n,Hangup()
exten => _X.,n(rec_vodacom),NoOp(Extension should be recorded : Vodacom)
exten => _X.,n,Gosub(recordingout,s,1(${EXTEN:2}))
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(rec_mtn),NoOp(Extension should be recorded : Mtn)
exten => _X.,n,Gosub(recordingout,s,1(${EXTEN:2}))
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(rec_liquid),NoOp(Extension should be recorded : Liquid)
exten => _X.,n,Gosub(recordingout,s,1(${EXTEN:2}))
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(rec_vo),NoOp(Extension should be recorded : Vox)
exten => _X.,n,Gosub(recordingout,s,1(${EXTEN:2}))
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(rec_tforge),NoOp(Extension should be recorded : TForge)
exten => _X.,n,Gosub(recordingout,s,1(${EXTEN:2}))
exten => _X.,n,Dial(IAX2/vm40100/${EXTEN:2})
exten => _X.,n,Hangup()
exten => _X.,n(rec_default),NoOp(Extension should be recorded : Default)
exten => _X.,n,Set(fixed=${IF($[${LEN(${EXTEN})} > 11]?${EXTEN:2}:${EXTEN})})
exten => _X.,n,Gosub(recordingout,s,1(${fixed}))
exten => _X.,n,Dial(IAX2/vm40100/${fixed})
exten => _X.,n,Hangup()

[recordingout]
exten => s,1,Set(DATE=${STRFTIME(${EPOCH},UTC-2,%Y%m%d%H%M)})
exten => s,n,Set(RECFILE=/home/RecTest/Out_${ARG1}${DATE}${CALLERID(num)})
exten => s,n,MixMonitor(${RECFILE}.wav,/etc/asterisk/soxthefile.sh ${RECFILE})
exten => s,n,Return()

[recordingin]
exten => s,1,Set(DATE=${STRFTIME(${EPOCH},UTC-2,%Y%m%d%H%M)})
exten => s,n,Set(RECFILE=/home/RecTest/In_${ARG1}${DATE}${CALLERID(num)})
exten => s,n,MixMonitor(${RECFILE}.wav,/etc/asterisk/soxthefile.sh ${RECFILE})
exten => s,n,Return()

You could simplify this as:

        same = n,       system(grep --quiet '^${ExcludedNumber}$' '${ExcludedNumberFile}')

thanks, see i knew there is some stuff that can be refined into making it better and more simple. but for a beginner that has started 7 months ago i dont think im doing too badly.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.