-/* Copyright (C) 2017-2020 Open Information Security Foundation
+/* Copyright (C) 2017-2021 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
* AppLayerExpectationGetDataId():
*
* ```
- * data = (char *)FlowGetStorageById(f, AppLayerExpectationGetDataId());
+ * data = (char *)FlowGetStorageById(f, AppLayerExpectationGetFlowId());
* ```
* This storage can be used to store information that are only available in the
* parent connection and could be useful in the parent connection. For instance
#include "util-print.h"
-static int g_expectation_id = -1;
-static int g_expectation_data_id = -1;
+static int g_ippair_expectation_id = -1;
+static int g_flow_expectation_id = -1;
SC_ATOMIC_DECLARE(uint32_t, expectation_count);
void AppLayerExpectationSetup(void)
{
- g_expectation_id = IPPairStorageRegister("expectation", sizeof(void *), NULL, ExpectationListFree);
- g_expectation_data_id = FlowStorageRegister("expectation", sizeof(void *), NULL, ExpectationDataFree);
+ g_ippair_expectation_id =
+ IPPairStorageRegister("expectation", sizeof(void *), NULL, ExpectationListFree);
+ g_flow_expectation_id =
+ FlowStorageRegister("expectation", sizeof(void *), NULL, ExpectationDataFree);
SC_ATOMIC_INIT(expectation_count);
}
return NULL;
}
- return IPPairGetStorageById(*ipp, g_expectation_id);
+ return IPPairGetStorageById(*ipp, g_ippair_expectation_id);
}
SC_ATOMIC_SUB(expectation_count, 1);
exp_list->length--;
if (exp_list->length == 0) {
- IPPairSetStorageById(ipp, g_expectation_id, NULL);
+ IPPairSetStorageById(ipp, g_ippair_expectation_id, NULL);
ExpectationListFree(exp_list);
exp_list = NULL;
}
if (ipp == NULL)
goto error;
- exp_list = IPPairGetStorageById(ipp, g_expectation_id);
+ exp_list = IPPairGetStorageById(ipp, g_ippair_expectation_id);
if (exp_list) {
CIRCLEQ_INSERT_HEAD(&exp_list->list, exp, entries);
/* In case there is already EXPECTATION_MAX_LEVEL expectations waiting to be fullfill,
exp_list->length = 0;
CIRCLEQ_INIT(&exp_list->list);
CIRCLEQ_INSERT_HEAD(&exp_list->list, exp, entries);
- IPPairSetStorageById(ipp, g_expectation_id, exp_list);
+ IPPairSetStorageById(ipp, g_ippair_expectation_id, exp_list);
}
exp_list->length += 1;
*
* \return expectation data identifier
*/
-int AppLayerExpectationGetDataId(void)
+int AppLayerExpectationGetFlowId(void)
{
- return g_expectation_data_id;
+ return g_flow_expectation_id;
}
/**
if (f->alproto_tc == ALPROTO_UNKNOWN) {
f->alproto_tc = alproto;
}
- void *fdata = FlowGetStorageById(f, g_expectation_data_id);
+ void *fdata = FlowGetStorageById(f, g_flow_expectation_id);
if (fdata) {
/* We already have an expectation so let's clean this one */
ExpectationDataFree(exp->data);
} else {
/* Transfer ownership of Expectation data to the Flow */
- if (FlowSetStorageById(f, g_expectation_data_id, exp->data) != 0) {
+ if (FlowSetStorageById(f, g_flow_expectation_id, exp->data) != 0) {
SCLogDebug("Unable to set flow storage");
}
}
/* we depend on detection engine for file pruning */
flags |= FILE_USE_DETECT;
if (ftpdata_state->files == NULL) {
- struct FtpTransferCmd *data = (struct FtpTransferCmd *)FlowGetStorageById(f, AppLayerExpectationGetDataId());
+ struct FtpTransferCmd *data =
+ (struct FtpTransferCmd *)FlowGetStorageById(f, AppLayerExpectationGetFlowId());
if (data == NULL) {
SCReturnStruct(APP_LAYER_ERROR);
}
ftpdata_state->files = FileContainerAlloc();
if (ftpdata_state->files == NULL) {
- FlowFreeStorageById(f, AppLayerExpectationGetDataId());
+ FlowFreeStorageById(f, AppLayerExpectationGetFlowId());
SCReturnStruct(APP_LAYER_ERROR);
}
SCLogDebug("Can't open file");
ret = -1;
}
- FlowFreeStorageById(f, AppLayerExpectationGetDataId());
+ FlowFreeStorageById(f, AppLayerExpectationGetFlowId());
ftpdata_state->tx_data.files_opened = 1;
} else {
if (input_len != 0) {