Go to the documentation of this file.
85 void *(*LocalStorageAlloc)(void);
94 void *(*StateGetTx)(
void *alstate, uint64_t tx_id);
157 static void AppLayerConfig(
void)
169 if (frames != NULL) {
186 if (f == NULL || f->
alparser == NULL)
232 return (alp_ctx.
ctxs[alproto][ipproto_map].
StateAlloc != NULL) ? 1 : 0;
253 AppLayerParserFramesFreeContainer(pstate->
frames);
357 r = snprintf(param,
sizeof(param),
"%s%s%s",
"app-layer.protocols.",
358 alproto_name,
".enabled");
361 }
else if (r > (
int)
sizeof(param)) {
362 FatalError(
"buffer not big enough to write param.");
368 r = snprintf(param,
sizeof(param),
"%s%s%s%s%s",
"app-layer.protocols.",
369 alproto_name,
".", ipproto,
".enabled");
372 }
else if (r > (
int)
sizeof(param)) {
373 FatalError(
"buffer not big enough to write param.");
387 }
else if (strcasecmp(node->
val,
"detection-only") == 0) {
390 SCLogError(
"Invalid value found for %s.", param);
409 .
Parser[(direction & STREAM_TOSERVER) ? 0 : 1] = Parser;
415 uint8_t ipproto,
AppProto alproto, uint8_t direction)
420 (direction & (STREAM_TOSERVER | STREAM_TOCLIENT));
436 void *(*StateAlloc)(
void *,
AppProto),
void (*StateFree)(
void *))
447 void *(*LocalStorageAlloc)(
void),
448 void (*LocalStorageFree)(
void *))
487 int (*StateGetProgress)(
void *alstate, uint8_t direction))
497 void (*StateTransactionFree)(
void *, uint64_t))
507 uint64_t (*StateGetTxCnt)(
void *alstate))
517 void *(StateGetTx)(
void *alstate, uint64_t tx_id))
539 BUG_ON(!AppProtoIsValid(alproto));
550 int (*StateGetEventInfoById)(
556 StateGetEventInfoById;
582 int (*StateGetEventInfo)(
623 void (*SetStreamDepthFlag)(
void *tx, uint8_t
flags))
667 const uint8_t ipproto,
const AppProto alproto,
668 void *alstate, uint64_t min_tx_id, uint64_t max_tx_id,
671 uint64_t ustate = *(uint64_t *)state;
672 uint64_t tx_id =
MAX(min_tx_id, ustate);
673 for ( ; tx_id < max_tx_id; tx_id++) {
675 if (tx_ptr != NULL) {
681 .has_next = (tx_id + 1 < max_tx_id),
698 return Func ? Func : AppLayerDefaultGetTxIterator;
761 void *alstate,
const uint8_t
flags,
762 bool tag_txs_as_inspected)
766 const int direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
770 const uint8_t ipproto = f->
proto;
776 SCLogDebug(
"called: %s, tag_txs_as_inspected %s",direction==0?
"toserver":
"toclient",
777 tag_txs_as_inspected?
"true":
"false");
790 if (state_progress < state_done_progress)
794 if (tag_txs_as_inspected) {
797 if (txd->
flags & inspected_flag) {
798 txd->
flags |= inspected_flag;
799 SCLogDebug(
"%p/%" PRIu64
" in-order tx is done for direction %s. Flags %02x", tx,
800 idx,
flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->
flags);
812 if (tag_txs_as_inspected) {
829 if (state_progress < state_done_progress)
836 if (txd->
flags & inspected_flag) {
837 txd->
flags |= inspected_flag;
838 SCLogDebug(
"%p/%" PRIu64
" out of order tx is done for direction %s. Flag %02x", tx,
839 idx,
flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->
flags);
841 SCLogDebug(
"%p/%" PRIu64
" out of order tx. Update inspect_id? %" PRIu64, tx, idx,
860 "AppLayerDecoderEvents *");
872 if (txd->
events != NULL) {
891 static void AppLayerParserFileTxHousekeeping(
892 const Flow *f,
void *tx,
const uint8_t pkt_dir,
const bool trunc)
900 #define IS_DISRUPTED(flags) ((flags) & (STREAM_DEPTH | STREAM_GAP))
919 const uint8_t ipproto = f->
proto;
921 void *
const alstate = f->
alstate;
924 if (alstate == NULL || alparser == NULL)
927 const uint64_t min = alparser->
min_id;
935 int pkt_dir_trunc = -1;
939 memset(&state, 0,
sizeof(state));
941 uint64_t new_min = min;
943 bool skipped =
false;
951 bool tx_skipped =
false;
958 if (pkt_dir_trunc == -1)
960 (pkt_dir == STREAM_TOSERVER) ? ts_disrupt_flags : tc_disrupt_flags);
961 AppLayerParserFileTxHousekeeping(f, tx, pkt_dir, (
bool)pkt_dir_trunc);
964 if (pkt_dir & STREAM_TOSERVER) {
969 const int tx_progress_tc =
971 if (tx_progress_tc < tx_end_state_tc) {
972 SCLogDebug(
"%p/%"PRIu64
" skipping: tc parser not done", tx, i);
976 const int tx_progress_ts =
978 if (tx_progress_ts < tx_end_state_ts) {
979 SCLogDebug(
"%p/%"PRIu64
" skipping: ts parser not done", tx, i);
984 if (has_tx_detect_flags) {
989 SCLogDebug(
"%p/%" PRIu64
" skipping: TS inspect not done: ts:%02x", tx, i,
998 SCLogDebug(
"%p/%" PRIu64
" skipping: TC inspect not done: ts:%02x", tx, i,
1006 SCLogDebug(
"%p/%" PRIu64
" tx_skipped", tx, i);
1011 if (logger_expectation != 0) {
1012 LoggerId tx_logged = GetTxLogged(txd);
1013 if (tx_logged != logger_expectation) {
1014 SCLogDebug(
"%p/%"PRIu64
" skipping: logging not done: want:%"PRIx32
", have:%"PRIx32,
1015 tx, i, logger_expectation, tx_logged);
1042 SCLogDebug(
"skipped? %s i %"PRIu64
", new_min %"PRIu64, skipped ?
"true" :
"false", i, new_min);
1045 SCLogDebug(
"final i %"PRIu64
", new_min %"PRIu64, i, new_min);
1052 SCLogDebug(
"no next: cur tx i %"PRIu64
", total %"PRIu64, i, total_txs);
1054 new_min = total_txs;
1055 SCLogDebug(
"no next: cur tx i %"PRIu64
", total %"PRIu64
": "
1056 "new_min updated to %"PRIu64, i, total_txs, new_min);
1064 SCLogDebug(
"update f->alparser->min_id? %"PRIu64
" vs %"PRIu64, new_min, alparser->
min_id);
1065 if (new_min > alparser->
min_id) {
1066 const uint64_t next_id = new_min;
1067 alparser->
min_id = next_id;
1076 static inline int StateGetProgressCompletionStatus(
const AppProto alproto,
const uint8_t
flags)
1078 if (
flags & STREAM_TOSERVER) {
1080 }
else if (
flags & STREAM_TOCLIENT) {
1094 void *alstate, uint8_t
flags)
1099 r = StateGetProgressCompletionStatus(alproto,
flags);
1101 uint8_t direction =
flags & (STREAM_TOCLIENT | STREAM_TOSERVER);
1103 alstate, direction);
1126 int r = StateGetProgressCompletionStatus(alproto, direction);
1138 event_name, event_id, event_type);
1147 *event_name = (
const char *)NULL;
1151 event_id, event_name, event_type);
1222 if ((
flags & (STREAM_EOF|STREAM_TOSERVER)) == (STREAM_EOF|STREAM_TOSERVER)) {
1223 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TS");
1225 }
else if ((
flags & (STREAM_EOF|STREAM_TOCLIENT)) == (STREAM_EOF|STREAM_TOCLIENT)) {
1226 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TC");
1235 static void HandleStreamFrames(
Flow *f,
StreamSlice stream_slice,
const uint8_t *input,
1236 const uint32_t input_len,
const uint8_t
flags)
1238 const uint8_t direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
1244 input != NULL && f->
proto == IPPROTO_TCP) {
1246 if (frame == NULL) {
1247 int64_t frame_len = -1;
1248 if (
flags & STREAM_EOF)
1249 frame_len = input_len;
1254 SCLogDebug(
"opened: frame %p id %" PRIi64, frame, frame->
id);
1259 if (direction == 0) {
1265 }
else if (
flags & STREAM_EOF) {
1270 int64_t slice_o = (int64_t)stream_slice.
offset - (int64_t)frame->
offset;
1271 int64_t frame_len = slice_o + (int64_t)input_len;
1272 SCLogDebug(
"%s: EOF frame->offset %" PRIu64
" -> %" PRIi64
": o %" PRIi64,
1274 frame->
len = frame_len;
1279 static void Setup(
Flow *f,
const uint8_t direction,
const uint8_t *input, uint32_t input_len,
1282 memset(as, 0,
sizeof(*as));
1298 uint8_t
flags,
const uint8_t *input, uint32_t input_len)
1301 #ifdef DEBUG_VALIDATION
1307 void *alstate = NULL;
1308 uint64_t p_tx_cnt = 0;
1309 uint32_t consumed = input_len;
1310 const uint8_t direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
1314 if (f->
proto == IPPROTO_TCP) {
1320 if (
flags & STREAM_GAP) {
1322 SCLogDebug(
"app-layer parser does not accept gaps");
1332 if (pstate == NULL) {
1334 if (pstate == NULL) {
1340 SetEOFFlags(pstate,
flags);
1345 if (alstate == NULL) {
1349 SCLogDebug(
"alloced new app layer state %p (name %s)",
1357 SCLogDebug(
"state data: updating file_flags %04x with flow file_flags %04x",
1364 SCLogDebug(
"using existing app layer state %p (name %s))",
1371 if (input_len > 0 || (
flags & STREAM_EOF)) {
1372 Setup(f,
flags & (STREAM_TOSERVER | STREAM_TOCLIENT), input, input_len,
flags,
1374 HandleStreamFrames(f, stream_slice, input, input_len,
flags);
1376 #ifdef QA_SIMULATION
1377 if (((stream_slice.
flags & STREAM_TOSERVER) &&
1378 stream_slice.
offset >= g_eps_applayer_error_offset_ts)) {
1379 SCLogNotice(
"putting parser %s into an error state from toserver offset %" PRIu64,
1384 if (((stream_slice.
flags & STREAM_TOCLIENT) &&
1385 stream_slice.
offset >= g_eps_applayer_error_offset_tc)) {
1386 SCLogNotice(
"putting parser %s into an error state from toclient offset %" PRIu64,
1398 }
else if (res.
status > 0) {
1415 (
flags & STREAM_TOSERVER) ?
"toserver" :
"toclient");
1416 if (direction == 0) {
1438 if (f->
proto == IPPROTO_TCP) {
1460 FlowSetNoPayloadInspectionFlag(f);
1466 FlowSetNoPayloadInspectionFlag(f);
1468 if (f->
proto == IPPROTO_TCP) {
1480 if (cur_tx_cnt > p_tx_cnt &&
tv) {
1486 if (consumed != input_len && f->
proto == IPPROTO_TCP && f->
protoctx != NULL) {
1496 if (f->
proto == IPPROTO_TCP) {
1510 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TC and APP_LAYER_PARSER_EOF_TS");
1551 int r = (!alp_ctx.
ctxs[alproto][ipproto_map].
logger) ? 0 : 1;
1568 if (f != NULL && f->
protoctx != NULL)
1594 if (state != NULL) {
1609 uint8_t ipproto,
AppProto alproto,
const char *
name,
const uint8_t direction)
1624 uint8_t ipproto,
AppProto alproto,
const int id,
const uint8_t direction)
1660 if (
ctx->StateFree != NULL && alstate != NULL)
1661 ctx->StateFree(alstate);
1675 static void ValidateParserProtoDump(
AppProto alproto, uint8_t ipproto)
1679 printf(
"ERROR: incomplete app-layer registration\n");
1680 printf(
"AppLayer protocol %s ipproto %u\n",
AppProtoToString(alproto), ipproto);
1681 printf(
"- option flags %"PRIx32
"\n",
ctx->option_flags);
1682 printf(
"- first_data_dir %"PRIx8
"\n",
ctx->first_data_dir);
1683 printf(
"Mandatory:\n");
1684 printf(
"- Parser[0] %p Parser[1] %p\n",
ctx->Parser[0],
ctx->Parser[1]);
1685 printf(
"- StateAlloc %p StateFree %p\n",
ctx->StateAlloc,
ctx->StateFree);
1686 printf(
"- StateGetTx %p StateGetTxCnt %p StateTransactionFree %p\n",
1687 ctx->StateGetTx,
ctx->StateGetTxCnt,
ctx->StateTransactionFree);
1688 printf(
"- GetTxData %p\n",
ctx->GetTxData);
1689 printf(
"- GetStateData %p\n",
ctx->GetStateData);
1690 printf(
"- StateGetProgress %p\n",
ctx->StateGetProgress);
1691 printf(
"Optional:\n");
1692 printf(
"- LocalStorageAlloc %p LocalStorageFree %p\n",
ctx->LocalStorageAlloc,
ctx->LocalStorageFree);
1693 printf(
"- StateGetEventInfo %p StateGetEventInfoById %p\n",
ctx->StateGetEventInfo,
1694 ctx->StateGetEventInfoById);
1697 #define BOTH_SET(a, b) ((a) != NULL && (b) != NULL)
1698 #define BOTH_SET_OR_BOTH_UNSET(a, b) (((a) == NULL && (b) == NULL) || ((a) != NULL && (b) != NULL))
1699 #define THREE_SET(a, b, c) ((a) != NULL && (b) != NULL && (c) != NULL)
1701 static void ValidateParserProto(
AppProto alproto, uint8_t ipproto)
1706 if (
ctx->Parser[0] == NULL &&
ctx->Parser[1] == NULL)
1718 if (
ctx->StateGetProgress == NULL) {
1725 if (
ctx->GetTxData == NULL) {
1728 if (
ctx->GetStateData == NULL) {
1733 ValidateParserProtoDump(alproto, ipproto);
1737 #undef BOTH_SET_OR_BOTH_UNSET
1740 static void ValidateParser(
AppProto alproto)
1742 ValidateParserProto(alproto, IPPROTO_TCP);
1743 ValidateParserProto(alproto, IPPROTO_UDP);
1746 static void ValidateParsers(
void)
1754 #define ARRAY_CAP_STEP 16
1755 static void (**PreRegisteredCallbacks)(void) = NULL;
1756 static size_t preregistered_callbacks_nb = 0;
1757 static size_t preregistered_callbacks_cap = 0;
1767 FatalError(
"Unable to realloc alp_ctx.ctxs.");
1779 if (preregistered_callbacks_nb == preregistered_callbacks_cap) {
1780 void *tmp =
SCRealloc(PreRegisteredCallbacks,
1781 sizeof(
void *) * (preregistered_callbacks_cap +
ARRAY_CAP_STEP));
1786 PreRegisteredCallbacks = tmp;
1788 PreRegisteredCallbacks[preregistered_callbacks_nb] = Register;
1789 preregistered_callbacks_nb++;
1801 SCRegisterDcerpcParser();
1802 SCRegisterDcerpcUdpParser();
1807 SCRegisterDnsUdpParser();
1808 SCRegisterDnsTcpParser();
1809 SCRegisterBittorrentDhtUdpParser();
1811 SCEnipRegisterParsers();
1815 SCRegisterNtpParser();
1818 SCRegisterKrb5Parser();
1819 SCRegisterDhcpParser();
1820 SCRegisterSnmpParser();
1821 SCRegisterSipParser();
1822 SCRegisterQuicParser();
1823 SCRegisterWebSocketParser();
1824 SCRegisterLdapTcpParser();
1825 SCRegisterLdapUdpParser();
1826 SCRegisterMdnsParser();
1827 SCRegisterTemplateParser();
1828 SCRfbRegisterParser();
1829 SCMqttRegisterParser();
1830 SCRegisterPgsqlParser();
1831 SCRegisterPop3Parser();
1832 SCRegisterRdpParser();
1834 SCRegisterTelnetParser();
1837 for (
size_t i = 0; i < preregistered_callbacks_nb; i++) {
1838 PreRegisteredCallbacks[i]();
1848 pstate->
flags |= flag;
1865 void (*RegisterUnittests)(
void))
1882 ctx = &alp_ctx.
ctxs[alproto][ip];
1883 if (
ctx->RegisterUnittests == NULL)
1885 ctx->RegisterUnittests();
#define AppLayerParserHasFilesInDir(txd, direction)
check if tx (possibly) has files in this tx for the direction
void AppLayerParserRegisterGetStateProgressFunc(uint8_t ipproto, AppProto alproto, int(*StateGetProgress)(void *alstate, uint8_t direction))
int AppLayerParserDeSetup(void)
AppLayerStateData *(* GetStateData)(void *state)
uint64_t(* StateGetTxCnt)(void *alstate)
enum ExceptionPolicy g_applayerparser_error_policy
uint16_t SCAppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
int SCConfValIsTrue(const char *val)
Check if a value is true.
AppLayerTxData *(* GetTxData)(void *tx)
void RegisterSMBParsers(void)
void RegisterIKEParsers(void)
int AppLayerParserIsEnabled(AppProto alproto)
simple way to globally test if a alproto is registered and fully enabled in the configuration.
void AppLayerParserRegisterLocalStorageFunc(uint8_t ipproto, AppProto alproto, void *(*LocalStorageAlloc)(void), void(*LocalStorageFree)(void *))
int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto, uint32_t flags)
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
void FramesFree(Frames *frames)
void AppLayerParserSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void *state, uint64_t tx_id, uint8_t flags)
#define APP_LAYER_TX_SKIP_INSPECT_TC
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id)
bool g_filedata_logger_enabled
void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto, void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig config)
void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
remove obsolete (inspected and logged) transactions
void * AppLayerParserGetProtocolParserLocalStorage(uint8_t ipproto, AppProto alproto)
void(* LocalStorageFree)(void *)
App layer protocol parser context.
void RegisterSSHParsers(void)
Function to register the SSH protocol parsers and other functions.
void *(* StateGetTx)(void *alstate, uint64_t tx_id)
#define FLOW_SGH_TOCLIENT
void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate, void *alstate, const uint8_t flags, bool tag_txs_as_inspected)
void SCAppLayerTxDataCleanup(AppLayerTxData *txd)
#define APP_LAYER_PARSER_BYPASS_READY
void(* ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig)
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto, const AppProto alproto)
struct HtpBodyChunk_ * next
DetectEngineState * de_state
void RegisterModbusParsers(void)
Function to register the Modbus protocol parser.
uint8_t AppLayerParserGetTxDetectProgress(AppLayerTxData *txd, const uint8_t dir)
void StreamTcpSetDisableRawReassemblyFlag(TcpSession *, char)
Set the No reassembly flag for the given direction in given TCP session.
FramesContainer * AppLayerFramesSetupContainer(Flow *f)
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
void SCAppLayerParserStateSetFlag(AppLayerParserState *pstate, uint16_t flag)
uint32_t reassembly_depth
AppLayerParserGetStateNameByIdFn GetStateNameById
void AppLayerIncGapErrorCounter(ThreadVars *tv, Flow *f)
#define APP_LAYER_PARSER_INT_STREAM_DEPTH_SET
void SCAppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth)
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
bool AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterStateProgressCompletionStatus(AppProto alproto, const int ts, const int tc)
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto)
int AppLayerParserProtoIsRegistered(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterTxFreeFunc(uint8_t ipproto, AppProto alproto, void(*StateTransactionFree)(void *, uint64_t))
#define FLOW_NOPAYLOAD_INSPECTION
int AppLayerParserGetStateIdByName(uint8_t ipproto, AppProto alproto, const char *name, const uint8_t direction)
void AppLayerParserStateProtoCleanup(uint8_t protomap, AppProto alproto, void *alstate, AppLayerParserState *pstate)
AppLayerGetTxIteratorFunc StateGetTxIterator
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction, const uint32_t progress)
update reassembly progress
void AppLayerParserRegisterGetStateFuncs(uint8_t ipproto, AppProto alproto, AppLayerParserGetStateIdByNameFn GetIdByNameFunc, AppLayerParserGetStateNameByIdFn GetNameByIdFunc)
int SCConfValIsFalse(const char *val)
Check if a value is false.
AppLayerStateData * AppLayerParserGetStateData(uint8_t ipproto, AppProto alproto, void *state)
Frame * AppLayerFrameNewByAbsoluteOffset(Flow *f, const StreamSlice *stream_slice, const uint64_t frame_start, const int64_t len, int dir, uint8_t frame_type)
create new frame using the absolute offset from the start of the stream
Frame * AppLayerFrameGetLastOpenByType(Flow *f, const int dir, const uint8_t frame_type)
TcpStreamCnf stream_config
#define APP_LAYER_PARSER_EOF_TS
void AppLayerIncAllocErrorCounter(ThreadVars *tv, Flow *f)
@ EXCEPTION_POLICY_NOT_SET
enum ExceptionPolicy ExceptionPolicyParse(const char *option, bool support_flow)
void AppLayerParserRegisterUnittests(void)
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction)
void AppLayerParserRegisterApplyTxConfigFunc(uint8_t ipproto, AppProto alproto, void(*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig))
uint8_t flags
STREAM_* flags.
Data structure to store app layer decoder events.
struct AppLayerTxConfig AppLayerTxConfig
uint8_t FlowGetReverseProtoMapping(uint8_t rproto)
void RegisterDNP3Parsers(void)
Register the DNP3 application protocol parser.
int(* StateGetEventInfoById)(uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
void FTPParserCleanup(void)
Free memory allocated for global FTP parser state.
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
const struct SigGroupHead_ * sgh_toserver
void StreamTcpReassembleTriggerRawInspection(TcpSession *ssn, int direction)
Trigger RAW stream inspection.
AppLayerResult(* AppLayerParserFPtr)(Flow *f, void *protocol_state, AppLayerParserState *pstate, StreamSlice stream_slice, void *local_storage)
Prototype for parsing functions.
struct AppLayerParserCtx_ AppLayerParserCtx
AppLayerParserState * alparser
void AppLayerParserRegisterProtocolParsers(void)
void SCAppLayerParserTriggerRawStreamInspection(Flow *f, int direction)
#define APP_LAYER_PARSER_SFRAME_TS
int AppLayerParserGetEventInfoById(uint8_t ipproto, AppProto alproto, uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
AppLayerParserGetFrameIdByNameFn GetFrameIdByName
const char * AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState *pstate, uint8_t direction)
int SCAppLayerParserConfParserEnabled(const char *ipproto, const char *alproto_name)
check if a parser is enabled in the config Returns enabled always if: were running unittests
void AppLayerFramesFreeContainer(Flow *f)
void SCAppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
void AppLayerIncTxCounter(ThreadVars *tv, Flow *f, int64_t step)
void *(* alproto_local_storage)[FLOW_PROTO_MAX]
struct AppLayerGetFileState AppLayerGetFileState
int(* StateGetEventInfo)(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
AppLayerParserThreadCtx * alp_tctx
void SCDetectEngineStateFree(DetectEngineState *state)
Frees a DetectEngineState object.
void AppLayerParserRegisterGetFrameFuncs(uint8_t ipproto, AppProto alproto, AppLayerParserGetFrameIdByNameFn GetIdByNameFunc, AppLayerParserGetFrameNameByIdFn GetNameByIdFunc)
void(* SetStreamDepthFlag)(void *tx, uint8_t flags)
FramesContainer * AppLayerFramesGetContainer(const Flow *f)
Per thread variable structure.
void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits)
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void *(*StateAlloc)(void *, AppProto), void(*StateFree)(void *))
#define APP_LAYER_PARSER_NO_REASSEMBLY
#define IS_DISRUPTED(flags)
void AppLayerParserSetEOF(AppLayerParserState *pstate)
void(* RegisterUnittests)(void)
void AppLayerParserStateFree(AppLayerParserState *pstate)
void AppLayerParserStateCleanup(const Flow *f, void *alstate, AppLayerParserState *pstate)
const struct SigGroupHead_ * sgh_toclient
void RegisterNFSTCPParsers(void)
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfo)(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type))
AppLayerParserGetFrameNameByIdFn GetFrameNameById
struct AppLayerParserProtoCtx_ AppLayerParserProtoCtx
App layer protocol parser context.
int AppLayerParserSetup(void)
void RegisterFTPParsers(void)
void AppLayerParserRegisterProtocolUnittests(uint8_t ipproto, AppProto alproto, void(*RegisterUnittests)(void))
void *(* StateAlloc)(void *, AppProto)
uint8_t FlowGetProtoMapping(uint8_t proto)
Function to map the protocol to the defined FLOW_PROTO_* enumeration.
void RegisterTFTPParsers(void)
#define FLOW_PROTO_APPLAYER_MAX
#define APP_LAYER_PARSER_EOF_TC
#define DEBUG_ASSERT_FLOW_LOCKED(f)
#define BOTH_SET_OR_BOTH_UNSET(a, b)
#define SCReturnPtr(x, type)
void(* StateFree)(void *)
void AppLayerParserRegisterGetTxFilesFunc(uint8_t ipproto, AppProto alproto, AppLayerGetFileState(*GetTxFiles)(void *, uint8_t))
void AppLayerParserRegisterSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void(*SetStreamDepthFlag)(void *tx, uint8_t flags))
#define APP_LAYER_PARSER_SFRAME_TC
void AppLayerIncParserErrorCounter(ThreadVars *tv, Flow *f)
uint8_t detect_progress_ts
uint32_t logged
logger flags for tx logging api
int RunmodeIsUnittests(void)
#define APP_LAYER_PARSER_NO_INSPECTION
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto, uint8_t direction, AppLayerParserFPtr Parser)
Register app layer parser for the protocol.
#define SCRealloc(ptr, sz)
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
void AppLayerParserRegisterGetTx(uint8_t ipproto, AppProto alproto, void *(StateGetTx)(void *alstate, uint64_t tx_id))
enum ExceptionPolicy AppLayerErrorGetExceptionPolicy(void)
AppLayerParserFPtr Parser[2]
void(* StateTransactionFree)(void *, uint64_t)
int AppLayerParserPreRegister(void(*Register)(void))
void RegisterSSLParsers(void)
Function to register the SSL protocol parser and other functions.
void StreamTcpSetSessionNoReassemblyFlag(TcpSession *, char)
disable reassembly
void SCGenericVarFree(GenericVar *gv)
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
const char *(* AppLayerParserGetFrameNameByIdFn)(const uint8_t id)
void StreamTcpDisableAppLayer(Flow *f)
AppLayerParserProtoCtx(* ctxs)[FLOW_PROTO_MAX]
int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name)
void SCAppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, AppProto alproto, uint8_t direction)
uint32_t files_opened
track file open/logs so we can know how long to keep the tx
void AppLayerParserRegisterStateDataFunc(uint8_t ipproto, AppProto alproto, AppLayerStateData *(*GetStateData)(void *state))
void FilesPrune(FileContainer *fc, const StreamingBufferConfig *sbcfg, const bool trunc)
void AppLayerIncInternalErrorCounter(ThreadVars *tv, Flow *f)
const char *(* AppLayerParserGetStateNameByIdFn)(const int id, const uint8_t direction)
AppLayerTxData * AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto, AppLayerTxData *(*GetTxData)(void *tx))
uint8_t detect_progress_tc
void SCAppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events)
uint32_t AppLayerParserGetStreamDepth(const Flow *f)
void RegisterIMAPParsers(void)
AppLayerGetFileState(* GetTxFiles)(void *, uint8_t)
AppLayerParserGetStateIdByNameFn GetStateIdByName
const StreamingBufferConfig * cfg
#define FRAME_STREAM_TYPE
#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS
#define APP_LAYER_TX_INSPECTED_TS
void AppLayerParserRegisterGetTxIterator(uint8_t ipproto, AppProto alproto, AppLayerGetTxIteratorFunc Func)
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
#define SCLogError(...)
Macro used to log ERROR messages.
#define FLOW_SGH_TOSERVER
void AppLayerParserPostStreamSetup(void)
AppLayerDecoderEvents * AppLayerParserGetDecoderEvents(AppLayerParserState *pstate)
#define THREE_SET(a, b, c)
const char * AppLayerGetProtoName(AppProto alproto)
Given the internal protocol id, returns a string representation of the protocol.
void UTHAppLayerParserStateGetIds(void *ptr, uint64_t *i1, uint64_t *i2, uint64_t *log, uint64_t *min)
void RegisterHTPParsers(void)
Register the HTTP protocol and state handling functions to APP layer of the engine.
int(* AppLayerParserGetStateIdByNameFn)(const char *name, const uint8_t direction)
#define FRAME_FLAG_ENDS_AT_EOF
void RegisterSMTPParsers(void)
Register the SMTP Protocol parser.
AppLayerParserState * AppLayerParserStateAlloc(void)
#define SCReturnCT(x, type)
AppLayerDecoderEvents * decoder_events
void AppLayerParserRegisterGetTxCnt(uint8_t ipproto, AppProto alproto, uint64_t(*StateGetTxCnt)(void *alstate))
int(* StateGetProgress)(void *alstate, uint8_t direction)
LoggerId AppLayerParserProtocolGetLoggerBits(uint8_t ipproto, AppProto alproto)
AppLayerDecoderEvents * events
void AppLayerParserRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfoById)(uint8_t event_id, const char **event_name, AppLayerEventType *event_type))
AppLayerGetTxIterTuple(* AppLayerGetTxIteratorFunc)(const uint8_t ipproto, const AppProto alproto, void *alstate, uint64_t min_tx_id, uint64_t max_tx_id, AppLayerGetTxIterState *state)
tx iterator prototype
bool g_file_logger_enabled
void RegisterHTTP2Parsers(void)
#define STREAM_APP_PROGRESS(stream)
#define APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD
int FlowChangeProto(Flow *f)
Check if change proto flag is set for flow.
uint8_t FlowGetDisruptionFlags(const Flow *f, uint8_t flags)
get 'disruption' flags: GAP/DEPTH/PASS
int SCAppLayerParserReallocCtx(AppProto alproto)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
void RegisterNFSUDPParsers(void)
uint64_t AppLayerParserGetMinId(AppLayerParserState *pstate)
AppProto alproto
application level protocol
void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto alproto, void *local_data)
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
void SMTPParserCleanup(void)
Free memory allocated for global SMTP parser state.
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
int(* AppLayerParserGetFrameIdByNameFn)(const char *frame_name)
void StreamTcpSetSessionBypassFlag(TcpSession *)
enable bypass
#define DEBUG_VALIDATE_BUG_ON(exp)
#define APP_LAYER_TX_INSPECTED_TC
void *(* LocalStorageAlloc)(void)
int AppLayerParserGetEventInfo(uint8_t ipproto, AppProto alproto, const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
#define APP_LAYER_TX_SKIP_INSPECT_TS