[asterisk-dev] Module to Asterisk function Compiler Issue question
Kevin P. Fleming
kpfleming at digium.com
Mon Aug 1 10:53:53 CDT 2011
On 08/01/2011 10:47 AM, Mike Myhre wrote:
>
>> Your module is not included in the Asterisk main binary; it's a
>> dynamic module loaded at run time. The symbol visibility is controlled
>> by the module loader, via the flags that I mentioned above.
>
> I think my confusion came from the assumption that the channels/*.c
> files were part of the asterisk binary and they aren't. They are modules
> themselves. For that reason, it is probably a big no-no to try to call a
> function in a loadable module (chan_sip.so) from a res module that I am
> creating. There is the possibility that the module may not be loaded and
> asterisk probably doesn't allow that anyway. Is that true? Or can I call
> a function that checks to see if that module is present and still be
> able to call a function as long as in the load_module function, I use a
> function like ast_custom_function_register that points to a structure
> defining the function (dial plan functions)?
Dial plan functions are not quite the same thing as what you are trying
to do. What you are trying to do is a bit complex, because you are
trying to make a function that has access to internal chan_sip data be
available to another function that is more generic. To make this work,
you have to use a mechanism where the function calls are passed through
the main Asterisk binary, so that they can fail gracefully if the target
function is not present (and so that the module load order is easier to
deal with). Take a look at how the music-on-hold provider functions are
'registered' with the main binary and then called from other modules.
*If* you can put your code into a res module, that will make things
easier as those are generally loaded before non-res modules (the loader
prioritizes loading of modules that export symbols), but then you'd have
difficulty accessing the data you need.
--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kfleming at digium.com | SIP: kpfleming at digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com & www.asterisk.org
More information about the asterisk-dev
mailing list