Example #1
0
File: pcap.go Project: robfig/pcap
func (p *Pcap) SetMonitor(monitor bool) error {
	var mon int32
	if monitor {
		mon = 1
	}

	if C.pcap_set_rfmon(p.cptr, C.int(mon)) != 0 {
		return p.Geterror()
	}
	return nil
}
Example #2
0
// Enable/disable monitor mode. This is only relevant to RF-based packet sources
// (e.g. a WiFi or Bluetooth network interface)
func (h *Handle) SetMonitorMode(monitor bool) error {
	var rfmon_int C.int

	if monitor {
		rfmon_int = 1
	} else {
		rfmon_int = 0
	}

	err := C.pcap_set_rfmon(h.pcap, rfmon_int)
	if err < 0 {
		return fmt.Errorf("Handle already active")
	}

	return nil
}
Example #3
0
// SetRFMon turns on radio monitoring mode, similar to promiscuous mode but for
// wireless networks.  If this mode is enabled, the interface will not need to
// associate with an access point before it can receive traffic.
func (p *InactiveHandle) SetRFMon(monitor bool) error {
	var mon C.int
	if monitor {
		mon = 1
	}
	switch canset := C.pcap_can_set_rfmon(p.cptr); canset {
	case 0:
		return CannotSetRFMon
	case 1:
		// success
	default:
		return statusError(canset)
	}
	if status := C.pcap_set_rfmon(p.cptr, mon); status != 0 {
		return statusError(status)
	}
	return nil
}