DHCP message parser.
More...
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <arpa/inet.h>
Go to the source code of this file.
|
#define | MAX_HW_LEN 16 |
|
#define | DHCP_HEADER_LEN 236 |
|
#define | DHCP_MAX_OPTION_COUNT 20 |
|
#define | DHCP_MAGIC_COOKIE 0x63825363 |
|
|
enum | dhcp_opcode_t { DHCP_BOOTREQUEST = 1
, DHCP_BOOTREPLY = 2
} |
|
enum | dhcp_option_code_t { DHCP_PAD = 0
, DHCP_MESSAGE_TYPE = 53
, DHCP_END = 255
} |
|
enum | dhcp_message_type_t {
DHCP_DISCOVER = 1
, DHCP_OFFER = 2
, DHCP_REQUEST = 3
, DHCP_DECLINE = 4
,
DHCP_ACK = 5
, DHCP_NAK = 6
, DHCP_RELEASE = 7
, DHCP_INFORM = 8
} |
|
DHCP message parser.
- Date
- 2022-09-12
- Copyright
- Copyright (c) 2022
◆ dhcp_message_t
◆ dhcp_option_t
◆ dhcp_options_t
◆ dhcp_message_type_t
◆ dhcp_opcode_t
◆ dhcp_option_code_t
◆ dhcp_free_message()
Free the memory allocated for a DHCP message.
- Parameters
-
message | the DHCP message to free |
◆ dhcp_parse_header()
Parse the header of a DHCP message (not including options)
- Parameters
-
data | a pointer to the start of the DHCP message |
- Returns
- the parsed DHCP message with the header fields filled in
Parse the header of a DHCP message (not including options)
- Parameters
-
data | a pointer to the start of the DHCP message |
- Returns
- the parsed DHCP message with the header fields filled in
◆ dhcp_parse_message()
Parse a DHCP message.
- Parameters
-
data | a pointer to the start of the DHCP message |
- Returns
- the parsed DHCP message
◆ dhcp_parse_option()
dhcp_option_t dhcp_parse_option |
( |
uint8_t * |
data, |
|
|
uint16_t * |
offset |
|
) |
| |
Parse a DHCP option.
- Parameters
-
data | a pointer to the start of the DHCP option |
offset | a pointer to the current offset inside the DHCP message Its value will be updated to point to the next option |
- Returns
- the parsed DHCP option
◆ dhcp_parse_options()
Parse DHCP options.
- Parameters
-
data | a pointer to the start of the DHCP options list |
- Returns
- a pointer to the start of the parsed DHCP options
◆ dhcp_print_header()
Print the header of a DHCP message.
- Parameters
-
message | the DHCP message to print the header of |
◆ dhcp_print_message()
Print a DHCP message.
- Parameters
-
message | the DHCP message to print |
◆ dhcp_print_option()
Print a DHCP option.
- Parameters
-
option | the DHCP option to print |