2005/9/23, Tyler T <[EMAIL PROTECTED]>: > 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 <stdio.h> > #include <stdlib.h> > #include <unistd.h> > #include <netinet/in.h> > #include <sys/types.h> > #include <sys/socket.h> > #include <netinet/ip.h> > #include <netinet/tcp.h> > #include <sys/time.h> > #include <arpa/inet.h> > > #include <netdb.h> > > struct ip *create_iph(char *ips, char *ipd, int sec); > void show_iph(struct ip *iph); > > int main(){ > > struct ip *iph; > > iph = create_iph("127.0.0.1","127.0.0.1",10); > showiph(iph); > > free(iph); > > iph=NULL; > > return 0; > > } > > struct ip *create_iph(char *ips, char *ipd, int sec){ > > struct ip *iph; > > iph = malloc(sizeof(struct ip)); > > iph->ip_v = 4; > iph->ip_hl = 5; > iph->ip_tos = 0; > iph->ip_len = sizeof(struct ip) + sizeof(struct tcphdr); > iph->ip_id = htons(sec); //cambiar el id por el numero de port a > scanear > iph->ip_ttl = 255; > iph->ip_p = 6; > iph->ip_sum = 0; //checksum > iph->ip_src.s_addr = inet_addr(ips); > iph->ip_dst.s_addr = 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 <netinet/in_systm.h> thanks for all. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"