func (p *packetConn) handleStats(s *unix.TpacketStats) *Stats {
	// Does the caller want instantaneous stats as provided by Linux?  If so,
	// return the structure directly.
	if p.noCumulativeStats {
		return &Stats{
			Packets: uint64(s.Packets),
			Drops:   uint64(s.Drops),
		}
	}

	// The caller wants cumulative stats.  Add stats with the internal stats
	// structure and return a copy of the resulting stats.
	packets := atomic.AddUint64(&p.stats.Packets, uint64(s.Packets))
	drops := atomic.AddUint64(&p.stats.Drops, uint64(s.Drops))

	return &Stats{
		Packets: packets,
		Drops:   drops,
	}
}
// handleStats handles creation of Stats structures from raw packet socket stats.
handleStats handles creation of Stats structures from raw packet socket stats.
// handleStats handles creation of Stats structures from raw packet socket stats .
func (p *packetConn) handleStats(s *unix.TpacketStats) *Stats {
	if p.noCumulativeStats {
		return &Stats{
			Packets: uint64(s.Packets),
			Drops:   uint64(s.Drops),
		}
	}
	packets := atomic.AddUint64(&p.stats.Packets, uint64(s.Packets))
	drops := atomic.AddUint64(&p.stats.Drops, uint64(s.Drops))
	return &Stats{
		Packets: packets,
		Drops:   drops,
	}
}
func ( p * packetConn ) handleStats ( s * unix . TpacketStats ) * Stats { if p . noCumulativeStats { return & Stats { Packets : uint64 ( s . Packets ) , Drops : uint64 ( s . Drops ) , } } packets := atomic . AddUint64 ( & p . stats . Packets , uint64 ( s . Packets ) ) drops := atomic . AddUint64 ( & p . stats . Drops , uint64 ( s . Drops ) ) return & Stats { Packets : packets , Drops : drops , } }
handleStats handles creation of Stats structures from raw packet socket stats.
handleStats handles creation of Stats structures from raw packet socket stats .
// Does the caller want instantaneous stats as provided by Linux?  If so, // return the structure directly. // The caller wants cumulative stats.  Add stats with the internal stats // structure and return a copy of the resulting stats.