MCPcopy Index your code
hub / github.com/Edgio/vflow / decodeData

Method decodeData

ipfix/decoder.go:508–575  ·  view source on GitHub ↗
(tr TemplateRecord)

Source from the content-addressed store, hash-verified

506}
507
508func (d *Decoder) decodeData(tr TemplateRecord) ([]DecodedField, error) {
509 var (
510 fields []DecodedField
511 err error
512 b []byte
513 readLength uint16
514 )
515
516 r := d.reader
517
518 for i := 0; i < len(tr.ScopeFieldSpecifiers); i++ {
519 m, ok := InfoModel[ElementKey{
520 tr.ScopeFieldSpecifiers[i].EnterpriseNo,
521 tr.ScopeFieldSpecifiers[i].ElementID,
522 }]
523
524 if !ok {
525 return nil, nonfatalError{fmt.Errorf("IPFIX element key (%d) not exist (scope)",
526 tr.ScopeFieldSpecifiers[i].ElementID)}
527 }
528
529 if readLength, err = d.getDataLength(tr.ScopeFieldSpecifiers[i].Length, m.Type); err != nil {
530 return nil, err
531 }
532
533 if b, err = r.Read(int(readLength)); err != nil {
534 return nil, err
535 }
536
537 fields = append(fields, DecodedField{
538 ID: m.FieldID,
539 Value: Interpret(&b, m.Type),
540 EnterpriseNo: tr.ScopeFieldSpecifiers[i].EnterpriseNo,
541 })
542 }
543
544 for i := 0; i < len(tr.FieldSpecifiers); i++ {
545 m, ok := InfoModel[ElementKey{
546 tr.FieldSpecifiers[i].EnterpriseNo,
547 tr.FieldSpecifiers[i].ElementID,
548 }]
549
550 if !ok {
551 return nil, nonfatalError{fmt.Errorf("IPFIX element key (%d) not exist",
552 tr.FieldSpecifiers[i].ElementID)}
553 }
554
555 if readLength, err = d.getDataLength(tr.FieldSpecifiers[i].Length, m.Type); err != nil {
556 return nil, err
557 }
558
559 if b, err = r.Read(int(readLength)); err != nil {
560 return nil, err
561 }
562
563 fields = append(fields, DecodedField{
564 ID: m.FieldID,
565 Value: Interpret(&b, m.Type),

Callers 1

decodeSetMethod · 0.95

Calls 3

getDataLengthMethod · 0.95
InterpretFunction · 0.85
ReadMethod · 0.80

Tested by

no test coverage detected