Skip to content

Commit bf18444

Browse files
authored
Fix compile error.
1 parent c1d3fc8 commit bf18444

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/networking/dhserver.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,16 @@ int fill_options(void *dest,
234234
static ip_addr_t get_dhcp_destination(struct netif *netif, const DHCP_TYPE *dhcp,
235235
const ip4_addr_t *yiaddr, bool is_nak)
236236
{
237-
bool giaddr_zero = ip4_addr_isany_val(*((ip4_addr_t*)dhcp->dp_giaddr));
238-
bool ciaddr_zero = ip4_addr_isany_val(*((ip4_addr_t*)dhcp->dp_ciaddr));
237+
ip4_addr_t giaddr = get_ip(dhcp->dp_giaddr);
238+
ip4_addr_t ciaddr = get_ip(dhcp->dp_ciaddr);
239+
bool giaddr_zero = ip4_addr_isany_val(giaddr);
240+
bool ciaddr_zero = ip4_addr_isany_val(ciaddr);
239241
bool broadcast_flag = (dhcp->dp_flags & htons(0x8000)) != 0;
240242
ip_addr_t dest_addr;
241243

242244
if (!giaddr_zero) {
243245
// If giaddr is not zero, send to giaddr (relay agent)
244-
ip_addr_set_ip4_u32(&dest_addr, get_ip(dhcp->dp_giaddr).addr);
246+
ip_addr_set_ip4_u32(&dest_addr, giaddr.addr);
245247
return dest_addr;
246248
}
247249

@@ -254,7 +256,7 @@ static ip_addr_t get_dhcp_destination(struct netif *netif, const DHCP_TYPE *dhcp
254256
if (!ciaddr_zero) {
255257
// RFC 2131: "If the 'giaddr' field is zero and the 'ciaddr' field is nonzero,
256258
// then the server unicasts DHCPOFFER and DHCPACK messages to the address in 'ciaddr'"
257-
ip_addr_set_ip4_u32(&dest_addr, get_ip(dhcp->dp_ciaddr).addr);
259+
ip_addr_set_ip4_u32(&dest_addr, ciaddr.addr);
258260
return dest_addr;
259261
}
260262

0 commit comments

Comments
 (0)