Skip to content

Commit

Permalink
update gRPC protobuf to include ICMP struct
Browse files Browse the repository at this point in the history
Signed-off-by: msherif1234 <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed Mar 20, 2023
1 parent efb6b74 commit 3785a30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/pipeline/decode/decode_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func PBFlowToMap(flow *pbflow.Record) config.GenericMap {
"Interface": flow.Interface,
"AgentIP": ipToStr(flow.AgentIp),
"Flags": flow.Flags,
"IcmpType": flow.Icmp.GetIcmpType(),
"IcmpCode": flow.Icmp.GetIcmpCode(),
}
return out
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/pipeline/decode/decode_protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func TestDecodeProtobuf(t *testing.T) {
IpFamily: &pbflow.IP_Ipv4{Ipv4: 0x0a090807},
},
Flags: 0x100,
Icmp: &pbflow.Icmp{
IcmpType: 8,
IcmpCode: 0,
},
}
rawPB, err := proto.Marshal(&flow)
require.NoError(t, err)
Expand All @@ -71,6 +75,8 @@ func TestDecodeProtobuf(t *testing.T) {
"Interface": "eth0",
"AgentIP": "10.9.8.7",
"Flags": uint32(0x100),
"IcmpType": uint32(8),
"IcmpCode": uint32(0),
}, out)
}

Expand Down Expand Up @@ -106,6 +112,10 @@ func TestPBFlowToMap(t *testing.T) {
IpFamily: &pbflow.IP_Ipv4{Ipv4: 0x0a090807},
},
Flags: 0x100,
Icmp: &pbflow.Icmp{
IcmpType: 10,
IcmpCode: 11,
},
}

out := PBFlowToMap(flow)
Expand All @@ -129,6 +139,8 @@ func TestPBFlowToMap(t *testing.T) {
"Interface": "eth0",
"AgentIP": "10.9.8.7",
"Flags": uint32(0x100),
"IcmpType": uint32(10),
"IcmpCode": uint32(11),
}, out)

}
6 changes: 6 additions & 0 deletions pkg/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ parameters:
IpFamily: &pbflow.IP_Ipv4{Ipv4: 0x0a0b0c0d},
},
Flags: 0x100,
Icmp: &pbflow.Icmp{
IcmpType: 10,
IcmpCode: 11,
},
}},
})
require.NoError(t, err)
Expand Down Expand Up @@ -233,6 +237,8 @@ parameters:
"Interface": "eth0",
"AgentIP": "10.11.12.13",
"Flags": float64(0x100),
"IcmpType": uint32(10),
"icmpCode": uint32(11),
}, capturedRecord)
}

Expand Down

0 comments on commit 3785a30

Please sign in to comment.