@@ -3984,6 +3984,8 @@ START_TEST(test_dhcp_parse_offer_and_ack)
39843984 struct ipconf * primary ;
39853985 uint32_t offer_ip = 0x0A000064U ;
39863986 uint32_t server_ip = 0x0A000001U ;
3987+ uint32_t router_ip = 0x0A000002U ;
3988+ uint32_t dns_ip = 0x08080808U ;
39873989 uint32_t mask = 0xFFFFFF00U ;
39883990
39893991 wolfIP_init (& s );
@@ -4042,17 +4044,34 @@ START_TEST(test_dhcp_parse_offer_and_ack)
40424044 opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
40434045 opt -> code = DHCP_OPTION_DNS ;
40444046 opt -> len = 4 ;
4045- opt -> data [0 ] = (server_ip >> 24 ) & 0xFF ;
4046- opt -> data [1 ] = (server_ip >> 16 ) & 0xFF ;
4047- opt -> data [2 ] = (server_ip >> 8 ) & 0xFF ;
4048- opt -> data [3 ] = (server_ip >> 0 ) & 0xFF ;
4047+ opt -> data [0 ] = (dns_ip >> 24 ) & 0xFF ;
4048+ opt -> data [1 ] = (dns_ip >> 16 ) & 0xFF ;
4049+ opt -> data [2 ] = (dns_ip >> 8 ) & 0xFF ;
4050+ opt -> data [3 ] = (dns_ip >> 0 ) & 0xFF ;
4051+ opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
4052+ opt -> code = DHCP_OPTION_ROUTER ;
4053+ opt -> len = 4 ;
4054+ opt -> data [0 ] = (router_ip >> 24 ) & 0xFF ;
4055+ opt -> data [1 ] = (router_ip >> 16 ) & 0xFF ;
4056+ opt -> data [2 ] = (router_ip >> 8 ) & 0xFF ;
4057+ opt -> data [3 ] = (router_ip >> 0 ) & 0xFF ;
4058+ opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
4059+ opt -> code = DHCP_OPTION_OFFER_IP ;
4060+ opt -> len = 4 ;
4061+ opt -> data [0 ] = (offer_ip >> 24 ) & 0xFF ;
4062+ opt -> data [1 ] = (offer_ip >> 16 ) & 0xFF ;
4063+ opt -> data [2 ] = (offer_ip >> 8 ) & 0xFF ;
4064+ opt -> data [3 ] = (offer_ip >> 0 ) & 0xFF ;
40494065 opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
40504066 opt -> code = DHCP_OPTION_END ;
40514067 opt -> len = 0 ;
40524068
40534069 ck_assert_int_eq (dhcp_parse_ack (& s , & msg ), 0 );
40544070 ck_assert_int_eq (s .dhcp_state , DHCP_BOUND );
4055- ck_assert_uint_eq (s .dns_server , server_ip );
4071+ ck_assert_uint_eq (primary -> ip , offer_ip );
4072+ ck_assert_uint_eq (primary -> mask , mask );
4073+ ck_assert_uint_eq (primary -> gw , router_ip );
4074+ ck_assert_uint_eq (s .dns_server , dns_ip );
40564075}
40574076END_TEST
40584077
0 commit comments