@@ -40,7 +40,7 @@ static void test_set_lltd_header_populates_fields(void **state) {
4040 assert_memory_equal (& header -> frameHeader .destination , & destination , sizeof (destination ));
4141 assert_memory_equal (& header -> realSource , & source , sizeof (source ));
4242 assert_memory_equal (& header -> realDestination , & destination , sizeof (destination ));
43- assert_int_equal (header -> seqNumber , 0x1234 );
43+ assert_int_equal (header -> seqNumber , htons ( 0x1234 ) );
4444 assert_int_equal (header -> opcode , opcode_probe );
4545 assert_int_equal (header -> tos , tos_discovery );
4646 assert_int_equal (header -> version , 1 );
@@ -59,7 +59,7 @@ static void test_set_hello_header_writes_payload(void **state) {
5959 (lltd_hello_upper_header_t * )(buffer + sizeof (lltd_demultiplex_header_t ));
6060 assert_memory_equal (& hello -> apparentMapper , & apparent , sizeof (apparent ));
6161 assert_memory_equal (& hello -> currentMapper , & current , sizeof (current ));
62- assert_int_equal (hello -> generation , 0x42 );
62+ assert_int_equal (hello -> generation , htons ( 0x42 ) );
6363}
6464
6565static void test_set_end_of_property_tlv_marks_buffer (void * * state ) {
@@ -94,35 +94,43 @@ static void test_set_uuid_tlv_correct_size(void **state) {
9494// Test that perf counter TLV uses network byte order (big-endian)
9595static void test_set_perf_counter_tlv_endianness (void * * state ) {
9696 (void )state ;
97- uint8_t buffer [sizeof (generic_tlv_t ) + sizeof (uint32_t )] = {0 };
97+ uint8_t buffer [sizeof (generic_tlv_t ) + sizeof (uint64_t )] = {0 };
9898
9999 size_t written = setPerfCounterTLV (buffer , 0 );
100100
101- assert_int_equal (written , sizeof (generic_tlv_t ) + sizeof (uint32_t ));
101+ assert_int_equal (written , sizeof (generic_tlv_t ) + sizeof (uint64_t ));
102102 generic_tlv_t * tlv = (generic_tlv_t * )buffer ;
103103 assert_int_equal (tlv -> TLVType , tlv_perfCounterFrequency );
104- assert_int_equal (tlv -> TLVLength , sizeof (uint32_t ));
105-
106- // Value should be 1000000 in network byte order
107- uint32_t * value = (uint32_t * )(buffer + sizeof (generic_tlv_t ));
108- assert_int_equal (* value , htonl (1000000 ));
104+ assert_int_equal (tlv -> TLVLength , sizeof (uint64_t ));
105+
106+ const uint8_t * bytes = buffer + sizeof (generic_tlv_t );
107+ uint64_t value =
108+ ((uint64_t )bytes [0 ] << 56 ) |
109+ ((uint64_t )bytes [1 ] << 48 ) |
110+ ((uint64_t )bytes [2 ] << 40 ) |
111+ ((uint64_t )bytes [3 ] << 32 ) |
112+ ((uint64_t )bytes [4 ] << 24 ) |
113+ ((uint64_t )bytes [5 ] << 16 ) |
114+ ((uint64_t )bytes [6 ] << 8 ) |
115+ (uint64_t )bytes [7 ];
116+ assert_int_equal (value , 1000000ULL );
109117}
110118
111119// Test QoS characteristics TLV uses network byte order
112120static void test_set_qos_characteristics_tlv_endianness (void * * state ) {
113121 (void )state ;
114- uint8_t buffer [sizeof (generic_tlv_t ) + sizeof (uint16_t )] = {0 };
122+ uint8_t buffer [sizeof (generic_tlv_t ) + sizeof (uint32_t )] = {0 };
115123
116124 size_t written = setQosCharacteristicsTLV (buffer , 0 );
117125
118- assert_int_equal (written , sizeof (generic_tlv_t ) + sizeof (uint16_t ));
126+ assert_int_equal (written , sizeof (generic_tlv_t ) + sizeof (uint32_t ));
119127 generic_tlv_t * tlv = (generic_tlv_t * )buffer ;
120128 assert_int_equal (tlv -> TLVType , tlv_qos_characteristics );
121- assert_int_equal (tlv -> TLVLength , sizeof (uint16_t ));
129+ assert_int_equal (tlv -> TLVLength , sizeof (uint32_t ));
122130
123- uint16_t * value = (uint16_t * )(buffer + sizeof (generic_tlv_t ));
124- uint16_t expected = Config_TLV_QOS_L2Fwd | Config_TLV_QOS_PrioTag | Config_TLV_QOS_VLAN ;
125- assert_int_equal (* value , htons (expected ));
131+ uint32_t * value = (uint32_t * )(buffer + sizeof (generic_tlv_t ));
132+ uint32_t expected = ( uint32_t )( Config_TLV_QOS_L2Fwd | Config_TLV_QOS_PrioTag | Config_TLV_QOS_VLAN ) << 16 ;
133+ assert_int_equal (* value , htonl (expected ));
126134}
127135
128136// Test icon image TLV has zero length (empty stub)
0 commit comments