|
|
|
|
@ -38,7 +38,17 @@ pub enum NTPEvent {
|
|
|
|
|
NotResponse,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl NTPEvent {
|
|
|
|
|
fn from_i32(value: i32) -> Option<NTPEvent> {
|
|
|
|
|
match value {
|
|
|
|
|
0 => Some(NTPEvent::UnsolicitedResponse),
|
|
|
|
|
1 => Some(NTPEvent::MalformedData),
|
|
|
|
|
2 => Some(NTPEvent::NotRequest),
|
|
|
|
|
3 => Some(NTPEvent::NotResponse),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct NTPState {
|
|
|
|
|
/// List of transactions for this session
|
|
|
|
|
@ -301,6 +311,28 @@ pub extern "C" fn rs_ntp_state_get_tx_detect_state(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub extern "C" fn rs_ntp_state_get_event_info_by_id(event_id: std::os::raw::c_int,
|
|
|
|
|
event_name: *mut *const std::os::raw::c_char,
|
|
|
|
|
event_type: *mut core::AppLayerEventType)
|
|
|
|
|
-> i8
|
|
|
|
|
{
|
|
|
|
|
if let Some(e) = NTPEvent::from_i32(event_id as i32) {
|
|
|
|
|
let estr = match e {
|
|
|
|
|
NTPEvent::UnsolicitedResponse => { "unsolicited_response\0" },
|
|
|
|
|
NTPEvent::MalformedData => { "malformed_data\0" },
|
|
|
|
|
NTPEvent::NotRequest => { "not_request\0" },
|
|
|
|
|
NTPEvent::NotResponse => { "not_response\0" },
|
|
|
|
|
};
|
|
|
|
|
unsafe{
|
|
|
|
|
*event_name = estr.as_ptr() as *const std::os::raw::c_char;
|
|
|
|
|
*event_type = core::APP_LAYER_EVENT_TYPE_TRANSACTION;
|
|
|
|
|
};
|
|
|
|
|
0
|
|
|
|
|
} else {
|
|
|
|
|
-1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub extern "C" fn rs_ntp_state_get_events(tx: *mut std::os::raw::c_void)
|
|
|
|
|
@ -390,6 +422,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
|
|
|
|
|
set_de_state : rs_ntp_state_set_tx_detect_state,
|
|
|
|
|
get_events : Some(rs_ntp_state_get_events),
|
|
|
|
|
get_eventinfo : Some(rs_ntp_state_get_event_info),
|
|
|
|
|
get_eventinfo_byid : Some(rs_ntp_state_get_event_info_by_id),
|
|
|
|
|
localstorage_new : None,
|
|
|
|
|
localstorage_free : None,
|
|
|
|
|
get_tx_mpm_id : None,
|
|
|
|
|
@ -407,7 +440,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
|
|
|
|
|
let _ = AppLayerRegisterParser(&parser, alproto);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SCLogDebug!("Protocol detecter and parser disabled for NTP.");
|
|
|
|
|
SCLogDebug!("Protocol detector and parser disabled for NTP.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|