EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Macros | Functions
sqlite_macconn_writer.h File Reference

File containing the definition of the sqlite macconn writer utilities. More...

#include <stdint.h>
#include <sqlite3.h>
#include "mac_mapper.h"
#include <utarray.h>
#include "../utils/allocs.h"
#include "../utils/os.h"
#include "../utils/squeue.h"
Include dependency graph for sqlite_macconn_writer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MACCONN_TABLE_NAME   "instance"
 
#define MACCONN_CREATE_TABLE
 
#define MACCONN_INSERT_INTO
 
#define MACCONN_DELETE_FROM   "DELETE FROM " MACCONN_TABLE_NAME " WHERE mac=@mac;"
 
#define MACCONN_SELECT_FROM
 

Functions

int open_sqlite_macconn_db (const char *db_path, sqlite3 **sql)
 Opens the sqlite macconn db. More...
 
void free_sqlite_macconn_db (sqlite3 *db)
 Closes the sqlite db. More...
 
int save_sqlite_macconn_entry (sqlite3 *db, struct mac_conn *conn)
 Saves a macconn entry in the sqlite db. More...
 
int get_sqlite_macconn_entries (sqlite3 *db, UT_array *entries)
 Saves a macconn entries in the sqlite db. More...
 

Detailed Description

File containing the definition of the sqlite macconn writer utilities.

Author
Alexandru Mereacre
Date
2021

Macro Definition Documentation

◆ MACCONN_CREATE_TABLE

#define MACCONN_CREATE_TABLE
Value:
"CREATE TABLE IF NOT EXISTS " MACCONN_TABLE_NAME \
" (id TEXT NOT NULL, mac TEXT NOT NULL, status INTEGER, vlanid INTEGER, " \
"primaryip TEXT, secondaryip TEXT, nat INTEGER, allow INTEGER, label TEXT, " \
"timestamp INTEGER, pass TEXT, PRIMARY KEY (id, mac));"
#define MACCONN_TABLE_NAME
Definition: sqlite_macconn_writer.h:24

◆ MACCONN_DELETE_FROM

#define MACCONN_DELETE_FROM   "DELETE FROM " MACCONN_TABLE_NAME " WHERE mac=@mac;"

◆ MACCONN_INSERT_INTO

#define MACCONN_INSERT_INTO
Value:
"INSERT INTO " MACCONN_TABLE_NAME \
" VALUES(@id, @mac, @status, @vlanid, @primaryip, @secondaryip, " \
"@nat, @allow, @label, @timestamp, @pass);"

◆ MACCONN_SELECT_FROM

#define MACCONN_SELECT_FROM
Value:
"SELECT mac, id, status, vlanid, nat, allow, label, pass FROM " \

◆ MACCONN_TABLE_NAME

#define MACCONN_TABLE_NAME   "instance"

Function Documentation

◆ free_sqlite_macconn_db()

void free_sqlite_macconn_db ( sqlite3 *  db)

Closes the sqlite db.

Parameters
dbThe sqlite db structure pointer

◆ get_sqlite_macconn_entries()

int get_sqlite_macconn_entries ( sqlite3 *  db,
UT_array *  entries 
)

Saves a macconn entries in the sqlite db.

Parameters
dbThe sqlite db structure pointer
entriesThe macconn entries
Returns
int 0 on success, -1 on failure

◆ open_sqlite_macconn_db()

int open_sqlite_macconn_db ( const char *  db_path,
sqlite3 **  sql 
)

Opens the sqlite macconn db.

Parameters
db_pathThe sqlite db path
[out]sqlThe returned sqlite db structure pointer
Returns
0 on success, -1 on failure

◆ save_sqlite_macconn_entry()

int save_sqlite_macconn_entry ( sqlite3 *  db,
struct mac_conn conn 
)

Saves a macconn entry in the sqlite db.

Parameters
dbThe sqlite db structure pointer
connThe MAC connection structure
Returns
int 0 on success, -1 on failure