1 #ifndef ETTERCAP_PLUGINS_H 2 #define ETTERCAP_PLUGINS_H 3 4 #include <ec_stdint.h> 5 #include <ec_version.h> 6 #include <ec_ui.h> 7 #include <ec_threads.h> 8 9 struct plugin_ops 10 { 11 char *ettercap_version; /* ettercap version MUST be the global EC_VERSION */ 12 char *name; /* the name of the plugin */ 13 char *info; /* a short description of the plugin */ 14 char *version; /* the plugin version. note: 15 will be displayed as 1.5 */ 15 int (*init)(void *); /* activation function */ 16 int (*fini)(void *); /* deactivation function */ 17 }; 18 19 struct plugin_list 20 { 21 char *name; 22 bool exists; 23 LIST_ENTRY(plugin_list) next; 24 }; 25 26 #ifdef OS_WINDOWS 27 #define PLUGIN_PATTERN "ec_*.dll" 28 #else 29 #define PLUGIN_PATTERN "ec_*.so" 30 #endif 31 32 EC_API_EXTERN void plugin_load_all(void); 33 EC_API_EXTERN int plugin_load_single(const char *path, char *name); 34 EC_API_EXTERN int plugin_register(void *handle, struct plugin_ops *ops); 35 EC_API_EXTERN int plugin_list_walk(int min, int max, void (*func)(char, struct plugin_ops *)); 36 #define PLP_MIN 1 37 #define PLP_MAX INT_MAX 38 39 EC_API_EXTERN int plugin_is_activated(char *name); 40 EC_API_EXTERN int search_plugin(char *name); 41 42 /* use these to activate and deactivate a plugin; these are *imported* from plugins */ 43 EC_API_EXTERN int plugin_init(char *name); 44 EC_API_EXTERN int plugin_fini(char *name); 45 EC_API_EXTERN int plugin_kill_thread(char *name, char *thread); 46 47 #define PLUGIN_FINISHED 0 48 #define PLUGIN_RUNNING 1 49 50 EC_API_EXTERN void plugin_list(void); 51 EC_API_EXTERN void free_plugin_list(struct plugin_list_t plugins); 52 53 #define PLUGIN_LOCK(x) \ 54 do{ \ 55 if (pthread_mutex_trylock(&x)) { \ 56 ec_thread_exit(); \ 57 return NULL; \ 58 } \ 59 } while(0) 60 61 #define PLUGIN_UNLOCK(x) \ 62 do{ \ 63 pthread_mutex_unlock(&x); \ 64 } while(0) 65 66 #endif 67 68 /* EOF */ 69 70 // vim:ts=3:expandtab 71 72