* \brief Call the probing expectation to see if there is some for this flow.
*
*/
-static AppProto AppLayerProtoDetectPEGetProto(Flow *f, uint8_t ipproto, uint8_t flags)
+static AppProto AppLayerProtoDetectPEGetProto(Flow *f, uint8_t flags)
{
AppProto alproto = ALPROTO_UNKNOWN;
/* Look if flow can be found in expectation list */
if (!FLOW_IS_PE_DONE(f, flags)) {
- alproto = AppLayerProtoDetectPEGetProto(f, ipproto, flags);
+ alproto = AppLayerProtoDetectPEGetProto(f, flags);
}
end:
return r;
}
-static Frame *AppLayerFrameUdp(Flow *f, const StreamSlice *stream_slice,
- const uint32_t frame_start_rel, const int64_t len, int dir, uint8_t frame_type)
+static Frame *AppLayerFrameUdp(
+ Flow *f, const uint32_t frame_start_rel, const int64_t len, int dir, uint8_t frame_type)
{
BUG_ON(f->proto != IPPROTO_UDP);
BUG_ON(f->alparser == NULL);
if (f->proto == IPPROTO_UDP) {
- return AppLayerFrameUdp(f, stream_slice, frame_start_rel, len, dir, frame_type);
+ return AppLayerFrameUdp(f, frame_start_rel, len, dir, frame_type);
}
FramesContainer *frames_container = AppLayerFramesSetupContainer(f);
return FrameGetById(frames, frame_id);
}
-static inline bool FrameIsDone(
- const Frame *frame, const uint64_t abs_offset, const uint64_t abs_right_edge)
+static inline bool FrameIsDone(const Frame *frame, const uint64_t abs_right_edge)
{
/* frame with negative length means we don't know the size yet. */
if (frame->len < 0)
SCLogDebug("start: left edge %" PRIu64 ", left_edge_rel %u, stream base %" PRIu64,
(uint64_t)frames->left_edge_rel + STREAM_BASE_OFFSET(stream), frames->left_edge_rel,
STREAM_BASE_OFFSET(stream));
- const uint64_t abs_offset = STREAM_BASE_OFFSET(stream);
const uint64_t acked = StreamTcpGetUsable(stream, eof);
uint64_t le = STREAM_APP_PROGRESS(stream);
if (i < FRAMES_STATIC_CNT) {
Frame *frame = &frames->sframes[i];
FrameDebug("prune(s)", frames, frame);
- if (eof || FrameIsDone(frame, abs_offset, acked)) {
+ if (eof || FrameIsDone(frame, acked)) {
// remove by not incrementing 'x'
SCLogDebug("removing %p id %" PRIi64, frame, frame->id);
FrameDebug("remove(s)", frames, frame);
const uint16_t o = i - FRAMES_STATIC_CNT;
Frame *frame = &frames->dframes[o];
FrameDebug("prune(d)", frames, frame);
- if (eof || FrameIsDone(frame, abs_offset, acked)) {
+ if (eof || FrameIsDone(frame, acked)) {
// remove by not incrementing 'x'
SCLogDebug("removing %p id %" PRIi64, frame, frame->id);
FrameDebug("remove(d)", frames, frame);
* \retval -1 error
* \retval -2 file doesn't need storing
*/
-int HTPFileStoreChunk(
- HtpState *s, HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t direction)
+int HTPFileStoreChunk(HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t direction)
{
SCEnter();
* \retval -1 error
* \retval -2 not storing files on this flow/tx
*/
-int HTPFileClose(HtpState *s, HtpTxUserData *tx, const uint8_t *data, uint32_t data_len,
- uint8_t flags, uint8_t direction)
+int HTPFileClose(
+ HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t flags, uint8_t direction)
{
SCEnter();
uint32_t, htp_tx_t *, bstr *rawvalue, HtpTxUserData *htud);
bool HTPFileCloseHandleRange(const StreamingBufferConfig *sbcfg, FileContainer *, const uint16_t,
HttpRangeContainerBlock *, const uint8_t *, uint32_t);
-int HTPFileStoreChunk(HtpState *, HtpTxUserData *, const uint8_t *, uint32_t, uint8_t);
+int HTPFileStoreChunk(HtpTxUserData *, const uint8_t *, uint32_t, uint8_t);
int HTPParseContentRange(bstr *rawvalue, HTTPContentRange *range);
-int HTPFileClose(HtpState *, HtpTxUserData *tx, const uint8_t *data, uint32_t data_len,
- uint8_t flags, uint8_t direction);
+int HTPFileClose(HtpTxUserData *tx, const uint8_t *data, uint32_t data_len, uint8_t flags,
+ uint8_t direction);
void HTPFileParserRegisterTests(void);
printf("FILEDATA (final chunk) END: \n");
#endif
if (!(htud->tsflags & HTP_DONTSTORE)) {
- if (HTPFileClose(hstate, htud, filedata, filedata_len, flags, STREAM_TOSERVER) ==
- -1) {
+ if (HTPFileClose(htud, filedata, filedata_len, flags, STREAM_TOSERVER) == -1) {
goto end;
}
}
#endif
if (!(htud->tsflags & HTP_DONTSTORE)) {
- result = HTPFileStoreChunk(
- hstate, htud, filedata, filedata_len, STREAM_TOSERVER);
+ result = HTPFileStoreChunk(htud, filedata, filedata_len, STREAM_TOSERVER);
if (result == -1) {
goto end;
} else if (result == -2) {
} else if (result == -2) {
htud->tsflags |= HTP_DONTSTORE;
} else {
- if (HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
+ if (HTPFileClose(htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
goto end;
}
}
} else if (result == -2) {
htud->tsflags |= HTP_DONTSTORE;
} else {
- if (HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
+ if (HTPFileClose(htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
goto end;
}
}
/* otherwise, just store the data */
if (!(htud->tsflags & HTP_DONTSTORE)) {
- result = HTPFileStoreChunk(hstate, htud, data, data_len, STREAM_TOSERVER);
+ result = HTPFileStoreChunk(htud, data, data_len, STREAM_TOSERVER);
if (result == -1) {
goto end;
} else if (result == -2) {
/* otherwise, just store the data */
if (!(htud->tcflags & HTP_DONTSTORE)) {
- result = HTPFileStoreChunk(hstate, htud, data, data_len, STREAM_TOCLIENT);
+ result = HTPFileStoreChunk(htud, data, data_len, STREAM_TOCLIENT);
SCLogDebug("result %d", result);
if (result == -1) {
goto end;
} else {
if (tx_ud->tsflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOSERVER);
+ (void)HTPFileClose(tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOSERVER);
tx_ud->tsflags &= ~HTP_FILENAME_SET;
}
}
} else {
if (tx_ud->tcflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOCLIENT);
+ (void)HTPFileClose(tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOCLIENT);
tx_ud->tcflags &= ~HTP_FILENAME_SET;
}
}
if (htud != NULL) {
if (htud->tsflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER);
+ (void)HTPFileClose(htud, NULL, 0, 0, STREAM_TOSERVER);
htud->tsflags &= ~HTP_FILENAME_SET;
if (abs_right_edge < (uint64_t)UINT32_MAX) {
StreamTcpReassemblySetMinInspectDepth(
if (htud != NULL) {
if (htud->tcflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOCLIENT);
+ (void)HTPFileClose(htud, NULL, 0, 0, STREAM_TOCLIENT);
htud->tcflags &= ~HTP_FILENAME_SET;
}
}
SCReturnInt(0);
}
-AppLayerThreadCtx *AppLayerGetCtxThread(ThreadVars *tv)
+AppLayerThreadCtx *AppLayerGetCtxThread(void)
{
SCEnter();
* \retval Pointer to the newly create thread context, on success;
* NULL, on failure.
*/
-AppLayerThreadCtx *AppLayerGetCtxThread(ThreadVars *tv);
+AppLayerThreadCtx *AppLayerGetCtxThread(void);
/**
* \brief Destroys the context created by AppLayerGetCtxThread().
void AppLayerProfilingResetInternal(AppLayerThreadCtx *app_tctx);
-static inline void AppLayerProfilingReset(AppLayerThreadCtx *app_tctx)
-{
-#ifdef PROFILING
- AppLayerProfilingResetInternal(app_tctx);
-#endif
-}
-
void AppLayerProfilingStoreInternal(AppLayerThreadCtx *app_tctx, Packet *p);
-static inline void AppLayerProfilingStore(AppLayerThreadCtx *app_tctx, Packet *p)
-{
#ifdef PROFILING
- AppLayerProfilingStoreInternal(app_tctx, p);
+#define AppLayerProfilingReset(app_tctx) AppLayerProfilingResetInternal(app_tctx)
+#define AppLayerProfilingStore(app_tctx, p) AppLayerProfilingStoreInternal(app_tctx, p)
+#else
+#define AppLayerProfilingReset(app_tctx)
+#define AppLayerProfilingStore(app_tctx, p)
#endif
-}
void AppLayerRegisterGlobalCounters(void);
if ((dtv = SCCalloc(1, sizeof(DecodeThreadVars))) == NULL)
return NULL;
- dtv->app_tctx = AppLayerGetCtxThread(tv);
+ dtv->app_tctx = AppLayerGetCtxThread();
if (OutputFlowLogThreadInit(tv, NULL, &dtv->output_flow_thread_data) != TM_ECODE_OK) {
SCLogError("initializing flow log API for thread failed");
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
- dtv.app_tctx = AppLayerGetCtxThread(&tv);
+ dtv.app_tctx = AppLayerGetCtxThread();
FlowInitConfig(FLOW_QUIET);
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
- dtv.app_tctx = AppLayerGetCtxThread(&tv);
+ dtv.app_tctx = AppLayerGetCtxThread();
FlowInitConfig(FLOW_QUIET);
PacketCopyData(p, raw_eth_pkt, pktsize);
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&th_v, 0, sizeof(th_v));
- dtv.app_tctx = AppLayerGetCtxThread(&th_v);
+ dtv.app_tctx = AppLayerGetCtxThread();
FlowInitConfig(FLOW_QUIET);
DecodeEthernet(&th_v, &dtv, p, GET_PKT_DATA(p), pktsize);
if (unlikely(ra_ctx == NULL))
return NULL;
- ra_ctx->app_tctx = AppLayerGetCtxThread(tv);
+ ra_ctx->app_tctx = AppLayerGetCtxThread();
SCMutexLock(&segment_thread_pool_mutex);
if (segment_thread_pool == NULL) {
/* handle error */
if (unlikely(r == TM_ECODE_FAILED)) {
/* Encountered error. Return packets to packetpool and return */
- TmThreadsSlotProcessPktFail(tv, s, NULL);
+ TmThreadsSlotProcessPktFail(tv, NULL);
return TM_ECODE_FAILED;
}
if (s->tm_flags & TM_FLAG_DECODE_TM) {
}
}
-static inline void TmThreadsSlotProcessPktFail(ThreadVars *tv, TmSlot *s, Packet *p)
+static inline void TmThreadsSlotProcessPktFail(ThreadVars *tv, Packet *p)
{
if (p != NULL) {
TmqhOutputPacketpool(tv, p);
#endif
TmEcode r = TmThreadsSlotVarRun(tv, extra_p, tv->tm_flowworker);
if (r == TM_ECODE_FAILED) {
- TmThreadsSlotProcessPktFail(tv, tv->tm_flowworker, extra_p);
+ TmThreadsSlotProcessPktFail(tv, extra_p);
break;
}
tv->tmqh_out(tv, extra_p);
TmEcode r = TmThreadsSlotVarRun(tv, p, s);
if (unlikely(r == TM_ECODE_FAILED)) {
- TmThreadsSlotProcessPktFail(tv, s, p);
+ TmThreadsSlotProcessPktFail(tv, p);
return TM_ECODE_FAILED;
}
/**
* \brief Releases resources used by the Classification Config API.
*/
-static void SCClassConfDeInitLocalResources(DetectEngineCtx *de_ctx, FILE *fd)
+static void SCClassConfDeInitLocalResources(FILE *fd)
{
if (fd != NULL) {
fclose(fd);
ret = false;
}
- SCClassConfDeInitLocalResources(de_ctx, fd);
+ SCClassConfDeInitLocalResources(fd);
return ret;
}
g_eps_master_switch = ExceptionPolicyParse("exception-policy", true);
}
-static enum ExceptionPolicy GetMasterExceptionPolicy(const char *option)
+static enum ExceptionPolicy GetMasterExceptionPolicy(void)
{
return g_eps_master_switch;
}
{
enum ExceptionPolicy p = EXCEPTION_POLICY_NOT_SET;
if (g_eps_have_exception_policy) {
- p = GetMasterExceptionPolicy(option);
+ p = GetMasterExceptionPolicy();
if (p == EXCEPTION_POLICY_AUTO) {
p = ExceptionPolicyPickAuto(midstream, support_flow);
/**
* \brief Releases local resources used by the Reference Config API.
*/
-static void SCRConfDeInitLocalResources(DetectEngineCtx *de_ctx, FILE *fd)
+static void SCRConfDeInitLocalResources(FILE *fd)
{
if (fd != NULL) {
fclose(fd);
}
-
- return;
}
/**
}
bool rc = SCRConfParseFile(de_ctx, fd);
- SCRConfDeInitLocalResources(de_ctx, fd);
+ SCRConfDeInitLocalResources(fd);
return rc ? 0 : -1;
}
/** \internal
* \brief find the first region for merging.
*/
-static StreamingBufferRegion *FindFirstRegionForOffset(const StreamingBuffer *sb,
- const StreamingBufferConfig *cfg, StreamingBufferRegion *r, const uint64_t offset,
- const uint32_t len, StreamingBufferRegion **prev)
+static StreamingBufferRegion *FindFirstRegionForOffset(const StreamingBufferConfig *cfg,
+ StreamingBufferRegion *r, const uint64_t offset, const uint32_t len,
+ StreamingBufferRegion **prev)
{
const uint64_t data_re = offset + len;
SCLogDebug("looking for first region matching %" PRIu64 "/%" PRIu64, offset, data_re);
return NULL;
}
-static StreamingBufferRegion *FindLargestRegionForOffset(const StreamingBuffer *sb,
- const StreamingBufferConfig *cfg, StreamingBufferRegion *r, const uint64_t offset,
- const uint32_t len)
+static StreamingBufferRegion *FindLargestRegionForOffset(const StreamingBufferConfig *cfg,
+ StreamingBufferRegion *r, const uint64_t offset, const uint32_t len)
{
const uint64_t data_re = offset + len;
SCLogDebug("starting at %p/%" PRIu64 ", offset %" PRIu64 ", data_re %" PRIu64, r,
return candidate;
}
-static StreamingBufferRegion *FindRightEdge(const StreamingBuffer *sb,
- const StreamingBufferConfig *cfg, StreamingBufferRegion *r, const uint64_t offset,
- const uint32_t len)
+static StreamingBufferRegion *FindRightEdge(const StreamingBufferConfig *cfg,
+ StreamingBufferRegion *r, const uint64_t offset, const uint32_t len)
{
const uint64_t data_re = offset + len;
StreamingBufferRegion *candidate = r;
*
* [gap][block]
**/
-static int WARN_UNUSED SBBInitLeadingGap(StreamingBuffer *sb, const StreamingBufferConfig *cfg,
- StreamingBufferRegion *region, uint64_t offset, uint32_t data_len)
+static int WARN_UNUSED SBBInitLeadingGap(
+ StreamingBuffer *sb, const StreamingBufferConfig *cfg, uint64_t offset, uint32_t data_len)
{
DEBUG_VALIDATE_BUG_ON(!RB_EMPTY(&sb->sbb_tree));
SCLogDebug("offset %" PRIu64 ", len %u", offset, len);
StreamingBufferRegion *start_prev = NULL;
StreamingBufferRegion *start =
- FindFirstRegionForOffset(sb, cfg, &sb->region, offset, len, &start_prev);
+ FindFirstRegionForOffset(cfg, &sb->region, offset, len, &start_prev);
if (start) {
const uint64_t insert_re = offset + len;
const uint64_t insert_start_offset = MIN(start->stream_offset, offset);
uint64_t insert_adjusted_re = insert_re;
SCLogDebug("start region %p/%" PRIu64 "/%u", start, start->stream_offset, start->buf_size);
- StreamingBufferRegion *big = FindLargestRegionForOffset(sb, cfg, start, offset, len);
+ StreamingBufferRegion *big = FindLargestRegionForOffset(cfg, start, offset, len);
DEBUG_VALIDATE_BUG_ON(big == NULL);
if (big == NULL) {
sc_errno = SC_EINVAL;
return NULL;
}
SCLogDebug("big region %p/%" PRIu64 "/%u", big, big->stream_offset, big->buf_size);
- StreamingBufferRegion *end = FindRightEdge(sb, cfg, big, offset, len);
+ StreamingBufferRegion *end = FindRightEdge(cfg, big, offset, len);
DEBUG_VALIDATE_BUG_ON(end == NULL);
if (end == NULL) {
sc_errno = SC_EINVAL;
* \note sets sc_errno
*/
static StreamingBufferRegion *BufferInsertAtRegion(StreamingBuffer *sb,
- const StreamingBufferConfig *cfg, const uint8_t *data, const uint32_t data_len,
- const uint64_t data_offset)
+ const StreamingBufferConfig *cfg, const uint32_t data_len, const uint64_t data_offset)
{
SCLogDebug("data_offset %" PRIu64 ", data_len %u, re %" PRIu64, data_offset, data_len,
data_offset + data_len);
return SC_EINVAL;
}
- StreamingBufferRegion *region = BufferInsertAtRegion(sb, cfg, data, data_len, offset);
+ StreamingBufferRegion *region = BufferInsertAtRegion(sb, cfg, data_len, offset);
if (region == NULL) {
return sc_errno;
}
} else {
/* gap before data in empty list */
SCLogDebug("empty sbb list: invoking SBBInitLeadingGap");
- if ((r = SBBInitLeadingGap(sb, cfg, region, offset, data_len)) != SC_OK)
+ if ((r = SBBInitLeadingGap(sb, cfg, offset, data_len)) != SC_OK)
return r;
}
}
} else {
/* gap before data in empty list */
SCLogDebug("empty sbb list: invoking SBBInitLeadingGap");
- if ((r = SBBInitLeadingGap(sb, cfg, region, offset, data_len)) != SC_OK)
+ if ((r = SBBInitLeadingGap(sb, cfg, offset, data_len)) != SC_OK)
return r;
}
if (rel_offset == region->buf_offset) {
* \retval -1 error
*/
static int SetupThresholdRule(DetectEngineCtx *de_ctx, uint32_t id, uint32_t gid,
- uint8_t parsed_type, uint8_t parsed_track, uint32_t parsed_count,
- uint32_t parsed_seconds, uint32_t parsed_timeout, uint8_t parsed_new_action,
- const char *th_ip)
+ uint8_t parsed_type, uint8_t parsed_track, uint32_t parsed_count, uint32_t parsed_seconds,
+ uint32_t parsed_timeout, uint8_t parsed_new_action)
{
Signature *s = NULL;
SigMatch *sm = NULL;
parsed_count, parsed_seconds, parsed_timeout, parsed_new_action,
th_ip);
} else {
- r = SetupThresholdRule(de_ctx, id, gid, parsed_type, parsed_track,
- parsed_count, parsed_seconds, parsed_timeout, parsed_new_action,
- th_ip);
+ r = SetupThresholdRule(de_ctx, id, gid, parsed_type, parsed_track, parsed_count,
+ parsed_seconds, parsed_timeout, parsed_new_action);
}
if (r < 0) {
goto error;