Skip to content
Snippets Groups Projects
config.h 2.78 KiB
Newer Older
  • Learn to ignore specific revisions
  • #ifndef CONFIG_H
    #define CONFIG_H
    
    #include <stdio.h>
    #include <string.h>
    #include <syslog.h>
    
    Rahul Thakur's avatar
    Rahul Thakur committed
    #include <stdbool.h>
    
    #include <stdlib.h>
    
    #include <regex.h>
    
    #include <libubox/list.h>
    
    #include <libubox/utils.h>
    
    Rahul Thakur's avatar
    Rahul Thakur committed
    
    
    Vivek Dutta's avatar
    Vivek Dutta committed
    #include <libbbfdm-api/dmcommon.h>
    
    
    #include "stringstore.h"
    
    // This functions reads the config from the uci file and stores in structures
    
    int read_config(bool *serv_enabled);
    void free_dns_servers(void);
    
    #define log_info(str) BBF_INFO("%s", str)
    #define log_info2(str, arg) BBF_INFO("%s %s", str, arg)
    #define log_error(str) BBF_ERR("%s", str)
    #define log_error2(str, arg) BBF_ERR("%s %s", str, arg)
    
    #define BUFSIZE			2048
    #define MAC_LENGTH		18
    
    #define TIMESTAMP_LENGTH	32
    
    #define MAX_URL_LENGTH 		1024
    #define MAX_NAME_LENGTH 	256
    
    #define MAX_BUFFER_LENGTH 	512
    
    #define MAX_TIME_LENGTH 	9
    #define MAX_WEEK_DAYS 		7
    
    #define MAX_BUNDLES_PER_FILTER 	32
    
    #define MAX_BLOCK_HISTORY_LIMIT	255
    
    
    #define FILTER_ACTIVE 		1
    #define FILTER_INACTIVE 	0
    
    extern size_t dns_server_cnt;
    extern char **dns_server_ip;
    
    extern struct list_head profiles, bundles;
    
    
    // Structure to handle dynamically allocated memory for downloaded data
    struct dynamic_memory {
    
    	unsigned long size;    // Current size of the data
    
    	unsigned long capacity;    // Current size of the data
    
    	char *data;     // Pointer to the allocated memory
    
    struct host {
    	struct list_head list;  // Linked list of hosts
    	char host_identifier[MAX_NAME_LENGTH];  // MAC address or device identifier
    };
    
    struct url_list {
    	unsigned int match_cnt;
    	struct list_head list;
    
    Rahul Thakur's avatar
    Rahul Thakur committed
    
    
    struct urlbundle {
    
    	stringstore download_url;
    
    	struct list_head custom_url;  // List of filter URLs
    	struct list_head list;  // Linked list of urlbundles
    	char name[MAX_NAME_LENGTH];
    };
    
    Rahul Thakur's avatar
    Rahul Thakur committed
    
    
    struct schedule {
    	unsigned int duration;
    	bool enable;
    	struct list_head days;  // List of days the schedule is active
    	struct list_head list;  // Linked list for multiple schedules
    	char name[MAX_NAME_LENGTH];
    	char start_time[MAX_TIME_LENGTH];
    	bool day[MAX_WEEK_DAYS];
    };
    
    Rahul Thakur's avatar
    Rahul Thakur committed
    
    
    struct urlfilter {
    	bool enable;
    	bool access_policy;
    	struct list_head filter_text;  // List of filter URLs
    
    	struct list_head schedules;  // List of schedules
    	unsigned int bundle_cnt;
    
    	struct list_head list;        // Linked list of filters for each profile
    
    	struct urlbundle *bundle;
    	struct urlbundle *bundles[MAX_BUNDLES_PER_FILTER];  // List of bundles
    
    	char dm_parent[MAX_NAME_LENGTH];
    };
    
    struct profile {
    
    	stringstore hosts;
    
    	struct list_head filters; // List of URL filters (struct urlfilter)
    	struct list_head list;    // Linked list for profiles
    	char name[MAX_NAME_LENGTH];
    };
    
    struct blocked_url_entry {
    	char mac_address[MAC_LENGTH];
    	char timestamp[TIMESTAMP_LENGTH];    // Timestamp in YYYY-MM-DD HH:MM:SS format
    	char url[MAX_URL_LENGTH];
    	char source[MAX_BUFFER_LENGTH]; 
    };
    
    
    int init_dns_server_list(void);