From owner-freebsd-net Sun Jan 5 3:30:51 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 267C437B407 for ; Sun, 5 Jan 2003 03:30:43 -0800 (PST) Received: from basit.cc (wireless.cs.twsu.edu [156.26.10.125]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD50E43EC2 for ; Sun, 5 Jan 2003 03:30:42 -0800 (PST) (envelope-from basit@basit.cc) Received: from basit (helo=localhost) by basit.cc with local-esmtp (Exim 4.10) id 18V90B-000D0A-00 for net@freebsd.org; Sun, 05 Jan 2003 05:31:35 -0600 Date: Sun, 5 Jan 2003 05:31:35 -0600 (CST) From: Abdul Basit X-X-Sender: basit@wireless.cs.twsu.edu To: net@freebsd.org Subject: raw socket/icmp-echo Message-ID: <20030105052449.K49935-100000@wireless.cs.twsu.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hello, I was trying to learn raw sockets, I wrote a simple program to get all icmp packets and display .. -- program int main(void) { int sockfd; int ip_len; char *buf; int n; struct icmp *icmp; struct ip *ip; buf = (char*) malloc(sizeof(struct ip)+sizeof(struct icmp)); sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); for (;;) { n = recv(sockfd, buf, sizeof(buf),0); ip = (struct ip *) buf; ip_len = ip->ip_hl << 2; // ip header length icmp = (struct icmp *) (buf + ip_len); if (icmp->icmp_type == ICMP_ECHO) { printf("ping request arrived\n"); } } } -- end The program compiles fine, but it can't recieve echo request , seems like the BSD kernel is not passing icmp echo type requests to raw socket? I beleive this is NOT the case in Linux, why this behaviour exists in BSD? is there any way to circumvent this ? Also, if anyone know any good tutorial on bpf , let me know the url (some simple example for capturing will be good .. i read bpf manpage, it seems little obscure to me). -- basit Graduate Stdudent Dept. Of Computer science. Wichita state university To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message