41 # define DHCPD_POOLS_H 1 56 # ifdef HAVE_BUILTIN_EXPECT 57 # define likely(x) __builtin_expect(!!(x), 1) 58 # define unlikely(x) __builtin_expect(!!(x), 0) 60 # define likely(x) (x) 61 # define unlikely(x) (x) 69 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) 70 # define _DP_ATTRIBUTE_HOT __attribute__ ((__hot__)) 72 # define _DP_ATTRIBUTE_HOT 188 # define STATE_WARNING 1 189 # define STATE_CRITICAL 2 280 extern void dp_time_tool(FILE *file,
const char *path,
int epoch);
301 extern const char *(*ntop_ipaddr) (
const union ipaddr_t *ip);
void __attribute__((noreturn)) print_version(void)
const char * ntop_ipaddr_v6(const union ipaddr_t *ip)
Definition: other.c:308
color_mode
Enumeration whether to use or not color output.
Definition: dhcpd-pools.h:111
int parse_color_mode(const char *restrict optarg)
Parse option argument color mode.
Definition: other.c:479
void delete_all_leases(struct conf_t *state)
Delete all leases from hash array.
Definition: hash.c:130
double range_size
Definition: dhcpd-pools.h:149
prefix_t
Enumeration of interesting data in dhcpd.leases file, that has to be further examined, and saved.
Definition: dhcpd-pools.h:96
Range limit.
Definition: dhcpd-pools.h:179
struct shared_network_t * shared_net
Definition: dhcpd-pools.h:136
int parse_ipaddr_v4(struct conf_t *state, const char *restrict src, union ipaddr_t *restrict dst)
int comp_tcperc(struct range_t *r1, struct range_t *r2)
Compare two range_t by their touched and in use percentage.
Definition: sort.c:182
void set_ipv_functions(struct conf_t *state, int version)
Set function pointers depending on IP version.
Definition: other.c:68
void prepare_data(struct conf_t *state)
Prepare data for analysis.
Definition: analyze.c:50
Shared networks limit.
Definition: dhcpd-pools.h:180
void delete_lease(struct conf_t *state, struct leases_t *lease)
Delete a lease from hash array.
Definition: hash.c:110
int comp_touched(struct range_t *r1, struct range_t *r2)
Compare two range_t by their touched addresses.
Definition: sort.c:164
int(* parse_ipaddr)(struct conf_t *state, const char *restrict src, union ipaddr_t *restrict dst)
Definition: dhcpd-pools.c:59
const char * dhcpdlease_file
Path to dhcpd.leases file.
Definition: dhcpd-pools.h:216
int netmask
Definition: dhcpd-pools.h:128
const char * mustach_template
Mustach template file path.
Definition: dhcpd-pools.h:220
void(* add_lease)(struct conf_t *state, union ipaddr_t *addr, enum ltype type)
Definition: dhcpd-pools.c:66
int comp_ip(struct range_t *r1, struct range_t *r2)
Compare two range_t by their first_ip.
Definition: sort.c:128
double ret_percent(struct range_t r)
Percentage in use in range.
Definition: sort.c:191
struct shared_network_t * shared_net_head
Last entry in shared network linked list.
Definition: dhcpd-pools.h:209
const char * dhcpdconf_file
Path to dhcpd.conf file.
Definition: dhcpd-pools.h:215
int status
Definition: dhcpd-pools.h:148
void add_lease_init(struct conf_t *state, union ipaddr_t *addr, enum ltype type)
int xstrstr_init(struct conf_t *state, const char *restrict str)
Definition: other.c:355
double get_range_size_init(const struct range_t *r)
double percent
Definition: dhcpd-pools.h:150
void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src)
Definition: other.c:279
struct leases_t * find_lease_init(struct conf_t *state, union ipaddr_t *addr)
Definition: dhcpd-pools.h:103
double critical
Critical percent threshold.
Definition: dhcpd-pools.h:222
Definition: dhcpd-pools.h:86
An individual lease.
Definition: dhcpd-pools.h:168
Definition: dhcpd-pools.h:102
char * name
Definition: dhcpd-pools.h:123
double get_range_size_v6(const struct range_t *r)
Definition: other.c:333
int(* comparer_t)(struct range_t *r1, struct range_t *r2)
Function pointer holding sort algorithm.
Definition: dhcpd-pools.h:194
unsigned int num_ranges
Number of ranges in the ranges array.
Definition: dhcpd-pools.h:211
uint32_t v4
Definition: dhcpd-pools.h:78
int leasecomp_v6(const struct leases_t *restrict a, const struct leases_t *restrict b)
Definition: sort.c:99
Linked list of sort functions.
Definition: dhcpd-pools.h:199
double touched
Definition: dhcpd-pools.h:140
Memory space for a binary IP address saving.
Definition: dhcpd-pools.h:77
struct leases_t * find_lease_v6(struct conf_t *state, union ipaddr_t *addr)
Definition: hash.c:100
int leasecomp_v4(const struct leases_t *restrict a, const struct leases_t *restrict b)
Definition: sort.c:90
double warning
Warning percent threshold.
Definition: dhcpd-pools.h:221
Various per range and shared net temporary calculation results.
Definition: dhcpd-pools.h:147
double crit_count
Maximum number of free IP's before critical.
Definition: dhcpd-pools.h:224
size_t ranges_size
Size of the ranges array.
Definition: dhcpd-pools.h:212
Definition: dhcpd-pools.h:112
Definition: dhcpd-pools.h:101
struct shared_network_t * shared_net_root
First entry in shared network linked list, that is the 'all networks',.
Definition: dhcpd-pools.h:208
void parse_cidr(struct conf_t *state, struct range_t *range_p, const char *word)
Convert a cidr notated address to a range.
Definition: other.c:234
void add_lease_v6(struct conf_t *state, union ipaddr_t *addr, enum ltype type)
Definition: hash.c:71
struct leases_t * leases
An array of individual leases from dhcpd.leases file.
Definition: dhcpd-pools.h:213
int output_analysis(struct conf_t *state, const char output_format)
Return output_format_names enum based on single char input.
Definition: output.c:1183
const char * ntop_ipaddr_v4(const union ipaddr_t *ip)
Definition: other.c:299
Definition: dhcpd-pools.h:97
int parse_ipaddr_init(struct conf_t *state, const char *restrict src, union ipaddr_t *restrict dst)
Convert text string IP address from either IPv4 or IPv6 to an integer.
Definition: other.c:126
Definition: dhcpd-pools.h:161
double tcp
Definition: dhcpd-pools.h:152
Definition: dhcpd-pools.h:99
Definition: dhcpd-pools.h:88
void do_counting(struct conf_t *state)
Perform counting.
Definition: analyze.c:60
__BEGIN_DECLS char * optarg
Definition: getopt.c:89
const char * output_file
Output file path.
Definition: dhcpd-pools.h:219
char * ethernet
Definition: dhcpd-pools.h:171
limbits
Output limit bits.
Definition: dhcpd-pools.h:178
double bup
Definition: dhcpd-pools.h:153
int(* ipcomp)(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b)
Definition: dhcpd-pools.c:64
int(* leasecomp)(const struct leases_t *restrict a, const struct leases_t *restrict b)
Definition: dhcpd-pools.c:65
double(* get_range_size)(const struct range_t *r)
Definition: dhcpd-pools.c:62
All networks summary limit.
Definition: dhcpd-pools.h:181
Counters for an individual range.
Definition: dhcpd-pools.h:135
double backups
Definition: dhcpd-pools.h:141
double warn_count
Maximum number of free IP's before warning.
Definition: dhcpd-pools.h:223
int rangecomp(const void *restrict r1, const void *restrict r2) __attribute__((nonnull(1
int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b)
Definition: sort.c:74
struct shared_network_t * next
Definition: dhcpd-pools.h:129
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.
Definition: getdata.c:202
int ipcomp_init(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b)
struct output_sort * next
Definition: dhcpd-pools.h:201
int xstrstr_v6(struct conf_t *state, const char *restrict str)
int comp_max(struct range_t *r1, struct range_t *r2)
Compare two range_t by their capacity.
Definition: sort.c:137
double backups
Definition: dhcpd-pools.h:127
comparer_t field_selector(char c)
Sort field selector.
Definition: sort.c:221
Runtime configuration state.
Definition: dhcpd-pools.h:207
Definition: dhcpd-pools.h:113
double ret_tcperc(struct range_t r)
Return percentage of addresses touched and in use in range.
Definition: sort.c:209
Definition: dhcpd-pools.h:87
int(* xstrstr)(struct conf_t *state, const char *restrict str)
Definition: dhcpd-pools.c:63
Definition: dhcpd-pools.h:114
int int comp_cur(struct range_t *r1, struct range_t *r2)
Compare two range_t by their current usage.
Definition: sort.c:146
Definition: dhcpd-pools.h:162
Definition: dhcpd-pools.h:104
double get_range_size_v4(const struct range_t *r)
Definition: other.c:328
Definition: dhcpd-pools.h:105
void clean_up(struct conf_t *state)
Free memory, flush buffers etc.
Definition: other.c:528
Counters for an individual shared network.
Definition: dhcpd-pools.h:122
struct leases_t * find_lease_v4(struct conf_t *state, union ipaddr_t *addr)
Definition: hash.c:92
double ret_tc(struct range_t r)
Touched and in use in range.
Definition: sort.c:200
struct output_sort * sorts
Linked list how to sort ranges.
Definition: dhcpd-pools.h:218
int comp_double(double f1, double f2)
Compare two doubles.
Definition: sort.c:119
void add_lease_v4(struct conf_t *state, union ipaddr_t *addr, enum ltype type)
Definition: hash.c:60
double available
Definition: dhcpd-pools.h:124
void mergesort_ranges(struct conf_t *state, struct range_t *restrict orig, unsigned int size, struct range_t *restrict temp, const int root_call)
Mergesort for range table.
Definition: sort.c:279
Definition: dhcpd-pools.h:100
double tc
Definition: dhcpd-pools.h:151
ltype
Lease state types.
Definition: dhcpd-pools.h:159
unsigned char v6[16]
Definition: dhcpd-pools.h:79
comparer_t func
Definition: dhcpd-pools.h:200
#define uint32_t
Definition: stdint.in.h:168
int parse_leases(struct conf_t *state, const int print_mac_addreses)
Lease file parser.
Definition: getdata.c:82
int parse_ipaddr_v6(struct conf_t *state, const char *restrict src, union ipaddr_t *restrict dst)
int leasecomp_init(const struct leases_t *restrict a __attribute__((unused)), const struct leases_t *restrict b __attribute__((unused)))
Compare IP address in leases_t structure, with IPv4/v6 determination.
Definition: sort.c:84
int mustach_dhcpd_pools(struct conf_t *state)
Start mustach processing.
Definition: mustach-dhcpd-pools.c:399
Default, use colors when output terminal is interactive.
Definition: dhcpd-pools.h:115
int shnet_output_helper(struct conf_t *state, struct output_helper_t *oh, struct shared_network_t *shared_p)
Calculate shared network percentages and such.
Definition: output.c:136
UT_hash_handle hh
Definition: dhcpd-pools.h:172
void copy_ipaddr_init(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src)
unsigned int snet_alarms
Suppress alarming thresholds for ranges that are part of a shared network.
Definition: dhcpd-pools.h:227
void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src)
Definition: other.c:274
double count
Definition: dhcpd-pools.h:139
int output_format
Column to use in color_tags array.
Definition: dhcpd-pools.h:217
int comp_tc(struct range_t *r1, struct range_t *r2)
Compare two range_t by their touched and in use addresses.
Definition: sort.c:173
#define restrict
Definition: config.h:1858
int comp_percent(struct range_t *r1, struct range_t *r2)
Compare two range_t by their current usage percentage.
Definition: sort.c:155
struct range_t * ranges
Array of ranges.
Definition: dhcpd-pools.h:210
dhcp_version
The IP version, IPv4 or IPv6, served by the dhcpd.
Definition: dhcpd-pools.h:85
const char * ntop_ipaddr_init(const union ipaddr_t *ip)
int range_output_helper(struct conf_t *state, struct output_helper_t *oh, struct range_t *range_p)
Calculate range percentages and such.
Definition: output.c:98
int xstrstr_v4(struct conf_t *state, const char *restrict str)
void(* copy_ipaddr)(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src)
Definition: dhcpd-pools.c:60
Definition: dhcpd-pools.h:98
int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b)
Definition: sort.c:65
double minsize
Minimum size of range or shared network to be considered exceeding threshold.
Definition: dhcpd-pools.h:225
double used
Definition: dhcpd-pools.h:125
double strtod_or_err(const char *restrict str, const char *restrict errmesg)
Return a double floating point value.
Definition: other.c:496
void flip_ranges(struct conf_t *state)
Reverse range.
Definition: other.c:515
double touched
Definition: dhcpd-pools.h:126
Definition: dhcpd-pools.h:160
void dp_time_tool(FILE *file, const char *path, int epoch)
Print a time stamp of a path or now to output file.
Definition: other.c:550