1 #ifndef DHCP_H 2 #define DHCP_H 3 4 #include <inttypes.h> 5 6 struct dhcp_option { 7 void *data; 8 int len; 9 }; 10 11 struct dhcp_packet { 12 uint8_t op; /* 0 */ 13 uint8_t htype; /* 1 */ 14 uint8_t hlen; /* 2 */ 15 uint8_t hops; /* 3 */ 16 uint32_t xid; /* 4 */ 17 uint16_t secs; /* 8 */ 18 uint16_t flags; /* 10 */ 19 uint32_t ciaddr; /* 12 */ 20 uint32_t yiaddr; /* 16 */ 21 uint32_t siaddr; /* 20 */ 22 uint32_t giaddr; /* 24 */ 23 uint8_t chaddr[16]; /* 28 */ 24 uint8_t sname[64]; /* 44 */ 25 uint8_t file[128]; /* 108 */ 26 uint32_t magic; /* 236 */ 27 uint8_t options[4]; /* 240 */ 28 }; 29 30 #define DHCP_VENDOR_MAGIC 0x63825363 31 32 int dhcp_pack_packet(void *packet, size_t *len, 33 const struct dhcp_option opt[256]); 34 35 int dhcp_unpack_packet(const void *packet, size_t len, 36 struct dhcp_option opt[256]); 37 38 #endif /* DHCP_H */ 39 40 41