-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.rs
59 lines (49 loc) · 1.49 KB
/
plugin.rs
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
use std::os::raw::c_int;
/// Main wireshark entry
use wireshark_ffi::bindings::*;
use crate::dissects::dissect_kafka_tcp;
use crate::fields::*;
use crate::utils::i8_str;
#[no_mangle]
#[used]
pub static plugin_version: [u8; 6] = *b"0.0.0\0";
#[no_mangle]
#[used]
pub static plugin_want_major: i32 = 3;
#[no_mangle]
#[used]
pub static plugin_want_minor: i32 = 6;
pub(crate) const KAFKA_PORT: u32 = 9092;
pub(crate) static mut PROTO_KAFKA: i32 = -1;
/// Protocol handler. Registered with wireshark at runtime.
static PLUGIN: proto_plugin = proto_plugin {
register_protoinfo: Some(proto_register_kafka),
register_handoff: Some(proto_reg_handoff_kafka),
};
#[no_mangle]
pub extern "C" fn plugin_register() {
unsafe {
proto_register_plugin(&PLUGIN);
}
}
extern "C" fn proto_register_kafka() {
unsafe {
PROTO_KAFKA = proto_register_protocol(
i8_str("Kafka4r\0"),
i8_str("kafka4r\0"),
i8_str("kafka4r\0"),
);
// Register fields
let hf_unsafe = HF.as_ptr() as *mut hf_register_info;
proto_register_field_array(PROTO_KAFKA, hf_unsafe, HF.len() as c_int);
// Register ett
let ett = create_ett();
proto_register_subtree_array(ett.as_ptr(), ett.len() as c_int);
}
}
extern "C" fn proto_reg_handoff_kafka() {
unsafe {
let kafka_handle = create_dissector_handle(Some(dissect_kafka_tcp), PROTO_KAFKA);
dissector_add_uint(i8_str("tcp.port\0"), KAFKA_PORT, kafka_handle);
}
}