From owner-freebsd-questions Thu Sep 3 01:36:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA12810 for freebsd-questions-outgoing; Thu, 3 Sep 1998 01:36:06 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from mail4.dlsu.edu.ph ([165.220.8.49]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA12697 for ; Thu, 3 Sep 1998 01:35:44 -0700 (PDT) (envelope-from 09533893@mail4.dlsu.edu.ph) Received: from localhost (09533893@localhost) by mail4.dlsu.edu.ph (8.7.6/8.7.3) with SMTP id QAA01924 for ; Thu, 3 Sep 1998 16:08:00 +0800 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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