Skip to content

Commit a2a945e

Browse files
committed
Fix TLV sizes for perf counter and QoS
1 parent ab92c7b commit a2a945e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

lltdDaemon/lltdTlvOps.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,13 @@ size_t setCharacteristicsTLV(void *buffer, uint64_t offset, void *networkInterfa
146146
size_t setPerfCounterTLV(void *buffer, uint64_t offset){
147147
generic_tlv_t *perf = (generic_tlv_t *) (buffer+offset);
148148
perf->TLVType = tlv_perfCounterFrequency;
149-
perf->TLVLength = sizeof(uint64_t);
150-
151-
// Write 64-bit value in big-endian (network) order
152-
uint64_t freq = 1000000; // 1 MHz performance counter frequency
153-
uint8_t *bytes = (uint8_t *)(buffer + offset + sizeof(generic_tlv_t));
154-
bytes[0] = (freq >> 56) & 0xFF;
155-
bytes[1] = (freq >> 48) & 0xFF;
156-
bytes[2] = (freq >> 40) & 0xFF;
157-
bytes[3] = (freq >> 32) & 0xFF;
158-
bytes[4] = (freq >> 24) & 0xFF;
159-
bytes[5] = (freq >> 16) & 0xFF;
160-
bytes[6] = (freq >> 8) & 0xFF;
161-
bytes[7] = freq & 0xFF;
162-
return sizeof(generic_tlv_t) + sizeof(uint64_t);
149+
perf->TLVLength = sizeof(uint32_t);
150+
151+
// Write 32-bit value in big-endian (network) order
152+
uint32_t freq = 1000000; // 1 MHz performance counter frequency
153+
uint32_t *value = (uint32_t *)(buffer + offset + sizeof(generic_tlv_t));
154+
*value = htonl(freq);
155+
return sizeof(generic_tlv_t) + sizeof(uint32_t);
163156
}
164157

165158
size_t setIconImageTLV(void *buffer, uint64_t offset){
@@ -245,12 +238,12 @@ size_t setHardwareIdTLV(void *buffer, uint64_t offset){
245238
//TODO: see if there really is support for Level2 Forwarding.. ? or just leave it hardcoded
246239
size_t setQosCharacteristicsTLV(void *buffer, uint64_t offset){
247240
generic_tlv_t *QosCharacteristicsTLV = (generic_tlv_t *) (buffer + offset);
248-
uint32_t *qosCharacteristics = (uint32_t *)(buffer + offset + sizeof(generic_tlv_t));
241+
uint16_t *qosCharacteristics = (uint16_t *)(buffer + offset + sizeof(generic_tlv_t));
249242
QosCharacteristicsTLV->TLVType = tlv_qos_characteristics;
250243
QosCharacteristicsTLV->TLVLength = sizeof(*qosCharacteristics);
251-
// QoS flags are in upper 16 bits of 32-bit value
252-
*qosCharacteristics = htonl((Config_TLV_QOS_L2Fwd | Config_TLV_QOS_PrioTag | Config_TLV_QOS_VLAN) << 16);
253-
return sizeof(generic_tlv_t) + sizeof(uint32_t);
244+
// QoS flags are 16-bit values in network order
245+
*qosCharacteristics = htons(Config_TLV_QOS_L2Fwd | Config_TLV_QOS_PrioTag | Config_TLV_QOS_VLAN);
246+
return sizeof(generic_tlv_t) + sizeof(uint16_t);
254247
}
255248

256249
// Detailed Icon TLV - sends the detailed icon image (multi-resolution ICO)

0 commit comments

Comments
 (0)