smf_modules.h
Go to the documentation of this file.
1 /* spmfilter - mail filtering framework
2  * Copyright (C) 2009-2012 Sebastian Jaekel, Axel Steiner and SpaceNet AG
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef _SMF_MODULES_H
19 #define _SMF_MODULES_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include <stdint.h>
26 
27 #include "smf_settings.h"
28 #include "smf_session.h"
29 #include "smf_list.h"
30 
45 typedef int (*ModuleLoadFunction)(SMFSettings_T *settings, SMFSession_T *session);
46 typedef int (*LoadEngine)(SMFSettings_T *settings);
47 
48 
53 typedef struct {
54  uint8_t type;
57  char *name;
58  union {
59  void *handle;
60  ModuleLoadFunction callback;
61  } u;
62 } SMFModule_T;
63 
64 typedef struct {
65  int (*load_error)(SMFSettings_T *settings, SMFSession_T *session);
66  int (*processing_error)(SMFSettings_T *settings, SMFSession_T *session, int retval);
67  int (*nexthop_error)(SMFSettings_T *settings, SMFSession_T *session);
69 
70 
72 SMFProcessQueue_T *smf_modules_pqueue_init(
73  int (*loaderr)(SMFSettings_T *settings, SMFSession_T *session),
74  int (*processerr)(SMFSettings_T *settings, SMFSession_T *session, int retval),
75  int (*nhoperr)(SMFSettings_T *settings, SMFSession_T *session));
76 
88 SMFModule_T *smf_module_create(const char *name);
89 
103 SMFModule_T *smf_module_create_callback(const char *name, ModuleLoadFunction callback);
104 
114 int smf_module_destroy(SMFModule_T *module);
115 
129 int smf_module_invoke(SMFSettings_T *settings, SMFModule_T *module, SMFSession_T *session);
130 
132 int smf_modules_process(SMFProcessQueue_T *q, SMFSession_T *session, SMFSettings_T *settings);
133 
135 int smf_modules_deliver_nexthop(SMFSettings_T *settings, SMFProcessQueue_T *q, SMFSession_T *session);
136 
138 int smf_modules_flush_dirty(SMFSettings_T *settings, SMFSession_T *session, SMFList_T *initial_headers);
139 
140 int smf_modules_engine_load(SMFSettings_T *settings);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* _SMF_MODULES_H */