@@ -384,12 +384,14 @@ def _encodeControlAndTag(self, type, tag, lenOfLenOrVal=0):
384
384
controlByte |= TLV_TAG_CONTROL_COMMON_PROFILE_4Bytes
385
385
return struct .pack ("<BL" , controlByte , tagNum )
386
386
else :
387
+ vendorId = (profile >> 16 ) & 0xFFFF
388
+ profileNum = (profile >> 0 ) & 0xFFFF
387
389
if tagNum <= UINT16_MAX :
388
390
controlByte |= TLV_TAG_CONTROL_FULLY_QUALIFIED_6Bytes
389
- return struct .pack ("<BLH " , controlByte , profile , tagNum )
391
+ return struct .pack ("<BHHH " , controlByte , vendorId , profileNum , tagNum )
390
392
else :
391
393
controlByte |= TLV_TAG_CONTROL_FULLY_QUALIFIED_8Bytes
392
- return struct .pack ("<BLL " , controlByte , profile , tagNum )
394
+ return struct .pack ("<BHHL " , controlByte , vendorId , profileNum , profile , tagNum )
393
395
raise ValueError ("Invalid object given for TLV tag" )
394
396
395
397
@staticmethod
@@ -490,16 +492,18 @@ def _decodeControlAndTag(self, tlv, decoding):
490
492
decoding ["tagLen" ] = 4
491
493
self ._bytesRead += 4
492
494
elif decoding ["tagControl" ] == "Fully Qualified 6-byte" :
493
- (profile ,) = struct .unpack (
494
- "<L" , tlv [self ._bytesRead : self ._bytesRead + 4 ])
495
+ (vendorId , profileNum ) = struct .unpack (
496
+ "<HH" , tlv [self ._bytesRead : self ._bytesRead + 4 ])
497
+ profile = (vendorId << 16 ) | profileNum
495
498
(tag ,) = struct .unpack (
496
499
"<H" , tlv [self ._bytesRead + 4 : self ._bytesRead + 6 ])
497
500
decoding ["profileTag" ] = (profile , tag )
498
501
decoding ["tagLen" ] = 2
499
502
self ._bytesRead += 6
500
503
elif decoding ["tagControl" ] == "Fully Qualified 8-byte" :
501
- (profile ,) = struct .unpack (
502
- "<L" , tlv [self ._bytesRead : self ._bytesRead + 4 ])
504
+ (vendorId , profileNum ) = struct .unpack (
505
+ "<HH" , tlv [self ._bytesRead : self ._bytesRead + 4 ])
506
+ profile = (vendorId << 16 ) | profileNum
503
507
(tag ,) = struct .unpack (
504
508
"<L" , tlv [self ._bytesRead + 4 : self ._bytesRead + 8 ])
505
509
decoding ["profileTag" ] = (profile , tag )
0 commit comments