Lines Matching refs:opt
146 static uint8_t *opt_find(uint8_t *opt, uint8_t cmd) { in opt_find() argument
147 for (int i = 0; i < 308 && opt[i] != DHCP_OPT_END;) { in opt_find()
148 if (opt[i] == cmd) { in opt_find()
149 return &opt[i]; in opt_find()
151 i += 2 + opt[i + 1]; in opt_find()
156 static void opt_write_n(uint8_t **opt, uint8_t cmd, size_t n, void *data) { in opt_write_n() argument
157 uint8_t *o = *opt; in opt_write_n()
161 *opt = o + n; in opt_write_n()
164 static void opt_write_u8(uint8_t **opt, uint8_t cmd, uint8_t val) { in opt_write_u8() argument
165 uint8_t *o = *opt; in opt_write_u8()
169 *opt = o; in opt_write_u8()
172 static void opt_write_u32(uint8_t **opt, uint8_t cmd, uint32_t val) { in opt_write_u32() argument
173 uint8_t *o = *opt; in opt_write_u32()
180 *opt = o; in opt_write_u32()
205 uint8_t *opt = (uint8_t *)&dhcp_msg.options; in dhcp_server_process() local
206 opt += 4; // assume magic cookie: 99, 130, 83, 99 in dhcp_server_process()
208 switch (opt[2]) { in dhcp_server_process()
236 opt_write_u8(&opt, DHCP_OPT_MSG_TYPE, DHCPOFFER); in dhcp_server_process()
241 uint8_t *o = opt_find(opt, DHCP_OPT_REQUESTED_IP); in dhcp_server_process()
267 opt_write_u8(&opt, DHCP_OPT_MSG_TYPE, DHCPACK); in dhcp_server_process()
278 opt_write_n(&opt, DHCP_OPT_SERVER_ID, 4, &d->ip.addr); in dhcp_server_process()
279 opt_write_n(&opt, DHCP_OPT_SUBNET_MASK, 4, &d->nm.addr); in dhcp_server_process()
280 opt_write_n(&opt, DHCP_OPT_ROUTER, 4, &d->ip.addr); // aka gateway; can have mulitple addresses in dhcp_server_process()
281 opt_write_u32(&opt, DHCP_OPT_DNS, DEFAULT_DNS); // can have mulitple addresses in dhcp_server_process()
282 opt_write_u32(&opt, DHCP_OPT_IP_LEASE_TIME, DEFAULT_LEASE_TIME_S); in dhcp_server_process()
283 *opt++ = DHCP_OPT_END; in dhcp_server_process()
284 … dhcp_socket_sendto(&d->udp, &dhcp_msg, opt - (uint8_t *)&dhcp_msg, 0xffffffff, PORT_DHCP_CLIENT); in dhcp_server_process()