const uint8_t *op = NULL;
size_t bl = 0;
+ /* Check we have the magic cookie */
+ if (dhcp->cookie != htonl(MAGIC_COOKIE)) {
+ errno = ENOTSUP;
+ return NULL;
+ }
+
while (p < e) {
o = *p++;
if (o == opt) {
const struct dhcp_state *state = D_CSTATE(ifp);
/* We don't write BOOTP leases */
- if (is_bootp(ifp, dhcp)) {
+ if (IS_BOOTP(ifp, dhcp)) {
unlink(state->leasefile);
return 0;
}
/* We may have found a BOOTP server */
if (get_option_uint8(ifp->ctx, &type, dhcp, DHO_MESSAGETYPE) == -1)
- type = 0;
+ return dhcp;
+
/* Authenticate the message */
auth = get_option(ifp->ctx, dhcp, DHO_AUTHENTICATION, &auth_len);
if (auth) {
* Also, we should not unicast from a BOOTP lease. */
if (s == -1 ||
(!(ifo->options & DHCPCD_INFORM) &&
- is_bootp(ifp, state->new)))
+ IS_BOOTP(ifp, state->new)))
{
a = state->addr.s_addr;
state->addr.s_addr = INADDR_ANY;
if (has_option_mask(ifo->requiremask, i) &&
get_option_uint8(ifp->ctx, &tmp, dhcp, (uint8_t)i) != 0)
{
- /* If we are bootp, then ignore the need for serverid.
- * To ignore bootp, require dhcp_message_type.
- * However, nothing really stops bootp from providing
+ /* If we are BOOTP, then ignore the need for serverid.
+ * To ignore BOOTP, require dhcp_message_type.
+ * However, nothing really stops BOOTP from providing
* DHCP style options as well so the above isn't
* always true. */
if (type == 0 && i == DHO_SERVERID)
const struct dhcp_opt *, size_t);
int get_option_addr(struct dhcpcd_ctx *,struct in_addr *,
const struct dhcp_message *, uint8_t);
-#define is_bootp(i, m) ((m) && \
- !IN_LINKLOCAL(htonl((m)->yiaddr)) && \
+#define IS_BOOTP(i, m) ((m) && \
+ !IN_LINKLOCAL(htonl((m)->yiaddr)) && \
get_option_uint8((i)->ctx, NULL, (m), DHO_MESSAGETYPE) == -1)
struct rt_head *get_option_routes(struct interface *,
const struct dhcp_message *);