@@ -4138,6 +4138,8 @@ START_TEST(test_dhcp_parse_offer_and_ack)
41384138 struct ipconf * primary ;
41394139 uint32_t offer_ip = 0x0A000064U ;
41404140 uint32_t server_ip = 0x0A000001U ;
4141+ uint32_t router_ip = 0x0A000002U ;
4142+ uint32_t dns_ip = 0x08080808U ;
41414143 uint32_t mask = 0xFFFFFF00U ;
41424144
41434145 wolfIP_init (& s );
@@ -4196,17 +4198,34 @@ START_TEST(test_dhcp_parse_offer_and_ack)
41964198 opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
41974199 opt -> code = DHCP_OPTION_DNS ;
41984200 opt -> len = 4 ;
4199- opt -> data [0 ] = (server_ip >> 24 ) & 0xFF ;
4200- opt -> data [1 ] = (server_ip >> 16 ) & 0xFF ;
4201- opt -> data [2 ] = (server_ip >> 8 ) & 0xFF ;
4202- opt -> data [3 ] = (server_ip >> 0 ) & 0xFF ;
4201+ opt -> data [0 ] = (dns_ip >> 24 ) & 0xFF ;
4202+ opt -> data [1 ] = (dns_ip >> 16 ) & 0xFF ;
4203+ opt -> data [2 ] = (dns_ip >> 8 ) & 0xFF ;
4204+ opt -> data [3 ] = (dns_ip >> 0 ) & 0xFF ;
4205+ opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
4206+ opt -> code = DHCP_OPTION_ROUTER ;
4207+ opt -> len = 4 ;
4208+ opt -> data [0 ] = (router_ip >> 24 ) & 0xFF ;
4209+ opt -> data [1 ] = (router_ip >> 16 ) & 0xFF ;
4210+ opt -> data [2 ] = (router_ip >> 8 ) & 0xFF ;
4211+ opt -> data [3 ] = (router_ip >> 0 ) & 0xFF ;
4212+ opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
4213+ opt -> code = DHCP_OPTION_OFFER_IP ;
4214+ opt -> len = 4 ;
4215+ opt -> data [0 ] = (offer_ip >> 24 ) & 0xFF ;
4216+ opt -> data [1 ] = (offer_ip >> 16 ) & 0xFF ;
4217+ opt -> data [2 ] = (offer_ip >> 8 ) & 0xFF ;
4218+ opt -> data [3 ] = (offer_ip >> 0 ) & 0xFF ;
42034219 opt = (struct dhcp_option * )((uint8_t * )opt + 6 );
42044220 opt -> code = DHCP_OPTION_END ;
42054221 opt -> len = 0 ;
42064222
42074223 ck_assert_int_eq (dhcp_parse_ack (& s , & msg ), 0 );
42084224 ck_assert_int_eq (s .dhcp_state , DHCP_BOUND );
4209- ck_assert_uint_eq (s .dns_server , server_ip );
4225+ ck_assert_uint_eq (primary -> ip , offer_ip );
4226+ ck_assert_uint_eq (primary -> mask , mask );
4227+ ck_assert_uint_eq (primary -> gw , router_ip );
4228+ ck_assert_uint_eq (s .dns_server , dns_ip );
42104229}
42114230END_TEST
42124231
0 commit comments