[asterisk-dev] [Code Review] 4190: res_pjsip_config_wizard: Allow streamlined configuration of common pjsip scenarios

George Joseph reviewboard at asterisk.org
Wed Dec 3 17:42:21 CST 2014

This is an automatically generated e-mail. To reply, visit:

(Updated Dec. 3, 2014, 4:42 p.m.)

Review request for Asterisk Developers, Joshua Colp and Mark Michelson.


Refactored to take advantage of the new sorcery_observer capabilities.
Addressed most of Mark's and Josh's comments.

Repository: Asterisk

Description (updated)

The PJSIP Configuration Wizard allows for creation of simple pjsip scenarios like phone or trunk without having to directly specify individual endpoints, aors, auths, identifies or registrations.  The easiest way to demonstrate this is with an example or two from pjsip_wizard.conf.sample...

;============EXAMPLE WIZARD CONFIGURATION FOR A PHONE=======================

; This config would create an endpoint, aor with dynamic contact, inbound
; auth and a phoneprov object.

type = wizard
accepts_auth = yes
accepts_registrations = yes
transport = ipv4
has_phoneprov = yes
aor/max_contacts = 1
inbound_auth/username = testname
inbound_auth/password = test password
endpoint/allow = ulaw
endpoint/context = default
phoneprov/MAC = 001122aa4455
phoneprov/PROFILE = profile1


; This ITSP has 2 servers available and requires registration.

; This config would create an endpoint, an aor with 2 static contacts, an outbound
; auth, an identify with 2 matches, and 2 registrations.

type = wizard
sends_auth = yes
sends_registrations = yes
transport = ipv4
; The number of remote_hosts drives the number of contacts, matches and registrations.
remote_hosts = sip1.myitsp.com:5060,sip2.myitsp.com:5060
outbound_auth/username = testname
outbound_auth/password = test password
endpoint/allow = ulaw
endpoint/context = default

pjsip_wizard.conf.sample has more details.

The history of the wizard approach can be found in the following 2 threads...



Load sequence...
* Register as an ast_sorcery_global_observer.
* When notified that res_pjsip has opened a sorcery instance, register as an ast_sorcery_instance_observer for res_pjsip.
* When notified that an object_type has been registered, call ast_sorcery_apply_wizard_mapping to add a memory wizard to the object type.
* When notified that the memory wizard has been mapped, save its callbacks for later use.
* When notified that an object type has been loaded or reloaded, parse pjsip_wizard.conf (detecting adds, changed and deletes), create, replace or delete the object types from the wizard definitions and add them to the memory wizard using the callbacks saved in the previous step.


The new module itself cannot be reloaded or unloaded but there's no point to that anyway.  'core reload' and 'module reload res_pjsip' work quite well though which is much more important.  'core reload' is the preferred reload mechanism over reloading specific pjsip modules because it reloads all modules so modules such as res_pjsip_outbound_registration know to start registration for newly discovered objects.  


This module does not change any existing functionality.  Once created by the wizard, pjsip objects are indistinguishable from ones created discretely other than the addition of the '@pjsip_wizard' attribute.


This module does not use sorcery to read its pjsip_wizard.conf file.  Since this module implements a sorcery wizard, doing so would have created 'chicken and egg' scenarios which would have been complex to solve.  It does use the standard config mechanism though so you can use extconfig.conf to get the config from an external source.

res_pjsip_phoneprov_provider needed a little rearranging to work with the wizard.  No other modules were modified.

Diffs (updated)

  branches/12/res/res_pjsip_phoneprov_provider.c 428944 
  branches/12/res/res_pjsip_config_wizard.c PRE-CREATION 
  branches/12/configs/pjsip_wizard.conf.sample PRE-CREATION 

Diff: https://reviewboard.asterisk.org/r/4190/diff/


Test suite tests are available that use the wizard to create objects and AMI to read the results.  The results are indistinguishable except the for '@pjsip_wizard' attribute.

I've converted my own PBX to use the wizard approach and phones and trunks operate normally.


George Joseph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141203/68518c70/attachment.html>

More information about the asterisk-dev mailing list