use crate::applayer::{self, *};
use crate::core;
use crate::core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_UDP};
-use crate::core::sc_app_layer_decoder_events_free_events;
use crate::dhcp::parser::*;
use std;
use std::ffi::CString;
pub struct DHCPTransaction {
tx_id: u64,
pub message: DHCPMessage,
- events: *mut core::AppLayerDecoderEvents,
tx_data: applayer::AppLayerTxData,
}
DHCPTransaction {
tx_id: id,
message: message,
- events: std::ptr::null_mut(),
tx_data: applayer::AppLayerTxData::new(),
}
}
-
- pub fn free(&mut self) {
- if !self.events.is_null() {
- sc_app_layer_decoder_events_free_events(&mut self.events);
- }
- }
-
}
impl Transaction for DHCPTransaction {
}
}
-impl Drop for DHCPTransaction {
- fn drop(&mut self) {
- self.free();
- }
-}
-
#[derive(Default)]
pub struct DHCPState {
// Internal transaction ID.
fn set_event(&mut self, event: DHCPEvent) {
if let Some(tx) = self.transactions.last_mut() {
- core::sc_app_layer_decoder_events_set_event_raw(
- &mut tx.events, event as u8);
+ tx.tx_data.set_event(event as u8);
self.events += 1;
}
}
std::mem::drop(Box::from_raw(state as *mut DHCPState));
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_dhcp_state_get_events(tx: *mut std::os::raw::c_void)
- -> *mut core::AppLayerDecoderEvents
-{
- let tx = cast_pointer!(tx, DHCPTransaction);
- return tx.events;
-}
-
export_tx_data_get!(rs_dhcp_get_tx_data, DHCPTransaction);
const PARSER_NAME: &'static [u8] = b"dhcp\0";
tx_comp_st_ts : 1,
tx_comp_st_tc : 1,
tx_get_progress : rs_dhcp_tx_get_alstate_progress,
- get_events : Some(rs_dhcp_state_get_events),
get_eventinfo : Some(DHCPEvent::get_event_info),
get_eventinfo_byid : Some(DHCPEvent::get_event_info_by_id),
localstorage_new : None,