diff --git a/src/device-storage.c b/src/device-storage.c index 41b41670f4..27ec27fc07 100644 --- a/src/device-storage.c +++ b/src/device-storage.c @@ -29,7 +29,7 @@ #include "util-storage.h" #include "util-unittest.h" -unsigned int LiveDevStorageSize(void) +unsigned int SCLiveDevStorageSize(void) { return StorageGetSize(STORAGE_DEVICE); } @@ -39,9 +39,9 @@ unsigned int LiveDevStorageSize(void) * The device storage API is a per-device storage. It is a mean to extend * the LiveDevice structure with arbitrary data. * - * You have first to register the storage via LiveDevStorageRegister() during - * the init of your module. Then you can attach data via LiveDevSetStorageById() - * and access them via LiveDevGetStorageById(). + * You have first to register the storage via SCLiveDevStorageRegister() during + * the init of your module. Then you can attach data via SCLiveDevSetStorageById() + * and access them via SCLiveDevGetStorageById(). * @{ */ @@ -56,10 +56,10 @@ unsigned int LiveDevStorageSize(void) * It has to be called once during the init of the sub system */ -LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *)) +SCLiveDevStorageId SCLiveDevStorageRegister(const char *name, void (*Free)(void *)) { int id = StorageRegister(STORAGE_DEVICE, name, Free); - LiveDevStorageId ldsi = { .id = id }; + SCLiveDevStorageId ldsi = { .id = id }; return ldsi; } @@ -71,7 +71,7 @@ LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *)) * \param ptr pointer to the data to store */ -int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr) +int SCLiveDevSetStorageById(LiveDevice *d, SCLiveDevStorageId id, void *ptr) { return StorageSetById(d->storage, STORAGE_DEVICE, id.id, ptr); } @@ -80,11 +80,11 @@ int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr) * \brief Get a value from a given LiveDevice storage * * \param d a pointer to the LiveDevice - * \param id the id of the storage (return of LiveDevStorageRegister() call) + * \param id the id of the storage (return of SCLiveDevStorageRegister() call) * */ -void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id) +void *SCLiveDevGetStorageById(LiveDevice *d, SCLiveDevStorageId id) { return StorageGetById(d->storage, STORAGE_DEVICE, id.id); } @@ -95,9 +95,9 @@ void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id) /* Start of "private" function */ -void LiveDevFreeStorage(LiveDevice *d) +void SCLiveDevFreeStorage(LiveDevice *d) { - if (LiveDevStorageSize() > 0) + if (SCLiveDevStorageSize() > 0) StorageFreeAll(d->storage, STORAGE_DEVICE); } diff --git a/src/device-storage.h b/src/device-storage.h index e59bc1aa6a..2e59796f66 100644 --- a/src/device-storage.h +++ b/src/device-storage.h @@ -30,15 +30,15 @@ typedef struct LiveDevStorageId_ { int id; -} LiveDevStorageId; +} SCLiveDevStorageId; -unsigned int LiveDevStorageSize(void); +unsigned int SCLiveDevStorageSize(void); -void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id); -int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr); +void *SCLiveDevGetStorageById(LiveDevice *d, SCLiveDevStorageId id); +int SCLiveDevSetStorageById(LiveDevice *d, SCLiveDevStorageId id, void *ptr); -void LiveDevFreeStorage(LiveDevice *d); +void SCLiveDevFreeStorage(LiveDevice *d); -LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *)); +SCLiveDevStorageId SCLiveDevStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_DEVICE_STORAGE_H */ diff --git a/src/util-device.c b/src/util-device.c index 39976ee148..2362506208 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -28,7 +28,7 @@ #define MAX_DEVNAME 10 -static LiveDevStorageId g_bypass_storage_id = { .id = -1 }; +static SCLiveDevStorageId g_bypass_storage_id = { .id = -1 }; /** * \file @@ -133,7 +133,7 @@ int LiveRegisterDevice(const char *dev) { LiveDevice *pd = NULL; - pd = SCCalloc(1, sizeof(LiveDevice) + LiveDevStorageSize()); + pd = SCCalloc(1, sizeof(LiveDevice) + SCLiveDevStorageSize()); if (unlikely(pd == NULL)) { return -1; } @@ -356,7 +356,7 @@ int LiveDeviceListClean(void) if (pd->dev) SCFree(pd->dev); - LiveDevFreeStorage(pd); + SCLiveDevFreeStorage(pd); SCFree(pd); } @@ -484,7 +484,7 @@ static void LiveDevExtensionFree(void *x) */ void LiveDevRegisterExtension(void) { - g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", LiveDevExtensionFree); + g_bypass_storage_id = SCLiveDevStorageRegister("bypass_stats", LiveDevExtensionFree); } /** @@ -501,7 +501,7 @@ int LiveDevUseBypass(LiveDevice *dev) SC_ATOMIC_INIT(bpinfo->ipv4_hash_count); SC_ATOMIC_INIT(bpinfo->ipv4_hash_count); - LiveDevSetStorageById(dev, g_bypass_storage_id, bpinfo); + SCLiveDevSetStorageById(dev, g_bypass_storage_id, bpinfo); return 0; } @@ -514,7 +514,7 @@ int LiveDevUseBypass(LiveDevice *dev) */ void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family) { - BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id); + BypassInfo *bpfdata = SCLiveDevGetStorageById(dev, g_bypass_storage_id); if (bpfdata) { if (family == AF_INET) { SC_ATOMIC_ADD(bpfdata->ipv4_hash_count, cnt); @@ -533,7 +533,7 @@ void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family) */ void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family) { - BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id); + BypassInfo *bpfdata = SCLiveDevGetStorageById(dev, g_bypass_storage_id); if (bpfdata) { if (family == AF_INET) { SC_ATOMIC_SUB(bpfdata->ipv4_hash_count, cnt); @@ -552,7 +552,7 @@ void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family) */ void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family) { - BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id); + BypassInfo *bpfdata = SCLiveDevGetStorageById(dev, g_bypass_storage_id); if (bpfdata) { if (family == AF_INET) { SC_ATOMIC_ADD(bpfdata->ipv4_fail, cnt); @@ -571,7 +571,7 @@ void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family) */ void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family) { - BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id); + BypassInfo *bpfdata = SCLiveDevGetStorageById(dev, g_bypass_storage_id); if (bpfdata) { if (family == AF_INET) { SC_ATOMIC_ADD(bpfdata->ipv4_success, cnt); @@ -591,7 +591,7 @@ TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data) LiveDevice *ldev = NULL, *ndev = NULL; json_t *ifaces = NULL; while(LiveDeviceForEach(&ldev, &ndev)) { - BypassInfo *bpinfo = LiveDevGetStorageById(ldev, g_bypass_storage_id); + BypassInfo *bpinfo = SCLiveDevGetStorageById(ldev, g_bypass_storage_id); if (bpinfo) { uint64_t ipv4_hash_count = SC_ATOMIC_GET(bpinfo->ipv4_hash_count); uint64_t ipv6_hash_count = SC_ATOMIC_GET(bpinfo->ipv6_hash_count); diff --git a/src/util-ebpf.c b/src/util-ebpf.c index ebf60177da..86a3f69be5 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -60,7 +60,7 @@ #define BYPASSED_FLOW_TIMEOUT 60 -static LiveDevStorageId g_livedev_storage_id = { .id = -1 }; +static SCLiveDevStorageId g_livedev_storage_id = { .id = -1 }; static SCFlowStorageId g_flow_storage_id = { .id = -1 }; struct bpf_map_item { @@ -134,7 +134,7 @@ static struct bpf_maps_info *EBPFGetBpfMap(const char *iface) LiveDevice *livedev = LiveGetDevice(iface); if (livedev == NULL) return NULL; - void *data = LiveDevGetStorageById(livedev, g_livedev_storage_id); + void *data = SCLiveDevGetStorageById(livedev, g_livedev_storage_id); return (struct bpf_maps_info *)data; } @@ -268,7 +268,7 @@ static int EBPFLoadPinnedMaps(LiveDevice *livedev, struct ebpf_timeout_config *c } /* Attach the bpf_maps_info to the LiveDevice via the device storage */ - LiveDevSetStorageById(livedev, g_livedev_storage_id, bpf_map_data); + SCLiveDevSetStorageById(livedev, g_livedev_storage_id, bpf_map_data); /* Declare that device will use bypass stats */ LiveDevUseBypass(livedev); @@ -457,7 +457,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section, } /* Attach the bpf_maps_info to the LiveDevice via the device storage */ - LiveDevSetStorageById(livedev, g_livedev_storage_id, bpf_map_data); + SCLiveDevSetStorageById(livedev, g_livedev_storage_id, bpf_map_data); LiveDevUseBypass(livedev); /* Finally we get the file descriptor for our eBPF program. We will use @@ -929,7 +929,7 @@ int EBPFCheckBypassedFlowCreate(ThreadVars *th_v, struct timespec *curtime, void void EBPFRegisterExtension(void) { - g_livedev_storage_id = LiveDevStorageRegister("bpfmap", BpfMapsInfoFree); + g_livedev_storage_id = SCLiveDevStorageRegister("bpfmap", BpfMapsInfoFree); g_flow_storage_id = SCFlowStorageRegister("bypassedlist", BypassedListFree); }