-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3970/
-----------------------------------------------------------

Review request for Asterisk Developers.


Repository: Asterisk


Description
-------

The big piece missing for me to finally transition to pjsip was the ability to 
mirror the auto provisioning features of res_phoneprov.  The first step (this 
patch) is to make res_phoneprov more modular so other modules (like pjsip) can 
provide configuration information instead of res_phoneprov relying solely on 
users.conf and sip.conf.  To accomplish this a new ast_phoneprov public API is 
now exposed which allows config providers to register themselves, set defaults 
(server profile, etc) and add user extensions.

ast_phoneprov_provider_register registers the provider and provides callbacks 
for loading default settings and loading users.
ast_phoneprov_provider_unregister clears the defaults and users.
ast_phoneprov_provider_set_defaults should be called by the provider's 
load_defaults callback to push the defaults.
ast_phoneprov_add_extension should be called once for each user/extension by 
the provider's load_users callback to add them.
ast_phoneprov_delete_extension deletes one extension.
ast_phoneprov_delete_extensions deletes all extensions for the provider.

Since res_phoneprov is a module that may or may not be loaded, the apis are 
implemented as inlines that check that res_phoneprov is actually loaded before 
calling the concrete function.  A new include file was added: 
include/asterisk/phoneprov.h

res_phoneprov actually registers itself as the provider for sip/users and is 
always available and is the default.

Writing a new provider...
Since res_phoneprov is also it's own provider, examples of what a new provider 
would have to do are in load_defaults() and load_users() in res_phoneprov.c.  
Those functions gather the information from users.conf and sip.conf and call 
the ast_provider_set_defaults and ast_phoneprov_add_extension apis.

So...
The provider creates 2 callback functions which call the 
ast_provider_set_defaults and ast_phoneprov_add_extension apis.  
It then calls ast_phoneprov_provider_register with those 2 callbacks.
res_phoneprov then calls the callbacks to cause the actual load.
During normal http server ops, all work is done by res_phoneprov and the 
provider is never called again unless a reload is needed.
If the provider wants to reload it can simply unregister and reregister or it 
can call its own load_defaults and load_users callbacks.
If res_phoneprov wants to reload, it iterates over its registry and calls the 
providers callbacks.

NOTE:  If res_phoneprov is actually unloaded, it has no way to know what 
providers were registered (other than itself) so a subsequent load will have 
nothing but it's own users.  

Additional changes...
I added a few convenience functions to chanvars for creating lists and finding 
and deleting entries.  No existing code was touched.

Next steps...
A provider for res_pjsip.


Diffs
-----

  branches/12/res/res_phoneprov.exports.in PRE-CREATION 
  branches/12/res/res_phoneprov.c 422556 
  branches/12/main/chanvars.c 422556 
  branches/12/include/asterisk/phoneprov.h PRE-CREATION 
  branches/12/include/asterisk/chanvars.h 422556 

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


Testing
-------

I ran through several scenarios including the use of PP_EACH_USER and 
PP_EACH_EXTENSION to make sure that all existing functionality was preserved.  
I actually use it with Grandstream phones and everything worked exactly as 
expected.


Thanks,

George Joseph

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to