INNER CODE UNIT · Go

htons

mozillazg/ptcpdump · bpf/bpf.go:471

func htons(n uint16) uint16 {
	b := *(*[2]byte)(unsafe.Pointer(&n))
	return binary.BigEndian.Uint16(b[:])
}

func (b *BPF) applyFilters() error {
	value := uint8(0)
	opts := b.opts

	log.Infof("start to update FilterPidMap with %+v", opts.pids)
	for _, pid := range opts.pids {
		pid := pid
		if err := b.objs.BpfMaps.PtcpdumpFilterPidMap.Update(pid, value, ebpf.UpdateAny); err != nil {
			return fmt.Errorf("update FilterPidMap: %w", err)
		}
	}

	log.Infof("start to update FilterUidMap with %+v", opts.pids)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…