ISC DHCP  4.3.5
A reference DHCPv4 and DHCPv6 implementation
dhclient.c File Reference
#include "dhcpd.h"
#include <syslog.h>
#include <signal.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <limits.h>
#include <isc/file.h>
#include <dns/result.h>

Go to the source code of this file.

Macros

#define ASSERT_STATE(state_is, state_shouldbe)   {}
 

Functions

int asprintf (char **strp, const char *fmt,...)
 
void run_stateless (int exit_mode, u_int16_t port)
 
int main (int argc, char **argv)
 
isc_result_t find_class (struct class **c, const char *s, const char *file, int line)
 
int check_collection (struct packet *packet, struct lease *lease, struct collection *collection)
 
void classify (struct packet *packet, struct class *class)
 
void unbill_class (struct lease *lease)
 
int find_subnet (struct subnet **sp, struct iaddr addr, const char *file, int line)
 
void state_reboot (void *cpp)
 
void state_init (void *cpp)
 
void state_selecting (void *cpp)
 
void dhcpack (struct packet *packet)
 
void bind_lease (struct client_state *client)
 
void state_bound (void *cpp)
 
void state_stop (void *cpp)
 
int commit_leases ()
 
int write_lease (struct lease *lease)
 
int write_host (struct host_decl *host)
 
void db_startup (int testp)
 
void bootp (struct packet *packet)
 
void dhcp (struct packet *packet)
 
void dhcpoffer (struct packet *packet)
 
struct client_leasepacket_to_lease (struct packet *packet, struct client_state *client)
 
void dhcpnak (struct packet *packet)
 
void send_discover (void *cpp)
 
void state_panic (void *cpp)
 
void send_request (void *cpp)
 
void send_decline (void *cpp)
 
void send_release (void *cpp)
 
void make_client_options (struct client_state *client, struct client_lease *lease, u_int8_t *type, struct option_cache *sid, struct iaddr *rip, struct option **prl, struct option_state **op)
 
void make_discover (struct client_state *client, struct client_lease *lease)
 
void make_request (struct client_state *client, struct client_lease *lease)
 
void make_decline (struct client_state *client, struct client_lease *lease)
 
void make_release (struct client_state *client, struct client_lease *lease)
 
void destroy_client_lease (struct client_lease *lease)
 
void rewrite_client_leases ()
 
void write_lease_option (struct option_cache *oc, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff)
 
int unhexchar (char c)
 
isc_result_t read_uuid (u_int8_t *uuid)
 
isc_result_t form_duid (struct data_string *duid, const char *file, int line)
 
isc_result_t write_client6_lease (struct client_state *client, struct dhc6_lease *lease, int rewrite, int sync)
 
int write_client_lease (struct client_state *client, struct client_lease *lease, int rewrite, int makesure)
 
void script_init (struct client_state *client, const char *reason, struct string_list *medium)
 
void client_option_envadd (struct option_cache *oc, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff)
 
void script_write_params (struct client_state *client, const char *prefix, struct client_lease *lease)
 
void script_write_requested (struct client_state *client)
 
int script_go (struct client_state *client)
 
void client_envadd (struct client_state *client, const char *prefix, const char *name, const char *fmt,...)
 
int dhcp_option_ev_name (char *buf, size_t buflen, struct option *option)
 
void go_daemon ()
 
void write_client_pid_file ()
 
void client_location_changed ()
 
void do_release (struct client_state *client)
 
int dhclient_interface_shutdown_hook (struct interface_info *interface)
 
int dhclient_interface_discovery_hook (struct interface_info *tmp)
 
isc_result_t dhclient_interface_startup_hook (struct interface_info *interface)
 
int parse_agent_information_option (struct packet *packet, int len, u_int8_t *data)
 
unsigned cons_agent_information_options (struct option_state *cfg_options, struct dhcp_packet *outpacket, unsigned agentix, unsigned length)
 
isc_result_t dhcp_set_control_state (control_object_state_t oldstate, control_object_state_t newstate)
 
void dhcpv4_client_assignments (void)
 

Variables

TIME default_lease_time = 43200
 
TIME max_lease_time = 86400
 
const char * path_dhclient_conf = _PATH_DHCLIENT_CONF
 
const char * path_dhclient_db = NULL
 
const char * path_dhclient_pid = NULL
 
char * path_dhclient_script = path_dhclient_script_array
 
const char * path_dhclient_duid = NULL
 
isc_boolean_t no_pid_file = ISC_FALSE
 
int dhcp_max_agent_option_packet_length = 0
 
int interfaces_requested = 0
 
struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }
 
struct iaddr iaddr_any = { 4, { 0, 0, 0, 0 } }
 
