Specifications

CHAPTER 5. IMPLEMENTATION 40
pass all checks performed by the module loader’s functions to be accepted as a valid Input
Abstraction Layer module.
mod_scan()
mod_verify() dl_function()
filename
filename, symbol
handle, symbol
dlopen()
Failure
Success
Failure
Success
Failure
Success
filename
SuccessFailure
dlsym()
SuccessFailure
Figure 5.5: Input Abstraction Layer Module Verification
Verified modules are stored in a double linked list. This double linked list is used by the
daemon to manage the available modules at run time. An element of the list represents one
module and consists of three pointers: a pointer data to a structure of type ModuleData, a
pointer prev to the previous element of the list and a pointer next to the next element of the
list. The data structure for an element of the list is declared in libial mod.h:
typedef struct IalModule_s {
ModuleData *data;
struct IalModule_s *prev;
struct IalModule_s *next;
} IalModule;
Each verified mo dule is added to the double linked list. To access the double linked list,
the daemon defines the global variable modules list head, which is initialized with the value
NULL:
IalModule *modules_list_head = NULL;
Once a verified module is found, the module loader adds it to the list by invoking the
function module add(). The function module add() allocates memory for the new element
(IalModule module) and sets up its members. To obtain the pointer to the module’s structure
ModuleData, the already discussed function dl function() is used. The following source code
is an excerpt of module add():
/* Define function returning a pointer to ModuleData. */
ModuleData *(*function) (void);
/* Obtain function pointer. */
function = dl_function(filename, "mod_get_data");
Now the function pointer returned by dl function() is assigned to function. It can