From owner-freebsd-net Mon Nov 23 00:32:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA14076 for freebsd-net-outgoing; Mon, 23 Nov 1998 00:32:00 -0800 (PST) (envelope-from owner-freebsd-net@FreeBSD.ORG) Received: from obie.softweyr.com ([204.68.178.33]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA14071 for ; Mon, 23 Nov 1998 00:31:57 -0800 (PST) (envelope-from wes@softweyr.com) Received: from softweyr.com (zaphod.softweyr.com [204.68.178.35]) by obie.softweyr.com (8.8.8/8.8.8) with ESMTP id BAA04997; Mon, 23 Nov 1998 01:31:10 -0700 (MST) (envelope-from wes@softweyr.com) Message-ID: <36591D4D.F335DC8F@softweyr.com> Date: Mon, 23 Nov 1998 01:31:10 -0700 From: Wes Peters Organization: Softweyr llc X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 3.0-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Vladislav SAFRONOV <0824@08700000.mhs.rosmail.com> CC: freebsd-net@FreeBSD.ORG Subject: Re: Help! Modifying Linux sources to compile under 2.2.7R. References: <151BD2D781F0D57E%151BD2D781F0D57E@mhs.mhs.rosmail.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Vladislav SAFRONOV wrote: > > I want to compile a little c program under Freebsd, but the source > warns: > > "Linux 2.0.33 source, will compile on BSD if you modify the ip > header etc." > > I thought small tcp/ip applications could be copmiled under any Unix > :(, Hah! You don't understand UNIX portability that well. You always have to poke around the various header files a bit. > Well what should I modify? What's the difference between BSD ip > header and Linux ip header? Well, first of all, if you're dinking with the raw IP header, this isn't a "typical" tcp/ip program at all. A typical tcp/ip program just opens a socket connection and pumps data through it. > ... > struct iphdr *iph=(struct iphdr *)buf; > struct udphdr *udp=(struct udphdr *)(buf + 20); > ... > iph->version=4; > iph->ihl=5; > iph->tos=0; > iph->tot_len=htons(sizeof(buf)); > iph->id=htons(1234); > iph->frag_off=0; > iph->ttl=255; > iph->protocol=17; > > iph->saddr=inet_addr(SIP); > iph->daddr=resolve_address(argv[1]); See /usr/include/netinet/ip.h, /usr/include/netinet/tcp.h, and /usr/include/netinet/udp.h. Or, better yet, get yourself a copy of Unix Network Program vol 1 by W. Richard Stevens. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC http://www.softweyr.com/~softweyr wes@softweyr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message