17 #include "../../../utils/allocs.h"
18 #include "../../../utils/os.h"
19 #include "../../../utils/squeue.h"
21 #define PCAP_TABLE_NAME "pcap"
22 #define PCAP_CREATE_TABLE \
23 "CREATE TABLE IF NOT EXISTS " PCAP_TABLE_NAME \
24 " (timestamp INTEGER NOT NULL, name TEXT NOT NULL, " \
25 "caplen INTEGER, length INTEGER, " \
26 "PRIMARY KEY (name));"
27 #define PCAP_INSERT_INTO \
28 "INSERT INTO " PCAP_TABLE_NAME " VALUES(@timestamp, @name, @caplen, " \
30 #define PCAP_SELECT_FIRST_ENTRY \
31 "SELECT timestamp,caplen FROM " PCAP_TABLE_NAME \
32 " ORDER BY timestamp ASC LIMIT 1;"
33 #define PCAP_SUM_GROUP \
34 "SELECT timestamp,caplen FROM " PCAP_TABLE_NAME \
35 " WHERE timestamp > @lt ORDER BY timestamp ASC LIMIT @lim;"
36 #define PCAP_SELECT_GROUP \
37 "SELECT timestamp,name FROM " PCAP_TABLE_NAME \
38 " WHERE timestamp >= @lt ORDER BY timestamp ASC LIMIT @lim;"
39 #define PCAP_DELETE_GROUP \
40 "DELETE FROM " PCAP_TABLE_NAME " WHERE timestamp >= @lt AND timestamp <= " \
67 uint32_t caplen, uint32_t length);
89 UT_array *pcap_meta_arr);
111 int sum_pcap_group(sqlite3 *db, uint64_t lt, uint32_t lim, uint64_t *ht,
int get_pcap_meta_array(sqlite3 *db, uint64_t lt, uint32_t lim, UT_array *pcap_meta_arr)
Returns the pcap meta array.
Definition: sqlite_pcap.c:156
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.
Definition: sqlite_pcap.c:114
int get_first_pcap_entry(sqlite3 *db, uint64_t *timestamp, uint64_t *caplen)
Returns the first pcap entry timestamp.
Definition: sqlite_pcap.c:82
int init_sqlite_pcap_db(sqlite3 *db)
Initialisez the sqlite pcap db tables.
Definition: sqlite_pcap.c:24
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.
Definition: sqlite_pcap.c:38
int delete_pcap_entries(sqlite3 *db, uint64_t lt, uint64_t ht)
Removes a set of entries.
Definition: sqlite_pcap.c:199