dhcpd-pools  3.0
ISC dhcpd lease usage analyser
Enumerations | Functions
getdata.c File Reference

Functions to read data from dhcpd.conf and dhcdp.leases files. More...

#include <config.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "error.h"
#include "xalloc.h"
#include "dhcpd-pools.h"
Include dependency graph for getdata.c:

Enumerations

enum  dhcpd_magic_numbers { MAXLEN = 1024 }
 MAXLEN is maximum expected line length in dhcpd.conf and dhcpd.leases. More...
 
enum  isc_conf_parser {
  ITS_NOTHING_INTERESTING, ITS_A_RANGE_FIRST_IP, ITS_A_RANGE_SECOND_IP, ITS_A_SHAREDNET,
  ITS_AN_INCLUDE, ITS_A_SUBNET, ITS_A_NETMASK
}
 Configuration file parsing state flags. More...
 

Functions

int parse_leases (struct conf_t *state, const int print_mac_addreses)
 Lease file parser. More...
 
static int is_interesting_config_clause (struct conf_t *state, char const *restrict s)
 Keyword search in dhcpd.conf file. More...
 
static void reorder_last_first (struct range_t *range_p)
 Flip first and last IP in range if they are in unusual order. More...
 
void parse_config (struct conf_t *state, const int is_include, const char *restrict config_file, struct shared_network_t *restrict shared_p)
 The dhcpd.conf file parser. More...
 

Detailed Description

Functions to read data from dhcpd.conf and dhcdp.leases files.

Enumeration Type Documentation

◆ dhcpd_magic_numbers

MAXLEN is maximum expected line length in dhcpd.conf and dhcpd.leases.

Enumerator
MAXLEN 

◆ isc_conf_parser

Configuration file parsing state flags.

The is_interesting_config_clause() will return one of these to parse_config().

Enumerator
ITS_NOTHING_INTERESTING 
ITS_A_RANGE_FIRST_IP 
ITS_A_RANGE_SECOND_IP 
ITS_A_SHAREDNET 
ITS_AN_INCLUDE 
ITS_A_SUBNET 
ITS_A_NETMASK 

Function Documentation

◆ is_interesting_config_clause()

static int is_interesting_config_clause ( struct conf_t state,
char const *restrict  s 
)
static

Keyword search in dhcpd.conf file.

Parameters
sA line from the dhcpd.conf file.
Returns
Indicator what configuration was found.

Referenced by parse_config().

Here is the call graph for this function:

◆ parse_config()

void parse_config ( struct conf_t state,
const int  is_include,
const char *restrict  config_file,
struct shared_network_t *restrict  shared_p 
)

The dhcpd.conf file parser.

FIXME: This spaghetti monster function needs to be rewrote at least ones more.

Referenced by main().

Here is the call graph for this function:

◆ parse_leases()

int parse_leases ( struct conf_t state,
const int  print_mac_addreses 
)

Lease file parser.

The parser can only read ISC DHCPD dhcpd.leases file format.

Referenced by main().

Here is the call graph for this function:

◆ reorder_last_first()

static void reorder_last_first ( struct range_t range_p)
static

Flip first and last IP in range if they are in unusual order.

Referenced by parse_config().