2021-12-30 21:09:26 -05:00
|
|
|
#ifndef __MOD_MANAGER_H
|
|
|
|
|
#define __MOD_MANAGER_H
|
|
|
|
|
|
2021-12-31 09:54:47 -05:00
|
|
|
#include <stdint.h>
|
2022-01-04 13:26:13 -05:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
2021-12-30 21:09:26 -05:00
|
|
|
|
2021-12-31 09:54:47 -05:00
|
|
|
#define ON 1
|
|
|
|
|
#define OFF 0
|
|
|
|
|
|
2022-01-04 13:26:13 -05:00
|
|
|
//Centralized configutation struct.
|
|
|
|
|
//Used by the module manager to decide which modules to load
|
|
|
|
|
//If <all> is set in a module, the other configurations are ignored
|
2021-12-31 09:54:47 -05:00
|
|
|
typedef struct module_config_t{
|
|
|
|
|
struct xdp_module {
|
|
|
|
|
char all;
|
|
|
|
|
char xdp_receive;
|
|
|
|
|
} xdp_module;
|
|
|
|
|
|
|
|
|
|
struct sched_module {
|
|
|
|
|
char all;
|
|
|
|
|
char handle_sched_process_exec;
|
|
|
|
|
}sched_module;
|
|
|
|
|
|
2022-01-04 20:09:59 -05:00
|
|
|
struct fs_module {
|
|
|
|
|
char all;
|
2022-01-26 13:04:23 -05:00
|
|
|
char tp_sys_enter_read;
|
|
|
|
|
char tp_sys_exit_read;
|
2022-02-05 13:49:20 -05:00
|
|
|
char tp_sys_enter_openat;
|
2022-01-04 20:09:59 -05:00
|
|
|
}fs_module;
|
|
|
|
|
|
2022-02-06 14:15:57 -05:00
|
|
|
struct exec_module {
|
|
|
|
|
char all;
|
|
|
|
|
char tp_sys_enter_execve;
|
|
|
|
|
}exec_module;
|
|
|
|
|
|
2021-12-31 09:54:47 -05:00
|
|
|
} module_config_t;
|
|
|
|
|
|
2022-01-04 13:26:13 -05:00
|
|
|
//Configuration struct. Used by the module manager to
|
|
|
|
|
//correctly attach the needed modules, providing necessary params
|
|
|
|
|
typedef struct module_config_attr_t{
|
2022-01-16 06:56:54 -05:00
|
|
|
struct kit_bpf *skel;
|
2022-01-04 13:26:13 -05:00
|
|
|
struct xdp_module_attr {
|
|
|
|
|
__u32 ifindex;
|
|
|
|
|
__u32 flags;
|
|
|
|
|
} xdp_module;
|
|
|
|
|
|
|
|
|
|
struct sched_module_attr {
|
|
|
|
|
void* __empty;
|
|
|
|
|
}sched_module;
|
|
|
|
|
|
2022-01-04 20:09:59 -05:00
|
|
|
struct fs_module_attr {
|
|
|
|
|
void* __empty;
|
|
|
|
|
}fs_module;
|
|
|
|
|
|
2022-02-06 14:15:57 -05:00
|
|
|
struct exec_module_attr {
|
|
|
|
|
void* __empty;
|
|
|
|
|
}exec_module;
|
|
|
|
|
|
2022-01-04 13:26:13 -05:00
|
|
|
} module_config_attr_t;
|
|
|
|
|
|
|
|
|
|
//An unique module configutation struct and attr
|
2021-12-31 09:54:47 -05:00
|
|
|
extern module_config_t module_config;
|
2022-01-04 13:26:13 -05:00
|
|
|
extern module_config_attr_t module_config_attr;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Installs the ebpf modules according to the module_config
|
|
|
|
|
*
|
|
|
|
|
* @return 0 if ok, -1 if error
|
|
|
|
|
*/
|
|
|
|
|
int setup_all_modules();
|
2021-12-30 21:09:26 -05:00
|
|
|
|
|
|
|
|
#endif
|