app-layer: remove logged API calls

pull/5169/head
Victor Julien 5 years ago
parent 455eab370e
commit 9664f73f75

@ -199,11 +199,6 @@ pub struct RustParser {
/// Function returning the current transaction progress
pub tx_get_progress: StateGetProgressFn,
/// Logged transaction getter function
pub get_tx_logged: Option<GetTxLoggedFn>,
/// Logged transaction setter function
pub set_tx_logged: Option<SetTxLoggedFn>,
/// Function called to get a detection state
pub get_de_state: GetDetectStateFn,
/// Function called to set a detection state
@ -278,8 +273,6 @@ pub type SetDetectStateFn = extern "C" fn (*mut c_void, &mut DetectEngineState
pub type GetEventInfoFn = extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int;
pub type GetEventInfoByIdFn = extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8;
pub type GetEventsFn = extern "C" fn (*mut c_void) -> *mut AppLayerDecoderEvents;
pub type GetTxLoggedFn = extern "C" fn (*mut c_void, *mut c_void) -> u32;
pub type SetTxLoggedFn = extern "C" fn (*mut c_void, *mut c_void, u32);
pub type LocalStorageNewFn = extern "C" fn () -> *mut c_void;
pub type LocalStorageFreeFn = extern "C" fn (*mut c_void);
pub type GetFilesFn = extern "C" fn (*mut c_void, u8) -> *mut FileContainer;

@ -507,8 +507,6 @@ pub unsafe extern "C" fn rs_template_register_parser() {
get_tx: rs_template_state_get_tx,
tx_get_comp_st: rs_template_state_progress_completion_status,
tx_get_progress: rs_template_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_de_state: rs_template_tx_get_detect_state,
set_de_state: rs_template_tx_set_detect_state,
get_events: Some(rs_template_state_get_events),

@ -426,8 +426,6 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
get_tx : rs_dhcp_state_get_tx,
tx_get_comp_st : rs_dhcp_state_progress_completion_status,
tx_get_progress : rs_dhcp_tx_get_alstate_progress,
get_tx_logged : None,
set_tx_logged : None,
get_de_state : rs_dhcp_tx_get_detect_state,
set_de_state : rs_dhcp_tx_set_detect_state,
get_events : Some(rs_dhcp_state_get_events),

@ -969,8 +969,6 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
get_tx: rs_dns_state_get_tx,
tx_get_comp_st: rs_dns_state_progress_completion_status,
tx_get_progress: rs_dns_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_events: Some(rs_dns_state_get_events),
get_eventinfo: Some(rs_dns_state_get_event_info),
get_eventinfo_byid: Some(rs_dns_state_get_event_info_by_id),
@ -1016,8 +1014,6 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
get_tx: rs_dns_state_get_tx,
tx_get_comp_st: rs_dns_state_progress_completion_status,
tx_get_progress: rs_dns_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_events: Some(rs_dns_state_get_events),
get_eventinfo: Some(rs_dns_state_get_event_info),
get_eventinfo_byid: Some(rs_dns_state_get_event_info_by_id),

@ -701,8 +701,6 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() {
get_tx : rs_ikev2_state_get_tx,
tx_get_comp_st : rs_ikev2_state_progress_completion_status,
tx_get_progress : rs_ikev2_tx_get_alstate_progress,
get_tx_logged : None,
set_tx_logged : None,
get_de_state : rs_ikev2_state_get_tx_detect_state,
set_de_state : rs_ikev2_state_set_tx_detect_state,
get_events : Some(rs_ikev2_state_get_events),

@ -647,8 +647,6 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
get_tx : rs_krb5_state_get_tx,
tx_get_comp_st : rs_krb5_state_progress_completion_status,
tx_get_progress : rs_krb5_tx_get_alstate_progress,
get_tx_logged : None,
set_tx_logged : None,
get_de_state : rs_krb5_state_get_tx_detect_state,
set_de_state : rs_krb5_state_set_tx_detect_state,
get_events : Some(rs_krb5_state_get_events),

@ -397,8 +397,6 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
get_tx : rs_ntp_state_get_tx,
tx_get_comp_st : rs_ntp_state_progress_completion_status,
tx_get_progress : rs_ntp_tx_get_alstate_progress,
get_tx_logged : None,
set_tx_logged : None,
get_de_state : rs_ntp_state_get_tx_detect_state,
set_de_state : rs_ntp_state_set_tx_detect_state,
get_events : Some(rs_ntp_state_get_events),

@ -519,8 +519,6 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
get_tx: rs_rdp_state_get_tx,
tx_get_comp_st: rs_rdp_tx_get_progress_complete,
tx_get_progress: rs_rdp_tx_get_progress,
get_tx_logged: None,
set_tx_logged: None,
get_de_state: rs_rdp_tx_get_detect_state,
set_de_state: rs_rdp_tx_set_detect_state,
get_events: None,

@ -689,8 +689,6 @@ pub unsafe extern "C" fn rs_rfb_register_parser() {
get_tx: rs_rfb_state_get_tx,
tx_get_comp_st: rs_rfb_state_progress_completion_status,
tx_get_progress: rs_rfb_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_de_state: rs_rfb_tx_get_detect_state,
set_de_state: rs_rfb_tx_set_detect_state,
get_events: Some(rs_rfb_state_get_events),

@ -382,8 +382,6 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
get_tx: rs_sip_state_get_tx,
tx_get_comp_st: rs_sip_state_progress_completion_status,
tx_get_progress: rs_sip_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_de_state: rs_sip_state_get_tx_detect_state,
set_de_state: rs_sip_state_set_tx_detect_state,
get_events: Some(rs_sip_state_get_events),

@ -575,8 +575,6 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
get_tx : rs_snmp_state_get_tx,
tx_get_comp_st : rs_snmp_state_progress_completion_status,
tx_get_progress : rs_snmp_tx_get_alstate_progress,
get_tx_logged : None,
set_tx_logged : None,
get_de_state : rs_snmp_state_get_tx_detect_state,
set_de_state : rs_snmp_state_set_tx_detect_state,
get_events : Some(rs_snmp_state_get_events),

@ -549,8 +549,6 @@ pub unsafe extern "C" fn rs_ssh_register_parser() {
get_tx: rs_ssh_state_get_tx,
tx_get_comp_st: rs_ssh_state_progress_completion_status,
tx_get_progress: rs_ssh_tx_get_alstate_progress,
get_tx_logged: None,
set_tx_logged: None,
get_de_state: rs_ssh_tx_get_detect_state,
set_de_state: rs_ssh_tx_set_detect_state,
get_events: Some(rs_ssh_state_get_events),

@ -117,9 +117,6 @@ typedef struct AppLayerParserProtoCtx_
int (*StateGetEventInfo)(const char *event_name,
int *event_id, AppLayerEventType *event_type);
LoggerId (*StateGetTxLogged)(void *alstate, void *tx);
void (*StateSetTxLogged)(void *alstate, void *tx, LoggerId logger);
DetectEngineState *(*GetTxDetectState)(void *tx);
int (*SetTxDetectState)(void *tx, DetectEngineState *);
@ -442,21 +439,6 @@ void AppLayerParserRegisterGetEventsFunc(uint8_t ipproto, AppProto alproto,
SCReturn;
}
void AppLayerParserRegisterLoggerFuncs(uint8_t ipproto, AppProto alproto,
LoggerId (*StateGetTxLogged)(void *, void *),
void (*StateSetTxLogged)(void *, void *, LoggerId))
{
SCEnter();
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateGetTxLogged =
StateGetTxLogged;
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateSetTxLogged =
StateSetTxLogged;
SCReturn;
}
void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits)
{
SCEnter();
@ -701,34 +683,6 @@ AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto,
return Func ? Func : AppLayerDefaultGetTxIterator;
}
void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto,
void *alstate, void *tx, LoggerId logger)
{
SCEnter();
if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
StateSetTxLogged != NULL) {
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
StateSetTxLogged(alstate, tx, logger);
}
SCReturn;
}
LoggerId AppLayerParserGetTxLogged(const Flow *f,
void *alstate, void *tx)
{
SCEnter();
LoggerId r = 0;
if (alp_ctx.ctxs[f->protomap][f->alproto].StateGetTxLogged != NULL) {
r = alp_ctx.ctxs[f->protomap][f->alproto].
StateGetTxLogged(alstate, tx);
}
SCReturnUInt(r);
}
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate)
{
SCEnter();
@ -787,9 +741,8 @@ static inline uint32_t GetTxLogged(const Flow *f, void *alstate, void *tx)
AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, tx);
if (txd) {
return txd->logged.flags;
} else {
return AppLayerParserGetTxLogged(f, alstate, tx);
}
return 0;
}
void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate,
@ -1549,7 +1502,6 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
printf("- GetTxDetectState %p SetTxDetectState %p\n", ctx->GetTxDetectState, ctx->SetTxDetectState);
printf("Optional:\n");
printf("- LocalStorageAlloc %p LocalStorageFree %p\n", ctx->LocalStorageAlloc, ctx->LocalStorageFree);
printf("- StateGetTxLogged %p StateSetTxLogged %p\n", ctx->StateGetTxLogged, ctx->StateSetTxLogged);
printf("- StateGetEvents %p StateGetEventInfo %p StateGetEventInfoById %p\n", ctx->StateGetEvents, ctx->StateGetEventInfo,
ctx->StateGetEventInfoById);
}
@ -1585,9 +1537,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
if (!(BOTH_SET_OR_BOTH_UNSET(ctx->LocalStorageAlloc, ctx->LocalStorageFree))) {
goto bad;
}
if (!(BOTH_SET_OR_BOTH_UNSET(ctx->StateGetTxLogged, ctx->StateSetTxLogged))) {
goto bad;
}
if (!(BOTH_SET(ctx->GetTxDetectState, ctx->SetTxDetectState))) {
goto bad;
}

