-/* Copyright (C) 2018 Open Information Security Foundation
+/* Copyright (C) 2018-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
* It has to be called once during the init of the sub system
*/
-int LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *)) {
- return StorageRegister(STORAGE_DEVICE, name, size, Alloc, Free);
+LiveDevStorageId LiveDevStorageRegister(const char *name, const unsigned int size,
+ void *(*Alloc)(unsigned int), void (*Free)(void *))
+{
+ int id = StorageRegister(STORAGE_DEVICE, name, size, Alloc, Free);
+ LiveDevStorageId ldsi = { .id = id };
+ return ldsi;
}
/**
* \param ptr pointer to the data to store
*/
-int LiveDevSetStorageById(LiveDevice *d, int id, void *ptr)
+int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr)
{
- return StorageSetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id, ptr);
+ return StorageSetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id, ptr);
}
/**
*
*/
-void *LiveDevGetStorageById(LiveDevice *d, int id)
+void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id)
{
- return StorageGetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
+ return StorageGetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
}
/**
/* Start of "private" function */
-void *LiveDevAllocStorageById(LiveDevice *d, int id)
+void *LiveDevAllocStorageById(LiveDevice *d, LiveDevStorageId id)
{
- return StorageAllocByIdPrealloc((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
+ return StorageAllocByIdPrealloc(
+ (Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
}
-void LiveDevFreeStorageById(LiveDevice *d, int id)
+void LiveDevFreeStorageById(LiveDevice *d, LiveDevStorageId id)
{
- StorageFreeById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
+ StorageFreeById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
}
void LiveDevFreeStorage(LiveDevice *d)
-/* Copyright (C) 2018 Open Information Security Foundation
+/* Copyright (C) 2018-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
#include "util-storage.h"
#include "util-device.h"
+typedef struct LiveDevStorageId_ {
+ int id;
+} LiveDevStorageId;
+
unsigned int LiveDevStorageSize(void);
-void *LiveDevGetStorageById(LiveDevice *d, int id);
-int LiveDevSetStorageById(LiveDevice *d, int id, void *ptr);
-void *LiveDevAllocStorageById(LiveDevice *d, int id);
+void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id);
+int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr);
+void *LiveDevAllocStorageById(LiveDevice *d, LiveDevStorageId id);
-void LiveDevFreeStorageById(LiveDevice *d, int id);
+void LiveDevFreeStorageById(LiveDevice *d, LiveDevStorageId id);
void LiveDevFreeStorage(LiveDevice *d);
void RegisterLiveDevStorageTests(void);
-int LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *));
+LiveDevStorageId LiveDevStorageRegister(const char *name, const unsigned int size,
+ void *(*Alloc)(unsigned int), void (*Free)(void *));
#endif /* __DEVICE_STORAGE_H__ */
-/* Copyright (C) 2011-2016 Open Information Security Foundation
+/* Copyright (C) 2011-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
#define MAX_DEVNAME 10
-static int g_bypass_storage_id = -1;
+static LiveDevStorageId g_bypass_storage_id = { .id = -1 };
/**
* \file
}
/**
- * Increase number of currently succesfully bypassed flows for a protocol family
+ * Increase number of currently successfully bypassed flows for a protocol family
*
* \param dev pointer to LiveDevice to set stats for
* \param cnt number of flows to add
-/* Copyright (C) 2018-2019 Open Information Security Foundation
+/* Copyright (C) 2018-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
#define BYPASSED_FLOW_TIMEOUT 60
-static int g_livedev_storage_id = -1;
-static int g_flow_storage_id = -1;
+static LiveDevStorageId g_livedev_storage_id = { .id = -1 };
+static int g_flow_storage_id = -1; // TODO change this in a different commit
struct bpf_map_item {
char iface[IFNAMSIZ];