diff options
Diffstat (limited to 'libdhcp/include')
-rw-r--r-- | libdhcp/include/libdhcp/dhcp.h | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/libdhcp/include/libdhcp/dhcp.h b/libdhcp/include/libdhcp/dhcp.h index e6b1801..aae4a4d 100644 --- a/libdhcp/include/libdhcp/dhcp.h +++ b/libdhcp/include/libdhcp/dhcp.h @@ -70,14 +70,6 @@ #include <libmisc/net.h> #include "hw/w5500.h" -struct dhcp_lease { - struct net_ip4_addr addr; - struct net_ip4_addr subnet_mask; - struct net_ip4_addr gateway; - struct net_ip4_addr dns; - uint32_t lifetime; /* in seconds, except 0xffffffff is "infinity" */ -}; - enum dhcp_event { DHCP_ASSIGN, DHCP_UPDATE, @@ -135,4 +127,32 @@ uint8_t DHCP_run(struct w5500 *chip, uint8_t socknum, dhcp_callback_t cb); */ void DHCP_stop(implements_net_packet_conn *sock); +void xhandle(uint8_t opt_typ, uint8_t opt_len, uint8_t *opt_dat) { + switch (opt_typ) { + case DHCP_OPT_SUBNET_MASK: + if (opt_len != 4) + return; + global_lease.subnet_mask.octets[0] = opt_dat[0]; + global_lease.subnet_mask.octets[1] = opt_dat[1]; + global_lease.subnet_mask.octets[2] = opt_dat[2]; + global_lease.subnet_mask.octets[3] = opt_dat[3]; + case DHCP_OPT_ROUTER : + if (opt_len < 4) + return; + global_lease.gateway.octets[0] = opt_dat[0]; + global_lease.gateway.octets[1] = opt_dat[1]; + global_lease.gateway.octets[2] = opt_dat[2]; + global_lease.gateway.octets[3] = opt_dat[3]; + break; + case DHCP_OPT_DOMAIN_SERVER : + if (opt_len < 4) + return; + global_lease.dns.octets[0] = opt_dat[0]; + global_lease.dns.octets[1] = opt_dat[1]; + global_lease.dns.octets[2] = opt_dat[2]; + global_lease.dns.octets[3] = opt_dat[3]; + break; + } +} + #endif /* _LIBDHCP_DHCP_H_ */ |