dropletzhu/isic-fix — pull request #1 by yformaggio (2014-06-02 14:40:10+00:00)
Title: error: dereferencing pointer to incomplete type

While compiling isic suite I got this error a lot of time when compiling tcpsic and udpsic:

make
gcc -o isic isic.c -Wall -W -g -O2 -I/usr/local/include `libnet-config --cflags` -DHAVE_LIBNET=1 -DSTDC_HEADERS=1 -Din_addr_t=u_int32_t `libnet-config --defines` -DVERSION=\"0.07\" -lnet -L/usr/local/lib `libnet-config --libs`
gcc -o tcpsic tcpsic.c -Wall -W -g -O2 -I/usr/local/include `libnet-config --cflags` -DHAVE_LIBNET=1 -DSTDC_HEADERS=1 -Din_addr_t=u_int32_t `libnet-config --defines` -DVERSION=\"0.07\" -lnet -L/usr/local/lib `libnet-config --libs`
tcpsic.c: In function ‘main’:
tcpsic.c:274:7: error: dereferencing pointer to incomplete type
tcp->th_off = rand() & 0xf;
^
tcpsic.c:275:11: error: dereferencing pointer to incomplete type
else tcp->th_off = 5;
^
tcpsic.c:276:21: error: dereferencing pointer to incomplete type
packet_len += (tcp->th_off) << 2;
^
tcpsic.c:296:7: error: dereferencing pointer to incomplete type
tcp->th_sport = RAND16;
^
tcpsic.c:297:11: error: dereferencing pointer to incomplete type
else tcp->th_sport = src_prt;
^
tcpsic.c:299:7: error: dereferencing pointer to incomplete type
tcp->th_dport = RAND16;
^
tcpsic.c:300:11: error: dereferencing pointer to incomplete type
else tcp->th_dport = dst_prt;
^
tcpsic.c:302:6: error: dereferencing pointer to incomplete type
tcp->th_seq = RAND32;
^
tcpsic.c:303:6: error: dereferencing pointer to incomplete type
tcp->th_ack = RAND32;
^
tcpsic.c:304:6: error: dereferencing pointer to incomplete type
tcp->th_x2 = rand() & 0xf; /* 4bit */
^
tcpsic.c:305:6: error: dereferencing pointer to incomplete type
tcp->th_flags = RAND8;
^
tcpsic.c:306:6: error: dereferencing pointer to incomplete type
tcp->th_win = RAND16;
^
tcpsic.c:307:6: error: dereferencing pointer to incomplete type
tcp->th_sum = 0;
^
tcpsic.c:309:7: error: dereferencing pointer to incomplete type
tcp->th_urp = RAND16;
^
tcpsic.c:310:11: error: dereferencing pointer to incomplete type
else tcp->th_urp = 0;
^
tcpsic.c:318:7: error: dereferencing pointer to incomplete type
tcp->th_sum = RAND16;
^
tcpsic.c:319:64: error: dereferencing pointer to incomplete type
else libnet_do_checksum(l, (u_int8_t *)buf, IPPROTO_TCP, (tcp->th_off<<2)+payload_s);
^
Makefile:27: recipe for target 'tcpsic' failed
make: *** [tcpsic] Error 1

It appears to me that the problem was due to missing headers in isic.h file. So I added

#include
#include

And it compiles without errors, only warnings.

For information my configuration is the following:

ArchLinux Linux 3.14.4-1-ARCH #1 SMP PREEMPT Tue May 13 16:41:39 CEST 2014 x86_64 GNU/Linux
gcc (GCC) 4.9.0 20140521 (prerelease)
and libnet-master.

I also removed config.status and added Makefile to a created .gitignore file.