From Jay.Franz at ssa.gov Wed Aug 22 21:40:06 2007 From: Jay.Franz at ssa.gov (Franz, Jay) Date: Wed, 22 Aug 2007 16:40:06 -0400 Subject: [Iftop-users] iftop 0.17 On HP-UX 11.23 Message-ID: I am attempting to compile iftop 0.17 on an HP Integrity (i.e., IA64) server under HP-UX 11.23. I am using the following GNU build environment: ar : GNU ar 2.17 as : GNU assembler 2.17 autoconf : autoconf (GNU Autoconf) 2.61 automake : automake (GNU automake) 1.10 bison : bison (GNU Bison) 2.3 flex : flex 2.5.33 gawk : GNU Awk 3.1.5 gcc : gcc (GCC) 4.1.2 make : GNU Make 3.81 nm : GNU nm 2.17 sed : GNU sed version 4.1.5 shtool : GNU shtool 2.0.7 (19-May-2007) And, the following configure command: CFLAGS=3D'-lpthread' CPPFLAGS=3D'-I /usr/local/include/ncurses' CC=3Dgcc ./configure The CFLAGS parameter is required to overcome an error in configure, to correctly identify the threads capability in HP-UX. The CPPFLAGS parameter is required to overcome an error in make, to correctly located the ncurses library. The command results in the following make error: source=3D'addrs_dlpi.c' object=3D'addrs_dlpi.o' libtool=3Dno \ depfile=3D'.deps/addrs_dlpi.Po' = tmpdepfile=3D'.deps/addrs_dlpi.TPo' \ depmode=3Dgcc3 /bin/sh ./config/depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I. -I /usr/local/include/ncurses -lpthread -c `test -f 'addrs_dlpi.c' || echo './'`a ddrs_dlpi.c addrs_dlpi.c:24:24: error: sys/sockio.h: No such file or directory addrs_dlpi.c:53: warning: 'struct in_addr' declared inside parameter list addrs_dlpi.c:53: warning: its scope is only this definition or declaration, which is probably not what you want addrs_dlpi.c: In function 'get_addrs_dlpi': addrs_dlpi.c:184: error: dereferencing pointer to incomplete type addrs_dlpi.c:190: error: dereferencing pointer to incomplete type addrs_dlpi.c:190: error: invalid application of 'sizeof' to incomplete type 'struct in_addr' make[2]: *** [addrs_dlpi.o] Error 1 make[2]: Leaving directory `/usr/local/install/iftop-0.17' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/install/iftop-0.17' make: *** [all] Error 2 # The first error, regarding the 'sys/sockio.h' header can be overcome by removing the include from the addrs_dlpi.c source, since, according to HP, the socket ioctl definitions are defined in the /usr/include/sys/ioctl.h' header file, which is included in the addrs_dlpi.c source. However, removing the 'sys/sockio.h' reference only resolves the first error; the other errors, regarding the pointer dereferencing and the type application remain. The section of addrs_dlpi.c code apparently generating the errors looks like: 178 #ifdef SIOCGIFADDR 179 180 fd =3D socket(PF_INET, SOCK_DGRAM, 0); /* any sort of IP = socket will do */ 181 182 strncpy(ifr.ifr_name, interface, IFNAMSIZ); 183 184 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_family =3D = AF_INET; 185 186 if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { 187 fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"); 188 perror("ioctl(SIOCGIFADDR)"); 189 } else { 190 memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr)); 191 got_ip_addr =3D 2; 192 } 193 #else 194 fprintf(stderr, "Cannot obtain IP address on this platform\n"); 195 #endif Although the warnings appear to reference the structure definition generating the errors: 51 52 int 53 get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) 54 { 55 int got_hw_addr =3D 0; 56 int got_ip_addr =3D 0; 57 Any ideas as to where to go next? Any help would be appreciated. Thanks. Jay Franz jay.franz@ssa.gov From Jay.Franz at ssa.gov Mon Aug 27 20:49:25 2007 From: Jay.Franz at ssa.gov (Franz, Jay) Date: Mon, 27 Aug 2007 15:49:25 -0400 Subject: [Iftop-users] iftop 0.17 On HP-UX 11.23 Message-ID: After much wailing and gnashing of teeth, I was able to successfully compile iftop 0.17 on HP-UX 11.23 by adding both LDFLAGS and CPPFLAGS definitions to the configure command and by patching two programs. The sordid details follow for any interested parties. Jay Franz jay.franz@ssa.gov =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D First, my build environment: autoconf-2.61 automake-1.10 binutils-2.17 bison-2.3 flex-2.5.33 gawk-3.1.5 gcc-4.1.2 gettext-0.16.1 libiconv-1.11 libpcap-0.9.7 libtool-1.5.24 m4-1.4.9 make-3.81 ncurses-5.6 patch-2.5.4 perl-5.8.8 sed-4.1.5 shtool-2.0.7 termcap-1.3.1 texinfo-4.9 Secondly, my configure statement: # LDFLAGS=3D'-lpthread -lipv6' CPPFLAGS=3D'-I = /usr/local/include/ncurses' ./configure And, finally, two patches, one for 'addrs_dlpi.c.patch' and one for 'dlcommon.c.patch'. addrs_dlpi.c.patch: 24d23 < #include 28a28 > #include dlcommon.c.patch: 28a29 > #include 465c466 < static void --- > void -------------------- An explanation of the above. First, the build environment should be self-explanatory. the gcc, gettext, libiconv, and make packages were downloaded and installed from the Porting and Archiving Center for HP-UX (http://hpux.connect.org.uk/). All others were built on the target server. ---------- Secondly, the first LDFLAG, '-lpthread', addresses the failure of the configure script to accurately identify the threads capability in HP-UX 11.23. Running configure without the flag results in the following error: # ./configure checking POSIX threads compilation... CFLAGS=3D and LIBS=3D checking POSIX threads usability... configure: error: it fails. We probably guessed the wrong CFLAGS. I can provide the 'config.log' for anyone who wants it. ---------- The second LDFLAG, '-lipv6', addresses the error when linking all of the compiled programs: gcc -g -O2 -lpthread -o iftop addr_hash.o edline.o hash.o iftop.o ns_hash.o options.o resolver.o screenfilter.o serv_hash.o sorted_list.o threadprof.o ui.o util.o addrs_ioctl.o addrs_dlpi.o dlcommon.o stringmap.o cfgfile.o vector.o -lpcap -lm -lcurses=20 ld: Unsatisfied symbol "if_nameindex" in file options.o ld: Unsatisfied symbol "if_freenameindex" in file options.o 2 errors. collect2: ld returned 1 exit status The 'if_nameindex' and 'if_freenameindex' symbols are defined in the 'ipv6' library. ---------- The CPPFLAG, '-I /usr/local/include/ncurses', addresses the following compilation error when compiling 'edline.c': source=3D'edline.c' object=3D'edline.o' libtool=3Dno \ depfile=3D'.deps/edline.Po' tmpdepfile=3D'.deps/edline.TPo' \ depmode=3Dgcc3 /bin/sh ./config/depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'edline.c' || echo './'`edline.c edline.c: In function 'edline': edline.c:68: error: 'KEY_END' undeclared (first use in this function) edline.c:68: error: (Each undeclared identifier is reported only once edline.c:68: error: for each function it appears in.) make[2]: *** [edline.o] Error 1 make[2]: Leaving directory `/usr/local/install/iftop-0.17' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/install/iftop-0.17' make: *** [all] Error 2 It is possible that this could be addressed in the configure script, since it appears to correctly identify the native 'curses' library; however, 'gcc' fails to locate the native library and forcing its inclusion (i.e., -I /usr/include) has no effect. ---------- Thirdly, the first patch, for 'addrs_dlpi.c' addresses the following compilation errors: source=3D'addrs_dlpi.c' object=3D'addrs_dlpi.o' libtool=3Dno \ depfile=3D'.deps/addrs_dlpi.Po' = tmpdepfile=3D'.deps/addrs_dlpi.TPo' \ depmode=3Dgcc3 /bin/sh ./config/depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I. -I /usr/local/include/ncurses -g -O2 -c `test -f 'addrs_dlpi.c' || echo './'`addrs_dlpi.c addrs_dlpi.c:24:24: error: sys/sockio.h: No such file or directory addrs_dlpi.c:53: warning: 'struct in_addr' declared inside parameter list addrs_dlpi.c:53: warning: its scope is only this definition or declaration, which is probably not what you want addrs_dlpi.c: In function 'get_addrs_dlpi': addrs_dlpi.c:184: error: dereferencing pointer to incomplete type addrs_dlpi.c:190: error: dereferencing pointer to incomplete type addrs_dlpi.c:190: error: invalid application of 'sizeof' to incomplete type 'struct in_addr'=20 make[2]: *** [addrs_dlpi.o] Error 1 make[2]: Leaving directory `/usr/local/install/iftop-0.17' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/install/iftop-0.17' make: *** [all] Error 2 The first error, regarding the 'sys/sockio.h' header file, is resolved by removing the include statement, as this file does not exist on HP-UX 11.23. The other errors, regarding the 'in_addr' structure, are resolved by including the 'netinet/in.h' library, where it is defined for HP-UX 11.23. ---------- The second patch, for 'dlcommon.c', resolves the following compilation errors and warnings: source=3D'dlcommon.c' object=3D'dlcommon.o' libtool=3Dno \ depfile=3D'.deps/dlcommon.Po' tmpdepfile=3D'.deps/dlcommon.TPo' = \ depmode=3Dgcc3 /bin/sh ./config/depcomp \ gcc -DHAVE_CONFIG_H -I. -I. -I. -I /usr/local/include/ncurses -g -O2 -c `test -f 'dlcommon.c' || echo './'`dlcommon.c dlcommon.c:467: error: static declaration of 'sigalrm' follows non-static declaration dlcommon.h:35: error: previous declaration of 'sigalrm' was here dlcommon.c: In function 'expecting': dlcommon.c:531: warning: incompatible implicit declaration of built-in function 'exit' dlcommon.c: In function 'err': dlcommon.c:1333: warning: incompatible implicit declaration of built-in function 'exit' dlcommon.c: In function 'syserr': dlcommon.c:1340: warning: incompatible implicit declaration of built-in function 'exit' make[2]: *** [dlcommon.o] Error 1 make[2]: Leaving directory `/usr/local/install/iftop-0.17' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/install/iftop-0.17' make: *** [all] Error 2 The errors, regarding re-declaration of the 'sigalrm' function, are resolved by removing the 'static' statement from the re-declaration of the function. This does allow the 'dlcommon.c' program to compile cleanly and the resulting build of iftop appears to work as expected; however, I am not a C programmer and this may not have been what was originally intended. YMMV. The warnings, regarding the 'exit' function, are resolved by including the 'stdlib.h' header file. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D