Pjsip database of registrations

So i am trying to always check whether the called extension is already registered in my database of registration before making the call otherwise then i would not make the call if not registered.
so earlier using chan_sip every registered endpoint was being added to /SIP/registry/EXTEN
then in my dialplan i would then check if this database exists or not and it was working so fine.
but when i moved to chan_psjip then every new registered endpoint would be added this way:

/registrar/contact/37200;@80316366e84eb97b6234ff873527f1e5: {“via_addr":“192.168.133.9”,“qualify_timeout”:“3.000000”,“call_id”:“U8vSqJ3wUy”,“reg_server”:"",“prune_on_boot”:“no”,“path”:"",“endpoint”:“37200”,“via_port”:“5060”,“authenticate_qualify”:“no”,“uri”:"sip:37200@192.168.133.9;transport=udp”,“qualify_frequency”:“0”,“user_agent”:“Linphonec/3.12.0 (belle-sip/1.6.3)”,“expiration_time”:“1583910539”,“outbound_proxy”:""}
/registrar/contact/37301;@46ba82eee12e5c52b156464ed1182ef9: {“via_addr”:“192.168.133.111”,“qualify_timeout”:“3.000000”,“call_id”:“mq0u3q2J6wdqJC0RiWkAzA…”,“reg_server”:"",“prune_on_boot”:“no”,“path”:"",“endpoint”:“37301”,“via_port”:“49142”,“authenticate_qualify”:“no”,“uri”:“sip:37301@192.168.133.111:49142;transport=UDP;rinstance=1a2057f2e9c432f5”,“qualify_frequency”:“0”,“user_agent”:“Z 5.3.8 rv2.9.30-mod”,“expiration_time”:“1583910361”,“outbound_proxy”:""}

this is how is checked before :
same => n,GotoIf({DB_EXISTS(SIP/Registry/{EXTEN:0:5})}?:not-found,1)

now i have to do this :
same => n,GotoIf({DB_EXISTS(registrar/contact/{EXTEN:0:5}(followed with this which i cant understand : @80316366e84eb97b6234ff873527f1e5))}?:not-found,1)

so my question is how could i edit how the registered contacts on pjsip would be stored as

registrar/contact/EXTEN like for example register/contact/37200
and not like this whole thing : /registrar/contact/37200;@80316366e84eb97b6234ff873527f1e5

or if i can not configure how database registrations could be stored
then how could then i check if database exists by checking only the non bold part /registrar/contact/37200**;@80316366e84eb97b6234ff873527f1e5** neglecting the bold part
since either ways my problem could be solved !
first is by re configuring how database for registration is stored and the other is by checking for not to whole part of the database entry

Why do you check using this mechanism, instead of just doing the dial attempt or using DEVICE_STATE to check the device state?

by checking device state i could check if the called party is registered or not ?

Yes. There is also the ChanIsAvail dialplan application[1]. Trying to Dial also works, as it will immediately fail if unregistered. That is what most people do.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_ChanIsAvail

1 Like

thanks i used DEVICE_STATE and i checked for 2 conditions UNAVILABLE and INVALID
it worked so fine.