SIP Express Router v0.8.8 - Developer's Guide | ||
---|---|---|
<<< Previous | The Module Interface | Next >>> |
Modules are compiled and stored as shared objects. Shared objects have usually appendix ".so". Shared objects can be loaded at runtime.
When you instruct the server to load a module using loadmodule command in the config file, it will call function load_module. The function will do the following:
It will try to open specified file using dlopen. For example if you write loadmodule "/usr/lib/ser/modules/auth.so" in the config file, the server will try to open file "/usr/lib/ser/modules/auth.so" using dlopen function.
If dlopen failed, the server will issue an error and abort.
As the next step, list of all previously loaded modules will be searched for the same module. If such module is found, it means, that user is trying to load the same module twice. In such case an warning will be issued and server will abort.
The server will try to find pointer to "exports" symbol using dlsym in the module. If that fails, server will issue an error and abort.
And as the last step, function register_module will register the module with the server core and loading of the module is complete.
Function register_module registers a module with the server core. By registration we mean the following set of steps (see function register_module in file sr_module.c for more details):
The function creates and initializes new instance of sr_module structure.
path field will be set to path of the module.
handle field will be set to handle previously retuned by dlopen.
exports field will be set to pointer to module's exports structure previously obtained through dlsym in load_module function.
As the last step, the newly created structure will be inserted into linked list of all loaded modules and registration is complete.
<<< Previous | Home | Next >>> |
Structure module_exports | Up | Module Configuration |