The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
dhcpclient.c File Reference
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/server/packet.h>
#include <freeradius-devel/dhcpv4/dhcpv4.h>
#include <freeradius-devel/util/pcap.h>
#include <ctype.h>
#include <assert.h>
#include <net/if.h>
+ Include dependency graph for dhcpclient.c:

Go to the source code of this file.

Data Structures

struct  dc_offer_t
 

Macros

#define DEBUG(fmt, ...)   if (fr_debug_lvl > 0) fprintf(stdout, fmt "\n", ## __VA_ARGS__)
 
#define ERROR(fmt, ...)   fr_perror("dhcpclient: " fmt, ## __VA_ARGS__)
 

Functions

static void dhcp_packet_debug (fr_packet_t *packet, fr_pair_list_t *list, bool received)
 
int main (int argc, char **argv)
 
static int request_init (fr_packet_t **out, fr_pair_list_t *packet_vps, char const *filename)
 
static int send_with_socket (fr_packet_t **reply, fr_packet_t *request, UNUSED fr_pair_list_t *request_list)
 
static NEVER_RETURNS void usage (void)
 

Variables

static fr_dict_attr_t const * attr_dhcp_dhcp_server_identifier
 
static fr_dict_attr_t const * attr_dhcp_message_type
 
static fr_dict_attr_t const * attr_dhcp_your_ip_address
 
static fr_dict_attr_t const * attr_packet_type
 
fr_dict_autoload_t dhcpclient_dict []
 
fr_dict_attr_autoload_t dhcpclient_dict_attr []
 
static char const * dhcpclient_version = RADIUSD_VERSION_BUILD("dhcpclient")
 
static fr_dict_t const * dict_dhcpv4
 
static fr_dict_t const * dict_freeradius
 
static char * iface = NULL
 
static int iface_ind = -1
 
static bool raw_mode = false
 
static bool reply_expected = true
 
static fr_table_num_sorted_t const request_types []
 
static size_t request_types_len = NUM_ELEMENTS(request_types)
 
static int retries = 3
 
static int sockfd
 
static fr_time_delta_t timeout
 

Data Structure Documentation

◆ dc_offer_t

struct dc_offer_t

Definition at line 74 of file dhcpclient.c.

Data Fields
uint32_t offered_addr
uint32_t server_addr

Macro Definition Documentation

◆ DEBUG

