MCPcopy Create free account
hub / github.com/danderson/netboot / Next

Method Next

pcap/reader.go:133–158  ·  view source on GitHub ↗

Next advances the Reader to the next packet in the input, which will then be available through the Packet method. It returns false when the Reader stops, either by reaching the end of the input or an error. After Next returns false, the Err method will return any error that occured while reading, ex

()

Source from the content-addressed store, hash-verified

131// error that occured while reading, except that if it was io.EOF, Err
132// will return nil.
133func (r *Reader) Next() bool {
134 hdr := struct {
135 Sec uint32
136 SubSec uint32
137 Len uint32
138 OrigLen uint32
139 }{}
140
141 if err := binary.Read(r.r, r.order, &hdr); err != nil {
142 r.err = err
143 return false
144 }
145
146 bs := make([]byte, hdr.Len)
147 if _, err := io.ReadFull(r.r, bs); err != nil {
148 r.err = err
149 return false
150 }
151
152 r.pkt = &Packet{
153 Timestamp: time.Unix(int64(hdr.Sec), r.tmult*int64(hdr.SubSec)),
154 Length: int(hdr.OrigLen),
155 Bytes: bs,
156 }
157 return true
158}

Callers 3

udpFromPcapFunction · 0.95
TestFilesFunction · 0.95
TestReadbackFunction · 0.95

Calls 1

ReadMethod · 0.80

Tested by 3

udpFromPcapFunction · 0.76
TestFilesFunction · 0.76
TestReadbackFunction · 0.76