Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Add PPP decoding #58

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 88 additions & 70 deletions pb/flow.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pb/flow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ message FlowMessage {
uint32 MPLSLastTTL = 61; // Last TTL
uint32 MPLSLastLabel = 62; // Last Label

// PPP information
bool HasPPP = 63;
uint32 PPPAddressControl = 64;

// Custom fields: start after ID 1000:
// uint32 MyCustomField = 1000;

Expand Down
23 changes: 22 additions & 1 deletion producer/producer_sf.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func ParseSampledHeaderConfig(flowMessage *flowmessage.FlowMessage, sampledHeade
data := (*sampledHeader).HeaderData
switch (*sampledHeader).Protocol {
case 1: // Ethernet
var hasPPP bool
var pppAddressControl uint16
var hasMPLS bool
var countMpls uint32
var firstLabelMpls uint32
Expand Down Expand Up @@ -188,12 +190,28 @@ func ParseSampledHeaderConfig(flowMessage *flowmessage.FlowMessage, sampledHeade
// GRE
if len(data) >= offset+4 && nextHeader == 47 {
etherTypeEncap = data[offset+2 : offset+4]
offset += 4
if (etherTypeEncap[0] == 0x8 && etherTypeEncap[1] == 0x0) ||
(etherTypeEncap[0] == 0x86 && etherTypeEncap[1] == 0xdd) {
encap = true
hasEncap = true
}
offset += 4
if etherTypeEncap[0] == 0x88 && etherTypeEncap[1] == 0x0b && len(data) >= offset+12 {
offset += 8
encap = true
hasPPP = true
pppAddressControl = binary.BigEndian.Uint16(data[offset : offset+2])
pppEtherType := data[offset+2 : offset+4]
if pppEtherType[0] == 0x0 && pppEtherType[1] == 0x21 {
etherTypeEncap = []byte{0x8, 0x00}
hasEncap = true
} else if pppEtherType[0] == 0x0 && pppEtherType[1] == 0x57 {
etherTypeEncap = []byte{0x86, 0xdd}
hasEncap = true
}
offset += 4

}

if hasEncap {
srcIPEncap = srcIP
Expand Down Expand Up @@ -249,6 +267,9 @@ func ParseSampledHeaderConfig(flowMessage *flowmessage.FlowMessage, sampledHeade
flowLabel = flowLabelTmp
}

(*flowMessage).HasPPP = hasPPP
(*flowMessage).PPPAddressControl = uint32(pppAddressControl)

(*flowMessage).HasMPLS = hasMPLS
(*flowMessage).MPLSCount = countMpls
(*flowMessage).MPLS1Label = firstLabelMpls
Expand Down
Loading