"additionalProperties": false
},
"http": {
+ "type": "object",
+ "properties": {
+ "memcap": {
+ "type": "integer"
+ },
+ "memuse": {
+ "type": "integer"
+ },
+ "byterange": {
+ "type": "object",
+ "properties": {
+ "memcap": {
+ "type": "integer"
+ },
+ "memuse": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false
+ },
+ "host": {
+ "type": "object",
+ "properties": {
+ "memcap": {
+ "type": "integer"
+ },
+ "memuse": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false
+ },
+ "ippair": {
"type": "object",
"properties": {
"memcap": {
return tmpval;
}
+int FTPSetMemcap(uint64_t size)
+{
+ if ((uint64_t)SC_ATOMIC_GET(ftp_memcap) < size) {
+ SC_ATOMIC_SET(ftp_memcap, size);
+ return 1;
+ }
+
+ return 0;
+}
+
/**
* \brief Check if alloc'ing "size" would mean we're over memcap
*
void RegisterFTPParsers(void);
void FTPParserRegisterTests(void);
void FTPParserCleanup(void);
+int FTPSetMemcap(uint64_t size);
uint64_t FTPMemuseGlobalCounter(void);
uint64_t FTPMemcapGlobalCounter(void);
-/* Copyright (C) 2021 Open Information Security Foundation
+/* Copyright (C) 2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#define CONTAINER_URLRANGE_HASH_SIZE 256
+int HTPByteRangeSetMemcap(uint64_t size)
+{
+ if (size == 0 || (uint64_t)SC_ATOMIC_GET(ContainerUrlRangeList.ht->memuse) < size) {
+ SC_ATOMIC_SET(ContainerUrlRangeList.ht->config.memcap, size);
+ return 1;
+ }
+
+ return 0;
+}
+
+uint64_t HTPByteRangeMemcapGlobalCounter(void)
+{
+ uint64_t tmpval = SC_ATOMIC_GET(ContainerUrlRangeList.ht->config.memcap);
+ return tmpval;
+}
+
+uint64_t HTPByteRangeMemuseGlobalCounter(void)
+{
+ uint64_t tmpval = SC_ATOMIC_GET(ContainerUrlRangeList.ht->memuse);
+ return tmpval;
+}
+
int HttpRangeContainerBufferCompare(HttpRangeContainerBuffer *a, HttpRangeContainerBuffer *b)
{
// lexical order : start, buflen, offset
-/* Copyright (C) 2021 Open Information Security Foundation
+/* Copyright (C) 2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
void HttpRangeFreeBlock(HttpRangeContainerBlock *b);
+uint64_t HTPByteRangeMemcapGlobalCounter(void);
+uint64_t HTPByteRangeMemuseGlobalCounter(void);
+int HTPByteRangeSetMemcap(uint64_t);
+
#endif /* SURICATA_APP_LAYER_HTP_RANGE_H */
#include "app-layer-protos.h"
#include "app-layer-expectation.h"
#include "app-layer-ftp.h"
+#include "app-layer-htp-range.h"
#include "app-layer-detect-proto.h"
#include "app-layer-frames.h"
#include "stream-tcp-reassemble.h"
StatsRegisterGlobalCounter("ftp.memuse", FTPMemuseGlobalCounter);
StatsRegisterGlobalCounter("ftp.memcap", FTPMemcapGlobalCounter);
StatsRegisterGlobalCounter("app_layer.expectations", ExpectationGetCounter);
+ StatsRegisterGlobalCounter("http.byterange.memuse", HTPByteRangeMemuseGlobalCounter);
+ StatsRegisterGlobalCounter("http.byterange.memcap", HTPByteRangeMemcapGlobalCounter);
+ StatsRegisterGlobalCounter("ippair.memuse", IPPairGetMemuse);
+ StatsRegisterGlobalCounter("ippair.memcap", IPPairGetMemuse);
+ StatsRegisterGlobalCounter("host.memuse", HostGetMemuse);
+ StatsRegisterGlobalCounter("host.memcap", HostGetMemcap);
}
static bool IsAppLayerErrorExceptionPolicyStatsValid(enum ExceptionPolicy policy)
#include "defrag-hash.h"
#include "ippair.h"
#include "app-layer.h"
+#include "app-layer-ftp.h"
#include "app-layer-htp-mem.h"
+#include "app-layer-htp-range.h"
#include "host-bit.h"
#include "util-misc.h"
StreamTcpReassembleMemuseGlobalCounter },
{ "flow", FlowSetMemcap, FlowGetMemcap, FlowGetMemuse },
{ "applayer-proto-http", HTPSetMemcap, HTPGetMemcap, HTPMemuseGlobalCounter },
+ { "applayer-proto-http-byterange", HTPByteRangeSetMemcap, HTPByteRangeMemcapGlobalCounter,
+ HTPByteRangeMemuseGlobalCounter },
{ "defrag", DefragTrackerSetMemcap, DefragTrackerGetMemcap, DefragTrackerGetMemuse },
{ "ippair", IPPairSetMemcap, IPPairGetMemcap, IPPairGetMemuse },
{ "host", HostSetMemcap, HostGetMemcap, HostGetMemuse },
+ { "ftp", FTPSetMemcap, FTPMemcapGlobalCounter, FTPMemuseGlobalCounter },
};
float MemcapsGetPressure(void)