@ -206,10 +206,6 @@ void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto a
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate);
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id);
void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate,
void *tx, LoggerId logged);
LoggerId AppLayerParserGetTxLogged(const Flow *f, void *alstate, void *tx);
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction);
void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate,
void *alstate, const uint8_t flags, bool tag_txs_as_inspected);

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Open Information Security Foundation
/* Copyright (C) 2017-2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -136,11 +136,6 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
AppLayerParserRegisterGetTx(p->ip_proto, alproto,
p->StateGetTx);
if (p->StateGetTxLogged && p->StateSetTxLogged) {
AppLayerParserRegisterLoggerFuncs(p->ip_proto, alproto,
p->StateGetTxLogged, p->StateSetTxLogged);
}
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(p->ip_proto, alproto,
p->GetTxDetectState, p->SetTxDetectState);

@ -48,9 +48,6 @@ typedef struct AppLayerParser {
int (*StateGetProgressCompletionStatus)(uint8_t direction);
int (*StateGetProgress)(void *alstate, uint8_t direction);
uint32_t (*StateGetTxLogged)(void *alstate, void *tx);
void (*StateSetTxLogged)(void *alstate, void *tx, uint32_t logger);
DetectEngineState *(*GetTxDetectState)(void *tx);
int (*SetTxDetectState)(void *tx, DetectEngineState *);

@ -223,7 +223,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
goto next_tx;
}
LoggerId tx_logged = txd ? txd->logged.flags : AppLayerParserGetTxLogged(f, alstate, tx);
LoggerId tx_logged = txd ? txd->logged.flags : 0;
const LoggerId tx_logged_old = tx_logged;
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, tx_logged);
if (tx_logged == logger_expectation) {
@ -297,9 +297,6 @@ next_logger:
tx_logged, tx_logged_old);
if (txd != NULL) {
txd->logged.flags |= tx_logged;
} else {
AppLayerParserSetTxLogged(p->proto, alproto, alstate, tx,
tx_logged);
}
}

Loading…
Cancel
Save