数据包字段枚举为字符串

Packet field enumeration as string

我想获取数据包字段的字符串表示形式,例如:

pkt[BOOTP].op == 'BOOTREPLY'

到目前为止,我找到的唯一麻烦的方法是:

 pkt[BOOTP].fields_desc[0].i2repr(pkt[BOOTP], 2)

还有其他想法吗?

您可以使用sprintf

pkt.sprintf("%BOOTP.op%")