Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Nov 1998 01:31:10 -0700
From:      Wes Peters <wes@softweyr.com>
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.
Message-ID:  <36591D4D.F335DC8F@softweyr.com>
References:  <151BD2D781F0D57E%151BD2D781F0D57E@mhs.mhs.rosmail.com>

index | next in thread | previous in thread | raw e-mail

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


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36591D4D.F335DC8F>