EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
sqlite_macconn_writer.h
Go to the documentation of this file.
1 
11 #ifndef SQLITE_MACCONN_WRITER_H
12 #define SQLITE_MACCONN_WRITER_H
13 
14 #include <stdint.h>
15 #include <sqlite3.h>
16 
17 #include "mac_mapper.h"
18 
19 #include <utarray.h>
20 #include "../utils/allocs.h"
21 #include "../utils/os.h"
22 #include "../utils/squeue.h"
23 
24 #define MACCONN_TABLE_NAME "instance"
25 
26 #define MACCONN_CREATE_TABLE \
27  "CREATE TABLE IF NOT EXISTS " MACCONN_TABLE_NAME \
28  " (id TEXT NOT NULL, mac TEXT NOT NULL, status INTEGER, vlanid INTEGER, " \
29  "primaryip TEXT, secondaryip TEXT, nat INTEGER, allow INTEGER, label TEXT, " \
30  "timestamp INTEGER, pass TEXT, PRIMARY KEY (id, mac));"
31 #define MACCONN_INSERT_INTO \
32  "INSERT INTO " MACCONN_TABLE_NAME \
33  " VALUES(@id, @mac, @status, @vlanid, @primaryip, @secondaryip, " \
34  "@nat, @allow, @label, @timestamp, @pass);"
35 #define MACCONN_DELETE_FROM "DELETE FROM " MACCONN_TABLE_NAME " WHERE mac=@mac;"
36 #define MACCONN_SELECT_FROM \
37  "SELECT mac, id, status, vlanid, nat, allow, label, pass FROM " \
38  " " MACCONN_TABLE_NAME ";"
39 
47 int open_sqlite_macconn_db(const char *db_path, sqlite3 **sql);
48 
54 void free_sqlite_macconn_db(sqlite3 *db);
55 
63 int save_sqlite_macconn_entry(sqlite3 *db, struct mac_conn *conn);
64 
72 int get_sqlite_macconn_entries(sqlite3 *db, UT_array *entries);
73 
74 #endif
File containing the definition of the mac mapper.
void free_sqlite_macconn_db(sqlite3 *db)
Closes the sqlite db.
Definition: sqlite_macconn_writer.c:26
int get_sqlite_macconn_entries(sqlite3 *db, UT_array *entries)
Saves a macconn entries in the sqlite db.
Definition: sqlite_macconn_writer.c:180
int save_sqlite_macconn_entry(sqlite3 *db, struct mac_conn *conn)
Saves a macconn entry in the sqlite db.
Definition: sqlite_macconn_writer.c:58
int open_sqlite_macconn_db(const char *db_path, sqlite3 **sql)
Opens the sqlite macconn db.
Definition: sqlite_macconn_writer.c:32
MAC connection structure.
Definition: mac_mapper.h:57