Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的内核代码中,我需要解析一些类似 TLV 的属性rtattr。有没有办法验证长度是否正确,即它必须是偶数。有这个宏吗?
rtattr
在 BER-TLV 数据中,L-value 可以动态改变长度。如果在第一个字节中,第 8 位是 1,则意味着 L 长度参数使用了几个字节。1-st 的其余部分,用 0x7F 掩码的字节,将显示用于长度定义的字节数。
示例0x820102将描述:第 1 字节第 8 位设置为 1,长度部分具有动态长度,第 1 字节的其余部分0x02显示用于长度的字节数。0x0102十六进制长度本身等于 258 个字节。
0x820102
0x02
0x0102