85 void *(*LocalStorageAlloc)(void);
94 void *(*StateGetTx)(
void *alstate, uint64_t tx_id);
157static 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 *))
445 FatalError(
"Unable to realloc alp_ctx.ctxs.");
461 void *(*LocalStorageAlloc)(
void),
462 void (*LocalStorageFree)(
void *))
501 int (*StateGetProgress)(
void *alstate, uint8_t direction))
511 void (*StateTransactionFree)(
void *, uint64_t))
521 uint64_t (*StateGetTxCnt)(
void *alstate))
531 void *(StateGetTx)(
void *alstate, uint64_t tx_id))
553 BUG_ON(!AppProtoIsValid(alproto));
564 int (*StateGetEventInfoById)(
570 StateGetEventInfoById;
596 int (*StateGetEventInfo)(
637 void (*SetStreamDepthFlag)(
void *tx, uint8_t
flags))
681 const uint8_t ipproto,
const AppProto alproto,
682 void *alstate, uint64_t min_tx_id, uint64_t max_tx_id,
685 uint64_t ustate = *(uint64_t *)state;
686 uint64_t tx_id =
MAX(min_tx_id, ustate);
687 for ( ; tx_id < max_tx_id; tx_id++) {
689 if (tx_ptr != NULL) {
695 .has_next = (tx_id + 1 < max_tx_id),
697 SCLogDebug(
"tuple: %p/%"PRIu64
"/%s", tuple.tx_ptr, tuple.tx_id,
698 tuple.has_next ?
"true" :
"false");
712 return Func ? Func : AppLayerDefaultGetTxIterator;
745 uint8_t p = (dir & STREAM_TOSERVER) ? txd->detect_progress_ts : txd->detect_progress_tc;
751 return txd->logged.flags;
755 void *alstate,
const uint8_t
flags,
756 bool tag_txs_as_inspected)
760 const int direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
764 const uint8_t ipproto = f->
proto;
770 SCLogDebug(
"called: %s, tag_txs_as_inspected %s",direction==0?
"toserver":
"toclient",
771 tag_txs_as_inspected?
"true":
"false");
777 if (ires.tx_ptr == NULL)
780 void *tx = ires.tx_ptr;
784 if (state_progress < state_done_progress)
788 if (tag_txs_as_inspected) {
791 if (txd->flags & inspected_flag) {
792 txd->flags |= inspected_flag;
793 SCLogDebug(
"%p/%" PRIu64
" in-order tx is done for direction %s. Flags %02x", tx,
794 idx,
flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->flags);
806 if (tag_txs_as_inspected) {
810 if (ires.tx_ptr == NULL)
813 void *tx = ires.tx_ptr;
817 if (ires.tx_id > idx && pstate->
inspect_id[direction] == idx) {
823 if (state_progress < state_done_progress)
830 if (txd->flags & inspected_flag) {
831 txd->flags |= inspected_flag;
832 SCLogDebug(
"%p/%" PRIu64
" out of order tx is done for direction %s. Flag %02x", tx,
833 idx,
flags & STREAM_TOSERVER ?
"toserver" :
"toclient", txd->flags);
835 SCLogDebug(
"%p/%" PRIu64
" out of order tx. Update inspect_id? %" PRIu64, tx, idx,
854 "AppLayerDecoderEvents *");
866 if (txd->events != NULL) {
885static void AppLayerParserFileTxHousekeeping(
886 const Flow *f,
void *tx,
const uint8_t pkt_dir,
const bool trunc)
894#define IS_DISRUPTED(flags) ((flags) & (STREAM_DEPTH | STREAM_GAP))
913 const uint8_t ipproto = f->
proto;
915 void *
const alstate = f->
alstate;
918 if (alstate == NULL || alparser == NULL)
921 const uint64_t min = alparser->
min_id;
929 int pkt_dir_trunc = -1;
933 memset(&state, 0,
sizeof(state));
935 uint64_t new_min = min;
937 bool skipped =
false;
942 if (ires.tx_ptr == NULL)
945 bool tx_skipped =
false;
946 void *tx = ires.tx_ptr;
952 if (pkt_dir_trunc == -1)
954 (pkt_dir == STREAM_TOSERVER) ? ts_disrupt_flags : tc_disrupt_flags);
955 AppLayerParserFileTxHousekeeping(f, tx, pkt_dir, (
bool)pkt_dir_trunc);
958 if (pkt_dir & STREAM_TOSERVER) {
959 txd->updated_ts =
false;
961 txd->updated_tc =
false;
963 const int tx_progress_tc =
965 if (tx_progress_tc < tx_end_state_tc) {
966 SCLogDebug(
"%p/%"PRIu64
" skipping: tc parser not done", tx, i);
970 const int tx_progress_ts =
972 if (tx_progress_ts < tx_end_state_ts) {
973 SCLogDebug(
"%p/%"PRIu64
" skipping: ts parser not done", tx, i);
978 if (has_tx_detect_flags) {
983 SCLogDebug(
"%p/%" PRIu64
" skipping: TS inspect not done: ts:%02x", tx, i,
992 SCLogDebug(
"%p/%" PRIu64
" skipping: TC inspect not done: ts:%02x", tx, i,
1000 SCLogDebug(
"%p/%" PRIu64
" tx_skipped", tx, i);
1005 if (logger_expectation != 0) {
1006 LoggerId tx_logged = GetTxLogged(txd);
1007 if (tx_logged != logger_expectation) {
1008 SCLogDebug(
"%p/%"PRIu64
" skipping: logging not done: want:%"PRIx32
", have:%"PRIx32,
1009 tx, i, logger_expectation, tx_logged);
1017 SCLogDebug(
"files_opened %u files_logged %u files_stored %u", txd->files_opened,
1018 txd->files_logged, txd->files_stored);
1020 if (txd->files_opened) {
1036 SCLogDebug(
"skipped? %s i %"PRIu64
", new_min %"PRIu64, skipped ?
"true" :
"false", i, new_min);
1039 SCLogDebug(
"final i %"PRIu64
", new_min %"PRIu64, i, new_min);
1042 if (!ires.has_next) {
1046 SCLogDebug(
"no next: cur tx i %"PRIu64
", total %"PRIu64, i, total_txs);
1048 new_min = total_txs;
1049 SCLogDebug(
"no next: cur tx i %"PRIu64
", total %"PRIu64
": "
1050 "new_min updated to %"PRIu64, i, total_txs, new_min);
1058 SCLogDebug(
"update f->alparser->min_id? %"PRIu64
" vs %"PRIu64, new_min, alparser->
min_id);
1059 if (new_min > alparser->
min_id) {
1060 const uint64_t next_id = new_min;
1061 alparser->
min_id = next_id;
1070static inline int StateGetProgressCompletionStatus(
const AppProto alproto,
const uint8_t
flags)
1072 if (
flags & STREAM_TOSERVER) {
1074 }
else if (
flags & STREAM_TOCLIENT) {
1088 void *alstate, uint8_t
flags)
1093 r = StateGetProgressCompletionStatus(alproto,
flags);
1095 uint8_t direction =
flags & (STREAM_TOCLIENT | STREAM_TOSERVER);
1097 alstate, direction);
1120 int r = StateGetProgressCompletionStatus(alproto, direction);
1132 event_name, event_id, event_type);
1141 *event_name = (
const char *)NULL;
1145 event_id, event_name, event_type);
1216 if ((
flags & (STREAM_EOF|STREAM_TOSERVER)) == (STREAM_EOF|STREAM_TOSERVER)) {
1217 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TS");
1219 }
else if ((
flags & (STREAM_EOF|STREAM_TOCLIENT)) == (STREAM_EOF|STREAM_TOCLIENT)) {
1220 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TC");
1229static void HandleStreamFrames(
Flow *f,
StreamSlice stream_slice,
const uint8_t *input,
1230 const uint32_t input_len,
const uint8_t
flags)
1232 const uint8_t direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
1238 input != NULL && f->
proto == IPPROTO_TCP) {
1240 if (frame == NULL) {
1241 int64_t frame_len = -1;
1242 if (
flags & STREAM_EOF)
1243 frame_len = input_len;
1246 f, &stream_slice, stream_slice.offset, frame_len, direction,
FRAME_STREAM_TYPE);
1248 SCLogDebug(
"opened: frame %p id %" PRIi64, frame, frame->
id);
1253 if (direction == 0) {
1259 }
else if (
flags & STREAM_EOF) {
1264 int64_t slice_o = (int64_t)stream_slice.offset - (int64_t)frame->
offset;
1265 int64_t frame_len = slice_o + (int64_t)input_len;
1266 SCLogDebug(
"%s: EOF frame->offset %" PRIu64
" -> %" PRIi64
": o %" PRIi64,
1268 frame->
len = frame_len;
1273static void Setup(
Flow *f,
const uint8_t direction,
const uint8_t *input, uint32_t input_len,
1276 memset(as, 0,
sizeof(*as));
1278 as->input_len = input_len;
1283 TcpStream *stream = (direction & STREAM_TOSERVER) ? &ssn->
client : &ssn->server;
1292 uint8_t
flags,
const uint8_t *input, uint32_t input_len)
1295#ifdef DEBUG_VALIDATION
1301 void *alstate = NULL;
1302 uint64_t p_tx_cnt = 0;
1303 uint32_t consumed = input_len;
1304 const uint8_t direction = (
flags & STREAM_TOSERVER) ? 0 : 1;
1308 if (f->
proto == IPPROTO_TCP) {
1314 if (
flags & STREAM_GAP) {
1316 SCLogDebug(
"app-layer parser does not accept gaps");
1326 if (pstate == NULL) {
1328 if (pstate == NULL) {
1334 SetEOFFlags(pstate,
flags);
1339 if (alstate == NULL) {
1343 SCLogDebug(
"alloced new app layer state %p (name %s)",
1351 SCLogDebug(
"state data: updating file_flags %04x with flow file_flags %04x",
1358 SCLogDebug(
"using existing app layer state %p (name %s))",
1365 if (input_len > 0 || (
flags & STREAM_EOF)) {
1366 Setup(f,
flags & (STREAM_TOSERVER | STREAM_TOCLIENT), input, input_len,
flags,
1368 HandleStreamFrames(f, stream_slice, input, input_len,
flags);
1371 if (((stream_slice.flags & STREAM_TOSERVER) &&
1372 stream_slice.offset >= g_eps_applayer_error_offset_ts)) {
1373 SCLogNotice(
"putting parser %s into an error state from toserver offset %" PRIu64,
1378 if (((stream_slice.flags & STREAM_TOCLIENT) &&
1379 stream_slice.offset >= g_eps_applayer_error_offset_tc)) {
1380 SCLogNotice(
"putting parser %s into an error state from toclient offset %" PRIu64,
1389 if (res.status < 0) {
1392 }
else if (res.status > 0) {
1401 if (res.consumed > input_len || res.needed + res.consumed < input_len) {
1409 (
flags & STREAM_TOSERVER) ?
"toserver" :
"toclient");
1410 if (direction == 0) {
1424 consumed = res.consumed;
1432 if (f->
proto == IPPROTO_TCP) {
1454 FlowSetNoPayloadInspectionFlag(f);
1460 FlowSetNoPayloadInspectionFlag(f);
1462 if (f->
proto == IPPROTO_TCP) {
1474 if (cur_tx_cnt > p_tx_cnt &&
tv) {
1480 if (consumed != input_len && f->
proto == IPPROTO_TCP && f->
protoctx != NULL) {
1490 if (f->
proto == IPPROTO_TCP) {
1504 SCLogDebug(
"setting APP_LAYER_PARSER_EOF_TC and APP_LAYER_PARSER_EOF_TS");
1545 int r = (!alp_ctx.
ctxs[alproto][ipproto_map].
logger) ? 0 : 1;
1562 if (f != NULL && f->
protoctx != NULL)
1588 if (state != NULL) {
1603 uint8_t ipproto,
AppProto alproto,
const char *
name,
const uint8_t direction)
1618 uint8_t ipproto,
AppProto alproto,
const int id,
const uint8_t direction)
1654 if (
ctx->StateFree != NULL && alstate != NULL)
1655 ctx->StateFree(alstate);
1669static void ValidateParserProtoDump(
AppProto alproto, uint8_t ipproto)
1673 printf(
"ERROR: incomplete app-layer registration\n");
1674 printf(
"AppLayer protocol %s ipproto %u\n",
AppProtoToString(alproto), ipproto);
1675 printf(
"- option flags %"PRIx32
"\n",
ctx->option_flags);
1676 printf(
"- first_data_dir %"PRIx8
"\n",
ctx->first_data_dir);
1677 printf(
"Mandatory:\n");
1678 printf(
"- Parser[0] %p Parser[1] %p\n",
ctx->Parser[0],
ctx->Parser[1]);
1679 printf(
"- StateAlloc %p StateFree %p\n",
ctx->StateAlloc,
ctx->StateFree);
1680 printf(
"- StateGetTx %p StateGetTxCnt %p StateTransactionFree %p\n",
1681 ctx->StateGetTx,
ctx->StateGetTxCnt,
ctx->StateTransactionFree);
1682 printf(
"- GetTxData %p\n",
ctx->GetTxData);
1683 printf(
"- GetStateData %p\n",
ctx->GetStateData);
1684 printf(
"- StateGetProgress %p\n",
ctx->StateGetProgress);
1685 printf(
"Optional:\n");
1686 printf(
"- LocalStorageAlloc %p LocalStorageFree %p\n",
ctx->LocalStorageAlloc,
ctx->LocalStorageFree);
1687 printf(
"- StateGetEventInfo %p StateGetEventInfoById %p\n",
ctx->StateGetEventInfo,
1688 ctx->StateGetEventInfoById);
1691#define BOTH_SET(a, b) ((a) != NULL && (b) != NULL)
1692#define BOTH_SET_OR_BOTH_UNSET(a, b) (((a) == NULL && (b) == NULL) || ((a) != NULL && (b) != NULL))
1693#define THREE_SET(a, b, c) ((a) != NULL && (b) != NULL && (c) != NULL)
1695static void ValidateParserProto(
AppProto alproto, uint8_t ipproto)
1700 if (
ctx->Parser[0] == NULL &&
ctx->Parser[1] == NULL)
1712 if (
ctx->StateGetProgress == NULL) {
1719 if (
ctx->GetTxData == NULL) {
1722 if (
ctx->GetStateData == NULL) {
1727 ValidateParserProtoDump(alproto, ipproto);
1731#undef BOTH_SET_OR_BOTH_UNSET
1734static void ValidateParser(
AppProto alproto)
1736 ValidateParserProto(alproto, IPPROTO_TCP);
1737 ValidateParserProto(alproto, IPPROTO_UDP);
1740static void ValidateParsers(
void)
1748#define ARRAY_CAP_STEP 16
1749static void (**PreRegisteredCallbacks)(void) = NULL;
1750static size_t preregistered_callbacks_nb = 0;
1751static size_t preregistered_callbacks_cap = 0;
1755 if (preregistered_callbacks_nb == preregistered_callbacks_cap) {
1756 void *tmp =
SCRealloc(PreRegisteredCallbacks,
1757 sizeof(
void *) * (preregistered_callbacks_cap +
ARRAY_CAP_STEP));
1762 PreRegisteredCallbacks = tmp;
1764 PreRegisteredCallbacks[preregistered_callbacks_nb] = Register;
1765 preregistered_callbacks_nb++;
1777 SCRegisterDcerpcParser();
1778 SCRegisterDcerpcUdpParser();
1783 SCRegisterDnsUdpParser();
1784 SCRegisterDnsTcpParser();
1785 SCRegisterBittorrentDhtUdpParser();
1787 SCEnipRegisterParsers();
1791 SCRegisterNtpParser();
1794 SCRegisterKrb5Parser();
1795 SCRegisterDhcpParser();
1796 SCRegisterSnmpParser();
1797 SCRegisterSipParser();
1798 SCRegisterQuicParser();
1799 SCRegisterWebSocketParser();
1800 SCRegisterLdapTcpParser();
1801 SCRegisterLdapUdpParser();
1802 SCRegisterMdnsParser();
1803 SCRegisterTemplateParser();
1804 SCRfbRegisterParser();
1805 SCMqttRegisterParser();
1806 SCRegisterPgsqlParser();
1807 SCRegisterPop3Parser();
1808 SCRegisterRdpParser();
1810 SCRegisterTelnetParser();
1813 for (
size_t i = 0; i < preregistered_callbacks_nb; i++) {
1814 PreRegisteredCallbacks[i]();
1824 pstate->
flags |= flag;
1841 void (*RegisterUnittests)(
void))
1858 ctx = &alp_ctx.
ctxs[alproto][ip];
1859 if (
ctx->RegisterUnittests == NULL)
1861 ctx->RegisterUnittests();
void RegisterDNP3Parsers(void)
Register the DNP3 application protocol parser.
void AppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events)
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)
void FramesFree(Frames *frames)
#define FRAME_STREAM_TYPE
#define FRAME_FLAG_ENDS_AT_EOF
void RegisterFTPParsers(void)
void FTPParserCleanup(void)
Free memory allocated for global FTP parser state.
struct HtpBodyChunk_ * next
void RegisterHTTP2Parsers(void)
void RegisterIKEParsers(void)
void RegisterIMAPParsers(void)
void RegisterModbusParsers(void)
Function to register the Modbus protocol parser.
void RegisterNFSTCPParsers(void)
void RegisterNFSUDPParsers(void)
int AppLayerParserGetEventInfo(uint8_t ipproto, AppProto alproto, const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState *pstate, uint8_t direction)
int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name)
int AppLayerParserIsEnabled(AppProto alproto)
simple way to globally test if a alproto is registered and fully enabled in the configuration.
AppLayerTxData * AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
enum ExceptionPolicy g_applayerparser_error_policy
void AppLayerParserRegisterGetTxCnt(uint8_t ipproto, AppProto alproto, uint64_t(*StateGetTxCnt)(void *alstate))
void AppLayerParserRegisterTxFreeFunc(uint8_t ipproto, AppProto alproto, void(*StateTransactionFree)(void *, uint64_t))
uint16_t SCAppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
AppLayerGetFileState AppLayerParserGetTxFiles(const Flow *f, void *tx, const uint8_t direction)
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
void AppLayerParserRegisterProtocolUnittests(uint8_t ipproto, AppProto alproto, void(*RegisterUnittests)(void))
int AppLayerParserGetStateIdByName(uint8_t ipproto, AppProto alproto, const char *name, const uint8_t direction)
void AppLayerParserStateFree(AppLayerParserState *pstate)
void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto, AppLayerTxData *(*GetTxData)(void *tx))
uint8_t AppLayerParserGetTxDetectProgress(AppLayerTxData *txd, const uint8_t dir)
FramesContainer * AppLayerFramesSetupContainer(Flow *f)
AppLayerStateData * AppLayerParserGetStateData(uint8_t ipproto, AppProto alproto, void *state)
void AppLayerParserTriggerRawStreamInspection(Flow *f, int direction)
void AppLayerParserSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void *state, uint64_t tx_id, uint8_t flags)
void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto, uint32_t flags)
void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
remove obsolete (inspected and logged) transactions
#define THREE_SET(a, b, c)
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
bool g_filedata_logger_enabled
const char * AppLayerParserGetFrameNameById(uint8_t ipproto, AppProto alproto, const uint8_t id)
FramesContainer * AppLayerFramesGetContainer(Flow *f)
uint32_t AppLayerParserGetStreamDepth(const Flow *f)
void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto alproto, void *local_data)
uint64_t AppLayerParserGetTxCnt(const Flow *f, void *alstate)
void AppLayerParserRegisterStateProgressCompletionStatus(AppProto alproto, const int ts, const int tc)
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
void AppLayerParserRegisterSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void(*SetStreamDepthFlag)(void *tx, uint8_t flags))
bool AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto)
AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto, const AppProto alproto)
void SCAppLayerParserStateSetFlag(AppLayerParserState *pstate, uint16_t flag)
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction)
void AppLayerParserRegisterApplyTxConfigFunc(uint8_t ipproto, AppProto alproto, bool(*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig))
int AppLayerParserPreRegister(void(*Register)(void))
void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits)
void AppLayerParserRegisterGetTxFilesFunc(uint8_t ipproto, AppProto alproto, AppLayerGetFileState(*GetTxFiles)(void *, uint8_t))
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id)
bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
void AppLayerFramesFreeContainer(Flow *f)
struct AppLayerParserProtoCtx_ AppLayerParserProtoCtx
App layer protocol parser context.
int AppLayerParserProtoIsRegistered(uint8_t ipproto, AppProto alproto)
uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterStateDataFunc(uint8_t ipproto, AppProto alproto, AppLayerStateData *(*GetStateData)(void *state))
void * AppLayerParserGetTx(uint8_t ipproto, AppProto alproto, void *alstate, uint64_t tx_id)
void AppLayerParserPostStreamSetup(void)
void AppLayerParserRegisterGetTxIterator(uint8_t ipproto, AppProto alproto, AppLayerGetTxIteratorFunc Func)
void AppLayerParserRegisterLocalStorageFunc(uint8_t ipproto, AppProto alproto, void *(*LocalStorageAlloc)(void), void(*LocalStorageFree)(void *))
int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto, uint8_t direction, AppLayerParserFPtr Parser)
Register app layer parser for the protocol.
const char * AppLayerParserGetStateNameById(uint8_t ipproto, AppProto alproto, const int id, const uint8_t direction)
void AppLayerParserStateCleanup(const Flow *f, void *alstate, AppLayerParserState *pstate)
AppLayerDecoderEvents * AppLayerParserGetDecoderEvents(AppLayerParserState *pstate)
int AppLayerParserDeSetup(void)
void UTHAppLayerParserStateGetIds(void *ptr, uint64_t *i1, uint64_t *i2, uint64_t *log, uint64_t *min)
void AppLayerParserRegisterGetTx(uint8_t ipproto, AppProto alproto, void *(StateGetTx)(void *alstate, uint64_t tx_id))
void * AppLayerParserGetProtocolParserLocalStorage(uint8_t ipproto, AppProto alproto)
AppLayerParserState * AppLayerParserStateAlloc(void)
int AppLayerParserGetEventInfoById(uint8_t ipproto, AppProto alproto, uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
struct AppLayerParserCtx_ AppLayerParserCtx
void AppLayerParserSetEOF(AppLayerParserState *pstate)
void SCAppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfo)(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type))
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
void AppLayerParserRegisterGetStateProgressFunc(uint8_t ipproto, AppProto alproto, int(*StateGetProgress)(void *alstate, uint8_t direction))
void SCAppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, AppProto alproto, 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 AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate, void *alstate, const uint8_t flags, bool tag_txs_as_inspected)
void AppLayerParserRegisterUnittests(void)
void SCAppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth)
void AppLayerParserStateProtoCleanup(uint8_t protomap, AppProto alproto, void *alstate, AppLayerParserState *pstate)
bool g_file_logger_enabled
void AppLayerParserRegisterProtocolParsers(void)
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void *(*StateAlloc)(void *, AppProto), void(*StateFree)(void *))
void AppLayerParserRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto, int(*StateGetEventInfoById)(uint8_t event_id, const char **event_name, AppLayerEventType *event_type))
void AppLayerParserRegisterGetStateFuncs(uint8_t ipproto, AppProto alproto, AppLayerParserGetStateIdByNameFn GetIdByNameFunc, AppLayerParserGetStateNameByIdFn GetNameByIdFunc)
void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto, void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig config)
int AppLayerParserSetup(void)
#define IS_DISRUPTED(flags)
void AppLayerParserRegisterGetFrameFuncs(uint8_t ipproto, AppProto alproto, AppLayerParserGetFrameIdByNameFn GetIdByNameFunc, AppLayerParserGetFrameNameByIdFn GetNameByIdFunc)
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
LoggerId AppLayerParserProtocolGetLoggerBits(uint8_t ipproto, AppProto alproto)
enum ExceptionPolicy AppLayerErrorGetExceptionPolicy(void)
uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate)
#define BOTH_SET_OR_BOTH_UNSET(a, b)
int(* AppLayerParserGetStateIdByNameFn)(const char *name, const uint8_t direction)
#define APP_LAYER_PARSER_INT_STREAM_DEPTH_SET
struct AppLayerGetFileState AppLayerGetFileState
#define APP_LAYER_TX_INSPECTED_TC
struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple
#define APP_LAYER_PARSER_NO_REASSEMBLY
#define APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD
#define APP_LAYER_PARSER_SFRAME_TS
#define APP_LAYER_PARSER_NO_INSPECTION
const char *(* AppLayerParserGetStateNameByIdFn)(const int id, const uint8_t direction)
AppLayerResult(* AppLayerParserFPtr)(Flow *f, void *protocol_state, AppLayerParserState *pstate, StreamSlice stream_slice, void *local_storage)
Prototype for parsing functions.
#define APP_LAYER_PARSER_BYPASS_READY
struct AppLayerTxData AppLayerTxData
const char *(* AppLayerParserGetFrameNameByIdFn)(const uint8_t id)
#define APP_LAYER_TX_SKIP_INSPECT_TC
int(* AppLayerParserGetFrameIdByNameFn)(const char *frame_name)
#define AppLayerParserHasFilesInDir(txd, direction)
check if tx (possibly) has files in this tx for the direction
#define APP_LAYER_TX_SKIP_INSPECT_TS
#define APP_LAYER_PARSER_EOF_TC
#define APP_LAYER_TX_INSPECTED_TS
#define APP_LAYER_PARSER_SFRAME_TC
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
struct AppLayerTxConfig AppLayerTxConfig
struct AppLayerResult AppLayerResult
#define APP_LAYER_PARSER_EOF_TS
#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS
struct StreamSlice StreamSlice
struct AppLayerStateData AppLayerStateData
enum AppLayerEventType AppLayerEventType
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
void RegisterSMBParsers(void)
void SMTPParserCleanup(void)
Free memory allocated for global SMTP parser state.
void RegisterSMTPParsers(void)
Register the SMTP Protocol parser.
void RegisterSSHParsers(void)
Function to register the SSH protocol parsers and other functions.
void RegisterSSLParsers(void)
Function to register the SSL protocol parser and other functions.
void RegisterTFTPParsers(void)
void AppLayerIncInternalErrorCounter(ThreadVars *tv, Flow *f)
void AppLayerIncAllocErrorCounter(ThreadVars *tv, Flow *f)
const char * AppLayerGetProtoName(AppProto alproto)
Given the internal protocol id, returns a string representation of the protocol.
void AppLayerIncGapErrorCounter(ThreadVars *tv, Flow *f)
void AppLayerIncParserErrorCounter(ThreadVars *tv, Flow *f)
void AppLayerIncTxCounter(ThreadVars *tv, Flow *f, uint64_t step)
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
int SCConfValIsTrue(const char *val)
Check if a value is true.
int SCConfValIsFalse(const char *val)
Check if a value is false.
TcpStreamCnf stream_config
#define FLOW_PROTO_APPLAYER_MAX
uint8_t FlowGetReverseProtoMapping(uint8_t rproto)
uint8_t FlowGetProtoMapping(uint8_t proto)
Function to map the protocol to the defined FLOW_PROTO_* enumeration.
uint8_t FlowGetDisruptionFlags(const Flow *f, uint8_t flags)
get 'disruption' flags: GAP/DEPTH/PASS
int FlowChangeProto(Flow *f)
Check if change proto flag is set for flow.
#define FLOW_SGH_TOCLIENT
#define FLOW_NOPAYLOAD_INSPECTION
#define FLOW_SGH_TOSERVER
AppLayerParserThreadCtx * alp_tctx
void RegisterHTPParsers(void)
Register the HTTP protocol and state handling functions to APP layer of the engine.
#define STREAM_APP_PROGRESS(stream)
void StreamTcpReassembleTriggerRawInspection(TcpSession *ssn, int direction)
Trigger RAW stream inspection.
void StreamTcpDisableAppLayer(Flow *f)
void StreamTcpSetSessionBypassFlag(TcpSession *)
enable bypass
void StreamTcpSetSessionNoReassemblyFlag(TcpSession *, char)
disable reassembly
void StreamTcpSetDisableRawReassemblyFlag(TcpSession *, char)
Set the No reassembly flag for the given direction in given TCP session.
void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction, const uint32_t progress)
update reassembly progress
Data structure to store app layer decoder events.
AppLayerParserProtoCtx(* ctxs)[FLOW_PROTO_MAX]
App layer protocol parser context.
AppLayerParserGetFrameIdByNameFn GetFrameIdByName
int(* StateGetEventInfo)(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
AppLayerGetFileState(* GetTxFiles)(void *, uint8_t)
void(* SetStreamDepthFlag)(void *tx, uint8_t flags)
AppLayerParserGetFrameNameByIdFn GetFrameNameById
void(* RegisterUnittests)(void)
void *(* StateGetTx)(void *alstate, uint64_t tx_id)
int(* StateGetProgress)(void *alstate, uint8_t direction)
void(* LocalStorageFree)(void *)
AppLayerStateData *(* GetStateData)(void *state)
AppLayerGetTxIteratorFunc StateGetTxIterator
void *(* StateAlloc)(void *, AppProto)
int(* StateGetEventInfoById)(uint8_t event_id, const char **event_name, AppLayerEventType *event_type)
AppLayerTxData *(* GetTxData)(void *tx)
AppLayerParserGetStateNameByIdFn GetStateNameById
AppLayerParserGetStateIdByNameFn GetStateIdByName
void(* StateFree)(void *)
void *(* LocalStorageAlloc)(void)
bool(* ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig)
AppLayerParserFPtr Parser[2]
uint64_t(* StateGetTxCnt)(void *alstate)
void(* StateTransactionFree)(void *, uint64_t)
AppLayerDecoderEvents * decoder_events
void *(* alproto_local_storage)[FLOW_PROTO_MAX]
const struct SigGroupHead_ * sgh_toclient
AppProto alproto
application level protocol
const struct SigGroupHead_ * sgh_toserver
AppLayerParserState * alparser
uint32_t reassembly_depth
Per thread variable structure.
int RunmodeIsUnittests(void)
#define SCReturnCT(x, type)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
#define SCReturnPtr(x, type)
#define SCLogError(...)
Macro used to log ERROR messages.
@ EXCEPTION_POLICY_NOT_SET
enum ExceptionPolicy ExceptionPolicyParse(const char *option, bool support_flow)
void FilesPrune(FileContainer *fc, const StreamingBufferConfig *sbcfg, const bool trunc)
#define SCRealloc(ptr, sz)
#define DEBUG_VALIDATE_BUG_ON(exp)
#define DEBUG_ASSERT_FLOW_LOCKED(f)