struct in_addr inaddr_any
 
struct sockaddr_in sockaddr_broadcast
 
struct in_addr giaddr
 
struct data_string default_duid
 
int duid_type = 0
 
int duid_v4 = 1
 
int std_dhcid = 0
 
u_int16_t local_port = 0
 
u_int16_t remote_port = 0
 
int no_daemon = 0
 
struct string_listclient_env = NULL
 
int client_env_count = 0
 
int onetry = 0
 
int quiet = 1
 
int nowait = 0
 
int stateless = 0
 
int wanted_ia_na = -1
 
int wanted_ia_ta = 0
 
int wanted_ia_pd = 0
 
int require_all_ias = 0
 
char * mockup_relay = NULL
 
char * progname = NULL
 
int bootp_broadcast_always = 0
 
struct optiondefault_requested_options []
 
FILE * leaseFile = NULL
 
int leases_written = 0
 
char scriptName [256]
 
FILE * scriptFile
 

Macro Definition Documentation

◆ ASSERT_STATE

#define ASSERT_STATE (   state_is,
  state_shouldbe 
)    {}

Definition at line 82 of file dhclient.c.

Function Documentation

◆ asprintf()

int asprintf ( char **  strp,
const char *  fmt,
  ... 
)

◆ bind_lease()

void bind_lease ( struct client_state client)

Definition at line 1824 of file dhclient.c.

◆ bootp()

void bootp ( struct packet packet)

Definition at line 1987 of file dhclient.c.

◆ check_collection()

int check_collection ( struct packet packet,
struct lease lease,
struct collection collection 
)

Definition at line 1403 of file dhclient.c.

◆ classify()

void classify ( struct packet packet,
struct class class 
)

Definition at line 1411 of file dhclient.c.

◆ client_envadd()

void client_envadd ( struct client_state client,
const char *  prefix,
const char *  name,
const char *  fmt,
  ... 
)

Definition at line 4692 of file dhclient.c.

◆ client_location_changed()

void client_location_changed ( void  )

Definition at line 4834 of file dhclient.c.

◆ client_option_envadd()

void client_option_envadd ( struct option_cache oc,
struct packet packet,
struct lease lease,
struct client_state client_state,
struct option_state in_options,
struct option_state cfg_options,
struct binding_scope **  scope,
struct universe u,
void *  stuff 
)

Definition at line 4431 of file dhclient.c.

◆ commit_leases()

int commit_leases ( void  )

Definition at line 1965 of file dhclient.c.

◆ cons_agent_information_options()

unsigned cons_agent_information_options ( struct option_state cfg_options,
struct dhcp_packet outpacket,
unsigned  agentix,
unsigned  length 
)

Definition at line 5058 of file dhclient.c.

◆ db_startup()

void db_startup ( int  testp)

Definition at line 1982 of file dhclient.c.

◆ destroy_client_lease()

void destroy_client_lease ( struct client_lease lease)

Definition at line 3782 of file dhclient.c.

◆ dhclient_interface_discovery_hook()

int dhclient_interface_discovery_hook ( struct interface_info tmp)

Definition at line 4953 of file dhclient.c.

◆ dhclient_interface_shutdown_hook()

int dhclient_interface_shutdown_hook ( struct interface_info interface)

Definition at line 4946 of file dhclient.c.

◆ dhclient_interface_startup_hook()

isc_result_t dhclient_interface_startup_hook ( struct interface_info interface)

Definition at line 4996 of file dhclient.c.

◆ dhcp()

void dhcp ( struct packet packet)

Definition at line 2020 of file dhclient.c.

◆ dhcp_option_ev_name()

int dhcp_option_ev_name ( char *  buf,
size_t  buflen,
struct option option 
)

Definition at line 4725 of file dhclient.c.

◆ dhcp_set_control_state()

isc_result_t dhcp_set_control_state ( control_object_state_t  oldstate,
control_object_state_t  newstate 
)

Definition at line 5145 of file dhclient.c.

◆ dhcpack()

void dhcpack ( struct packet packet)

Definition at line 1655 of file dhclient.c.

◆ dhcpnak()

void dhcpnak ( struct packet packet)

Definition at line 2565 of file dhclient.c.

◆ dhcpoffer()

void dhcpoffer ( struct packet packet)

Definition at line 2307 of file dhclient.c.

◆ dhcpv4_client_assignments()

void dhcpv4_client_assignments ( void  )

Definition at line 5534 of file dhclient.c.

◆ do_release()

void do_release ( struct client_state client)

Definition at line 4868 of file dhclient.c.

◆ find_class()

