mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Move even more definitions from FTL.h into the respective headers.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -107,124 +107,7 @@ enum { TYPE_A = 1, TYPE_AAAA, TYPE_ANY, TYPE_SRV, TYPE_SOA, TYPE_PTR, TYPE_TXT,
|
||||
enum { REPLY_UNKNOWN, REPLY_NODATA, REPLY_NXDOMAIN, REPLY_CNAME, REPLY_IP, REPLY_DOMAIN, REPLY_RRNAME, REPLY_SERVFAIL, REPLY_REFUSED, REPLY_NOTIMP, REPLY_OTHER };
|
||||
enum { PRIVACY_SHOW_ALL = 0, PRIVACY_HIDE_DOMAINS, PRIVACY_HIDE_DOMAINS_CLIENTS, PRIVACY_MAXIMUM, PRIVACY_NOSTATS };
|
||||
enum { MODE_IP, MODE_NX, MODE_NULL, MODE_IP_NODATA_AAAA, MODE_NODATA };
|
||||
enum { REGEX_UNKNOWN, REGEX_BLOCKED, REGEX_NOTBLOCKED };
|
||||
enum { BLOCKING_DISABLED, BLOCKING_ENABLED, BLOCKING_UNKNOWN };
|
||||
enum { GRAVITY_LIST, BLACK_LIST, WHITE_LIST, REGEX_LIST, UNKNOWN_LIST };
|
||||
enum {
|
||||
DEBUG_DATABASE = (1 << 0), /* 00000000 00000001 */
|
||||
DEBUG_NETWORKING = (1 << 1), /* 00000000 00000010 */
|
||||
DEBUG_LOCKS = (1 << 2), /* 00000000 00000100 */
|
||||
DEBUG_QUERIES = (1 << 3), /* 00000000 00001000 */
|
||||
DEBUG_FLAGS = (1 << 4), /* 00000000 00010000 */
|
||||
DEBUG_SHMEM = (1 << 5), /* 00000000 00100000 */
|
||||
DEBUG_GC = (1 << 6), /* 00000000 01000000 */
|
||||
DEBUG_ARP = (1 << 7), /* 00000000 10000000 */
|
||||
DEBUG_REGEX = (1 << 8), /* 00000001 00000000 */
|
||||
DEBUG_API = (1 << 9), /* 00000010 00000000 */
|
||||
DEBUG_OVERTIME = (1 << 10), /* 00000100 00000000 */
|
||||
DEBUG_EXTBLOCKED = (1 << 11), /* 00001000 00000000 */
|
||||
DEBUG_CAPS = (1 << 12), /* 00010000 00000000 */
|
||||
};
|
||||
|
||||
// Database table "ftl"
|
||||
enum { DB_VERSION, DB_LASTTIMESTAMP, DB_FIRSTCOUNTERTIMESTAMP };
|
||||
// Database table "counters"
|
||||
enum { DB_TOTALQUERIES, DB_BLOCKEDQUERIES };
|
||||
|
||||
// Static structs
|
||||
|
||||
typedef struct {
|
||||
int queries;
|
||||
int blocked;
|
||||
int cached;
|
||||
int unknown;
|
||||
int forwarded;
|
||||
int clients;
|
||||
int domains;
|
||||
int queries_MAX;
|
||||
int forwarded_MAX;
|
||||
int clients_MAX;
|
||||
int domains_MAX;
|
||||
int strings_MAX;
|
||||
int gravity;
|
||||
int gravity_conf;
|
||||
int querytype[TYPE_MAX-1];
|
||||
int forwardedqueries;
|
||||
int reply_NODATA;
|
||||
int reply_NXDOMAIN;
|
||||
int reply_CNAME;
|
||||
int reply_IP;
|
||||
int reply_domain;
|
||||
} countersStruct;
|
||||
|
||||
// Dynamic structs
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
unsigned char type;
|
||||
unsigned char status;
|
||||
unsigned char privacylevel;
|
||||
unsigned char reply;
|
||||
unsigned char dnssec;
|
||||
time_t timestamp;
|
||||
int domainID;
|
||||
int clientID;
|
||||
int forwardID;
|
||||
int id; // the ID is a (signed) int in dnsmasq, so no need for a long int here
|
||||
unsigned long response; // saved in units of 1/10 milliseconds (1 = 0.1ms, 2 = 0.2ms, 2500 = 250.0ms, etc.)
|
||||
int64_t db;
|
||||
unsigned int timeidx;
|
||||
bool complete;
|
||||
} queriesData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
size_t ippos;
|
||||
size_t namepos;
|
||||
int count;
|
||||
int failed;
|
||||
bool new;
|
||||
} forwardedData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
size_t ippos;
|
||||
size_t namepos;
|
||||
time_t lastQuery;
|
||||
int count;
|
||||
int blockedcount;
|
||||
int overTime[OVERTIME_SLOTS];
|
||||
unsigned int numQueriesARP;
|
||||
bool new;
|
||||
} clientsData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
unsigned char regexmatch;
|
||||
size_t domainpos;
|
||||
int count;
|
||||
int blockedcount;
|
||||
} domainsData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
time_t timestamp;
|
||||
int total;
|
||||
int blocked;
|
||||
int cached;
|
||||
int forwarded;
|
||||
int querytypedata[TYPE_MAX-1];
|
||||
} overTimeData;
|
||||
|
||||
typedef struct {
|
||||
char **domains;
|
||||
int count;
|
||||
} whitelistStruct;
|
||||
|
||||
typedef struct {
|
||||
int version;
|
||||
unsigned int global_shm_counter;
|
||||
unsigned int next_str_pos;
|
||||
} ShmSettings;
|
||||
|
||||
// Use out own memory handling functions that will detect possible errors
|
||||
// and report accordingly in the log. This will make debugging FTL crashs
|
||||
@@ -244,14 +127,4 @@ extern pthread_t DBthread;
|
||||
extern pthread_t GCthread;
|
||||
extern pthread_t DNSclientthread;
|
||||
|
||||
// Pointer getter functions
|
||||
#define getQuery(queryID, checkMagic) _getQuery(queryID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
queriesData* _getQuery(int queryID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getClient(clientID, checkMagic) _getClient(clientID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
clientsData* _getClient(int clientID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getDomain(domainID, checkMagic) _getDomain(domainID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
domainsData* _getDomain(int domainID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getForward(forwardID, checkMagic) _getForward(forwardID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
forwardedData* _getForward(int forwardID, bool checkMagic, int line, const char * function, const char * file);
|
||||
|
||||
#endif // FTL_H
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "overTime.h"
|
||||
#include "api.h"
|
||||
#include "version.h"
|
||||
// enum REGEX
|
||||
#include "regex_r.h"
|
||||
|
||||
#define min(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
|
||||
|
||||
|
||||
@@ -51,4 +51,20 @@ typedef struct {
|
||||
extern ConfigStruct config;
|
||||
extern FTLFileNamesStruct FTLfiles;
|
||||
|
||||
enum {
|
||||
DEBUG_DATABASE = (1 << 0), /* 00000000 00000001 */
|
||||
DEBUG_NETWORKING = (1 << 1), /* 00000000 00000010 */
|
||||
DEBUG_LOCKS = (1 << 2), /* 00000000 00000100 */
|
||||
DEBUG_QUERIES = (1 << 3), /* 00000000 00001000 */
|
||||
DEBUG_FLAGS = (1 << 4), /* 00000000 00010000 */
|
||||
DEBUG_SHMEM = (1 << 5), /* 00000000 00100000 */
|
||||
DEBUG_GC = (1 << 6), /* 00000000 01000000 */
|
||||
DEBUG_ARP = (1 << 7), /* 00000000 10000000 */
|
||||
DEBUG_REGEX = (1 << 8), /* 00000001 00000000 */
|
||||
DEBUG_API = (1 << 9), /* 00000010 00000000 */
|
||||
DEBUG_OVERTIME = (1 << 10), /* 00000100 00000000 */
|
||||
DEBUG_EXTBLOCKED = (1 << 11), /* 00001000 00000000 */
|
||||
DEBUG_CAPS = (1 << 12), /* 00010000 00000000 */
|
||||
};
|
||||
|
||||
#endif //CONFIG_H
|
||||
|
||||
@@ -47,4 +47,9 @@ extern bool DBdeleteoldqueries;
|
||||
}\
|
||||
}
|
||||
|
||||
// Database table "ftl"
|
||||
enum { DB_VERSION, DB_LASTTIMESTAMP, DB_FIRSTCOUNTERTIMESTAMP };
|
||||
// Database table "counters"
|
||||
enum { DB_TOTALQUERIES, DB_BLOCKEDQUERIES };
|
||||
|
||||
#endif //DATABASE_COMMON_H
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "memory.h"
|
||||
#include "shmem.h"
|
||||
#include "log.h"
|
||||
// enum REGEX
|
||||
#include "regex_r.h"
|
||||
|
||||
// converts upper to lower case, and leaves other characters unchanged
|
||||
void strtolower(char *str)
|
||||
|
||||
@@ -20,4 +20,61 @@ const char *getDomainString(const int queryID);
|
||||
const char *getClientIPString(const int queryID);
|
||||
const char *getClientNameString(const int queryID);
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
unsigned char type;
|
||||
unsigned char status;
|
||||
unsigned char privacylevel;
|
||||
unsigned char reply;
|
||||
unsigned char dnssec;
|
||||
time_t timestamp;
|
||||
int domainID;
|
||||
int clientID;
|
||||
int forwardID;
|
||||
int id; // the ID is a (signed) int in dnsmasq, so no need for a long int here
|
||||
unsigned long response; // saved in units of 1/10 milliseconds (1 = 0.1ms, 2 = 0.2ms, 2500 = 250.0ms, etc.)
|
||||
int64_t db;
|
||||
unsigned int timeidx;
|
||||
bool complete;
|
||||
} queriesData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
size_t ippos;
|
||||
size_t namepos;
|
||||
int count;
|
||||
int failed;
|
||||
bool new;
|
||||
} forwardedData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
size_t ippos;
|
||||
size_t namepos;
|
||||
time_t lastQuery;
|
||||
int count;
|
||||
int blockedcount;
|
||||
int overTime[OVERTIME_SLOTS];
|
||||
unsigned int numQueriesARP;
|
||||
bool new;
|
||||
} clientsData;
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
unsigned char regexmatch;
|
||||
size_t domainpos;
|
||||
int count;
|
||||
int blockedcount;
|
||||
} domainsData;
|
||||
|
||||
// Pointer getter functions
|
||||
#define getQuery(queryID, checkMagic) _getQuery(queryID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
queriesData* _getQuery(int queryID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getClient(clientID, checkMagic) _getClient(clientID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
clientsData* _getClient(int clientID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getDomain(domainID, checkMagic) _getDomain(domainID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
domainsData* _getDomain(int domainID, bool checkMagic, int line, const char * function, const char * file);
|
||||
#define getForward(forwardID, checkMagic) _getForward(forwardID, checkMagic, __LINE__, __FUNCTION__, __FILE__)
|
||||
forwardedData* _getForward(int forwardID, bool checkMagic, int line, const char * function, const char * file);
|
||||
|
||||
#endif //DATASTRUCTURE_H
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "memory.h"
|
||||
// global variable killed
|
||||
#include "signals.h"
|
||||
// data getter functions
|
||||
#include "datastructure.h"
|
||||
|
||||
bool doGC = false;
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
#include "memory.h"
|
||||
#include "log.h"
|
||||
|
||||
// Fixed size structs
|
||||
countersStruct *counters = NULL;
|
||||
overTimeData *overTime = NULL;
|
||||
|
||||
// The special memory handling routines have to be the last ones in this source file
|
||||
// as we restore the original definition of the strdup, free, calloc, and realloc
|
||||
|
||||
@@ -16,6 +16,30 @@ void *FTLcalloc(size_t nmemb, size_t size, const char *file, const char *functio
|
||||
void *FTLrealloc(void *ptr_in, size_t size, const char *file, const char *function, const int line) __attribute__((alloc_size(2)));
|
||||
void FTLfree(void *ptr, const char* file, const char *function, const int line);
|
||||
|
||||
typedef struct {
|
||||
int queries;
|
||||
int blocked;
|
||||
int cached;
|
||||
int unknown;
|
||||
int forwarded;
|
||||
int clients;
|
||||
int domains;
|
||||
int queries_MAX;
|
||||
int forwarded_MAX;
|
||||
int clients_MAX;
|
||||
int domains_MAX;
|
||||
int strings_MAX;
|
||||
int gravity;
|
||||
int gravity_conf;
|
||||
int querytype[TYPE_MAX-1];
|
||||
int forwardedqueries;
|
||||
int reply_NODATA;
|
||||
int reply_NXDOMAIN;
|
||||
int reply_CNAME;
|
||||
int reply_IP;
|
||||
int reply_domain;
|
||||
} countersStruct;
|
||||
|
||||
extern countersStruct *counters;
|
||||
|
||||
#endif //MEMORY_H
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "log.h"
|
||||
// global variable counters
|
||||
#include "memory.h"
|
||||
// data getter functions
|
||||
#include "datastructure.h"
|
||||
|
||||
overTimeData *overTime = NULL;
|
||||
|
||||
/**
|
||||
* Initialize the overTime slot
|
||||
|
||||
@@ -22,6 +22,16 @@ unsigned int getOverTimeID(const time_t timestamp);
|
||||
*/
|
||||
void moveOverTimeMemory(const time_t mintime);
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic;
|
||||
time_t timestamp;
|
||||
int total;
|
||||
int blocked;
|
||||
int cached;
|
||||
int forwarded;
|
||||
int querytypedata[TYPE_MAX-1];
|
||||
} overTimeData;
|
||||
|
||||
extern overTimeData *overTime;
|
||||
|
||||
#endif //OVERTIME_H
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "memory.h"
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
// data getter functions
|
||||
#include "datastructure.h"
|
||||
#include <regex.h>
|
||||
|
||||
static int num_regex;
|
||||
|
||||
@@ -15,4 +15,6 @@ void free_regex(void);
|
||||
void read_regex_from_database(void);
|
||||
void log_regex(const double time);
|
||||
|
||||
enum { REGEX_UNKNOWN, REGEX_BLOCKED, REGEX_NOTBLOCKED };
|
||||
|
||||
#endif //REGEX_H
|
||||
|
||||
@@ -22,4 +22,6 @@ void check_blocking_status(void);
|
||||
|
||||
extern unsigned char blockingstatus;
|
||||
|
||||
enum { BLOCKING_DISABLED, BLOCKING_ENABLED, BLOCKING_UNKNOWN };
|
||||
|
||||
#endif //SETUPVARS_H
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "log.h"
|
||||
#include "memory.h"
|
||||
#include "config.h"
|
||||
// data getter functions
|
||||
#include "datastructure.h"
|
||||
|
||||
/// The version of shared memory used
|
||||
#define SHARED_MEMORY_VERSION 6
|
||||
|
||||
@@ -21,6 +21,12 @@ typedef struct {
|
||||
void *ptr;
|
||||
} SharedMemory;
|
||||
|
||||
typedef struct {
|
||||
int version;
|
||||
unsigned int global_shm_counter;
|
||||
unsigned int next_str_pos;
|
||||
} ShmSettings;
|
||||
|
||||
/// Create shared memory
|
||||
///
|
||||
/// \param name the name of the shared memory
|
||||
|
||||
Reference in New Issue
Block a user