From owner-freebsd-bugs Wed Jun 24 17:41:27 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA08091 for freebsd-bugs-outgoing; Wed, 24 Jun 1998 17:41:27 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from almond.elite.net (root@almond.elite.net [205.199.220.5]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA08006; Wed, 24 Jun 1998 17:40:49 -0700 (PDT) (envelope-from nate@almond.elite.net) Received: (from nate@localhost) by almond.elite.net (8.8.3/ELITE) id RAA05172; Wed, 24 Jun 1998 17:40:45 -0700 (PDT) From: Nate Lawson Message-Id: <199806250040.RAA05172@almond.elite.net> Subject: Apparent bug in sendto() with raw sockets To: freebsd-bugs@FreeBSD.ORG, freebsd-net@FreeBSD.ORG Date: Wed, 24 Jun 1998 17:40:43 -0700 (PDT) X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I had some code that opens a raw socket and sends packets. It worked on 2.0.5 and I recently had to dust it off. To my surprise, the same code (recompiled, of course) now gets "Invalid argument" in the sendto() call on 2.2.5. I stripped out all irrelevant code, and came up with the code fragment below. It works on: OpenBSD 2.4, Linux 2.0.something It fails on: FreeBSD 2.2.5, 2.2.6, 3.0-current The error is always EINVAL in sendto(). Answers? Thanks, Nate /* Cut here for sample code */ #include #include #include #include #include #include main () { static struct sockaddr sa; int fd; int on=1; struct sockaddr_in *p; u_char buf[] = { 0x45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xa, 0x2, 0x2, 0x2, 0xa, 0x1, 0x1, 0x1 }; p = (struct sockaddr_in*)&sa; p->sin_family = AF_INET; p->sin_addr.s_addr = inet_addr ("10.1.1.1"); if ((fd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { perror("socket"); exit(1); } if (setsockopt (fd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) { perror("setsockopt IP_HDRINCL"); exit(1); } if (sendto (fd, buf, sizeof(buf), 0, &sa, sizeof(sa)) < 0) { perror("sendto"); exit(1); } fprintf (stderr, "Success.\n"); exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message