72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <assert.h>
|
|
|
|
namespace dhcp4 {
|
|
|
|
struct __attribute__((packed)) message {
|
|
uint8_t op; // message type
|
|
uint8_t htype; // hardware type
|
|
uint8_t hlen; // hardware address length
|
|
uint8_t hops;
|
|
uint32_t xid; // transaction id
|
|
uint16_t secs; // seconds elapsed
|
|
uint16_t flags;
|
|
uint32_t ciaddr; // client IP address
|
|
uint32_t yiaddr; // your (client) IP address
|
|
uint32_t siaddr; // next server IP address
|
|
uint32_t giaddr; // relay agent IP address
|
|
uint8_t chaddr[16]; // client hardware address
|
|
uint8_t sname[64];
|
|
uint8_t file[128];
|
|
uint8_t options[];
|
|
};
|
|
|
|
struct op {
|
|
enum {
|
|
bootrequest = 1,
|
|
bootreply = 2,
|
|
};
|
|
};
|
|
|
|
struct htype {
|
|
enum {
|
|
ethernet = 1,
|
|
};
|
|
};
|
|
|
|
static_assert((sizeof (message)) == 236);
|
|
|
|
struct option {
|
|
enum {
|
|
ip_address_lease_time = 51,
|
|
option_overload = 52,
|
|
message_type = 53,
|
|
server_identifier = 54,
|
|
parameter_request_list = 55,
|
|
maximum_message_size = 57,
|
|
client_identifier = 61,
|
|
};
|
|
};
|
|
|
|
struct message_type {
|
|
enum {
|
|
dhcpdiscover = 1,
|
|
dhcpoffer = 2,
|
|
dhcprequest = 3,
|
|
dhcpdecline = 4,
|
|
dhcpack = 5,
|
|
dhcpnak = 6,
|
|
dhcprelease = 7,
|
|
dhcpinform = 8,
|
|
};
|
|
};
|
|
|
|
int make_message(void * buf,
|
|
uint32_t bootp_message_type,
|
|
uint32_t transaction_id,
|
|
uint8_t const * chaddr,
|
|
uint32_t dhcp_message_type);
|
|
}
|