(data *[]byte, expanded bool)
| 777 | } |
| 778 | |
| 779 | func decodeCounterSample(data *[]byte, expanded bool) (SFlowCounterSample, error) { |
| 780 | s := SFlowCounterSample{} |
| 781 | var sdc SFlowDataSource |
| 782 | var sdce SFlowDataSourceExpanded |
| 783 | var sdf SFlowDataFormat |
| 784 | |
| 785 | *data, sdf = (*data)[4:], SFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) |
| 786 | s.EnterpriseID, s.Format = sdf.decode() |
| 787 | *data, s.SampleLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) |
| 788 | *data, s.SequenceNumber = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) |
| 789 | if expanded { |
| 790 | *data, sdce = (*data)[8:], SFlowDataSourceExpanded{SFlowSourceFormat(binary.BigEndian.Uint32((*data)[:4])), SFlowSourceValue(binary.BigEndian.Uint32((*data)[4:8]))} |
| 791 | s.SourceIDClass, s.SourceIDIndex = sdce.decode() |
| 792 | } else { |
| 793 | *data, sdc = (*data)[4:], SFlowDataSource(binary.BigEndian.Uint32((*data)[:4])) |
| 794 | s.SourceIDClass, s.SourceIDIndex = sdc.decode() |
| 795 | } |
| 796 | *data, s.RecordCount = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) |
| 797 | |
| 798 | for i := uint32(0); i < s.RecordCount; i++ { |
| 799 | cdf := SFlowCounterDataFormat(binary.BigEndian.Uint32((*data)[:4])) |
| 800 | _, counterRecordType := cdf.decode() |
| 801 | switch counterRecordType { |
| 802 | case SFlowTypeGenericInterfaceCounters: |
| 803 | if record, err := decodeGenericInterfaceCounters(data); err == nil { |
| 804 | s.Records = append(s.Records, record) |
| 805 | } else { |
| 806 | return s, err |
| 807 | } |
| 808 | case SFlowTypeEthernetInterfaceCounters: |
| 809 | if record, err := decodeEthernetCounters(data); err == nil { |
| 810 | s.Records = append(s.Records, record) |
| 811 | } else { |
| 812 | return s, err |
| 813 | } |
| 814 | case SFlowTypeTokenRingInterfaceCounters: |
| 815 | skipRecord(data) |
| 816 | return s, errors.New("skipping TypeTokenRingInterfaceCounters") |
| 817 | case SFlowType100BaseVGInterfaceCounters: |
| 818 | skipRecord(data) |
| 819 | return s, errors.New("skipping Type100BaseVGInterfaceCounters") |
| 820 | case SFlowTypeVLANCounters: |
| 821 | if record, err := decodeVLANCounters(data); err == nil { |
| 822 | s.Records = append(s.Records, record) |
| 823 | } else { |
| 824 | return s, err |
| 825 | } |
| 826 | case SFlowTypeLACPCounters: |
| 827 | if record, err := decodeLACPCounters(data); err == nil { |
| 828 | s.Records = append(s.Records, record) |
| 829 | } else { |
| 830 | return s, err |
| 831 | } |
| 832 | case SFlowTypeProcessorCounters: |
| 833 | if record, err := decodeProcessorCounters(data); err == nil { |
| 834 | s.Records = append(s.Records, record) |
| 835 | } else { |
| 836 | return s, err |
no test coverage detected
searching dependent graphs…