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 *))
 
  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) {
 
  885 static 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;
 
 1070 static 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");
 
 1229 static 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;
 
 1273 static 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;
 
 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);
 
 1669 static 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) 
 1695 static 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 
 1734 static void ValidateParser(
AppProto alproto)
 
 1736     ValidateParserProto(alproto, IPPROTO_TCP);
 
 1737     ValidateParserProto(alproto, IPPROTO_UDP);
 
 1740 static void ValidateParsers(
void)
 
 1748 #define ARRAY_CAP_STEP 16 
 1749 static void (**PreRegisteredCallbacks)(void) = NULL;
 
 1750 static size_t preregistered_callbacks_nb = 0;
 
 1751 static 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();
 
  
 
#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
 
struct StreamSlice StreamSlice
 
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)
 
#define APP_LAYER_PARSER_BYPASS_READY
 
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
 
AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto, const AppProto alproto)
 
struct HtpBodyChunk_ * next
 
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.
 
struct AppLayerTxData AppLayerTxData
 
enum AppLayerEventType AppLayerEventType
 
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)
 
Data structure to store app layer decoder events.
 
struct AppLayerTxConfig AppLayerTxConfig
 
bool(* ApplyTxConfig)(void *state, void *tx, int mode, 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
 
struct AppLayerResult AppLayerResult
 
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)
 
struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple
 
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 AppLayerParserRegisterGetFrameFuncs(uint8_t ipproto, AppProto alproto, AppLayerParserGetFrameIdByNameFn GetIdByNameFunc, AppLayerParserGetFrameNameByIdFn GetNameByIdFunc)
 
void(* SetStreamDepthFlag)(void *tx, uint8_t flags)
 
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)
 
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
 
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)
 
void AppLayerParserRegisterApplyTxConfigFunc(uint8_t ipproto, AppProto alproto, bool(*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig))
 
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))
 
void SCAppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events)
 
uint32_t AppLayerParserGetStreamDepth(const Flow *f)
 
void RegisterIMAPParsers(void)
 
AppLayerGetFileState(* GetTxFiles)(void *, uint8_t)
 
AppLayerParserGetStateIdByNameFn GetStateIdByName
 
struct AppLayerStateData AppLayerStateData
 
#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)
 
FramesContainer * AppLayerFramesGetContainer(Flow *f)
 
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)
 
void AppLayerIncTxCounter(ThreadVars *tv, Flow *f, uint64_t step)
 
#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)
 
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
 
#define SCLogNotice(...)
Macro used to log NOTICE messages.
 
void RegisterNFSUDPParsers(void)
 
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