0

Help!
Now I study about NAT (Network Address Translator), it is a new way about translate IP local to public.
Ok, the point is when I want to install NAT in LINUX, i got error messages like below. I think this is about coding in nat.h. What should I do with the redefinition error?
Thank you for help me. ;)
========================================================
-bash-3.00$ make
making all in nat...
make[1]: Entering directory `/home/petry/Netbench/NetBench-1.1.0/nat'
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c route.c
In file included from route.c:95:
nat.h:165: redefinition of `struct ifnet'
nat.h:174: redefinition of `struct ifqueue'
make[1]: *** [route.o] Error 1
make[1]: Leaving directory `/home/petry/Netbench/NetBench-1.1.0/nat'
make: *** [sub_all] Error 1
========================================================

3
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by p3_tib2001
0

Help!
Now I study about NAT (Network Address Translator), it is a new way about translate IP local to public.
Ok, the point is when I want to install NAT in LINUX, i got error messages like below. I think this is about coding in nat.h. What should I do with the redefinition error?
Thank you for help me. ;)
========================================================
-bash-3.00$ make
making all in nat...
make[1]: Entering directory `/home/petry/Netbench/NetBench-1.1.0/nat'
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c route.c
In file included from route.c:95:
nat.h:165: redefinition of `struct ifnet'
nat.h:174: redefinition of `struct ifqueue'
make[1]: *** [route.o] Error 1
make[1]: Leaving directory `/home/petry/Netbench/NetBench-1.1.0/nat'
make: *** [sub_all] Error 1
========================================================

hi..
First check whether you have declared structs more than 1 time or not.
To check open a terminal and go to the directory containing the source code, using cd command and than execute command
grep -rin "struct ifnet" .
This will list all the lines which contains above structure than u can trace its multiple declaration or definition.

0

Secondly There can be a change that the header file containing the definition of structures , has been included more than once in a file.

0

Secondly There can be a change that the header file containing the definition of structures , has been included more than once in a file.

Maybe, to avoid the problem I suggest using ifndef directive in headers containing structs.

0

Thanks for the advice. I've tried the solutions but still have errors.
The last time I did that I remark the struct. And I got the error message like this.
==========================================================
-bash-3.00$ make
making all in nat...
make[1]: Entering directory `/home/petry/Netbench/NetBench-1.1.0/nat'
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c route.c
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c radix.c
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c nat.c
nat.c:73: sys/protosw.h: No such file or directory
nat.c:81: sys/mbuf.h: No such file or directory
nat.c:108: netinet/ip.h: No such file or directory
In file included from nat.c:116:
nat.h:108: warning: `FWRITE' redefined
/home/petry/simple//sslittle-na-sstrix/include/fcntlbits.h:59: warning: this is the location of the previous definition
nat.h:109: warning: `FREAD' redefined
/home/petry/simple//sslittle-na-sstrix/include/fcntlbits.h:58: warning: this is the location of the previous definition
nat.c:124: netinet/ip_var.h: No such file or directory
nat.c:127: netinet/tcp.h: No such file or directory
nat.c:128: netinet/udp.h: No such file or directory
nat.c:129: netinet/ip_icmp.h: No such file or directory
make[1]: *** [nat.o] Error 1
make[1]: Leaving directory `/home/petry/Netbench/NetBench-1.1.0/nat'
make: *** [sub_all] Error 1

0

