Skip to content

Commit

Permalink
fix decoding order in decodeData
Browse files Browse the repository at this point in the history
  • Loading branch information
glowa001 committed Nov 30, 2018
1 parent f5dc6c2 commit 819155e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions ipfix/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,48 +480,48 @@ func (d *Decoder) decodeData(tr TemplateRecord) ([]DecodedField, error) {
)
r := d.reader

for i := 0; i < len(tr.FieldSpecifiers); i++ {
b, err = r.Read(int(tr.FieldSpecifiers[i].Length))
for i := 0; i < len(tr.ScopeFieldSpecifiers); i++ {
b, err = r.Read(int(tr.ScopeFieldSpecifiers[i].Length))
if err != nil {
return nil, err
}

m, ok := InfoModel[ElementKey{
tr.FieldSpecifiers[i].EnterpriseNo,
tr.FieldSpecifiers[i].ElementID,
tr.ScopeFieldSpecifiers[i].EnterpriseNo,
tr.ScopeFieldSpecifiers[i].ElementID,
}]

if !ok {
return nil, nonfatalError(fmt.Errorf("IPFIX element key (%d) not exist",
tr.FieldSpecifiers[i].ElementID))
return nil, nonfatalError(fmt.Errorf("IPFIX element key (%d) not exist (scope)",
tr.ScopeFieldSpecifiers[i].ElementID))
}

fields = append(fields, DecodedField{
ID: m.FieldID,
Value: Interpret(&b, m.Type),
ID: m.FieldID,
Value: Interpret(&b, m.Type),
EnterpriseNo: tr.ScopeFieldSpecifiers[i].EnterpriseNo,
})
}

for i := 0; i < len(tr.ScopeFieldSpecifiers); i++ {
b, err = r.Read(int(tr.ScopeFieldSpecifiers[i].Length))
for i := 0; i < len(tr.FieldSpecifiers); i++ {
b, err = r.Read(int(tr.FieldSpecifiers[i].Length))
if err != nil {
return nil, err
}

m, ok := InfoModel[ElementKey{
tr.ScopeFieldSpecifiers[i].EnterpriseNo,
tr.ScopeFieldSpecifiers[i].ElementID,
tr.FieldSpecifiers[i].EnterpriseNo,
tr.FieldSpecifiers[i].ElementID,
}]

if !ok {
return nil, nonfatalError(fmt.Errorf("IPFIX element key (%d) not exist (scope)",
tr.ScopeFieldSpecifiers[i].ElementID))
return nil, nonfatalError(fmt.Errorf("IPFIX element key (%d) not exist",
tr.FieldSpecifiers[i].ElementID))
}

fields = append(fields, DecodedField{
ID: m.FieldID,
Value: Interpret(&b, m.Type),
EnterpriseNo: tr.ScopeFieldSpecifiers[i].EnterpriseNo,
ID: m.FieldID,
Value: Interpret(&b, m.Type),
})
}

Expand Down

0 comments on commit 819155e

Please sign in to comment.