#define DEBUG (   fmt,
  ... 
)    if (fr_debug_lvl > 0) fprintf(stdout, fmt "\n", ## __VA_ARGS__)

Definition at line 39 of file dhcpclient.c.

◆ ERROR

#define ERROR (   fmt,
  ... 
)    fr_perror("dhcpclient: " fmt, ## __VA_ARGS__)

Definition at line 41 of file dhcpclient.c.

Function Documentation

◆ dhcp_packet_debug()

static void dhcp_packet_debug ( fr_packet_t packet,
fr_pair_list_t list,
bool  received 
)
static

Definition at line 465 of file dhcpclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 521 of file dhcpclient.c.

+ Here is the call graph for this function:

◆ request_init()

static int request_init ( fr_packet_t **  out,
fr_pair_list_t packet_vps,
char const *  filename 
)
static

Definition at line 136 of file dhcpclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_with_socket()

static int send_with_socket ( fr_packet_t **  reply,
fr_packet_t request,
UNUSED fr_pair_list_t request_list 
)
static

Definition at line 329 of file dhcpclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ usage()

static NEVER_RETURNS void usage ( void  )
static

Definition at line 114 of file dhcpclient.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ attr_dhcp_dhcp_server_identifier

fr_dict_attr_t const* attr_dhcp_dhcp_server_identifier
static

Definition at line 91 of file dhcpclient.c.

◆ attr_dhcp_message_type

fr_dict_attr_t const* attr_dhcp_message_type
static

Definition at line 90 of file dhcpclient.c.

◆ attr_dhcp_your_ip_address

fr_dict_attr_t const* attr_dhcp_your_ip_address
static

Definition at line 92 of file dhcpclient.c.

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type
static

Definition at line 89 of file dhcpclient.c.

◆ dhcpclient_dict

fr_dict_autoload_t dhcpclient_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_dhcpv4, .proto = "dhcpv4" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: dhcpclient.c:79
static fr_dict_t const * dict_dhcpv4
Definition: dhcpclient.c:80

Definition at line 83 of file dhcpclient.c.

◆ dhcpclient_dict_attr

fr_dict_attr_autoload_t dhcpclient_dict_attr
Initial value:
= {
{ .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_dhcpv4 },
{ .out = &attr_dhcp_message_type, .name = "Message-Type", .type = FR_TYPE_UINT8, .dict = &dict_dhcpv4},
{ .out = &attr_dhcp_dhcp_server_identifier, .name = "Server-Identifier", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_dhcpv4 },
{ .out = &attr_dhcp_your_ip_address, .name = "Your-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_dhcpv4 },
{ NULL }
}
static fr_dict_attr_t const * attr_packet_type
Definition: dhcpclient.c:89
static fr_dict_attr_t const * attr_dhcp_message_type
Definition: dhcpclient.c:90
static fr_dict_attr_t const * attr_dhcp_your_ip_address
Definition: dhcpclient.c:92
static fr_dict_attr_t const * attr_dhcp_dhcp_server_identifier
Definition: dhcpclient.c:91
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
Definition: merged_model.c:86
@ FR_TYPE_UINT8
8 Bit unsigned integer.
Definition: merged_model.c:97
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99

Definition at line 95 of file dhcpclient.c.

◆ dhcpclient_version

char const* dhcpclient_version = RADIUSD_VERSION_BUILD("dhcpclient")
static

Definition at line 71 of file dhcpclient.c.

◆ dict_dhcpv4

fr_dict_t const* dict_dhcpv4
static

Definition at line 80 of file dhcpclient.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 79 of file dhcpclient.c.

◆ iface

char* iface = NULL
static

Definition at line 61 of file dhcpclient.c.

◆ iface_ind

int iface_ind = -1
static

Definition at line 62 of file dhcpclient.c.

◆ raw_mode

bool raw_mode = false
static

Definition at line 68 of file dhcpclient.c.

◆ reply_expected

bool reply_expected = true
static

Definition at line 69 of file dhcpclient.c.

◆ request_types

fr_table_num_sorted_t const request_types[]
static
Initial value:
= {
{ L("auto"), 0 },
{ L("decline"), FR_DHCP_DECLINE },
{ L("discover"), FR_DHCP_DISCOVER },
{ L("inform"), FR_DHCP_INFORM },
{ L("lease_query"), FR_DHCP_LEASE_QUERY },
{ L("release"), FR_DHCP_RELEASE },
{ L("request"), FR_DHCP_REQUEST }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207
@ FR_DHCP_REQUEST
Definition: dhcpv4.h:47
@ FR_DHCP_DECLINE
Definition: dhcpv4.h:48
@ FR_DHCP_DISCOVER
Definition: dhcpv4.h:45
@ FR_DHCP_LEASE_QUERY
Definition: dhcpv4.h:54
@ FR_DHCP_RELEASE
Definition: dhcpv4.h:51
@ FR_DHCP_INFORM
Definition: dhcpv4.h:52

Definition at line 103 of file dhcpclient.c.

◆ request_types_len

size_t request_types_len = NUM_ELEMENTS(request_types)
static

Definition at line 112 of file dhcpclient.c.

◆ retries

int retries = 3
static

Definition at line 53 of file dhcpclient.c.

◆ sockfd

int sockfd
static

Definition at line 56 of file dhcpclient.c.

◆ timeout

fr_time_delta_t timeout
static

Definition at line 54 of file dhcpclient.c.