nast-0.2.0/0040755000175000001440000000000010014474061011663 5ustar embyteusersnast-0.2.0/BUGS0100644000175000001440000000100710003274504012337 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool Known BUGS ============================================================================ Checking promisc can have bad response, pay attention! Nast doesn't compile with gcc < 3. We must make more tests! Port scanner and some other plugins don't work with lo device yet. In graphical mode the sniffer uses only 10000 lines before clean all and restart. nast-0.2.0/TODO0100644000175000001440000000105110014144201012333 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool TODO ============================================================================ This file could change unexpectedly ;-) 0.2.1 ===== implement tcpstream and rst for any connection add os fingerprinting rewrite port scanner rewrite psearch() routine add debug support write a cool connection tracking 0.2.2 ===== sniff other packets (handle_DNS() for example) 0.3.0 ===== GTK+ interface nast-0.2.0/depcomp0100644000175000001440000002752510003274507013246 0ustar embyteusers#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. This file always lives in the current directory. # Also, the AIX compiler puts `$object:' at the start of each line; # $object doesn't have directory information. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" outname="$stripped.o" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; tru64) # The Tru64 AIX compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. tmpdepfile1="$object.d" tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` if test "$libtool" = yes; then "$@" -Wc,-MD else "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a space and a tab in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. test -z "$dashmflag" && dashmflag=-M ( IFS=" " case " $* " in *" --mode=compile "*) # this is libtool, let us make it quiet for arg do # cycle over the arguments case "$arg" in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) # X makedepend ( shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift;; -*) ;; *) set fnord "$@" "$arg"; shift;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tail +3 "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 nast-0.2.0/arp.c0100644000175000001440000001471310003274511012610 0ustar embyteusers/* Nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" void handle_ARP (FILE *output) { struct nast_arp_hdr *arp; struct libnet_ethernet_hdr *eptr; u_short ether_type; eptr = (struct libnet_ethernet_hdr *) packet; arp = (struct nast_arp_hdr *) (packet+offset); ether_type = ntohs(eptr->ether_type); if (ether_type == ETHERTYPE_ARP) { n_print("princ",line_s,row_s,lg,"\n---[ ARP ]-----------------------------------------------------------\n"); n_print("princ",line_s=line_s+2,row_s,lg,"%s", nast_hex_ntoa (eptr->ether_shost)); n_print("princ",line_s,28,lg," -> "); n_print("princ",line_s,33,lg, "%s\n", nast_hex_ntoa (eptr->ether_dhost)); switch (ntohs(arp->ar_op)) { case 1: { n_print("princ",++line_s,row_s,lg,"Type: ARP request: "); n_print("princ",line_s,20,lg,"Who has %d.%d.%d.%d? ",arp->__ar_tip[0],arp->__ar_tip[1],arp->__ar_tip[2],arp->__ar_tip[3]); n_print("princ",line_s,46,lg,"Tell %d.%d.%d.%d\n",arp->__ar_sip[0],arp->__ar_sip[1],arp->__ar_sip[2],arp->__ar_sip[3]); } break; case 2: { n_print("princ",++line_s,row_s,lg,"Type: ARP reply: "); n_print("princ",line_s,20,lg,"%d.%d.%d.%d is at %s\n",arp->__ar_sip[0],arp->__ar_sip[1],arp->__ar_sip[2],arp->__ar_sip[3], nast_hex_ntoa (eptr->ether_shost)); } break; case 8: n_print("princ",++line_s,row_s,lg,"Type: InARP request"); break; case 9: n_print("princ",++line_s,row_s,lg,"Type: InARP reply"); break; default: n_print("princ",++line_s,row_s,lg,"Type: Unknown Opcode"); break; } n_print("princ",++line_s,row_s,lg,"Hardware size: %d - ", arp->ar_hln); n_print("princ",line_s,30,lg,"Protocol size: %d\n", arp->ar_pln); } else if (eptr->ether_type == ETHERTYPE_REVARP) { n_print("princ",line_s,row_s,lg,"\n---[ RARP ]----------------------------------------------------------\n"); n_print("princ",line_s=line_s+2,row_s,lg,"%s" , nast_hex_ntoa (eptr->ether_shost)); n_print("princ",line_s,28,lg," -> "); n_print("princ",line_s,33,lg,"%s\n", nast_hex_ntoa (eptr->ether_dhost)); switch (ntohs(arp->ar_op)) { case 3: n_print("princ",++line_s,row_s,lg,"Type: RARP request"); break; case 4: n_print("princ",++line_s,row_s,lg,"Type: RARP reply"); break; case 8: n_print("princ",++line_s,row_s,lg,"Type: InARP request"); break; case 9: n_print("princ",++line_s,row_s,lg,"Type: InARP reply"); break; default: n_print("princ",++line_s,row_s,lg,"Type: Unknown Opcode"); break; } n_print("princ",++line_s,row_s,lg,"Hardware size: %d ",arp->ar_hln); n_print("princ",++line_s,30,lg,"Protocol size: %d\n",arp->ar_pln); } n_print("princ",++line_s,0,lg,"Packet Number: %d",npkt); if(!graph) printf("\n"); ++line_s; row_s=0; } /* This function is important: control ARP response and verify that no-one is making arp-poisoning in LAN * NB_ It's important that you run this function when U are sure that no-one is making arp-poisoning, so I can * retrive a truly ip-mac list to confront the next ARP response with * * PS: ARP_RESPONSE have not broadcast destination like REQUEST */ /* car : control arp response */ int car (char *dev,int lg) { struct host *list; u_short i,n; char ebuf[PCAP_ERRBUF_SIZE]; struct nast_arp_hdr *arp; int line; line=6; #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif if (lg) { openfile(); n_print (NULL,0,0,lg,"Logging to file... \n"); fflush (stdout); n_print (NULL,0,0,lg,"NAST Control ARP Poisoning Report\n\n"); n_print (NULL,0,0,lg,"Made on %s\n\n", timed); } list = malloc (sizeof (struct host) * 255); /* to implement like list */ n_print ("princ",1,1,lg,"I'll build a truly MAC-IP list...\n\n"); n_print ("princ",2,1,lg,"(Press a key)\n"); getchar(); n_print ("princ",3,1,lg,"- Waiting please... \n"); fflush (stdout); if ((list = map_lan(dev, 0, &n))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return(1); } if (n==0) { if(w_error(0, "What are you doing? You are alone in this network!\n")==-1) return(1); } n_print ("princ",4,1,lg,"- Now let me sniff arp-response on the network...\n\n"); /* open pcap sniffer */ if ((pcap_lookupnet(dev, &netp, &maskp, ebuf))==-1) { w_error(1, "pcap_lookupnet error: %s\n", ebuf); } if ((descr = pcap_open_live(dev, BUFSIZ, PROMISC, 10, ebuf))==NULL) { w_error(1, "pcap_open_live error: %s\n", ebuf); } if ((pcap_compile (descr, &fp, "arp", 0, netp))==-1) { w_error(1, "pcap_compile error\n"); } if ((pcap_setfilter (descr, &fp))==-1) { w_error(1, "pcap_setfilter error\n"); } /* demonize */ if (demonize) bkg(); /* now sniff */ while (1) { if ((packet = (u_char *) pcap_next (descr, &hdr))==NULL) continue; if (handle_ethernet(packet)!=ETHERTYPE_ARP) continue; /* this is a paranoic test */ arp = (struct nast_arp_hdr *) (packet+offset); if (ntohs (arp->ar_op)==2) { for (i=0; i__ar_sip, list[i].ip, 4)) { n_print ("princ",line,1,lg,"Verifing: %d.%d.%d.%d ", arp->__ar_sip[0], arp->__ar_sip[1], arp->__ar_sip[2], arp->__ar_sip[3]); n_print ("princ",line,27,lg,"Is %s ?\t", nast_hex_ntoa(arp->__ar_sha)); if (memcmp(arp->__ar_sha, list[i].mac, ETHER_ADDR_LEN)) n_print ("princ",line,40,lg,"Warning! Truly is %s, possible ARP-Poisoning!!!\n", nast_hex_ntoa (list[i].mac)); else n_print ("princ",line,40,lg,"Correct\n"); ++line; break; } } } } if (lg) n_print (NULL,0,0,lg,"\ndone\n"); return 0; } nast-0.2.0/dev.c0100644000175000001440000000307210003274511012600 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* Find pcap_datalink */ int device (char *dev, pcap_t* descr) { char errbuf[PCAP_ERRBUF_SIZE]; u_short off; off = 0; if ((datalink = pcap_datalink(descr)) < 0) { w_error(1, "Error: pcap_datalink: %s\n", errbuf); } switch (datalink) { case DLT_EN10MB: off = 14; break; case DLT_NULL: case DLT_PPP: off = 4; break; /*for OpenBSD. If this offset doesn't work change it in 108*/ case DLT_LOOP: off=12; break; case DLT_SLIP: off = 16; break; case DLT_RAW: off = 0; break; case DLT_SLIP_BSDOS: case DLT_PPP_BSDOS: off = 24; break; case DLT_FDDI: off = 21; break; case DLT_LINUX_SLL: off = 16; break; default: w_error(1, "Error: Unknown Datalink Type: (%d)\n", datalink); } return(off); } nast-0.2.0/aclocal.m40100644000175000001440000004501310003274516013524 0ustar embyteusers# aclocal.m4 generated automatically by aclocal 1.5 # Copyright 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 5 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # We require 2.13 because we rely on SHELL being computed by configure. AC_PREREQ([2.13]) # AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) # ----------------------------------------------------------- # If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED. # The purpose of this macro is to provide the user with a means to # check macros which are provided without letting her know how the # information is coded. # If this macro is not defined by Autoconf, define it here. ifdef([AC_PROVIDE_IFELSE], [], [define([AC_PROVIDE_IFELSE], [ifdef([AC_PROVIDE_$1], [$2], [$3])])]) # AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE]) # ---------------------------------------------- AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AC_PROG_INSTALL])dnl # test to see if srcdir already configured if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first]) fi # Define the identity of the package. PACKAGE=$1 AC_SUBST(PACKAGE)dnl VERSION=$2 AC_SUBST(VERSION)dnl ifelse([$3],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])]) # Autoconf 2.50 wants to disallow AM_ names. We explicitly allow # the ones we care about. ifdef([m4_pattern_allow], [m4_pattern_allow([^AM_[A-Z]+FLAGS])])dnl # Autoconf 2.50 always computes EXEEXT. However we need to be # compatible with 2.13, for now. So we always define EXEEXT, but we # don't compute it. AC_SUBST(EXEEXT) # Similar for OBJEXT -- only we only use OBJEXT if the user actually # requests that it be used. This is a bit dumb. : ${OBJEXT=o} AC_SUBST(OBJEXT) # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AM_MISSING_PROG(AMTAR, tar) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_DEP_TRACK])dnl AC_REQUIRE([AM_SET_DEPDIR])dnl AC_PROVIDE_IFELSE([AC_PROG_][CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_][CC], defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_][CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_][CXX], defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl ]) # # Check to make sure that the build environment is sane. # # serial 3 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # serial 2 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= am_backtick='`' AC_MSG_WARN([${am_backtick}missing' script is too old or missing]) fi ]) # AM_AUX_DIR_EXPAND # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [ # expand $ac_aux_dir to an absolute path am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` ]) # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"$am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # serial 4 -*- Autoconf -*- # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # --------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX" or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'] [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi for depmode in $am_compiler_list; do # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. echo '#include "conftest.h"' > conftest.c echo 'int i;' > conftest.h echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=conftest.c object=conftest.o \ depfile=conftest.Po tmpdepfile=conftest.TPo \ $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && grep conftest.h conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then am_cv_$1_dependencies_compiler_type=$depmode break fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) $1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type" AC_SUBST([$1DEPMODE]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [rm -f .deps 2>/dev/null mkdir .deps 2>/dev/null if test -d .deps; then DEPDIR=.deps else # MS-DOS does not allow filenames that begin with a dot. DEPDIR=_deps fi rmdir .deps 2>/dev/null AC_SUBST(DEPDIR) ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking Speeds up one-time builds --enable-dependency-tracking Do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) pushdef([subst], defn([AC_SUBST])) subst(AMDEPBACKSLASH) popdef([subst]) ]) # Generate code to set up dependency tracking. # This macro should only be invoked once -- use via AC_REQUIRE. # Usage: # AM_OUTPUT_DEPENDENCY_COMMANDS # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[ AC_OUTPUT_COMMANDS([ test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do case "$mf" in Makefile) dirpart=.;; */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; *) continue;; esac grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue # Extract the definition of DEP_FILES from the Makefile without # running `make'. DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` test -z "$DEPDIR" && continue # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n -e '/^U = / s///p' < "$mf"` test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" # We invoke sed twice because it is the simplest approach to # changing $(DEPDIR) to its actual value in the expansion. for file in `sed -n -e ' /^DEP_FILES = .*\\\\$/ { s/^DEP_FILES = // :loop s/\\\\$// p n /\\\\$/ b loop p } /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`echo "$file" | sed -e 's|/[^/]*$||'` $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])]) # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' doit: @echo done END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include='#' am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote='"' _am_result=BSD fi fi AC_SUBST(am__include) AC_SUBST(am__quote) AC_MSG_RESULT($_am_result) rm -f confinc confmf ]) # serial 3 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. # # FIXME: Once using 2.50, use this: # m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl AC_DEFUN([AM_CONDITIONAL], [ifelse([$1], [TRUE], [errprint(__file__:__line__: [$0: invalid condition: $1 ])dnl m4exit(1)])dnl ifelse([$1], [FALSE], [errprint(__file__:__line__: [$0: invalid condition: $1 ])dnl m4exit(1)])dnl AC_SUBST([$1_TRUE]) AC_SUBST([$1_FALSE]) if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi]) # Like AC_CONFIG_HEADER, but automatically create stamp file. # serial 3 # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. We must strip everything past the first ":", # and everything past the last "/". AC_PREREQ([2.12]) AC_DEFUN([AM_CONFIG_HEADER], [ifdef([AC_FOREACH],dnl [dnl init our file count if it isn't already m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0])) dnl prepare to store our destination file list for use in config.status AC_FOREACH([_AM_File], [$1], [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*])) m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index)) dnl and add it to the list of files AC keeps track of, along dnl with our hook AC_CONFIG_HEADERS(_AM_File, dnl COMMANDS, [, INIT-CMDS] [# update the timestamp echo timestamp >"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index[" ][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS m4_popdef([_AM_Dest])])],dnl [AC_CONFIG_HEADER([$1]) AC_OUTPUT_COMMANDS( ifelse(patsubst([$1], [[^ ]], []), [], [test -z "$CONFIG_HEADERS" || echo timestamp >dnl patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl [am_indx=1 for am_file in $1; do case " \$CONFIG_HEADERS " in *" \$am_file "*) am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\` if test -n "\$am_dir"; then am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\` for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do am_tmpdir=\$am_tmpdir\$am_subdir/ if test ! -d \$am_tmpdir; then mkdir \$am_tmpdir fi done fi echo timestamp > "\$am_dir"stamp-h\$am_indx ;; esac am_indx=\`expr \$am_indx + 1\` done]) ])]) # AM_CONFIG_HEADER # _AM_DIRNAME(PATH) # ----------------- # Like AS_DIRNAME, only do it during macro expansion AC_DEFUN([_AM_DIRNAME], [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1, m4_if(m4_regexp([$1], [^/.*]), -1, [.], m4_patsubst([$1], [^\(/\).*], [\1])), m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl ]) # _AM_DIRNAME nast-0.2.0/fgw.c0100644000175000001440000001275310012736044012617 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* try to find lan-gateway * * return 1 if lan-gw is found * return 0 if lan-gw is not found * return -1 on error * */ /* This version is limitated: * Max 255 hosts to search gateway for ... */ #include "include/nast.h" int fgw (u_char *dev) { /* an "external" ip (www.google.com) */ u_char *extip = { "66.102.11.99" }; u_long myip; struct libnet_ether_addr *tmpmac; u_char mymac[6]; u_short i, k, pcount; u_short n; /* n=number of up hosts */ int line,col; libnet_t *l; u_char ebuf[LIBNET_ERRBUF_SIZE]; libnet_ptag_t ptag; /* to be implemented*/ int lg; pcap_t *p; struct host * uphost; /* pcap options */ u_int16_t type; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; int sd; struct timeval tv; fd_set rfsd; n = k = ptag = pcount = lg = 0; line = col = 1; /* query device to find MAC / IP / NETMASK */ if (!dev) { w_error(1, "Device is null!\n"); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif if (demonize) { w_error(0, "Is very useless demonize me in finding gateway! Omit"); demonize = 0; } l = libnet_init (LIBNET_LINK, dev, ebuf); myip = libnet_get_ipaddr4(l); tmpmac = libnet_get_hwaddr(l); for (i=0; i<6; i++) mymac[i]=tmpmac->ether_addr_octet[i]; /* init libnet_t *l */ l = libnet_init (LIBNET_LINK, dev, ebuf); /* build tcp and ip header (this doesn't change */ if (libnet_build_tcp (2500, 80, 847930886, 524972923, 0x02, 32767, 0, 0, LIBNET_TCP_H, NULL, 0, l, 0)==-1) { libnet_destroy (l); w_error(1, "Error building tcp header : %s\n" ,libnet_geterror(l)); } if (libnet_build_ipv4 (LIBNET_TCP_H + LIBNET_IPV4_H, 0x08, 35320, 0, 64, IPPROTO_TCP, 0, myip, libnet_name2addr4(l, extip, LIBNET_DONT_RESOLVE), NULL, 0, l, 0)==-1) { libnet_destroy(l); w_error(1, "Error building ip header : %s\n", libnet_geterror(l)); } n_print ("princ",line,col,lg,"Finding suitable hosts (excluding localhost) -> "); fflush (stdout); /* find up possible hosts */ if ((uphost = map_lan(dev, 0, &n))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return -1; } if (n==0) { if(w_error(0,"What are you doing? You are alone in this network!\n\n")==-1) return -1; } n_print ("princ",line,50,lg,"Done\n\n"); line = line+2; /* set gwip and increment within for cicle */ while (k < n) { n_print ("princ",line,col,lg,"Trying %d.%d.%d.%d (%s)-> ",uphost[k].ip[0], uphost[k].ip[1], uphost[k].ip[2], uphost[k].ip[3], nast_hex_ntoa (uphost[k].mac)); fflush (stdout); if ((ptag = libnet_build_ethernet (uphost[k].mac, mymac, 0x0800, NULL, 0, l, ptag))==-1) { libnet_destroy(l); w_error(1, "Error rebuilding ethernet frame : %s\n", libnet_geterror(l)); } if (libnet_write (l) == -1) { libnet_destroy(l); w_error(1, "Error writing packet on wire : %s\n", libnet_geterror(l)); } pcap_lookupnet(dev,&netp,&maskp,ebuf); if ((p = pcap_open_live (dev, BUFSIZ, NOT_PROMISC, 10, ebuf))==NULL) { libnet_destroy(l); w_error(1, "pcap_open_live() error : %s\n", ebuf); } /* to better work with many traffic */ pcap_compile(p,&fp,"src port 80 and dst port 2500",0,netp); pcap_setfilter(p,&fp); sd = pcap_fileno(p); /* try to sniff */ for (;;) { /* set 2 secondz delay | DONT TOUCH! */ FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); tv.tv_sec = 2; tv.tv_usec = 0; /* 30 packet max for delay */ if (pcount == 30) { n_print ("princ",line,2,lg,"Bad (timeout due to high traffic to your host, try again later to make sure)\n"); break; } if (!select(sd+1, &rfsd, NULL, NULL, &tv)) { n_print ("princ",line,50,lg,"Bad\n"); break; } /* capture packet (packet) and pcap_header (hdr) */ packet = (u_char *) pcap_next (p, &hdr); if (packet==NULL) { //fprintf (stderr, "Null packet!\n"); break; } type = handle_ethernet (packet); if (type==ETHERTYPE_IP) { ip = (struct libnet_ipv4_hdr *) (packet + offset); tcp = (struct libnet_tcp_hdr *) (packet + offset + sizeof(struct libnet_ipv4_hdr)); /* verify packet : ports and source ip*/ if ((ntohs(tcp->th_sport)==80) && (ntohs(tcp->th_dport)==2500) && (!strcmp(inet_ntoa(ip->ip_src), extip))) { n_print ("princ",line,50,lg,"Yep!\n"); break; } } pcount ++; } pcap_close(p); pcount = 1; k++; ++line; } if(!graph) printf("\n"); n_print("winfo",2,1,lg," "); n_print("winfo",2,2,lg,"\nFinished\n"); if (l) libnet_destroy(l); //printf ("\n"); return 0; } nast-0.2.0/eth.c0100644000175000001440000000207510003274517012612 0ustar embyteusers/* Pktsant - Copyright (C) 2002 Snifth This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* handle ethernet header */ u_int16_t handle_ethernet (u_char *packet) { struct libnet_ethernet_hdr *eptr; /* net/ethernet.h */ u_short ether_type; eptr = (struct libnet_ethernet_hdr *) packet; ether_type = ntohs (eptr->ether_type); return ether_type; } nast-0.2.0/map.c0100644000175000001440000002435610012736044012613 0ustar embyteusers/* Nast - map.c This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* pseudo BuG : If someone is arp-poisoning we must him as the owner of the ip! ------ * This function receive 1 if it must print to stdout (nast -m) * alse 0 if is used by another funz (run in silent mode) * * * Return if called from another function: * - NULL on error * - n=0 if localhost is the only host in network segment * - n>0 and struct host */ /* Don't touch here said embyte */ #include "include/nast.h" int arpreply (u_char *t, char *dev, u_short mode, int lg); int send_arp(libnet_t *l, u_char *device, u_char *ip_dst, u_char *enet_src, u_long ip_src); struct host * map_lan(char *dev, u_short mode, u_short * n); u_int scan_ulong(char *s, u_long *u); int line; u_char enet_dst[6] = /* broadcast */ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; u_short k, count; struct host * uphost; char errbuf[256]; libnet_ptag_t ptag; struct host * map_lan(char *dev, u_short mode, u_short * n) { libnet_t *l; struct libnet_ether_addr *e; struct in_addr addr; char r[3]; long ip_src; u_long u; u_int i; u_char ip_dst[4], orig_ip[4]; u_char netmask[4], enet_src[6], offset[4]; char *net, *mask; u_short j[4]; /* index */ count=k=ptag=0; line = 7; #ifdef HAVE_LIBNCURSES if(graph && mode) init_scr(); #endif /* make uphost point to at least 1 cell to avoid conflict with NULL on error */ uphost = calloc (1, sizeof (struct host)); if (demonize && mode) { w_error(0,"Is very useless demonize me in mapping LAN! Omit"); demonize=0; } if ((l = libnet_init (LIBNET_LINK, dev, errbuf))==NULL) { w_error(1, "libnet_init() : %s\n", errbuf); } if ((e = libnet_get_hwaddr(l))==NULL) { w_error(1, "Can't get hardware address: %s\n", errbuf); } memcpy (enet_src, e->ether_addr_octet, 6); if((ip_src = libnet_get_ipaddr4(l))==-1) { w_error(1, "Error getting ip source\n"); } if (pcap_lookupnet(dev, &netp, &maskp, errbuf)==-1) { w_error(1, "Error: %s\n", errbuf); } addr.s_addr = netp; if ((net = inet_ntoa(addr))==NULL) { w_error(1, "Impossible get the netaddress\n"); } /* netaddress */ i = scan_ulong(net,&u); if (!i) return NULL; ip_dst[0] = u; net += i; if (*net != '.') return NULL; ++net; i = scan_ulong(net,&u); if (!i) return NULL; ip_dst[1] = u; net += i; if (*net != '.') return NULL; ++net; i = scan_ulong(net,&u); if (!i) return NULL; ip_dst[2] = u; net += i; if (*net != '.') return NULL; ++net; i = scan_ulong(net,&u); if (!i) return NULL; ip_dst[3] = u; net += i; memcpy (orig_ip, ip_dst, 4); addr.s_addr = maskp; if ((mask = inet_ntoa(addr))==NULL) { w_error(1, "Impossible get the netmask\n"); } /* netmask */ i = scan_ulong(mask,&u); if (!i) return NULL; netmask[0] = u; mask += i; if (*mask != '.') return NULL; ++mask; i = scan_ulong(mask,&u); if (!i) return NULL; netmask[1] = u; mask += i; if (*mask != '.') return NULL; ++mask; i = scan_ulong(mask,&u); if (!i) return NULL; netmask[2] = u; mask += i; if (*mask != '.') return NULL; ++mask; i = scan_ulong(mask,&u); if (!i) return NULL; netmask[3] = u; mask += i; /* computate offset from netaddress and netmask */ for (i=0; i<=3; i++) offset[i]=255-netmask[i]; /* large netmask */ if (offset[1] && offset[2] && offset[3]) { if (mode) { n_print ("winfo",1,2,lg,"You are going to scan a large network (%s netmask)! Are you sure? (y/n) : ", nast_atoda(netmask)); fgets(r, 3, stdin); if (!(r[0]=='s' || r[0]=='S' || r[0]=='y' || r[0]=='Y')) goto refuse; printf ("\n"); } else n_print ("winfo",2,2,lg,"Warning, scanning a large netmask (%s), this will take a long time\n", nast_atoda(netmask)); } /* begin to map */ if (mode) { n_print("princ",1,1,lg,"Mapping the Lan for %s subnet ... please wait\n\n", nast_atoda(netmask)); n_print("princ",3,1,lg,"MAC address\t\tIp address (hostname)\n"); n_print("princ",4,1,lg,"===========================================================\n"); } /* print il localhost */ if (mode) { n_print ("princ",6,1,lg,"%s\t", nast_hex_ntoa (e->ether_addr_octet)); n_print ("princ",6,24,lg,"%s (%s) (*)\n",libnet_addr2name4(ip_src , 0),libnet_addr2name4(ip_src , LIBNET_RESOLVE)); } /* open descriptor to read */ if ((descr = pcap_open_live (dev, BUFSIZ, NOT_PROMISC, 10, errbuf))==NULL) { w_error(1, "pcap_open_live() error : %s\n", errbuf); } /* put filter on arp */ if(pcap_compile(descr, &fp, "arp", 0, netp) == -1) { w_error(1,"Error calling pcap_compile\n\n"); } if(pcap_setfilter(descr, &fp) == -1) { w_error(1, "Error calling pcap_setfilter\n\n"); } /* begin! */ /* don't arp request subnet ip */ ip_dst[3]++; /* 255.255.255.XXX */ if (!offset[0] && !offset[1] && !offset[2] && offset[3]) for (j[3]=0; j[3]<=offset[3]; j[3]++) { if (send_arp(l, dev, ip_dst, enet_src, ip_src)==-1) goto error; arpreply(ip_dst, dev, mode, lg); ip_dst[3]++; } /* 255.255.XXX.XXX */ else if (!offset[0] && !offset[1] && offset[2] && offset[3]) for (j[2]=0; j[2]<=offset[2]; j[2]++) { for (j[3]=0; j[3]<=offset[3]; j[3]++) { if (send_arp(l, dev, ip_dst, enet_src, ip_src)==-1) goto error; arpreply(ip_dst, dev, mode, lg); ip_dst[3]++; } ip_dst[2]++; ip_dst[3]=orig_ip[3]; } /* 255.XXX.XXX.XXX */ else if (!offset[0] && offset[1] && offset[2] && offset[3]) { for (j[1]=0; j[1]<=offset[1]; j[1]++) { for (j[2]=0; j[2]<=offset[2]; j[2]++) { for (j[3]=0; j[3]<=offset[3]; j[3]++) { if (send_arp(l, dev, ip_dst, enet_src, ip_src)==-1) goto error; arpreply(ip_dst, dev, mode, lg); ip_dst[3]++; } ip_dst[2]++; ip_dst[3]=orig_ip[3]; } ip_dst[1]++; ip_dst[2]=orig_ip[2]; } } /* XXX.XXX.XXX.XXX */ else if (offset[0] && offset[1] && offset[2] && offset[3]) { for (j[0]=0; j[0]<=offset[1]; j[0]++) { for (j[1]=0; j[1]<=offset[1]; j[1]++) { for (j[2]=0; j[2]<=offset[2]; j[2]++) { for (j[3]=0; j[3]<=offset[3]; j[3]++) { if (send_arp(l, dev, ip_dst, enet_src, ip_src)==-1) goto error; arpreply(ip_dst, dev, mode, lg); ip_dst[3]++; } ip_dst[2]++; ip_dst[3]=orig_ip[3]; } ip_dst[1]++; ip_dst[2]=orig_ip[2]; } ip_dst[0]++; ip_dst[1]=orig_ip[1]; } } /* paranoic test */ else { w_error(1, "Netmask error: %s is invalid\n\n", nast_atoda(netmask)); } error: if (mode) n_print ("winfo",2,1,lg,"\n(*) This is localhost\n\n"); refuse: if (descr) pcap_close (descr); if (l) libnet_destroy(l); /* print to video (map has been called from cmd line) */ if (mode) { n_print("winfo",1,1,lg," \n"); n_print("winfo",1,1,lg,"Finished\n"); return NULL; } /* map has been called from another funz */ else { /* number of found hosts */ *n = k; return (uphost); } } /* stolen from arpreply by ? */ u_int scan_ulong(char *s, u_long *u) { u_int pos; u_long c, result; pos = result = 0; while ((c = (u_long) (u_char) (s[pos] - '0')) < 10) { result = result * 10 + c; ++pos; } *u = result; return (pos); } /* is it alive? */ int arpreply(u_char *t, char *dev, u_short mode,int lg) { struct nast_arp_hdr *arp; struct libnet_ethernet_hdr *eptr; u_short sd, pcount; u_char ip[20]; struct timeval tv; fd_set rfsd; /* retrive socket descriptor for select() funz */ sd = pcap_fileno(descr); /* timeout is 5 packet or timer.. */ pcount = 0; /* try for an answer ... */ for (;;) { FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); tv.tv_sec = 0; tv.tv_usec = 20000; if (pcount == 5) break; if (!select(sd+1, &rfsd, NULL, NULL, &tv)) break; /* timeout */ if ((packet = (u_char *) pcap_next (descr, &hdr))==NULL) continue; offset=(device(dev,descr)); eptr = (struct libnet_ethernet_hdr *) (packet); arp = (struct nast_arp_hdr *)(packet+offset); /* It's an arp reply! */ if ((ntohs(arp->ar_op)) == 2) { sprintf (ip, "%d.%d.%d.%d", arp->__ar_sip[0],arp->__ar_sip[1],arp->__ar_sip[2],arp->__ar_sip[3]); if (memcmp (t, arp->__ar_sip, sizeof(arp->__ar_sip))) continue; /* it's it! */ else { if (mode) { n_print("princ",line,1,lg,"%s \t%s (%s)\n", nast_hex_ntoa (eptr->ether_shost), ip, libnet_addr2name4(inet_addr(ip), LIBNET_RESOLVE)); ++line; } else { /* ask for new memory */ if (k) uphost = realloc (uphost, (k+1)*sizeof(struct host)); memcpy (uphost[k].ip, arp->__ar_sip, 4); memcpy (uphost[k].mac, eptr->ether_shost, 6); k++; } } break; } pcount ++; } return 0; } /* Build our arp request */ int send_arp(libnet_t *l, u_char *device, u_char *ip_dst, u_char *enet_src, u_long ip_src) { if ((ptag = libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP, 6, 4, ARPOP_REQUEST, enet_src, (u_char *)&ip_src, enet_dst, ip_dst, NULL, 0, l, ptag)) == -1) { w_error(1, "libnet_build_arp error : %s\n", libnet_geterror(l)); } if (!count) { count ++; if (libnet_build_ethernet(enet_dst, enet_src, ETHERTYPE_ARP, NULL, 0, l, 0)==-1) { w_error(1, "libnet_build_ethereal error : %s\n", libnet_geterror(l)); } } if (libnet_write(l)==-1) { w_error(1, "Error writing arp request : %s\n", libnet_geterror(l)); } return 0; } nast-0.2.0/rst.c0100644000175000001440000000752010003274523012637 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" struct pkt { u_long seq; u_long ack; }; char errbuf[256]; struct pkt info; /* reset a connection */ int rst (char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport) { struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; libnet_t *l; u_short n; #ifdef HAVE_LIBNCURSES if(graph) init_scr(); #endif if (demonize) { w_error(0,"Is very useless demonize me in resetting connection! Omit"); demonize=0; } pcap_lookupnet (dev,&netp,&maskp,errbuf); if((descr=pcap_open_live(dev, BUFSIZ, PROMISC, 10, errbuf)) == NULL) { w_error(1, "pcap_open_live: %s\n", errbuf); } offset=(device(dev,descr)); if (sport && dport) n_print("princ",1,1,0,"- Waiting for SEQ ACK (%s:%d -> %s:%d)\n",libnet_addr2name4(ip_src , 0),sport,libnet_addr2name4(ip_dst , 0),dport); else if (!dport && sport) n_print("princ",1,1,0,"- Waiting for SEQ ACK (%s:%d -> %s)\n",libnet_addr2name4(ip_src , 0),sport,libnet_addr2name4(ip_dst , 0)); else if (!sport && dport) n_print("princ",1,1,0,"- Waiting for SEQ ACK (%s -> %s:%d)\n",libnet_addr2name4(ip_src , 0),libnet_addr2name4(ip_dst , 0),dport); for (;;) { packet = (u_char *) pcap_next(descr, &hdr); ip = (struct libnet_ipv4_hdr *) (packet + offset); if (ip->ip_p != IPPROTO_TCP) continue; if ((ip->ip_src.s_addr != ip_src) || (ip->ip_dst.s_addr != ip_dst)) continue; tcp = (struct libnet_tcp_hdr *) (packet + offset + sizeof (struct libnet_ipv4_hdr)); if (!(tcp->th_flags & TH_ACK)) continue; /* the specified port are not either zero */ if (sport && dport) { if ((tcp->th_sport != htons(sport)) || (tcp->th_dport != htons(dport))) continue; } /* dport is 0 */ else if (!dport && sport) { if ((tcp->th_sport != htons(sport))) continue; /* DPORT */ dport = htons (tcp->th_dport); } /* sport is 0 */ else if (!sport && dport) { if ((tcp->th_dport != htons(dport))) continue; /* SPORT */ sport = htons (tcp->th_sport); } info.seq = htonl (tcp->th_seq); info.ack = htonl (tcp->th_ack); n_print("princ",3,1,0,"- Stoled SEQ (%lu) ACK (%lu)...\n", info.seq, info.ack); break; } pcap_close(descr); /* second part */ if ((l = libnet_init (LIBNET_RAW4, NULL, errbuf))==NULL) { w_error(1, "libnet_init: %s\n", errbuf); } if (libnet_build_tcp (sport, dport, info.seq, info.ack, TH_RST, 32767, 0, 0, LIBNET_TCP_H, NULL, 0, l, 0)==-1) { libnet_destroy (l); w_error(1, "Error building tcp header : %s\n" ,libnet_geterror(l)); } if (libnet_build_ipv4 (LIBNET_TCP_H + LIBNET_IPV4_H, 0x08, 35320, 0, 64, IPPROTO_TCP, 0, ip_src , ip_dst , NULL, 0, l, 0)==-1) { libnet_destroy (l); w_error(1, "Error building ip header : %s\n", libnet_geterror(l)); } /* send 2 packet for security :) */ for (n = 0; n < 2 ; n++) if (libnet_write (l) == -1) { libnet_destroy(l); w_error(1, "Error writing packet on wire : %s\n", libnet_geterror(l)); } libnet_destroy(l); n_print("princ",5,1,0,"- Connection has been resetted\n\n"); return (0); } nast-0.2.0/tcp.c0100644000175000001440000001045010003274524012612 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* handle a tcp packet */ void handle_TCP (u_short d, u_short x, FILE *output, FILE *ldd) { struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; struct servent *service; u_char flags; u_short size_ip, size_tcp, size_buf; size_ip = LIBNET_IPV4_H; size_buf = 0; buf = NULL; ip = (struct libnet_ipv4_hdr *) (packet+offset); tcp = (struct libnet_tcp_hdr *) (packet+size_ip+offset); size_tcp = (tcp->th_off) * 4; n_print("princ",line_s,row_s,lg,"\n---[ TCP ]-----------------------------------------------------------\n"); service = getservbyport(htons(ntohs(tcp->th_sport)), "tcp"); n_print("princ",line_s=line_s+2,row_s,lg,"%s:%d(%s)",inet_ntoa(ip->ip_src),ntohs(tcp->th_sport),(service) ? service->s_name : "unknown"); service = getservbyport(htons(ntohs(tcp->th_dport)), "tcp"); n_print("princ",line_s,28,lg," -> "); n_print("princ",line_s,33,lg,"%s:%d(%s)\n",inet_ntoa(ip->ip_dst),ntohs(tcp->th_dport),(service) ? service->s_name : "unknown"); n_print("princ",++line_s,row_s,lg,"TTL: %d \t", ip->ip_ttl); n_print("princ",line_s,10,lg,"Window: %d\t", ntohs(tcp->th_win)); n_print("princ",line_s,25,lg,"Version: %d\t", ip->ip_v); n_print("princ",line_s,39,lg,"Lenght: %d\n", ntohs(ip->ip_len)); n_print("princ",++line_s,row_s,lg,"FLAGS: "); /*modifed by embyte */ flags = tcp->th_flags; row_s = 8; if (flags & TH_FIN) /*se mascherando con il fin ottengo 1 vuol dire che c�(l'and �1 se tutti e due sono 1) */ n_print("princ",line_s,++row_s,lg,"F"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & TH_SYN) n_print("princ",line_s,++row_s,lg,"S"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & TH_RST) n_print("princ",line_s,++row_s,lg,"R"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & TH_PUSH) n_print("princ",line_s,++row_s,lg,"P"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & TH_ACK) n_print("princ",line_s,++row_s,lg,"A"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & TH_URG) n_print("princ",line_s,++row_s,lg,"U"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & 0x80) n_print("princ",line_s,++row_s,lg,"U"); else n_print("princ",line_s,++row_s,lg,"-"); if (flags & 0x40) n_print("princ",line_s,++row_s,lg,"E"); n_print("princ",line_s,16,lg,"\tSEQ: %u - ACK: %u\n", ntohl(tcp->th_seq),ntohl(tcp->th_ack)); n_print("princ",++line_s,0,lg,"Packet Number: %d",npkt); if(!graph) printf("\n"); row_s=0; ++line_s; size_buf = ntohs(ip->ip_len) - size_ip - size_tcp; if (size_buf) { buf = (char *) (packet + offset + size_ip + size_tcp); if (d) { n_print("princ",line_s,row_s,lg,"\n---[ TCP Data ]------------------------------------------------------\n"); data_sniffo (buf, size_buf, output); } if (x) { n_print("princ",line_s,row_s,lg,"\n---[ TCP Hex-Ascii Data ]--------------------------------------------"); print_ascii_hex (buf, size_buf, output); } /* log data (payload only) */ if (ldd) { service = getservbyport(htons(ntohs(tcp->th_sport)), "tcp"); fprintf(ldd, "%s:%d(%s) -> ",inet_ntoa(ip->ip_src),ntohs(tcp->th_sport),(service) ? service->s_name : "unknown"); service = getservbyport(htons(ntohs(tcp->th_dport)), "tcp"); fprintf(ldd, "%s:%d(%s) TCP\n",inet_ntoa(ip->ip_dst),ntohs(tcp->th_dport),(service) ? service->s_name : "unknown"); data_sniffo (buf, size_buf, ldd); fprintf(ldd, "\n"); } } row_s = 0; } nast-0.2.0/udp.c0100644000175000001440000000604310003274525012620 0ustar embyteusers/* nast Copyright (C) 2002 Snifth This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* handle a udp packet */ void handle_UDP (u_short d, u_short x, FILE *output, FILE *ldd) { struct libnet_ipv4_hdr *ip; struct libnet_udp_hdr *udp; struct servent *service; u_short size_buf, size_ip, size_udp; size_ip = LIBNET_IPV4_H; size_udp = LIBNET_UDP_H; size_buf = 0; ip = (struct libnet_ipv4_hdr *) (packet+offset); udp = (struct libnet_udp_hdr *) (packet+size_ip+offset); service = getservbyport (htons(ntohs(udp->uh_sport)), "udp"); n_print("princ",line_s,row_s,lg,"\n---[ UDP ]-----------------------------------------------------------\n"); n_print("princ",line_s=line_s+2,row_s,lg,"%s:%d(%s)", inet_ntoa (ip->ip_src), ntohs(udp->uh_sport), (service) ? service->s_name : "unknown"); service = getservbyport(htons(ntohs(udp->uh_dport)), "udp"); n_print("princ",line_s,28,lg," -> "); n_print("princ",line_s,33,lg,"%s:%d(%s)\n", inet_ntoa(ip->ip_dst), ntohs(udp->uh_dport), (service) ? service->s_name : "unknown"); n_print("princ",++line_s,row_s,lg,"Version: %d\t Total Lenght: %d\t", ip->ip_v, ntohs(ip->ip_len)); n_print("princ",line_s,39,lg, "TTL: %d\n", ip->ip_ttl); n_print("princ",++line_s,0,lg,"Packet Number: %d",npkt); if(!graph) printf("\n"); size_buf = ntohs(ip->ip_len) - size_ip - size_udp; ++line_s; row_s=0; /* there is a payload */ if (size_buf) { buf = (char *) (packet + size_ip + size_udp + offset); if (d) { n_print("princ",line_s,row_s,lg,"\n---[ UDP Data ]------------------------------------------------------\n"); data_sniffo (buf, size_buf, output); } if (x) { n_print("princ",line_s,row_s,lg,"\n---[ UDP Hex-Ascii Data ]--------------------------------------------"); print_ascii_hex (buf, size_buf, output); } /* log data (payload only) */ if (ldd) { service = getservbyport (htons(ntohs(udp->uh_sport)), "udp"); fprintf(ldd, "%s:%d(%s) -> ", inet_ntoa (ip->ip_src), ntohs(udp->uh_sport), (service) ? service->s_name : "unknown"); service = getservbyport(htons(ntohs(udp->uh_dport)), "udp"); fprintf(ldd, "%s:%d(%s) UDP\n", inet_ntoa(ip->ip_dst), ntohs(udp->uh_dport), (service) ? service->s_name : "unknown"); data_sniffo (buf, size_buf, ldd); fprintf(ldd, "\n"); } } row_s=0; } nast-0.2.0/bcount.c0100644000175000001440000003115310011544554013323 0ustar embyteusers/* NAST This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" #define Rst 0 #define Fin 1 int conn_len(u_long ip_src,u_long ip_dst,u_short s_port,u_short d_port, double len); struct statistics { unsigned long s_ip; unsigned long d_ip; unsigned short s_port; unsigned short d_port; double tot_len; int lin; } stat_conn[100]; void bytecounting (); void n_bytecounting (); /*with graphic*/ int run_bc (char *dev, char *filter); void ptimecounting(); int nconns = 0; int liness = 13; unsigned long ptime; /* parzial time of execution, in seconds */ double partial; /* partial traffic */ time_t begin; /* save begin time for calculate avarage rate */ int run_bc (char *dev, char *filter) { char ebuf[PCAP_ERRBUF_SIZE]; if (!dev) { w_error(1, "Device is null!\n"); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif if (demonize) n_print ("winfo",1,1,0,"Is very useless demonize me in finding gateway! Omit"); /* 1 to avoid inf */ ptime=1; begin = time(NULL); /* open pcap sniffer */ if ((pcap_lookupnet(dev, &netp, &maskp, ebuf))==-1) { w_error(1,"pcap_lookupnet error: %s\n\n", ebuf); } if ((descr = pcap_open_live(dev, BUFSIZ, PROMISC, 10, ebuf))==NULL) { w_error(1, "pcap_open_live error: %s\n\n", ebuf); } if ((offset=(device(dev,descr)))==-1) return -1; if (strcmp (filter, "any") && strcmp (filter, "")) /* filter!="any" */ { if ((pcap_compile (descr, &fp, filter, 0, netp))==-1) { w_error(0, "pcap_compile error\n\n"); return 0; } if ((pcap_setfilter (descr, &fp))==-1) { w_error(0, "pcap_setfilter error\n\n"); return 0; } n_print ("princ",0,1,0,"Filter \"%s\" has been applied to \"%s\"\n\n", filter, dev); } else n_print ("princ",0,1,0,"Reading from \"%s\"\n\n", dev); pthread_create (&pt[0], NULL, (void *) ptimecounting, NULL); if(graph) pthread_create (&pt[1], NULL, (void *) n_bytecounting, NULL); else bytecounting() ; return 0; } void bytecounting () { u_short icons; double total; double pspeed, tspeed; /* current and total speed */ unsigned long long number; char *units[] = { "B/s", "kB/s", "MB/s", "GB/s" }; char value[15]; int line; total=0; icons=0; number=0; partial=0; line = 4; n_print (NULL,0,0,0,"Packets\t\tTotal\t\tCurrent speed\t\tAvarage speed\n"); n_print (NULL,0,0,0,"---------------------------------------------------------------------\n"); while (1) { if ((packet = (u_char *) pcap_next (descr, &hdr))!=NULL) { total+=(double)(hdr.len)/1024; /* sum (Kbytes)*/ partial+=(double)(hdr.len)/1024; ++number; /* clean line */ printf ("\r \r"); switch (icons) { case 0: printf ("\\ "); break; case 1: printf ("| "); break; case 2: printf ("/ "); break; case 3: printf ("- "); break; } if (icons==3) icons=0; else icons++; sprintf (value, "%Ld", number); printf (value); /* calculate space */ if (strlen(value) < 6) printf ("\t\t"); else printf ("\t"); if (total < 1) sprintf (value, "%.0fB", total*1024); else if (total < 1024) sprintf (value, "%.2fkB", total); else if (total < 1024*1024) sprintf (value, "%.2fMB", total/1024); else sprintf (value, "%.2fGB", total/1024*1024); printf ("%s", value); /* calculate space */ if (strlen (value) < 8) printf ("\t\t"); else printf ("\t"); pspeed = partial/ptime; if (pspeed < 1) sprintf (value, "%.0f%s", pspeed*1024, units[0]); else if (pspeed < 1024) sprintf (value, "%.2f%s", pspeed, units[1]); else if (pspeed < 1024*1024) sprintf (value, "%.2f%s", pspeed/1024, units[2]); else sprintf (value, "%.2f%s", pspeed/1024*1024, units[3]); printf ("%s", value); /* calculate space */ if (strlen (value) < 7) printf ("\t\t\t"); else if (strlen (value) < 13) printf ("\t\t"); else printf ("\t"); tspeed = total/((int)(time(NULL)-begin)); if (tspeed < 1) sprintf (value, "%.0f%s", tspeed*1024, units[0]); else if (tspeed < 1024) sprintf (value, "%.2f%s", tspeed, units[1]); else if (tspeed < 1024*1024) sprintf (value, "%.2f%s", tspeed/1024, units[2]); else sprintf (value, "%.2f%s", tspeed/1024*1024, units[3]); printf ("%s", value); fflush (stdout); } } pcap_close(descr); } void n_bytecounting() { u_short icons; double total; double tot; double pspeed, tspeed; /* current and total speed */ unsigned long long number; char *units[] = { "B/s", "kB/s", "MB/s", "GB/s" }; char value[15]; int line, l; int tcp,udp,icmp,igmp,arp,rarp,others; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcph; u_int16_t type; int k; total=tot=0; icons=0; number=0; partial=0; line = 4; l = 11; tcp = udp = icmp = igmp = others = arp = rarp = k = 0; for(k=0;k<100;k++) { memset(&stat_conn[k], 0, sizeof(stat_conn[k])); } n_print ("princ",1,1,0,"Packets\t\tTotal\t\tCurrent speed\t\tAvarage speed\n"); n_print ("princ",2,1,0,"-----------------------------------------------------------------------------\n"); n_print ("princ",6,1,0,"ARP RARP ICMP IGMP TCP UDP Others\n"); n_print ("princ",7,1,0,"-----------------------------------------------------------------------------\n"); n_print ("princ",11,1,0,"From Port To Port Total traffic"); n_print("princ",12,1,0,"-----------------------------------------------------------------------------\n"); while(bc_glob!=0) { if ((packet = (u_char *) pcap_next (descr, &hdr))!=NULL) { total+=(double)(hdr.len)/1024; /* sum (Kbytes)*/ partial+=(double)(hdr.len)/1024; ++number; tot=(double)(hdr.len)/1024; type = handle_ethernet (packet); ip = (struct libnet_ipv4_hdr *) (packet+offset); tcph = (struct libnet_tcp_hdr *) (packet + LIBNET_IPV4_H + offset); switch(ip->ip_p) { case IPPROTO_TCP: ++tcp; switch(tcph->th_flags) { case TH_SYN: conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case TH_ACK: conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case TH_RST: conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case (TH_SYN|TH_ACK): conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case (TH_ACK|TH_PUSH): conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case (TH_URG|TH_ACK): conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case (TH_FIN|TH_ACK): conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; case (TH_RST|TH_ACK): conn_len(ip->ip_src.s_addr,ip->ip_dst.s_addr,htons(tcph->th_sport),htons(tcph->th_dport),tot); break; default: break; } break; case IPPROTO_UDP: ++udp; break; case IPPROTO_ICMP: ++icmp; break; case IPPROTO_IGMP: ++igmp; break; default: if (type==ETHERTYPE_ARP) ++arp; else if (type==ETHERTYPE_REVARP) ++rarp; else ++others; break; } n_print ("princ",8,1,0," "); n_print ("princ",8,3,0,"%d",arp); n_print ("princ",8,15,0,"%d",rarp); n_print ("princ",8,27,0,"%d",icmp); n_print ("princ",8,39,0,"%d",igmp); n_print ("princ",8,51,0,"%d",tcp); n_print ("princ",8,63,0,"%d",udp); n_print ("princ",8,75,0,"%d",others); switch (icons) { case 0: n_print ("princ",3,1,0,"\\ "); break; case 1: n_print ("princ",3,1,0,"| "); break; case 2: n_print ("princ",3,1,0,"/ "); break; case 3: n_print ("princ",3,1,0,"- "); break; } if (icons==3) icons=0; else icons++; n_print ("princ",3,1,0," "); sprintf (value, "%Ld", number); n_print ("princ",3,3,0,"%s",value); if (total < 1) sprintf (value, "%.0fB", total*1024); else if (total < 1024) sprintf (value, "%.2fkB", total); else if (total < 1024*1024) sprintf (value, "%.2fMB", total/1024); else sprintf (value, "%.2fGB", total/1024*1024); n_print ("princ",3,24,0,"%s",value); pspeed = partial/ptime; if (pspeed < 1) sprintf (value, "%.0f%s", pspeed*1024, units[0]); else if (pspeed < 1024) sprintf (value, "%.2f%s", pspeed, units[1]); else if (pspeed < 1024*1024) sprintf (value, "%.2f%s", pspeed/1024, units[2]); else sprintf (value, "%.2f%s", pspeed/1024*1024, units[3]); n_print ("princ",3,40,0,"%s",value); tspeed = total/((int)(time(NULL)-begin)); if (tspeed < 1) sprintf (value, "%.0f%s", tspeed*1024, units[0]); else if (tspeed < 1024) sprintf (value, "%.2f%s", tspeed, units[1]); else if (tspeed < 1024*1024) sprintf (value, "%.2f%s", tspeed/1024, units[2]); else sprintf (value, "%.2f%s", tspeed/1024*1024, units[3]); n_print ("princ",3,64,0,"%s",value); } } pcap_close(descr); } int conn_len(u_long ip_src,u_long ip_dst,u_short s_port,u_short d_port, double len) { int i; char value[15]; for(i=0;i<100;i++) if((ip_src==stat_conn[i].s_ip && ip_dst==stat_conn[i].d_ip && s_port==stat_conn[i].s_port && d_port==stat_conn[i].d_port) || (ip_src==stat_conn[i].d_ip && ip_dst==stat_conn[i].s_ip && s_port==stat_conn[i].d_port && d_port==stat_conn[i].s_port)) { stat_conn[i].tot_len += len; if (stat_conn[i].tot_len < 1) sprintf (value, "%.0fB", stat_conn[i].tot_len*1024); else if (stat_conn[i].tot_len < 1024) sprintf (value, "%.2fkB", stat_conn[i].tot_len); else if (stat_conn[i].tot_len < 1024*1024) sprintf (value, "%.2fMB", stat_conn[i].tot_len/1024); else sprintf (value, "%.2fGB", stat_conn[i].tot_len/1024*1024); n_print("princ",stat_conn[i].lin,60,0,"%s",value); return(0); /*ce l'ho gi�(duplicato)*/ } for(i=0;i<100;i++)/*cerco spazio vuoto*/ { if(stat_conn[i].s_ip)continue; else { stat_conn[i].s_ip = ip_src; stat_conn[i].d_ip = ip_dst; stat_conn[i].s_port = s_port; stat_conn[i].d_port = d_port; stat_conn[i].tot_len = len; n_print("princ",liness,1,0,"%s",libnet_addr2name4(stat_conn[i].s_ip, LIBNET_DONT_RESOLVE)); n_print("princ",liness,18,0,"%d",stat_conn[i].s_port); n_print("princ",liness,29,0,"%s",libnet_addr2name4(stat_conn[i].d_ip, LIBNET_DONT_RESOLVE)); n_print("princ",liness,49,0,"%d",stat_conn[i].d_port); if (stat_conn[i].tot_len < 1) sprintf (value, "%.0fB", stat_conn[i].tot_len*1024); else if (stat_conn[i].tot_len < 1024) sprintf (value, "%.2fkB", stat_conn[i].tot_len); else if (stat_conn[i].tot_len < 1024*1024) sprintf (value, "%.2fMB", stat_conn[i].tot_len/1024); else sprintf (value, "%.2fGB", stat_conn[i].tot_len/1024*1024); n_print("princ",stat_conn[i].lin,60,0,"%s",value); stat_conn[i].lin=liness; nconns++; liness++; return(1); } } return(0); } void ptimecounting() { for (;;) { sleep(1); if (ptime==10) { /* refresh every X seconds */ ptime=1; partial=0; } else ptime++; } } nast-0.2.0/README0100644000175000001440000000336210013751054012543 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool README ============================================================================ Required libraries: =================== Libnet 1.1.1 (*) Libpcap 0.8.1 (**) (Pthread support) (*) www.packetfactory.net/libnet (**) www.tcpdump.org Raccomanded libraries: ====================== Libncurses (*) (*) www.gnu.org/software/ncurses/ncurses.html Installation: ============= 1) tar xvfz nast-x.y.z.tar.gz (*) 2) cd nast-x.y.z 3) ./configure (./configure --help for help) 4) make (make help for help) 5) make install (you must be root if you want to install in default prefix) Read accepted options with "nast -h" and run with "nast [options]". If you need help use manpage (nast(8)). (*) x.y.z is the release version. Ncurses, even they aren't necessary, are STRONGLY recommended for a better use of the plugins, specially TCP stream and byte counting! Use: ==== The use of Nast under shell is quite easy and the man page should be enought. The use of Nast with Ncurses graphical interface is a little bit more complex, so you should read the README_NCURSES for avoid problems (press "h" for runtime help)! Disclaimer: =========== There is no warranty, expressed or implied, associated with this tool. Use at your OWN risk. License: ======== GNU GENERAL PUBLIC LICENSE see COPYING file for details. Contact: ======== Website: http://nast.berlios.de CVS: http://www.spine-group.org/cgi-bin/cvsweb.cgi/ Newsletter: http://lists.berlios.de/mailman/listinfo/nast-news Email: Embyte or Snifth Bug: ==== Please report bug to Authors. nast-0.2.0/configure0100755000175000001440000047304310003274602013577 0ustar embyteusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for nast 0.2.0. # # Report bugs to . # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" # Sed expression to map a string onto a valid variable name. as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME='nast' PACKAGE_TARNAME='nast' PACKAGE_VERSION='0.2.0' PACKAGE_STRING='nast 0.2.0' PACKAGE_BUGREPORT='embyte@madlab.it' ac_unique_file="main.c" ac_default_prefix=/usr/local # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS NCURSES GETOPT build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures nast 0.2.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of nast 0.2.0:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF nast configure 0.2.0 generated by GNU Autoconf 2.57 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by nast $as_me 0.2.0, which was generated by GNU Autoconf 2.57. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core core.* *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" # Print a banner echo " Please wait, I'm going to configure Nast 0.2.0 " ######### # Subst # ######### ################# # Checks for OS # ################# ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6 if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_target_alias=$target_alias test "x$ac_cv_target_alias" = "x" && ac_cv_target_alias=$ac_cv_host_alias ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_target" >&5 echo "${ECHO_T}$ac_cv_target" >&6 target=$ac_cv_target target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- case "$target" in *linux*) { echo "$as_me:$LINENO: Found Linux, happy day!" >&5 echo "$as_me: Found Linux, happy day!" >&6;} ;; *freebsd*) { echo "$as_me:$LINENO: Found FreeBSD, are you a nerd?" >&5 echo "$as_me: Found FreeBSD, are you a nerd?" >&6;} ;; *openbsd*) { echo "$as_me:$LINENO: WARNING: OpenBSD port: we are working on... Nast could not run correctly " >&5 echo "$as_me: WARNING: OpenBSD port: we are working on... Nast could not run correctly " >&2;} ;; *netbsd*) { echo "$as_me:$LINENO: WARNING: NetBSD port: we are working on... Nast could not run correctly " >&5 echo "$as_me: WARNING: NetBSD port: we are working on... Nast could not run correctly " >&2;} ;; *) { echo "$as_me:$LINENO: WARNING: Your OS seems to be officially unsupported yet, please send an email authors " >&5 echo "$as_me: WARNING: Your OS seems to be officially unsupported yet, please send an email authors " >&2;} ;; esac ################ # Setup prefix # ################ if test "$prefix" = "NONE"; then prefix="/usr/local" fi ####################### # Checks for compiler # ####################### ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C compiler default output" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ######################### # Checks for libraries. # ######################### # # -- libnet -- # filechk="yes" echo "$as_me:$LINENO: checking for /usr/lib/libnet.a" >&5 echo $ECHO_N "checking for /usr/lib/libnet.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_lib_libnet_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/lib/libnet.a"; then ac_cv_file__usr_lib_libnet_a=yes else ac_cv_file__usr_lib_libnet_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_lib_libnet_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_lib_libnet_a" >&6 if test $ac_cv_file__usr_lib_libnet_a = yes; then : else filechk="no" fi if test "$filechk" = "no"; then echo "$as_me:$LINENO: checking for /usr/local/lib/libnet.a" >&5 echo $ECHO_N "checking for /usr/local/lib/libnet.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_local_lib_libnet_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/local/lib/libnet.a"; then ac_cv_file__usr_local_lib_libnet_a=yes else ac_cv_file__usr_local_lib_libnet_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_local_lib_libnet_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_local_lib_libnet_a" >&6 if test $ac_cv_file__usr_local_lib_libnet_a = yes; then filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include" fi fi if test "$filechk" = "no"; then { { echo "$as_me:$LINENO: error: Libnet archive file (libnet.a) not found in /usr or /usr/local! Libnet-1.1.x Packet Shaping Library is required. You can download it from official web site: http://www.packetfactory.net/libnet " >&5 echo "$as_me: error: Libnet archive file (libnet.a) not found in /usr or /usr/local! Libnet-1.1.x Packet Shaping Library is required. You can download it from official web site: http://www.packetfactory.net/libnet " >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: checking for libnet_name2addr4 in -lnet" >&5 echo $ECHO_N "checking for libnet_name2addr4 in -lnet... $ECHO_C" >&6 if test "${ac_cv_lib_net_libnet_name2addr4+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnet $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char libnet_name2addr4 (); int main () { libnet_name2addr4 (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_net_libnet_name2addr4=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_net_libnet_name2addr4=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_net_libnet_name2addr4" >&5 echo "${ECHO_T}$ac_cv_lib_net_libnet_name2addr4" >&6 if test $ac_cv_lib_net_libnet_name2addr4 = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBNET 1 _ACEOF LIBS="-lnet $LIBS" else { { echo "$as_me:$LINENO: error: Libnet-1.1.x Packet Shaping Library not found! It's required. You can download it from official web site: http://www.packetfactory.net/libnet " >&5 echo "$as_me: error: Libnet-1.1.x Packet Shaping Library not found! It's required. You can download it from official web site: http://www.packetfactory.net/libnet " >&2;} { (exit 1); exit 1; }; } fi # # -- libpcap -- # filechk="yes" echo "$as_me:$LINENO: checking for /usr/lib/libpcap.a" >&5 echo $ECHO_N "checking for /usr/lib/libpcap.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_lib_libpcap_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/lib/libpcap.a"; then ac_cv_file__usr_lib_libpcap_a=yes else ac_cv_file__usr_lib_libpcap_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_lib_libpcap_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_lib_libpcap_a" >&6 if test $ac_cv_file__usr_lib_libpcap_a = yes; then : else filechk="no" fi if test "$filechk" = "no"; then echo "$as_me:$LINENO: checking for /usr/local/lib/libpcap.a" >&5 echo $ECHO_N "checking for /usr/local/lib/libpcap.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_local_lib_libpcap_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/local/lib/libpcap.a"; then ac_cv_file__usr_local_lib_libpcap_a=yes else ac_cv_file__usr_local_lib_libpcap_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_local_lib_libpcap_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_local_lib_libpcap_a" >&6 if test $ac_cv_file__usr_local_lib_libpcap_a = yes; then filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include" fi fi if test "$filechk" = "no"; then { { echo "$as_me:$LINENO: error: Libpcap archive file (libpcap.a) not found in /usr or /usr/local! Libpcap-0.7.1 Packet Capture Library is required. You can download it from official web site: http://www.tcpdump.org/#current " >&5 echo "$as_me: error: Libpcap archive file (libpcap.a) not found in /usr or /usr/local! Libpcap-0.7.1 Packet Capture Library is required. You can download it from official web site: http://www.tcpdump.org/#current " >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: checking for pcap_dispatch in -lpcap" >&5 echo $ECHO_N "checking for pcap_dispatch in -lpcap... $ECHO_C" >&6 if test "${ac_cv_lib_pcap_pcap_dispatch+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pcap_dispatch (); int main () { pcap_dispatch (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pcap_pcap_dispatch=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pcap_pcap_dispatch=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pcap_pcap_dispatch" >&5 echo "${ECHO_T}$ac_cv_lib_pcap_pcap_dispatch" >&6 if test $ac_cv_lib_pcap_pcap_dispatch = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBPCAP 1 _ACEOF LIBS="-lpcap $LIBS" else { { echo "$as_me:$LINENO: error: Libpcap-0.7.1 Packet Capture Library not found! It's required. You can download it from official web site: http://www.tcpdump.org/#current " >&5 echo "$as_me: error: Libpcap-0.7.1 Packet Capture Library not found! It's required. You can download it from official web site: http://www.tcpdump.org/#current " >&2;} { (exit 1); exit 1; }; } fi # # -- libncurses support -- # filechk="yes" echo "$as_me:$LINENO: checking for /usr/lib/libncurses.a" >&5 echo $ECHO_N "checking for /usr/lib/libncurses.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_lib_libncurses_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/lib/libncurses.a"; then ac_cv_file__usr_lib_libncurses_a=yes else ac_cv_file__usr_lib_libncurses_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_lib_libncurses_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_lib_libncurses_a" >&6 if test $ac_cv_file__usr_lib_libncurses_a = yes; then : else filechk="no" fi if test "$filechk" = "no"; then echo "$as_me:$LINENO: checking for /usr/local/lib/libncurses.a" >&5 echo $ECHO_N "checking for /usr/local/lib/libncurses.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_local_lib_libncurses_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/local/lib/libncurses.a"; then ac_cv_file__usr_local_lib_libncurses_a=yes else ac_cv_file__usr_local_lib_libncurses_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_local_lib_libncurses_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_local_lib_libncurses_a" >&6 if test $ac_cv_file__usr_local_lib_libncurses_a = yes; then filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include" fi fi if test "$filechk" = "no"; then { echo "$as_me:$LINENO: WARNING: Libncurses archive file (libncurses.a) not found in /usr or /usr/local! Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&5 echo "$as_me: WARNING: Libncurses archive file (libncurses.a) not found in /usr or /usr/local! Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&2;} fi ENABLE_NCRS="no" echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 echo $ECHO_N "checking for initscr in -lncurses... $ECHO_C" >&6 if test "${ac_cv_lib_ncurses_initscr+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char initscr (); int main () { initscr (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_ncurses_initscr=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ncurses_initscr=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5 echo "${ECHO_T}$ac_cv_lib_ncurses_initscr" >&6 if test $ac_cv_lib_ncurses_initscr = yes; then ENABLE_NCRS="yes"; NCURSES=ncurses/n_nast.o; LIBS="-lncurses $LIBS"; cat >>confdefs.h <<\_ACEOF #define HAVE_LIBNCURSES 1 _ACEOF else echo "$as_me:$LINENO: result: Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&5 echo "${ECHO_T} Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&6 fi #fi # # --lmenu support-- # filechk="yes" echo "$as_me:$LINENO: checking for /usr/lib/libmenu.a" >&5 echo $ECHO_N "checking for /usr/lib/libmenu.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_lib_libmenu_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/lib/libmenu.a"; then ac_cv_file__usr_lib_libmenu_a=yes else ac_cv_file__usr_lib_libmenu_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_lib_libmenu_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_lib_libmenu_a" >&6 if test $ac_cv_file__usr_lib_libmenu_a = yes; then : else filechk="no" fi if test "$filechk" = "no"; then echo "$as_me:$LINENO: checking for /usr/local/lib/libmenu.a" >&5 echo $ECHO_N "checking for /usr/local/lib/libmenu.a... $ECHO_C" >&6 if test "${ac_cv_file__usr_local_lib_libmenu_a+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test "$cross_compiling" = yes && { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} { (exit 1); exit 1; }; } if test -r "/usr/local/lib/libmenu.a"; then ac_cv_file__usr_local_lib_libmenu_a=yes else ac_cv_file__usr_local_lib_libmenu_a=no fi fi echo "$as_me:$LINENO: result: $ac_cv_file__usr_local_lib_libmenu_a" >&5 echo "${ECHO_T}$ac_cv_file__usr_local_lib_libmenu_a" >&6 if test $ac_cv_file__usr_local_lib_libmenu_a = yes; then filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include" fi fi if test "$filechk" = "no"; then { echo "$as_me:$LINENO: WARNING: Menu archive file (libncurses.a) not found in /usr or /usr/local! Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&5 echo "$as_me: WARNING: Menu archive file (libncurses.a) not found in /usr or /usr/local! Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&2;} fi ENABLE_NCRS="no" echo "$as_me:$LINENO: checking for menu_opts_off in -lmenu" >&5 echo $ECHO_N "checking for menu_opts_off in -lmenu... $ECHO_C" >&6 if test "${ac_cv_lib_menu_menu_opts_off+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmenu $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char menu_opts_off (); int main () { menu_opts_off (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_menu_menu_opts_off=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_menu_menu_opts_off=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_menu_menu_opts_off" >&5 echo "${ECHO_T}$ac_cv_lib_menu_menu_opts_off" >&6 if test $ac_cv_lib_menu_menu_opts_off = yes; then ENABLE_NCRS="yes"; MENU=ncurses/n_menu.o; LIBS="-lmenu $LIBS"; cat >>confdefs.h <<\_ACEOF #define HAVE_LIBMENU 1 _ACEOF else echo "$as_me:$LINENO: result: Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&5 echo "${ECHO_T} Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) " >&6 fi ############################ # Checks for linux pthread # ############################ case "$target" in *linux*) echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6 if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_create (); int main () { pthread_create (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthread_pthread_create=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pthread_pthread_create=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5 echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6 if test $ac_cv_lib_pthread_pthread_create = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" else { { echo "$as_me:$LINENO: error: Linux threads library not found in your linux-box! Strange.. " >&5 echo "$as_me: error: Linux threads library not found in your linux-box! Strange.. " >&2;} { (exit 1); exit 1; }; } fi CFLAGS="-Wall -O2" ;; *bsd*) CFLAGS="-Wall -O2 -pthread" ;; esac ############################################## # Checks for headers and common libs/headers # ############################################## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_prog_egrep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 echo "${ECHO_T}$ac_cv_prog_egrep" >&6 EGREP=$ac_cv_prog_egrep echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in errno.h sys/utsname.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc in yes:no ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF else { echo "$as_me:$LINENO: WARNING: This headers are required!" >&5 echo "$as_me: WARNING: This headers are required!" >&2;} fi done echo "$as_me:$LINENO: checking for getopt_long" >&5 echo $ECHO_N "checking for getopt_long... $ECHO_C" >&6 if test "${ac_cv_func_getopt_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char getopt_long (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char getopt_long (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_getopt_long) || defined (__stub___getopt_long) choke me #else char (*f) () = getopt_long; #endif #ifdef __cplusplus } #endif int main () { return f != getopt_long; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_getopt_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_getopt_long=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_getopt_long" >&5 echo "${ECHO_T}$ac_cv_func_getopt_long" >&6 if test $ac_cv_func_getopt_long = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETOPT 1 _ACEOF else GETOPT="getopt.o getopt1.o" fi #AC_CHECK_HEADER(getopt.h, AC_DEFINE(HAVE_GETOPT), GETOPT="getopt.o getopt1.o") # Checks for typedefs, structures, and compiler characteristics. echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; char **p; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; ccp = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++ccp; p = (char**) ccp; ccp = (char const *const *) p; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 if test "${ac_cv_struct_tm+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { struct tm *tp; tp->tm_sec; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_struct_tm=time.h else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_struct_tm=sys/time.h fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 echo "${ECHO_T}$ac_cv_struct_tm" >&6 if test $ac_cv_struct_tm = sys/time.h; then cat >>confdefs.h <<\_ACEOF #define TM_IN_SYS_TIME 1 _ACEOF fi # Checks for library functions. for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc in yes:no ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6 if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_malloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if STDC_HEADERS || HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { exit (malloc (0) ? 0 : 1); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_malloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_malloc_0_nonnull=no fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6 if test $ac_cv_func_malloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 0 _ACEOF LIBOBJS="$LIBOBJS malloc.$ac_objext" cat >>confdefs.h <<\_ACEOF #define malloc rpl_malloc _ACEOF fi echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifdef signal # undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main () { int i; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_signal=void else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=int fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub__doprnt) || defined (__stub____doprnt) choke me #else char (*f) () = _doprnt; #endif #ifdef __cplusplus } #endif int main () { return f != _doprnt; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6 if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done ################## # Write Makefile # ################## ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" # Sed expression to map a string onto a valid variable name. as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by nast $as_me 0.2.0, which was generated by GNU Autoconf 2.57. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ nast config.status 0.2.0 configured by $0, generated by GNU Autoconf 2.57, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@NCURSES@,$NCURSES,;t t s,@GETOPT@,$GETOPT,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@target@,$target,;t t s,@target_cpu@,$target_cpu,;t t s,@target_vendor@,$target_vendor,;t t s,@target_os@,$target_os,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if diff $ac_file $tmp/config.h >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi ################# # Print results # ################# echo " Ok. I have done with all. Results are: PLATFORM ...... : `uname -mp` O.S. .......... : `uname -rs` (`uname -n`) COMPILER ...... : ${CC} CFLAGS ........ : ${CFLAGS} CPPFLAGS ...... : ${CPPFLAGS} LDFLAGS ....... : ${LDFLAGS} LIBS .......... : ${LIBS} PREFIX ........ : ${prefix} NCURSES SUPPORT : ${ENABLE_NCRS} Type 'make' to compile or 'make help' to show accepted options. " # ok we have done nast-0.2.0/configure.ac0100644000175000001440000001455510003274604014157 0ustar embyteusers############################################## # # # Nast - Network Analyzer Sniffer Tool # # # # configure.ac - written by embyte@madlab.it # # modified by Snifth@box.it # # # ############################################## AC_INIT(nast, 0.2.0, embyte@madlab.it) AC_CONFIG_SRCDIR(main.c) AC_CONFIG_HEADER(config.h) # Print a banner echo " Please wait, I'm going to configure Nast 0.2.0 " ######### # Subst # ######### AC_SUBST(NCURSES) AC_SUBST(GETOPT) ################# # Checks for OS # ################# AC_CANONICAL_TARGET case "$target" in *linux*) AC_MSG_NOTICE([Found Linux, happy day!]) ;; *freebsd*) AC_MSG_NOTICE([Found FreeBSD, are you a nerd?]) ;; *openbsd*) AC_MSG_WARN([ OpenBSD port: we are working on... Nast could not run correctly ]) ;; *netbsd*) AC_MSG_WARN([ NetBSD port: we are working on... Nast could not run correctly ]) ;; *) AC_MSG_WARN([ Your OS seems to be officially unsupported yet, please send an email authors ]) ;; esac ################ # Setup prefix # ################ AC_PREFIX_DEFAULT(/usr/local) if test "$prefix" = "NONE"; then prefix="/usr/local" fi ####################### # Checks for compiler # ####################### AC_PROG_CC ######################### # Checks for libraries. # ######################### # # -- libnet -- # filechk="yes" AC_CHECK_FILE(/usr/lib/libnet.a,, filechk="no") if test "$filechk" = "no"; then AC_CHECK_FILE(/usr/local/lib/libnet.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include") fi if test "$filechk" = "no"; then AC_MSG_ERROR([ Libnet archive file (libnet.a) not found in /usr or /usr/local! Libnet-1.1.x Packet Shaping Library is required. You can download it from official web site: http://www.packetfactory.net/libnet ]) fi AC_CHECK_LIB(net, libnet_name2addr4,, AC_MSG_ERROR([ Libnet-1.1.x Packet Shaping Library not found! It's required. You can download it from official web site: http://www.packetfactory.net/libnet ])) # # -- libpcap -- # filechk="yes" AC_CHECK_FILE(/usr/lib/libpcap.a,, filechk="no") if test "$filechk" = "no"; then AC_CHECK_FILE(/usr/local/lib/libpcap.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include") fi if test "$filechk" = "no"; then AC_MSG_ERROR([ Libpcap archive file (libpcap.a) not found in /usr or /usr/local! Libpcap-0.7.1 Packet Capture Library is required. You can download it from official web site: http://www.tcpdump.org/#current ]) fi AC_CHECK_LIB(pcap, pcap_dispatch,, AC_MSG_ERROR([ Libpcap-0.7.1 Packet Capture Library not found! It's required. You can download it from official web site: http://www.tcpdump.org/#current ])) # # -- libncurses support -- # filechk="yes" AC_CHECK_FILE(/usr/lib/libncurses.a,, filechk="no") if test "$filechk" = "no"; then AC_CHECK_FILE(/usr/local/lib/libncurses.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include") fi if test "$filechk" = "no"; then AC_MSG_WARN([ Libncurses archive file (libncurses.a) not found in /usr or /usr/local! Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) ]) fi ENABLE_NCRS="no" AC_CHECK_LIB(ncurses, initscr, ENABLE_NCRS="yes"; NCURSES=ncurses/n_nast.o; LIBS="-lncurses $LIBS"; AC_DEFINE(HAVE_LIBNCURSES), AC_MSG_RESULT([ Ncurses library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) ])) #fi # # --lmenu support-- # filechk="yes" AC_CHECK_FILE(/usr/lib/libmenu.a,, filechk="no") if test "$filechk" = "no"; then AC_CHECK_FILE(/usr/local/lib/libmenu.a, filechk="yes" ; LDFLAGS="-L/usr/local/lib"; CPPFLAGS="-I/usr/local/include") fi if test "$filechk" = "no"; then AC_MSG_WARN([ Menu archive file (libncurses.a) not found in /usr or /usr/local! Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) ]) fi ENABLE_NCRS="no" AC_CHECK_LIB(menu, menu_opts_off, ENABLE_NCRS="yes"; MENU=ncurses/n_menu.o; LIBS="-lmenu $LIBS"; AC_DEFINE(HAVE_LIBMENU), AC_MSG_RESULT([ Menu library (*) not found in your system. You can download it from official web site: http://www.gnu.org/software/ncurses/ncurses.html (*): CRT screen handling and optimization package Building without ncurses menu support (-G flag will doesn't work) ])) ############################ # Checks for linux pthread # ############################ case "$target" in *linux*) AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR([ Linux threads library not found in your linux-box! Strange.. ])) CFLAGS="-Wall -O2" ;; *bsd*) CFLAGS="-Wall -O2 -pthread" ;; esac ############################################## # Checks for headers and common libs/headers # ############################################## AC_HEADER_STDC AC_CHECK_HEADERS(errno.h sys/utsname.h,, AC_MSG_WARN(This headers are required!)) AH_TEMPLATE(HAVE_GETOPT, define if the getopt.h header is present, OpenBSD for ex. doesn't have one) AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT), GETOPT="getopt.o getopt1.o") #AC_CHECK_HEADER(getopt.h, AC_DEFINE(HAVE_GETOPT), GETOPT="getopt.o getopt1.o") # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_HEADER_TIME AC_STRUCT_TM # Checks for library functions. AC_FUNC_MALLOC AC_TYPE_SIGNAL AC_FUNC_VPRINTF ################## # Write Makefile # ################## AC_OUTPUT(Makefile) ################# # Print results # ################# echo " Ok. I have done with all. Results are: PLATFORM ...... : `uname -mp` O.S. .......... : `uname -rs` (`uname -n`) COMPILER ...... : ${CC} CFLAGS ........ : ${CFLAGS} CPPFLAGS ...... : ${CPPFLAGS} LDFLAGS ....... : ${LDFLAGS} LIBS .......... : ${LIBS} PREFIX ........ : ${prefix} NCURSES SUPPORT : ${ENABLE_NCRS} Type 'make' to compile or 'make help' to show accepted options. " # ok we have done nast-0.2.0/sniff.c0100644000175000001440000001320510013762502013131 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* prototypes */ void sniff (int d, int x, FILE *output, FILE *ldd); int run_sniffer (u_short promisc, u_short data, u_short hex, u_short f, u_short l, u_short tcpdlog, u_short tcpdread, char *filter, char *dev, char *ldname); /* plugin to run sniffer */ int run_sniffer (u_short promisc, u_short data, u_short hex, u_short f, u_short l, u_short tcpdlog, u_short tcpdread, char *filter, char *dev, char *ldname) { char *mask; char errbuf[PCAP_ERRBUF_SIZE]; libnet_t *L; int ld; struct libnet_ether_addr *e; struct in_addr addr; /* log data FILE descriptor */ FILE *ldd; ldd = NULL; ld = 0; npkt = 0; if (strcmp (ldname, "NULL")) /* != NULL */ (ld=1); /* ask pcap for the network address and mask of the device */ if ((pcap_lookupnet(dev,&netp,&maskp,errbuf))==-1) { w_error(1, "pcap_lookupnet error: %s\n\n", errbuf); } if (tcpdlog) /* write in tcdl file in tcpdump log format */ { if ((descr = pcap_open_live (dev, BUFSIZ, promisc, 10, errbuf))==NULL) { w_error(1, "pcap_open_live() error: %s\n\n",errbuf); } if ((dumper = pcap_dump_open(descr,tcpdl))==NULL) { w_error(1, "pcap_dump_open() error: %s\n\n",errbuf); } } else if(tcpdread) /* read from tcpdl file */ { if ((descr = pcap_open_offline(tcpdl,errbuf))==NULL) { w_error(1, "pcap_open_offline() error: %s\n\n",errbuf); } } /* normal case */ else if ((descr = pcap_open_live (dev, BUFSIZ, promisc, 10, errbuf))==NULL) { w_error(1, "pcap_open_live() error: %s\n\n",errbuf); } if ((offset=(device(dev,descr)))==-1) return -1; L = libnet_init (LIBNET_LINK, dev, errbuf); e = libnet_get_hwaddr(L); if (!e) { w_error(1, "Can't get hardware address: %s\n\n", libnet_geterror(L)); } addr.s_addr = maskp; if ((mask = inet_ntoa(addr))==NULL) { w_error(1, "Impossible get the mask\n\n"); } if(!graph) { printf("%sSniffing on:\n\n%s", CYAN, NORMAL); printf("%s- Device:\t%s%s\n",BOLD, NORMAL, dev); printf("%s- MAC address:\t%s%s\n", BOLD, NORMAL, nast_hex_ntoa (e->ether_addr_octet)); printf("%s- IP address:\t%s%s\n", BOLD, NORMAL, libnet_addr2name4(libnet_get_ipaddr4(L), 0)); printf("%s- Netmask:\t%s%s\n",BOLD, NORMAL, mask); printf("%s- Promisc mode:\t%s", BOLD, NORMAL); if (promisc) printf("Set\n"); else printf("Not set\n"); printf ("%s- Filter:\t%s", BOLD, NORMAL); if (filter) printf("%s\n", filter); else printf("None\n"); printf("%s- Logging:\t%s", BOLD, NORMAL); if (!ld && !l) printf ("None\n"); else if (ld && !l) printf ("Sniffed data\n"); else if (!ld && l) printf ("Traffic\n"); else if (ld && l) printf ("Traffic and Sniffed data\n"); } /* log all packets */ if (l) { openfile(); fprintf(logd, "NAST SNIFFER LOGGING REPORT\n"); fprintf(logd, "Made on %s, device %s (%s)\n\n", timed, dev, libnet_addr2name4(libnet_get_ipaddr4(L), 0)); } /* log only data */ if (ld) { if ((ldd = (fopen(ldname,"w"))) == NULL) { w_error(1, "\nError: unable to open logfile descriptor: %s\n\n", strerror(errno)); } fprintf(ldd, "NAST SNIFFED DATA REPORT\n"); fprintf(ldd, "Made on %s, device %s (%s)\n\n", timed, dev, libnet_addr2name4(libnet_get_ipaddr4(L), 0)); } libnet_destroy(L); if (f) { if(pcap_compile(descr,&fp,filter,0,netp) == -1) { if(w_error(0, "Error in pcap_compile, insert a different filter\n")==-1) return(0); } if(pcap_setfilter(descr,&fp) == -1) { w_error(1, "Error calling pcap_setfilter\n\n"); } } /* demonize only now */ if (demonize) bkg(); /* sniff here */ while(1) { (packet = (u_char *) pcap_next (descr, &hdr)); if(packet==NULL) continue; ++npkt; if (!ldname) sniff (data, hex, stdout, NULL); /* print to stdout and write to data file*/ /* this works also for tcpdump read file!! */ else { sniff (data, hex, stdout, ldd); fflush (ldd); } if (l) { sniff (data, hex, logd, NULL); /* log packets to file */ fflush (logd); } if (tcpdlog) { fflush((FILE *)dumper); pcap_dump((u_char *)dumper,&hdr,packet); } } if (l) fclose (logd); if (ldname) fclose (ldd); return 0; } /* sniffer function heandler */ void sniff (int d, int x, FILE *output, FILE *ldd) { struct libnet_ipv4_hdr *ip; u_int16_t type; type = handle_ethernet (packet); if ((type==ETHERTYPE_ARP) || (type==ETHERTYPE_REVARP)) handle_ARP(output); ip = (struct libnet_ipv4_hdr *) (packet+offset); switch(ip->ip_p) { case IPPROTO_TCP: handle_TCP (d, x, output, ldd); break; case IPPROTO_UDP: handle_UDP (d, x, output, ldd); break; case IPPROTO_ICMP: handle_ICMP (d, x, output, ldd); break; case IPPROTO_IGMP: handle_IGMP (output); break; } } nast-0.2.0/config.guess0100644000175000001440000011302010003274616014174 0ustar embyteusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-08-21' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c ; for c in cc gcc c89 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; if test $? = 0 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # Netbsd (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # Determine the machine/vendor (is the vendor relevant). case "${UNAME_MACHINE}" in amiga) machine=m68k-unknown ;; arm32) machine=arm-unknown ;; atari*) machine=m68k-atari ;; sun3*) machine=m68k-sun ;; mac68k) machine=m68k-apple ;; macppc) machine=powerpc-apple ;; hp3[0-9][05]) machine=m68k-hp ;; ibmrt|romp-ibm) machine=romp-ibm ;; *) machine=${UNAME_MACHINE}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE}" in i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; 2-1307) UNAME_MACHINE="alphaev68" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; arc64:OpenBSD:*:*) echo mips64el-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hkmips:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; sparc*:NetBSD:*) echo `uname -p`-unknown-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) case "${HPUX_REV}" in 11.[0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; esac ;; esac fi ;; esac if [ "${HP_ARCH}" = "" ]; then sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF eval $set_cc_for_build (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; hppa*:OpenBSD:*:*) echo hppa-unknown-openbsd exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in big) echo mips-unknown-linux-gnu && exit 0 ;; little) echo mipsel-unknown-linux-gnu && exit 0 ;; esac ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. ld_supported_targets=`cd /; ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf cat >$dummy.c < #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 printf ("%s-pc-linux-gnu\n", argv[1]); # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif #else printf ("%s-pc-linux-gnuaout\n", argv[1]); #endif return 0; } EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) if test "${UNAME_MACHINE}" = "x86pc"; then UNAME_MACHINE=pc fi echo `uname -p`-${UNAME_MACHINE}-nto-qnx exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[KW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: nast-0.2.0/install-sh0100644000175000001440000001273610003274617013675 0ustar embyteusers#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 nast-0.2.0/error.c0100644000175000001440000000240310003274617013157 0ustar embyteusers/* nast - Network analyzer sniffer tool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* fatal error = 1 non-fatal error = 0 */ #include "include/nast.h" #include int w_error(int fatal, char *err, ...); int w_error(int fatal, char *err, ...) { char error[100]; int n,ris; va_list ap; ris = 0; va_start(ap, err); n = vsnprintf(error, 100, err, ap); va_end(ap); #ifdef HAVE_LIBNCURSES if(graph){ n_error(error, fatal); return -1;/*it returns -1 only if the error isn't fatal! */ } #endif fprintf(stderr, "\n%s\n\n", error); exit(-1); } nast-0.2.0/config.sub0100644000175000001440000006700510003274626013653 0ustar embyteusers#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-08-13' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dsp16xx \ | fr30 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | m32r | m68000 | m68k | m88k | mcore \ | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el | mips64vr4300 \ | mips64vr4300el | mips64vr5000 | mips64vr5000el \ | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | s390 | s390x \ | sh | sh[34] | sh[34]eb | shbe | shle \ | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 \ | we32k \ | x86 | xscale \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alphapca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armv*-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cray2-* | cydra-* \ | d10v-* | d30v-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | m32r-* \ | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ | mipsle-* | mipstx39-* | mipstx39el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | s390-* | s390x-* \ | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [cjt]90) basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=t3e-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb) basic_machine=sh-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: nast-0.2.0/missing/0040755000175000001440000000000010014474117013336 5ustar embyteusersnast-0.2.0/missing/getopt.h0100644000175000001440000001444010003274676015017 0ustar embyteusers/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if defined __STDC__ && __STDC__ const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if defined __STDC__ && __STDC__ # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ nast-0.2.0/flink.c0100644000175000001440000002055510007450113013130 0ustar embyteusers/* NAST This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* return -1 on error, else 0 */ #include "include/nast.h" int flink (u_char *dev) { libnet_t *l = NULL; pcap_t *p = NULL; u_short ether_type; struct libnet_icmpv4_hdr *icmp; struct libnet_ether_addr *mymac; struct host * uphost; libnet_ptag_t ptag; u_long myip; struct libnet_ipv4_hdr * ip; u_char errbuf[LIBNET_ERRBUF_SIZE]; /*to be implemented*/ int lg; struct timeval tv; fd_set rfsd; u_char testip[20]; /* ipsorci ritornati da map.c*/ u_char mac_src[6], mac_dst[6]; /* mac address */ u_long ip_src, ip_dst; /* ip da usare dopo */ u_short i, k, sd, pcount, n; /* n=num of up hosts */ i = n = k = ptag = ip_dst = sd = lg = 0; if (!dev) { w_error(1, "Device is null!\n"); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif if (demonize) { w_error (0,"Is very useless demonize me in finding link! Omit"); demonize=0; } n_print ("princ",2,2,lg,"- Searching for possible hosts to use for test : waiting please... "); fflush (stdout); /* find two hosts for test */ if ((uphost = map_lan(dev, 0, &n))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return(0); } /* there are at least 3 host in lan? */ if (n<2) { n_print ("princ",4,2,lg,"\nYou have only %d host in lan, test won't be truly...\n", n+1); n_print ("princ",5,2,lg,"Try again with at least 3 hosts up.\n\n"); return -1; } /* find a suitable host that reply to ping request */ if ((l = libnet_init (LIBNET_RAW4, NULL, errbuf))==NULL) { w_error(1, "\nError : libnet_init: %s\n", errbuf); } if (!(mymac = libnet_get_hwaddr(l))) { w_error(1, "\nError : can't get hardware address: %s\n", libnet_geterror(l)); } /* MAC is my MAC ADDRESS*/ for (k=0; k<6; k++) mac_src[k]=mymac->ether_addr_octet[k]; myip = libnet_get_ipaddr4(l); if (myip == -1) { w_error(1, "\nError : autodetect device ip address failed: %s\n", libnet_geterror(l)); } if (libnet_build_icmpv4_echo(ICMP_ECHO, 0, 0, 1000, 5249, NULL, 0, l,0)==-1) { libnet_destroy(l); w_error(1, "\nError : can't build ICMP header : %s\n", libnet_geterror(l)); } for (i = 0; i GOOD :-) */ if ((ip->ip_src.s_addr == inet_addr(testip)) && icmp->icmp_type==ICMP_ECHOREPLY && icmp->icmp_id == 1000) { /* sisitemo ip/mac dst */ ip_dst = ip->ip_src.s_addr; for (k=0; k<6; k++) mac_dst[k]=uphost[i].mac[k]; /* sistemo ip src */ /* subito il primo host risponde ai ping */ if (!i) sprintf(testip, "%d.%d.%d.%d", uphost[1].ip[0], uphost[1].ip[1], uphost[1].ip[2], uphost[1].ip[3]); else sprintf(testip, "%d.%d.%d.%d", uphost[0].ip[0], uphost[0].ip[1], uphost[0].ip[2], uphost[0].ip[3]); if ( (ip_src=inet_addr(testip)) == -1) { if(w_error(0, "\nError : uphost[].ip is not a valid ip. Mhh strange, contact developer please\n")==-1) return(0); } /* host found */ pcap_close (p); goto rfound; } /* altro pacchetto ricevuto */ pcount ++; } /* l'host non risponde all'icmp request, vado al prossimo */ pcap_close (p); } n_print ("winfo",1,1,lg,"\n\nI don't find any host in you LAN which reply to an icmp request!\nI need at last one to resolve test. Try again later and adjust firewall if you can...\n\n"); return -1; /* --------------------------------------------------------------------- */ rfound: n_print ("princ",2,68,lg,"OK"); if (uphost) free (uphost); n_print ("princ",3,2,lg,"\n- Try to send icmp spoofed request... \n"); if ((l = libnet_init (LIBNET_LINK, dev, errbuf))==NULL) { w_error(1, "libnet_init: %s\n", errbuf); } /* costruisco il pacchetto */ if (libnet_build_icmpv4_echo(ICMP_ECHO, 0, 0, 1000, 5249, NULL, 0, l,0)==-1) { libnet_destroy(l); w_error(1, "Can't build ICMP header : %s\n", libnet_geterror(l)); } if (libnet_build_ipv4(LIBNET_ICMPV4_ECHO_H + LIBNET_IPV4_H, 0x00, 1000, 0, 64, IPPROTO_ICMP, 0, ip_src, ip_dst, NULL, 0, l, 0)==-1) { libnet_destroy(l); w_error(1, "Can't build TCP header : %s\n", libnet_geterror(l)); } if (libnet_build_ethernet(mac_dst, mac_src, ETHERTYPE_IP, NULL, 0, l, 0)==-1) { libnet_destroy(l); w_error(1, "Can't build ethernet header : %s\n", libnet_geterror(l)); } /* write packet */ if (libnet_write (l) == -1) { libnet_destroy(l); w_error(1, "Error writing packet on wire : %s\n", libnet_geterror(l)); } /* open pcap device in promisc mode */ if ((p = pcap_open_live (dev, BUFSIZ, PROMISC, 10, errbuf))==NULL) { libnet_destroy(l); w_error(1, "pcap_open_liver() error : %s\n", errbuf); } /* recupero il descrittore per la select() */ sd = pcap_fileno(p); n_print ("princ",4,2,lg,"- Waiting for a possible reply...\n"); /* per il traffico alto metto un timeout di 30 pacchetti */ pcount = 1; for (;;) { if (pcount == 60) { n_print ("princ",6,2,lg,"- No answer -> supposed SWITCH present\n"); break; } /* set 2 secondz delay | DON'T TOUCH! */ FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); tv.tv_sec = 2; tv.tv_usec = 0; if (!select(sd+1, &rfsd, NULL, NULL, &tv)) { n_print("princ",6,2,lg,"- No answer within two seconds -> supposed SWITCH present\n"); break; } /* capture packet (packet) and pcap_header (hdr) */ packet = (u_char *) pcap_next (p, &hdr); if (packet==NULL) { //fprintf (stderr, "Null packet!\n"); break; } if ((ether_type = handle_ethernet (packet)) != ETHERTYPE_IP) continue; offset = (device(dev,p)); ip = (struct libnet_ipv4_hdr *) (packet + offset); icmp = (struct libnet_icmpv4_hdr *) (packet + offset + LIBNET_IPV4_H); if ((ip->ip_src.s_addr == ip_dst) && icmp->icmp_type==ICMP_ECHOREPLY && icmp->icmp_id == 1000) { n_print ("princ",6,2,lg,"- Supposed HUB present\n"); break; } /* altro pacchetto ricevuto */ pcount ++; } if(graph) n_print("winfo",2,1,0,"Finished\n"); libnet_destroy(l); return 0; } nast-0.2.0/data.c0100644000175000001440000000644010003274631012740 0ustar embyteusers/* nast - Network analyzer sniffer tool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" #define BYTES 16 #define SHORTS (BYTES / 2) #define DIGITS 5 #define LINE (DIGITS * SHORTS) void print_ascii_hex(char *data, u_int l, FILE *log) { u_int offset; u_int i; int s1, s2; int nshorts; char hex[BYTES*DIGITS+1], *hsp; char ascii[BYTES+1], *asp; row_s=0; line_s+=3; nshorts = l / sizeof(u_short); offset = i = 0; hsp = hex; asp = ascii; while (--nshorts >= 0) { s1 = *data++; s2 = *data++; (void)snprintf(hsp, sizeof(hex) - (hsp - hex), " %02x%02x", s1, s2); hsp += DIGITS; *(asp++) = (isgraph(s1) ? s1 : '.'); *(asp++) = (isgraph(s2) ? s2 : '.'); if (++i >= SHORTS) { *hsp = *asp = '\0'; /*fprintf(log, "\n0x%04x %-*s %s", offset, LINE, hex, ascii);*/ if(!graph) printf("\n"); n_print("princ",line_s,row_s,lg,"0x%04x %-*s %s", offset, LINE, hex, ascii); i = 0; hsp = hex; asp = ascii; offset += BYTES; ++line_s; } } if (l & 1) { s1 = *data++; (void)snprintf(hsp, sizeof(hex) - (hsp - hex), " %02x", s1); hsp += 3; *(asp++) = (isgraph(s1) ? s1 : '.'); ++i; } if (i > 0) { *hsp = *asp = '\0'; if(!graph) printf("\n"); n_print("princ",line_s,row_s,lg,"0x%04x %-*s %s", offset, LINE, hex, ascii); ++line_s; } } void data_sniffo (char *data_info, u_int len, FILE *log) { int i,ld; row_s = ld = 0; if(log==stdout) ld = 0; else ld = 1; line_s+=3; if(graph && !ld) { if (data_info == NULL) { n_print("princ",line_s,row_s,lg,"NULL DATA"); ++line_s; } for (i = 0; i < len; i++) { if (ispunct(data_info[i]) || isalnum(data_info[i])) { n_print("princ",line_s,row_s,lg,"%c",data_info[i]); row_s++; } else if (data_info[i]=='\n') { n_print("princ",++line_s,row_s,lg,""); row_s=0; } else if (data_info[i]=='\r') row_s = row_s + 5; else if (data_info[i]=='\t') row_s = row_s + 3; else row_s++; } } if(!graph || (graph && ld)) { fputc('\n', log); line_s-=3; if (data_info == NULL) fprintf(log, "NULL DATA\n"); for (i = 0; i < len; i++) { if (ispunct(data_info[i]) || isalnum(data_info[i])) fputc (data_info[i], log); else if (data_info[i]=='\n') fputc('\n', log); else if (data_info[i]=='\r') fputc('\r', log); else if (data_info[i]=='\t') fputc ('\t', log); else fputc (' ', log); } } } nast-0.2.0/mkinstalldirs0100644000175000001440000000133010003274631014457 0ustar embyteusers#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1.1.1 2004/01/20 18:55:21 embyte Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here nast-0.2.0/common.c0100644000175000001440000001526610013746653013336 0ustar embyteusers/* NAST This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Common functions */ #include "include/nast.h" #include /* run complex plugins here */ /* r: reset a connection * s: follow tcp stream * M: multi_scanner * S: single port_scanner */ int runcplx (char what, char *dev, int l) { u_long ip_dst, ip_src; u_short port_dst, port_src; libnet_plist_t plist, *plist_p; char buff[50]; u_short i; libnet_t *L; char errbuf[PCAP_ERRBUF_SIZE]; i = 0; if ((L = libnet_init (LIBNET_LINK, NULL, errbuf))==NULL) { w_error(1,"Error loading libnet core!\n"); } switch (what) { case 'r': /* don't touch here */ error: puts ("Type connection extremes"); puts ("------------------------"); do { if (i) printf ("Cannot resolve input address, type again!\n"); printf ("1 ip / hostname : "); fgets (buff, 50, stdin); if ((ip_src = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(1,"Error: %s\n", libnet_geterror(L)); } i ++; } while (ip_src == -1); i = 0; printf ("1 port (0 to autodetect) : "); fgets (buff, 50, stdin); port_src = atoi(buff); do { if (i) printf ("Cannot resolve input address, type again!\n"); printf ("2 ip / hostname : "); fgets (buff, 50, stdin); if ((ip_dst = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(1, "Error: %s\n", libnet_geterror(L)); } i++; } while (ip_dst == -1); printf ("2 port (0 to autodetect) : "); fgets (buff, 50, stdin); port_dst = atoi(buff); if (!port_src && !port_dst) { printf ("\nOnly one port can be zero\n"); i=0; goto error; } printf ("\n"); /* demonize */ if (demonize) printf ("Is very useless demonize me now! Omit\n\n"); rst (dev, ip_src, ip_dst, port_src, port_dst); break; case 's': puts ("Type connection extremes"); puts ("------------------------"); do { if (i) printf ("Cannot resolve input address, type again!\n"); printf ("1st ip : "); fgets (buff, 50, stdin); if ((ip_src = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(1,"Error: %s\n", libnet_geterror(L)); } i ++; } while (ip_src == -1); printf ("1st port : "); fgets (buff, 50, stdin); port_src = atoi(buff); i = 0; do { if (i) printf ("Cannot resolve input address, type again!\n"); printf ("2nd : "); fgets (buff, 50, stdin); if ((ip_dst = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(1, "Error: %s\n", libnet_geterror(L)); } i++; } while (ip_dst == -1); printf ("2nd port : "); fgets (buff, 50, stdin); port_dst = atoi(buff); printf ("\n"); /* demonize */ if (demonize) bkg(); stream (dev, ip_src, ip_dst, port_src, port_dst,l); break; case 'S': printf("Port Scanner extremes\n"); printf("Insert IP to scan : "); fgets(buff ,50 ,stdin); if ((ip_dst = libnet_name2addr4(L, dn(buff), LIBNET_RESOLVE))==-1) { w_error(1, "Error: %s\n", libnet_geterror(L)); } do { bzero(buff,50); printf("Insert Port range : "); fgets(buff ,50 ,stdin); } while (atoi(dn(buff)) < 1 || atoi(dn(buff)) > 65536); plist_p = &plist; if (libnet_plist_chain_new(L, &plist_p, dn(buff)) == -1) { w_error(1, "Bad token in port list: %s\n",libnet_geterror(L)); } printf("\n"); /* demonize */ if (demonize) printf ("Is very useless demonize for single portscan! Omit\n\n"); port(dev,ip_dst,plist_p,l); break; case 'M': printf("Port Scanner extremes\n"); do { printf("Insert Port range : "); fgets(buff ,50 ,stdin); } while (atoi(dn(buff)) < 1 || atoi(dn(buff)) > 65536); plist_p = &plist; if (libnet_plist_chain_new(L, &plist_p, dn(buff) )== -1) { w_error(1, "Bad token in port list: %s\n",libnet_geterror(L)); } printf("\n"); /* demonize */ if (demonize) bkg(); mhport (dev,plist_p,l); break; } if (L) libnet_destroy(L); return 0; } /* delete \n */ char * dn (char * s) { if (s[strlen(s)-1]=='\n') s[strlen(s)-1]='\0'; return s; } /* open a file to log to */ void openfile(void) { if ((logd = (fopen(logname,"w"))) == NULL) { w_error(1, "Unable to open logfile descriptor: %s\n\n", strerror(errno)); } } /* signal handler */ void sigexit() { #ifdef HAVE_LIBNCURSES # include if(graph) { endwin(); printf("Thank you for using NAST\n\n"); exit(0); } #endif if (!tr && sniff_glob) { if (pcap_stats(descr,&statistic) < 0) w_error(1, "Error: pcap_stats: %s\n", pcap_geterr(descr)); else { printf("\n\nPackets Received:\t\t%d\n", statistic.ps_recv); printf("Packets Dropped by kernel:\t%d\n", statistic.ps_drop); } } if (tl) pcap_dump_close(dumper); if (logd) fclose(logd); exit(0); } /* demonize process */ void bkg(void) { if (fork()) exit(0); printf ("\nRunning in background with PID %d\n", getpid()); puts("\n"); fclose (stdout); } /* convert u_char to "##:##:##...##" format */ char * nast_hex_ntoa (u_char *s) { char *r = calloc (18, sizeof (char)); sprintf (r, "%02X:%02X:%02X:%02X:%02X:%02X", s[0], s[1], s[2], s[3], s[4], s[5]); return r; } /* convert u_char[4] to "###.###.###.###" format */ char * nast_atoda (u_char *s) /* array to dot array */ { char *r = calloc (16, sizeof (char)); sprintf (r, "%d.%d.%d.%d", s[0], s[1], s[2], s[3]); return r; } void n_print(char *wins, int y, int x, int lg, char *string, ...) { char msg[2048]; int n; va_list ap; va_start(ap, string); n = vsnprintf(msg, 2048, string, ap); va_end(ap); if(!graph && !lg) { printf("%s",msg); fflush(NULL); } if(!graph && lg) { fprintf(logd,"%s\n",msg); printf("%s",msg); fflush(NULL); } #ifdef HAVE_LIBNCURSES if(graph && lg) { fprintf(logd,"%s",msg); ng_print(wins,y,x,msg); } if(graph && !lg) ng_print(wins,y,x,msg); #endif } nast-0.2.0/ncurses/0040755000175000001440000000000010014474126013347 5ustar embyteusersnast-0.2.0/ncurses/n_stream.c0100644000175000001440000000655310003274677015340 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #include #include #include #ifdef HAVE_LIBNCURSES void *read_packet(void *threadid); int line = 1; int col = 3; int tmp; struct stream_thread { char s_dev[30]; char s_sfilter[200]; }; struct stream_thread st_thread_data[1]; int streamg (char *dev, char *sfilter) { line = 1; col = 3; tmp=line; werase(princ->win); winscroll(princ,-1000); SAFE_SCROLL_REFRESH(princ); /* if someone press enter without a filter selected */ if(strstr(sfilter,"host") == NULL) return -1; strcpy(st_thread_data[0].s_dev,dev); strcpy(st_thread_data[0].s_sfilter,sfilter); pthread_create(&thID[5],NULL,read_packet,(void *) &st_thread_data[0]); return 0; } void data_sniffo_stream (char *data_info, u_int len) { int i; if (data_info == NULL) { mvwprintw(princ->win,line,col,"NULL DATA"); SAFE_SCROLL_REFRESH(princ); ++line; } for (i = 0; i < len; i++) { if (ispunct(data_info[i]) || isalnum(data_info[i])) { mvwprintw(princ->win,line,col,"%c",data_info[i]); SAFE_SCROLL_REFRESH(princ); col++; } else if (data_info[i]=='\n') { line++; col=3; } else if (data_info[i]=='\r') col = col + 5; else if (data_info[i]=='\t') col = col + 3; else col++; } /* if(line>LINES-16 && line!=tmp) { winscroll(princ,+1); tmp=line; }*/ } void *read_packet(void *threadid) { char errbuf[LIBNET_ERRBUF_SIZE]; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; pcap_t *s_str; char *data; int n; u_short TCP_SIZE_H; struct stream_thread *sdata; sdata = (struct stream_thread *) threadid; data = packet = NULL; if ((s_str = pcap_open_offline(tcpdl,errbuf))==NULL) { w_error(1, "pcap_open_offline() error: %s\n\n",errbuf); } if ((offset=(device(sdata->s_dev,s_str)))==-1) w_error(1, "Offset error"); data = malloc (1024); if(pcap_compile(s_str,&fp,sdata->s_sfilter,0,netp) == -1) { w_error(1, "Error calling pcap_compile\n\n"); } if(pcap_setfilter(s_str,&fp) == -1) { w_error(1, "Error calling pcap_setfilter\n\n"); } while(1) { packet = (u_char *) pcap_next(s_str, &hdr); if(packet==NULL) continue; ip = (struct libnet_ipv4_hdr *) (packet + offset); if (ip->ip_p != IPPROTO_TCP) continue; tcp = (struct libnet_tcp_hdr *) (packet + offset + LIBNET_IPV4_H); TCP_SIZE_H = tcp->th_off*4; n=ntohs(ip->ip_len) - LIBNET_IPV4_H - TCP_SIZE_H; data = (char *) (packet + offset + LIBNET_IPV4_H + TCP_SIZE_H); data_sniffo_stream(data, n); } pthread_exit(NULL); } #endif nast-0.2.0/ncurses/n_rst.c0100644000175000001440000002657610013746653014663 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES # define Rst 0 # define Fin 1 # define Syn 2 int r_add(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, u_long seq, u_long ack, int flag); int r_del(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, int flag); int r_nconn = 0; int r_lines = 1; int app = 0; int rst_connection_db(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport) { char errbuf[256]; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; pcap_t* descr; int k; logd = stdout; nmax = 2; if((descr=pcap_open_live(dev,BUFSIZ,1,0,errbuf)) == NULL) { w_error(1, "pcap_open_live: %s", errbuf); } offset=(device(dev,descr)); for(k=0;k<30;k++) { memset(&c_inf[k], 0, sizeof(c_inf[k])); } init_scr(); mvwprintw(winfo->win,0,2,"Source"); mvwprintw(winfo->win,0,21,"Port"); mvwprintw(winfo->win,0,34,"Destination"); mvwprintw(winfo->win,0,55,"Port"); mvwprintw(winfo->win,0,66,"State"); SAFE_SCROLL_REFRESH(winfo); while(rst_glob!=0) { if ((packet = (u_char *) pcap_next (descr, &hdr))!=NULL) { ip = (struct libnet_ipv4_hdr *) (packet + offset); tcp = (struct libnet_tcp_hdr *) (packet + offset + LIBNET_IPV4_H); if (ip->ip_p == IPPROTO_TCP) { if (!sport && !dport) { if ( ip->ip_src.s_addr == ip_src && ip->ip_dst.s_addr == ip_dst) { switch(tcp->th_flags) { case TH_SYN: r_add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),Syn); break; case (TH_SYN|TH_ACK): r_add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case TH_ACK: r_add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case TH_RST: r_del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; case (TH_ACK|TH_PUSH): r_add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case (TH_URG|TH_ACK): r_add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case (TH_FIN|TH_ACK): r_del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Fin); case (TH_RST|TH_ACK): r_del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; default: break; } } /*caso rovescio */ else if ( ip->ip_src.s_addr == ip_dst && ip->ip_dst.s_addr == ip_src ) { switch(tcp->th_flags) { case TH_SYN: r_add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),Syn); break; case (TH_SYN|TH_ACK): r_add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case TH_ACK: r_add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case TH_RST: r_del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; case (TH_ACK|TH_PUSH): r_add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case (TH_URG|TH_ACK): r_add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),htonl (tcp->th_seq), htonl (tcp->th_ack),0); break; case (TH_FIN|TH_ACK): r_del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Fin); case (TH_RST|TH_ACK): r_del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; default: break; } } } } } } pcap_close(descr); return 0; } int r_add(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, u_long seq, u_long ack, int flag) { int i; for(i=0;i<30;i++) if((ip_src==c_inf[i].s_ip && ip_dst==c_inf[i].d_ip && sport==c_inf[i].s_port && dport==c_inf[i].d_port && c_inf[i].set) || (ip_src==c_inf[i].d_ip && ip_dst==c_inf[i].s_ip && sport==c_inf[i].d_port && dport==c_inf[i].s_port && c_inf[i].set)) { c_inf[i].seq=seq; c_inf[i].ack=ack; sf[c_inf[i].pr].seq=seq; sf[c_inf[i].pr].ack=ack; return(0); } for(i=0;i<30;i++)/*cerco spazio vuoto*/ { if(c_inf[i].s_ip) continue; else if(flag!=Syn) return(0); else { c_inf[i].s_ip = ip_src; c_inf[i].d_ip = ip_dst; c_inf[i].s_port = sport; c_inf[i].d_port = dport; c_inf[i].seq=seq; c_inf[i].ack=ack; c_inf[i].pr=app; mvwprintw(winfo->win,r_lines,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,r_lines,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,r_lines,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,r_lines,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,r_lines,66,"Work"); c_inf[i].lin=r_lines; SAFE_SCROLL_REFRESH(winfo); sprintf(sf[app].string,"%2s%12d%20s%14d Work",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); /* create the filter for tcp stream*/ sprintf(sf[app].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); sf[app].seq=c_inf[i].seq; sf[app].ack=c_inf[i].ack; sf[app].ip_src=c_inf[i].s_ip; sf[app].ip_dst=c_inf[i].d_ip; sf[app].s_port=c_inf[i].s_port; sf[app].d_port=c_inf[i].d_port; sf[i].cont=app; c_inf[i].set=1; r_nconn++; r_lines++; app++; ++nmax; return(1); } } return(0); } int r_del(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, int flag) { int i; for(i=0;i<30;i++) { if(ip_src==c_inf[i].s_ip && ip_dst==c_inf[i].d_ip && sport==c_inf[i].s_port && dport==c_inf[i].d_port) { if(flag){ mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Closed"); sprintf(sf[sf[i].cont].string,"%2s%12d%20s%14d Closed", libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } else { mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Resetted"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%13d Resetted",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } sprintf(sf[sf[i].cont].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); SAFE_SCROLL_REFRESH(winfo); //wrefresh(winfo->win); memset(&c_inf[i], 0, sizeof(c_inf[i])); r_nconn--; } else if(ip_src==c_inf[i].d_ip && ip_dst==c_inf[i].s_ip && sport==c_inf[i].d_port && dport==c_inf[i].s_port) { if(flag){ mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Closed"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%14d Closed",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } else { mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Resetted"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%13d Resetted",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } sprintf(sf[sf[i].cont].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); SAFE_SCROLL_REFRESH(winfo); memset(&c_inf[i], 0, sizeof(c_inf[i])); r_nconn--; } } return -1; } int reset_conn(char *dev,u_long s_ip, u_long d_ip, u_short s_port, u_short d_port,u_long seq, u_long ack) { char errbuf[256]; libnet_t *l; u_short n; n_print("princ",3,1,0,"- Stoled SEQ (%lu) ACK (%lu)...\n", seq, ack); if ((l = libnet_init (LIBNET_RAW4, NULL, errbuf))==NULL) { w_error(1, "libnet_init: %s\n", errbuf); } if (libnet_build_tcp (s_port, d_port, seq, ack, TH_RST, 32767, 0, 0, LIBNET_TCP_H, NULL, 0, l, 0)==-1) { libnet_destroy (l); w_error(1, "Error building tcp header : %s\n" ,libnet_geterror(l)); } if (libnet_build_ipv4 (LIBNET_TCP_H + LIBNET_IPV4_H, 0x08, 35320, 0, 64, IPPROTO_TCP, 0,s_ip , d_ip , NULL, 0, l, 0)==-1) { libnet_destroy (l); w_error(1, "Error building ip header : %s\n", libnet_geterror(l)); } for (n = 0; n < 2 ; n++) if (libnet_write (l) == -1) { libnet_destroy(l); w_error(1, "Error writing packet on wire : %s\n", libnet_geterror(l)); } n_print("princ",5,1,0,"- Creating and sending the packet..."); libnet_destroy(l); wattron(princ->win,A_BOLD); n_print("princ",7,1,0,"- Connection has been resetted!!\n\n"); wattroff(princ->win,A_BOLD); redrawscrollwin(princ,0); return (0); } #endif nast-0.2.0/ncurses/n_comm.c0100644000175000001440000001216610012736044014764 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES int tmp; int ng_print(char *wins, int y, int x, char *string) { N_SCROLLWIN *w; int ris; ris = 0; w = NULL; if(wins==NULL) return(0); if(!strcmp(wins,"princ")) w=princ; if(!strcmp(wins,"winfo")) w=winfo; if(!strcmp(wins,"pop")) { pop_up_win(); if(string[strlen(string)-1]=='\n') (string[strlen(string)-1]='\0'); mvwprintw(pop_up,y,x,"%s",string); mvwprintw(pop_up,11,13,"Press 'q' to close this window"); wrefresh(pop_up); do { ris=wgetch(pop_up); } while(ris!='q'); delwin(pop_up); nmenu(); redrawscrollwin(winfo,0); redrawscrollwin(princ,0); return 0; } if(string[0]=='\n') string[0]=' '; if(string[strlen(string)-1]=='\n') (string[strlen(string)-1]='\0'); mvwprintw(w->win,y,x,"%s",string); if(sniff_glob) { if(!mvar) SAFE_SCROLL_REFRESH(w); else ; } if(!sniff_glob) SAFE_SCROLL_REFRESH(w); if(w==princ) { if(y!=tmp) { if(line_s>LINES-16) { if(!mvar) { winscroll(princ,linm); winscroll(princ,+(y-tmp)); linm=0; } else linm+=y-tmp; } } tmp=y; } if(line_s >= 10000) { werase(princ->win); winscroll(princ,-10000); line_s=0; row_s=0; } return 0; } void init_scr(void) { werase(princ->win); werase(winfo->win); winscroll(princ, -10000); // rewind the scrollbar winscroll(winfo,-300); // rewind the scrollbar redrawscrollwin(princ,0); redrawscrollwin(winfo,0); } int check_pthread(void) { int ris,i,ret; ris = i = ret = 0; if ( (sniff_glob || stream_glob || bc_glob || rst_glob || arp_glob) == 1) { lg = 0; pop_up_win(); mvwprintw(pop_up,6,8,"Warning, another function is running!"); mvwprintw(pop_up,7,11,"Should i stop its thread (y/n)?"); wmove(pop_up,8,6); do { ris=wgetch(pop_up); if (ris == 'y') { if(stream_glob) { (i=0); pthread_cancel(thID[5]); pthread_join(thID[5], NULL); } if(sniff_glob) (i=1); if(rst_glob) (i=2); if(arp_glob) (i=6); if(bc_glob) { bc_glob=0; pthread_cancel(pt[1]); pthread_join(pt[1], NULL); werase(winfo->win); return(0); } stream_glob = sniff_glob = rst_glob = arp_glob = 0; pthread_cancel(thID[i]); pthread_join(thID[i], NULL); winscroll(princ, -10000); werase(princ->win); ret = 0; } else if (ris == 'n') { delwin(pop_up); pop_up_win(); mvwprintw(pop_up,6,8,"I will continue with the old function"); ret = 1; } } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); } return(ret); } int n_error(char *err, int fatal) { int ris; ris = 0; if(fatal) { endwin(); fprintf(stderr, "\n%s\n\n", err); exit(-1); } else { pop_up_win(); mvwprintw(pop_up,6,3,"%s",err); mvwprintw(pop_up,12,18,"Press 'q' to quit"); do { ris=wgetch(pop_up); } while( ris != 'q'); delwin(pop_up); werase(princ->win); redrawscrollwin(princ,0); return(0); } } int shutdown_thread(void) { int ris,i,ret; ris = i = ret = 0; if ( (sniff_glob || stream_glob || bc_glob || rst_glob || arp_glob) == 1) { if(bc_glob) { bc_glob=0; werase(princ->win); werase(winfo->win); pthread_cancel(pt[1]); pthread_join(pt[1], NULL); return(0); } if(stream_glob) { (i=3); stream_glob=0; werase(princ->win); werase(winfo->win); pthread_cancel(thID[5]); pthread_join(thID[5],NULL); pthread_cancel(thID[i]); pthread_join(thID[i], NULL); return(0); } if(sniff_glob) { (i=1); sniff_glob=0; werase(princ->win); werase(winfo->win); redrawscrollwin(winfo,0); pthread_cancel(thID[i]); pthread_join(thID[i], NULL); return(0); } if(rst_glob) { (i=2); rst_glob=0; werase(princ->win); werase(winfo->win); redrawscrollwin(winfo,0); pthread_cancel(thID[i]); pthread_join(thID[i], NULL); return(0); } if(arp_glob) { (i=6); arp_glob=0; werase(princ->win); werase(winfo->win); redrawscrollwin(winfo,0); pthread_cancel(thID[i]); pthread_join(thID[i], NULL); return(0); } } return(0); } #endif nast-0.2.0/ncurses/n_conn.c0100644000175000001440000002172710013746653015001 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES # define Rst 0 # define Fin 1 int add(u_long ip_src,u_long ip_dst,u_short sport,u_short dport); int del(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, int flag); int nconn = 0; int lines = 1; int z = 0; int tmp; int connection(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport) { char errbuf[256]; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; pcap_t* descr; pcap_dumper_t *dumper; int k; logd = stdout; nmax = 2; nconn = 0; lines = 1; z=0; tcpdl = "STREAM"; if((descr=pcap_open_live(dev,BUFSIZ,1,0,errbuf)) == NULL) { w_error(1, "pcap_open_live: %s", errbuf); } /* create dumper for log the datas */ if ((dumper = pcap_dump_open(descr,tcpdl))==NULL) { w_error(1, "pcap_open_live() error: %s\n\n",errbuf); } offset=(device(dev,descr)); for(k=0;k<30;k++) { memset(&c_inf[k], 0, sizeof(c_inf[k])); memset(&sf[k].string, 0, sizeof(sf[k].string)); memset(&sf[k].sfilter, 0, sizeof(sf[k].sfilter)); } init_scr(); mvwprintw(winfo->win,0,2,"Source"); mvwprintw(winfo->win,0,21,"Port"); mvwprintw(winfo->win,0,34,"Destination"); mvwprintw(winfo->win,0,55,"Port"); mvwprintw(winfo->win,0,66,"State"); SAFE_SCROLL_REFRESH(winfo); while(1) { if ((packet = (u_char *) pcap_next (descr, &hdr))!=NULL) { fflush((FILE *)dumper); pcap_dump((u_char *)dumper,&hdr,packet); ip = (struct libnet_ipv4_hdr *) (packet + offset); tcp = (struct libnet_tcp_hdr *) (packet + offset + LIBNET_IPV4_H); if (ip->ip_p == IPPROTO_TCP) { if (!sport && !dport) { if ( ip->ip_src.s_addr == ip_src && ip->ip_dst.s_addr == ip_dst) { switch(tcp->th_flags) { case TH_SYN: add(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport)); break; case TH_ACK: break; case TH_RST: del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; case (TH_ACK|TH_PUSH): break; case (TH_URG|TH_ACK): break; case (TH_FIN|TH_ACK): del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Fin); case (TH_RST|TH_ACK): del(ip_src,ip_dst,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; default: break; } } /* caso rovescio */ else if ( ip->ip_src.s_addr == ip_dst && ip->ip_dst.s_addr == ip_src ) { switch(tcp->th_flags) { case TH_SYN: add(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport)); break; case TH_ACK: break; case TH_RST: del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; case (TH_ACK|TH_PUSH): break; case (TH_URG|TH_ACK): break; case (TH_FIN|TH_ACK): del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Fin); case (TH_RST|TH_ACK): del(ip_dst,ip_src,htons(tcp->th_sport),htons(tcp->th_dport),Rst); break; default: break; } } } } } } pcap_close(descr); pcap_dump_close(dumper); return 0; } int add(u_long ip_src,u_long ip_dst,u_short sport,u_short dport) { int i; for(i=0;i<30;i++) if((ip_src==c_inf[i].s_ip && ip_dst==c_inf[i].d_ip && sport==c_inf[i].s_port && dport==c_inf[i].d_port) || (ip_src==c_inf[i].d_ip && ip_dst==c_inf[i].s_ip && sport==c_inf[i].d_port && dport==c_inf[i].s_port)) return(0); /*ce l'ho gi� (duplicato)*/ for(i=0;i<30;i++)/*cerco spazio vuoto*/ { if(c_inf[i].s_ip)continue; else { c_inf[i].s_ip = ip_src; c_inf[i].d_ip = ip_dst; c_inf[i].s_port = sport; c_inf[i].d_port = dport; mvwprintw(winfo->win,lines,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,lines,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,lines,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,lines,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,lines,66,"Open"); SAFE_SCROLL_REFRESH(winfo); sprintf(sf[z].string, "%2s%12d%20s%12d Open",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); /* create the filter for tcp stream*/ sprintf(sf[z].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); c_inf[i].lin=lines; sf[i].cont=z; nconn++; lines++; z++; ++nmax; return(1); } } return(0); } int del(u_long ip_src,u_long ip_dst,u_short sport,u_short dport, int flag) { int i; for(i=0;i<30;i++) { if(ip_src==c_inf[i].s_ip && ip_dst==c_inf[i].d_ip && sport==c_inf[i].s_port && dport==c_inf[i].d_port) { if(flag){ mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Closed"); sprintf(sf[sf[i].cont].string,"%2s%12d%20s%14d Closed", libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } else { mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Resetted"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%13d Resetted",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } sprintf(sf[sf[i].cont].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); SAFE_SCROLL_REFRESH(winfo); //wrefresh(winfo->win); memset(&c_inf[i], 0, sizeof(c_inf[i])); nconn--; } else if(ip_src==c_inf[i].d_ip && ip_dst==c_inf[i].s_ip && sport==c_inf[i].d_port && dport==c_inf[i].s_port) { if(flag){ mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Closed"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%14d Closed",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } else { mvwprintw(winfo->win,c_inf[i].lin,2,"%s",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,21,"%d",c_inf[i].s_port); mvwprintw(winfo->win,c_inf[i].lin,34,"%s",libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE)); mvwprintw(winfo->win,c_inf[i].lin,55,"%d",c_inf[i].d_port); mvwprintw(winfo->win,c_inf[i].lin,66,"Resetted"); sprintf(sf[sf[i].cont].string, "%2s%12d%20s%13d Resetted",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); } sprintf(sf[sf[i].cont].sfilter,"host %s and port %d and host %s and port %d",libnet_addr2name4(c_inf[i].s_ip, LIBNET_DONT_RESOLVE),c_inf[i].s_port,libnet_addr2name4(c_inf[i].d_ip, LIBNET_DONT_RESOLVE),c_inf[i].d_port); SAFE_SCROLL_REFRESH(winfo); memset(&c_inf[i], 0, sizeof(c_inf[i])); nconn--; } } return -1; } #endif nast-0.2.0/ncurses/n_scroll_win.c0100644000175000001440000000754210003274706016210 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES N_SCROLLWIN *newscrollwin(int lines, int cols, int y, int x, char *title, int maxlines) { N_SCROLLWIN *win; win = calloc(1, sizeof(N_SCROLLWIN)); win->win = newpad(maxlines, cols - 2); win->out = newwin(lines, cols, y, x); win->y_max = maxlines; win->lines = lines; win->cols = cols; win->x = x; win->y = y; win->title = strdup(title); scrollok(win->win, TRUE); /* move the cursor to the right starting point */ win->y_scroll = maxlines - (lines-2); wmove(win->win, win->y_scroll - 1, 0); /* draw the outer window */ wattrset(win->out, COLOR_PAIR(3)); wborder(win->out, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER); wmove(win->out, 0, 2); wattrset(win->out, COLOR_PAIR(2)); waddstr(win->out, " "); waddstr(win->out, title); waddstr(win->out, " "); wattrset(win->out, COLOR_PAIR(3)); drawscroller(win); return win; } /* redraw the window with or without focus */ void redrawscrollwin(N_SCROLLWIN *win, int focus) { if (focus) wattron(win->out, A_BOLD); werase(win->out); wmove(win->out, 0, 0); wattron(win->out, COLOR_PAIR(3)); wborder(win->out, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER); if (focus) { wmove(win->out, 0, 0); wattron(win->out, COLOR_PAIR(4)); waddch(win->out, ACS_LARROW); waddch(win->out, ACS_RARROW); wattroff(win->out, COLOR_PAIR(4)); } wattron(win->out, COLOR_PAIR(2)); wmove(win->out, 0, 2); waddstr(win->out, " "); waddstr(win->out, win->title); waddstr(win->out, " "); wattroff(win->out, COLOR_PAIR(2)); redrawwin(win->out); if (focus) wattroff(win->out, A_BOLD); drawscroller(win); SAFE_SCROLL_REFRESH(win); } /* display the scroll indicator on the right */ void drawscroller(N_SCROLLWIN *win) { short height = (win->lines-2) * (win->lines-2) / win->y_max; short vpos = win->lines * win->y_scroll / win->y_max; wattron(win->out, COLOR_PAIR(2)); wattroff(win->out, A_BOLD); height = (height < 1) ? 1 : height; vpos = (vpos == 0) ? 1 : vpos; vpos = (vpos > (win->lines-1) - height) ? (win->lines-1) - height : vpos; wmove(win->out, 1, win->x + win->cols - 1); wvline(win->out, ACS_CKBOARD, win->lines - 2); wattron(win->out, A_REVERSE); wmove(win->out, vpos, win->x + win->cols - 1); wvline(win->out, ' ', height); wattroff(win->out, A_REVERSE); wnoutrefresh(win->out); } /* scroll a window for delta lines */ void winscroll(N_SCROLLWIN *win, int delta) { win->y_scroll += delta; win->y_scroll = (win->y_scroll < 0) ? 0 : win->y_scroll; win->y_scroll = (win->y_scroll > win->y_max - (win->lines-2) ) ? win->y_max - (win->lines-2) : win->y_scroll; drawscroller(win); SAFE_SCROLL_REFRESH(win); } void delscrollwin(N_SCROLLWIN **win) { werase((*win)->win); SAFE_WREFRESH((*win)->win); werase((*win)->out); SAFE_WREFRESH((*win)->out); delwin((*win)->win); delwin((*win)->out); SAFE_FREE((*win)->title); SAFE_FREE(*win); } #endif nast-0.2.0/ncurses/n_menu.c0100644000175000001440000011630210012736256014777 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES # define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) # define CTRLD 4 void *n_sniff(void *threadid); void *t_arp(void *threadarg); int check_filter(char *filt); int s_select(void); int r_select(void); int sport,dport; u_long ip_src, ip_dst; libnet_t *L = NULL; libnet_plist_t plist, *plist_p; static u_short ports[] = { 21, 22, 23, 25, 43, 53, 79, 80, 110, 119, 143, 220, 513, 514 }; char *choices[] = { " (S)niffer ", " (A)nalyzer ", " (O)ptions ", (char *)NULL, }; char *sniffer[] = { "Start Sniff ", "Stop Sniff ", "Filter ", "Promisc ", "ASCII ", "HEX ", "Log Payload ", "Log TCPDUMP format ", "Read TCPDUMP File ", "Log all packets ", (char *)NULL, }; char *analyzer[] = { "Check Sniffers ", "Hosts List ", "TCP Stream ", "Find Gateway ", "Reset Connection ", "Port Scanner ", "Multi Port Scanner ", "Find Link ", "Daemon Banner ", "Check ARP Poinsoning ", "Byte Counting ", (char *)NULL, }; char *options[] = { "Interface ", "Log Report ", "Daemonize ", "Stop Application ", "Version ", "Help ", "Exit ", (char *)NULL, }; void nmenu() { ITEM **my_items; int ris; int n_choices, i; ris = 0; n_choices = ARRAY_SIZE(choices); my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(choices[i], choices[i]); my_nmenu = new_menu((ITEM **)my_items); my_nmenu_win = newwin(3,COLS, 3, 0); keypad(my_nmenu_win, TRUE); wbkgd(my_nmenu_win,COLOR_PAIR(5)); if(flg==0) { menu_opts_on(my_nmenu, O_SHOWDESC); mvwprintw(my_nmenu_win,1,1," (S)niffer (A)nalyzer (O)ptions"); } else menu_opts_off(my_nmenu, O_SHOWDESC); mvwprintw(my_nmenu_win,1,COLS-8,"(F1)"); set_menu_win(my_nmenu, my_nmenu_win); set_menu_sub(my_nmenu, derwin(my_nmenu_win, 2, COLS-2, 1, 1)); if(flg==1) set_menu_format(my_nmenu, 1, 3); set_menu_mark(my_nmenu, " "); wcolor_set(my_nmenu_win,3,NULL); box(my_nmenu_win, 0, 0); post_menu(my_nmenu); wrefresh(my_nmenu_win); } int sniffer_menu() { ITEM **my_items; int c, ris; MENU *my_menu; WINDOW *my_menu_win; int n_choices, i, y; y = 1; ris = 0; mvar = 1; /* Create items */ n_choices = ARRAY_SIZE(sniffer); my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(sniffer[i], sniffer[i]); /* Crate menu */ my_menu = new_menu((ITEM **)my_items); /* Set menu option not to show the description */ menu_opts_off(my_menu, O_SHOWDESC); /* Create the window to be associated with the menu */ my_menu_win = newwin(12, 27, 5, 0); keypad(my_menu_win, TRUE); wbkgd(my_menu_win,COLOR_PAIR(3)); set_menu_win(my_menu, my_menu_win); set_menu_sub(my_menu, derwin(my_menu_win, 11, 25, 1, 1)); set_menu_mark(my_menu, " "); box(my_menu_win, 0, 0); post_menu(my_menu); wrefresh(my_menu_win); while( (c = wgetch(my_menu_win)) != 'q') { switch(c) { case KEY_UP: y--; if (!y) { menu_driver(my_menu, REQ_LAST_ITEM); y=10; } else menu_driver(my_menu, REQ_UP_ITEM); break; case KEY_DOWN: y++; if(y==11) { menu_driver(my_menu, REQ_FIRST_ITEM); y=1; } else menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_LEFT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-2); break; case KEY_RIGHT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-1); break; case 10: curr_item = current_item(my_menu); switch(item_index(curr_item)) { case 0: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); sniff_glob = 1; pthread_create( &thID[1], NULL, n_sniff , NULL); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 1: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); sniff_glob = 0; lg = 0; pthread_cancel (thID[1]); pthread_join (thID[1], NULL); winscroll(princ, -10000); werase(princ->win); delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; promisc = 1; //ascii = hex = f = l = tl = tr = 0; return(0); break; case 2: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert filter to apply (NULL takes no effects):"); mvwprintw(pop_up,3,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,5,2); echo(); wgetnstr(pop_up, n_filter, 60); noecho(); if(strcmp(n_filter, "NULL")) (f=1); else { (f=0); strcpy(n_filter,"NULL"); } delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 3: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Do you want to set Promisc Mode (y/n)?"); mvwprintw(pop_up,3,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,5,2); do { ris=wgetch(pop_up); if (ris == 'y') promisc=1; else if (ris == 'n') promisc=0; } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 4: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Do you want to set ASCII data printing (y/n)?"); mvwprintw(pop_up,3,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,5,2); do { ris=wgetch(pop_up); if (ris == 'y') ascii=1; else if (ris == 'n') ascii=0; } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 5: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Do you want to set ASCII-HEX data printing (y/n)?"); mvwprintw(pop_up,3,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,5,2); do { ris=wgetch(pop_up); if (ris == 'y') hex=1; else if (ris == 'n') hex=0; } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 6: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert name file for data logging"); mvwprintw(pop_up,3,2,"(NULL takes no effects):"); mvwprintw(pop_up,4,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, ldfile, 50); noecho(); if (strcmp (ldfile, "NULL")) /* != NULL */ (ld=1); else { (ld=0); strcpy(ldfile,"NULL"); } delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 7: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert name file for packets logging"); mvwprintw(pop_up,3,2,"in tcpdump format (NULL takes no effects):"); mvwprintw(pop_up,4,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, tcpdfile, 50); noecho(); if (strcmp (tcpdfile, "NULL")) { /* != NULL */ (tl=1); tcpdl=tcpdfile; } else { (tl=0); strcpy(tcpdfile,"NULL"); } delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 8: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert name file for packets reading"); mvwprintw(pop_up,3,2,"in tcpdump format (NULL takes no effects):"); mvwprintw(pop_up,4,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, tcpdfile, 50); noecho(); if (strcmp (tcpdfile, "NULL")) { /* != NULL */ (tr=1); tcpdl=tcpdfile; if(check_pthread() == 1) return(0); sniff_glob = 1; pthread_create( &thID[1], NULL, n_sniff , NULL); delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); } else { (tr=0); strcpy(tcpdfile,"NULL"); } delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; case 9: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert name file for packets logging"); mvwprintw(pop_up,3,2,"(NULL takes no effects):"); mvwprintw(pop_up,4,2,"Remember to restart sniffer to take option working!"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, logfile, 50); noecho(); if (strcmp (logfile, "NULL")) /* != NULL */ { (l=1); logname = logfile; lg = 1; } else { (l=0); strcpy(logfile,"NULL"); lg = 0; } delwin(pop_up); redrawscrollwin(princ,0); mvar = 0; return(0); break; } break; } wrefresh(my_menu_win); } /* Unpost and free all the memory taken up */ unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); mvar = 0; return(0); } int analyzer_menu() { ITEM **my_items; int c; MENU *my_menu; WINDOW *my_menu_win; int n_choices, i, y; char errbuf[PCAP_ERRBUF_SIZE]; char arg[30]; char buff[50]; u_long anip; y = 1; anip = 0; mvar = 1; L = libnet_init (LIBNET_LINK, NULL, errbuf); /* Create items */ n_choices = ARRAY_SIZE(analyzer); my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(analyzer[i], analyzer[i]); /* Crate menu */ my_menu = new_menu((ITEM **)my_items); /* Set menu option not to show the description */ menu_opts_off(my_menu, O_SHOWDESC); /* Create the window to be associated with the menu */ my_menu_win = newwin(13, 28, 5, 15); keypad(my_menu_win, TRUE); wbkgd(my_menu_win,COLOR_PAIR(3)); set_menu_win(my_menu, my_menu_win); set_menu_sub(my_menu, derwin(my_menu_win, 12, 26, 1, 1)); set_menu_mark(my_menu, " "); box(my_menu_win, 0, 0); post_menu(my_menu); wrefresh(my_menu_win); while((c = wgetch(my_menu_win)) != 'q') { switch(c) { case KEY_UP: y--; if (!y) { menu_driver(my_menu, REQ_LAST_ITEM); y=11; } else menu_driver(my_menu, REQ_UP_ITEM); break; case KEY_DOWN: y++; if (y==12) { menu_driver(my_menu, REQ_FIRST_ITEM); y=1; } else menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_LEFT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-2); break; case KEY_RIGHT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-1); break; case 10: /* Enter */ curr_item = current_item(my_menu); switch(item_index(curr_item)) { case 0: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); pop_up_win(); mvwprintw(pop_up,2,15,"Promisc check"); mvwprintw(pop_up,3,2,"Insert IP to scan or \"all\" for all nodes"); wmove(pop_up,5,2); echo(); wgetnstr(pop_up, arg, 50); noecho(); if (strcmp (arg, "all")) { anip = libnet_name2addr4(L, arg, LIBNET_RESOLVE); if (anip==-1) { libnet_destroy(L); if(w_error(0, "Error: cannot resolve %s\n\n", optarg) == -1) return(0); } } delwin(pop_up); redrawscrollwin(princ,0); psearch (dev, anip, lr); return(0); break; case 1: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); map_lan(dev, 1, NULL); return(0); break; case 2: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); sport = dport = 0; pop_up_win(); mvwprintw(pop_up,2,2,"Insert Src IP: (NULL will takes no effects)"); wmove(pop_up,3,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); if (!strcmp(buff,"NULL")) { delwin(pop_up); redrawscrollwin(princ,0); return(0); } if ((ip_src = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(0, "Error: %s", libnet_geterror(L)); redrawscrollwin(princ,0); return(0); } mvwprintw(pop_up,5,2,"Insert Dst IP: (NULL will takes no effects)"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); if (!strcmp(buff,"NULL")) { delwin(pop_up); redrawscrollwin(princ,0); return(0); } if ((ip_dst = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(0, "Error: %s", libnet_geterror(L)); redrawscrollwin(princ,0); return 0; } delwin(pop_up); redrawscrollwin(princ,0); nmenu(); memset(&th_data[0], 0, sizeof(th_data[0])); /*passing thread data*/ th_data[0].ip_src=ip_src; th_data[0].ip_dst=ip_dst; th_data[0].sport=0; th_data[0].dport=0; strcpy(th_data[0].device,dev); stream_glob = 1; pthread_create(&thID[3], NULL, conn_db ,(void *) &th_data[0]); libnet_destroy(L); s_select(); return(0); break; case 3: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); fgw (dev); return(0); break; case 4: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); sport = dport = 0; pop_up_win(); mvwprintw(pop_up,2,2,"Insert Src IP: (NULL will takes no effects)"); wmove(pop_up,3,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); if (!strcmp(buff,"NULL")) { delwin(pop_up); redrawscrollwin(princ,0); return(0); } if ((ip_src=libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(0, "Error: %s", libnet_geterror(L)); redrawscrollwin(princ,0); return 0; } mvwprintw(pop_up,5,2,"Insert Dst IP: (NULL will takes no effects)"); wmove(pop_up,6,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); if (!strcmp(buff,"NULL")) { delwin(pop_up); redrawscrollwin(princ,0); return(0); } if ((ip_dst=libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(0, "Error: %s", libnet_geterror(L)); redrawscrollwin(princ,0); return 0; } memset(&th_r_data[0], 0, sizeof(th_r_data[0])); /*passing thread data*/ th_r_data[0].ip_src=ip_src; th_r_data[0].ip_dst=ip_dst; th_r_data[0].sport=0; th_r_data[0].dport=0; strcpy(th_r_data[0].device,dev); rst_glob = 1; pthread_create( &thID[2], NULL, conn_db_r ,(void *) &th_r_data[0]); libnet_destroy(L); nmenu(); r_select(); return(0); break; case 5: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); pop_up_win(); mvwprintw(pop_up,2,18,"- Port Scanner -"); mvwprintw(pop_up,4,2,"Insert IP to scan (NULL will take no effect):"); wmove(pop_up,5,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); if (!strcmp(buff,"NULL")) { delwin(pop_up); redrawscrollwin(princ,0); return(0); } if ((ip_dst = libnet_name2addr4(L, dn (buff), LIBNET_RESOLVE))==-1) { w_error(1, "Error: %s", libnet_geterror(L)); } do { mvwprintw(pop_up,7,2,"Insert Port range: "); wmove(pop_up,8,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); } while (atoi(buff) < 1 || atoi(buff) > 65536); plist_p = &plist; if (libnet_plist_chain_new(L, &plist_p, buff) == -1) { if(w_error(0, "Bad token in port list: %s\n",libnet_geterror(L))==-1) return(0); } delwin(pop_up); nmenu(); redrawscrollwin(princ,0); port(dev,ip_dst,plist_p,lr); return(0); break; case 6: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); pop_up_win(); mvwprintw(pop_up,2,18,"- MULTI Port Scanner -"); mvwprintw(pop_up,4,2,"Insert IP to scan (NULL will take no effect):"); do { mvwprintw(pop_up,5,2,"Insert Port range: "); wmove(pop_up,8,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); } while (atoi(buff) < 1 || atoi(buff) > 65536); plist_p = &plist; if (libnet_plist_chain_new(L, &plist_p, buff) == -1) { if(w_error(0, "Bad token in port list: %s\n",libnet_geterror(L))==-1) return(0); } delwin(pop_up); nmenu(); redrawscrollwin(princ,0); mhport (dev,plist_p,lr); return(0); break; case 7: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); flink(dev); return(0); break; case 8: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); mport(dev,ports,lr); return(0); break; case 9: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); memset(&th_arp_data[0], 0, sizeof(th_arp_data[0])); /*passing thread data*/ th_arp_data[0].lr=lr; strcpy(th_arp_data[0].device,dev); arp_glob = 1; pthread_create( &thID[6], NULL, t_arp ,(void *) &th_arp_data[0]); return(0); break; case 10: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); pop_up_win(); mvwprintw(pop_up,2,2,"Insert filter to apply"); mvwprintw(pop_up,3,2,"(null or 'any' to disable):"); wmove(pop_up,5,2); echo(); wgetnstr(pop_up, buff, 50); noecho(); delwin(pop_up); redrawscrollwin(princ,0); bc_glob = 1; run_bc(dev,buff); mvar = 0; return(0); break; } break; } wrefresh(my_menu_win); } /* Unpost and free all the memory taken up */ unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(0); } int options_menu() { ITEM **my_items; int c,ris; MENU *my_menu; WINDOW *my_menu_win; int n_choices, i, ok, y; char errbuf[PCAP_ERRBUF_SIZE]; char temp[10]; ris = ok = 0; mvar = y = 1; /* Create items */ n_choices = ARRAY_SIZE(options); my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(options[i], options[i]); /* Crate menu */ my_menu = new_menu((ITEM **)my_items); /* Set menu option not to show the description */ menu_opts_off(my_menu, O_SHOWDESC); /* Create the window to be associated with the menu */ my_menu_win = newwin(9, 21, 5, 31); keypad(my_menu_win, TRUE); wbkgd(my_menu_win,COLOR_PAIR(3)); set_menu_win(my_menu, my_menu_win); set_menu_sub(my_menu, derwin(my_menu_win, 8, 19, 1, 1)); set_menu_mark(my_menu, " "); box(my_menu_win, 0, 0); post_menu(my_menu); wrefresh(my_menu_win); while((c = wgetch(my_menu_win)) != 'q') { switch(c) { case KEY_UP: y--; if (!y) { menu_driver(my_menu, REQ_LAST_ITEM); y=7; } else menu_driver(my_menu, REQ_UP_ITEM); break; case KEY_DOWN: y++; if (y==8) { menu_driver(my_menu, REQ_FIRST_ITEM); y=1; } else menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_LEFT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-1); break; case KEY_RIGHT: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return(-2); break; case 10: /* Enter */ curr_item = current_item(my_menu); switch(item_index(curr_item)) { case 0: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); while(!ok) { pop_up_win(); mvwprintw(pop_up,6,5,"Insert the device you want to use, please:"); mvwprintw(pop_up,7,5," for the default <%s> press enter!",dev); wmove(pop_up,9,23); echo(); wgetnstr(pop_up, temp, 10); if(!strcmp(temp,"")) strcpy(temp,dev); noecho(); if ((pcap_lookupnet(temp,&netp,&maskp,errbuf))==-1) { w_error(0, " Impossible to use device: %s",temp); } else { ok = 1; strcpy(dev,temp); } } delwin(pop_up); redrawscrollwin(princ,0); return(0); break; case 1: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,2,2,"Insert name file for report logging"); mvwprintw(pop_up,3,2,"(NULL takes no effects):"); wmove(pop_up,5,2); echo(); wgetnstr(pop_up, reportl, 50); noecho(); if (strcmp (reportl, "NULL")) /* != NULL */ { (lr=1); logname=reportl; } else { (lr=0); strcpy(reportl,"NULL"); } delwin(pop_up); redrawscrollwin(princ,0); return(0); break; case 2: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); if(check_pthread() == 1) return(0); pop_up_win(); /*mvwprintw(pop_up,2,2,"Do you want to demonize process (y/n)?"); wmove(pop_up,4,2); do { ris=wgetch(pop_up); if (ris == 'y') demonize=1; else if (ris == 'n') demonize=0; } while( ris != 'y' && ris != 'n');*/ mvwprintw(pop_up,6,18, "Not yet implemented!"); mvwprintw(pop_up,12,19,"Press 'q' to quit"); do { ris=wgetch(pop_up); } while( ris != 'q'); wrefresh(pop_up); delwin(pop_up); redrawscrollwin(princ,0); return(0); break; case 3: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); shutdown_thread(); return(0); break; case 4: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,5,9, "NAST - Network Analyzer Sniffer Tool"); mvwprintw(pop_up,7,11, "Version %s (C) Embyte & Snifth", PACKAGE_VERSION); mvwprintw(pop_up,9,18,"Press 'q' to quit"); do { ris=wgetch(pop_up); } while( ris != 'q'); wrefresh(pop_up); return(0); break; case 5: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); help_win(); attron(A_BOLD); mvwprintw(help,2,2,"[F1] -> Menu Selection"); mvwprintw(help,3,2,"[F2] -> Main window interactions"); mvwprintw(help,4,2,"[F3] -> Info window interactions"); mvwprintw(help,5,2,"[UP] -> Scrolling UP windows (1 line)"); mvwprintw(help,6,2,"[DOWN] -> Scrolling DOWN windows (1 line)"); mvwprintw(help,7,2,"[PgUP] -> Scrolling UP windows (5 lines)"); mvwprintw(help,8,2,"[PgDOWN] -> Scrolling DOWN windows (5 lines)"); mvwprintw(help,9,2,"[Shift + s] -> Sniffer Menu"); mvwprintw(help,10,2,"[Shift + a] -> Analyzer Menu"); mvwprintw(help,11,2,"[Shift + o] -> Options Menu"); mvwprintw(help,12,2,"[i] -> Show informations about options"); mvwprintw(help,13,2,"[x] -> Erase Main Window"); mvwprintw(help,14,2,"[d] -> Erase Info window"); mvwprintw(help,15,2,"[h] -> This help"); mvwprintw(help,16,2,"[q] -> Exit all windows"); mvwprintw(help,17,2,"When you use the sniffer pay attention that the"); mvwprintw(help,18,2,"options MUST be selected BEFORE sniffer starting!"); mvwprintw(help,20,2,"[Shift + q] -> Exit NAST"); attroff(A_BOLD); do { ris=wgetch(help); } while( ris != 'q'); wrefresh(help); werase(help); nmenu(); redrawscrollwin(princ,0); redrawscrollwin(winfo,0); return(0); break; case 6: unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ,0); refresh(); pop_up_win(); mvwprintw(pop_up,7,10,"Are you sure you want to exit (y/n)?"); wmove(pop_up,4,2); do { ris=wgetch(pop_up); if (ris == 'y') { init_scr(); shutdown_thread(); endwin(); exit(0); } else if (ris == 'n'); } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); return(0); break; } break; } wrefresh(my_menu_win); } /* Unpost and free all the memory taken up */ unpost_menu(my_menu); free_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); werase(my_menu_win); wrefresh(my_menu_win); return (0); } void *n_sniff(void *threadid) { init_scr(); line_s = row_s = 0; run_sniffer (promisc, ascii, hex, f, l, tl, tr, n_filter, dev, ldfile); pthread_exit(NULL); } void *conn_db(void *threadarg) { char device[30]; u_long ip_src; u_long ip_dst; u_short sport; u_short dport; struct thread_conn *th_conn; th_conn = (struct thread_conn *) threadarg; ip_src = th_conn->ip_src; ip_dst = th_conn->ip_dst; sport = th_conn->sport; dport = th_conn->dport; strcpy(device,th_conn->device); connection(device,ip_src,ip_dst,sport,dport); pthread_exit(NULL); } void *conn_db_r(void *threadarg) { char device[30]; u_long ip_src; u_long ip_dst; u_short sport; u_short dport; struct thread_conn_rst *th_conn; th_conn = (struct thread_conn_rst *) threadarg; ip_src = th_conn->ip_src; ip_dst = th_conn->ip_dst; sport = th_conn->sport; dport = th_conn->dport; strcpy(device,th_conn->device); rst_connection_db(device,ip_src,ip_dst,sport,dport); pthread_exit(NULL); } void *t_arp(void *threadarg) { char device[30]; int lg; struct thread_arp *arp; arp=(struct thread_arp *) threadarg; lg = arp->lr; strcpy(device,arp->device); car(device,lg); pthread_exit(NULL); }; int s_select() { int i, l, c, x; char currfil[200]; i = x = 0; l=1; while((c = getch()) != 'q') { switch(c) { case KEY_DOWN: memset(&currfil, 0, sizeof(currfil)); if(l>=(nmax-1)) break; else { wmove(winfo->win, l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); } if(l>4) { winscroll(winfo,+1); SAFE_SCROLL_REFRESH(winfo); } if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, A_NORMAL); ++l; ++i; } redrawscrollwin(winfo, 0); strcpy(currfil,sf[i].sfilter); ++l; ++i; break; case KEY_UP: memset(&currfil, 0, sizeof(currfil)); if (l<=2) break; winscroll(winfo,-1); SAFE_SCROLL_REFRESH(winfo); --l; --i; if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); ++l; ++i; wmove(winfo->win, l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, A_NORMAL); redrawscrollwin(winfo, 0); } break; case 10: if(currfil==0) break; if(x) { pthread_cancel(thID[5]); pthread_join(thID[5],NULL); } x=1; streamg (dev,currfil); break; } } return 0; } int r_select() { int i, n, c, l; char currfil[200]; u_long seq; u_long ack; u_long s_ip; u_long d_ip; u_short s_port,d_port; seq = ack = s_ip = d_ip = s_port = d_port = i = n = 0; l = 1; while((c = getch()) != 'q') { switch(c) { case KEY_DOWN: memset(&currfil, 0, sizeof(currfil)); ack=0; seq=0; if(l>=(nmax-1)) break; else { wmove(winfo->win, l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; } if(l>4) { winscroll(winfo,+1); SAFE_SCROLL_REFRESH(winfo); } if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, A_NORMAL); ++l; ++i; } redrawscrollwin(winfo, 0); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; ++l; ++i; break; case KEY_UP: memset(&currfil, 0, sizeof(currfil)); seq=0; ack=0; if (l<=2) break; winscroll(winfo,-1); SAFE_SCROLL_REFRESH(winfo); --l; --i; if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; ++l; ++i; wmove(winfo->win, l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, A_NORMAL); redrawscrollwin(winfo, 0); } break; case 10: if(currfil==0) break; for(n=0;n<3;n++) reset_conn(dev,s_ip,d_ip,s_port,d_port,seq,ack); break; } } return 0; } #endif nast-0.2.0/ncurses/n_nast.c0100644000175000001440000004177710012736044015010 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "n_nast.h" #ifdef HAVE_LIBNCURSES void init_curs(void); void title(void); int get_info(void); int main_graph(void) { int row,col; char errbuf[PCAP_ERRBUF_SIZE]; char currfil[200]; char devapp[10]; int key, c, out; int ris; int l,i,n,ok,x; u_long seq; u_long ack; u_long s_ip; u_long d_ip; u_short s_port,d_port; int res; pcap_if_t *devices; pcap_if_t *devc; key = c = 0xff;/*unuse value*/ strcpy(n_filter,"NULL"); strcpy(ldfile,"NULL"); strcpy(devapp,"NULL"); ris = out = f = hex = ascii = ld = tl = tr = lr = mvar = linm = n = ok = x = 0; promisc = 1; seq = ack = s_ip = d_ip = s_port = d_port = 0; l = 3; stream_glob = bc_glob = sniff_glob = rst_glob = 0; flg = 0; init_curs(); getmaxyx(stdscr,row,col); if(row<24 || col<78) { endwin(); printf("\nSorry,you must have a screen of at least 85 colons and 31 rows\n\n"); exit(1); } if (princ == NULL) { princ = newscrollwin(LINES-13, COLS, 6, 0, " Main Window (F2)", 10000); SAFE_SCROLL_REFRESH(princ); } if (winfo == NULL) { winfo = newscrollwin(7, COLS, LINES-7, 0, " Info Window (F3)", 300); SAFE_SCROLL_REFRESH(winfo); } winscroll(princ, -10000); // rewind the scrollbar winscroll(winfo,-300); // rewind the scrollbar redrawscrollwin(princ, 0); redrawscrollwin(winfo, 0); refresh(); title(); nmenu(); redrawscrollwin(princ, 0); redrawscrollwin(winfo, 0); /*finding a suitable device */ res = pcap_findalldevs(&devices, errbuf); if (res < 1 && 0) { fprintf(stderr, "pcap_findalldevs error: %s\n", errbuf); return -1; } /* try to find the device */ for (devc = devices; devc; devc = devc->next) { if (!strcmp(devc->name,"any")) continue; if (devc->flags & PCAP_IF_LOOPBACK) { strcpy(dev,devc->name); continue; } else { strcpy(dev,devc->name); break; } } pcap_freealldevs(devices); while(!ok) { pop_up_win(); mvwprintw(pop_up,2,2,"Welcome to Nast, the Network Analyzer Sniffer Tool!"); mvwprintw(pop_up,4,6," Distribuited under GPL license by"); mvwprintw(pop_up,5,6," Embyte & Snifth (C) 2003-2004"); mvwprintw(pop_up,8,6,"Insert the device you want to use, please:"); mvwprintw(pop_up,9,6," for the default <%s> press enter!",dev); wmove(pop_up,9,23); echo(); mvwgetnstr(pop_up,11,25,devapp,10); if(!strcmp(devapp,"")) ; else strcpy(dev,devapp); noecho(); if ((pcap_lookupnet(dev,&netp,&maskp,errbuf))==-1) { w_error(0, " Impossible to use device: %s",dev); } else ok = 1; } delwin(pop_up); redrawscrollwin(princ,0); nmenu(); do { redrawscrollwin(princ, 0); redrawscrollwin(winfo, 0); title(); key=getch(); switch(key) { case KEY_F(1): flg=1; nmenu(); while( (out!=1) && ((c = wgetch(my_nmenu_win)) != 'q') ) { switch(c) { case KEY_LEFT: menu_driver(my_nmenu, REQ_PREV_ITEM); break; case KEY_RIGHT: menu_driver(my_nmenu, REQ_NEXT_ITEM); break; case 10: curr_item = current_item(my_nmenu); switch(item_index(curr_item)) { case 0: sniffer: box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ, 0); ris = sniffer_menu(); if (ris == -1) { menu_driver(my_nmenu, REQ_RIGHT_ITEM); goto analyzer; } if (ris == -2) { menu_driver(my_nmenu, REQ_LAST_ITEM); goto options; } if(ris == 0) { (out=1); menu_driver(my_nmenu, REQ_FIRST_ITEM); } break; case 1: analyzer: box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ, 0); ris = analyzer_menu(); if (ris == -1) { menu_driver(my_nmenu, REQ_RIGHT_ITEM); goto options; } if (ris == -2) { menu_driver(my_nmenu, REQ_LEFT_ITEM); goto sniffer; } if(ris == 0) { (out=1); menu_driver(my_nmenu, REQ_FIRST_ITEM); } break; case 2: options: box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); redrawscrollwin(princ, 0); ris = options_menu(); if (ris == -1) { menu_driver(my_nmenu, REQ_LEFT_ITEM); goto analyzer; } if (ris == -2) { menu_driver(my_nmenu, REQ_FIRST_ITEM); goto sniffer; } if(ris == 0) { (out=1); menu_driver(my_nmenu, REQ_FIRST_ITEM); } break; } box(my_nmenu_win, 0, 0); wrefresh(my_nmenu_win); pos_menu_cursor(my_nmenu); redrawscrollwin(princ, 0); flg=0; nmenu(); break; } } flg=0; redrawscrollwin(princ,0); nmenu(); out=0; break; case KEY_F(2): while((c = getch()) != 'q') { switch(c) { case KEY_UP: winscroll(princ, -1); // rewind the scrollbar break; case KEY_DOWN: winscroll(princ, +1); // rewind the scrollbar break; case KEY_NPAGE: winscroll(princ, +10); // rewind the scrollbar break; case KEY_PPAGE: winscroll(princ, -10); // rewind the scrollbar break; } redrawscrollwin(princ, 0); } break; case KEY_F(3): while((c = getch()) != 'q') { switch(c) { case KEY_UP: winscroll(winfo, -1); // rewind the scrollbar break; case KEY_DOWN: winscroll(winfo, +1); // rewind the scrollbar break; case KEY_NPAGE: winscroll(winfo, +5); // rewind the scrollbar break; case KEY_PPAGE: winscroll(winfo, -5); // rewind the scrollbar break; } redrawscrollwin(winfo, 0); } break; case 'S': flg=1; nmenu(); menu_driver(my_nmenu, REQ_FIRST_ITEM); goto sniffer; break; case 'A': flg=1; nmenu(); menu_driver(my_nmenu, REQ_NEXT_ITEM); goto analyzer; break; case 'O': flg=1; nmenu(); menu_driver(my_nmenu, REQ_LAST_ITEM); goto options; break; case 'i': get_info(); break; case 'd': werase(winfo->win); redrawscrollwin(winfo,0); break; case 'x': werase(princ->win); redrawscrollwin(princ,0); break; case 'h': help_win(); mvwprintw(help,2,2,"[F1] -> Menu Selection"); mvwprintw(help,3,2,"[F2] -> Main window interactions"); mvwprintw(help,4,2,"[F3] -> Info window interactions"); mvwprintw(help,5,2,"[UP] -> Scrolling UP windows (1 line)"); mvwprintw(help,6,2,"[DOWN] -> Scrolling DOWN windows (1 line)"); mvwprintw(help,7,2,"[PgUP] -> Scrolling UP windows (5 lines)"); mvwprintw(help,8,2,"[PgDOWN] -> Scrolling DOWN windows (5 lines)"); mvwprintw(help,9,2,"[Shift + s] -> Sniffer Menu"); mvwprintw(help,10,2,"[Shift + a] -> Analyzer Menu"); mvwprintw(help,11,2,"[Shift + o] -> Options Menu"); mvwprintw(help,12,2,"[i] -> Show informations about options"); mvwprintw(help,13,2,"[x] -> Erase Main Window"); mvwprintw(help,14,2,"[d] -> Erase Info window"); mvwprintw(help,15,2,"[h] -> This help"); mvwprintw(help,16,2,"[q] -> Exit all windows"); mvwprintw(help,17,2,"When you use the sniffer pay attention that the"); mvwprintw(help,18,2,"options will be selected BEFORE sniffer starting!"); mvwprintw(help,20,2,"[Shift + q] -> Exit NAST"); do { ris=wgetch(help); } while( ris != 'q'); wrefresh(help); werase(help); nmenu(); redrawscrollwin(princ,0); redrawscrollwin(winfo,0); break; case 'Q': pop_up_win(); mvwprintw(pop_up,7,10,"Are you sure you want to exit (y/n)?"); wmove(pop_up,4,2); do { ris=wgetch(pop_up); if (ris == 'y') { shutdown_thread(); endwin(); printf("Thank you for using Nast\n\n"); exit(0); } else if (ris == 'n'); } while( ris != 'y' && ris != 'n'); delwin(pop_up); redrawscrollwin(princ,0); break; case 's': if(!stream_glob) break; i = 0; l = 1; while((c = getch()) != 'q') { switch(c) { case KEY_DOWN: memset(&currfil, 0, sizeof(currfil)); if(l>=(nmax-1)) break; else { wmove(winfo->win, l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); } if(l>4) { winscroll(winfo,+1); SAFE_SCROLL_REFRESH(winfo); } if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, A_NORMAL); ++l; ++i; } redrawscrollwin(winfo, 0); strcpy(currfil,sf[i].sfilter); ++l; ++i; break; case KEY_UP: memset(&currfil, 0, sizeof(currfil)); if (l<=2) break; winscroll(winfo,-1); SAFE_SCROLL_REFRESH(winfo); --l; --i; if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); ++l; ++i; wmove(winfo->win, l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, A_NORMAL); redrawscrollwin(winfo, 0); } break; case 10: if(currfil==0) break; if (x) { pthread_cancel(thID[5]); pthread_join(thID[5],NULL); } x=1; streamg (dev,currfil); break; } } break; case 'r': if(!rst_glob) break; i = 0; l = 1; while((c = getch()) != 'q') { switch(c) { case KEY_DOWN: memset(&currfil, 0, sizeof(currfil)); ack=0; seq=0; if(l>=(nmax-1)) break; else { wmove(winfo->win, l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; } if(l>4) { winscroll(winfo,+1); SAFE_SCROLL_REFRESH(winfo); } if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, A_NORMAL); ++l; ++i; } redrawscrollwin(winfo, 0); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; ++l; ++i; break; case KEY_UP: memset(&currfil, 0, sizeof(currfil)); seq=0; ack=0; if (l<=2) break; winscroll(winfo,-1); SAFE_SCROLL_REFRESH(winfo); --l; --i; if(l==1) ; else { wmove(winfo->win, --l, 2); wattron(winfo->win, COLOR_PAIR(4)); waddstr(winfo->win, sf[--i].string); wattroff(winfo->win, COLOR_PAIR(4)); strcpy(currfil,sf[i].sfilter); seq=sf[i].seq; ack=sf[i].ack; s_ip=sf[i].ip_src; d_ip=sf[i].ip_dst; s_port=sf[i].s_port; d_port=sf[i].d_port; ++l; ++i; wmove(winfo->win, l, 2); wattron(winfo->win, A_NORMAL); waddstr(winfo->win, sf[i].string); wattroff(winfo->win, A_NORMAL); redrawscrollwin(winfo, 0); } break; case 10: if(currfil==0) break; for(n=0;n<3;n++) reset_conn(dev,s_ip,d_ip,s_port,d_port,seq,ack); break; } } break; } } while (key!='X'); init_scr(); shutdown_thread(); endwin(); printf("Thanx you for using NAST\n\n"); exit(0); } void init_curs(void) { /* Initialize curses */ initscr(); start_color(); cbreak(); noecho(); keypad(stdscr, TRUE); curs_set(0); init_pair(1, COLOR_BLACK, COLOR_GREEN); init_pair(2, COLOR_CYAN, COLOR_BLACK); init_pair(3, COLOR_GREEN, COLOR_BLACK); init_pair(4, COLOR_WHITE, COLOR_BLUE); init_pair(5, COLOR_WHITE, COLOR_BLACK); } void title(void) { char TITLE[]= { "NAST - NETWORK ANALYZER SNIFFER TOOL -" }; WINDOW *title; title = subwin(stdscr,3,COLS,0,0); wbkgd(title,COLOR_PAIR(1)); box(title,0,0); mvwprintw(title,1,(COLS-sizeof(TITLE))/2, TITLE); wrefresh(title); } int get_info() { char *mask; char errbuf[PCAP_ERRBUF_SIZE]; libnet_t *L; struct libnet_ether_addr *e; struct in_addr addr; werase(winfo->win); /* ask pcap for the network address and mask of the device */ if ((pcap_lookupnet(dev,&netp,&maskp,errbuf))==-1) { if(w_error(0, "pcap_lookupnet error: %s", errbuf)==-1) return(0); } if ((descr = pcap_open_live (dev, BUFSIZ, promisc, 10, errbuf))==NULL) { w_error(1, "pcap_open_live() error: %s",errbuf); } if ((offset=(device(dev,descr)))==-1) return -1; L = libnet_init (LIBNET_LINK, dev, errbuf); e = libnet_get_hwaddr(L); if (!e) { w_error(1, "Can't get hardware address: %s", libnet_geterror(L)); } addr.s_addr = maskp; if ((mask = inet_ntoa(addr))==NULL) { w_error(1, "Impossible get the mask"); } mvwprintw(winfo->win,1,2,"IP: "); wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,1,13,"%s", libnet_addr2name4(libnet_get_ipaddr4(L), 0)); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,1,30,"MAC: "); wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,1,39,"%s", nast_hex_ntoa (e->ether_addr_octet)); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,2,2,"Netmask: "); wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,2,13,"%s",mask); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,2,30,"Promisc: "); wattron(winfo->win,A_BOLD); if (promisc) mvwprintw(winfo->win,2,39,"Enable"); else mvwprintw(winfo->win,2,39,"Disable"); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,1,60,"Iface: "); wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,1,67,"%s",dev); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,2,60,"ASCII: "); wattron(winfo->win,A_BOLD); if (ascii) mvwprintw(winfo->win,2,67,"Enable"); else mvwprintw(winfo->win,2,67,"Disable"); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,3,2,"ASCII-HEX: "); wattron(winfo->win,A_BOLD); if (hex) mvwprintw(winfo->win,3,13,"Enable"); else mvwprintw(winfo->win,3,13,"Disable"); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,3,30,"Filter: "); wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,3,39,"%s",n_filter); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,3,60,"Log Data: "); if(ld) { wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,3,70,"Enable"); wattroff(winfo->win,A_BOLD); mvwprintw(winfo->win,3,76,", Datafile: %s", ldfile); } else { wattron(winfo->win,A_BOLD); mvwprintw(winfo->win,3,70,"Disable"); wattroff(winfo->win,A_BOLD); } wrefresh(winfo->win); libnet_destroy(L); return(0); } void pop_up_win(void) { char message[23]; sprintf(message," Input Window "); pop_up = newwin(17,55,(LINES-17)/2,(COLS-55)/2); wbkgd(pop_up,COLOR_PAIR(4)); box(pop_up,0,0); mvwprintw(pop_up,0,(55 -strlen(message))/2, message); wrefresh(pop_up); } void help_win(void) { char message[23]; sprintf(message," Help "); help = newwin(23,67,(LINES-23)/2,(COLS-67)/2); wbkgd(help,COLOR_PAIR(4)); box(help,0,0); mvwprintw(help,0,(67 -strlen(message))/2, message); wrefresh(help); } #endif nast-0.2.0/ncurses/n_nast.h0100644000175000001440000001023610003274724015001 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../include/nast.h" #ifdef HAVE_LIBNCURSES /*don't compile if we haven't ncurses*/ # include # define SAFE_WREFRESH(x) do { wrefresh(x); } while(0) # define SAFE_WIN_REFRESH(x) do { wrefresh(x->win); } while(0) # define SAFE_FREE(x) do{ if(x) { free(x); x = NULL; } }while(0) # define SAFE_SCROLL_REFRESH(sx) do { \ pnoutrefresh(sx->win, sx->y_scroll, 0, sx->y + 1, sx->x + 1, sx->y + sx->lines - 2, sx->cols - 1 ); \ wnoutrefresh(sx->out); \ doupdate(); \ } while(0) # define POLL_WGETCH(x, y) do { \ struct pollfd poll_fd = { \ .fd = 0, \ .events = POLLIN, \ }; \ poll(&poll_fd, 1, 1); \ if (poll_fd.revents & POLLIN) \ x = wgetch(y); \ else \ usleep(1000); \ } while(0) struct scrolling_window { WINDOW *win; WINDOW *out; int y_scroll; int y_max; int lines; int cols; int x; int y; char *title; }; typedef struct scrolling_window N_SCROLLWIN; N_SCROLLWIN *newscrollwin(int lines, int cols, int y, int x, char *title, int maxlines); void redrawscrollwin(N_SCROLLWIN *win, int focus); void drawscroller(N_SCROLLWIN *win); void winscroll(N_SCROLLWIN *win, int delta); void delscrollwin(N_SCROLLWIN **win); void nmenu(void); int sniffer_menu(void); int analyzer_menu(void); int options_menu(void); void pop_up_win(void); void *conn_db(void *threadarg); void *conn_db_r(void *threadarg); int connection(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport); int rst_connection_db(char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport); int reset_conn(char *dev,u_long s_ip, u_long d_ip, u_short s_port, u_short d_port,u_long seq, u_long ack); int streamg (char *dev,char *sfilter); void data_sniffo_stream (char *data_info, u_int len); void init_scr(void); int reset(char *dev, char *sfilter); int check_pthread(void); int shutdown_thread(void); void help_win(void); WINDOW *query; WINDOW *werror; WINDOW *help; N_SCROLLWIN *princ; N_SCROLLWIN *winfo; N_SCROLLWIN *wstream; N_SCROLLWIN *wconn; MENU *my_nmenu; ITEM *curr_item; WINDOW *my_nmenu_win; WINDOW *pop_up; u_short mvar; u_short promisc,hex,ascii,ld,f,lr,l; u_short flg; int linm; int fileds; char dev[10]; char n_filter[60]; char ldfile[50]; char tcpdfile[50]; char reportl[50]; char logfile[50]; /*descriptor for stream*/ pcap_t* str; pcap_dumper_t *dumper; /* thread for database connections */ pthread_t thID[6]; struct thread_conn { char device[30]; u_long ip_src; u_long ip_dst; u_short sport; u_short dport; int thread_id; }; struct thread_arp { char device[30]; int lr; }; struct thread_conn_rst { char device[30]; u_long ip_src; u_long ip_dst; u_short sport; u_short dport; int thread_id; }; struct thread_conn th_data[1]; struct thread_conn_rst th_r_data[1]; struct thread_arp th_arp_data[1]; struct connections { unsigned long s_ip; unsigned long d_ip; unsigned short s_port; unsigned short d_port; u_long seq; u_long ack; int lin; int pr; int set; } c_inf[30]; /* connection struct */ struct cnn { char string[200]; /*filter for tcp stream*/ char sfilter[200]; u_long seq; u_long ack; u_long ip_src; u_long ip_dst; u_short s_port; u_short d_port; int cont; } sf[30]; /* num max of db connections */ int nmax; #endif nast-0.2.0/getopt.c0100644000175000001440000007331610003274641013340 0ustar embyteusers/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO # define _NO_PROTO #endif #ifdef HAVE_CONFIG_H # include #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 # include # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ # include # include #endif /* GNU C library. */ #ifdef VMS # include # if HAVE_STRING_H - 0 # include # endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. */ # if defined HAVE_LIBINTL_H || defined _LIBC # include # ifndef _ # define _(msgid) gettext (msgid) # endif # else # define _(msgid) (msgid) # endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "missing/getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ # include # define my_index strchr #else # if HAVE_STRING_H # include # else # include # endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv extern char *getenv (); #endif static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ # if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); # endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } # ifdef text_set_element text_set_element (__libc_subinit, store_args_and_env); # endif /* text_set_element */ # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int print_errors = opterr; if (optstring[0] == ':') print_errors = 0; if (argc < 1) return -1; optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (print_errors) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (print_errors) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (int, char *const *, const char *); int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ nast-0.2.0/Makefile.in0100644000175000001440000000324310006030103013711 0ustar embyteusers# # $Id: Makefile.in,v 1.2 2004/01/28 21:57:23 mastershadow Exp $ # CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ mandir = @mandir@ datadir = @datadir@ srcdir = @srcdir@ shtool = @SHTOOL@ OBJS = main.o dev.o tcp.o icmp.o arp.o udp.o prom.o\ eth.o map.o sniff.o data.o rst.o fgw.o flink.o \ port.o common.o stream.o igmp.o bcount.o error.o\ ncurses/n_menu.o ncurses/n_scroll_win.o ncurses/n_comm.o \ ncurses/n_stream.o ncurses/n_conn.o ncurses/n_rst.o @NCURSES@ @GETOPT@\ all: nast world: nast install nast: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o nast $(OBJS) $(LIBS) @echo @echo "Done! Type make install from root" @echo .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ install: chown root nast nast.8 cp -fR nast @bindir@ cp -fR nast.8 @mandir@/man8/ @echo @echo "Run with nast (-h for help), enjoy!" @echo "Use -G flag to run in ncurses interface" @echo clean: rm -f *~ ncurses/*~ *.bak *.o ncurses/*.o *.log nast config.status stamp-h* rm -rf *.cache distclean: clean rm -f config.h Makefile version: @echo @cat VERSION @echo love: @echo "Not right now,i have a headcache..." help: @echo @echo "Accepted commands for Makefile:" @echo "make compile sources" @echo "make install install binary and manpage" @echo "make world compile and install" @echo "make clean clean trash files from current directory)" @echo "make distclean uninstall" @echo "make version show version" @echo "make love surprise" @echo "make help print this help" @echo nast-0.2.0/icmp.c0100644000175000001440000001447110003274643012765 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" void handle_ICMP (u_short d, u_short x, FILE *output, FILE *ldd) { struct libnet_ipv4_hdr *ip; struct libnet_icmpv4_hdr *icmp; u_short size_ip, size_icmp, size_buf; size_ip = LIBNET_IPV4_H; size_icmp = LIBNET_ICMPV4_H; /* base ICMP header lenght */ size_buf = 0; ip = (struct libnet_ipv4_hdr *) (packet+offset); icmp = (struct libnet_icmpv4_hdr *) (packet+size_ip+offset); n_print("princ",line_s,row_s,lg,"\n---[ ICMP ]----------------------------------------------------------\n"); n_print("princ",line_s=line_s+2,row_s,lg,"%s", inet_ntoa(ip->ip_src)); n_print("princ",line_s,16,lg," -> "); n_print("princ",line_s,24,lg,"%s\n", inet_ntoa(ip->ip_dst)); n_print("princ",++line_s,row_s,lg,"Version: %d\t", ip->ip_v); n_print("princ",line_s,20,lg,"Lenght: %d\t", ntohs(ip->ip_len)); n_print("princ",line_s,35,lg,"TTL: %d\n", ip->ip_ttl); n_print("princ",++line_s,row_s,lg,"Type: "); row_s = 8; switch((icmp->icmp_type)) { case 0: n_print("princ",line_s,row_s,lg,"Echo reply\n"); size_icmp+=4; break; case 3: n_print("princ",line_s,row_s,lg,"Dest_unreach: "); size_icmp+=4; switch (icmp->icmp_code) { case 0: n_print("princ",line_s,28,lg,"Network Unreachable\n"); break; case 1: n_print("princ",line_s,28,lg,"Host Unreachable\n"); break; case 2: n_print("princ",line_s,28,lg,"Protocol Unreachable\n"); break; case 3: n_print("princ",line_s,28,lg,"Port Unreachable\n"); break; case 4: n_print("princ",line_s,28,lg,"Fragmentation neded (DF)\n"); break; case 5: n_print("princ",line_s,28,lg,"Source route failed\n"); break; case 6: n_print("princ",line_s,28,lg,"Destination network unknown\n"); break; case 7: n_print("princ",line_s,28,lg,"Destination host unknown\n"); break; case 8: n_print("princ",line_s,28,lg,"Source host isolated\n"); break; case 9: n_print("princ",line_s,28,lg,"Destination network administratively prohibited\n"); break; case 10: n_print("princ",line_s,28,lg,"Destination host administratively prohibited\n"); break; case 11: n_print("princ",line_s,28,lg,"Network unreacjable(tOS)\n"); break; case 12: n_print("princ",line_s,28,lg,"Host Unreachable (tOS)\n"); break; case 13: n_print("princ",line_s,28,lg,"Communication administratively prohibited\n"); break; case 14: n_print("princ",line_s,28,lg,"Host precedence violation\n"); break; case 15: n_print("princ",line_s,28,lg,"Precedence cutoff in effect\n"); break; default: n_print("princ",line_s,28,lg,"Unknown - error?\n"); break; } break; case 4: n_print("princ",line_s,row_s,lg,"Source quench\n"); size_icmp+=4; break; case 5: n_print("princ",line_s,row_s,lg,"Redirect: "); size_icmp+=4; switch(icmp->icmp_code) { case 0: n_print("princ",line_s,28,lg,"Redirect for network\n"); break; case 1: n_print("princ",line_s,28,lg, "Redirect for host\n"); break; case 2: n_print("princ",line_s,28,lg,"Redircet for tos & network\n"); break; case 3: n_print("princ",line_s,28,lg,"Redirect for tos & host\n"); break; default: n_print("princ",line_s,28,lg,"Unknown - error?\n"); break; } break; case 8: n_print("princ",line_s,row_s,lg,"Echo request\n"); size_icmp+=4; break; case 11: n_print("princ",line_s,row_s,lg,"Time exceeded: "); size_icmp+=4; switch (icmp->icmp_code) { case 0: n_print("princ",line_s,28,lg,"TTL (0) during transit\n"); break; case 1: n_print("princ",line_s,28,lg,"TTL (0) during reassembly\n"); break; default: n_print("princ",line_s,28,lg,"Unknown - error?\n"); break; } break; case 12: n_print("princ",line_s,row_s,lg,"Parameter problem: "); switch (icmp->icmp_code) { case 0: n_print("princ",line_s,28,lg,"IP header bad\n"); break; case 1: n_print("princ",line_s,28,lg,"Requiring option missing\n"); break; } break; case 13: n_print("princ",line_s,row_s,lg,"Timestamp\n"); size_icmp+=16; break; case 14: n_print("princ",line_s,row_s,lg,"Timestamp reply\n"); size_icmp+=16; break; case 15: n_print("princ",line_s,row_s,lg,"Information\n"); break; case 16: n_print("princ",line_s,row_s,lg,"Information reply\n"); break; case 17: n_print("princ",line_s,row_s,lg,"Address mask\n"); size_icmp+=8; break; case 18: n_print("princ",line_s,row_s,lg,"Address mask reply\n"); size_icmp+=8; break; default: n_print("princ",line_s,row_s,lg, "%i\n", icmp->icmp_type); break; } n_print("princ",++line_s,0,lg,"Packet Number: %d",npkt); if(!graph) printf("\n"); size_buf = ntohs(ip->ip_len) - size_ip - size_icmp; row_s=0; ++line_s; if (size_buf) { buf = (char *) (packet + size_ip + size_icmp + offset); if (d) { n_print("princ",line_s,row_s,lg,"\n---[ ICMP Data ]-----------------------------------------------------\n"); data_sniffo (buf, size_buf, output); line_s+=2; } if (x) { n_print("princ",line_s,row_s,lg,"\n---[ ICMP Hex-Ascii Data ]-------------------------------------------"); print_ascii_hex (buf, size_buf, output); line_s+=2; } /* log data (payload only) */ if (ldd) { fprintf(ldd, "%s -> %s ICMP\n", inet_ntoa(ip->ip_src), inet_ntoa(ip->ip_dst)); data_sniffo (buf, size_buf, ldd); fprintf(ldd, "\n"); } } row_s = 0; } nast-0.2.0/igmp.c0100644000175000001440000000414410003274644012766 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" void handle_IGMP (FILE *output) { struct libnet_ipv4_hdr *ip; struct libnet_igmp_hdr *igmp; ip = (struct libnet_ipv4_hdr *) (packet + offset); igmp = (struct libnet_igmp_hdr *) (packet + LIBNET_IPV4_H + offset); n_print("princ",line_s,row_s,lg,"\n---[ IGMP ]----------------------------------------------------------\n"); n_print("princ",line_s=line_s+2,row_s,lg,"%s -> %s\n", inet_ntoa(ip->ip_src), inet_ntoa(ip->ip_dst)); n_print("princ",++line_s,row_s,lg,"IP Version: %d\t Lenght: %d\t", ip->ip_v, ntohs(ip->ip_len)); n_print("princ",line_s,30,lg,"TTL: %d\t Code: %d\n", ip->ip_ttl, igmp->igmp_code); n_print("princ",++line_s,row_s,lg,"Type: "); switch(igmp->igmp_type) { case 0x11: n_print("princ",line_s,10,lg,"Membreship Query v1 [get address %s]\n", inet_ntoa(igmp->igmp_group)); break; case 0x12: n_print("princ",line_s,10,lg,"Membership Report v1 %s\n", inet_ntoa(igmp->igmp_group)); break; case 0x16: n_print("princ",line_s,10,lg,"Membership Report v2 %s\n", inet_ntoa(igmp->igmp_group)); break; case 0x17: n_print("princ",line_s,10,lg,"Leave %s (v2)\n", inet_ntoa(igmp->igmp_group)); break; default: n_print("princ",line_s,10,lg,"%d\n", igmp->igmp_type); break; } n_print("princ",++line_s,0,lg,"Packet Number: %d",npkt); if(!graph) printf("\n"); row_s=0; ++line_s; } nast-0.2.0/getopt1.c0100644000175000001440000001071610003274645013420 0ustar embyteusers/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "missing/getopt.h" #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ nast-0.2.0/VERSION0100644000175000001440000000040310003274645012731 0ustar embyteusers============================================================================ Nast (Network Analyzer Sniffer Tool) VERSION ============================================================================ 0.2.0 nast-0.2.0/main.c0100644000175000001440000002553010013746653012765 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" #include #ifdef HAVE_GETOPT # include #else # include "missing/getopt.h" #endif void usage(char *name); int main(int argc,char **argv) { char *dev, *app; char *filter, *buffer, ldname[50]; char errbuf[PCAP_ERRBUF_SIZE]; extern char *optarg; int option, option_index; u_long anip; libnet_t *L; struct utsname buf; static u_short ports[] = { 21, 22, 23, 25, 43, 53, 79, 80, 110, 119, 143, 220, 513, 514 }; struct FLAGSTRUCT { u_short promisc; u_short l; u_short data; u_short hex; u_short f; u_short ps; u_short gw; u_short rt; u_short lk; u_short pr; u_short st; u_short mp; u_short banner; u_short maplan; u_short c_arp; u_short ld; u_short bytecount; u_short ncurses; u_short tcpdlog; u_short tcpdread; } flags; static struct option long_options[] = { { "help", 0, NULL, 'H'}, { "promisc", 0, NULL, 'p'}, { "ascii-data", 0, NULL, 'd'}, { "filter", 1, NULL, 'f'}, { "interface", 1, NULL, 'i'}, { "ascii-hex-data", 0, NULL, 'x'}, { "log-file", 1, NULL, 'l'}, { "check-sniffers", 1, NULL, 'P'}, { "host-list", 0, NULL, 'm'}, { "tcp-stream", 0, NULL, 's'}, { "find-gateway", 0, NULL, 'g'}, { "reset-connection", 0, NULL, 'r'}, { "port-scanner", 0, NULL, 'S'}, { "multi-port-scanner", 0, NULL, 'M'}, { "find-link", 0, NULL, 'L'}, { "daemon-banner", 0, NULL, 'b'}, { "check-arp-poisoning", 0, NULL, 'c'}, { "ncurses", 0, NULL, 'G'}, { "daemon", 0, NULL, 'B'}, { "version", 0, NULL, 'V'}, { "ld", 1, NULL, '\0'}, { "byte-counting", 1, NULL, 'C'}, { "tcpdump-log", 1, NULL, 'T'}, { "tcpdump-log-read", 1, NULL , 'R'}, { 0, 0, 0, 0} }; printf ("\n%sNast V. %s%s\n\n", BOLD, PACKAGE_VERSION, NORMAL); /* check permissions */ if (getuid() || getgid()) { fprintf(stderr, "You must be root, Sorry\n\n"); return -1; } /* finding a suitable device */ dev = pcap_lookupdev(errbuf); if (dev==NULL) { fprintf (stderr, "Error: can't find a suitable interface to use: %s\n", errbuf); return -1; } /* res = pcap_findalldevs(&devices, errbuf); if (res < 1 && 0) { fprintf(stderr, "pcap_findalldevs error: %s\n", errbuf); return -1; } try to find the device for (devc = devices; devc; devc = devc->next) { if (!strcmp(devc->name,"any")) continue; if (devc->flags & PCAP_IF_LOOPBACK) { strcpy(dev,devc->name); continue; } else { strcpy(dev,devc->name); break; } } pcap_freealldevs(devices); */ if ((L = libnet_init (LIBNET_LINK, dev, errbuf))==NULL) { fprintf(stderr, "Error: can't initialize libnet engine: %s", errbuf); fprintf(stderr, "Have you activate a non-loopback iface? (man ifconfig)\n"); exit(-1); } line_s = row_s = cont = lg = 0; option_index = 0; anip = 0; sniff_glob = 0; memset (&flags, 0, sizeof (struct FLAGSTRUCT)); flags.promisc = 1; /*default is promisc */ logname = filter = buffer = tcpdl = NULL; strcpy(ldname,"NULL"); /* get global time */ tm = time(NULL); strftime(timed,60,"%T",localtime(&tm)); while ((option=getopt_long(argc, argv, "mi:hHpdxl:f:C:P:R:T:sgrSLbMcGBV0", long_options, &option_index)) !=EOF) switch(option) { case 'h': case 'H': usage(argv[0]); break; case 'i': (app=optarg); strcpy(dev,app); break; case 'l': /* log to file */ flags.l=1; lg = 1; (logname = optarg); break; case 'p': flags.promisc=0; break; case 'd': flags.data=1; break; case 'x': flags.hex=1; break; case 'f': flags.f=1; (filter = optarg); break; case 'P': flags.ps=1; if (dev!=NULL) /* we have other interface that is not lo */ if (strcmp (optarg, "all")) /* != all */ { anip = libnet_name2addr4(L, optarg, LIBNET_RESOLVE); if (anip==-1) { libnet_destroy(L); w_error(1, "Error: cannot resolve %s\n\n", optarg); } } /* if optarg=all -> anip = 0 */ break; case 's': flags.st=1; break; case 'g': flags.gw=1; break; case 'r': flags.rt=1; break; case 'S': flags.pr = 1; break; case 'L': flags.lk=1; break; case 'b': flags.banner=1; break; case 'M': flags.mp=1; break; case 'm': flags.maplan=1; break; case 'c': flags.c_arp=1; break; case 'B': demonize=1; break; case 'C': flags.bytecount=1; (filter = optarg); break; case 'T': flags.tcpdlog=1; tl=1; (tcpdl = optarg); break; case 'R': flags.tcpdread=1; tr=1; (tcpdl = optarg); break; case 'G': #ifdef HAVE_LIBNCURSES flags.ncurses=1; graph=1; #else printf ("You have not compiled ncurses interface support!\n"); printf ("You *must* install libncurses and recompile nast\n"); printf ("\nDownload it from official web site: http://www.gnu.org/software/ncurses/ncurses.html\n"); printf ("or install your distribution binary package (remember to install also the -devel package)\n\n"); return -1; #endif break; case 'V': printf ("%s2003-2004 (c) Embyte & Snifth\n", BOLD); if (uname(&buf)!=-1) { printf ("Running on %s %s (%s)\n", buf.sysname, buf.release, buf.machine); } printf ("See http://nast.berlios.de%s\n\n", NORMAL); exit(0); /* only long options */ case '\0': if (!strcmp(long_options[option_index].name,"ld")) strcpy(ldname,optarg); break; default: usage(argv[0]); break; } /* END OF ARGS SWITCH */ if (dev==NULL) { fprintf(stderr, "Cannot find a suitable network interface!\n"); fprintf(stderr, "Check you connection (will ifconfig help you?)\n\n"); libnet_destroy(L); return -1; } /* destroy libnet_t *L */ libnet_destroy(L); /* signal handlers */ signal(SIGKILL, sigexit); signal(SIGQUIT, sigexit); signal(SIGTERM, sigexit); signal(SIGINT, sigexit); /* Do we want a log? */ if (flags.l == 0) logd = stdout; /* RUN PLUGIN ONLY HERE! */ #ifdef HAVE_LIBNCURSES if (flags.ncurses) return main_graph(); #endif if (flags.banner) return mport (dev, ports, flags.l); if (flags.maplan) { if (map_lan(dev, 1, NULL)==NULL) return 0; else return -1; } if (flags.c_arp) return car (dev,flags.l); if (flags.gw) return fgw (dev); if (flags.lk) return flink (dev); if (flags.rt) return runcplx ('r', dev, flags.l); if (flags.st) return runcplx ('s', dev, flags.l); if (flags.mp) return runcplx ('M', dev ,flags.l); if (flags.pr) return runcplx ('S', dev, flags.l); if (flags.ps) return psearch (dev, anip, flags.l); if (flags.bytecount) return run_bc (dev, filter); /* END OF PLUG_INS */ /* SNIFF HERE */ sniff_glob = 1; return run_sniffer (flags.promisc, flags.data, flags.hex, flags.f, flags.l, flags.tcpdlog, flags.tcpdread, filter, dev, ldname); } void usage(char *name) { printf("\n%sUsage:%s nast [options]\n\n", BOLD, NORMAL); printf("%sSniffer options:%s\n", BOLD, NORMAL); printf(" -i, --interface Interface\n"); printf(" if not specified will be autodetected\n"); printf(" -p, --promisc Set promisc mode (set by default)\n"); printf(" -d, --ascii-data Print ascii data\n"); printf(" -x, --ascii-hex-data Print ascii-hex data\n"); printf(" -f, --filter <\"filter\"> Apply filter\n"); printf(" --ld Log sniffed data to (only payload)\n"); printf(" use -l to log all packets too, useful with -B\n"); printf(" -T, --tcpdump-log Log all packets in tcpdump format\n"); printf(" -R, --tcpdump-log-read Read all packets saved in tcpdump format\n"); printf(" from saved file\n"); printf("\n%sAnalyzer options:%s\n", BOLD, NORMAL); printf(" -P, --check-sniffers Check for remote sniffers,\n"); printf(" use -P all to query all network NIC\n"); printf(" -m, --host-list Build hosts list of the LAN\n"); printf(" -s, --tcp-stream Follow TCP Stream\n"); printf(" -g, --find-gateway Try to find a valid gateway\n"); printf(" -r, --reset-connection Reset a connection (use with caution)\n"); printf(" -S, --port-scanner Syn style port scanner\n"); printf(" -M, --multi-port-scanner Port scanner all LAN's host (SYN style)\n"); printf(" -L, --find-link Try to resolve if there's a hub or a switch in LAN\n"); printf(" -b, --daemon-banner Catch daemon banner for the hosts in LAN\n"); printf(" -c, --check-arp-poisoning Verify if someone is making arp-poisoning\n"); printf(" comparing arp responses\n"); printf(" -C, --byte-counting <\"filter\"> Apply traffic counting to \"filter\"\n"); printf(" use -C any to disable filter\n"); printf("\n%sGraphical options:%s\n", BOLD, NORMAL); printf(" -G, --ncurses Ncurses menu:\n"); printf(" this option is available only if you\n"); printf(" have compiled nast with ncurses support,\n"); printf(" this is the default if I found libncurses\n"); printf(" installed in your *unix-box\n"); printf("\n%sOther options:%s\n", BOLD, NORMAL); printf(" -l, --log-file Log reports to file (work with many features)\n"); printf(" -B, --daemon Run in background like demon:\n"); printf(" usefull for sniffer/stream/arp_control logging\n"); printf(" -V, --version Show version information\n"); printf(" -h, --help Print this help\n"); printf("\n"); exit(0); } nast-0.2.0/config.h.in0100644000175000001440000000441010003274650013702 0ustar embyteusers/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* define if the getopt.h header is present, OpenBSD doesn't have one */ #undef HAVE_GETOPT /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `ncurses' library (-lncurses). */ #undef HAVE_LIBNCURSES /* Define to 1 if you have the `net' library (-lnet). */ #undef HAVE_LIBNET /* Define to 1 if you have the `pcap' library (-lpcap). */ #undef HAVE_LIBPCAP /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if your system has a working `malloc' function. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Define to empty if `const' does not conform to ANSI C. */ #undef const nast-0.2.0/nast.80100644000175000001440000005513010013751171012721 0ustar embyteusers.\" Nast manpage .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied .\" warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. .\" .TH NAST "8" "20040216" "NAST 0.2.0" .SH NAME .B NAST 0.2.0 \- Network Analyzer Sniffer Tool .SH SYNOPSIS .B nast [-G] [-i interface] [-l filename] [-f filter] [--ld filename] [-pdxPmsgrSMLbcCBVh] .SH DESCRIPTION Nast is a packet sniffer and a LAN analyzer based on Libnet and Libpcap. .LP It can sniff in normal mode or in promiscuous mode the packets on a network interface and log it. It dumps the headers of packets and the payload in ascii or ascii-hex format. You can apply a filter. The sniffed data can be saved in a separated file. .TP As analyzer tool, it has many features like: .br * Build LAN hosts list .br * Follow a TCP-DATA stream .br * Find LAN Internet gateways .br * Discover promiscuous nodes .br * Reset an established connection .br * Perform a single half-open portscanner .br * Perform a multi half-open portscanner .br * Find link type (hub or switch) .br * Catch daemon banner of LAN nodes .br * Control ARP answers to discover possible ARP-spoofing .br * Byte counting with an optional filter .br * Write reports logging .br .TP It also provides a new ncurses interface. .PP .SH CMDLINE SNIFFER OPTIONS .TP \fB-i, --interface\fR Select the Interface, if not specified will be auto-detected. .br .TP \fB-p, --promisc\fR Disable promiscuous mode on NIC. .br .TP \fB-d, --ascii-data\fR Print data in ascii format. .br .TP \fB-x, --ascii-hex-data\fR Print data in ascii-hex format. .br .TP \fB-f, --filter <"filter">\fR Apply <"filter"> to sniffer (see "FILTER SYNTAX" section below for syntax) .br .TP \fB --ld \fR Log captured data to (only payload). Use -l to log all packet instead, useful with -B .br .TP \fB-T, --tcpdump-log \fR Log all packets in tcpdump format to .br .TP \fB-R, --tcpdump-log-read \fR Read all packets saved in tcpdump format from .br .PP .SH ANALYZER FEATURES .TP \fB-P, --check-promisc \fR Check other NIC on the LAN with the promiscuous flag set. .br By performing a fake ARP broadcast, we can determine if a NIC is in promiscuous mode or not. If the checked host is in promiscuous mode it will responds with an ARP response otherwise it drop the packet. .br Note: This method doesn't work with all OS .br Use \fB-P all\fR to query all network NIC eg: root@localhost:~/$ nast -P 192.168.1.2 NAST "NETWORK ANALYZER SNIFFER TOOL" 192.168.1.2 (localhost.org) Found!! We can check all nodes by using: .br root@localhost:~/$ nast -P all .TP \fB-m, --host-list\fR Map the LAN by performing a series of ARP request to sequential subnet IP addresses. eg: root@localhost:~/$ nast -m NAST "NETWORK ANALYZER SNIFFER TOOL" Mapping the Lan for 255.255.255.0 subnet ... please wait MAC address IP address (hostname) .br =========================================================== .br 00:4R:BR:3E:21:12 192.168.1.1(nast.experiment.net) .br 00:50:BA:80:AC:11 192.168.1.2 (localhost.org) (*) (*) This is localhost .br .TP \fB-s, --tcp-stream\fR Follow a TCP/IP connection printing all data in payload. You must specify the IP addresses of the ends. eg of a ftp connection: .br root@localhost:~/$ nast -s NAST "NETWORK ANALYZER SNIFFER TOOL" Type connection extremes .br ------------------------ .br 1st ip : 192.168.1.1 .br 1st port : 1041 .br 2nd : 192.168.1.2 .br 2nd port : 21 .br NAST TCP STREAM LOG .br .br 192.168.1.1->mistaya.neverland.org .br PASV .br 192.168.1.1<-mistaya.neverland.org .br 227 Entering Passive Mode (192,168,1,2,4,12). .br 192.168.1.1->mistaya.neverland.org .br LIST .br (...) .br .br .TP \fB-g, --find-gateway\fR Try to find possible Internet-gateways. .br We send a SYN packet to a public host on port 80 through sequential host-lan and if a SYN-ACK return we have find the gateway. .br .TP \fB-r, --reset-connection\fR Destroy an established connection. You must specify the IP addresses of the ends and at least one port . Please, pay attention when use this function. eg: root@localhost:~/$ nast -r NAST "NETWORK ANALYZER SNIFFER TOOL" Type connection extremes .br ------------------------ .br 1 ip / hostname : 192.168.1.1 .br 1 port (0 to autodetect) : 0 .br 2 ip / hostname : 192.168.1.2 .br 2 port (0 to autodetect) : 21 .br - Waiting for SEQ ACK (192.168.1.1 -> 192.168.1.2:21) .br - Stoled SEQ (247656261) ACK (3764364876)... .br - Connection has been resetted .br .br This feature works only if we can read SEQ and ACK numbers, because RST mechanism works with them. .br .TP \fB-S, --port-scanner\fR Performs a half-open port scanning on the selected host. It tries also to determine some firewall (just iptables) rules. .br About this technique NMAP says: This technique is often referred to as "half-open" scanning, because you don't open a full TCP connection. You send a SYN packet, as if you are going to open a real connection and you wait for a response. A SYN|ACK indicates the port is listening. A RST is indicative of a non-listener. If a SYN|ACK is received, a RST is immediately sent to tear down the connection (actually our OS kernel does this for us). The primary advantage to this scanning technique is that fewer sites will log it. Unfortunately you need root privileges to build these custom SYN packets. .br eg: root@localhost:~/$ nast -S .br .br NAST "NETWORK ANALYZER SNIFFER TOOL" .br Port Scanner extremes .br Insert IP to scan : 192.168.1.3 .br Insert Port range : 1-100 .br Wait for scanning... .br State Port Services Notes .br Open 22 ssh None .br Open 27 nsw-fe None All the other 98 ports are in state closed .br Scanning terminated on Apr 14 21:46:55 The Port range could be in the following style: .br eg: 1-100 (means from port 1 to 100) 1,3,5,1000 (means ports 1,3,5 and 1000) 1-50,60 (means from port 1 to 50 and port 60) .br .TP \fB-M, --multi-port-scanner\fR Same as above but done on all hosts of the lan. .br .TP \fB-L, --find-link\fR Tries to determine what type of link is used in the LAN (Hub or switch). .br In the LAN segment is there a HUB or a SWITCH? We can find it by sending a spoofed ICMP echo-request (to work there must be at least 3 host in LAN and at least one of them must reply with a ICMP echo-replay) .br .TP \fB-b, --daemon-banner\fR Checks the most famous daemon banner on the LAN's hosts. .br You can customize ports database adding them to ports[] variable in main.c .br .TP \fB-c, --check-arp-poisoning\fR Control ARP answers to discover possible ARP spoofing attacks like man-in-the-middle .br When run, Nast make a database of all network node (IP and MAC address), then sniff ARP response and verify the correctness of IP-mac address association. Remember to execute Nast when you are sure that nobody is making ARP-poisoning, than have fun and relax and check program output:). .br .TP \fB-C, --byte-counting <"filter">\fR Apply traffic counting to <"filter"> (see FILTER SYNTAX section below for syntax) .br Use \fB-C any\fR if you don't want to use a filter. eg: root@localhost:~/$ nast -C any NAST "NETWORK ANALYZER SNIFFER TOOL" Reading from "eth0" Packets Total Current speed Average speed .br ---------------------------------------------------------------- .br - 24 1008B 18B/s 21B/s .br .PP .SH GENERAL OPTIONS .TP \fB-G, --ncurses\fR Run Nast with the ncurses interfaces (only if compiled with ncurses support) .br .TP \fB-l, --log-file \fR Log reports to . Work with many features. .br .TP \fB-B, --daemon\fR Run in background like daemon and turn off stdout (very useful for sniffer/stream/ARP control logging) .br .TP \fB-V, --version\fR Show version information .PP .SH NCURSES INTERFACE NOTE Versions later 0.2.0 have a new ncurses interface which has many improvements regarding the correspondent command line version. For example you can select the connection interactively for tcp stream and reset features and byte counting module show much more informations (packets type and connections load). .TP Please read NCURSES_README file before using the ncurses interface! .PP .SH FILTER SYNTAX, WHAT PCAP GIVE US! Important: this section has been copied from Tcpdump 3.7.1 manpage and "expression" here stand from "filter". .br \fBRemeber\fR to enclose filter between apexes ("something like this") .be .IP "\fI expression\fP" .RS selects which packets will be dumped. If no \fIexpression\fP is given, all packets on the net will be dumped. Otherwise, only packets for which \fIexpression\fP is `true' will be dumped. .LP The \fIexpression\fP consists of one or more .I primitives. Primitives usually consist of an .I id (name or number) preceded by one or more qualifiers. There are three different kinds of qualifier: .IP \fItype\fP qualifiers say what kind of thing the id name or number refers to. Possible types are .BR host , .B net and .BR port . E.g., `host foo', `net 128.3', `port 20'. If there is no type qualifier, .B host is assumed. .IP \fIdir\fP qualifiers specify a particular transfer direction to and/or from .IR id . Possible directions are .BR src , .BR dst , .B "src or dst" and .B "src and" .BR dst . E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'. If there is no dir qualifier, .B "src or dst" is assumed. For `null' link layers (i.e. point to point protocols such as slip) the .B inbound and .B outbound qualifiers can be used to specify a desired direction. .IP \fIproto\fP qualifiers restrict the match to a particular protocol. Possible protos are: .BR ether , .BR fddi , .BR tr , .BR ip , .BR ip6 , .BR arp , .BR rarp , .BR decnet , .B tcp and .BR udp . E.g., `ether src foo', `arp net 128.3', `tcp port 21'. If there is no proto qualifier, all protocols consistent with the type are assumed. E.g., `src foo' means `(ip or arp or rarp) src foo' (except the latter is not legal syntax), `net bar' means `(ip or arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'. .LP [`fddi' is actually an alias for `ether'; the parser treats them identically as meaning ``the data link level used on the specified network interface.'' FDDI headers contain Ethernet-like source and destination addresses, and often contain Ethernet-like packet types, so you can filter on these FDDI fields just as with the analogous Ethernet fields. FDDI headers also contain other fields, but you cannot name them explicitly in a filter expression. .LP Similarly, `tr' is an alias for `ether'; the previous paragraph's statements about FDDI headers also apply to Token Ring headers.] .LP In addition to the above, there are some special `primitive' keywords that don't follow the pattern: .BR gateway , .BR broadcast , .BR less , .B greater and arithmetic expressions. All of these are described below. .LP More complex filter expressions are built up by using the words .BR and , .B or and .B not to combine primitives. E.g., `host foo and not port ftp and not port ftp-data'. To save typing, identical qualifier lists can be omitted. E.g., `tcp dst port ftp or ftp-data or domain' is exactly the same as `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'. .LP Allowable primitives are: .IP "\fBdst host \fIhost\fR" True if the IPv4/v6 destination field of the packet is \fIhost\fP, which may be either an address or a name. .IP "\fBsrc host \fIhost\fR" True if the IPv4/v6 source field of the packet is \fIhost\fP. .IP "\fBhost \fIhost\fP True if either the IPv4/v6 source or destination of the packet is \fIhost\fP. Any of the above host expressions can be prepended with the keywords, \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in: .in +.5i .nf \fBip host \fIhost\fR .fi .in -.5i which is equivalent to: .in +.5i .nf \fBether proto \fI\\ip\fB and host \fIhost\fR .fi .in -.5i If \fIhost\fR is a name with multiple IP addresses, each address will be checked for a match. .IP "\fBether dst \fIehost\fP True if the ethernet destination address is \fIehost\fP. \fIEhost\fP may be either a name from /etc/ethers or a number (see .IR ethers (3N) for numeric format). .IP "\fBether src \fIehost\fP True if the ethernet source address is \fIehost\fP. .IP "\fBether host \fIehost\fP True if either the ethernet source or destination address is \fIehost\fP. .IP "\fBgateway\fP \fIhost\fP True if the packet used \fIhost\fP as a gateway. I.e., the ethernet source or destination address was \fIhost\fP but neither the IP source nor the IP destination was \fIhost\fP. \fIHost\fP must be a name and must be found both by the machine's host-name-to-IP-address resolution mechanisms (host name file, DNS, NIS, etc.) and by the machine's host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.). (An equivalent expression is .in +.5i .nf \fBether host \fIehost \fBand not host \fIhost\fR .fi .in -.5i which can be used with either names or numbers for \fIhost / ehost\fP.) This syntax does not work in IPv6-enabled configuration at this moment. .IP "\fBdst net \fInet\fR" True if the IPv4/v6 destination address of the packet has a network number of \fInet\fP. \fINet\fP may be either a name from /etc/networks or a network number (see \fInetworks(4)\fP for details). .IP "\fBsrc net \fInet\fR" True if the IPv4/v6 source address of the packet has a network number of \fInet\fP. .IP "\fBnet \fInet\fR" True if either the IPv4/v6 source or destination address of the packet has a network number of \fInet\fP. .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR" True if the IP address matches \fInet\fR with the specific \fInetmask\fR. May be qualified with \fBsrc\fR or \fBdst\fR. Note that this syntax is not valid for IPv6 \fInet\fR. .IP "\fBnet \fInet\fR/\fIlen\fR" True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR bits wide. May be qualified with \fBsrc\fR or \fBdst\fR. .IP "\fBdst port \fIport\fR" True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a destination port value of \fIport\fP. The \fIport\fP can be a number or a name used in /etc/services (see .IR tcp (4P) and .IR udp (4P)). If a name is used, both the port number and protocol are checked. If a number or ambiguous name is used, only the port number is checked (e.g., \fBdst port 513\fR will print both tcp/login traffic and udp/who traffic, and \fBport domain\fR will print both tcp/domain and udp/domain traffic). .IP "\fBsrc port \fIport\fR" True if the packet has a source port value of \fIport\fP. .IP "\fBport \fIport\fR" True if either the source or destination port of the packet is \fIport\fP. Any of the above port expressions can be prepended with the keywords, \fBtcp\fP or \fBudp\fP, as in: .in +.5i .nf \fBtcp src port \fIport\fR .fi .in -.5i which matches only tcp packets whose source port is \fIport\fP. .IP "\fBless \fIlength\fR" True if the packet has a length less than or equal to \fIlength\fP. This is equivalent to: .in +.5i .nf \fBlen <= \fIlength\fP. .fi .in -.5i .IP "\fBgreater \fIlength\fR" True if the packet has a length greater than or equal to \fIlength\fP. This is equivalent to: .in +.5i .nf \fBlen >= \fIlength\fP. .fi .in -.5i .IP "\fBip proto \fIprotocol\fR" True if the packet is an IP packet (see .IR ip (4P)) of protocol type \fIprotocol\fP. \fIProtocol\fP can be a number or one of the names \fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP, \fIesp\fP, \fIvrrp\fP, \fIudp\fP, or \fItcp\fP. Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell. Note that this primitive does not chase the protocol header chain. .IP "\fBip6 proto \fIprotocol\fR" True if the packet is an IPv6 packet of protocol type \fIprotocol\fP. Note that this primitive does not chase the protocol header chain. .IP "\fBip6 protochain \fIprotocol\fR" True if the packet is IPv6 packet, and contains protocol header with type \fIprotocol\fR in its protocol header chain. For example, .in +.5i .nf \fBip6 protochain 6\fR .fi .in -.5i matches any IPv6 packet with TCP protocol header in the protocol header chain. The packet may contain, for example, authentication header, routing header, or hop-by-hop option header, between IPv6 header and TCP header. The BPF code emitted by this primitive is complex and cannot be optimized by BPF optimizer code in \fItcpdump\fP, so this can be somewhat slow. .IP "\fBip protochain \fIprotocol\fR" Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4. .IP "\fBether broadcast\fR" True if the packet is an ethernet broadcast packet. The \fIether\fP keyword is optional. .IP "\fBip broadcast\fR" True if the packet is an IP broadcast packet. It checks for both the all-zeroes and all-ones broadcast conventions, and looks up the local subnet mask. .IP "\fBether multicast\fR" True if the packet is an ethernet multicast packet. The \fIether\fP keyword is optional. This is shorthand for `\fBether[0] & 1 != 0\fP'. .IP "\fBip multicast\fR" True if the packet is an IP multicast packet. .IP "\fBip6 multicast\fR" True if the packet is an IPv6 multicast packet. .IP "\fBether proto \fIprotocol\fR" True if the packet is of ether type \fIprotocol\fR. \fIProtocol\fP can be a number or one of the names \fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP, \fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP, \fIiso\fP, \fIstp\fP, \fIipx\fP, or \fInetbeui\fP. Note these identifiers are also keywords and must be escaped via backslash (\\). .IP [In the case of FDDI (e.g., `\fBfddi protocol arp\fR') and Token Ring (e.g., `\fBtr protocol arp\fR'), for most of those protocols, the protocol identification comes from the 802.2 Logical Link Control (LLC) header, which is usually layered on top of the FDDI or Token Ring header. .IP When filtering for most protocol identifiers on FDDI or Token Ring, \fItcpdump\fR checks only the protocol ID field of an LLC header in so-called SNAP format with an Organizational Unit Identifier (OUI) of 0x000000, for encapsulated Ethernet; it doesn't check whether the packet is in SNAP format with an OUI of 0x000000. .IP The exceptions are \fIiso\fP, for which it checks the DSAP (Destination Service Access Point) and SSAP (Source Service Access Point) fields of the LLC header, \fIstp\fP and \fInetbeui\fP, where it checks the DSAP of the LLC header, and \fIatalk\fP, where it checks for a SNAP-format packet with an OUI of 0x080007 and the Appletalk etype. .IP In the case of Ethernet, \fItcpdump\fR checks the Ethernet type field for most of those protocols; the exceptions are \fIiso\fP, \fIsap\fP, and \fInetbeui\fP, for which it checks for an 802.3 frame and then checks the LLC header as it does for FDDI and Token Ring, \fIatalk\fP, where it checks both for the Appletalk etype in an Ethernet frame and for a SNAP-format packet as it does for FDDI and Token Ring, \fIaarp\fP, where it checks for the Appletalk ARP etype in either an Ethernet frame or an 802.2 SNAP frame with an OUI of 0x000000, and \fIipx\fP, where it checks for the IPX etype in an Ethernet frame, the IPX DSAP in the LLC header, the 802.3 with no LLC header encapsulation of IPX, and the IPX etype in a SNAP frame.] .IP "\fBdecnet src \fIhost\fR" True if the DECNET source address is .IR host , which may be an address of the form ``10.123'', or a DECNET host name. [DECNET host name support is only available on Ultrix systems that are configured to run DECNET.] .IP "\fBdecnet dst \fIhost\fR" True if the DECNET destination address is .IR host . .IP "\fBdecnet host \fIhost\fR" True if either the DECNET source or destination address is .IR host . .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fInetbeui\fP" Abbreviations for: .in +.5i .nf \fBether proto \fIp\fR .fi .in -.5i where \fIp\fR is one of the above protocols. .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR" Abbreviations for: .in +.5i .nf \fBether proto \fIp\fR .fi .in -.5i where \fIp\fR is one of the above protocols. Note that \fItcpdump\fP does not currently know how to parse these protocols. .IP "\fBvlan \fI[vlan_id]\fR" True if the packet is an IEEE 802.1Q VLAN packet. If \fI[vlan_id]\fR is specified, only true is the packet has the specified \fIvlan_id\fR. Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR changes the decoding offsets for the remainder of \fIexpression\fR on the assumption that the packet is a VLAN packet. .IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR" Abbreviations for: .in +.5i .nf \fBip proto \fIp\fR\fB or ip6 proto \fIp\fR .fi .in -.5i where \fIp\fR is one of the above protocols. .IP "\fBiso proto \fIprotocol\fR" True if the packet is an OSI packet of protocol type \fIprotocol\fP. \fIProtocol\fP can be a number or one of the names \fIclnp\fP, \fIesis\fP, or \fIisis\fP. .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR" Abbreviations for: .in +.5i .nf \fBiso proto \fIp\fR .fi .in -.5i where \fIp\fR is one of the above protocols. Note that \fItcpdump\fR does an incomplete job of parsing these protocols. .PP .SH EXAMPLES Here are some examples of the use of NAST: .br .SH nast -p -f "src 192.168.1.2" .br In this example we put the NIC in promiscuous mode and with the help of the filter we choose to see only the traffic from 192.168.1.2 .br .SH nast -p -B --ld logfile.txt .br Here we run nast in background mode and log all data that pass through our NIC. .br .SH nast -S -l logfile.txt .br In this other case we log the results of the port scanner in the file "logfile.txt" .br .SH nast -c -B .br This is a very useful options. We run in background mode nast that checks if someone is arp-poisoning. .br .PP .SH SUPPORTED PLATFORMS Tested: .br * Linux 2.4.x .br * Linux 2.6.x .br * FreeBSD 5.x .br * FreeBSD 4.x .LP Not tested yet: .br * Linux 2.2.x .PP .SH AVAILABILITY Official web site: http://nast.berlios.de .br Newsletter: http://lists.berlios.de/mailman/listinfo/nast-news .PP .SH KNOWN BUGS * Promiscuous mode scanner many times returns wrong results .br * Sometimes the port scanner generates false results .LP Please report bugs to authors .PP .SH AUTHORS Embyte .br Snifth .PP .SH LICENSE GNU GENERAL PUBLIC LICENSE Version 2, June 1991 .br See COPYING for details. nast-0.2.0/port.c0100644000175000001440000005453510013746653013034 0ustar embyteusers/* NAST This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 356, Boston, MA 02111-1567, USA. */ #include "include/nast.h" /* single host syn port scanner*/ int port(char *dev,u_long dst_ip,libnet_plist_t *plist_p,int lg) { int c, build_ip, fr, fd ; libnet_t *l; libnet_ptag_t tcp; libnet_ptag_t t; struct timeval tv; struct servent *service; fd_set rfsd; int sd,close; struct libnet_tcp_hdr *Tcp; struct libnet_ipv4_hdr *ip; struct libnet_icmpv4_hdr *icmp; u_long src_ip; u_char *pkt; u_short bport, eport, cport; char errbuf[LIBNET_ERRBUF_SIZE]; int lineh; //char *filter="not src host 62.10.127.46"; //char *filter="not src host 192.168.1.1"; lineh = 1; pkt = NULL; close = bport = eport = cport = t = fr = fd = 0; tm = time(NULL); /* per avere sia ora che data si pu usare %c, ma il compilatore tira fuori dei warning decisamente noiosi:)*/ strftime(timed,60,"%b %d %T",localtime(&tm)); if (lg) { openfile(); n_print (NULL,0,0,lg,"Logging to file... \n"); fflush (stdout); n_print (NULL,0,0,lg,"NAST PORT SCAN REPORT\n"); n_print (NULL,0,0,lg,"Made on %s\n\n", timed); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif /* demonize */ if (demonize) { w_error(0,"Is very useless demonize me in checking banner! Omit"); demonize=0; } n_print("princ",lineh,2,lg,"Wait for scanning...\n\n"); n_print("princ",++lineh,2,lg,"State Port Services Notes\n\n"); ++lineh; if(pcap_lookupnet(dev,&netp,&maskp,errbuf)==-1) { w_error(1,"pcap_lookupnet() error %s\n",errbuf); } if ((descr = pcap_open_live (dev, BUFSIZ, 0, 1, errbuf))==NULL) { w_error(1, "pcap_open_live() error: %s\n",errbuf); } sd = pcap_fileno(descr); if ((offset=(device(dev,descr)))==-1) return -1; l = libnet_init( LIBNET_RAW4, /* injection type */ dev, /* network interface */ errbuf); /* errbuf */ if (l == NULL) { w_error(1, "libnet_init() failed: %s", errbuf); } if ((src_ip = libnet_get_ipaddr4(l))==-1) { w_error(1, "Can't get local ip address : %s\n", libnet_geterror(l)); } /*if(pcap_compile(descr,&fp,filter,0,netp) == -1) { if(w_error(0, "Error in pcap_compile, insert a different filter\n")==-1) return(0); } if(pcap_setfilter(descr,&fp) == -1) { w_error(1, "Error calling pcap_setfilter\n\n"); }*/ tcp = 0; build_ip = 1; while (libnet_plist_chain_next_pair(plist_p, &bport, &eport)) { while (!(bport > eport) && bport != 0) { cport = bport++; tcp = libnet_build_tcp( 1050, /* source port */ cport, /* destination port */ 0x01010101, /* sequence number */ 0, /* acknowledgement num */ TH_SYN, /* control flags */ 32767, /* window size */ 0, /* checksum */ 0, /* urgent pointer */ LIBNET_TCP_H, /* TCP packet size */ NULL, /* payload */ 0, /* payload size */ l, /* libnet handle */ tcp); /* libnet id */ if (tcp == -1) { w_error(1, "Can't build TCP header: %s\n", libnet_geterror(l)); } if (build_ip) { build_ip = 0; t = libnet_build_ipv4( LIBNET_IPV4_H + LIBNET_TCP_H, /* length */ 0, /* TOS */ 242, /* IP ID */ 0, /* IP Frag */ 64, /* TTL */ IPPROTO_TCP, /* protocol */ 0, /* checksum */ src_ip, /* source IP */ dst_ip, /* destination IP */ NULL, /* payload */ 0, /* payload size */ l, /* libnet handle */ 0); if (t == -1) { w_error(1, "Can't build IP header: %s\n", libnet_geterror(l)); } } /* usleep con be omissed when scanned another linux box,but if u scan a openBSD it must be uesed! otherwise it find drop rule that doesn't exist!*/ //usleep(100); usleep(900); c = libnet_write(l); if (c == -1) { w_error(1, "Libnet_write() Error: %s\n", libnet_geterror(l)); } for(;;) { fflush (logd); tv.tv_sec = 2; //tv.tv_usec = 75000; FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); if((pkt = (u_char *) pcap_next(descr,&hdr))==NULL) { break; } ip = (struct libnet_ipv4_hdr *) (pkt + offset); icmp = (struct libnet_icmpv4_hdr *) (pkt + offset + LIBNET_IPV4_H); Tcp = (struct libnet_tcp_hdr *) (pkt + offset + LIBNET_IPV4_H); if (Tcp->th_flags == (TH_RST|TH_ACK)) { close++; break; } service = getservbyport(htons(cport), "tcp"); if(ip->ip_p == IPPROTO_ICMP) { n_print("princ",lineh,2,lg,"Filtered %d %s",(cport), (service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); switch((icmp->icmp_type)) { case 3: switch (icmp->icmp_code) { case 0: n_print("princ",lineh,56,lg,"Network Unreachable(*)\n"); break; case 1: n_print("princ",lineh,56,lg,"Host Unreachable(*)\n"); break; case 2: n_print("princ",lineh,56,lg,"Protocol Unreachable(*)\n"); break; case 3: n_print("princ",lineh,56,lg,"Port Unreachable(*)\n"); break; case 9: n_print("princ",lineh,56,lg,"Destination network administratively prohibited(*)\n"); break; case 10: n_print("princ",lineh,56,lg,"Destination host administratively prohibited(*)\n"); break; case 13: n_print("princ",lineh,56,lg,"Comm. administratively prohibited(*)\n"); } break; default: n_print("princ",lineh,56,lg,"%d(*)\n", icmp->icmp_type); break; } fr++; ++lineh; break; } if (!select(sd+1, &rfsd, NULL, NULL, &tv)) { n_print("princ",lineh,2,lg,"Filtered %d %s", (cport),(service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); n_print("princ",lineh,56,lg,"SYN packet timeout(**)\n"); fd++; ++lineh; break; } if (Tcp->th_seq != 0 && (Tcp->th_flags == (TH_SYN|TH_ACK))) { n_print("princ",lineh,2,lg,"Open %d %s", cport ,(service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); n_print("princ",lineh,56,lg,"None\n"); ++lineh; break; } } } } n_print("winfo",1,2,lg,"\nAll the other %d ports are in state closed\n",close); if (fr!=0) n_print("winfo",2,1,lg,"(*)Possible REJECT rule in the firewall\n"); if (fd!=0) n_print("winfo",3,1,lg,"(**)Possible DROP rule in the firewall\n"); libnet_destroy(l); pcap_close(descr); n_print("princ",lineh+2,1,lg,"Scanning terminated on %s\n",timed); if (lg) { n_print(NULL,0,0,lg,"Done! Results has been writed to '%s'\n", logname); fclose (logd); } printf ("\n"); return 0; if (lg) { n_print(NULL,0,0,lg,"Error! Results has been writed to '%s'\n", logname); fclose (logd); } printf ("\n"); return 1; } /* multy hosts - catch banner*/ int mport (u_char *dev, u_short ports[],int lg) { struct host *uphost; struct servent *service; struct in_addr daddr; u_short i, j, n; char banner[1024]; char *msg = "HEAD / HTTP/1.0\n\n"; struct sockaddr_in sin; char ip[20]; int sd, r, size, bsent,z,k,x,y; struct timeval tv; fd_set rfds; int lineh; int linep; int len; char *buf_p, *banner_p, *p; u_char tmpbuf[1024], *ph=NULL, obuf[4]; lineh = 3; linep = 6; if (lg) { openfile(); n_print (NULL,0,0,lg,"Logging to file... \n"); fflush (stdout); n_print (NULL,0,0,lg,"NAST BANNER SCAN REPORT\n"); n_print (NULL,0,0,lg,"Made on %s\n\n", timed); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif /* demonize */ if (demonize) { w_error(0,"Is very useless demonize me in checking banner! Omit"); demonize=0; } tm = time(NULL); strftime(timed,60,"%b %d %T",localtime(&tm)); n_print ("princ",1,1,lg, "Builing hosts list... "); if ((uphost = map_lan(dev, 0, &n))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return(0); } if (n==0) { n_print("winfo",1,1,lg," "); n_print("winfo",1,1,lg,"\nWhat are you doing? You are alone in this network!\n\n"); } n_print("princ",1,25,lg,"done\n\n"); memset (&sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; for (i=0; is_name); if(!graph) printf("\t\t"); FD_ZERO (&rfds); FD_SET (sd, &rfds); tv.tv_sec=2; tv.tv_usec=0; fcntl(sd, F_SETFL, O_NONBLOCK); if(ports[j]==80) { select(sd+1, &rfds, NULL, NULL, &tv); size = strlen(msg); bzero(banner,1024); bsent = send(sd, msg, size, 0); r = read (sd, banner, 1024); len = strlen("Server: "); banner_p = (char *)malloc(strlen(banner)+1); bzero(banner_p, strlen(banner)+1); for(buf_p = strtok(banner, "\n"); buf_p != NULL;) { p = strstr(buf_p, "Server: "); if(p) { memmove(banner_p, (p+len), strlen(buf_p)-len); } buf_p = strtok(NULL, "\n"); } if(banner_p) { strncpy(banner, banner_p, 1024); } else { strncpy(banner, "no banner available", 1024); } free(banner_p); if (banner[r-1]=='\n') banner[r-1]='\0'; n_print("princ",linep,24,lg,"%s",banner); if(!graph) printf("\n"); ++linep; close(sd); j++; continue; } if(ports[j] == 23) { y=0; select(sd+1, &rfds, NULL, NULL, &tv); do { usleep(100000); bzero(tmpbuf, 1024); r = read (sd, tmpbuf, 1024); if(r==-1) break; for(z = 0; z < r; z++) { if((z % 3) == 0 && z > 0) { if(tmpbuf[z-3] != 255) { bzero(banner, 1024); z=0; for(k = 0; k < r; k++) { if(tmpbuf[k] == 255) { k++; k++; } else if(tmpbuf[k] != 0 && tmpbuf[k] != 13) { banner[z] = tmpbuf[k]; z++; } } banner[z] = '\0'; break; } } } ph = tmpbuf; x = strlen(tmpbuf); while(x > 0) { obuf[0] = 255; ph++; x--; if( (*ph == 251) || (*ph == 252)) y = 254; if( (*ph == 253) || (*ph == 254)) y = 252; if(y) { obuf[1] = y; ph++; x--; obuf[2] = *ph; send(sd, obuf, 3, 0); y = 0; } ph++; x--; } } while(ph != NULL); if (banner[r-1]=='\n') banner[r-1]='\0'; for(i=0;i<=(strlen(banner));i++) { if(banner[i]=='\n'){ banner[i]=' '; } } n_print("princ",linep,24,lg,"%s\n",banner); linep++; close(sd); j++; continue; } /* read the banner */ if (select (sd+1, &rfds, NULL, NULL, &tv)) { memset (&banner, 0, 1024); r = read (sd, banner, 1024); if (banner[r-1]=='\n') banner[r-1]='\0'; n_print("princ",linep,24,lg,"%s\n", banner); ++linep; } /* 1st time out expired */ else { /* send two \n to socket */ write (sd, "\n\n", 2); /* reset timer */ FD_ZERO (&rfds); FD_SET (sd, &rfds); tv.tv_sec=8; tv.tv_usec=0; /* try a 2nd time */ if (select (sd+1, &rfds, NULL, NULL, &tv)) { memset (&banner, 0, 1024); r = recv (sd, banner, 1024, 0); if (banner[r-1]=='\n') banner[r-1]='\0'; n_print("princ",linep,24,lg,"%s\n", banner); ++linep; } } } fflush (logd); close (sd); j++; if (ports[j] == '\0') break; } lineh = linep+2; linep = linep+5; if(!graph) printf("\n"); } free (uphost); n_print("winfo",1,1,lg," "); n_print("winfo",1,2,lg,"\nScanning terminated on %s\n",timed); if (lg) { fclose (logd); } printf ("\n"); return 0; } int mhport(u_char *dev,libnet_plist_t *plist_p,int lg) { int c, build_ip, fr=0, fd=0 ; libnet_t *l; libnet_ptag_t tcp=0; libnet_ptag_t t=0; struct timeval tv; struct servent *service; fd_set rfsd; int sd,close = 0; struct pcap_pkthdr pcap_h; struct libnet_tcp_hdr *Tcp; struct libnet_ipv4_hdr *ip; struct libnet_icmpv4_hdr *icmp; u_long src_ip = 0; u_char *pkt; u_short bport = 0, eport = 0, cport = 0, i = 0 ,n = 0; char errbuf[LIBNET_ERRBUF_SIZE]; struct host * uphost; u_char testip[20]; int lineh; int linep; lineh = 3; linep = 6; tm = time(NULL); strftime(timed,60,"%b %d %T",localtime(&tm)); if (lg) { openfile(); n_print (NULL,0,0,lg,"Logging to file... \n"); fflush (stdout); n_print (NULL,0,0,lg,"NAST MULTI PORT SCAN REPORT\n"); n_print (NULL,0,0,lg,"Made on %s\n\n", timed); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif /* demonize */ if (demonize) { w_error(0,"Is very useless demonize me in checking banner! Omit"); demonize=0; } n_print ("princ",1,1,lg,"Builing hosts list..."); if ((uphost = map_lan(dev, 0, &n))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return(0); } if (n==0) { if(w_error(0, "\nWhat are you doing? You are alone in this network!\n\n")==-1) return(0); } n_print ("princ",1,22,lg,"done\n"); for(i=0;i eport) && bport != 0) { cport = bport++; tcp = libnet_build_tcp( 1050, /* source port */ cport, /* destination port */ 1234567, /* sequence number */ 0, /* acknowledgement num */ TH_SYN, /* control flags */ 32767, /* window size */ 0, /* checksum */ 0, /* urgent pointer */ LIBNET_TCP_H, /* TCP packet size */ NULL, /* payload */ 0, /* payload size */ l, /* libnet handle */ tcp); /* libnet id */ if (tcp == -1) { libnet_destroy(l); pcap_close(descr); w_error(1, "Can't build TCP header: %s\n", libnet_geterror(l)); } if (build_ip) { build_ip = 0; t = libnet_build_ipv4( LIBNET_IPV4_H + LIBNET_TCP_H, /* length */ 0, /* TOS */ 242, /* IP ID */ 0, /* IP Frag */ 64, /* TTL */ IPPROTO_TCP, /* protocol */ 0, /* checksum */ src_ip, /* source IP */ inet_addr(testip), /* destination IP */ NULL, /* payload */ 0, /* payload size */ l, /* libnet handle */ 0); if (t == -1) { libnet_destroy(l); pcap_close(descr); w_error(1, "Can't build IP header: %s\n", libnet_geterror(l)); } } //usleep(5); c = libnet_write(l); if (c == -1) { w_error(1, "Error: %s\n", libnet_geterror(l)); } for(;;) { fflush (logd); tv.tv_sec = 2; FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); pkt = (u_char *) pcap_next(descr,&pcap_h); ip = (struct libnet_ipv4_hdr *) (pkt + offset); icmp = (struct libnet_icmpv4_hdr *) (pkt + offset + LIBNET_IPV4_H); Tcp = (struct libnet_tcp_hdr *) (pkt + offset + sizeof(struct libnet_ipv4_hdr)); if (Tcp->th_flags == (TH_RST|TH_ACK)) { close++; break; } service = getservbyport(htons(cport), "tcp"); /*ho lasciato gli icmp pi logici x un filtraggio...dubito che vada bene un echo_request:)*/ if(ip->ip_p == IPPROTO_ICMP) { n_print("princ",lineh,2,lg,"Filtered %d %s", cport, (service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); switch((icmp->icmp_type)) { case 3: switch (icmp->icmp_code) { case 0: n_print("princ",lineh,56,lg,"Network Unreachable(*)\n"); break; case 1: n_print("princ",lineh,56,lg,"Host Unreachable(*)\n"); break; case 2: fprintf(logd,"Protocol Unreachable(*)\n"); break; case 3: n_print("princ",lineh,56,lg,"Port Unreachable(*)\n"); break; case 9: n_print("princ",lineh,56,lg,"Destination network administratively prohibited(*)\n"); break; case 10: n_print("princ",lineh,56,lg,"Destination host administratively prohibited(*)\n"); break; case 13: n_print("princ",lineh,56,lg,"Comm. administratively prohibited(*)\n"); break; } break; default: n_print("princ",lineh,56,lg,"%i(*)\n", icmp->icmp_type); break; } fr++; ++lineh; break; } if (!select(sd+1, &rfsd, NULL, NULL, &tv)) { n_print("princ",lineh,2,lg,"Filtered %d %s", cport,(service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); n_print("princ",lineh,56,lg,"SYN packet timeout(**)\n"); fd++; ++lineh; break; } if (Tcp->th_seq != 0 && (Tcp->th_flags == (TH_SYN|TH_ACK))) { n_print("princ",lineh,2,lg,"Open %d %s", cport,(service) ? service->s_name : "unknown"); if(!graph || (graph && lg)) fprintf(logd,"\t\t\t"); n_print("princ",lineh,56,lg,"None\n"); ++lineh; break; } } } } n_print("princ",++lineh,2,lg,"\nAll the other %d ports are in state closed\n",close); if (fr!=0) n_print("princ",++lineh,1,lg,"(*)Possible REJECT rule in the firewall\n"); if (fd!=0) n_print("princ",++lineh,1,lg,"(**)Possible DROP rule in the firewall\n"); libnet_destroy(l); pcap_close(descr); close=0; fd = 0; fr =0; lineh = lineh+2; } free (uphost); n_print("winfo",2,2,lg,"Scanning terminated on %s\n",timed); if (lg) { printf ("Done! Results has been writed to '%s'\n", logname); fclose (logd); } printf ("\n"); return 0; } nast-0.2.0/prom.c0100644000175000001440000001307510013746653013017 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* if ip_dst is 0 scan for all network NIC */ int psearch (char *dev, u_long ip_dst, u_short lg) { u_char enet_dst[6] = { 0xff, 0xff, 0, 0, 0, 0 }; u_char enet_src[6]; u_long ip_src; char errbuf[256]; int sd,ln; fd_set rfsd; struct timeval tv; libnet_t *l; struct libnet_ether_addr *e; struct nast_arp_hdr *arp; u_char *pkt; struct host *uphost=NULL; u_short pcount, i, k; u_char ip[16]; k = i = 0; ln = 3; if (lg) { openfile(); n_print (NULL,0,0,lg,"Logging to file... \n"); fflush (stdout); n_print (NULL,0,0,lg,"NAST SNIFFER SCAN REPORT\n"); n_print (NULL,0,0,lg,"Made on %s\n\n", timed); } #ifdef HAVE_LIBNCURSES if (graph) init_scr(); #endif /* demonize */ if (demonize) { w_error(0,"Is very useless demonize me in checking sniffers! Omit"); demonize=0; } n_print("pop",7,2,lg,"This check can have false response, pay attention!\n"); if ((l = libnet_init (LIBNET_LINK, dev, errbuf))==NULL) { w_error(1, "libnet_init: %s\n\n", errbuf); } if ((e = libnet_get_hwaddr(l))==NULL) { w_error(1, "Can't get hardware address: %s\n\n", libnet_geterror(l)); } memcpy (enet_src, e->ether_addr_octet, 6); if ((pcap_lookupnet(dev, &netp, &maskp, errbuf))==-1) { w_error(1, "pcap_lookupnet error: %s\n", errbuf); } if ((ip_src = libnet_get_ipaddr4(l))==-1) { w_error(1, "Can't get local ip address : %s\n\n", libnet_geterror(l)); } /* log all packets */ if (ip_dst==0) { n_print ("princ",1,1,lg,"Probe for hosts..."); fflush (logd); if ((uphost = map_lan(dev, 0, &k))==NULL) { if(w_error(0, "\nCan't build truly host list! mmhhh!\nReport bug to author please\n\n")==-1) return(0); } if (k==0) { if(w_error(0, "\nWhat are you doing? You are alone in this network!\n\n")==-1) return(0); } n_print ("princ",1,20,lg,"done\n\n"); } /* only 1 host */ if (ip_dst!=0) { k=1; n_print("princ",1,1,lg,"Scanning for sniffer the following host:\n"); } while (i < k) { /* single host */ if (ip_dst!=0) { if (libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP, 6, 4, ARPOP_REQUEST, enet_src, (u_char *)&ip_src, enet_dst, (u_char *)&ip_dst, NULL, 0, l, 0)==-1) { w_error(1, "Can't build arp header : %s\n\n", libnet_geterror(l)); } } /* all network */ else { if (libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP, 6, 4, ARPOP_REQUEST, enet_src, (u_char *)&ip_src, enet_dst, uphost[i].ip, NULL, 0, l, 0)==-1) { w_error(1, "Can't build arp header : %s\n\n", libnet_geterror(l)); } } if (libnet_build_ethernet(enet_dst, enet_src, ETHERTYPE_ARP, NULL, 0, l, 0)==-1) { w_error(1, "Can't build arp header : %s\n\n", libnet_geterror(l)); } /* inizializzo e recupero il file descriptor per la select */ if ((descr = pcap_open_live(dev, BUFSIZ, NOT_PROMISC, 10, errbuf))==NULL) { libnet_destroy(l); w_error(1, "pcap_open_liver() error : %s\n\n", errbuf); } if ((pcap_compile(descr,&fp,"arp",0,netp))==-1) { libnet_destroy(l); w_error(1, "error: %s\n", pcap_geterr (descr)); } if ((pcap_setfilter(descr,&fp))==-1) { libnet_destroy(l); w_error(1, "error: %s\n", pcap_geterr (descr)); } sd = pcap_fileno(descr); if (ip_dst!=0) n_print ("princ",ln,1,lg,"%s (%s) --------->", libnet_addr2name4(ip_dst, LIBNET_DONT_RESOLVE), libnet_addr2name4(ip_dst, LIBNET_RESOLVE)); else { sprintf (ip, "%d.%d.%d.%d", uphost[i].ip[0], uphost[i].ip[1], uphost[i].ip[2], uphost[i].ip[3]); n_print ("princ",ln,1,lg,"%s (%s) --------->", ip, libnet_addr2name4(inet_addr(ip), LIBNET_RESOLVE)); } fflush (logd); /* mando il pacchetto */ if (libnet_write(l)==-1) { w_error(1, "Error sending arp request : %s\n\n", libnet_geterror(l)); } if ((offset=(device(dev,descr)))==-1) return -1; pcount=1; for (;;) { /* inizializzo la select() */ FD_ZERO (&rfsd); FD_SET (sd ,&rfsd); tv.tv_sec = 3; tv.tv_usec = 0; if (!select(sd+1, &rfsd, NULL, NULL, &tv) || (pcount==10)) { n_print ("princ",ln,45,lg," Not found\n"); break; } if ((pkt = (u_char *) pcap_next(descr, &hdr))!=NULL) { arp = (struct nast_arp_hdr *) (pkt+offset); if (ntohs(arp->ar_op)==2) { n_print ("princ",ln,45,lg," Found!\n"); break; } } pcount++; } /* next host */ if (descr) pcap_close(descr); i++; ++ln; } if (l) libnet_destroy(l); if (lg) { n_print (NULL,0,0,lg,"\nFinished\n\n"); fclose (logd); } else { n_print("winfo",1,1,lg," "); n_print ("winfo",1,1,lg,"\nFinished\n\n"); } return 0; } nast-0.2.0/NCURSES_README0100644000175000001440000000307710003274670013753 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool README_NCURSES ============================================================================ Well, even if a lot of plugins are easy to use, some others are a little bit more complex. I will show you how to use 'em: --> USE HELP: Press "h" or select "Help" item from Options menu Tcp stream: 1) press "Shift + A" to use the analyzer functions 2) Select "TCP Stream" :-) 3) Insert the source and destination IPs (or the names if you have a DNS) then press "Enter" 4) Use the "UP key" or "DOWN key" to select a connection from the DataBase in the"Info Window" 5) Press "Enter" to see the stream The stream will refresh itself when new data comes on the connection. 6) If you want to see more lines in the "Main Window" press "q", then "F2" and do as usual. 7) If you want to select another connection from the DataBase in "Info Window" press "s" and go to point 4:) Reset connection: 1) Go to point 1 of TCP Stream and change "TCP Stream" with " Reset Connection":-) Sniffer options: 1) You MUST select the options of the sniffer (like "data", "hex" etc) BEFORE start the sniffer. If you want to change a options you MUST restart the sniffer engine. To stop applications as TCP Stream, Reset Connections and Byte Counting, use "Stop Application" under "Options". That's all! Have fun;-) nast-0.2.0/AUTHORS0100644000175000001440000000077110003274670012737 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool AUTHORS ============================================================================ AUTHORS AND MANTEINERS ARE: Embyte Snifth One is student at University of Bergamo (department of computer science engineering), the second is student at Politecnico of Turin (department of telecommunications) nast-0.2.0/INSTALL0100644000175000001440000001722710003274670012724 0ustar embyteusersBasic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. nast-0.2.0/ChangeLog0100644000175000001440000000734110003274672013443 0ustar embyteusers============================================================================== Nast - Network Analyzer Sniffer Tool Changelog ============================================================================== 0.2.0 Date: 04-01-07 ++ Completely rewritten ncurses graphical interface (-G flag) + Many improvements in graphical analyzer features: + Connections handling for data stream sniffing and connection resetting + Added new stats for byte counter + Added dns resolution support + Recoded a new errors handler !! Fixed banner catcher + Added tcpdump-format logging and loading + Added NCURSES_README file 0.1.7e Date: 03-05-21 + Set promisc mode as default in sniffer + Worked on libnet defines (now it compile on sparc64), Makefile.in and nast.8 !! Fixed a serious memory lack bug in map_lan() which frequently causes segmentation faults 0.1.7d Date: 03-04-23 ++ Nast has been included in FreeBSD ports + Ported to FreeBSD 4.x (tested on 4.6 and 4.7) !! Fixed some importants bugs in configure.ac 0.1.7 Date: 03-04-16 + Ported to FreeBSD 5 (tested on FreeBSD 5) + Added logging support to car() and psearch() + Added two possible logging support to sniffing (-l and --ld) + Added traffic monitoring feature (-C <"filter">) + Extended promiscous mode research to all network NIC (-P all) + Added nast_hex_ntoa() to convert u_char[6] MAC address to "##:##:..##" form + Added nast_atoda() to convert u_char[4] internet host address to "###.###.###.###" format + Added a check on interfaces in main() !! Breaked netmask limitation in map_lan(). Now Nast work with every netmask. !! Breaked max host number limitation in map_lan(). Now Nast can search for a limitless number of host using dynamic allocation. !! Fixed (int) to_ms in pcap_open_live() (setting>0) to work with *BSD !! Fixed a video output bug in car() !! Fixed common return value (NULL) of map_lan() to distinguish no-host from error !! Worked on sniffer features (log, output, headers size, *buf offset, ..) !! Much code has been modified in order to work exclusively on libnet making it os-independent (all headers file has been deleted and includes have been optimized) !! Fixed a bug in logging support in port.c !! Fixed a bug in mport() with telnet banner reader !! Cleaned option parser in main() !! Arranged manpage and compilation/installation procedure 0.1.6 Date: 03-02-17 + Added -B (--daemon) flag to demonize Nast + Added -V (--verbose) flag to show version information + Added long opt support + Added signal() function + Added IGMP support + Better implemented file logging !! Completly rewritten arpreply() and something else in map_lan() becouse it didn't work very well !! Fixed a wrong interpretation of flags in main() !! Fixed a bug in resolve hostname with -P !! Adjust usage() 0.1.5.1 Date: 03-01-27 + Added the control of ARP_RESPONSE so as to discover possible ARP-poisoning !! Fixed the wrong IP bug of ARP_RESPONSE in handle_ARP() !! Fixed a return bug in map_lan() !! Corrected Changelog !! Fixed a wrong printf in fgw() 0.1.5 Date: 03-01-02 ++ First public release... + Log in a file functions reports + Configure files + README, COPYING, AUTHORS, Changelog, man-page added 0.1.4 + Multi port scanner + Follow TCP stream + Catch daemon banner + Ncurses interface 0.1.3 + Reset a connection + HUB or SWITCH detection + Find a gateway !! Corrected Makefile 0.1.2 + Mapping the LAN + Single port scanner 0.1.1 + Set a filter + Log sniffer data in file + Check promisc node in the LAN + Add makefile 0.1.0 + Sniff packets and print header + Print ASCII ASCII-HEX data payload nast-0.2.0/include/0040755000175000001440000000000010014474076013314 5ustar embyteusersnast-0.2.0/include/ARPhdr.h0100644000175000001440000000404410003274725014601 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* See RFC 826 for protocol description. ARP packets are variable in size; the arphdr structure defines the fixed-length portion. Protocol type values are the same as those for 10 Mb/s Ethernet. It is followed by the variable-sized fields ar_sha, arp_spa, arp_tha and arp_tpa in that order, according to the lengths specified. Field names used correspond to RFC 826. */ struct nast_arp_hdr { unsigned short int ar_hrd; /* Format of hardware address. */ unsigned short int ar_pro; /* Format of protocol address. */ unsigned char ar_hln; /* Length of hardware address. */ unsigned char ar_pln; /* Length of protocol address. */ unsigned short int ar_op; /* ARP opcode (command). */ unsigned char __ar_sha[ETHER_ADDR_LEN]; /* Sender hardware address. */ unsigned char __ar_sip[4]; /* Sender IP address. */ unsigned char __ar_tha[ETHER_ADDR_LEN]; /* Target hardware address. */ unsigned char __ar_tip[4]; /* Target IP address. */ /* ARP protocol opcodes. */ #define ARPOP_REQUEST 1 /* ARP request. */ #define ARPOP_REPLY 2 /* ARP reply. */ #define ARPOP_RREQUEST 3 /* RARP request. */ #define ARPOP_RREPLY 4 /* RARP reply. */ #define ARPOP_InREQUEST 8 /* InARP request. */ #define ARPOP_InREPLY 9 /* InARP reply. */ #define ARPOP_NAK 10 }; nast-0.2.0/include/nast.h0100644000175000001440000000767110013746653014444 0ustar embyteusers/* Nast common include file This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* include */ #include #include #include #include "../config.h" #ifdef HAVE_LIBNCURSES #include #endif #include "ARPhdr.h" /* colors */ #define BOLD "\033[1m" #define UNDER "\033[3m" #define NORMAL "\033[0m" #define CYAN "\033[1;36m" #define TCP_HDR_LEN hdr.len - LIBNET_IPV4_H - LIBNET_TCP_H + offset #define UDP_HDR_LEN hdr.len - LIBNET_IPV4_H - LIBNET_TCP_H + offset #define ICMP_HDR_LEN hdr.len - LIBNET_IPV4_H - LIBNET_TCP_H + offset #define IGMP_HDR_LEN hdr.len - LIBNET_IPV4_H - LIBNET_TCP_H + offset #define PROMISC 1 #define NOT_PROMISC 0 /* sniffing functions */ int run_sniffer (u_short promisc, u_short data, u_short hex, u_short f, u_short l, u_short tcpdlog, u_short tcpdread, char *filter, char *dev, char ldname[50]); /* ASCII DATA,HEX DATA,LOGFILE/STDOUT,LOG DATA FILE */ void handle_TCP (u_short d, u_short x, FILE *output, FILE *ldd); void handle_UDP (u_short d, u_short x, FILE *output, FILE *ldd); void handle_ICMP(u_short d, u_short x, FILE *output, FILE *ldd); void handle_IGMP(FILE *output); void handle_ARP (FILE *output); u_int16_t handle_ethernet (u_char *packet); int device (char *dev, pcap_t* descr); void data_sniffo (char *data, u_int l, FILE *log); void print_ascii_hex (char *data_info, u_int len, FILE *log); /* network analyzer functions */ struct host * map_lan (char *dev, u_short mode, u_short *n); int psearch (char *dev, u_long ip_dst, u_short lg); int fgw (u_char *dev); int rst (char *dev, u_long src, u_long dst, u_short sport, u_short dport); int flink (u_char *dev); int port(char *dev, u_long dst_ip, libnet_plist_t *plist_p, int lg); int mport (u_char *dev, u_short ports[], int lg); int mhport (u_char *dev, libnet_plist_t *plist_p, int lg); int stream (char *dev, u_long ip_src, u_long ip_dst, u_short sport, u_short dport, int lg); int car (char *dev, int lg); int run_bc (char *dev, char *filter); /* other functions*/ void sigexit(); void openfile(void); void bkg(void); /* ncurses menu */ #ifdef HAVE_LIBNCURSES int main_graph(void); #endif /* common functions */ char * dn (char * s); int runcplx (char what, char *dev, int l); char * nast_hex_ntoa (u_char *s); char * nast_atoda (u_char *s); int w_error(int fatal, char *err, ...); int n_error(char *err, int fatal); void n_print(char *wins, int y, int x, int lg, char *string, ...); int ng_print(char *wins, int y, int x, char *string); int check_pthread(void); void init_scr(void); /* variable */ FILE *logd; short offset; int npkt; u_char *packet; u_char *buf; struct pcap_pkthdr hdr; pcap_t* descr; pcap_dumper_t *dumper; struct pcap_stat statistic; bpf_u_int32 maskp; /* subnet mask */ bpf_u_int32 netp; /* ip */ int datalink; struct bpf_program fp; /* hold compiled program */ char *logname; char *tcpdl; u_short tr,tl; u_short graph; /* global var for ncurses mode */ u_short cont; /* golbal var*/ int stream_glob; int bc_glob; int sniff_glob; int rst_glob; int arp_glob; pthread_t pt[2]; int lg; struct host { unsigned char mac[ETHER_ADDR_LEN]; unsigned char ip[4]; }; /* time variable */ time_t tm; char timed[60]; /* for demonize nast */ u_short demonize; int line_s; int row_s; nast-0.2.0/stream.c0100644000175000001440000000525710013746653013340 0ustar embyteusers/* nast This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "include/nast.h" /* read data stream */ int stream (char *dev,u_long ip_src,u_long ip_dst,u_short sport,u_short dport,int lg) { char errbuf[LIBNET_ERRBUF_SIZE]; struct libnet_ipv4_hdr *ip; struct libnet_tcp_hdr *tcp; char *data; int n; u_short TCP_SIZE_H; if(lg) { openfile(); printf ("Running and logging to file...\n"); } fputs("NAST TCP Stream\n\n",logd); tm = time(NULL); /* per avere sia ora che data si pu usare %c, ma il compilatore tira fuori dei warning decisamente noiosi:)*/ strftime(timed,60,"%b %d %T",localtime(&tm)); if ((descr = pcap_open_live (dev, BUFSIZ, PROMISC, 10, errbuf)) == NULL) { w_error(1, "pcap_open_live: %s\n", errbuf); } data = malloc (1024); if ((offset=(device(dev,descr)))==-1) return -1; for (;;) { packet = (u_char *) pcap_next(descr, &hdr); if (packet == NULL) break; ip = (struct libnet_ipv4_hdr *) (packet + offset); if (ip->ip_p != IPPROTO_TCP) continue; tcp = (struct libnet_tcp_hdr *) (packet + offset + LIBNET_IPV4_H); TCP_SIZE_H = tcp->th_off*4; if ((n=ntohs(ip->ip_len) - LIBNET_IPV4_H - TCP_SIZE_H)<1) continue; /* caso diritto */ if ( ip->ip_src.s_addr == ip_src && ip->ip_dst.s_addr == ip_dst && tcp->th_sport == htons(sport) && tcp->th_dport == htons(dport) ) { fprintf(logd,"\n%s->%s\n", libnet_addr2name4(ip_src, LIBNET_RESOLVE) , libnet_addr2name4(ip_dst, LIBNET_RESOLVE)); data = (char *) (packet + offset + LIBNET_IPV4_H + TCP_SIZE_H); data_sniffo(data, n, logd); } /* caso rovescio */ else if ( ip->ip_src.s_addr == ip_dst && ip->ip_dst.s_addr == ip_src && tcp->th_sport == htons(dport) && tcp->th_dport == htons(sport)) { fprintf(logd,"\n%s<-%s\n", libnet_addr2name4(ip_src, LIBNET_RESOLVE) , libnet_addr2name4(ip_dst, LIBNET_RESOLVE)); data = (char *) (packet + offset + LIBNET_IPV4_H + TCP_SIZE_H); data_sniffo(data, n, logd); } } pcap_close(descr); return 0; } nast-0.2.0/COPYING0100644000175000001440000004312710003274674012730 0ustar embyteusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. nast-0.2.0/CREDITS0100644000175000001440000000255610003274675012717 0ustar embyteusers============================================================================ Nast - Network Analyzer Sniffer Tool CREDITS ============================================================================ IN RANDOM ORDER SPECIAL THANKS TO: mydecay For giving me a OpenBSD shell to test on. Author of ripper. Kronos For testing and patching beta versions. Nicola Bonelli For autoconf support. Alberto Ornaghi In order to have given ideas to me, Marco Valleri councils and to have tested the code. Authors of ettercap. A particular thx to Alor by Snifth for all the code about scrolling windows in ncurses mode. Ripped from lmap (www.antifork.org) click For testing. SPINE members. Tabris Paul Dorman For giving me excelents ideas Kirill Ponomarew FreeBSD port manteiner Michael Hostbaek FreeBSD tester Uopa For testing on FreeBSD 4.x Yonatan Bokovza For ispelling manpage Abaddon For the "make love" ;) University LAN :-)