![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
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>
Include dependency graph for dhcpv4.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | dhcp_packet_t |
| struct | fr_dhcpv4_attr_flags_t |
| struct | fr_dhcpv4_ctx_t |
| Used as the decoder ctx. More... | |
Macros | |
| #define | DEFAULT_PACKET_SIZE (300) |
| #define | DHCP_CHADDR_LEN (16) |
| #define | DHCP_FILE_FIELD (1) |
| #define | DHCP_FILE_LEN (128) |
| #define | DHCP_OPTION_FIELD (0) |
| #define | DHCP_OPTION_MAGIC_NUMBER (0x63825363U) |
| #define | DHCP_PACK_OPTION1(x, y) ((x) | ((y) << 8)) |
| #define | DHCP_SNAME_FIELD (2) |
| #define | DHCP_SNAME_LEN (64) |
| #define | DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8) |
| #define | DHCP_VEND_LEN (308) |
| #define | DHCPV4_MAX_ATTRIBUTES 255 |
| #define | ETH_ADDR_LEN 6 |
| #define | FR_DHCP_PACKET_CODE_VALID(_code) (((_code) > 0) && ((_code) < FR_DHCP_CODE_MAX)) |
| #define | INADDR_BROADCAST INADDR_NONE |
| #define | MAX_PACKET_SIZE (1500 - 40) |
| #define | MIN_PACKET_SIZE (244) |
Enumerations | |
| enum | fr_dhcpv4_attr_flags_prefix_t : int8_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 : uint16_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 } |
Functions | |
| fr_cmp_ret_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) |
| Return DHCPv4-specific flags for a given attribute. | |
| 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, fr_dhcpv4_packet_code_t code, uint32_t xid, fr_pair_list_t *vps) |
| ssize_t | fr_dhcpv4_encode_dbuff (fr_dbuff_t *dbuff, dhcp_packet_t *original, fr_dhcpv4_packet_code_t 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. | |
| static bool | fr_dhcpv4_flag_dns_label (fr_dict_attr_t const *da) |
| static bool | fr_dhcpv4_flag_exists (fr_dict_attr_t const *da) |
| static fr_dhcpv4_attr_flags_prefix_t | fr_dhcpv4_flag_prefix (fr_dict_attr_t const *da) |
| static bool | fr_dhcpv4_flag_prefix_bits (fr_dict_attr_t const *da) |
| static bool | fr_dhcpv4_flag_prefix_split (fr_dict_attr_t const *da) |
| 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_dcursor_t *cursor, void *to_eval, void *uctx) |
| DHCPV4-specific iterator. | |
| bool | fr_dhcpv4_ok (uint8_t const *data, size_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, size_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. | |
Variables | |
| fr_dict_attr_t const ** | dhcp_header_attrs [] |
| size_t | dhcp_header_attrs_len |
| int | dhcp_header_sizes [] |
| char const * | dhcp_message_types [FR_DHCP_CODE_MAX] |
| uint8_t | eth_bcast [ETH_ADDR_LEN] |
| fr_dict_protocol_t | libfreeradius_dhcpv4_dict_protocol |
Implementation of the DHCPv4 protocol.
Definition in file dhcpv4.h.
| struct dhcp_packet_t |
| Data Fields | ||
|---|---|---|
| uint8_t | chaddr[DHCP_CHADDR_LEN] | |
| uint32_t | ciaddr | |
| uint8_t | file[DHCP_FILE_LEN] | |
| uint16_t | flags | |
| uint32_t | giaddr | |
| uint8_t | hlen | |
| uint8_t | hops | |
| uint8_t | htype | |
| uint8_t | opcode | |
| uint32_t | option_format | |
| uint8_t | options[DHCP_VEND_LEN] | |
| uint16_t | secs | |
| uint32_t | siaddr | |
| uint8_t | sname[DHCP_SNAME_LEN] | |
| uint32_t | xid | |
| uint32_t | yiaddr | |
| struct fr_dhcpv4_attr_flags_t |
| Data Fields | ||
|---|---|---|
| bool | dns_label | |
| bool | exists | |
| fr_dhcpv4_attr_flags_prefix_t | prefix | |
| struct fr_dhcpv4_ctx_t |
Collaboration diagram for fr_dhcpv4_ctx_t:| Data Fields | ||
|---|---|---|
| fr_dict_attr_t const * | root | |
| TALLOC_CTX * | tmp_ctx | for temporary things cleaned up during decoding |
| #define FR_DHCP_PACKET_CODE_VALID | ( | _code | ) | (((_code) > 0) && ((_code) < FR_DHCP_CODE_MAX)) |
| enum fr_dhcpv4_attr_flags_prefix_t : int8_t |
| enum fr_dhcpv4_packet_code_t : uint16_t |
| fr_cmp_ret_t fr_dhcpv4_attr_cmp | ( | void const * | a, |
| void const * | b | ||
| ) |
|
inlinestatic |
Return DHCPv4-specific flags for a given attribute.
Assert in debug builds when the attribute belongs to another dictionary, as the flags of one protocol say nothing about an attribute of another.
If the attribute does not carry the protocol-specific extension, then assert. Other builds log the error and return zeroed flags instead of NULL.
Definition at line 162 of file dhcpv4.h.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 | data_len, | ||
| void * | decode_ctx | ||
| ) |
Decode DHCP option.
| [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 587 of file decode.c.
Here is the call graph for this function:
Here is the caller graph for this function:| ssize_t fr_dhcpv4_encode | ( | uint8_t * | buffer, |
| size_t | buflen, | ||
| dhcp_packet_t * | original, | ||
| fr_dhcpv4_packet_code_t | code, | ||
| uint32_t | xid, | ||
| fr_pair_list_t * | vps | ||
| ) |
| ssize_t fr_dhcpv4_encode_dbuff | ( | fr_dbuff_t * | dbuff, |
| dhcp_packet_t * | original, | ||
| fr_dhcpv4_packet_code_t | 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.
| [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. |
Definition at line 737 of file encode.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| void fr_dhcpv4_global_free | ( | void | ) |
| int fr_dhcpv4_global_init | ( | void | ) |
| bool fr_dhcpv4_is_encodable | ( | void const * | item, |
| void const * | uctx | ||
| ) |
| void * fr_dhcpv4_next_encodable | ( | fr_dcursor_t * | cursor, |
| void * | to_eval, | ||
| void * | uctx | ||
| ) |
Check received DHCP request is valid and build fr_packet_t structure if it is.
| 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) |
Definition at line 248 of file base.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_packet_t * fr_dhcpv4_packet_alloc | ( | uint8_t const * | data, |
| size_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 | ||
| ) |
| fr_packet_t * fr_dhcpv4_udp_packet_recv | ( | int | sockfd | ) |
Receive DHCP packet using a connectionless UDP socket.
| sockfd | handle. |
Definition at line 74 of file udp.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int fr_dhcpv4_udp_packet_send | ( | fr_packet_t * | packet | ) |
|
extern |
|
extern |
|
extern |
|
extern |
1.9.8