MCPcopy Create free account
hub / github.com/Edgio/vflow / decodeData

Method decodeData

netflow/v9/decoder.go:318–372  ·  view source on GitHub ↗
(tr TemplateRecord)

Source from the content-addressed store, hash-verified

316}
317
318func (d *Decoder) decodeData(tr TemplateRecord) ([]DecodedField, error) {
319 var (
320 fields []DecodedField
321 err error
322 b []byte
323 )
324
325 r := d.reader
326
327 for i := 0; i < len(tr.ScopeFieldSpecifiers); i++ {
328 b, err = r.Read(int(tr.ScopeFieldSpecifiers[i].Length))
329 if err != nil {
330 return nil, err
331 }
332
333 m, ok := ipfix.InfoModel[ipfix.ElementKey{
334 0,
335 tr.ScopeFieldSpecifiers[i].ElementID,
336 }]
337
338 if !ok {
339 return nil, nonfatalError(fmt.Errorf("Netflow element key (%d) not exist (scope)",
340 tr.ScopeFieldSpecifiers[i].ElementID))
341 }
342
343 fields = append(fields, DecodedField{
344 ID: m.FieldID,
345 Value: ipfix.Interpret(&b, m.Type),
346 })
347 }
348
349 for i := 0; i < len(tr.FieldSpecifiers); i++ {
350 b, err = r.Read(int(tr.FieldSpecifiers[i].Length))
351 if err != nil {
352 return nil, err
353 }
354
355 m, ok := ipfix.InfoModel[ipfix.ElementKey{
356 0,
357 tr.FieldSpecifiers[i].ElementID,
358 }]
359
360 if !ok {
361 return nil, nonfatalError(fmt.Errorf("Netflow element key (%d) not exist",
362 tr.FieldSpecifiers[i].ElementID))
363 }
364
365 fields = append(fields, DecodedField{
366 ID: m.FieldID,
367 Value: ipfix.Interpret(&b, m.Type),
368 })
369 }
370
371 return fields, nil
372}
373
374// NewDecoder constructs a decoder
375func NewDecoder(raddr net.IP, b []byte) *Decoder {

Callers 1

decodeSetMethod · 0.95

Calls 3

InterpretFunction · 0.92
ReadMethod · 0.80
nonfatalErrorTypeAlias · 0.70

Tested by

no test coverage detected