+static void
+parse_dhcp_options(struct relayd_host *host, struct dhcp_header *dhcp, int len)
+{
+ uint8_t *end = (uint8_t *) dhcp + len;
+ struct dhcp_option *opt = (void *)dhcp->option_data;
+ static const uint8_t dest[4] = { 0, 0, 0, 0 };
+
+ while((uint8_t *) opt < end) {
+ if ((uint8_t *) opt + opt->len > end)
+ break;
+
+ opt = (void *) &opt->data[opt->len];
+ switch(opt->code) {
+ case DHCP_OPTION_ROUTER:
+ DPRINTF(2, "Found a DHCP router option, len=%d\n", opt->len);
+ if (!memcmp(opt->data, host->ipaddr, 4))
+ relayd_add_host_route(host, dest, 0);
+ else
+ relayd_add_pending_route(opt->data, dest, 0, 10000);
+ break;
+ case DHCP_OPTION_ROUTES:
+ DPRINTF(2, "Found a DHCP static routes option, len=%d\n", opt->len);
+ break;
+ case DHCP_OPTION_END:
+ opt = (void *) end;
+ continue;
+ default:
+ DPRINTF(3, "Skipping unknown DHCP option %02x\n", opt->code);
+ continue;
+ }
+
+ }
+}
+