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

Function decodeFlowCounter

sflow/flow_counter.go:155–221  ·  view source on GitHub ↗
(r io.ReadSeeker)

Source from the content-addressed store, hash-verified

153}
154
155func decodeFlowCounter(r io.ReadSeeker) (*CounterSample, error) {
156 var (
157 cs = new(CounterSample)
158 rTypeFormat uint32
159 rTypeLength uint32
160 err error
161 )
162
163 if err = cs.unmarshal(r); err != nil {
164 return nil, err
165 }
166
167 cs.Records = make(map[string]Record)
168
169 for i := uint32(0); i < cs.RecordsNo; i++ {
170 if err = read(r, &rTypeFormat); err != nil {
171 return nil, err
172 }
173 if err = read(r, &rTypeLength); err != nil {
174 return nil, err
175 }
176
177 switch rTypeFormat {
178
179 case SFGenericInterfaceCounters:
180 d, err := decodeGenericIntCounters(r)
181 if err != nil {
182 return cs, err
183 }
184 cs.Records["GenInt"] = d
185 case SFEthernetInterfaceCounters:
186 d, err := decodeEthIntCounters(r)
187 if err != nil {
188 return cs, err
189 }
190 cs.Records["EthInt"] = d
191 case SFTokenRingInterfaceCounters:
192 d, err := decodeTokenRingCounters(r)
193 if err != nil {
194 return cs, err
195 }
196 cs.Records["TRInt"] = d
197 case SF100BaseVGInterfaceCounters:
198 d, err := decodeVGCounters(r)
199 if err != nil {
200 return cs, err
201 }
202 cs.Records["VGInt"] = d
203 case SFVLANCounters:
204 d, err := decodeVlanCounters(r)
205 if err != nil {
206 return cs, err
207 }
208 cs.Records["Vlan"] = d
209 case SFProcessorCounters:
210 d, err := decodedProcessorCounters(r)
211 if err != nil {
212 return cs, err

Callers 1

SFDecodeMethod · 0.85

Calls 8

readFunction · 0.85
decodeGenericIntCountersFunction · 0.85
decodeEthIntCountersFunction · 0.85
decodeTokenRingCountersFunction · 0.85
decodeVGCountersFunction · 0.85
decodeVlanCountersFunction · 0.85
decodedProcessorCountersFunction · 0.85
unmarshalMethod · 0.45

Tested by

no test coverage detected