/// Function to handle the end of data coming on one of the sides
/// due to the stream reaching its 'depth' limit.
pub truncate: Option<TruncateFn>,
+
+ pub get_frame_id_by_name: Option<GetFrameIdByName>,
+ pub get_frame_name_by_id: Option<GetFrameNameById>,
}
/// Create a slice, given a buffer and a length
pub type GetTxDataFn = unsafe extern "C" fn(*mut c_void) -> *mut AppLayerTxData;
pub type ApplyTxConfigFn = unsafe extern "C" fn (*mut c_void, *mut c_void, c_int, AppLayerTxConfig);
pub type TruncateFn = unsafe extern "C" fn (*mut c_void, u8);
+pub type GetFrameIdByName = unsafe extern "C" fn(*const c_char) -> c_int;
+pub type GetFrameNameById = unsafe extern "C" fn(u8) -> *const c_char;
// Defined in app-layer-register.h
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config : None,
flags : APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate : None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config: Some(rs_dns_apply_tx_config),
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config: Some(rs_dns_apply_tx_config),
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS | APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: 0,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config : None,
flags : APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate : None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config : None,
flags : APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate : None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
// register UDP parser
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config: None,
flags: 0,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config : None,
flags : APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate : None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = std::ffi::CString::new("tcp").unwrap();
apply_tx_config: None,
flags: 0,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
truncate: Some(rs_smb_state_truncate),
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
apply_tx_config : None,
flags : APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate : None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("udp").unwrap();
if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {
apply_tx_config: None,
flags: 0,
truncate: None,
+ get_frame_id_by_name: None,
+ get_frame_name_by_id: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
void (*SetStreamDepthFlag)(void *tx, uint8_t flags);
+ AppLayerParserGetFrameIdByNameFn GetFrameIdByName;
+ AppLayerParserGetFrameNameByIdFn GetFrameNameById;
+
/* each app-layer has its own value */
uint32_t stream_depth;
SCReturn;
}
+void AppLayerParserRegisterGetFrameFuncs(uint8_t ipproto, AppProto alproto,
+ AppLayerParserGetFrameIdByNameFn GetIdByNameFunc,
+ AppLayerParserGetFrameNameByIdFn GetNameByIdFunc)
+{
+ SCEnter();
+ alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameIdByName = GetIdByNameFunc;
+ alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameNameById = GetNameByIdFunc;
+ SCReturn;
+}
+
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto,
int (*StateGetEventInfo)(const char *event_name, int *event_id,
AppLayerEventType *event_type))
SCReturn;
}
+int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name)
+{
+ if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameIdByName != NULL) {
+ return alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameIdByName(name);
+ } else {
+ return -1;
+ }
+}
+
+const char *AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
+{
+ if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameNameById != NULL) {
+ return alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetFrameNameById(id);
+ } else {
+ return NULL;
+ }
+}
+
/***** Cleanup *****/
void AppLayerParserStateProtoCleanup(
/***** Parser related registration *****/
+typedef int (*AppLayerParserGetFrameIdByNameFn)(const char *frame_name);
+typedef const char *(*AppLayerParserGetFrameNameByIdFn)(const uint8_t id);
+
/**
* \brief Register app layer parser for the protocol.
*
void AppLayerParserRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto,
int (*StateGetEventInfoById)(int event_id, const char **event_name,
AppLayerEventType *event_type));
+void AppLayerParserRegisterGetFrameFuncs(uint8_t ipproto, AppProto alproto,
+ AppLayerParserGetFrameIdByNameFn GetFrameIdByName,
+ AppLayerParserGetFrameNameByIdFn GetFrameNameById);
void AppLayerParserRegisterGetStreamDepth(uint8_t ipproto,
AppProto alproto,
uint32_t (*GetStreamDepth)(void));
uint32_t AppLayerParserGetStreamDepth(const Flow *f);
void AppLayerParserSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void *state, uint64_t tx_id, uint8_t flags);
int AppLayerParserIsEnabled(AppProto alproto);
+int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name);
+const char *AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id);
/***** Cleanup *****/
AppLayerParserRegisterTruncateFunc(p->ip_proto, alproto, p->Truncate);
}
+ if (p->GetFrameIdByName && p->GetFrameNameById) {
+ AppLayerParserRegisterGetFrameFuncs(
+ p->ip_proto, alproto, p->GetFrameIdByName, p->GetFrameNameById);
+ }
+
return 0;
}
void (*Truncate)(void *state, uint8_t direction);
+ AppLayerParserGetFrameIdByNameFn GetFrameIdByName;
+ AppLayerParserGetFrameNameByIdFn GetFrameNameById;
+
} AppLayerParser;
/**