EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Data Structures | Macros | Functions | Variables
cleaner_middleware.c File Reference

File containing the implementation of the capture cleaner service structures. More...

#include "./cleaner_middleware.h"
#include <libgen.h>
#include <sqlite3.h>
#include <utarray.h>
#include "../../capture_config.h"
#include "../../capture_service.h"
#include "../pcap_middleware/sqlite_pcap.h"
#include "../../../utils/allocs.h"
#include "../../../utils/os.h"
#include <eloop.h>
Include dependency graph for cleaner_middleware.c:

Data Structures

struct  cleaner_middleware_context
 

Macros

#define CLEANER_PROCESS_INTERVAL    5 /* Frequency in sec to run the cleaner function*/
 
#define CLEANER_GROUP_INTERVAL
 
#define CLEANER_STORE_SIZE   1000 /*Specifies the capture store size in KiB */
 

Functions

int clean_capture (struct middleware_context *context)
 
void eloop_tout_cleaner_handler (void *eloop_ctx, void *user_ctx)
 
void free_cleaner_middleware (struct middleware_context *context)
 
struct middleware_contextinit_cleaner_middleware (sqlite3 *db, char *db_path, struct eloop_data *eloop, struct pcap_context *pc, char *params)
 
int process_cleaner_middleware (struct middleware_context *context, const char *ltype, struct pcap_pkthdr *header, uint8_t *packet, char *ifname)
 

Variables

struct capture_middleware cleaner_middleware
 Cleaner Middleware. The cleaner middleware is designed to periodically remove the oldest PCAP files when the use more than CLEANER_STORE_SIZE KiB. More...
 

Detailed Description

File containing the implementation of the capture cleaner service structures.

Author
Alexandru Mereacre
Date
2021

Defines the start function for the capturte cleaner service, which removes the capture files from the database folder when it reaches a given size specified in the capture_conf structure. The store size is give by the parameter CLEANER_STORE_SIZE in Kb.

Macro Definition Documentation

◆ CLEANER_GROUP_INTERVAL

#define CLEANER_GROUP_INTERVAL
Value:
1024 /* Number of rows to sum from the pcap metadata to calculate the store \
size*/

◆ CLEANER_PROCESS_INTERVAL

#define CLEANER_PROCESS_INTERVAL    5 /* Frequency in sec to run the cleaner function*/

◆ CLEANER_STORE_SIZE

#define CLEANER_STORE_SIZE   1000 /*Specifies the capture store size in KiB */

Function Documentation

◆ clean_capture()

int clean_capture ( struct middleware_context context)

◆ eloop_tout_cleaner_handler()

void eloop_tout_cleaner_handler ( void *  eloop_ctx,
void *  user_ctx 
)

◆ free_cleaner_middleware()

void free_cleaner_middleware ( struct middleware_context context)

◆ init_cleaner_middleware()

struct middleware_context* init_cleaner_middleware ( sqlite3 *  db,
char *  db_path,
struct eloop_data *  eloop,
struct pcap_context pc,
char *  params 
)

◆ process_cleaner_middleware()

int process_cleaner_middleware ( struct middleware_context context,
const char *  ltype,
struct pcap_pkthdr *  header,
uint8_t *  packet,
char *  ifname 
)

Variable Documentation

◆ cleaner_middleware

struct capture_middleware cleaner_middleware
Initial value:
= {
.name = "cleaner middleware",
}
struct middleware_context * init_cleaner_middleware(sqlite3 *db, char *db_path, struct eloop_data *eloop, struct pcap_context *pc, char *params)
Definition: cleaner_middleware.c:168
void free_cleaner_middleware(struct middleware_context *context)
Definition: cleaner_middleware.c:155
int process_cleaner_middleware(struct middleware_context *context, const char *ltype, struct pcap_pkthdr *header, uint8_t *packet, char *ifname)
Definition: cleaner_middleware.c:236

Cleaner Middleware. The cleaner middleware is designed to periodically remove the oldest PCAP files when the use more than CLEANER_STORE_SIZE KiB.

Authors
Alexandru Mereacre, Alois Klink