add FieldClassOperation to pcap and associated formatting changes

This commit is contained in:
soypat
2025-12-31 18:54:21 -03:00
parent dc374169dc
commit 3cbef6fa92
6 changed files with 17 additions and 21 deletions
+3 -4
View File
@@ -670,6 +670,7 @@ const (
FieldClassAddress // address
// FieldClassBinaryText represents long stretches of binary data such as BOOTP DHCPv4 field.
FieldClassBinaryText // binary-text
FieldClassOperation // op
)
const octet = 8
@@ -718,8 +719,7 @@ var baseARPFields = [...]FrameField{
BitLength: 1 * octet,
},
{
Name: "Opcode",
Class: FieldClassType,
Class: FieldClassOperation,
FrameBitOffset: 6 * octet,
BitLength: 2 * octet,
},
@@ -924,8 +924,7 @@ var baseUDPFields = [...]FrameField{
var baseDHCPv4Fields = [...]FrameField{
{
Name: "Opcode",
Class: FieldClassType,
Class: FieldClassOperation,
FrameBitOffset: 0,
BitLength: 1 * octet,
},
+1 -1
View File
@@ -112,7 +112,7 @@ func (f *Formatter) formatField(dst []byte, pktStartOff int, field FrameField, p
dst = hex.AppendEncode(dst, f.buf)
case FieldClassText:
dst = strconv.AppendQuote(dst, string(f.buf))
case FieldClassDst, FieldClassSrc, FieldClassSize, FieldClassAddress:
case FieldClassDst, FieldClassSrc, FieldClassSize, FieldClassAddress, FieldClassOperation:
// IP, MAC addresses and ports.
if field.BitLength <= 16 {
v, err := fieldAsUint(pkt, fieldBitStart, field.BitLength, field.RightAligned)
+3 -2
View File
@@ -23,11 +23,12 @@ func _() {
_ = x[FieldClassText-12]
_ = x[FieldClassAddress-13]
_ = x[FieldClassBinaryText-14]
_ = x[FieldClassOperation-15]
}
const _FieldClass_name = "undefinedsourcedestinationprotocolversiontypesizeflagsidentificationchecksumoptionspayloadtextaddressbinary-text"
const _FieldClass_name = "undefinedsourcedestinationprotocolversiontypesizeflagsidentificationchecksumoptionspayloadtextaddressbinary-textop"
var _FieldClass_index = [...]uint8{0, 9, 15, 26, 34, 41, 45, 49, 54, 68, 76, 83, 90, 94, 101, 112}
var _FieldClass_index = [...]uint8{0, 9, 15, 26, 34, 41, 45, 49, 54, 68, 76, 83, 90, 94, 101, 112, 114}
func (i FieldClass) String() string {
if i >= FieldClass(len(_FieldClass_index)-1) {