EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Functions
sqlite_pcap.c File Reference

File containing the implementation of the sqlite pcap utilities. More...

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <string.h>
#include "sqlite_pcap.h"
#include "../../../utils/allocs.h"
#include "../../../utils/log.h"
#include "../../../utils/os.h"
#include "../../../utils/sqliteu.h"
Include dependency graph for sqlite_pcap.c:

Functions

int init_sqlite_pcap_db (sqlite3 *db)
 Initialisez the sqlite pcap db tables. More...
 
int save_sqlite_pcap_entry (sqlite3 *db, char *name, uint64_t timestamp, uint32_t caplen, uint32_t length)
 Save a pcap entry into the sqlite db. More...
 
int get_first_pcap_entry (sqlite3 *db, uint64_t *timestamp, uint64_t *caplen)
 Returns the first pcap entry timestamp. More...
 
int sum_pcap_group (sqlite3 *db, uint64_t lt, uint32_t lim, uint64_t *ht, uint64_t *sum)
 Calculates the sum of the group of a pcap. More...
 
int get_pcap_meta_array (sqlite3 *db, uint64_t lt, uint32_t lim, UT_array *pcap_meta_arr)
 Returns the pcap meta array. More...
 
int delete_pcap_entries (sqlite3 *db, uint64_t lt, uint64_t ht)
 Removes a set of entries. More...
 

Detailed Description

File containing the implementation of the sqlite pcap utilities.

Author
Alexandru Mereacre
Date
2021

Function Documentation

◆ delete_pcap_entries()

int delete_pcap_entries ( sqlite3 *  db,
uint64_t  lt,
uint64_t  ht 
)

Removes a set of entries.

Parameters
dbThe sqlite db structure pointer
ltThe lower timestamp
htThe higher timestamp
Returns
int 0 on success, 1 for no data and -1 on failure

◆ get_first_pcap_entry()

int get_first_pcap_entry ( sqlite3 *  db,
uint64_t *  timestamp,
uint64_t *  caplen 
)

Returns the first pcap entry timestamp.

Parameters
dbThe sqlite db structure pointer
timestampThe returned timestamp value
caplenThe returned caplen value
Returns
int 0 on success, 1 for no data and -1 on failure

◆ get_pcap_meta_array()

int get_pcap_meta_array ( sqlite3 *  db,
uint64_t  lt,
uint32_t  lim,
UT_array *  pcap_meta_arr 
)

Returns the pcap meta array.

Parameters
dbThe sqlite db structure pointer
ltThe lower timestamp
limThe limit number of rows
pcap_meta_arrThe pcap meta array
Returns
int 0 on success, 1 for no data and -1 on failure

◆ init_sqlite_pcap_db()

int init_sqlite_pcap_db ( sqlite3 *  db)

Initialisez the sqlite pcap db tables.

Parameters
dbThe sqlite3 db
Returns
0 on success, -1 on failure

◆ save_sqlite_pcap_entry()

int save_sqlite_pcap_entry ( sqlite3 *  db,
char *  name,
uint64_t  timestamp,
uint32_t  caplen,
uint32_t  length 
)

Save a pcap entry into the sqlite db.

Parameters
dbThe sqlite db structure pointer
nameThe pcap file name
timestampThe timestamp value
caplenThe capture len
lengthThe offwire packet len
Returns
int 0 on success, -1 on failure

◆ sum_pcap_group()

int sum_pcap_group ( sqlite3 *  db,
uint64_t  lt,
uint32_t  lim,
uint64_t *  ht,
uint64_t *  sum 
)

Calculates the sum of the group of a pcap.

Parameters
dbThe sqlite db structure pointer
ltThe lower bound timestamp
limThe limit number of rows
htThe returned upper timestamp
sumThe returned sum
Returns
int 0 on success, 1 for no data and -1 on failure