| 313 | } |
| 314 | |
| 315 | func (d *Decoder) decodeFlows(flowCount int, msg *Message) error { |
| 316 | remainingLen := d.reader.Len() |
| 317 | expectedLen := flowCount * 48 |
| 318 | flowIndex := 0 |
| 319 | |
| 320 | var err error |
| 321 | |
| 322 | if expectedLen > remainingLen { |
| 323 | err = fmt.Errorf("Expect %v bytes to read, %v remaining bytes encountered", expectedLen, remainingLen) |
| 324 | } |
| 325 | |
| 326 | // there should be *flowCount* number of flows in the message, each 48 bytes long |
| 327 | for err == nil && flowIndex < flowCount { |
| 328 | |
| 329 | fr := FlowRecord{} |
| 330 | err = fr.unmarshal(d.reader) |
| 331 | if err == nil { |
| 332 | msg.Flows = append(msg.Flows, fr) |
| 333 | } |
| 334 | flowIndex++ |
| 335 | } |
| 336 | |
| 337 | return err |
| 338 | } |
| 339 | |
| 340 | func combineErrors(errorSlice ...error) (err error) { |
| 341 | switch len(errorSlice) { |