static void gateway_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen) { IPaddr_t ip; ip = net_read_ip(popt); net_set_gateway(ip); }
static void dhcp_options_process(unsigned char *popt, struct bootp *bp) { unsigned char *end = popt + sizeof(*bp) + OPT_SIZE; int oplen; IPaddr_t ip; char str[256]; while (popt < end && *popt != 0xff) { oplen = *(popt + 1); switch (*popt) { case 1: ip = net_read_ip(popt + 2); net_set_netmask(ip); break; case 3: ip = net_read_ip(popt + 2); net_set_gateway(ip); break; case 6: ip = net_read_ip(popt + 2); setenv_ip("nameserver", ip); break; case 12: memcpy(str, popt + 2, oplen); str[oplen] = 0; setenv("hostname", str); break; case 15: memcpy(str, popt + 2, oplen); str[oplen] = 0; setenv("domainname", str); break; case 17: memcpy(str, popt + 2, oplen); str[oplen] = 0; setenv("rootpath", str); break; case 51: net_copy_uint32 (&dhcp_leasetime, (uint32_t *)(popt + 2)); break; case 53: /* Ignore Message Type Option */ break; case 54: net_copy_ip(&net_dhcp_server_ip, (popt + 2)); break; case 58: /* Ignore Renewal Time Option */ break; case 59: /* Ignore Rebinding Time Option */ break; case 66: /* Ignore TFTP server name */ break; case 67: /* vendor opt bootfile */ /* * I can't use dhcp_vendorex_proc here because I need * to write into the bootp packet - even then I had to * pass the bootp packet pointer into here as the * second arg */ memcpy(str, popt + 2, oplen); str[oplen] = 0; if (bp->bp_file[0] == '\0') { /* * only use vendor boot file if we didn't * receive a boot file in the main non-vendor * part of the packet - god only knows why * some vendors chose not to use this perfectly * good spot to store the boot file (join on * Tru64 Unix) it seems mind bogglingly crazy * to me */ printf("*** WARNING: using vendor " "optional boot file\n"); setenv("bootfile", str); } break; default: #ifdef CONFIG_BOOTP_VENDOREX if (dhcp_vendorex_proc (popt)) break; #endif debug("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt); break; } popt += oplen + 2; /* Process next option */ } }