isc_result_t find_class ( struct class **  c,
const char *  s,
const char *  file,
int  line 
)

Definition at line 1397 of file dhclient.c.

◆ find_subnet()

int find_subnet ( struct subnet **  sp,
struct iaddr  addr,
const char *  file,
int  line 
)

Definition at line 1422 of file dhclient.c.

◆ form_duid()

isc_result_t form_duid ( struct data_string duid,
const char *  file,
int  line 
)

Definition at line 3982 of file dhclient.c.

◆ go_daemon()

void go_daemon ( void  )

Definition at line 4765 of file dhclient.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 205 of file dhclient.c.

◆ make_client_options()

void make_client_options ( struct client_state client,
struct client_lease lease,
u_int8_t *  type,
struct option_cache sid,
struct iaddr rip,
struct option **  prl,
struct option_state **  op 
)

Definition at line 3360 of file dhclient.c.

◆ make_decline()

void make_decline ( struct client_state client,
struct client_lease lease 
)

Definition at line 3665 of file dhclient.c.

◆ make_discover()

void make_discover ( struct client_state client,
struct client_lease lease 
)

Definition at line 3510 of file dhclient.c.

◆ make_release()

void make_release ( struct client_state client,
struct client_lease lease 
)

Definition at line 3725 of file dhclient.c.

◆ make_request()

void make_request ( struct client_state client,
struct client_lease lease 
)

Definition at line 3575 of file dhclient.c.

◆ packet_to_lease()

struct client_lease* packet_to_lease ( struct packet packet,
struct client_state client 
)

Definition at line 2442 of file dhclient.c.

◆ parse_agent_information_option()

int parse_agent_information_option ( struct packet packet,
int  len,
u_int8_t *  data 
)

Definition at line 5048 of file dhclient.c.

◆ read_uuid()

isc_result_t read_uuid ( u_int8_t *  uuid)

Definition at line 3929 of file dhclient.c.

◆ rewrite_client_leases()

void rewrite_client_leases ( void  )

Definition at line 3796 of file dhclient.c.

◆ run_stateless()

void run_stateless ( int  exit_mode,
u_int16_t  port 
)

Definition at line 1280 of file dhclient.c.

◆ script_go()

int script_go ( struct client_state client)

Definition at line 4611 of file dhclient.c.

◆ script_init()

void script_init ( struct client_state client,
const char *  reason,
struct string_list medium 
)

Definition at line 4400 of file dhclient.c.

◆ script_write_params()

void script_write_params ( struct client_state client,
const char *  prefix,
struct client_lease lease 
)

Definition at line 4472 of file dhclient.c.

◆ script_write_requested()

void script_write_requested ( struct client_state client)

Definition at line 4592 of file dhclient.c.

◆ send_decline()

void send_decline ( void *  cpp)

Definition at line 3083 of file dhclient.c.

◆ send_discover()

void send_discover ( void *  cpp)

Definition at line 2644 of file dhclient.c.

◆ send_release()

void send_release ( void *  cpp)

Definition at line 3122 of file dhclient.c.

◆ send_request()

void send_request ( void *  cpp)

Definition at line 2884 of file dhclient.c.

◆ state_bound()

void state_bound ( void *  cpp)

Definition at line 1899 of file dhclient.c.

◆ state_init()

void state_init ( void *  cpp)

Definition at line 1533 of file dhclient.c.

◆ state_panic()

void state_panic ( void *  cpp)

Definition at line 2774 of file dhclient.c.

◆ state_reboot()

void state_reboot ( void *  cpp)

Definition at line 1480 of file dhclient.c.

◆ state_selecting()

void state_selecting ( void *  cpp)

Definition at line 1570 of file dhclient.c.

◆ state_stop()

void state_stop ( void *  cpp)

Definition at line 1941 of file dhclient.c.

◆ unbill_class()

void unbill_class ( struct lease lease)

Definition at line 1417 of file dhclient.c.

◆ unhexchar()

int unhexchar ( char  c)

Definition at line 3914 of file dhclient.c.

◆ write_client6_lease()

isc_result_t write_client6_lease ( struct client_state client,
struct dhc6_lease lease,
int  rewrite,
int  sync 
)

Definition at line 4102 of file dhclient.c.

◆ write_client_lease()

int write_client_lease ( struct client_state client,
struct client_lease lease,
int  rewrite,
int  makesure 
)

Definition at line 4256 of file dhclient.c.

◆ write_client_pid_file()

void write_client_pid_file ( void  )

Definition at line 4807 of file dhclient.c.

◆ write_host()

int write_host ( struct host_decl host)

Definition at line 1976 of file dhclient.c.

◆ write_lease()

