dhcpd-pools  2.28
ISC dhcpd lease usage analyser
Functions
other.c File Reference

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 <unistd.h>
#include "error.h"
#include "progname.h"
#include "quote.h"
#include "dhcpd-pools.h"
#include "defaults.h"
Include dependency graph for other.c:

Functions

void set_ipv_functions (int version)
 Set function pointers depending on IP version. More...
 
int parse_ipaddr_init (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 (const char *restrict src, union ipaddr_t *restrict dst)
 
int parse_ipaddr_v6 (const char *restrict src, union ipaddr_t *restrict dst)
 
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 (const char *restrict str)
 Determine if the dhcpd is in IPv4 or IPv6 mode. More...
 
int xstrstr_v4 (const char *restrict str)
 parse lease file in IPv4 mode More...
 
int xstrstr_v6 (const char *restrict str)
 
double strtod_or_err (const char *restrict str, const char *restrict errmesg)
 Return a double floating point value. More...
 
void flip_ranges (struct range_t *restrict flip_me, struct range_t *restrict tmp_ranges)
 Reverse range. More...
 
void clean_up (void)
 Free memory, flush buffers etc. More...
 
void __attribute__ ((__noreturn__))
 A version printing. More...
 

Detailed Description

Collection of various functions.

Function Documentation

void __attribute__ ( (__noreturn__)  )

A version printing.

Command line help screen.

void clean_up ( void  )

Free memory, flush buffers etc.

Referenced by field_selector(), main(), and return_limit().

Here is the call graph for this function:

void copy_ipaddr_init ( union ipaddr_t *restrict dst   __attribute__(unused),
const union ipaddr_t *restrict src   __attribute__(unused) 
)

Copy IP address to union.

Parameters
dstDestination for a binary IP address.
srcSourse of an IP address.

Referenced by set_ipv_functions().

void copy_ipaddr_v4 ( union ipaddr_t *restrict  dst,
const union ipaddr_t *restrict  src 
)

Referenced by set_ipv_functions().

void copy_ipaddr_v6 ( union ipaddr_t *restrict  dst,
const union ipaddr_t *restrict  src 
)

Referenced by set_ipv_functions().

void flip_ranges ( struct range_t *restrict  flip_me,
struct range_t *restrict  tmp_ranges 
)

Reverse range.

Used before output, if a caller has requested reverse sorting. FIXME: The temporary memory area handling should be internal to this function, not a parameter.

Parameters
flip_meThe range that needs to be inverted.
tmp_rangesTemporary memory area for the flip.
double get_range_size_init ( const struct range_t *r   __attribute__(unused))

Calculate how many addresses there are in a range.

Parameters
rPointer to range structure, which has information about first and last IP in the range.
Returns
Size of a 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.

Parameters
ipBinary IP address.
Returns
Printable 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().

int parse_ipaddr_init ( const char *restrict  src,
union ipaddr_t *restrict  dst 
)

Convert text string IP address from either IPv4 or IPv6 to an integer.

Parameters
srcAn IP string in either format.
dstAn union which will hold conversion result.
Returns
Was parsing successful.

Referenced by set_ipv_functions().

Here is the call graph for this function:

int parse_ipaddr_v4 ( const char *restrict  src,
union ipaddr_t *restrict  dst 
)

Referenced by set_ipv_functions().

int parse_ipaddr_v6 ( const char *restrict  src,
union ipaddr_t *restrict  dst 
)

Referenced by set_ipv_functions().

Here is the call graph for this function:

void set_ipv_functions ( int  version)

Set function pointers depending on IP version.

Parameters
ipIP version.

Referenced by main(), parse_ipaddr_init(), and xstrstr_init().

Here is the call graph for this function:

double strtod_or_err ( const char *restrict  str,
const char *restrict  errmesg 
)

Return a double floating point value.

Parameters
strString to be converted to a double.
errmesgExit error message if conversion fails.
Returns
Binary result of string to double conversion.

Here is the call graph for this function:

xstrstr_init ( const char *restrict  str)

Determine if the dhcpd is in IPv4 or IPv6 mode.

This function may be needed when dhcpd.conf file has zero IP version hints.

Parameters
strA line from dhcpd.conf
Returns
prefix_t enum value

Referenced by set_ipv_functions().

Here is the call graph for this function:

xstrstr_v4 ( const char *restrict  str)

parse lease file in IPv4 mode

parse lease file in IPv6 mode

Parameters
strA line from dhcpd.conf
Returns
prefix_t enum value

Referenced by set_ipv_functions().

int xstrstr_v6 ( const char *restrict  str)

Referenced by set_ipv_functions().