EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
File containing the implementation of dnsmasq service configuration utilities. More...
#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "dhcp_config.h"
#include "../utils/allocs.h"
#include "../utils/log.h"
#include "../utils/os.h"
#include "../utils/squeue.h"
Macros | |
#define | PROCESS_RESTART_TIME 5 |
#define | MAX_DHCP_CHECK_COUNT 100 |
#define | DNSMASQ_BIND_INTERFACE_OPTION "--bind-interfaces" |
#define | DNSMASQ_BIND_DYNAMIC_OPTION "--bind-dynamic" |
#define | DNSMASQ_NO_DAEMON_OPTION "--no-daemon" |
#define | DNSMASQ_LOG_QUERIES_OPTION "--log-queries" |
#define | DNSMASQ_CONF_FILE_OPTION "-C" |
#define | DNSMASQ_SCRIPT_STR |
Functions | |
int | define_dhcp_interface_name (const struct dhcp_conf *dconf, uint16_t vlanid, char *ifname) |
Creates the DHCP interface name for the given vlan id. More... | |
int | generate_dnsmasq_conf (struct dhcp_conf *dconf, UT_array *dns_server_array) |
Generates the dnsmasq configuration file. More... | |
int | generate_dnsmasq_script (char *dhcp_script_path, char *supervisor_control_path) |
Generates the dnsmasq executable script for DHCP requests. More... | |
void | get_dnsmasq_args (const char *dnsmasq_bin_path, const char *dnsmasq_conf_path, const char *argv[static 6]) |
Builds the argv for calling dnsmasq. More... | |
int | check_dhcp_running (char *name, int wait_time) |
char * | run_dhcp_process (const char *dhcp_bin_path, const char *dhcp_conf_path) |
Execute the DHCP server. More... | |
bool | kill_dhcp_process (void) |
Terminate the DHCP server. More... | |
int | signal_dhcp_process (const char *dhcp_bin_path) |
Signal the DHCP process to reload the config. More... | |
int | clear_dhcp_lease_entry (char *mac_addr, char *dhcp_leasefile_path) |
Clear the DHCP lease entry for a MAC addrress. More... | |
File containing the implementation of dnsmasq service configuration utilities.
#define DNSMASQ_BIND_DYNAMIC_OPTION "--bind-dynamic" |
#define DNSMASQ_BIND_INTERFACE_OPTION "--bind-interfaces" |
#define DNSMASQ_CONF_FILE_OPTION "-C" |
#define DNSMASQ_LOG_QUERIES_OPTION "--log-queries" |
#define DNSMASQ_NO_DAEMON_OPTION "--no-daemon" |
#define DNSMASQ_SCRIPT_STR |
#define MAX_DHCP_CHECK_COUNT 100 |
#define PROCESS_RESTART_TIME 5 |
int check_dhcp_running | ( | char * | name, |
int | wait_time | ||
) |
int clear_dhcp_lease_entry | ( | char * | mac_addr, |
char * | dhcp_leasefile_path | ||
) |
Clear the DHCP lease entry for a MAC addrress.
mac_addr | The MAC address string |
dhcp_leasefile_path | The DHCP file path |
int define_dhcp_interface_name | ( | const struct dhcp_conf * | dconf, |
uint16_t | vlanid, | ||
char * | ifname | ||
) |
Creates the DHCP interface name for the given vlan id.
dconf | The dhcp configuration structure. | |
vlanid | The vlan id. | |
[out] | ifname | The DHCP interface name. |
vlanid
must be less than 4095 chars ifname
must point to at least #IF_NAMESIZE bytes. 0 | Success |
-1 | Error (invalid args) |
int generate_dnsmasq_conf | ( | struct dhcp_conf * | dconf, |
UT_array * | dns_server_array | ||
) |
Generates the dnsmasq configuration file.
dconf | The dhcp configuration structure. |
dns_server_array | The array including the DNS servers IP addresses. |
0
on success, -1
otherwise int generate_dnsmasq_script | ( | char * | dhcp_script_path, |
char * | supervisor_control_path | ||
) |
Generates the dnsmasq executable script for DHCP requests.
dhcp_script_path | The dhcp executable script path string. |
supervisor_control_path | The UNIX domains supervisor control path. |
void get_dnsmasq_args | ( | const char * | dnsmasq_bin_path, |
const char * | dnsmasq_conf_path, | ||
const char * | argv[static 6] | ||
) |
Builds the argv
for calling dnsmasq.
dnsmasq_bin_path | The path to the dnsmasq binary. | |
dnsmasq_conf_path | The path to the dnsmasq config file. | |
[in,out] | argv | The array to store the args warning. |
argv
must have space for at least 6 pointers. bool kill_dhcp_process | ( | void | ) |
Terminate the DHCP server.
char* run_dhcp_process | ( | const char * | dhcp_bin_path, |
const char * | dhcp_conf_path | ||
) |
Execute the DHCP server.
This function returns a pointer to statically allocated memory, which may be overwritten by subsequent calls.
dhcp_bin_path | The DHCP server binary path |
dhcp_conf_path | The DHCP server config path |
free()
int signal_dhcp_process | ( | const char * | dhcp_bin_path | ) |
Signal the DHCP process to reload the config.
dhcp_bin_path | The DHCP server binary path |