int write_lease ( struct lease lease)

Definition at line 1970 of file dhclient.c.

◆ write_lease_option()

void write_lease_option ( struct option_cache oc,
struct packet packet,
struct lease lease,
struct client_state client_state,
struct option_state in_options,
struct option_state cfg_options,
struct binding_scope **  scope,
struct universe u,
void *  stuff 
)

Definition at line 3858 of file dhclient.c.

Variable Documentation

◆ bootp_broadcast_always

int bootp_broadcast_always = 0

Definition at line 113 of file dhclient.c.

◆ client_env

struct string_list* client_env = NULL

Definition at line 97 of file dhclient.c.

◆ client_env_count

int client_env_count = 0

Definition at line 98 of file dhclient.c.

◆ default_duid

struct data_string default_duid

Definition at line 75 of file dhclient.c.

◆ default_lease_time

TIME default_lease_time = 43200

Definition at line 53 of file dhclient.c.

◆ default_requested_options

struct option* default_requested_options[]

Definition at line 36 of file clparse.c.

◆ dhcp_max_agent_option_packet_length

int dhcp_max_agent_option_packet_length = 0

Definition at line 66 of file dhclient.c.

◆ duid_type

int duid_type = 0

Definition at line 76 of file dhclient.c.

◆ duid_v4

int duid_v4 = 1

Definition at line 77 of file dhclient.c.

◆ giaddr

struct in_addr giaddr

Definition at line 74 of file dhclient.c.

◆ iaddr_any

struct iaddr iaddr_any = { 4, { 0, 0, 0, 0 } }

Definition at line 71 of file dhclient.c.

◆ iaddr_broadcast

struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } }

Definition at line 70 of file dhclient.c.

◆ inaddr_any

struct in_addr inaddr_any

Definition at line 72 of file dhclient.c.

◆ interfaces_requested

int interfaces_requested = 0

Definition at line 68 of file dhclient.c.

◆ leaseFile

FILE* leaseFile = NULL

Definition at line 3793 of file dhclient.c.

◆ leases_written

int leases_written = 0

Definition at line 3794 of file dhclient.c.

◆ local_port

u_int16_t local_port = 0

Definition at line 91 of file dhclient.c.

◆ max_lease_time

TIME max_lease_time = 86400

Definition at line 54 of file dhclient.c.

◆ mockup_relay

char* mockup_relay = NULL

Definition at line 109 of file dhclient.c.

◆ no_daemon

int no_daemon = 0

Definition at line 96 of file dhclient.c.

◆ no_pid_file

isc_boolean_t no_pid_file = ISC_FALSE

Definition at line 64 of file dhclient.c.

◆ nowait

int nowait = 0

Definition at line 101 of file dhclient.c.

◆ onetry

int onetry = 0

Definition at line 99 of file dhclient.c.

◆ path_dhclient_conf

const char* path_dhclient_conf = _PATH_DHCLIENT_CONF

Definition at line 56 of file dhclient.c.

◆ path_dhclient_db

const char* path_dhclient_db = NULL

Definition at line 57 of file dhclient.c.

◆ path_dhclient_duid

const char* path_dhclient_duid = NULL

Definition at line 61 of file dhclient.c.

◆ path_dhclient_pid

const char* path_dhclient_pid = NULL

Definition at line 58 of file dhclient.c.

◆ path_dhclient_script

char* path_dhclient_script = path_dhclient_script_array

Definition at line 60 of file dhclient.c.

◆ progname

char* progname = NULL

Definition at line 111 of file dhclient.c.

◆ quiet

int quiet = 1

Definition at line 100 of file dhclient.c.

◆ remote_port

u_int16_t remote_port = 0

Definition at line 92 of file dhclient.c.

◆ require_all_ias

int require_all_ias = 0

Definition at line 106 of file dhclient.c.

◆ scriptFile

FILE* scriptFile

Definition at line 4398 of file dhclient.c.

◆ scriptName

char scriptName[256]

Definition at line 4397 of file dhclient.c.

◆ sockaddr_broadcast

struct sockaddr_in sockaddr_broadcast

Definition at line 73 of file dhclient.c.

◆ stateless

int stateless = 0

Definition at line 102 of file dhclient.c.

◆ std_dhcid

int std_dhcid = 0

Definition at line 78 of file dhclient.c.

◆ wanted_ia_na

int wanted_ia_na = -1

Definition at line 103 of file dhclient.c.

◆ wanted_ia_pd

int wanted_ia_pd = 0

Definition at line 105 of file dhclient.c.

◆ wanted_ia_ta

int wanted_ia_ta = 0

Definition at line 104 of file dhclient.c.