TEST(TestIronBee, test_data_indexed) { ib_engine_t *ib; ib_data_config_t *dataconfig; ib_data_t *data; ib_field_t *f; size_t i; size_t j; ib_num_t n; ibtest_engine_create(&ib); ASSERT_EQ(IB_OK, ib_data_config_create(ib_engine_pool_main_get(ib), & dataconfig)); ASSERT_EQ(IB_OK, ib_data_register_indexed_ex(dataconfig, "foo", 3, &i)); ASSERT_EQ(IB_OK, ib_data_lookup_index(dataconfig, "foo", &j)); ASSERT_EQ(i, j); ASSERT_EQ(IB_ENOENT, ib_data_lookup_index(dataconfig, "bar", NULL)); ASSERT_EQ(IB_EINVAL, ib_data_register_indexed(dataconfig, "foo")); ASSERT_EQ(IB_OK, ib_data_create(dataconfig, ib_engine_pool_main_get(ib), &data)); ASSERT_TRUE(data); ASSERT_EQ(IB_OK, ib_data_add_num(data, "foo", 5, NULL)); ASSERT_EQ(IB_OK, ib_data_get_indexed(data, i, &f)); ASSERT_EQ(IB_OK, ib_field_value(f, ib_ftype_num_out(&n))); ASSERT_EQ(5, n); ASSERT_EQ(IB_OK, ib_data_get(data, "foo", &f)); ASSERT_EQ(IB_OK, ib_field_value(f, ib_ftype_num_out(&n))); ASSERT_EQ(5, n); }
// Test pattern matching a field. TEST(TestIronBee, test_data_pcre) { ib_engine_t *ib; ib_data_config_t *dataconfig; ib_data_t *data; ib_field_t *list_field; ib_field_t *out_field; ib_list_t *list; ib_list_t *out_list; ib_field_t *field1; ib_field_t *field2; ib_field_t *field3; ib_num_t num1 = 1; ib_num_t num2 = 2; ib_num_t num3 = 3; ibtest_engine_create(&ib); ASSERT_EQ(IB_OK, ib_data_config_create(ib_engine_pool_main_get(ib), & dataconfig)); ASSERT_EQ(IB_OK, ib_data_create(dataconfig, ib_engine_pool_main_get(ib), &data)); ASSERT_TRUE(data); ASSERT_IB_OK( ib_field_create(&field1, ib_data_pool(data), "field1", 6, IB_FTYPE_NUM, &num1)); ASSERT_IB_OK( ib_field_create(&field2, ib_data_pool(data), "field2", 6, IB_FTYPE_NUM, &num2)); ASSERT_IB_OK( ib_field_create(&field3, ib_data_pool(data), "field3", 6, IB_FTYPE_NUM, &num3)); ASSERT_IB_OK(ib_data_add_list(data, "ARGV", &list_field)); ASSERT_IB_OK(ib_data_get(data, "ARGV", &out_field)); ASSERT_IB_OK(ib_field_value(list_field, &list)); ASSERT_IB_OK(ib_list_push(list, field1)); ASSERT_IB_OK(ib_list_push(list, field2)); ASSERT_IB_OK(ib_list_push(list, field3)); ASSERT_IB_OK(ib_data_get(data, "ARGV:/.*(1|3)/", &out_field)); ASSERT_IB_OK(ib_field_value(out_field, &out_list)); ASSERT_NE(list, out_list); /* Make sure it's a different list. */ ASSERT_EQ(2U, IB_LIST_ELEMENTS(out_list)); out_field = (ib_field_t *) IB_LIST_FIRST(out_list)->data; ASSERT_FALSE(memcmp(out_field->name, field1->name, field1->nlen)); out_field = (ib_field_t *) IB_LIST_LAST(out_list)->data; ASSERT_FALSE(memcmp(out_field->name, field3->name, field3->nlen)); ibtest_engine_destroy(ib); }
ib_status_t ib_action_inst_create_ex( ib_engine_t *ib, const char *name, const char *parameters, ib_action_inst_t **act_inst) { assert(ib != NULL); assert(name != NULL); ib_hash_t *action_hash = ib->actions; ib_action_t *action; ib_status_t rc; ib_mpool_t *mpool = ib_engine_pool_main_get(ib); assert(mpool != NULL); rc = ib_hash_get(action_hash, &action, name); if (rc != IB_OK) { /* name is not registered */ return rc; } *act_inst = (ib_action_inst_t *)ib_mpool_alloc(mpool, sizeof(ib_action_inst_t)); if (*act_inst == NULL) { return IB_EALLOC; } (*act_inst)->action = action; (*act_inst)->params = ib_mpool_strdup(mpool, parameters); (*act_inst)->fparam = NULL; if (action->fn_create != NULL) { rc = action->fn_create( ib, parameters, *act_inst, action->cbdata_create ); if (rc != IB_OK) { return rc; } } else { rc = IB_OK; } if ((*act_inst)->fparam == NULL) { rc = ib_field_create(&((*act_inst)->fparam), mpool, IB_FIELD_NAME("param"), IB_FTYPE_NULSTR, ib_ftype_nulstr_in(parameters)); } return rc; }
TEST(TestIronBee, test_data_name) { ib_engine_t *ib = NULL; ib_data_config_t *dataconfig = NULL; ib_data_t *data = NULL; ib_field_t *list_field = NULL; ib_field_t *out_field = NULL; ibtest_engine_create(&ib); ASSERT_EQ(IB_OK, ib_data_config_create(ib_engine_pool_main_get(ib), & dataconfig)); ASSERT_EQ(IB_OK, ib_data_create(dataconfig, ib_engine_pool_main_get(ib), &data)); ASSERT_TRUE(data); ASSERT_IB_OK(ib_data_add_list(data, "ARGV", &list_field)); ASSERT_IB_OK(ib_data_get(data, "ARGV", &out_field)); ASSERT_TRUE(out_field); out_field = NULL; ASSERT_IB_OK(ib_data_get_ex(data, "ARGV:/.*(1|3)/", 4, &out_field)); ASSERT_TRUE(out_field); ibtest_engine_destroy(ib); }
ib_status_t ib_action_register( ib_engine_t *ib, const char *name, ib_flags_t flags, ib_action_create_fn_t fn_create, void *cbdata_create, ib_action_destroy_fn_t fn_destroy, void *cbdata_destroy, ib_action_execute_fn_t fn_execute, void *cbdata_execute ) { IB_FTRACE_INIT(); ib_hash_t *action_hash = ib->actions; ib_mpool_t *pool = ib_engine_pool_main_get(ib); ib_status_t rc; char *name_copy; ib_action_t *act; rc = ib_hash_get(action_hash, &act, name); if (rc == IB_OK) { /* name already is registered */ IB_FTRACE_RET_STATUS(IB_EINVAL); } name_copy = ib_mpool_strdup(pool, name); if (name_copy == NULL) { IB_FTRACE_RET_STATUS(IB_EALLOC); } act = (ib_action_t *)ib_mpool_alloc(pool, sizeof(*act)); if (act == NULL) { IB_FTRACE_RET_STATUS(IB_EALLOC); } act->name = name_copy; act->flags = flags; act->fn_create = fn_create; act->cbdata_create = cbdata_create; act->fn_destroy = fn_destroy; act->cbdata_destroy = cbdata_destroy; act->fn_execute = fn_execute; act->cbdata_execute = cbdata_execute; rc = ib_hash_set(action_hash, name_copy, act); IB_FTRACE_RET_STATUS(rc); }
TEST_F(CoreOperatorsTest, NeTest) { ib_status_t status; ib_num_t call_result; ib_operator_inst_t *op; ib_rule_t *rule = NULL; /* Not used by this operator. */ status = ib_operator_inst_create(ib_engine, NULL, rule, IB_OP_FLAG_PHASE, "ne", "1", IB_OPINST_FLAG_NONE, &op); ASSERT_EQ(IB_OK, status); // call contains ib_field_t *field; const ib_num_t matching = 2; const ib_num_t nonmatching = 1; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NUM, ib_ftype_num_in(&matching) ); ib_rule_exec_t rule_exec; memset(&rule_exec, 0, sizeof(rule_exec)); rule_exec.ib = ib_engine; rule_exec.tx = ib_tx; rule_exec.rule = rule; ib_field_setv(field, ib_ftype_num_in(&matching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_num_in(&nonmatching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); }
TEST_F(CoreOperatorsTest, ContainsTest) { ib_status_t status; ib_num_t call_result; ib_operator_inst_t *op; ib_rule_t *rule = NULL; /* Not used by this operator. */ status = ib_operator_inst_create(ib_engine, NULL, rule, IB_OP_FLAG_PHASE, "contains", "needle", IB_OPINST_FLAG_NONE, &op); ASSERT_EQ(IB_OK, status); // call contains ib_field_t *field; const char *matching = "data with needle in it"; const char *nonmatching = "non matching string"; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NULSTR, NULL ); ib_rule_exec_t rule_exec; memset(&rule_exec, 0, sizeof(rule_exec)); rule_exec.ib = ib_engine; rule_exec.rule = rule; ib_field_setv(field, ib_ftype_nulstr_in(matching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_nulstr_in(nonmatching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); }
ib_status_t ib_action_register( ib_engine_t *ib, const char *name, ib_action_create_fn_t fn_create, void *cbdata_create, ib_action_destroy_fn_t fn_destroy, void *cbdata_destroy, ib_action_execute_fn_t fn_execute, void *cbdata_execute ) { ib_hash_t *action_hash = ib->actions; ib_mpool_t *pool = ib_engine_pool_main_get(ib); ib_status_t rc; char *name_copy; ib_action_t *act; rc = ib_hash_get(action_hash, &act, name); if (rc == IB_OK) { /* name already is registered */ return IB_EINVAL; } name_copy = ib_mpool_strdup(pool, name); if (name_copy == NULL) { return IB_EALLOC; } act = (ib_action_t *)ib_mpool_alloc(pool, sizeof(*act)); if (act == NULL) { return IB_EALLOC; } act->name = name_copy; act->fn_create = fn_create; act->cbdata_create = cbdata_create; act->fn_destroy = fn_destroy; act->cbdata_destroy = cbdata_destroy; act->fn_execute = fn_execute; act->cbdata_execute = cbdata_execute; rc = ib_hash_set(action_hash, name_copy, act); return rc; }
ib_status_t ib_action_inst_create(ib_engine_t *ib, ib_context_t *ctx, const char *name, const char *parameters, ib_flags_t flags, ib_action_inst_t **act_inst) { IB_FTRACE_INIT(); ib_hash_t *action_hash = ib->actions; ib_mpool_t *pool = ib_engine_pool_main_get(ib); ib_action_t *action; ib_status_t rc; rc = ib_hash_get(action_hash, &action, name); if (rc != IB_OK) { /* name is not registered */ IB_FTRACE_RET_STATUS(rc); } *act_inst = (ib_action_inst_t *)ib_mpool_alloc(pool, sizeof(ib_action_inst_t)); if (*act_inst == NULL) { IB_FTRACE_RET_STATUS(IB_EALLOC); } (*act_inst)->action = action; (*act_inst)->flags = flags; if (action->fn_create != NULL) { rc = action->fn_create( ib, ctx, pool, parameters, *act_inst, action->cbdata_create ); } else { rc = IB_OK; } IB_FTRACE_RET_STATUS(rc); }
TEST_F(CoreOperatorsTest, ContainsTest) { ib_status_t status; ib_num_t call_result; const ib_operator_t *op; void *instance_data; status = ib_operator_lookup(ib_engine, "contains", &op); ASSERT_EQ(IB_OK, status); status = ib_operator_inst_create(op, ib_context_main(ib_engine), IB_OP_CAPABILITY_NON_STREAM, "needle", &instance_data); ASSERT_EQ(IB_OK, status); // call contains ib_field_t *field; const char *matching = "data with needle in it"; const char *nonmatching = "non matching string"; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NULSTR, NULL ); ib_field_setv(field, ib_ftype_nulstr_in(matching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_nulstr_in(nonmatching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); }
TEST_F(CoreOperatorsTest, NeTest) { ib_status_t status; ib_num_t call_result; const ib_operator_t *op; void *instance_data; status = ib_operator_lookup(ib_engine, "ne", &op); ASSERT_EQ(IB_OK, status); status = ib_operator_inst_create(op, ib_context_main(ib_engine), IB_OP_CAPABILITY_NON_STREAM, "1", &instance_data); ASSERT_EQ(IB_OK, status); // call contains ib_field_t *field; const ib_num_t matching = 2; const ib_num_t nonmatching = 1; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NUM, ib_ftype_num_in(&matching) ); ib_field_setv(field, ib_ftype_num_in(&matching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_num_in(&nonmatching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); }
MemoryPool Engine::main_memory_pool() const { return MemoryPool(ib_engine_pool_main_get(ib())); }
/* Called when module is loaded. */ static ib_status_t geoip_init(ib_engine_t *ib, ib_module_t *m, void *cbdata) { ib_status_t rc; GeoIP *geoip_db = NULL; module_data_t *mod_data; mod_data = ib_mpool_calloc(ib_engine_pool_main_get(ib), sizeof(*mod_data), 1); if (mod_data == NULL) { return IB_EALLOC; } ib_log_debug(ib, "Initializing default GeoIP database..."); geoip_db = GeoIP_new(GEOIP_MMAP_CACHE); if (geoip_db == NULL) { ib_log_debug(ib, "Failed to initialize GeoIP database."); return IB_EUNKNOWN; } ib_log_debug(ib, "Initializing GeoIP database complete."); ib_log_debug(ib, "Registering handler..."); /* Store off pointer to our module data structure */ mod_data->geoip_db = geoip_db; /* And point the generic module data at it */ m->data = mod_data; rc = ib_hook_tx_register(ib, handle_context_tx_event, geoip_lookup, mod_data); if (rc != IB_OK) { ib_log_debug( ib, "Failed to register tx hook: %s", ib_status_to_string(rc)); return rc; } ib_log_debug(ib, "Done registering handler."); rc = ib_var_source_register( &(mod_data->geoip_source), ib_engine_var_config_get(ib), IB_S2SL("GEOIP"), IB_PHASE_NONE, IB_PHASE_NONE ); if (rc != IB_OK) { ib_log_warning(ib, "GeoIP failed to register \"GEOIP\" var: %s", ib_status_to_string(rc) ); /* Continue */ } if (rc != IB_OK) { ib_log_debug(ib, "Failed to load GeoIP module."); return rc; } geoip_directive_map[0].cbdata_cb = mod_data; ib_log_debug(ib, "GeoIP module loaded."); return IB_OK; }
/** * Called at context close. Initialized user-agent target. * * @param[in] ib Engine * @param[in] ctx Context * @param[in] event Event triggering the callback * @param[in] cbdata Callback data (module). * * @returns Status code */ static ib_status_t modua_ctx_close( ib_engine_t *ib, ib_context_t *ctx, ib_state_event_type_t event, void *cbdata ) { ib_module_t *m = (ib_module_t *)cbdata; if (ib_context_type(ctx) == IB_CTYPE_MAIN) { modua_config_t *cfg; ib_var_target_t *target; ib_status_t rc; rc = ib_context_module_config(ctx, m, &cfg); if (rc != IB_OK) { ib_log_error(ib, "Can't fetch configuration: %s", ib_status_to_string(rc)); return rc; } rc = ib_var_target_acquire_from_string( &target, ib_engine_pool_main_get(ib), ib_engine_var_config_get(ib), IB_S2SL("request_headers:User-Agent"), NULL, NULL ); if (rc != IB_OK) { ib_log_error(ib, "Error acquiring target for User-Agent header: %s", ib_status_to_string(rc)); return rc; } cfg->user_agent = target; rc = ib_var_target_acquire_from_string( &target, ib_engine_pool_main_get(ib), ib_engine_var_config_get(ib), IB_S2SL("request_headers:X-Forwarded-For"), NULL, NULL ); if (rc != IB_OK) { ib_log_error(ib, "Error acquiring target for X-Forwarded-For header: %s", ib_status_to_string(rc)); return rc; } cfg->forwarded_for = target; rc = ib_var_source_acquire( &(cfg->remote_addr), ib_engine_pool_main_get(ib), ib_engine_var_config_get(ib), IB_S2SL("remote_addr") ); if (rc != IB_OK) { ib_log_error(ib, "Error acquiring source for remote_addr" " header: %s", ib_status_to_string(rc)); return rc; } } return IB_OK; }
/// @test Test ironbee library - data provider TEST(TestIronBee, test_data_dynf) { ib_engine_t *ib; ib_data_config_t *dataconfig; ib_data_t *data; ib_field_t *dynf; ib_field_t *f; ib_field_t *f2; ib_status_t rc; ib_num_t n; ib_list_t* l; ibtest_engine_create(&ib); ASSERT_EQ(IB_OK, ib_data_config_create(ib_engine_pool_main_get(ib), & dataconfig)); ASSERT_EQ(IB_OK, ib_data_create(dataconfig, ib_engine_pool_main_get(ib), &data)); ASSERT_TRUE(data); /* Create a field with no initial value. */ ASSERT_EQ( IB_OK, ib_field_create_dynamic( &dynf, ib_engine_pool_main_get(ib), IB_FIELD_NAME("test_dynf"), IB_FTYPE_LIST, dyn_get, (void *)ib_engine_pool_main_get(ib), NULL, NULL ) ); ASSERT_TRUE(dynf); ASSERT_EQ(9UL, dynf->nlen); ASSERT_MEMEQ("test_dynf", dynf->name, 9); /* Add the field to the data store. */ ASSERT_EQ(IB_OK, ib_data_add(data, dynf)); /* Fetch the field from the data store */ ASSERT_EQ(IB_OK, ib_data_get(data, "test_dynf", &f)); ASSERT_TRUE(f); ASSERT_EQ(dynf, f); /* Fetch a dynamic field from the data store */ ASSERT_EQ(IB_OK, ib_data_get(data, "test_dynf:dyn_subkey", &f)); ASSERT_TRUE(f); ASSERT_EQ(9UL, f->nlen); /* Get the list value from the dynamic field. */ rc = ib_field_mutable_value(f, ib_ftype_list_mutable_out(&l)); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(1UL, ib_list_elements(l)); /* Get the single value from the list. */ f2 = (ib_field_t *)ib_list_node_data(ib_list_first(l)); ASSERT_TRUE(f2); ASSERT_EQ(10UL, f2->nlen); rc = ib_field_value(f2, ib_ftype_num_out(&n)); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(5, n); /* Fetch a another subkey */ ASSERT_EQ(IB_OK, ib_data_get(data, "test_dynf:dyn_subkey2", &f)); ASSERT_TRUE(f); ASSERT_EQ(9UL, f->nlen); /* Get the list value from the dynamic field. */ rc = ib_field_mutable_value(f, ib_ftype_list_mutable_out(&l)); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(1UL, ib_list_elements(l)); /* Get the single value from the list. */ f2 = (ib_field_t *)ib_list_node_data(ib_list_first(l)); ASSERT_TRUE(f2); ASSERT_EQ(11UL, f2->nlen); rc = ib_field_value(f2, ib_ftype_num_out(&n)); ASSERT_EQ(IB_OK, rc); ASSERT_EQ(5, n); ibtest_engine_destroy(ib); }
TEST_F(OperatorTest, OperatorCallTest) { ib_status_t status; ib_num_t call_result; ib_rule_t *rule = NULL; /* Unused by this operator. */ ib_operator_inst_t *op; status = ib_operator_register(ib_engine, "test_op", IB_OP_FLAG_PHASE, test_create_fn, NULL, test_destroy_fn, NULL, test_execute_fn, NULL); ASSERT_EQ(IB_OK, status); status = ib_operator_inst_create(ib_engine, NULL, rule, IB_OP_FLAG_PHASE, "test_op", "INVALID", IB_OPINST_FLAG_NONE, &op); ASSERT_EQ(IB_EINVAL, status); status = ib_operator_inst_create(ib_engine, NULL, rule, IB_OP_FLAG_PHASE, "test_op", "data", IB_OPINST_FLAG_NONE, &op); ASSERT_EQ(IB_OK, status); ib_rule_exec_t rule_exec; memset(&rule_exec, 0, sizeof(rule_exec)); rule_exec.ib = ib_engine; rule_exec.rule = rule; ib_field_t *field; const char *matching = "data matching string"; const char *nonmatching = "non matching string"; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NULSTR, NULL ); ib_field_setv(field, ib_ftype_nulstr_in(matching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_nulstr_in(nonmatching)); status = ib_operator_execute(&rule_exec, op, field, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); status = ib_operator_inst_destroy(op); ASSERT_EQ(IB_OK, status); }
TEST_F(OperatorTest, OperatorCallTest) { ib_status_t status; ib_num_t call_result; void *instance_data; ib_operator_t *op; const ib_operator_t *cop; status = ib_operator_create_and_register( &op, ib_engine, "test_op", IB_OP_CAPABILITY_NON_STREAM, test_create_fn, NULL, NULL, NULL, test_execute_fn, NULL ); ASSERT_EQ(IB_OK, status); status = ib_operator_lookup(ib_engine, "test_op", &cop); ASSERT_EQ(IB_OK, status); status = ib_operator_inst_create(op, ib_context_main(ib_engine), IB_OP_CAPABILITY_NON_STREAM, "INVALID", &instance_data); ASSERT_EQ(IB_EINVAL, status); status = ib_operator_inst_create(op, ib_context_main(ib_engine), IB_OP_CAPABILITY_NON_STREAM, "data", &instance_data); ASSERT_EQ(IB_OK, status); ib_field_t *field; const char *matching = "data matching string"; const char *nonmatching = "non matching string"; ib_field_create( &field, ib_engine_pool_main_get(ib_engine), IB_FIELD_NAME("testfield"), IB_FTYPE_NULSTR, NULL ); ib_field_setv(field, ib_ftype_nulstr_in(matching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(1, call_result); ib_field_setv(field, ib_ftype_nulstr_in(nonmatching)); status = ib_operator_inst_execute(op, instance_data, ib_tx, field, NULL, &call_result); ASSERT_EQ(IB_OK, status); EXPECT_EQ(0, call_result); status = ib_operator_inst_destroy(op, instance_data); ASSERT_EQ(IB_OK, status); }
/** * Initialize the eudoxus operator module. * * Registers the operators and the hash for storing the eudoxus engine * instances created by the LoadEudoxus directive. * * @param[in] ib Ironbee engine. * @param[in] m Module instance. * @param[in] cbdata Not used. */ static ib_status_t ee_module_init(ib_engine_t *ib, ib_module_t *m, void *cbdata) { ib_status_t rc; ib_mpool_t *main_mp; ib_mpool_t *mod_mp; ee_config_t *config; main_mp = ib_engine_pool_main_get(ib); config = ee_get_config(ib); assert(config != NULL); rc = ib_mpool_create(&mod_mp, "ee_module", main_mp); if (rc != IB_OK ) { ib_log_error(ib, MODULE_NAME_STR ": Error allocating module mpool."); return rc; } if (config->eudoxus_pattern_hash == NULL) { rc = ib_hash_create_nocase(&(config->eudoxus_pattern_hash), mod_mp); if (rc != IB_OK ) { ib_log_error(ib, MODULE_NAME_STR ": Error initializing module."); return rc; } } rc = ib_operator_create_and_register( NULL, ib, "ee_match_any", ( IB_OP_CAPABILITY_NON_STREAM | IB_OP_CAPABILITY_STREAM | IB_OP_CAPABILITY_CAPTURE ), &ee_match_any_operator_create, NULL, NULL, NULL, &ee_match_any_operator_execute, m ); if (rc != IB_OK) { ib_log_error( ib, "Failed to register ee_match_any operator: %s", ib_status_to_string(rc)); return rc; } rc = ib_hook_tx_register(ib, tx_finished_event, ee_tx_finished_handler, m); if (rc != IB_OK) { ib_log_error( ib, "Failed to register transaction finished event for ee_match_any operator: %s", ib_status_to_string(rc)); return rc; } return IB_OK; }