24 # define LIBRARY_DIR "."
49 int celem, melem, attr, *nlist = NULL;
50 char id[13], name[32], mod_fullpath[
PATH_MAX], arg[1024], *modules_path;
55 mm = (
mm_t) calloc(1,
sizeof(
struct mm_st));
64 if (modules_path != NULL)
65 log_write(sm->
log, LOG_NOTICE,
"modules search path: %s", modules_path);
67 log_write(sm->
log, LOG_NOTICE,
"modules search path undefined, using deafult: "LIBRARY_DIR);
82 if(strcmp(
id,
"sess-start") == 0) {
87 else if(strcmp(
id,
"sess-end") == 0) {
92 else if(strcmp(
id,
"in-sess") == 0) {
97 else if(strcmp(
id,
"in-router") == 0) {
102 else if(strcmp(
id,
"out-sess") == 0) {
107 else if(strcmp(
id,
"out-router") == 0) {
112 else if(strcmp(
id,
"pkt-sm") == 0) {
117 else if(strcmp(
id,
"pkt-user") == 0) {
122 else if(strcmp(
id,
"pkt-router") == 0) {
127 else if(strcmp(
id,
"user-load") == 0) {
132 else if(strcmp(
id,
"user-unload") == 0) {
137 else if(strcmp(
id,
"user-create") == 0) {
142 else if(strcmp(
id,
"user-delete") == 0) {
147 else if(strcmp(
id,
"disco-extend") == 0) {
154 log_write(sm->
log, LOG_ERR,
"unknown chain type '%s'",
id);
182 mod->
name = strdup(name);
184 if (modules_path != NULL)
185 snprintf(mod_fullpath,
PATH_MAX,
"%s/mod_%s.so", modules_path, name);
187 snprintf(mod_fullpath,
PATH_MAX,
"%s/mod_%s.so", LIBRARY_DIR, name);
188 mod->
handle = dlopen(mod_fullpath, RTLD_LAZY);
192 if (modules_path != NULL)
193 snprintf(mod_fullpath,
PATH_MAX,
"%s\\mod_%s.dll", modules_path, name);
195 snprintf(mod_fullpath,
PATH_MAX,
"mod_%s.dll", name);
196 mod->
handle = (
void*) LoadLibrary(mod_fullpath);
202 log_debug(
ZONE,
"preloaded module '%s' to chain '%s' (not added yet)", name,
id);
207 log_write(sm->
log, LOG_ERR,
"failed loading module '%s' to chain '%s' (%s)", name,
id, dlerror());
211 log_write(sm->
log, LOG_ERR,
"failed loading module '%s' to chain '%s' (errcode: %x)", name,
id, GetLastError());
213 FreeLibrary((HMODULE) mod->
handle);
226 mi->arg = (arg[0] ==
'\0') ? NULL : strdup(arg);
230 log_write(sm->
log, LOG_ERR,
"init for module '%s' (seq %d) failed", name, mi->seq);
241 FreeLibrary((HMODULE) mod->
handle);
257 (*list)[*nlist] = mi;
259 log_write(sm->
log, LOG_NOTICE,
"module '%s' added to chain '%s' (order %d index %d seq %d)", mod->
name,
id, *nlist, mod->
index, mi->seq);
272 static void _mm_reaper(
const char *module,
int modulelen,
void *val,
void *arg) {
275 if(mod->
free != NULL)
283 FreeLibrary((HMODULE) mod->
handle);
291 int i, j, *nlist = NULL;
298 for(i = 0; i < 13; i++) {
354 for(j = 0; j < *nlist; j++) {
479 if (mm != NULL && pkt != NULL )
572 for(n = 0; n < mm->
npkt_sm; n++) {