#define LIBDHCP 1 |
typedef int(*) DHCP_Client(LIBDHCP_Control *, int argc, char **argv, char **envp) |
The function prototype of the DHCP client main() function or primary entry point, (renamed dhcpv4_client for the DHCPv4 client, and dhcpv6_client for the DHCPv6 client). Users must include the appropriate dhcpv{4,6}client.h header to obtain the declarations of these clients' entry points.
typedef enum dhcp_state_e DHCP_State |
The DHCP_state enum represents the states of the DHCP clients, that each client will call the user's call back for on a state change.
typedef int( *) LIBDHCP_Callback(struct libdhcp_control_s *control, enum dhcp_state_e state, void *arg) |
The DHCP client callback type. The DHCP clients will call the users' callback on important state change events, which is of this function type, and is passed in through the client control structure.
typedef enum libdhcp_capability_e LIBDHCP_Capability |
LIBDHCP_Capability
enum that defines the capabilities DHCP clients are allowed to exercise.
The DHCP_CONFIGURE* capabilities are supported by DHCPv6 in process, while the DHCPv4 client would fork and exec the dhclient-script to implement them if these bits are set - otherwise, if no bits are set, the callback is called and the script is not run.
typedef struct libdhcp_control_s LIBDHCP_Control |
LIBDHCP_Control
The libdhcp DHCP client control structure. Each client is called with a pointer to this structure as the first argument to its main dhcp*_client function. This structure specifies what the client is allowed to do and how it will communicate state changes to the calling code.
typedef int( *) LIBDHCP_Error_Handler(struct libdhcp_control_s *ctl, int priority, const char *fmt, va_list ap) |
The libdhcp error handler / logger callback type. The DHCP clients, and parts of libdhcp, that need to report / log an error condition will call a function of this type, passed in through the control structure. No DHCP client or libdhcp code will do any logging unless a non-zero pointer to a function of this type is recorded in the ctl->eh member.
enum dhcp_state_e |
The DHCP_state enum represents the states of the DHCP clients, that each client will call the user's call back for on a state change.
enum libdhcp_capability_e |
LIBDHCP_Capability
enum that defines the capabilities DHCP clients are allowed to exercise.
The DHCP_CONFIGURE* capabilities are supported by DHCPv6 in process, while the DHCPv4 client would fork and exec the dhclient-script to implement them if these bits are set - otherwise, if no bits are set, the callback is called and the script is not run.
int libdhcp_call_client | ( | LIBDHCP_Control * | , | |
DHCP_Client | , | |||
... | ||||
) |
calls the dhcpv{4,6}_client function with the arguments in the variable argument list.
Definition at line 61 of file libdhcp.c.
Referenced by do_dhcpv6().
LIBDHCP_Control* libdhcp_control_new | ( | LIBDHCP_Callback | callback, | |
LIBDHCP_Capability | dhc_cap, | |||
time_t | timeout, | |||
void * | arg, | |||
LIBDHCP_Error_Handler | error_handler, | |||
uint8_t | log_level | |||
) |
libdhcp_control_new - creates a new DHCP client control LIBDHCP_Control structure. The arguments correspond to the named LIBDHCP_Control structure members .
callback | the user's function to be called on state changes |
dhc_cap |
DHCP client capabilities to enable -
|
timeout | time period in seconds after which client must return |
arg | argument to pass to user's callback as third arg |
error_handler | the logger this client is to use |
log_level | the maximum log level to be logged by this client |
Definition at line 34 of file libdhcp.c.
References libdhcp_control_s::arg, libdhcp_control_s::callback, libdhcp_control_s::capability, libdhcp_control_s::eh, libdhcp_control_s::log_level, and libdhcp_control_s::timeout.
char* libdhcp_state_string | ( | DHCP_State | , | |
char * | buf | |||
) |
function to convert a DHCP_State to a string.
Definition at line 84 of file libdhcp.c.
References DHC4_BOUND, DHC4_EXPIRE, DHC4_FAIL, DHC4_MEDIUM, DHC4_NBI, DHC4_PREINIT, DHC4_REBIND, DHC4_REBOOT, DHC4_RELEASE, DHC4_RENEW, DHC4_STOP, DHC4_TIMEOUT, DHC6_BOUND, DHC6_REBIND, DHC6_RELEASE, and DHC_TIMEDOUT.
Referenced by dhcp4_nic_callback(), and dhcp6_nic_callback().
int libdhcp_stderr_logger | ( | struct libdhcp_control_s * | ctl, | |
int | priority, | |||
const char * | fmt, | |||
va_list | ap | |||
) |
default error handler that logs to stderr.
Definition at line 131 of file libdhcp.c.
References LOG_FATAL, and libdhcp_control_s::log_level.
int libdhcp_syslogger | ( | struct libdhcp_control_s * | ctl, | |
int | priority, | |||
const char * | fmt, | |||
va_list | ap | |||
) |
default error handler that logs to syslog.
Definition at line 167 of file libdhcp.c.
References LOG_FATAL, and libdhcp_control_s::log_level.