1818#include "dns_sd.h"
1919
2020#define BUFSZ 256
21- #define IP_ADDR (a , b , c , d ) ((uint32_t) \
22- 0 \
23- | ((a & 0xff) << 24) \
24- | ((b & 0xff) << 16) \
25- | ((c & 0xff) << 8) \
26- | ((d & 0xff) << 0) \
27- )
2821
2922extern bool label_is_valid (const char * label , size_t label_size );
3023extern int add_a_record (const struct dns_sd_rec * inst , uint32_t ttl ,
@@ -441,7 +434,7 @@ ZTEST(dns_sd, test_add_a_record)
441434 const uint32_t offset = 0 ;
442435 const uint16_t host_offset = 0x59 ;
443436 /* this one is made up */
444- const uint32_t addr = IP_ADDR ( 177 , 5 , 240 , 13 ) ;
437+ const struct in_addr addr = { { { 177 , 5 , 240 , 13 } } } ;
445438
446439 static uint8_t actual_buf [BUFSZ ];
447440 static const uint8_t expected_buf [] = {
@@ -451,7 +444,7 @@ ZTEST(dns_sd, test_add_a_record)
451444
452445 int expected_int = sizeof (expected_buf );
453446 int actual_int = add_a_record (& nasxxxxxx , ttl , host_offset ,
454- addr , actual_buf , offset ,
447+ ntohl ( addr . s_addr ) , actual_buf , offset ,
455448 sizeof (actual_buf ));
456449
457450 zassert_equal (actual_int , expected_int , "" );
@@ -462,12 +455,12 @@ ZTEST(dns_sd, test_add_a_record)
462455 /* test offset too large */
463456 zassert_equal (- E2BIG ,
464457 add_a_record (& nasxxxxxx , ttl , DNS_SD_PTR_MASK ,
465- addr , actual_buf , offset ,
458+ ntohl ( addr . s_addr ) , actual_buf , offset ,
466459 sizeof (actual_buf )), "" );
467460
468461 /* test buffer too small */
469462 zassert_equal (- ENOSPC , add_a_record (& nasxxxxxx , ttl ,
470- host_offset , addr ,
463+ host_offset , ntohl ( addr . s_addr ) ,
471464 actual_buf , offset ,
472465 0 ), "" );
473466}
@@ -518,9 +511,7 @@ ZTEST(dns_sd, test_add_aaaa_record)
518511/** Test for @ref dns_sd_handle_ptr_query */
519512ZTEST (dns_sd , test_dns_sd_handle_ptr_query )
520513{
521- struct in_addr addr = {
522- .s_addr = htonl (IP_ADDR (177 , 5 , 240 , 13 )),
523- };
514+ struct in_addr addr = { { { 177 , 5 , 240 , 13 } } };
524515 static uint8_t actual_rsp [512 ];
525516 static uint8_t expected_rsp [] = {
526517 0x00 , 0x00 , 0x84 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 ,
@@ -586,9 +577,7 @@ ZTEST(dns_sd, test_dns_sd_handle_service_type_enum)
586577 DNS_SD_EMPTY_TXT ,
587578 CONST_PORT );
588579
589- struct in_addr addr = {
590- .s_addr = htonl (IP_ADDR (177 , 5 , 240 , 13 )),
591- };
580+ struct in_addr addr = { { { 177 , 5 , 240 , 13 } } };
592581 static uint8_t actual_rsp [512 ];
593582 static uint8_t expected_rsp [] = {
594583 0x00 , 0x00 , 0x84 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 ,
0 commit comments