-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor.c
110 lines (85 loc) · 1.54 KB
/
monitor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* monitor.c
*
* Created on: Nov 8, 2010
* Author: nuno
*/
#include "config.h"
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include "pcap_monitoring.h"
#include "table_port.h"
#include "filter.h"
#include "debugfs_support.h"
#ifdef MY_KPROBES
#include "syscalls_monitor.h"
#endif
char *application_name = "server";
struct local_addresses_list *local_list = NULL;
//#ifdef UNIT_TESTING
extern int populate(void);
extern int depopulate(void);
//#endif
static int loadSubSystems(void)
{
#ifdef DEBUGFS_SUPPORT
init_debug();
#endif
#ifdef FILTER_SUPPORT
init_Filter();
#endif
#ifdef DB_SUPPORT
init_DB();
#endif
// populate();
#ifdef SYSCALLS_SUPPORT
#ifdef MY_KPROBES
my_print_debug("Loaded %d probes", init_kretprobes_syscalls());
#endif
#endif
return 0;
}
static int unloadSubSystems(void)
{
#ifdef DEBUGFS_SUPPORT
destroy_debug();
#endif
#ifdef FILTER_SUPPORT
exit_Filter();
#endif
// depopulate();
#ifdef DB_SUPPORT
exit_DB();
#endif
#ifdef SYSCALLS_SUPPORT
#ifdef MY_KPROBES
destroy_kretprobes_syscalls();
#endif
#endif
return 0;
}
static int __init monitor_init(void)
{
loadSubSystems();
local_list = listAllDevicesAddress();
#ifdef UNIT_TESTING
populate();
#endif
return 0;
}
static void __exit monitor_exit(void)
{
int ret = -1;
unloadSubSystems();
#ifdef UNIT_TESTING
depopulate();
#endif
ret = remove_local_addresses_list(local_list);
if(ret == 0)
kfree(local_list);
}
module_init(monitor_init);
module_exit(monitor_exit);
MODULE_LICENSE("GPL");