Date: Thu, 3 Sep 1998 16:07:57 +0800 (HKT) From: "Canicula. Roel M." <09533893@mail4.dlsu.edu.ph> To: questions@FreeBSD.ORG Subject: BPF Message-ID: <Pine.LNX.3.95.980903155709.1272A-100000@mail4.dlsu.edu.ph>
next in thread | raw e-mail | index | archive | help
Greetings!
I'm Roel Canicula from De La Salle University in Manila, Philippines.
I've been trying to port my linux packet capture routines to work under
FreeBSD. I have read the bpf manual page and came up with the following
code:
void main() {
int fd;
struct ifreq ifr;
char buf[500];
/* Open /dev/bpf0 */
if ((fd=open("/dev/bpf0", O_RDONLY))==-1) {
perror("open");
exit(1);
}
/* Bind file descriptor to network interface (eb0) */
strcpy(ifr.ifr_name, "eb0");
if (ioctl(fd, BIOCSETIF, &ifr)==-1) {
perror("BIOCSETIF");
exit(1);
}
/* Listen for packets */
if (read(fd, buf, 500)==-1) {
perror("read");
exit(1);
}
...
}
The read() function returns an error and sets errno to EINVAL. I can't
figure out what's wrong with the code. I'd really appreciate it if you
could tell me how to make it work. Thank you very much.
Roel Canicula
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.3.95.980903155709.1272A-100000>
