According to the wiki: https://switchbrew.org/wiki/Sockets_services#Open, we can use /dev/bpf in NintendoSwitch, so I wrote these code:
Code: Select all
// init socket
SocketInitConfig cfg = *(socketGetDefaultInitConfig());
cfg.bsd_service_type = BsdServiceType_System;
socketInitialize(&cfg);
// open bpf
int fd = open("soc:/dev/bpf0", O_RDWR);
if (fd < 0) {
perror("Unable to open /dev/bpf");
} else {
printf("/dev/bpf: %d\n", fd);
}
// set network interface
struct ifreq ifr;
strncpy(ifr.ifr_name, "lo0", sizeof(ifr.ifr_name));
if (ioctl(fd, BIOCSETIF, &ifr) == -1) {
perror("BIOCSETIF");
return 1;
}
1. I don't know which IF to use, so I used lo0 for testing. If I want to monitor game traffic, which IF should I use ?
2. When using ioctl BIOCSETIF, the program always returned -1 with a blank error description.
3. I am also unable to use BIOCSETF. I am curious if the ioctl on the NintendoSwitch really supports the BIOCSETIF and BIOCSETF as it described in the switchbrew wiki.
In the code of libnx, I saw content related to BIOCSETF, and I think maybe someone has done something similar before.
https://github.com/switchbrew/libnx/bla ... ket.c#L708