Home
Support

Knowledge Base

BSPs and drivers
Community resources
Product documentation
Questions?
Contact us

How to activate promiscuous mode with io-pkt
 
________________________________________________________________________

Applicable Environment
________________________________________________________________________
  • Topic: How to activate promiscuous mode with io-pkt
  • SDP: 6.5.0
  • Target: Any supported target
________________________________________________________________________

Recommendation
________________________________________________________________________

With io-net network driver arguments could be used to enable promiscuous. Since io-pkt the promiscuous is enabled on demand by the stack. Setting up a bridge or running tcpdump (bpf utility) enables this mode for example. Note that nicinfo maybe prints inaccurate status of the promiscuous mode. Check the status with ifconfig instead.

This is an c-example on how to enable promiscuous mode on interface en0:

#include <string.h>
#include <stdlib.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <err.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/bpf.h>
#include <net/if.h>

int main(int argc, char *argv[])
{
int fd;
char *bpfn, *ifname;
struct ifreq ifr;

bpfn = "/dev/bpf0";
ifname = "en0";

if ((fd = open(bpfn, O_RDWR)) == -1) {
perror("open");
exit(0);
}

strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, &ifr) == -1) {
perror("ioctl BIOCSETIF");
exit(0);
}

if (ioctl(fd, BIOCPROMISC, NULL) == -1) {
perror("ioctl BIOCPROMISC");
exit(0);
}

sleep(10);
close(fd);
return 0;
}

PROMISC in the ifconfig output for the en0 interface indicate that promiscuous is active.

/root# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
inet 127.0.0.1 netmask 0xff000000
en0: flags=80008b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST,SHIM
> mtu 1500
address: 00:80:ad:b7:d7:3f
media: Ethernet 100baseTX full-duplex
status: active
inet 10.42.171.102 netmask 0xffffff00 broadcast 10.42.171.255

________________________________________________________________________
NOTE: This entry has been validated against the SDP version listed above. Use caution when considering this advice for any other SDP version. For supported releases, please reach out to QNX Technical Support if you have any questions/concerns.
________________________________________________________________________


Related Attachments
 None Found





Please contact us with your questions or concerns.