Implementation of the DHCPv4 protocol.
More...
#include <freeradius-devel/util/pcap.h>
#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/protocol/dhcpv4/rfc2131.h>
Go to the source code of this file.
|
enum | fr_dhcpv4_attr_flags_prefix_t {
DHCPV4_FLAG_PREFIX_INVALID = -1
,
DHCPV4_FLAG_PREFIX_NONE = 0
,
DHCPV4_FLAG_PREFIX_BITS = 1
,
DHCPV4_FLAG_PREFIX_SPLIT = 2
} |
|
enum | fr_dhcpv4_packet_code_t {
FR_DHCP_INVALID = 0
,
FR_DHCP_DISCOVER = 1
,
FR_DHCP_OFFER = 2
,
FR_DHCP_REQUEST = 3
,
FR_DHCP_DECLINE = 4
,
FR_DHCP_ACK = 5
,
FR_DHCP_NAK = 6
,
FR_DHCP_RELEASE = 7
,
FR_DHCP_INFORM = 8
,
FR_DHCP_FORCE_RENEW = 9
,
FR_DHCP_LEASE_QUERY = 10
,
FR_DHCP_LEASE_UNASSIGNED = 11
,
FR_DHCP_LEASE_UNKNOWN = 12
,
FR_DHCP_LEASE_ACTIVE = 13
,
FR_DHCP_BULK_LEASE_QUERY = 14
,
FR_DHCP_LEASE_QUERY_DONE = 15
,
FR_DHCP_CODE_MAX = 16
,
FR_DHCP_DO_NOT_RESPOND = 256
} |
|
|
int8_t | fr_dhcpv4_attr_cmp (void const *a, void const *b) |
|
static fr_dhcpv4_attr_flags_t const * | fr_dhcpv4_attr_flags (fr_dict_attr_t const *da) |
|
int | fr_dhcpv4_decode (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, unsigned int *code) |
|
ssize_t | fr_dhcpv4_decode_foreign (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len) |
|
ssize_t | fr_dhcpv4_decode_option (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t len, void *decode_ctx) |
| Decode DHCP option.
|
|
ssize_t | fr_dhcpv4_encode (uint8_t *buffer, size_t buflen, dhcp_packet_t *original, int code, uint32_t xid, fr_pair_list_t *vps) |
|
ssize_t | fr_dhcpv4_encode_dbuff (fr_dbuff_t *dbuff, dhcp_packet_t *original, int code, uint32_t xid, fr_pair_list_t *vps) |
|
ssize_t | fr_dhcpv4_encode_foreign (fr_dbuff_t *dbuff, fr_pair_list_t const *list) |
|
ssize_t | fr_dhcpv4_encode_option (fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx) |
| Encode a DHCP option and any sub-options.
|
|
void | fr_dhcpv4_global_free (void) |
|
int | fr_dhcpv4_global_init (void) |
| Resolve/cache attributes in the DHCP dictionary.
|
|
bool | fr_dhcpv4_is_encodable (void const *item, void const *uctx) |
|
void * | fr_dhcpv4_next_encodable (fr_dlist_head_t *list, void *to_eval, void *uctx) |
| DHCPV4-specific iterator.
|
|
bool | fr_dhcpv4_ok (uint8_t const *data, ssize_t data_len, uint8_t *message_type, uint32_t *xid) |
| Check received DHCP request is valid and build fr_packet_t structure if it is.
|
|
fr_packet_t * | fr_dhcpv4_packet_alloc (uint8_t const *data, ssize_t data_len) |
|
int | fr_dhcpv4_packet_encode (fr_packet_t *packet, fr_pair_list_t *list) |
|
uint8_t const * | fr_dhcpv4_packet_get_option (dhcp_packet_t const *packet, size_t packet_size, fr_dict_attr_t const *da) |
| Retrieve a DHCP option from a raw packet buffer.
|
|
void | fr_dhcpv4_print_hex (FILE *fp, uint8_t const *packet, size_t packet_len) |
| Print a raw DHCP packet as hex.
|
|
fr_packet_t * | fr_dhcpv4_udp_packet_recv (int sockfd) |
| Receive DHCP packet using a connectionless UDP socket.
|
|
int | fr_dhcpv4_udp_packet_send (fr_packet_t *packet) |
| Send DHCP packet using a connectionless UDP socket.
|
|
Implementation of the DHCPv4 protocol.
- Id
- 59e4080fe806988ec13a8ec726c8c096d84f01c0
- Copyright
- 2008 The FreeRADIUS server project
-
2008 Alan DeKok (aland.nosp@m.@dep.nosp@m.loyin.nosp@m.grad.nosp@m.ius.c.nosp@m.om)
Definition in file dhcpv4.h.
◆ dhcp_packet_t
◆ fr_dhcpv4_attr_flags_t
struct fr_dhcpv4_attr_flags_t |
◆ fr_dhcpv4_ctx_t
Used as the decoder ctx.
Definition at line 134 of file dhcpv4.h.
Data Fields |
fr_dict_attr_t const * |
root |
|
TALLOC_CTX * |
tmp_ctx |
for temporary things cleaned up during decoding |
◆ DEFAULT_PACKET_SIZE
#define DEFAULT_PACKET_SIZE (300) |
◆ DHCP_CHADDR_LEN
◆ DHCP_FILE_FIELD
◆ DHCP_FILE_LEN
◆ DHCP_OPTION_FIELD
◆ DHCP_OPTION_MAGIC_NUMBER
#define DHCP_OPTION_MAGIC_NUMBER (0x63825363) |
◆ DHCP_PACK_OPTION1
#define DHCP_PACK_OPTION1 |
( |
|
x, |
|
|
|
y |
|
) |
| ((x) | ((y) << 8)) |
◆ DHCP_SNAME_FIELD
◆ DHCP_SNAME_LEN
◆ DHCP_UNPACK_OPTION1
#define DHCP_UNPACK_OPTION1 |
( |
|
x | ) |
(((x) & 0xff00) >> 8) |
◆ DHCP_VEND_LEN
◆ DHCPV4_MAX_ATTRIBUTES
#define DHCPV4_MAX_ATTRIBUTES 255 |
◆ ETH_ADDR_LEN
◆ FR_DHCP_PACKET_CODE_VALID
◆ fr_dhcpv4_flag_dns_label
◆ fr_dhcpv4_flag_exists
◆ fr_dhcpv4_flag_prefix
◆ fr_dhcpv4_flag_prefix_bits
◆ fr_dhcpv4_flag_prefix_split
◆ INADDR_BROADCAST
#define INADDR_BROADCAST INADDR_NONE |
◆ MAX_PACKET_SIZE
#define MAX_PACKET_SIZE (1500 - 40) |
◆ MIN_PACKET_SIZE
◆ fr_dhcpv4_attr_flags_prefix_t
Enumerator |
---|
DHCPV4_FLAG_PREFIX_INVALID | |
DHCPV4_FLAG_PREFIX_NONE | |
DHCPV4_FLAG_PREFIX_BITS | |
DHCPV4_FLAG_PREFIX_SPLIT | |
Definition at line 139 of file dhcpv4.h.
◆ fr_dhcpv4_packet_code_t
Enumerator |
---|
FR_DHCP_INVALID | |
FR_DHCP_DISCOVER | |
FR_DHCP_OFFER | |
FR_DHCP_REQUEST | |
FR_DHCP_DECLINE | |
FR_DHCP_ACK | |
FR_DHCP_NAK | |
FR_DHCP_RELEASE | |
FR_DHCP_INFORM | |
FR_DHCP_FORCE_RENEW | |
FR_DHCP_LEASE_QUERY | |
FR_DHCP_LEASE_UNASSIGNED | |
FR_DHCP_LEASE_UNKNOWN | |
FR_DHCP_LEASE_ACTIVE | |
FR_DHCP_BULK_LEASE_QUERY | |
FR_DHCP_LEASE_QUERY_DONE | |
FR_DHCP_CODE_MAX | |
FR_DHCP_DO_NOT_RESPOND | |
Definition at line 43 of file dhcpv4.h.
◆ fr_dhcpv4_attr_cmp()
int8_t fr_dhcpv4_attr_cmp |
( |
void const * |
a, |
|
|
void const * |
b |
|
) |
| |
◆ fr_dhcpv4_attr_flags()
◆ fr_dhcpv4_decode()
◆ fr_dhcpv4_decode_foreign()
◆ fr_dhcpv4_decode_option()
Decode DHCP option.
- Parameters
-
[in] | ctx | context to alloc new attributes in. |
[out] | out | Where to write the decoded options. |
[in] | data | to parse. |
[in] | data_len | of data to parse. |
[in] | decode_ctx | Unused. |
Definition at line 538 of file decode.c.
◆ fr_dhcpv4_encode()
◆ fr_dhcpv4_encode_dbuff()
◆ fr_dhcpv4_encode_foreign()
◆ fr_dhcpv4_encode_option()
Encode a DHCP option and any sub-options.
- Parameters
-
[out] | dbuff | Where to write encoded DHCP attributes. |
[in] | cursor | with current VP set to the option to be encoded. Will be advanced to the next option to encode. |
[in] | encode_ctx | Containing DHCPv4 dictionary. |
- Returns
- > 0 length of data written.
- < 0 error.
- 0 not valid option for DHCP (skipping).
Definition at line 726 of file encode.c.
◆ fr_dhcpv4_global_free()
void fr_dhcpv4_global_free |
( |
void |
| ) |
|
◆ fr_dhcpv4_global_init()
int fr_dhcpv4_global_init |
( |
void |
| ) |
|
Resolve/cache attributes in the DHCP dictionary.
- Returns
- 0 on success.
- -1 on failure.
Definition at line 584 of file base.c.
◆ fr_dhcpv4_is_encodable()
bool fr_dhcpv4_is_encodable |
( |
void const * |
item, |
|
|
void const * |
uctx |
|
) |
| |
◆ fr_dhcpv4_next_encodable()
void * fr_dhcpv4_next_encodable |
( |
fr_dlist_head_t * |
list, |
|
|
void * |
to_eval, |
|
|
void * |
uctx |
|
) |
| |
DHCPV4-specific iterator.
Definition at line 319 of file base.c.
◆ fr_dhcpv4_ok()
Check received DHCP request is valid and build fr_packet_t structure if it is.
- Parameters
-
| data | pointer to received packet. |
| data_len | length of received data, and then length of the actual DHCP data. |
[out] | message_type | where the message type will be stored (if used) |
[out] | xid | where the xid will be stored (if used) |
- Returns
- true if the packet is well-formed
- false if it's a bad packet
Definition at line 240 of file base.c.
◆ fr_dhcpv4_packet_alloc()
◆ fr_dhcpv4_packet_encode()
◆ fr_dhcpv4_packet_get_option()
Retrieve a DHCP option from a raw packet buffer.
Definition at line 37 of file packet.c.
◆ fr_dhcpv4_print_hex()
void fr_dhcpv4_print_hex |
( |
FILE * |
fp, |
|
|
uint8_t const * |
packet, |
|
|
size_t |
packet_len |
|
) |
| |
Print a raw DHCP packet as hex.
Definition at line 672 of file base.c.
◆ fr_dhcpv4_udp_packet_recv()
Receive DHCP packet using a connectionless UDP socket.
- Parameters
-
- Returns
-
Definition at line 74 of file udp.c.
◆ fr_dhcpv4_udp_packet_send()
Send DHCP packet using a connectionless UDP socket.
- Parameters
-
- Returns
- >= 0 if successful.
- < 0 if failed.
Definition at line 41 of file udp.c.
◆ dhcp_header_attrs
◆ dhcp_header_attrs_len
◆ dhcp_header_sizes
◆ dhcp_message_types
char const* dhcp_message_types[] |
|
extern |
◆ eth_bcast