From owner-freebsd-questions@FreeBSD.ORG Fri Sep 23 09:06:05 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 25F4616A41F for ; Fri, 23 Sep 2005 09:06:05 +0000 (GMT) (envelope-from espartano.list@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id A442743D45 for ; Fri, 23 Sep 2005 09:06:04 +0000 (GMT) (envelope-from espartano.list@gmail.com) Received: by xproxy.gmail.com with SMTP id t13so575467wxc for ; Fri, 23 Sep 2005 02:06:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Qfkx/SeGtTYGv30BmOW2Bxx/O5vLlFC7owJMwWSyc8aJORve+3Ge1rTcVnrYJpdmCegdQ/eAUBpJaT/HtlVQ6dv/Ii4uu4d2IldoS+bNM5feRGEcheSCW9U8vJRuCILD82AgyS/WdlmgFE1oWJ1EvwPcIoKLSgIJ+hXqg8ROxME= Received: by 10.70.63.2 with SMTP id l2mr951397wxa; Fri, 23 Sep 2005 02:06:03 -0700 (PDT) Received: by 10.70.125.20 with HTTP; Fri, 23 Sep 2005 02:06:03 -0700 (PDT) Message-ID: <9385b1fc05092302062e1cb50d@mail.gmail.com> Date: Fri, 23 Sep 2005 04:06:03 -0500 From: Tyler T To: freebsd-questions@freebsd.org In-Reply-To: <9385b1fc0509230142733b4f94@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <9385b1fc0509230142733b4f94@mail.gmail.com> Subject: Re: Problen with a little C program X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tyler T List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2005 09:06:05 -0000 2005/9/23, Tyler T : > hi list, firts sorry for my english. > > for hobbye i am trying to write a little program in C lenguage, the > program create a ip header and show the values of ip header whitout > send any data, only create the header, the program is this: > > //////BEGIN//////// > #include > #include > #include > #include > #include > #include > #include > #include > #include > #include > > #include > > struct ip *create_iph(char *ips, char *ipd, int sec); > void show_iph(struct ip *iph); > > int main(){ > > struct ip *iph; > > iph =3D create_iph("127.0.0.1","127.0.0.1",10); > showiph(iph); > > free(iph); > > iph=3DNULL; > > return 0; > > } > > struct ip *create_iph(char *ips, char *ipd, int sec){ > > struct ip *iph; > > iph =3D malloc(sizeof(struct ip)); > > iph->ip_v =3D 4; > iph->ip_hl =3D 5; > iph->ip_tos =3D 0; > iph->ip_len =3D sizeof(struct ip) + sizeof(struct tcphdr); > iph->ip_id =3D htons(sec); //cambiar el id por el numero de port = a scanear > iph->ip_ttl =3D 255; > iph->ip_p =3D 6; > iph->ip_sum =3D 0; //checksum > iph->ip_src.s_addr =3D inet_addr(ips); > iph->ip_dst.s_addr =3D inet_addr(ipd); > > return iph; > } > > void show_iph(struct ip *iph){ > > printf("version %d\n",iph->ip_v); > printf("header leng (ihl) %d\n",iph->ip_hl); > printf("total leng %d\n",iph->ip_len); > printf("identification %d\n",iph->ip_id); > printf("TTL %d\n",iph->ip_ttl); > printf("protocol %d\n",iph->ip_p); > printf("checksum %d\n",iph->ip_sum); > printf("type of service (TOS) %d\n",iph->ip_tos); > printf("ip source %s\n",inet_ntoa(iph->ip_src)); > printf("ip destination %s\n",inet_ntoa(iph->ip_dst)); > > } > ////////END/////// > > when i execute: "gcc -o sock_raw sock_raw.c" i obtain: > > -bash-2.05b$ gcc -o sock_raw sock_raw.c > In file included from sock_raw.c:7: > /usr/include/netinet/ip.h:160: error: syntax error before "n_long" > /usr/include/netinet/ip.h:163: error: syntax error before "n_long" > -bash-2.05b$ > > > my system is: FreeBSD 5.4 STABLE > and my gcc version is: gcc version 3.4.2 [FreeBSD] 20040728 > > thanks in advance. > sorry, i have the solution: It was necessary to include the library thanks for all.