Olivier
2008-Nov-05 08:01 UTC
[asterisk-users] How is it best to initialize specific SIP peer settings
Hello, Let's say you would like to define, for every SIP peer, a value which would set, for instance, the maximum daytime calls number. Extension 101 would get a 2 value, extension 102 would also get 2, extension 103 would get 1, and so ... How is it best to proceed as those values : - shall be usable from dial plan, - shall be set when system starts up. Now I would simply use database set from CLI to set those values once for all but using some sort of config file might be more flexible (if you've got many values to set). How would you proceed ? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20081105/4d44616f/attachment.htm
John Todd
2008-Nov-05 18:02 UTC
[asterisk-users] How is it best to initialize specific SIP peer settings
On Nov 5, 2008, at 12:01 AM, Olivier wrote:> Hello, > > Let's say you would like to define, for every SIP peer, a value > which would set, for instance, the maximum daytime calls number. > Extension 101 would get a 2 value, extension 102 would also get 2, > extension 103 would get 1, and so ... > > How is it best to proceed as those values : > - shall be usable from dial plan, > - shall be set when system starts up. > > Now I would simply use database set from CLI to set those values > once for all but using some sort of config file might be more > flexible (if you've got many values to set). > How would you proceed ? > > RegardsOliver - Perhaps what you are looking for is the "setvar=" parameters in sip.conf? For each peer, you can set values which will carry over into the dialplan. I'm not sure if this is what you're looking for. Combining this with the templates methods in sip.conf, it would be quickly possible to define a large number of SIP peers with very few lines of configuration file, and set values that could be used for pretty much any purpose in the Dialplan. Of course, these values only get set on inbound calls to these peers - for calls destined TO these SIP peers, you'd need to also store these values in some database in order to obtain those values and process the data, and perhaps the astdb or ODBC would be appropriate for this. It all depends on what you're trying to do and what is the minimum amount of work you wish to expend. Heck, I've even used System() calls with grep and awk for very rare and slow lookups, though I wouldn't suggest it as a matter of course. One may argue that the best use of "setvar" is to store a key value, which then is used to look up the "real" data (astdb or ODBC) in the dialplan as the first parts of the dialplan logic. That way, both inbound and outbound events can easily access the same data set as long as they have the correct key. I include the most simplistic, non-database-y example below: ...from sip.conf... [my-template](!) context=my-main-context type=friend host=dynamic disallow=all allow=ulaw allow=alaw nat=yes [1234](my-template) secret=somepassword setvar=USER="John Whorfin" [1235](my-template) secret=otherpassword setvar=USER="Penny Preddy" JT --- John Todd jtodd at digium.com +1-256-428-6083 Asterisk Open Source Community Director