Thanks for the advice. I've tried the solutions but still have errors.
The last time I did that I remark the struct. And I got the error message like this.
==========================================================
-bash-3.00$ make
making all in nat...
make[1]: Entering directory `/home/petry/Netbench/NetBench-1.1.0/nat'
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c route.c
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c radix.c
/home/petry/simple/bin/sslittle-na-sstrix-gcc -Wall -DDEBUG -DCONSTANT_PACKET -I/home/petry/Netbench/NetBench-1.1.0/include -DMAX_PACKETS=10 -c nat.c
nat.c:73: sys/protosw.h: No such file or directory
nat.c:81: sys/mbuf.h: No such file or directory
nat.c:108: netinet/ip.h: No such file or directory
In file included from nat.c:116:
nat.h:108: warning: `FWRITE' redefined
/home/petry/simple//sslittle-na-sstrix/include/fcntlbits.h:59: warning: this is the location of the previous definition
nat.h:109: warning: `FREAD' redefined
/home/petry/simple//sslittle-na-sstrix/include/fcntlbits.h:58: warning: this is the location of the previous definition
nat.c:124: netinet/ip_var.h: No such file or directory
nat.c:127: netinet/tcp.h: No such file or directory
nat.c:128: netinet/udp.h: No such file or directory
nat.c:129: netinet/ip_icmp.h: No such file or directory
make[1]: *** [nat.o] Error 1
make[1]: Leaving directory `/home/petry/Netbench/NetBench-1.1.0/nat'
make: *** [sub_all] Error 1

Now here it seems that compiler is not able to find the header files used in nat.c. So specify the search path of those header files in makefile , using -I option.
eg: Header files are somewhere in path /opt/ipp/include
than u can specify the path at the time of compilation or in makefile using option -I as shown below.
gcc myprog.c -I/opt/ipp/include
where myprog.c is my program to be compiled and the header files required by it are present in apth /opt/ipp/include.

0

In the Makefile already use the -I option, like this :
nat.o: nat.c $(HEADER_FILES)
$(CC) $(CFLAG) -I$(NETINCLUDE) -DMAX_PACKETS=$(MAX_PACKETS) -c nat.c

any idea?

0

In the Makefile already use the -I option, like this :
nat.o: nat.c $(HEADER_FILES)
$(CC) $(CFLAG) -I$(NETINCLUDE) -DMAX_PACKETS=$(MAX_PACKETS) -c nat.c

any idea?

Check what has been assigned to varialbe NETINCLUDE and what is the actual path of the header files included in .c file? Are they same?

0

Dear varsha0702,

I've copy file that needed in the appropriate folder. Then, fix another error after copy those files. But, now I got strange error. This error comes from the main program of nat, that is nat.c. If I compile with gcc from Linux, nothing problem with this nat.c. But, now I want to compile the nat.c with gcc from SimpleScalar, and got this error. Here's some errors :
=======================================================
nat.c:1787: invalid type argument of `->'
nat.c:1790: invalid type argument of `->'
nat.c:1791: invalid type argument of `->'
nat.c:1793: invalid type argument of `->'
nat.c:1794: invalid type argument of `->'
nat.c:1795: invalid type argument of `->'
nat.c:1796: invalid type argument of `->'
nat.c:1797: invalid type argument of `->'
nat.c:1798: invalid type argument of `->'
nat.c:1807: `msk' undeclared (first use this function)
nat.c:1810: `iph' undeclared (first use this function)
nat.c:1831: warning: assignment makes integer from pointer without a cast
nat.c:1852: invalid type argument of `->'
nat.c:1853: invalid type argument of `->'
nat.c:1855: invalid type argument of `->'
nat.c:1856: invalid type argument of `->'
nat.c:1857: invalid type argument of `->'
nat.c:1874: invalid type argument of `->'
nat.c:1875: invalid type argument of `->'
nat.c:1880: `csump' undeclared (first use this function)
nat.c:1889: invalid type argument of `->'
nat.c:1889: `TCP_CLOSE' undeclared (first use this function)
nat.c:1890: invalid type argument of `->'
nat.c:1890: `TCP_LAST_ACK' undeclared (first use this function)
nat.c:1893: `udphdr_t' undeclared (first use this function)
nat.c:1893: `udp' undeclared (first use this function)
nat.c:1893: parse error before `)'
nat.c:1899: invalid type argument of `->'
nat.c:1900: invalid type argument of `->'
nat.c:1903: invalid type argument of `->'
nat.c: At top level:
nat.c:1212: warning: `nat_delnat' defined but not used
make[1]: *** [nat.o] Error 1
make[1]: Leaving directory `/home/petry/Netbench/NetBench-1.1.0/nat'
make: *** [sub_all] Error 1
======================================================

Anyone can help me?.. Thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.