18
18
#include "dns_sd.h"
19
19
20
20
#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
- )
28
21
29
22
extern bool label_is_valid (const char * label , size_t label_size );
30
23
extern int add_a_record (const struct dns_sd_rec * inst , uint32_t ttl ,
@@ -441,7 +434,7 @@ ZTEST(dns_sd, test_add_a_record)
441
434
const uint32_t offset = 0 ;
442
435
const uint16_t host_offset = 0x59 ;
443
436
/* 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 } } } ;
445
438
446
439
static uint8_t actual_buf [BUFSZ ];
447
440
static const uint8_t expected_buf [] = {
@@ -451,7 +444,7 @@ ZTEST(dns_sd, test_add_a_record)
451
444
452
445
int expected_int = sizeof (expected_buf );
453
446
int actual_int = add_a_record (& nasxxxxxx , ttl , host_offset ,
454
- addr , actual_buf , offset ,
447
+ ntohl ( addr . s_addr ) , actual_buf , offset ,
455
448
sizeof (actual_buf ));
456
449
457
450
zassert_equal (actual_int , expected_int , "" );
@@ -462,12 +455,12 @@ ZTEST(dns_sd, test_add_a_record)
462
455
/* test offset too large */
463
456
zassert_equal (- E2BIG ,
464
457
add_a_record (& nasxxxxxx , ttl , DNS_SD_PTR_MASK ,
465
- addr , actual_buf , offset ,
458
+ ntohl ( addr . s_addr ) , actual_buf , offset ,
466
459
sizeof (actual_buf )), "" );
467
460
468
461
/* test buffer too small */
469
462
zassert_equal (- ENOSPC , add_a_record (& nasxxxxxx , ttl ,
470
- host_offset , addr ,
463
+ host_offset , ntohl ( addr . s_addr ) ,
471
464
actual_buf , offset ,
472
465
0 ), "" );
473
466
}
@@ -518,9 +511,7 @@ ZTEST(dns_sd, test_add_aaaa_record)
518
511
/** Test for @ref dns_sd_handle_ptr_query */
519
512
ZTEST (dns_sd , test_dns_sd_handle_ptr_query )
520
513
{
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 } } };
524
515
static uint8_t actual_rsp [512 ];
525
516
static uint8_t expected_rsp [] = {
526
517
0x00 , 0x00 , 0x84 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 ,
@@ -586,9 +577,7 @@ ZTEST(dns_sd, test_dns_sd_handle_service_type_enum)
586
577
DNS_SD_EMPTY_TXT ,
587
578
CONST_PORT );
588
579
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 } } };
592
581
static uint8_t actual_rsp [512 ];
593
582
static uint8_t expected_rsp [] = {
594
583
0x00 , 0x00 , 0x84 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 ,
0 commit comments