net/dhcpv4: Use net_if_ipv4_set_netmask()
Use the interface function rather than writing directly to the iface structure. Check for errors in nbuf read. Change-Id: I75311755c2060b640325962ada28adea597cb914 Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
This commit is contained in:
parent
defbc89358
commit
dc862ec104
1 changed files with 11 additions and 3 deletions
|
@ -534,17 +534,25 @@ static enum net_verdict parse_options(struct net_if *iface, struct net_buf *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DHCPV4_OPTIONS_SUBNET_MASK:
|
case DHCPV4_OPTIONS_SUBNET_MASK: {
|
||||||
|
struct in_addr netmask;
|
||||||
|
|
||||||
if (length != 4) {
|
if (length != 4) {
|
||||||
NET_ERR("options_subnet_mask, bad length");
|
NET_ERR("options_subnet_mask, bad length");
|
||||||
return NET_DROP;
|
return NET_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
frag = net_nbuf_read(frag, pos, &pos, length,
|
frag = net_nbuf_read(frag, pos, &pos, length,
|
||||||
iface->ipv4.netmask.s4_addr);
|
netmask.s4_addr);
|
||||||
|
if (!frag && pos) {
|
||||||
|
NET_ERR("options_subnet_mask, short packet");
|
||||||
|
return NET_DROP;
|
||||||
|
}
|
||||||
|
net_if_ipv4_set_netmask(iface, &netmask);
|
||||||
NET_DBG("options_subnet_mask %s",
|
NET_DBG("options_subnet_mask %s",
|
||||||
net_sprint_ipv4_addr(&iface->ipv4.netmask));
|
net_sprint_ipv4_addr(&netmask));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DHCPV4_OPTIONS_ROUTER: {
|
case DHCPV4_OPTIONS_ROUTER: {
|
||||||
struct in_addr router;
|
struct in_addr router;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue