NextPacket returns the next decoded packet from the PacketSource. On error, it returns a nil packet and a non-nil error.
()
| 798 | // NextPacket returns the next decoded packet from the PacketSource. On error, |
| 799 | // it returns a nil packet and a non-nil error. |
| 800 | func (p *PacketSource) NextPacket() (Packet, error) { |
| 801 | data, ci, err := p.source.ReadPacketData() |
| 802 | if err != nil { |
| 803 | return nil, err |
| 804 | } |
| 805 | packet := NewPacket(data, p.decoder, p.DecodeOptions) |
| 806 | m := packet.Metadata() |
| 807 | m.CaptureInfo = ci |
| 808 | m.Truncated = m.Truncated || ci.CaptureLength < ci.Length |
| 809 | return packet, nil |
| 810 | } |
| 811 | |
| 812 | // packetsToChannel reads in all packets from the packet source and sends them |
| 813 | // to the given channel. This routine terminates when a non-temporary error |
no test coverage detected