dhcpd-pools
3.0
ISC dhcpd lease usage analyser
|
Collection of various functions. More...
#include <config.h>
#include <arpa/inet.h>
#include <errno.h>
#include <limits.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "error.h"
#include "progname.h"
#include "quote.h"
#include "xalloc.h"
#include "dhcpd-pools.h"
Macros | |
#define | stringify(s) #s |
#define | stringify_value(s) stringify(s) |
Functions | |
static char * | cidr_last_v4 (union ipaddr_t *restrict addr, const int mask) |
Find last address in IPv4 range by using cidr format. More... | |
static char * | cidr_last_v6 (union ipaddr_t *restrict addr, const int mask) |
Find last address in IPv6 range by using cidr format. More... | |
void | set_ipv_functions (struct conf_t *state, int version) |
Set function pointers depending on IP version. More... | |
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. More... | |
int | parse_ipaddr_v4 (struct conf_t *state __attribute__((unused)), const char *restrict src, union ipaddr_t *restrict dst) |
int | parse_ipaddr_v6 (struct conf_t *state __attribute__((unused)), const char *restrict src, union ipaddr_t *restrict dst) |
static int | strtol_mask (const char *str) |
Convert string to a desimal format network marks. More... | |
void | parse_cidr (struct conf_t *state, struct range_t *range_p, const char *word) |
Convert a cidr notated address to a range. More... | |
void | copy_ipaddr_init (union ipaddr_t *restrict dst __attribute__((unused)), const union ipaddr_t *restrict src __attribute__((unused))) |
Copy IP address to union. More... | |
void | copy_ipaddr_v4 (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) |
void | copy_ipaddr_v6 (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) |
const char * | ntop_ipaddr_init (const union ipaddr_t *ip __attribute__((unused))) |
Convert an address to string. More... | |
const char * | ntop_ipaddr_v4 (const union ipaddr_t *ip) |
const char * | ntop_ipaddr_v6 (const union ipaddr_t *ip) |
double | get_range_size_init (const struct range_t *r __attribute__((unused))) |
Calculate how many addresses there are in a range. More... | |
double | get_range_size_v4 (const struct range_t *r) |
double | get_range_size_v6 (const struct range_t *r) |
int | xstrstr_init (struct conf_t *state, const char *restrict str) |
int | xstrstr_v4 (struct conf_t *state __attribute__((unused)), const char *restrict str) |
int | xstrstr_v6 (struct conf_t *state __attribute__((unused)), const char *restrict str) |
int | parse_color_mode (const char *restrict optarg) |
Parse option argument color mode. More... | |
double | strtod_or_err (const char *restrict str, const char *restrict errmesg) |
Return a double floating point value. More... | |
void | flip_ranges (struct conf_t *state) |
Reverse range. More... | |
void | clean_up (struct conf_t *state) |
Free memory, flush buffers etc. More... | |
void | dp_time_tool (FILE *file, const char *path, int epoch) |
Print a time stamp of a path or now to output file. More... | |
void | __attribute__ ((__noreturn__)) |
A version printing. More... | |
Variables | |
char *(* | cidr_last )(union ipaddr_t *restrict addr, const int mask) |
Collection of various functions.
#define stringify | ( | s | ) | #s |
#define stringify_value | ( | s | ) | stringify(s) |
Referenced by __attribute__().
void __attribute__ | ( | (__noreturn__) | ) |
Find last address in IPv4 range by using cidr format.
addr | Pointer to memory where address needs to be stored. |
Referenced by set_ipv_functions().
Find last address in IPv6 range by using cidr format.
addr | Pointer to memory where address needs to be stored. |
Referenced by set_ipv_functions().
void clean_up | ( | struct conf_t * | state | ) |
void copy_ipaddr_init | ( | union ipaddr_t *restrict dst | __attribute__(unused), |
const union ipaddr_t *restrict src | __attribute__(unused) | ||
) |
Copy IP address to union.
dst | Destination for a binary IP address. |
src | Sourse of an IP address. |
Referenced by set_ipv_functions().
Referenced by set_ipv_functions().
Referenced by set_ipv_functions().
void dp_time_tool | ( | FILE * | file, |
const char * | path, | ||
int | epoch | ||
) |
Print a time stamp of a path or now to output file.
Referenced by html_header(), must_put_base(), must_put_range(), must_put_shnet(), and output_json().
void flip_ranges | ( | struct conf_t * | state | ) |
Reverse range.
Used before output, if a caller has requested reverse sorting.
Referenced by main().
double get_range_size_init | ( | const struct range_t *r | __attribute__(unused) | ) |
Calculate how many addresses there are in a range.
r | Pointer to range structure, which has information about first and last IP in the range. |
Referenced by set_ipv_functions().
double get_range_size_v4 | ( | const struct range_t * | r | ) |
Referenced by set_ipv_functions().
double get_range_size_v6 | ( | const struct range_t * | r | ) |
Referenced by set_ipv_functions().
const char* ntop_ipaddr_init | ( | const union ipaddr_t *ip | __attribute__(unused) | ) |
Convert an address to string.
This function will convert the IPv4 addresses to 123.45.65.78 format, and the IPv6 addresses to it's native format depending on which version of the addressing is found to be in use.
ip | Binary IP address. |
Referenced by set_ipv_functions().
const char* ntop_ipaddr_v4 | ( | const union ipaddr_t * | ip | ) |
Referenced by set_ipv_functions().
const char* ntop_ipaddr_v6 | ( | const union ipaddr_t * | ip | ) |
Referenced by set_ipv_functions().
Convert a cidr notated address to a range.
range_p | Pointer to memory where addresses need to be stored. |
word | A range as a cidr string. |
Referenced by parse_config().
int parse_color_mode | ( | const char *restrict | optarg | ) |
Parse option argument color mode.
Color | mode string. |
Referenced by parse_command_line_opts().
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.
src | An IP string in either format. |
dst | An union which will hold conversion result. |
Referenced by set_ipv_functions().
int parse_ipaddr_v4 | ( | struct conf_t *state | __attribute__(unused), |
const char *restrict | src, | ||
union ipaddr_t *restrict | dst | ||
) |
Referenced by set_ipv_functions().
void set_ipv_functions | ( | struct conf_t * | state, |
int | version | ||
) |
Set function pointers depending on IP version.
ip | IP version. |
Referenced by main(), parse_cidr(), parse_command_line_opts(), parse_ipaddr_init(), and xstrstr_init().
Return a double floating point value.
str | String to be converted to a double. |
errmesg | Exit error message if conversion fails. |
Referenced by parse_command_line_opts().
|
static |
Convert string to a desimal format network marks.
src | Digit that should be a network mask. |
Referenced by parse_cidr().
Referenced by set_ipv_functions().
Referenced by parse_cidr(), and set_ipv_functions().