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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
use crate::event::manager::EventManager;
use crate::session::session::Session;
use std::cell::RefCell;
use std::rc::Rc;
// L2 Event
pub const BUILTIN_L2_EVENT: &str = "BUILTIN_L2_EVENT";
// L3 Event
pub const BUILTIN_L3_EVENT: &str = "BUILTIN_L3_EVENT";
pub const BUILTIN_IPV4_EVENT: &str = "BUILTIN_IPV4_EVENT";
pub const BUILTIN_IPV6_EVENT: &str = "BUILTIN_IPV6_EVENT";
// L4 Event
pub const BUILTIN_L4_EVENT: &str = "BUILTIN_L4_EVENT";
pub const BUILTIN_TCP_EVENT: &str = "BUILTIN_TCP_EVENT";
pub const BUILTIN_TCP_OPENING_EVENT: &str = "BUILTIN_TCP_OPENING_EVENT";
pub const BUILTIN_TCP_ACTIVE_EVENT: &str = "BUILTIN_TCP_ACTIVE_EVENT";
pub const BUILTIN_TCP_EXPIRE_EVENT: &str = "BUILTIN_TCP_EXPIRE_EVENT";
pub const BUILTIN_TCP_CLOSED_EVENT: &str = "BUILTIN_TCP_CLOSED_EVENT";
pub const BUILTIN_UDP_EVENT: &str = "BUILTIN_UDP_EVENT";
pub const BUILTIN_UDP_OPENING_EVENT: &str = "BUILTIN_UDP_OPENING_EVENT";
pub const BUILTIN_UDP_ACTIVE_EVENT: &str = "BUILTIN_UDP_ACTIVE_EVENT";
pub const BUILTIN_UDP_EXPIRE_EVENT: &str = "BUILTIN_UDP_EXPIRE_EVENT";
// L7 Event
pub const BUILTIN_L7_EVENT: &str = "BUILTIN_L7_EVENT";
pub const BUILTIN_DNS_EVENT: &str = "BUILTIN_DNS_EVENT";
pub const BUILTIN_HTTP_EVENT: &str = "BUILTIN_HTTP_EVENT";
pub struct BuiltInEvent {}
impl BuiltInEvent {
pub fn trigger_l2_event(mgr: Rc<RefCell<EventManager>>, session: Option<Rc<RefCell<Session>>>) {
let builtin_l2_event = mgr.borrow_mut().event2index(BUILTIN_L2_EVENT);
mgr.borrow_mut().trigger(builtin_l2_event, session);
}
pub fn trigger_l3_event(mgr: Rc<RefCell<EventManager>>, session: Option<Rc<RefCell<Session>>>) {
let builtin_l3_event = mgr.borrow_mut().event2index(BUILTIN_L3_EVENT);
mgr.borrow_mut().trigger(builtin_l3_event, session);
}
pub fn trigger_ipv4_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_ipv4_event = mgr.borrow_mut().event2index(BUILTIN_IPV4_EVENT);
mgr.borrow_mut().trigger(builtin_ipv4_event, session);
}
pub fn trigger_ipv6_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_ipv6_event = mgr.borrow_mut().event2index(BUILTIN_IPV6_EVENT);
mgr.borrow_mut().trigger(builtin_ipv6_event, session);
}
pub fn trigger_l4_event(mgr: Rc<RefCell<EventManager>>, session: Option<Rc<RefCell<Session>>>) {
let builtin_l4_event = mgr.borrow_mut().event2index(BUILTIN_L4_EVENT);
mgr.borrow_mut().trigger(builtin_l4_event, session);
}
pub fn trigger_tcp_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_tcp_event = mgr.borrow_mut().event2index(BUILTIN_TCP_EVENT);
mgr.borrow_mut().trigger(builtin_tcp_event, session);
}
pub fn trigger_tcp_opening_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_tcp_opening_event = mgr.borrow_mut().event2index(BUILTIN_TCP_OPENING_EVENT);
mgr.borrow_mut().trigger(builtin_tcp_opening_event, session);
}
pub fn trigger_tcp_active_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_tcp_active_event = mgr.borrow_mut().event2index(BUILTIN_TCP_ACTIVE_EVENT);
mgr.borrow_mut().trigger(builtin_tcp_active_event, session);
}
pub fn trigger_tcp_expire_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_tcp_expire_event = mgr.borrow_mut().event2index(BUILTIN_TCP_EXPIRE_EVENT);
mgr.borrow_mut().trigger(builtin_tcp_expire_event, session);
}
pub fn trigger_tcp_closed_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_tcp_closed_event = mgr.borrow_mut().event2index(BUILTIN_TCP_CLOSED_EVENT);
mgr.borrow_mut().trigger(builtin_tcp_closed_event, session);
}
pub fn trigger_udp_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_udp_event = mgr.borrow_mut().event2index(BUILTIN_UDP_EVENT);
mgr.borrow_mut().trigger(builtin_udp_event, session);
}
pub fn trigger_udp_opening_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_udp_opening_event = mgr.borrow_mut().event2index(BUILTIN_UDP_OPENING_EVENT);
mgr.borrow_mut().trigger(builtin_udp_opening_event, session);
}
pub fn trigger_udp_active_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_udp_active_event = mgr.borrow_mut().event2index(BUILTIN_UDP_ACTIVE_EVENT);
mgr.borrow_mut().trigger(builtin_udp_active_event, session);
}
pub fn trigger_udp_expire_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_udp_expire_event = mgr.borrow_mut().event2index(BUILTIN_UDP_EXPIRE_EVENT);
mgr.borrow_mut().trigger(builtin_udp_expire_event, session);
}
pub fn trigger_l7_event(mgr: Rc<RefCell<EventManager>>, session: Option<Rc<RefCell<Session>>>) {
let builtin_l7_event = mgr.borrow_mut().event2index(BUILTIN_L7_EVENT);
mgr.borrow_mut().trigger(builtin_l7_event, session);
}
pub fn trigger_dns_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_dns_event = mgr.borrow_mut().event2index(BUILTIN_DNS_EVENT);
mgr.borrow_mut().trigger(builtin_dns_event, session);
}
pub fn trigger_http_event(
mgr: Rc<RefCell<EventManager>>,
session: Option<Rc<RefCell<Session>>>,
) {
let builtin_http_event = mgr.borrow_mut().event2index(BUILTIN_HTTP_EVENT);
mgr.borrow_mut().trigger(builtin_http_event, session);
}
}
|