(Network-Method Seam");
isseam=1;
}
if(isseam)
{
if(sess->check_seam)
{
printf(": ");
char hostname[100];
lft_session_params * subsess=LFTSessionOpen();
strncpy(hostname, inet_ntoa(tp->hopaddr),100);
subsess->senddevsel = 1;
subsess->senddev = sess->pcap_send_dev;
subsess->userdevsel = 1;
subsess->userdev = sess->pcap_dev;
subsess->auto_ports=0;
subsess->dport=179;
subsess->seq_start=30;
subsess->retry_min=1;
subsess->retry_max=1;
subsess->resolve_names=0;
subsess->ahead_limit=1;
subsess->break_on_icmp = 0;
subsess->is_graphviz_subquery=1;
subsess->hostname=hostname;
subsess->hostname_lsrr_size = 0;
LFTExecute(subsess);
if(subsess->target_open > 0)
printf("Vulnerable/Handshake");
else
{
if(subsess->target_filtered)
printf("Protected/Filtered");
else
printf("Vulnerable/Shun");
}
LFTSessionClose(subsess);
}
printf(")");
}
printf("%s>];\n",GVNTEND);
}
else
UpdateLatency(tp,&minlat,&maxlat,&latinitialized);
}
}
if(minlat==maxlat)
snprintf(latencybuf,100,": %.1fms",minlat);
else
snprintf(latencybuf,100,": %.1f - %.1fms",minlat,maxlat);
if(icmpcode==-1)
{
rankstring=addtostringbuf(rankstring, &rankstringsz, " -> \"Destination");
if (sess->protocol==0 || sess->protocol==4)
{
rankstring=addtostringbuf(rankstring, &rankstringsz, " [target ");
if (sess->target_open > 0)
rankstring=addtostringbuf(rankstring, &rankstringsz, "open]");
else
{
if(sess->target_filtered > 0)
rankstring=addtostringbuf(rankstring, &rankstringsz, "filtered]");
else
rankstring=addtostringbuf(rankstring, &rankstringsz, "closed]");
}
}
rankstring=addtostringbuf(rankstring, &rankstringsz, latencybuf);
}
else
{
snprintf(nodenamebuff,200,"\"%d", hopno+1);
rankstring=addtostringbuf(rankstring, &rankstringsz, " -> ");
rankstring=addtostringbuf(rankstring, &rankstringsz, nodenamebuff);
rankstring=addtostringbuf(rankstring, &rankstringsz, latencybuf);
}
switch (anomtype)
{
case 1:
rankstring=addtostringbuf(rankstring, &rankstringsz, "\\n");
rankstring=addtostringbuf(rankstring, &rankstringsz, GV_ANOMALY1_TEXT);
break;
case 2:
rankstring=addtostringbuf(rankstring, &rankstringsz, "\\n");
rankstring=addtostringbuf(rankstring, &rankstringsz, GV_ANOMALY2_TEXT);
break;
case 3:
rankstring=addtostringbuf(rankstring, &rankstringsz, "\\n");
rankstring=addtostringbuf(rankstring, &rankstringsz, GV_ANOMALY3_TEXT);
break;
default:
break;
}
rankstring=addtostringbuf(rankstring, &rankstringsz, "\"");
free(prevlevelnodes);
prevlevelnodes=currlevelnodes;
prevlevelnodessz=currlevelnodessz;
currlevelnodes=NULL;
currlevelnodessz=0;
}
if(icmpcode==-1)
break;
}
if(neglstart!=-1)
{
holecount++;
printf("\tHOLE%d[%s, label=<",holecount,GVHOPSTYLE_HOLE);
printf("%s%s%s%s",GVNTBEG,cpath,GVNIMG_HOLE,GVNTMID);
snprintf(nodenamebuff,200,"HOLE%d",holecount);
printf("No Response%s>];\n",GVNTEND);
routemap=addNodeToRouteMap(routemap, &routemapsz, prevlevelnodes, &currlevelnodes, &currlevelnodessz, nodenamebuff);
free(prevlevelnodes);
prevlevelnodes=currlevelnodes;
prevlevelnodessz=currlevelnodessz;
currlevelnodes=NULL;
currlevelnodessz=0;
snprintf(nodenamebuff,200,"\"No reply received after TTL %d\"", neglstart+1);
rankstring=addtostringbuf(rankstring, &rankstringsz, " -> ");
rankstring=addtostringbuf(rankstring, &rankstringsz, nodenamebuff);
neglstart=-1;
neglend=-1;
}
free(prevlevelnodes);
printf("\tranksep=equally;\n\t{\n\t\tnode [shape=plaintext];\n\t\t%s;\n\t}\n",rankstring);
free(rankstring);
printf("%s",routemap);
free(routemap);
printf("}\n");
}
/*---------------------------------------------------------------------------*/
lft-3.8/INSTALL 000644 000766 000000 00000023563 11053131665 013134 0 ustar 00vic wheel 000000 000000 #######################################################
## Installation Instructions for Layer Four Traceroute
#######################################################
Instructions are provided for different platforms below.
#######################################################
On WINDOWS:
#######################################################
Building this program on Windows is possible without UNIX-like
compatibility environments. To compile the program, use the
Microsoft Visual Studio Express edition which is free and may be
downloaded from http://www.microsoft.com You must also download
and install the Windows Platform SDK which is available from the
same web site. The platform SDK provides the necessary Winsock
header files. Please read the documentation related to fully
installing the Windows Platform SDK for use with Visual Studio
Express or your alternative compiler to ensure all necessary
files are placed in the appropriate locations, specifically the
header files.
Using VS Express, you may build LFT by following these
instructions:
Open a Command Prompt window (cmd.exe), change directories to the
"lft" folder you downloaded, and type the following commands (from
inside the LFT folder):
"%VS80COMNTOOLS%vsvars32.bat"
nmake -f makefile.vc
This will create lft.exe and whob.exe in the current folder.
Of course, you may move the files wherever you choose. Depending
on the Windows platform, you may or may not have TCP raw sockets
functionality, causing TCP traces to fail. However, in this case
ICMP and UDP traces should still work.
You may also have to explicitly allow lft.exe to use the network
by creating a rule in Windows (or your 3rd-party) Firewall.
#######################################################
On UNIX-like operating systems:
#######################################################
Some special options to consider when running './configure' are:
1. Using '--enable-gtod' is useful on platforms where BPF timestamps are not
precise. This forces LFT to call gettimeofday() on each packet instead of
relying on the timestamp in the packet's pcap header.
2. Using '--enable-universal' will automatically compile universal binaries
on the Darwin/Mac OS X platform for PPC and Intel architectures.
Below 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.
lft-3.8/whois.c 000644 000766 000000 00000251527 13263006600 013376 0 ustar 00vic wheel 000000 000000 /*
* Handle communication with whois servers.
*
* This file is part of the Prefix WhoIs Project.
* See http://pwhois.org
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
* This software includes:
* - simplified access to regular expressions
* - tokenizer
* - lookup functions for AS, NETNAME, ORGNAME
* - works with the following sources:
* ARIN, RIPE, APNIC, RADB, CYMRU, PWHOIS, RISWHOIS
* - will do recursive lookups
* - convenient framework for further whois digging
*
* To compile the standalone client:
* cc -o whob whois.c -DSTANDALONE
*
*
* Portions (c) Victor Oppleman (lft@oppleman.com)
* Portions (c) 2011 Markus Gothe
* Portions (c) 2002 Ugen Antsilevitch (ugen@xonix.com)
*
*/
#include "lft_lib.h"
#define PORT_WHOIS 43
#if defined(WIN32) || defined(_WIN32)
#define read(a, b, c) recv(a, b, c, 0)
#define write(a, b, c) send(a, b, c, 0)
#define close(s) closesocket(s)
#define snprintf _snprintf
#endif
#include "whois.h"
#if defined(BSD_IP_STACK)
#define pcap_snprintf snprintf
#endif
/*#define ASSERT(x) if (!(x)) { fprintf(stderr, "Assertion ("#x") failed\n"); exit(EXIT_FAILURE); }*/
/* OPTIONS and variable initialization */
static char pwhois_server[] = "whois.pwhois.org";
static char myaddress_server[] = "myaddress.today";
static char radb_server[] = "whois.ra.net";
static char cymru_server[] = "whois.cymru.com";
static char arin_server[] = "whois.arin.net";
static char apnic_server[] = "whois.apnic.net";
static char ripe_server[] = "whois.ripe.net";
static char ripe_ris_server[] = "riswhois.ripe.net";
#ifdef STANDALONE
const char *version = "3.8"; /* set version string for library and client */
const char *appname = "WhoB"; /* set application name */
static int go_interactive = 0; /* We'll wait on STDIN unless args suggest otherwise */
static int use_cymru = 0; /* Don't use Cymru by default */
static int use_riswhois = 0; /* Don't use RIPE NCC RIS by default */
static int display_orgname = 1; /* Display orgname by default */
static int display_aspath = 0; /* Don't display AS-PATH by default */
static int display_netname = 0; /* Don't display netname by default */
static int display_radb_as = 0; /* Don't display RADB Origin-AS by default */
static int show_routes_byasn = 0; /* Don't show all advertisements by default */
static int show_routes_bytransitasn = 0; /* Don't show all routes that transit ASN by default */
static int show_networks_byasn = 0; /* Don't show all networks by default */
static int show_contacts_byasn = 0; /* Don't show all contact info by default */
static int show_routes_byprefix = 0; /* Don't show all routes by prefix by default */
static int show_server_status = 0; /* Don't show pwhois server status by default */
static int show_cache_date = 0; /* Don't show pwhois cache date by default */
static int read_from_file = 0; /* Don't read input from file by default */
static int riswhoisfromfile = 0; /* Don't use riswhois by default for readfromfile */
static int cymrufromfile = 0; /* Don't use Cymru by default for readfromfile */
static int use_gigo = 1; /* Use GIGO feature by default */
static int use_stdin = 0; /* Don't use STDIN for bulk file input by default */
static const unsigned int max_hostname_input = 200; /* Maximum length of input from user */
static const int max_lines = 2500; /* Maximum lines to read from bulk file per query */
static const int line_size = 256; /* Maximum line length */
static char hostname[256];
#endif
/* END of OPTIONS and variable initialization */
#if defined(WIN32) || defined(_WIN32)
char *
index(char *s, char c)
{
char *t;
if (!s)
return NULL;
for (t = s; *t; t++)
if (*t == c) {
return t;
}
/* Return terminating \0 if specifically requested */
if (c == '\0')
return t;
return NULL;
}
#endif
#if defined(WIN32) || defined(_WIN32)
int
inet_aton(const char *cp, struct in_addr *pin)
{
if (!pin)
return -1;
pin->s_addr = inet_addr(cp);
return (pin->s_addr != -1) ? 1 : 0;
}
#endif
typedef struct token_s {
char *ptr;
} token_t;
static token_t *
tokens(char *buf, const char *sep)
{
char *c, *c1;
int size, cur;
token_t *rt;
if (!buf || !sep)
return NULL;
size = 1;
for (c = buf; *c ; c++)
if (index(sep, *c)) {
size++;
while (*c && index(sep, *c))
c++;
}
size++; /* for the NULL */
if (!(rt = (token_t *)malloc(size * sizeof(token_t))))
return NULL;
memset(rt, 0, size * sizeof(token_t));
rt[0].ptr = buf;
cur = 0;
for (c = buf; *c ; c++) {
if (index(sep, *c)) {
c1 = c;
while (*c && index(sep, *c))
c++;
if (*c)
rt[++cur].ptr = c;
*c1 = '\0';
}
}
rt[++cur].ptr = NULL;
return rt;
}
typedef struct ip_blk_s {
unsigned int start;
unsigned int end;
} ip_blk_t;
static ip_blk_t *
w_blk2range(char *s_start, char *s_end)
{
struct in_addr in;
unsigned int s, e;
ip_blk_t *r;
if (!s_start || !s_end)
return NULL;
if (!inet_aton(s_start, &in))
return NULL;
s = ntohl(in.s_addr);
if (!inet_aton(s_end, &in))
return NULL;
e = ntohl(in.s_addr);
if (!(r = malloc(sizeof(ip_blk_t))))
return NULL;
r->start = s;
r->end = e;
return r;
}
static ip_blk_t *
w_mask2range(char *addr, char *mask)
{
struct in_addr in;
unsigned int s, m;
ip_blk_t *r;
if (!addr || !mask)
return NULL;
m = (unsigned int)strtoul(mask, (char **)NULL, 10);
if (m > 32)
return NULL;
if (!inet_aton(addr, &in))
return NULL;
s = ntohl(in.s_addr);
if (!(r = malloc(sizeof(ip_blk_t))))
return NULL;
r->start = s &~ (((unsigned)0xffffffff) >> m);
r->end = s | (((unsigned)0xffffffff) >> m);
return r;
}
static int rm_spaces(char* str)
{
/* Remove spaces (isspace()) from anywhere within a string
ONLY operates on a null-terminated (\0) string! */
int j = -1;
unsigned int i;
if (!str) return 0;
for (i=0; i<=strlen(str); i++)
if (!(isspace(*(str+i))))
*(str+(++j)) = *(str+i);
else
continue;
return 1;
}
static char *match_prefix(const char *prefix, const char *target)
{
/* Target will be something like "origin: AS22773" and prefix will be "origin:" and
* we return a pointer to "AS22773" */
while (*prefix) {
if (tolower(*prefix) != tolower(*target))
return NULL;
prefix++;
target++;
}
while (isspace(*target))
target++;
/* strip out the leading AS from the number */
if (strncmp(target,"AS",2) == 0)
target += 2;
return strdup(target);
}
static ip_blk_t *match_iprange(char *target)
{
/* matches something like "1.2.3.4-5.6.7.8" */
char *pos, *dash, *beforedash;
/* ip_blk_t *out; */
while (isspace(*target))
target++;
pos = target;
while (*pos && !isspace(*pos))
pos++;
beforedash = strdup(target);
beforedash[pos-target] = 0;
dash = strchr(target, '-');
if (!dash)
return NULL;
dash++;
while (isspace(*dash))
dash++;
return w_blk2range(beforedash, dash);
}
static ip_blk_t *match_ipprefix(char *target)
{
/* matches something like 1.2.3.0/24 */
char *slash, *pos;
char *beforeslash;
/* ip_blk_t *out; */
while (isspace(*target))
target++;
pos = target;
while (*pos && !isspace(*pos) && *pos != '/')
pos++;
beforeslash = strdup(target);
beforeslash[pos - target] = 0;
slash = strchr(target, '/');
if (!slash) return NULL;
slash++;
return w_mask2range(beforeslash, slash);
}
static char *match_inparens(char *target)
{
/* matches something like " (HELLO)" and returns "HELLO" */
char *end, *res;
target = strchr(target, '(');
if (!target)
return NULL;
target++;
end = strchr(target, ')');
if (!end)
return NULL;
res = strdup(target);
res[end - target] = 0;
return res;
}
static char *match_afterparens(char *target)
{
/* matches something like " (HELLO) xxx" and returns a pointer to "xxx" */
target = strchr(target, '(');
if (!target) return NULL;
target = strchr(target, ')');
if (!target) return NULL;
target++;
while(*target && isspace(*target)) target++;
if (*target) return strdup(target);
else return NULL;
}
static int stricontains(const char *haystack, const char *needle)
{
/* Search for a substring without a string library */
int i, j, match;
i = 0, j = 0;
while (haystack[i] != '\0') {
while (tolower(haystack[i]) != tolower(needle[0]) && haystack[i] != '\0')
i++;
if (haystack[i] == '\0')
return (-1);
match = i;
while (tolower(haystack[i]) == tolower(needle[j]) && haystack[i] != '\0' && needle[j] != '\0') {
i++;
j++;
}
if (needle[j] == '\0')
return (match);
if (haystack[i] == '\0')
return (-1);
i = match + 1;
j = 0;
}
return 0;
}
whois_session_params *w_init(void)
{
/* int e; */
whois_session_params *wsess = (whois_session_params *)malloc(sizeof(whois_session_params));
wsess->w_noisy = 0; /* Don't show debug msgs by default */
memset(&(wsess->pw_serv), 0, sizeof(wsess->pw_serv));
wsess->consolidated_asn[0] = wsess->consolidated_asp[0] =
wsess->consolidated_route[0] = wsess->consolidated_orgname[0] =
wsess->consolidated_netname[0] ='?';
wsess->consolidated_asn[1] = wsess->consolidated_asp[1] =
wsess->consolidated_route[1] = wsess->consolidated_orgname[1] =
wsess->consolidated_netname[1] =0;
memset(&wsess->tbuf, 0, sizeof(wsess->tbuf));
wsess->logprintfCookie = 0;
return wsess;
}
whois_session_params * w_reinit(whois_session_params * wsess)
{
/* int e; */
wsess->w_noisy = 0; /* Don't show debug msgs by default */
memset(&(wsess->pw_serv), 0, sizeof(wsess->pw_serv));
wsess->consolidated_asn[0] = wsess->consolidated_asp[0] =
wsess->consolidated_route[0] = wsess->consolidated_orgname[0] =
wsess->consolidated_netname[0] = '?';
wsess->consolidated_asn[1] = wsess->consolidated_asp[1] =
wsess->consolidated_route[1] = wsess->consolidated_orgname[1] =
wsess->consolidated_netname[1] = 0;
memset(&wsess->tbuf, 0, sizeof(wsess->tbuf));
wsess->logprintfCookie = 0;
return wsess;
}
__inline__ void w_close(whois_session_params * wsess)
{
free(wsess);
}
static char *
w_ask(const char *serv, const char *q, const char *port)
{
int s;
struct sockaddr_in sin4;
struct hostent *hp;
char *br;
int q_s, br_s, cur, n, myport;
char buf[128], *sendbuf;
#ifdef USE_WHOIS_TIMEOUT
#if defined(WIN32) || defined(_WIN32)
int whreadtimeout = 20000;
#else
struct timeval whreadtimeout;
whreadtimeout.tv_sec = 20;
whreadtimeout.tv_usec = 0;
#endif
#endif
if (!serv || !q)
return NULL;
if (!(hp = gethostbyname(serv)))
return NULL;
sin4.sin_family = AF_INET;
if (port) {
if (!(myport = (int)strtol(port, (char **)NULL, 10)))
return NULL;
sin4.sin_port = htons(myport);
} else {
sin4.sin_port = htons(PORT_WHOIS);
}
memcpy((void *)&sin4.sin_addr, hp->h_addr, hp->h_length);
if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0)
return NULL;
#ifdef USE_WHOIS_TIMEOUT
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &whreadtimeout, sizeof(whreadtimeout));
#endif
if (connect(s, (const struct sockaddr *)(const void *)&sin4, sizeof (sin4)) < 0)
return NULL;
br_s = 512;
if (!(br = (char *)malloc(br_s)))
return NULL;
q_s = strlen(q);
sendbuf = (char *)malloc(q_s+2);
if(q[q_s-1]=='\r' || q[q_s-1]=='\n')
{
strncpy(sendbuf, q, q_s+1);
}
else
{
strncpy(sendbuf, q, q_s+1);
sendbuf[q_s]='\n';
q_s++;
sendbuf[q_s]=0;
}
if (write(s, sendbuf, q_s) != q_s) /* || write(s, "\r\n", 2) != 2)*/
return NULL;
cur = 0;
while ((n = read(s, buf, sizeof(buf))) > 0) {
if ((cur + n) >= br_s) {
br_s = br_s * 2;
if (!(br = realloc(br, br_s)))
return NULL;
}
strncpy((char *)&br[cur], buf, n);
cur += n;
}
br[cur] = 0;
close(s);
return br;
}
int
w_lookup_all_pwhois(whois_session_params * wsess, char *addr)
{
token_t *ls;
char *serv, *reply;
const char *format;
int i;
if (!addr)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
reply = w_ask(serv, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",serv);
else
fprintf(stderr,"No reply from %s.\n",serv);
}
return -1;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
char *value = NULL;
if ((value = match_prefix("origin-as:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_asn,"?",1) == 0) strncpy(wsess->consolidated_asn,value,255);
} else
if ((value = match_prefix("prefix:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_route,"?",1) == 0) strncpy(wsess->consolidated_route,value,255);
} else
if ((value = match_prefix("as-path:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_asp,"?",1) == 0) strncpy(wsess->consolidated_asp,value,255);
} else
if ((value = match_prefix("org-name:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_orgname,"?",1) == 0) strncpy(wsess->consolidated_orgname,value,255);
} else
if ((value = match_prefix("net-name:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_netname,"?",1) == 0) strncpy(wsess->consolidated_netname,value,255);
} else
if ((value = match_prefix("cache-date:", ls[i].ptr))) {
if ((wsess->tval = atol(value)) != 0) {
format = "%d-%b-%y %H:%M:%S %Z";
(void)strftime(wsess->tbuf, sizeof(wsess->tbuf), format, localtime(&wsess->tval));
}
}
if(value)
free(value);
}
free(ls);
free(reply);
return 0;
}
int
w_lookup_all_riswhois(whois_session_params * wsess, char *addr)
{
token_t *ls=NULL;
char *serv=NULL, *reply=NULL;
const char *risopts = "-1 -M "; /* 1 object/prefix, Most specific */
char *risquery = malloc((strlen(risopts)* sizeof(char)) + (strlen(addr) * sizeof(char)) + 1);
unsigned int i;
if (!addr)
return -1;
/* prepare the text-string-based query */
risquery[0]=0;
strcat(risquery,risopts);
strcat(risquery,addr);
reply = w_ask(ripe_ris_server, risquery, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",serv);
else
fprintf(stderr,"No reply from %s.\n",serv);
}
return -1;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
char *value = NULL;
if ((value = match_prefix("origin:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_asn,"?",1) == 0) strncpy(wsess->consolidated_asn,value,255);
} else
if ((value = match_prefix("route:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_route,"?",1) == 0) strncpy(wsess->consolidated_route,value,255);
} else
if ((value = match_prefix("descr:", ls[i].ptr))) {
if (strncmp(wsess->consolidated_orgname,"?",1) == 0) strncpy(wsess->consolidated_orgname,value,255);
if (strncmp(wsess->consolidated_netname,"?",1) == 0) strncpy(wsess->consolidated_netname,value,255);
}
if(value)
free(value);
}
free(ls); free(reply); free(risquery);
return 0;
}
int
w_lookup_as_pwhois(whois_session_params * wsess, char *addr)
{
token_t *ls;
char *reply = NULL, *value = NULL;
unsigned int i;
int ans = 0;
if (!addr)
return 0;
reply = w_ask(pwhois_server, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",pwhois_server);
else
fprintf(stderr,"No reply from %s.\n",pwhois_server);
}
return 0;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
if ((value = match_prefix("origin-as:", ls[i].ptr)))
break;
}
free(ls); free(reply);
if (!value)
return 0;
rm_spaces(value);
for (i = 0; i < strlen(value); i++) {
if (!isdigit(value[i])) {
free(value);
return 0;
}
}
ans = strtol(value, (char **)NULL, 10);
free(value);
return ans;
}
int
w_lookup_as_riswhois(whois_session_params * wsess, char *addr)
{
token_t *ls;
char *reply = NULL, *value = NULL;
const char *risopts = "-1 -M "; /* 1 object/prefix, Most specific */
char *risquery = malloc((strlen(risopts) * sizeof(char)) + (strlen(addr) * sizeof(char)) + 1);
unsigned int i;
int ans = 0;
if (!addr)
return 0;
/* prepare the text-string-based query */
risquery[0]=0;
strcat(risquery,risopts);
strcat(risquery,addr);
reply = w_ask(ripe_ris_server, risquery, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",ripe_ris_server);
else
fprintf(stderr,"No reply from %s.\n",ripe_ris_server);
}
return 0;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
if ((value = match_prefix("origin:", ls[i].ptr)))
break;
}
free(ls);
free(reply);
free(risquery);
if (!value)
return 0;
rm_spaces(value);
for (i = 0; i < strlen(value); i++) {
if (!isdigit(value[i])) {
free(value);
return 0;
}
}
ans = atoi(value);
free(value);
return ans;
}
int
w_lookup_all_riswhois_bulk(whois_session_params * wsess, struct ip_list_array *iplist)
{
token_t *responses=0;
char *reply=0;
const char *bulk_begin = "-k -1 -M\n"; /* Keepalive, 1 object/prefix, Most specific */
const char *bulk_end = "-k";
char *bulk_ip_query = malloc((strlen(bulk_begin) * sizeof(char)) + ((strlen(bulk_end)+1) * sizeof(char)) + (16 * (*iplist).numItems));
int i = 0;
unsigned int j = 0;
int k = 0;
int entity_id = 0;
unsigned int until = 0;
char *value = NULL;
bulk_ip_query[0]=0;
if (!iplist)
return -1;
/* clean up the response data set in case the caller doesn't (and we return error) */
for (i = 0; i < (*iplist).numItems; i++) {
(*iplist).asn[(i)] = 0;
memset((*iplist).netName[i],0,sizeof((*iplist).netName[i]));
memset((*iplist).orgName[i],0,sizeof((*iplist).orgName[i]));
}
/* prepare the text-string-based query */
strcat(bulk_ip_query,bulk_begin);
for (i = 0; i < ((*iplist).numItems); i++) {
strcat(bulk_ip_query,inet_ntoa((*iplist).ipaddr[i]));
strcat(bulk_ip_query,"\n");
}
strcat(bulk_ip_query,bulk_end);
reply = w_ask(ripe_ris_server, bulk_ip_query, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",ripe_ris_server);
else
fprintf(stderr,"No reply from %s.\n",ripe_ris_server);
}
/* clean up the response data set in case the caller doesn't */
for (i = 0; i < (*iplist).numItems; i++)
(*iplist).asn[(i)] = 0;
return -1;
}
responses = tokens(reply, "\n");
for (i = 0; responses[i].ptr; i++) {
value = NULL;
if ((value = match_prefix("origin:", responses[i].ptr)) != NULL) {
if (k > 0) { entity_id++; k = 0; }
rm_spaces(value); /* strip out any spaces from the ASN */
for (j = 0; j < strlen(value); j++) {
if (!isdigit(value[j])) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
else
printf("Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
if(strtol(value, (char **) NULL, 10)) {
(*iplist).asn[(entity_id)] = strtol(value, (char **)NULL, 10);
k++;
} else if (wsess->w_noisy > 2)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Skipping additional object for same query.\n");
else
fprintf(stderr,"Skipping additional object for same query.\n");
}
} else
if ((value = match_prefix("descr:", responses[i].ptr))) {
strncpy((*iplist).orgName[entity_id],value,100);
/* yes, this is duplicated. riswhois adds a netname attribute here, so we reuse 'descr' */
for (until = 0; until < strlen(value); until++) {
if (isspace(value[until]))
break;
}
strncpy((*iplist).netName[entity_id],value,(until));
k++;
} else
if ((value = match_prefix("% ", responses[i].ptr)) != NULL) {
if (i > 5 && k < 1) { /* Weed out up to 5 leading lines from RIPE NCC RIS */
if (wsess->w_noisy > 2)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"%% MATCHED on '%s'\n",responses[i].ptr);
else
printf("%% MATCHED on '%s'\n",responses[i].ptr);
}
/* (*iplist).asn[(entity_id)] = 0; */
k++;
} /* else printf("'%s'\n",responses[i].ptr); */
} /* else printf("'%s'\n",responses[i].ptr); */
if(value)
free(value);
if ((entity_id) >= (*iplist).numItems)
break;
}
free(responses); free(reply); free(bulk_ip_query);
return 0;
}
int
w_lookup_as(whois_session_params * wsess, char *addr)
{
token_t *ls;
ip_blk_t *a = NULL, *b = NULL;
/* char *sa, *sb; */
char *reply, *value = NULL;
unsigned int i;
int ans = 0;
int use_this = 1;
if (!addr)
return 0;
reply = w_ask(radb_server, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",radb_server);
else
fprintf(stderr,"No reply from %s.\n",radb_server);
}
return 0;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
value = NULL;
if ((value = match_prefix("local-as:", ls[i].ptr)) != NULL) {
break;
} else
if ((value = match_prefix("route:", ls[i].ptr)) != NULL) {
a = match_ipprefix(value);
if (b) {
if (((b->end - b->start) > (a->end - a->start))) {
use_this = 1;
free(b);
b = a;
a = NULL;
} else {
use_this = 0;
free(a);
a = NULL;
}
} else {
use_this = 1;
b = a;
a = NULL;
}
} else
if (use_this && (value = match_prefix("origin:", ls[i].ptr))) {
break;
}
if(value != NULL)
free(value);
}
free(ls);
free(reply);
if(b != NULL)
free(b);
if (!value)
return 0;
rm_spaces(value);
for (i = 0; i < strlen(value); i++) {
if (!isdigit(value[i])) {
return 0;
}
}
ans = strtol(value, (char **)NULL, 10);
free(value);
return ans;
}
int
w_lookup_as_cymru(whois_session_params * wsess, char *addr)
{
/*
* Look up the ASN at the prefix-based Cymru whois server
*/
token_t *ls;
char *reply;
unsigned int i;
char value[6];
memset(&value, 0, sizeof(value));
if (!addr)
return 0;
reply = w_ask(cymru_server, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",cymru_server);
else
fprintf(stderr,"No reply from %s.\n",cymru_server);
}
return 0;
}
ls = tokens(reply, "\n");
/* Set i to 1 to skip the first/header line of reply from cymru */
strncpy(value,ls[1].ptr,5);
rm_spaces(value); /* strip out any spaces from the ASN */
for (i = 0; i < strlen(value); i++) {
if (!isdigit(value[i])) {
return 0;
}
}
free(ls);
free(reply);
return (strtol(value, (char **)NULL, 10));
}
int
w_lookup_as_cymru_bulk(whois_session_params * wsess, struct ip_list_array *iplist)
{
token_t *responses;
char *reply;
const char *bulk_begin = "begin\n";
const char *bulk_end = "end\n";
char *bulk_ip_query = malloc((strlen(bulk_begin) * sizeof(char)) + (strlen(bulk_end)* sizeof(char)) + (16 * (*iplist).numItems));
int i;
unsigned int j;
char value[6];
memset(&value, 0, sizeof(value));
bulk_ip_query[0]=0;
if (!iplist)
return -1;
/* clean up the response data set in case the caller doesn't (and we return error) */
for (i = 0; i < (*iplist).numItems; i++)
(*iplist).asn[(i)] = 0;
/* prepare the text-string-based query */
strcat(bulk_ip_query,bulk_begin);
for (i = 0; i < ((*iplist).numItems); i++) {
strcat(bulk_ip_query,inet_ntoa((*iplist).ipaddr[i]));
strcat(bulk_ip_query,"\n");
}
strcat(bulk_ip_query,bulk_end);
reply = w_ask(cymru_server, bulk_ip_query, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",cymru_server);
else
fprintf(stderr,"No reply from %s.\n",cymru_server);
}
return -1;
}
responses = tokens(reply, "\n");
/* Set i to 1 to skip the first/header line of reply from cymru */
for (i = 1; responses[i].ptr; i++) {
strncpy(value,responses[i].ptr,5);
rm_spaces(value); /* strip out any spaces from the ASN */
for (j = 0; j < strlen(value); j++) {
if (!isdigit(value[j])) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
else
fprintf(stderr,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
if(strtol(value, (char **)NULL, 10)) {
(*iplist).asn[(i-1)] = strtol(value, (char **)NULL, 10);
} else {
(*iplist).asn[(i-1)] = 0;
}
if ((i+1) > (*iplist).numItems)
break;
}
free(responses); free(reply); free(bulk_ip_query);
return 0;
}
#ifdef STANDALONE
static int w_display_rvbyasn_pwhois(whois_session_params * wsess, char *asn)
{
char *reply;
const char *query_begin = "routeview source-as=";
char *whob_query = NULL;
char *serv;
if (!asn)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
whob_query = malloc( (strlen(appname) + strlen(version) + strlen(query_begin) + strlen(asn)) * sizeof(char) + 10);
whob_query[0]=0;
/* prepare the text-string-based query */
strcat(whob_query,"app=\"");
strcat(whob_query,appname);
strcat(whob_query," ");
strcat(whob_query,version);
strcat(whob_query,"\" ");
strcat(whob_query,query_begin);
strcat(whob_query,asn);
strcat(whob_query,"\n");
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply); free(whob_query);
return 0;
}
static int w_display_rvbytransitasn_pwhois(whois_session_params * wsess, char *asn)
{
char *reply;
const char *query_begin = "routeview transit-as=";
char *whob_query = NULL;
char *serv;
if (!asn)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
whob_query = malloc( (strlen(appname) + strlen(version) + strlen(query_begin) + strlen(asn)) * sizeof(char) + 10);
whob_query[0]=0;
/* prepare the text-string-based query */
strcat(whob_query,"app=\"");
strcat(whob_query,appname);
strcat(whob_query," ");
strcat(whob_query,version);
strcat(whob_query,"\" ");
strcat(whob_query,query_begin);
strcat(whob_query,asn);
strcat(whob_query,"\n");
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply); free(whob_query);
return 0;
}
static int w_display_contactsbyasn_pwhois(whois_session_params * wsess, char *asn)
{
char *reply;
const char *query_begin = "registry source-as=";
char *whob_query = NULL;
char *serv;
if (!asn)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
whob_query = malloc( ((strlen(appname) + strlen(version) + strlen(query_begin) + strlen(asn)) * sizeof(char)) + 10);
whob_query[0]=0;
/* prepare the text-string-based query */
strcat(whob_query,"app=\"");
strcat(whob_query,appname);
strcat(whob_query," ");
strcat(whob_query,version);
strcat(whob_query,"\" ");
strcat(whob_query,query_begin);
strcat(whob_query,asn);
strcat(whob_query,"\n");
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply); free(whob_query);
return 0;
}
static int w_display_networksbyasn_pwhois(whois_session_params * wsess, char *asn)
{
char *reply;
const char *query_begin = "netblock source-as=";
char *whob_query = NULL;
char *serv;
if (!asn)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
whob_query =(char *)malloc(((strlen(appname) + strlen(version) + strlen(query_begin) + strlen(asn)) * sizeof(char)) + 10);
whob_query[0]=0;
/* prepare the text-string-based query */
strcat(whob_query,"app=\"");
strcat(whob_query,appname);
strcat(whob_query," ");
strcat(whob_query,version);
strcat(whob_query,"\" ");
strcat(whob_query,query_begin);
strcat(whob_query,asn);
strcat(whob_query,"\n");
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply); free(whob_query);
return 0;
}
static int w_display_rvbyprefix_pwhois(whois_session_params * wsess, char *prefix)
{
char *reply;
const char *query_begin = "routeview prefix=";
char *whob_query = NULL;
char *serv;
if (!prefix)
return -1;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
whob_query = malloc(((strlen(appname) * sizeof(char))+10) + (strlen(version) * sizeof(char)) + (strlen(query_begin) * sizeof(char)) + (strlen(prefix))* sizeof(char));
whob_query[0]=0;
/* prepare the text-string-based query */
strcat(whob_query,"app=\"");
strcat(whob_query,appname);
strcat(whob_query," ");
strcat(whob_query,version);
strcat(whob_query,"\" ");
strcat(whob_query,query_begin);
strcat(whob_query,prefix);
strcat(whob_query,"\n");
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply); free(whob_query);
return 0;
}
static int w_display_bulkfromfile_pwhois(whois_session_params * wsess, char *filespec)
{
const char *query_begin = "begin\n";
const char *query_end = "end\n";
const char *appname_extras = "BULK_FILE";
const char *format_instructions = "type=cymru\n";
char *reply;
char *serv;
FILE *bulkFile;
int num_lines = 0, i = 0;
char *lines = malloc(line_size * max_lines);
char *this_line = malloc(line_size);
size_t whob_query_len = ((strlen(appname) * sizeof(char) +10) + (strlen(appname_extras) * sizeof(char)) + (strlen(version) * sizeof(char))) + (strlen(query_begin) * sizeof(char)) + (strlen(format_instructions) * sizeof(char)) + (strlen(query_end) * sizeof(char)) + (line_size * max_lines);
char *whob_query = (char *)malloc(whob_query_len);
reply = NULL;
*whob_query = '\0';
if (!filespec) {
fprintf(stderr,"You must specify a file to use (or '-' for stdin) for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (!strncmp(filespec,"-",1) || use_stdin == 1) {
bulkFile = stdin;
} else
bulkFile = fopen(filespec, "r");
if (!bulkFile) {
fprintf(stderr,"%s: Unable to open \'%s\' for reading.\n",appname,filespec);
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
while (!feof(bulkFile)) {
if (num_lines >= max_lines && wsess->w_noisy >= 2)
fprintf(stderr,"Processing next batch of %d beginning at line %d.\n",max_lines,(num_lines+1));
memset(lines, 0, line_size * max_lines);
memset(whob_query, 0, whob_query_len);
for (i = 0; i < max_lines; i++) {
if (fgets(this_line,line_size - 1,bulkFile)) {
if (strncmp(this_line, "#", 1) && strncmp(this_line, ";", 1)) {
strcat(lines,this_line);
num_lines++;
if (wsess->w_noisy >= 4)
fprintf(stderr,"Line %d: %s",num_lines,this_line);
}
} else if (feof(bulkFile)) {
if (wsess->w_noisy >= 2)
fprintf(stderr,"End of file reached after reading %d lines.\n",num_lines);
break;
} else if (ferror(bulkFile)) {
if (wsess->w_noisy >= 1)
fprintf(stderr,"Error in stream on line %d.\n",num_lines+1);
break;
}
}
/* prepare the text-string-based query */
strcat(whob_query, query_begin);
strcat(whob_query, "app=\"");
strcat(whob_query, appname);
strcat(whob_query, " ");
strcat(whob_query, version);
strcat(whob_query, " ");
strcat(whob_query, appname_extras);
strcat(whob_query, "\"\n");
if (use_cymru)
strcat(whob_query, format_instructions);
strcat(whob_query, lines);
strcat(whob_query, query_end);
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
free(this_line);
free(lines);
free(whob_query);
free(reply);
return -1;
}
printf("%s",reply);
}
free(this_line);
free(lines);
free(whob_query);
free(reply);
fclose(bulkFile);
return 0;
}
static int w_display_bulkfromfile_riswhois(whois_session_params * wsess, char *filespec)
{
const char *query_begin = "-k -1 -M\n"; /* Keepalive, 1 object/prefix, Most specific */
const char *query_end = "-k";
char *reply;
char *serv;
FILE *bulkFile;
int num_lines = 0, i = 0;
char *lines = (char *)malloc(line_size * max_lines);
char *this_line = (char *)malloc(line_size);
size_t whob_query_len = 10 + (strlen(query_begin) * sizeof(char)) + (strlen(query_end) * sizeof(char)) + (line_size * max_lines);
char *whob_query = (char *)malloc(whob_query_len);
reply = NULL;
*whob_query = '\0';
if (!filespec) {
fprintf(stderr,"You must specify a file to use (or '-' for stdin) for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (!strncmp(filespec,"-",1) || use_stdin == 1) {
bulkFile = stdin;
} else
bulkFile = fopen(filespec, "r");
if (!bulkFile) {
fprintf(stderr,"%s: Unable to open \'%s\' for reading.\n",appname,filespec);
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = ripe_ris_server;
while (!feof(bulkFile)) {
if (num_lines >= max_lines && wsess->w_noisy >= 2)
fprintf(stderr,"Processing next batch of %d beginning at line %d.\n",max_lines,(num_lines+1));
memset(lines, 0, line_size * max_lines);
memset(whob_query, 0, whob_query_len);
for (i = 0; i < max_lines; i++) {
if (fgets(this_line,line_size - 1,bulkFile)) {
if (strncmp(this_line, "#", 1) && strncmp(this_line, ";", 1)) {
strcat(lines,this_line);
num_lines++;
if (wsess->w_noisy >= 4)
fprintf(stderr,"Line %d: %s",num_lines,this_line);
}
} else if(feof(bulkFile)) {
if (wsess->w_noisy >= 2)
fprintf(stderr,"End of file reached after reading %d lines.\n",num_lines);
break;
} else if (ferror(bulkFile)) {
if (wsess->w_noisy >= 1)
fprintf(stderr,"Error in stream on line %d.\n",num_lines+1);
break;
}
}
/* prepare the text-string-based query */
strcat(whob_query, query_begin);
strcat(whob_query, lines);
strcat(whob_query, query_end);
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if (wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
free(this_line);
free(lines);
free(whob_query);
free(reply);
return -1;
}
printf("%s",reply);
}
free(this_line);
free(lines);
free(whob_query);
free(reply);
fclose(bulkFile);
return 0;
}
static int w_display_bulkfromfile_cymru(whois_session_params * wsess, char *filespec)
{
const char *query_begin = "begin\n";
const char *query_end = "end";
char *reply;
char *serv;
FILE *bulkFile;
int num_lines = 0, i = 0;
char *lines = (char *)malloc(line_size * max_lines);
char *this_line = (char *)malloc(line_size);
size_t whob_query_len = 10 + (strlen(query_begin) * sizeof(char)) + (strlen(query_end) * sizeof(char)) + (line_size * max_lines);
char *whob_query = (char *)malloc(whob_query_len);
reply = NULL;
*whob_query = '\0';
if (!filespec) {
fprintf(stderr,"You must specify a file to use (or '-' for stdin) for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (!strncmp(filespec,"-",1) || use_stdin == 1) {
bulkFile = stdin;
} else
bulkFile = fopen(filespec, "r");
if (!bulkFile) {
fprintf(stderr,"%s: Unable to open \'%s\' for reading.\n",appname,filespec);
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = cymru_server;
while (!feof(bulkFile)) {
if (num_lines >= max_lines && wsess->w_noisy >= 2)
fprintf(stderr,"Processing next batch of %d beginning at line %d.\n",max_lines,(num_lines+1));
memset(lines, 0, line_size * max_lines);
memset(whob_query, 0, whob_query_len);
for (i = 0; i < max_lines; i++) {
if (fgets(this_line, line_size - 1, bulkFile)) {
if (strncmp(this_line, "#", 1) && strncmp(this_line, ";", 1)) {
strcat(lines, this_line);
num_lines++;
if (wsess->w_noisy >= 4)
fprintf(stderr,"Line %d: %s",num_lines,this_line);
}
} else if(feof(bulkFile)) {
if (wsess->w_noisy >= 2)
fprintf(stderr,"End of file reached after reading %d lines.\n",num_lines);
break;
} else if(ferror(bulkFile)) {
if (wsess->w_noisy >= 1)
fprintf(stderr,"Error in stream on line %d.\n",num_lines+1);
break;
}
}
/* prepare the text-string-based query */
strcat(whob_query, query_begin);
strcat(whob_query, lines);
strcat(whob_query, query_end);
reply = w_ask(serv, whob_query, NULL);
if (!reply) {
if(wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
free(this_line);
free(lines);
free(whob_query);
free(reply);
return -1;
}
printf("%s",reply);
}
free(this_line);
free(lines);
free(whob_query);
free(reply);
fclose(bulkFile);
return 0;
}
static int w_display_pwhois_version(whois_session_params * wsess)
{
char *reply;
char *serv;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
if (wsess->w_noisy)
fprintf(stderr,"Querying '%s' for version/status.\n",serv);
reply = w_ask(serv, "version", NULL);
if (!reply) {
if(wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply);
return 0;
}
static int w_display_myaddress_http(whois_session_params * wsess)
{
char *reply;
char *serv;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = myaddress_server;
if (wsess->w_noisy)
fprintf(stderr,"Querying '%s' for my public address.\n",serv);
reply = w_ask(serv, "Accept:*/*\nHost: myaddress.today\nUser-Agent: WhoB\nGET /\n\n", "80");
if (!reply) {
if(wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply);
return 0;
}
static int w_display_myaddress(whois_session_params * wsess)
{
char *reply;
char *serv;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
if (wsess->w_noisy)
fprintf(stderr,"Querying '%s' for my public address.\n",serv);
reply = w_ask(serv, "whoami", NULL);
if (!reply) {
if(wsess->w_noisy)
fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply);
return 0;
}
static int w_display_pwhois_gigo(whois_session_params * wsess, char *user_query)
{
char *reply;
char *serv;
if (strlen(wsess->pw_serv) > 0)
serv = wsess->pw_serv;
else
serv = pwhois_server;
if (wsess->w_noisy)
fprintf(stderr,"Querying '%s' for: '%s'\n",serv,user_query);
reply = w_ask(serv, user_query, NULL);
if (!reply) {
if (wsess->w_noisy) fprintf(stderr,"No reply from %s.\n",serv);
return -1;
}
printf("%s",reply);
free(reply);
return 0;
}
#endif
int
w_lookup_all_pwhois_bulk(whois_session_params * wsess, struct ip_list_array *iplist)
{
token_t *responses;
char *reply;
const char *bulk_begin = "begin\n";
const char *bulk_end = "end\n";
char *bulk_ip_query = NULL;
int i = 0, k = 0, entity_id = 0;
unsigned int j = 0;
char *value = NULL;
if (!iplist)
return -1;
if ((uintptr_t)(*iplist).application) {
bulk_ip_query = (char *)malloc(((strlen((*iplist).application) * sizeof(char)) +10) + ((strlen(bulk_begin) + strlen(bulk_end) + 1) * sizeof(char)) + (16 * (*iplist).numItems));
} else
bulk_ip_query = (char *)malloc(((strlen(appname) * sizeof(char)) +10) + ((strlen(version) + strlen(bulk_begin) + strlen(bulk_end) + 1) * sizeof(char)) + (16 * (*iplist).numItems));
*bulk_ip_query = '\0';
/* clean up the response data set in case the caller doesn't (and we return error) */
for (i = 0; i < (*iplist).numItems; i++) {
(*iplist).asn[(i)] = 0;
memset((*iplist).netName[i],0,sizeof((*iplist).netName[i]));
memset((*iplist).orgName[i],0,sizeof((*iplist).orgName[i]));
}
/* prepare the text-string-based query */
strcat(bulk_ip_query,bulk_begin);
if ((uintptr_t)(*iplist).application) {
strcat(bulk_ip_query, "app=\"");
strcat(bulk_ip_query, (*iplist).application);
strcat(bulk_ip_query, "\"\n");
} else {
strcat(bulk_ip_query, "app=\"");
strcat(bulk_ip_query, appname);
strcat(bulk_ip_query, " ");
strcat(bulk_ip_query, version);
strcat(bulk_ip_query, "\"\n");
}
for (i = 0; i < ((*iplist).numItems); i++) {
strcat(bulk_ip_query, inet_ntoa((*iplist).ipaddr[i]));
strcat(bulk_ip_query, "\n");
}
strcat(bulk_ip_query, bulk_end);
reply = w_ask(pwhois_server, bulk_ip_query, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",pwhois_server);
else
fprintf(stderr,"No reply from %s.\n",pwhois_server);
}
/* clean up the response data set in case the caller doesn't */
for (i = 0; i < (*iplist).numItems; i++)
(*iplist).asn[(i)] = 0;
return -1;
}
responses = tokens(reply, "\n");
for(i = 0; responses[i].ptr; i++){
value = NULL;
// printf("LINE %d: '%s'\n",i, responses[i].ptr);
if((value = match_prefix("IP:", responses[i].ptr)) != NULL){
/* if any keys matched, increment the id of the array */
if(k > 0){
entity_id++;
k = 0;
}
} else
if((value = match_prefix("origin-as:", responses[i].ptr)) != NULL) {
rm_spaces(value); /* strip out any spaces from the ASN */
for(j = 0; j < strlen(value); j++) {
if(!isdigit(value[j])){
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
else
fprintf(stderr,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
if ((int)strtol(value, (char **)NULL, 10)) {
(*iplist).asn[(entity_id)] = strtol(value, (char **)NULL, 10);
k++;
} else {
(*iplist).asn[(entity_id)] = 0;
k++;
}
} else if ((value = match_prefix("org-name:", responses[i].ptr))) {
strncpy((*iplist).orgName[entity_id],value,100);
k++;
} else if ((value = match_prefix("net-name:", responses[i].ptr))) {
strncpy((*iplist).netName[entity_id],value,32);
k++;
}
if(value)
free(value);
if ((entity_id+1) > (*iplist).numItems)
break;
}
free(responses);
free(reply);
free(bulk_ip_query);
return 0;
}
int
w_lookup_all_pwhois_bulk_ext(whois_session_params * wsess, struct ext_ip_list_array *iplist)
{
token_t *responses;
char *reply;
const char *bulk_begin = "begin\n";
const char *bulk_end = "end\n";
char *bulk_ip_query = NULL;
int i=0;
unsigned int j=0;
int k=0;
int pntcnt;
int entity_id = 0;
char *value = NULL;
if (!iplist)
return -1;
iplist->geoavailable=0;
if ((uintptr_t)(*iplist).application) {
bulk_ip_query = malloc(((strlen((*iplist).application) * sizeof(char)) +10) + ((strlen(bulk_begin) + strlen(bulk_end) + 1) * sizeof(char)) + (16 * (*iplist).numItems));
} else bulk_ip_query = malloc(((strlen(appname) * sizeof(char)) +10) + ((strlen(version) + strlen(bulk_begin) + strlen(bulk_end) + 1) * sizeof(char)) + (16 * (*iplist).numItems));
bulk_ip_query[0]=0;
/* clean up the response data set in case the caller doesn't (and we return error) */
for (i = 0; i < (*iplist).numItems; i++) {
(*iplist).asn[(i)] = 0;
memset((*iplist).netName[i],0,sizeof((*iplist).netName[i]));
memset((*iplist).orgName[i],0,sizeof((*iplist).orgName[i]));
}
/* prepare the text-string-based query */
strcat(bulk_ip_query,bulk_begin);
if ((uintptr_t)(*iplist).application) {
strcat(bulk_ip_query,"app=\"");
strcat(bulk_ip_query,(*iplist).application);
strcat(bulk_ip_query,"\"\n");
} else {
strcat(bulk_ip_query,"app=\"");
strcat(bulk_ip_query,appname);
strcat(bulk_ip_query," ");
strcat(bulk_ip_query,version);
strcat(bulk_ip_query,"\"\n");
}
for (i = 0; i < ((*iplist).numItems); i++) {
strcat(bulk_ip_query,inet_ntoa((*iplist).ipaddr[i]));
strcat(bulk_ip_query,"\n");
}
strcat(bulk_ip_query,bulk_end);
reply = w_ask(pwhois_server, bulk_ip_query, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",pwhois_server);
else
fprintf(stderr,"No reply from %s.\n",pwhois_server);
}
/* clean up the response data set in case the caller doesn't */
for (i = 0; i < (*iplist).numItems; i++)
(*iplist).asn[(i)] = 0;
return -1;
}
responses = tokens(reply, "\n");
for (i = 0; responses[i].ptr; i++) {
value = NULL;
// printf("LINE %d: '%s'\n",i, responses[i].ptr);
if ((value = match_prefix("IP:", responses[i].ptr)) != NULL) {
/* if any keys matched, increment the id of the array */
if (k > 0) { entity_id++; k = 0; }
} else
if ((value = match_prefix("origin-as:", responses[i].ptr)) != NULL) {
rm_spaces(value); /* strip out any spaces from the ASN */
for (j = 0; j < strlen(value); j++) {
if (!isdigit(value[j])) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
else
fprintf(stderr,"Parse error at \'%c\': non-numeric value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
if(atoi(value)) {
(*iplist).asn[(entity_id)] = atoi(value);
k++;
} else {
(*iplist).asn[(entity_id)] = 0;
k++;
}
} else if ((value = match_prefix("as-org-name-source:", responses[i].ptr))) {
strncpy((*iplist).asOrgNameSource[entity_id],value,20);
k++;
} else if ((value = match_prefix("org-name-source:", responses[i].ptr))) {
strncpy((*iplist).orgNameSource[entity_id],value,20);
k++;
} else if ((value = match_prefix("net-name-source:", responses[i].ptr))) {
strncpy((*iplist).netNameSource[entity_id],value,20);
k++;
} else if ((value = match_prefix("prefix:", responses[i].ptr))) {
strncpy((*iplist).prefix[entity_id],value,20);
k++;
} else if ((value = match_prefix("org-name:", responses[i].ptr))) {
strncpy((*iplist).orgName[entity_id],value,100);
k++;
} else if ((value = match_prefix("net-name:", responses[i].ptr))) {
strncpy((*iplist).netName[entity_id],value,32);
k++;
} else if ((value = match_prefix("longitude:", responses[i].ptr))) {
rm_spaces(value); /* strip out any spaces from the LONGITUDE */
for (j = 0, pntcnt = 0; j < strlen(value); j++) {
if(value[j]=='.')
pntcnt++;
if (!isdigit(value[j]) && (value[j]!='.' || pntcnt>1)) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': can't parse value at position %d of %s).\n",value[i],i,value);
else
fprintf(stderr,"Parse error at \'%c\': can't parse value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
(*iplist).longitude[(entity_id)]=atof(value);
iplist->geoavailable++;
k++;
} else if ((value = match_prefix("latitude:", responses[i].ptr))) {
rm_spaces(value); /* strip out any spaces from the LONGITUDE */
for (j = 0, pntcnt = 0; j < strlen(value); j++) {
if(value[j]=='.')
pntcnt++;
if (!isdigit(value[j]) && (value[j]!='.' || pntcnt>1)) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"Parse error at \'%c\': can't parse value at position %d of %s).\n",value[i],i,value);
else
fprintf(stderr,"Parse error at \'%c\': can't parse value at position %d of %s).\n",value[i],i,value);
}
break;
}
}
(*iplist).latitude[(entity_id)]=atof(value);
iplist->geoavailable++;
k++;
} else if ((value = match_prefix("city:", responses[i].ptr))) {
strncpy((*iplist).city[entity_id],value,50);
iplist->geoavailable++;
k++;
} else if ((value = match_prefix("country:", responses[i].ptr))) {
strncpy((*iplist).country[entity_id],value,50);
iplist->geoavailable++;
k++;
} else if ((value = match_prefix("region:", responses[i].ptr))) {
strncpy((*iplist).state[entity_id],value,50);
iplist->geoavailable++;
k++;
}
if(value)
free(value);
if ((entity_id+1) > (*iplist).numItems)
break;
}
free(responses); free(reply); free(bulk_ip_query);
return 0;
}
static char *
w_lookup_netname_other(whois_session_params * wsess, char *addr, char *serv)
{
token_t *ls;
ip_blk_t *a = NULL, *b = NULL;
char *reply, *ans = NULL;
int i;
int use_this = 1;
if (!addr || !serv)
return NULL;
reply = w_ask(serv, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",serv);
else
fprintf(stderr,"No reply from %s.\n",serv);
}
return NULL;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
char *value=NULL;
if ((value = match_prefix("inetnum:", ls[i].ptr))) {
a = match_ipprefix(value);
if (b) {
if (((b->end - b->start) > (a->end - a->start))) {
use_this = 1;
free(b);
b = a;
a = NULL;
} else {
use_this = 0;
free(a);
a = NULL;
}
} else {
use_this = 1;
b = a;
a = NULL;
}
free(value);
} else
if (use_this && (value = match_prefix("netname:", ls[i].ptr))) {
if (ans)
free(ans);
ans = value;
}
}
free(ls); free(reply); if (b) free(b);
return ans;
}
char *
w_lookup_netname(whois_session_params * wsess, char *addr)
{
token_t *ls;
ip_blk_t *a = NULL, *b = NULL;
char *na = NULL, *nb = NULL;
char *reply, *ans = NULL;
int i;
int have_new, have_old;
if (!addr)
return NULL;
reply = w_ask(arin_server, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",arin_server);
else
fprintf(stderr,"No reply from %s.\n",arin_server);
}
return NULL;
}
ls = tokens(reply, "\n");
ans = NULL;
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_prefix("netname:", ls[i].ptr))) {
ans = value;
break;
}
}
if (!ans) {
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_inparens(ls[i].ptr))) {
char *after = match_afterparens(ls[i].ptr);
if (after) {
na = value;
a = match_iprange(after);
} else {
na = value;
if (ls[i+1].ptr && (a = match_iprange(ls[i+1].ptr))) {
/* successful match */
} else { /* Bad format */
free(na); na = NULL;
continue;
}
}
}
have_new = (na && a);
have_old = (nb && b);
if (have_new) {
if (have_old) {
if (((b->end - b->start) > (a->end - a->start))) {
/* keep new, discard old */
free(nb); free(b);
nb = na; na = NULL;
b = a; a = NULL;
} else { /* keep old, discard new */
free(na); free(a);
na = NULL;
a = NULL;
}
} else { /* nothing old, save new */
nb = na; na = NULL;
b = a; a = NULL;
}
}
} /* loop */
if (na) free(na);
if (a) free(a);
if (b) free(b);
free(ls); free(reply);
if (!nb)
return NULL;
/* Add "!" to the beginning of the question */
na = malloc(strlen(nb) + 2);
strcpy(&na[1], nb);
na[0] = '!';
free(nb);
reply = w_ask(arin_server, na, NULL);
free(na);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",arin_server);
else
fprintf(stderr,"No reply from %s.\n",arin_server);
}
return NULL;
}
ls = tokens(reply, "\n");
}
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_prefix("netname:", ls[i].ptr))) {
ans = value;
break;
}
}
free(ls); free(reply);
{
char *other = NULL;
if (ans && strstr(ans, "RIPE")) {
other = w_lookup_netname_other(wsess, addr, ripe_server);
}
if (ans && !strncmp(ans, "APNIC", 5)) {
other = w_lookup_netname_other(wsess, addr, apnic_server);
}
if (other) {
char *together = malloc(strlen(ans) + strlen(other) + 2);
together[0]=0;
strcpy(together, ans);
strcat(together, "/");
strcat(together, other);
free(ans);
ans = together;
}
}
return ans;
}
static char *
w_lookup_orgname_other(whois_session_params * wsess, char *addr, char *serv)
{
token_t *ls;
ip_blk_t *a = NULL, *b = NULL;
char *reply, *ans = NULL;
int i;
int use_this = 1;
if (!addr || !serv)
return NULL;
reply = w_ask(serv, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",serv);
else
fprintf(stderr,"No reply from %s.\n",serv);
}
return NULL;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
char *value=NULL;
if ((value = match_prefix("inetnum:", ls[i].ptr))) {
a = match_ipprefix(value);
if (b) {
if (((b->end - b->start) > (a->end - a->start))) {
use_this = 1;
free(b);
b = a;
a = NULL;
} else {
use_this = 0;
free(a);
a = NULL;
}
} else {
use_this = 1;
b = a;
a = NULL;
}
free(value);
}else
if (use_this && (value = match_prefix("orgname:", ls[i].ptr))) {
if (ans)
free(ans);
ans = value;
}
}
if (!ans) {
for (i = 0; ls[i].ptr; i++) {
char *value;
if (use_this && (value = match_prefix("descr:", ls[i].ptr))) {
if (ans)
free(ans);
ans = value;
break;
}
}
}
free(ls); free(reply); if (b) free(b);
return ans;
}
char *
w_lookup_orgname(whois_session_params * wsess, char *addr)
{
token_t *ls;
ip_blk_t *a = NULL, *b = NULL;
char *na = NULL, *nb = NULL;
char *reply, *ans = NULL;
int i;
int have_new, have_old;
if (!addr)
return NULL;
reply = w_ask(arin_server, addr, NULL);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",arin_server);
else
fprintf(stderr,"No reply from %s.\n",arin_server);
}
return NULL;
}
ls = tokens(reply, "\n");
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_prefix("netname:", ls[i].ptr))) {
ans = value;
break;
}
}
if (!ans) {
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_inparens(ls[i].ptr))) {
char *after = match_afterparens(ls[i].ptr);
if (after) {
na = value;
a = match_iprange(after);
} else {
na = value;
if (ls[i+1].ptr && (a = match_iprange(ls[i+1].ptr))) {
/* successful match */
} else { /* Bad format */
free(na); na = NULL;
continue;
}
}
}
have_new = (na && a);
have_old = (nb && b);
if (have_new) {
if (have_old) {
if (((b->end - b->start) > (a->end - a->start))) {
/* keep new, discard old */
free(nb); free(b);
nb = na; na = NULL;
b = a; a = NULL;
} else { /* keep old, discard new */
free(na); free(a);
na = NULL;
a = NULL;
}
} else { /* nothing old, save new */
nb = na; na = NULL;
b = a; a = NULL;
}
}
} /* loop */
if (na) free(na);
if (a) free(a);
if (b) free(b);
free(ls); free(reply);
if (!nb)
return NULL;
/* Add "!" to the beginning of the question */
na = malloc(strlen(nb) + 2);
strcpy(&na[1], nb);
na[0] = '!';
free(nb);
reply = w_ask(arin_server, na, NULL);
free(na);
if (!reply) {
if (wsess->w_noisy)
{
if(wsess->logprintfCookie)
lft_printf(wsess->logprintfCookie,"No reply from %s.\n",arin_server);
else
fprintf(stderr,"No reply from %s.\n",arin_server);
}
return NULL;
}
ls = tokens(reply, "\n");
}
for (i = 0; ls[i].ptr; i++) {
char *value;
if ((value = match_prefix("orgname:", ls[i].ptr))) {
if(ans)
free(ans);
ans = value;
break;
}
}
free(ls); free(reply);
{
char *other = NULL;
if (ans && strstr(ans, "RIPE")) {
other = w_lookup_orgname_other(wsess, addr, ripe_server);
}
if (ans && (!strncmp(ans, "APNIC", 5) || strstr(ans, "Asia Pacific Net") )) {
other = w_lookup_orgname_other(wsess, addr, apnic_server);
}
if (other) {
/* char *together = malloc(strlen(ans) + strlen(other) + 4);
strcpy(together, other);
strcat(together, " (");
strcat(together, ans);
strcat(together, ")");
*/
free(ans);
ans = other;
}
}
return ans;
}
#ifdef STANDALONE
/*---------------------------------------------------------------------------*/
void lft_printf(lft_session_params * sess, const char *templ, ...)
{
va_list ap;
char buf[1024];
(void)sess;
va_start (ap, templ);
vsprintf(buf, templ, ap);
va_end (ap);
printf("%s",buf);
}
/*---------------------------------------------------------------------------*/
static void
usage (char *prog)
{
fprintf (stderr,
"\nWhoB - version %s\n\n"
" - a likable whois client from the Prefix WhoIs project\n"
" visit http://www.pwhois.org\n"
"\nUsage: %s [-g] [] \n"
"\nMainstream Options:\n"
" -g Disable GIGO mode; enable other options then submit query\n"
" -R Display the Origin-AS on file at the RADB/IRR also\n"
" -p Display the AS-Path learned by the pWhoIs server (pWhoIs-only)\n"
" -n Display the network name on file at the registrar\n"
" -t Display the date the route was last updated (pWhoIs-only)\n"
" -u Display the date the route was last updated in GMT (pWhoIs-only)\n"
" -o Disable display of the organization\'s name on file at the registrar\n"
"\nAdvanced Options:\n"
" -h host Specify your own pWhoIs-compatible server to query\n"
" -f file Read from 'file' (or '-' as stdin) as bulk input to pWhoIs\n"
" -c Use Cymru\'s whois server instead of pWhoIs\n"
" -r Use RIPE NCC\'s RIS whois server instead of pWhoIs\n"
"\nPrefix WhoIs Advanced Options:\n"
" -A Display all routes transiting the target ASN (pWhoIs-only)\n"
" -a Display all routes announced by the target ASN (pWhoIs-only)\n"
" -P Display all routes respective to a target prefix (pWhoIs-only)\n"
" -N Display all networks registered to the target ASN (pWhoIs-only)\n"
" -O Display organizational contact info for the target ASN (pWhoIs-only)\n"
"\nVerbosity Options and Status:\n"
" -s Display the version and status of the pWhoIs server (pWhoIs-only)\n"
" -V Display verbose/debug output. Use more \'V\'s for additional detail\n"
" -v Display WhoB\'s version information and exit\n"
" me|whoami Display the public IP address of this host\n"
"\n"
,version,prog);
fprintf(stderr,"Example: %s -gnp 1.2.3.4\n",prog);
fprintf(stderr,"Returns: IP Address | ASN-by-prefix (prefix) | AS-Path | NetName | OrgName\n\n");
exit(EXIT_FAILURE);
}
static void
show_startup_msgs (whois_session_params * wsess)
{
if (wsess->w_noisy) {
fprintf(stderr,"WhoB version %s firing up...",version);
if (wsess->w_noisy > 1) fprintf(stderr," (verbosity level %d)\n",wsess->w_noisy); else printf ("\n");
if (wsess->w_noisy > 1) {
fprintf(stderr,"Data sources:");
if ((strlen(wsess->pw_serv) > 0) && (!use_cymru || read_from_file)) fprintf(stderr," %s (pWhoIs)",wsess->pw_serv);
else if ((!use_cymru || read_from_file) && !use_riswhois) fprintf(stderr," %s (pWhoIs)", pwhois_server);
else if (!use_cymru) fprintf(stderr," %s (RIPE NCC)", ripe_ris_server);
if (use_cymru && !read_from_file) fprintf(stderr," %s (Cymru)",cymru_server);
if (display_radb_as) fprintf(stderr,", %s (RADB)",radb_server);
fprintf(stderr,".\n");
if (read_from_file) {
if (cymrufromfile) fprintf(stderr,"Using Cymru for bulk file resolution.\n");
else if (riswhoisfromfile) fprintf(stderr,"Using RIPE NCC for bulk file resolution.\n");
else fprintf(stderr,"Using Prefix WhoIs for bulk file resolution.\n");
}
}
if (show_routes_byprefix == 1 && (show_routes_byasn == 1 || show_routes_bytransitasn == 1)) {
fprintf(stderr,"You may only perform routeviews one at a time. Using by-ASN.\n");
show_routes_byprefix = 0;
}
}
}
int main(int ac, char **av)
{
struct hostent *he, *pwhost;
char *addr = NULL;
struct in_addr in, pws;
int ch;
int user_asn = 0;
char user_asn_buf[10];
whois_session_params * wsess;
memset(&hostname, 0, sizeof(hostname));
wsess = w_init();
setbuf(stdout, NULL);
while ((ch = getopt (ac, av, "AaCcfgNnOopPRrstuVvh:w:")) != EOF)
switch (ch) {
case 'a':
use_gigo = 0;
show_routes_byasn = 1;
go_interactive = 1;
break;
case 'A':
use_gigo = 0;
show_routes_bytransitasn = 1;
go_interactive = 1;
break;
case 'N':
use_gigo = 0;
show_networks_byasn = 1;
go_interactive = 1;
break;
case 'O':
use_gigo = 0;
show_contacts_byasn = 1;
go_interactive = 1;
break;
case 's':
use_gigo = 0;
show_server_status = 1;
go_interactive = 1;
break;
case 'P':
use_gigo = 0;
show_routes_byprefix = 1;
go_interactive = 1;
break;
case 'v':
usage(av[0]);
break;
case 'u': /* show all times in UTC */
#if defined(sun)
if(putenv("TZ=GMT0") == -1) {
fprintf(stderr, "%s: Unable to set TZ to UTC.",appname);
}
#else
#if !defined(WIN32) && !defined(_WIN32)
if (setenv("TZ", "GMT0", 1) == -1) {
fprintf(stderr, "%s: Unable to set TZ to UTC.",appname);
}
#endif
#endif
show_cache_date = 1;
break;
case 't':
show_cache_date = 1;
break;
case 'w':
if (strlen(optarg) > max_hostname_input) {
fprintf(stderr,"Sorry, the server name you supplied was unreasonably long.\n");
exit(EXIT_FAILURE);
}
if (inet_aton(optarg, &pws)) {
strncpy(wsess->pw_serv, optarg, strlen(optarg));
} else {
if (!(pwhost = gethostbyname(optarg))) {
fprintf(stderr,"Sorry, I cannot resolve \'%s\' to use as your pWhoIs server.\n", optarg);
exit(EXIT_FAILURE);
}
memcpy(&pws, pwhost->h_addr, pwhost->h_length);
strncpy(wsess->pw_serv,inet_ntoa(pws),strlen(inet_ntoa(pws)));
}
break;
case 'h':
if (strlen(optarg) > max_hostname_input) {
fprintf(stderr,"Sorry, the server name you supplied was unreasonably long.\n");
exit(EXIT_FAILURE);
}
if (inet_aton(optarg, &pws)) {
strncpy(wsess->pw_serv,optarg,strlen(optarg));
} else {
if (!(pwhost = gethostbyname(optarg))) {
fprintf(stderr,"Sorry, I cannot resolve \'%s\' to use as your pWhoIs server.\n", optarg);
exit(EXIT_FAILURE);
}
memcpy(&pws, pwhost->h_addr, pwhost->h_length);
strncpy(wsess->pw_serv,inet_ntoa(pws),strlen(inet_ntoa(pws)));
}
break;
case 'c':
use_cymru = 1;
/* cymrufromfile = 1; */ /* Use pwhois Cymru compatibility mode by default */
break;
case 'C':
use_cymru = 1;
cymrufromfile = 1;
break;
case 'n':
display_netname = 1;
go_interactive = 1;
break;
case 'r':
use_riswhois = 1;
riswhoisfromfile = 1;
break;
case 'R':
display_radb_as = 1;
go_interactive = 1;
break;
case 'o':
display_orgname = 0;
go_interactive = 1;
break;
case 'p':
display_aspath = 1;
go_interactive = 1;
break;
case 'f':
use_gigo = 0;
read_from_file = 1;
break;
case 'V':
wsess->w_noisy++;
break;
case 'g':
use_gigo = 0;
go_interactive = 1;
break;
default:
usage (av[0]);
}
/* Catch hostname input without any arguments */
if ((ac - optind) > 0)
go_interactive = 1;
if (go_interactive > 0) {
/* Quickly check stdin for input to avoid David having to type */
/* '-f -' to pipe into to whob, even if it has args :-) */
fd_set rfds;
struct timeval timev;
int selretval;
/* Watch stdin (fd 0) briefly for input. */
FD_ZERO(&rfds);
FD_SET(0, &rfds);
timev.tv_sec = 0;
timev.tv_usec = 100;
selretval = select(1, &rfds, NULL, NULL, &timev);
if (selretval) {
/* There's input in them there hills, treat it as the input file */
use_gigo = 0;
read_from_file = 1;
use_stdin = 1;
}
/*
else
if (wsess->w_noisy) fprintf(stderr,"No input found on stdin.\n");
*/
} else if (read_from_file < 1) {
/* No indication we should be interactive based on arguments, so wait for STDIN */
use_gigo = 0;
read_from_file = 1;
use_stdin = 1;
}
if (((ac - optind) < 1) && (show_server_status != 1) && (go_interactive > 0))
usage (av[0]);
/* Show the verbose startup information if verbosity is enabled/requested */
show_startup_msgs(wsess);
if (show_server_status == 1) {
w_display_pwhois_version(wsess);
exit(EXIT_FAILURE);
} else if ((read_from_file > 0 && use_stdin < 1) || go_interactive > 0) {
if (strlen(av[optind]) > max_hostname_input) {
fprintf(stderr,"Sorry, the subject name you supplied was unreasonably long.\n");
exit(EXIT_FAILURE);
} else {
strncpy(hostname,av[optind],strlen(av[optind]));
optind++;
}
}
if (read_from_file) {
if (riswhoisfromfile)
w_display_bulkfromfile_riswhois(wsess, hostname);
else if (cymrufromfile)
w_display_bulkfromfile_cymru(wsess, hostname);
else
w_display_bulkfromfile_pwhois(wsess, hostname);
exit(EXIT_SUCCESS);
}
if (use_gigo > 0) {
if (strncmp(hostname,"me",2) == 0 || strncmp(hostname,"whoami",6) == 0) {
w_display_myaddress(wsess);
exit(EXIT_SUCCESS);
} else {
w_display_pwhois_gigo(wsess, hostname);
exit(EXIT_SUCCESS);
}
}
if ((show_routes_byasn || show_routes_bytransitasn || show_contacts_byasn || show_networks_byasn) && (strlen(hostname) <= 10) && atoi(hostname) && stricontains(hostname,".") < 1) {
user_asn = atoi(hostname);
if (wsess->w_noisy > 1) fprintf(stderr,"Using user-supplied ASN %d for lookup.\n",user_asn);
} else if (show_routes_byprefix == 1) {
printf("Displaying all routes for prefix %s.\n",hostname);
} else {
if (strncmp(hostname,"me",2) == 0 || strncmp(hostname,"whoami",6) == 0) {
w_display_myaddress(wsess);
exit(EXIT_SUCCESS);
}
if (inet_aton(hostname, &in)) {
addr = hostname;
} else {
if (!(he = gethostbyname(hostname))) {
fprintf(stderr,"Sorry, I cannot resolve \'%s\'\n", hostname);
exit(EXIT_FAILURE);
}
memcpy(&in, he->h_addr, he->h_length);
addr = inet_ntoa(in);
}
}
if (show_routes_byasn) {
if (user_asn > 0) {
printf("Displaying all routes whose Origin-AS is %d.\n", user_asn);
snprintf(user_asn_buf,9,"%d",user_asn);
w_display_rvbyasn_pwhois(wsess, user_asn_buf);
} else {
w_lookup_all_pwhois(wsess, addr);
if (atoi(wsess->consolidated_asn)) {
printf("Displaying all routes whose Origin-AS is %s.\n", wsess->consolidated_asn);
w_display_rvbyasn_pwhois(wsess, wsess->consolidated_asn);
} else {
printf("Sorry, unable to resolve the ASN for %s (%s) at this time.\n",hostname,addr);
}
}
} else if (show_routes_bytransitasn) {
if (user_asn > 0) {
printf("Displaying all routes whose Transit-AS is %d.\n", user_asn);
snprintf(user_asn_buf,9,"%d",user_asn);
w_display_rvbytransitasn_pwhois(wsess, user_asn_buf);
} else {
w_lookup_all_pwhois(wsess, addr);
if (atoi(wsess->consolidated_asn)) {
printf("Displaying all routes whose Transit-AS is %s.\n", wsess->consolidated_asn);
w_display_rvbytransitasn_pwhois(wsess, wsess->consolidated_asn);
} else {
printf("Sorry, unable to resolve the ASN for %s (%s) at this time.\n",hostname,addr);
}
}
} else if (show_networks_byasn) {
if (user_asn > 0) {
printf("Displaying all networks registered to the Origin-AS %d.\n", user_asn);
snprintf(user_asn_buf,9,"%d",user_asn);
w_display_networksbyasn_pwhois(wsess, user_asn_buf);
} else {
w_lookup_all_pwhois(wsess, addr);
if (atoi(wsess->consolidated_asn)) {
printf("Displaying all networks registered to the Origin-AS %s.\n", wsess->consolidated_asn);
w_display_networksbyasn_pwhois(wsess, wsess->consolidated_asn);
} else {
printf("Sorry, unable to resolve the ASN for %s (%s) at this time.\n",hostname,addr);
}
}
} else if (show_contacts_byasn) {
if (user_asn > 0) {
printf("Displaying all contact info on file for Origin-AS %d.\n", user_asn);
snprintf(user_asn_buf,9,"%d",user_asn);
w_display_contactsbyasn_pwhois(wsess, user_asn_buf);
} else {
w_lookup_all_pwhois(wsess, addr);
if (atoi(wsess->consolidated_asn)) {
printf("Displaying all contact info on file for Origin-AS %s.\n", wsess->consolidated_asn);
w_display_contactsbyasn_pwhois(wsess, wsess->consolidated_asn);
} else {
printf("Unable to resolve the ASN for %s (%s) at this time.\n",hostname,addr);
}
}
} else if (show_routes_byprefix) {
w_display_rvbyprefix_pwhois(wsess, hostname);
} else {
printf("%s | Searching...", addr);
if (use_cymru) {
printf("\b\b\b\b\b\b\b\b\b\b\b\b");
printf("origin-as %d ", w_lookup_as_cymru(wsess, addr));
} else if (use_riswhois) {
w_lookup_all_riswhois(wsess, addr);
printf("\b\b\b\b\b\b\b\b\b\b\b\b");
printf("origin-as %s (%s) ", wsess->consolidated_asn, wsess->consolidated_route);
} else {
w_lookup_all_pwhois(wsess, addr);
printf("\b\b\b\b\b\b\b\b\b\b\b\b");
printf("origin-as %s (%s) ", wsess->consolidated_asn, wsess->consolidated_route);
if (show_cache_date && (strlen(wsess->tbuf) > 0))
printf("| %s ", wsess->tbuf);
}
if (display_radb_as)
printf("| radb-as %d ", w_lookup_as(wsess, addr));
if ((display_aspath) && (!use_cymru) && (!use_riswhois))
printf("| as-path %s ", wsess->consolidated_asp);
if (display_netname) {
if (use_cymru) {
printf("| %s ", w_lookup_netname(wsess, addr));
} else if (use_riswhois) {
if (!display_orgname)
printf("| %s ", wsess->consolidated_netname);
} else {
printf("| %s ", wsess->consolidated_netname);
}
}
if (display_orgname) {
if (use_cymru) {
printf("| %s ", w_lookup_orgname(wsess, addr));
} else {
printf("| %s ", wsess->consolidated_orgname);
}
}
printf("\n");
}
w_close(wsess);
exit(EXIT_SUCCESS);
}
#endif
lft-3.8/configure 000755 000766 000000 00000511150 12732330274 014006 0 ustar 00vic wheel 000000 000000 #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
#
# Copyright (C) 1992-1996, 1998-2012 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 more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
as_myself=
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
IFS=$as_save_IFS
;;
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
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# Use a proper internal environment variable to ensure we don't fall
# into an infinite loop, continuously re-executing ourselves.
if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
_as_can_reexec=no; export _as_can_reexec;
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
fi
# We don't want this to propagate to other subprocesses.
{ _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
# is contrary to our usage. Disable this feature.
alias -g '\${1+\"\$@\"}'='\"\$@\"'
setopt NO_GLOB_SUBST
else
case \`(set -o) 2>/dev/null\` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
"
as_required="as_fn_return () { (exit \$1); }
as_fn_success () { as_fn_return 0; }
as_fn_failure () { as_fn_return 1; }
as_fn_ret_success () { return 0; }
as_fn_ret_failure () { return 1; }
exitcode=0
as_fn_success || { exitcode=1; echo as_fn_success failed.; }
as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
test \$(( 1 + 1 )) = 2 || exit 1"
if (eval "$as_required") 2>/dev/null; then :
as_have_required=yes
else
as_have_required=no
fi
if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_found=false
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
as_found=:
case $as_dir in #(
/*)
for as_base in sh bash ksh sh5; do
# Try only shells that exist, to save several forks.
as_shell=$as_dir/$as_base
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
CONFIG_SHELL=$as_shell as_have_required=yes
if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
break 2
fi
fi
done;;
esac
as_found=false
done
$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
CONFIG_SHELL=$SHELL as_have_required=yes
fi; }
IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
export CONFIG_SHELL
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
fi
if test x$as_have_required = xno; then :
$as_echo "$0: This script requires a shell more modern than all"
$as_echo "$0: the shells that I found on your system."
if test x${ZSH_VERSION+set} = xset ; then
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
$0: including any error possibly output before this
$0: message. Then install a modern shell, or manually run
$0: the script under such a shell if you do have one."
fi
exit 1
fi
fi
fi
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
# Unset more variables known to interfere with behavior of common tools.
CLICOLOR_FORCE= GREP_OPTIONS=
unset CLICOLOR_FORCE GREP_OPTIONS
## --------------------- ##
## M4sh Shell Functions. ##
## --------------------- ##
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; 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
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# 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
as_lineno_1=$LINENO as_lineno_1a=$LINENO
as_lineno_2=$LINENO as_lineno_2a=$LINENO
eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
# Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# If we had to re-execute with $CONFIG_SHELL, we're ensured to have
# already done that, so ensure we don't try to do so again and fall
# in an infinite loop. This has already happened in practice.
_as_can_reexec=no; export _as_can_reexec
# 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 sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
test -n "$DJDIR" || exec 7<&0 &1
# Name of the host.
# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME=
PACKAGE_TARNAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_BUGREPORT=
PACKAGE_URL=
ac_unique_file="lft_ifname.h"
# Factoring default headers for most tests.
ac_includes_default="\
#include
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_SYS_STAT_H
# include
#endif
#ifdef STDC_HEADERS
# include
# include
#else
# ifdef HAVE_STDLIB_H
# include
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include
# endif
# include
#endif
#ifdef HAVE_STRINGS_H
# include
#endif
#ifdef HAVE_INTTYPES_H
# include
#endif
#ifdef HAVE_STDINT_H
# include
#endif
#ifdef HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='LTLIBOBJS
LIBOBJS
ALLOCA
EGREP
GREP
CPP
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
SET_MAKE
LN_S
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_URL
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_universal
enable_gtod
with_pcap
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# 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.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
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
case $ac_option in
*=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*=) ac_optarg= ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-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)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$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 ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$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 ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
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 ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$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_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=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 ;;
-*) as_fn_error $? "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information"
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
case $ac_envvar in #(
'' | [0-9]* | *[!_$as_cr_alnum]* )
as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
esac
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_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'`
as_fn_error $? "missing argument to $ac_option"
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
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
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
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
as_fn_error $? "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
as_fn_error $? "pwd does not report name of working directory"
# 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 the parent directory.
ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_myself" : 'X\(//\)[^/]' \| \
X"$as_myself" : 'X\(//\)$' \| \
X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
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
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
eval ac_env_${ac_var}_set=\${${ac_var}+set}
eval ac_env_${ac_var}_value=\$${ac_var}
eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
eval ac_cv_env_${ac_var}_value=\$${ac_var}
done
#
# 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 this package 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 \`..']
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]
--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]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_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]
_ACEOF
fi
if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-universal whether to include intel and ppc arch for Mac OS X
--enable-gtod use gettimeofday instead of pcap timestamps
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pcap=PATH specify path to pcap library
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
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS (Objective) 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 the package provider.
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested 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
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
generated by GNU Autoconf 2.69
Copyright (C) 2012 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
fi
## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##
# ac_fn_c_try_compile LINENO
# --------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_cpp ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } > conftest.i && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
# the include files in INCLUDES and setting the cache variable VAR
# accordingly.
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if eval \${$3+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
$as_echo_n "checking $2 usability... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_header_compiler=yes
else
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
$as_echo_n "checking $2 presence... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <$2>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_header_preproc=yes
else
ac_header_preproc=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
yes:no: )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
no:yes:* )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
# variable VAR accordingly.
ac_fn_c_check_type ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=no"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof ($2))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof (($2)))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
eval "$3=yes"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_type
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case declares $2.
For example, HP-UX 11i declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* 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_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
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`
/usr/bin/hostinfo = `(/usr/bin/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=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&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_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=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
2)
as_fn_append 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
as_fn_append ac_configure_args " '$ac_arg'"
;;
esac
done
done
{ ac_configure_args0=; unset ac_configure_args0;}
{ ac_configure_args1=; unset 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: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
$as_echo "## ---------------- ##
## Cache variables. ##
## ---------------- ##"
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
$as_echo "## ----------------- ##
## Output variables. ##
## ----------------- ##"
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
$as_echo "## ------------------- ##
## File substitutions. ##
## ------------------- ##"
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
$as_echo "## ----------- ##
## confdefs.h. ##
## ----------- ##"
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
$as_echo "/* confdefs.h */" > 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
cat >>confdefs.h <<_ACEOF
#define PACKAGE_URL "$PACKAGE_URL"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
# We do not want a PATH search for config.site.
case $CONFIG_SITE in #((
-*) ac_site_file1=./$CONFIG_SITE;;
*/*) ac_site_file1=$CONFIG_SITE;;
*) ac_site_file1=./$CONFIG_SITE;;
esac
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file" \
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
See \`config.log' for more details" "$LINENO" 5; }
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. DJGPP emulates it as a regular file.
if test /dev/null != "$cache_file" && test -f "$cache_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
$as_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 $ac_precious_vars; 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,)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
$as_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
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_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.
*) as_fn_append ac_configure_args " '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
## -------------------- ##
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/acconfig.h"
ac_aux_dir=
for ac_dir in config "$srcdir"/config; 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
as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5
fi
# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
if ${ac_cv_build+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_build_alias=$build_alias
test "x$ac_build_alias" = x &&
ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
test "x$ac_build_alias" = x &&
as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
if ${ac_cv_host+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "x$host_alias" = x; then
ac_cv_host=$ac_cv_build
else
ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_host
shift
host_cpu=$1
host_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
case $host_os in
*cygwin* ) CYGWIN=yes;;
* ) CYGWIN=no;;
esac
cat >>confdefs.h <<_ACEOF
#define HOST_SYSTEM_TYPE "$host"
_ACEOF
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_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"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl.exe
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM 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.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { { ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
if test -z "$ac_file"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
ac_exeext=$ac_cv_exeext
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; 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 | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
int
main ()
{
FILE *f = fopen ("conftest.out", "w");
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
ac_clean_files="$ac_clean_files conftest.out"
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
if test "$cross_compiling" != yes; then
{ { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
if { ac_try='./conftest$ac_cv_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if ${ac_cv_objext+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if ${ac_cv_c_compiler_gnu+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_compiler_gnu=yes
else
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if ${ac_cv_prog_cc_g+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
else
CFLAGS=""
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
$as_echo "$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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if ${ac_cv_prog_cc_c89+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
struct stat;
/* 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;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
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
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
$as_echo_n "checking whether ln -s works... " >&6; }
LN_S=$as_ln_s
if test "$LN_S" = "ln -s"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
$as_echo "no, using $LN_S" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
$as_echo_n "(cached) " >&6
else
cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
*@@@%%%=?*=@@@%%%*)
eval ac_cv_prog_make_${ac_make}_set=yes;;
*)
eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
SET_MAKE=
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
SET_MAKE="MAKE=${MAKE-make}"
fi
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if ${ac_cv_path_install+:} false; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
# Account for people who put trailing slashes in PATH elements.
case $as_dir/ in #((
./ | .// | /[cC]/* | \
/etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
/usr/ucb/* ) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
elif test $ac_prog = install &&
grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# program-specific install script used by HP pwplus--don't use.
:
else
rm -rf conftest.one conftest.two conftest.dir
echo one > conftest.one
echo two > conftest.two
mkdir conftest.dir
if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
test -s conftest.one && test -s conftest.two &&
test -s conftest.dir/conftest.one &&
test -s conftest.dir/conftest.two
then
ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
break 3
fi
fi
fi
done
done
;;
esac
done
IFS=$as_save_IFS
rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
# As a last resort, use the slow shell script. Don't cache a
# value for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the value is a relative name.
INSTALL=$ac_install_sh
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostbyname ();
int
main ()
{
return gethostbyname ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nsl_gethostbyname=yes
else
ac_cv_lib_nsl_gethostbyname=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBNSL 1
_ACEOF
LIBS="-lnsl $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5
$as_echo_n "checking for connect in -lsocket... " >&6; }
if ${ac_cv_lib_socket_connect+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char connect ();
int
main ()
{
return connect ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_connect=yes
else
ac_cv_lib_socket_connect=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5
$as_echo "$ac_cv_lib_socket_connect" >&6; }
if test "x$ac_cv_lib_socket_connect" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSOCKET 1
_ACEOF
LIBS="-lsocket $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lresolv" >&5
$as_echo_n "checking for inet_aton in -lresolv... " >&6; }
if ${ac_cv_lib_resolv_inet_aton+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lresolv $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char inet_aton ();
int
main ()
{
return inet_aton ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_resolv_inet_aton=yes
else
ac_cv_lib_resolv_inet_aton=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_inet_aton" >&5
$as_echo "$ac_cv_lib_resolv_inet_aton" >&6; }
if test "x$ac_cv_lib_resolv_inet_aton" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBRESOLV 1
_ACEOF
LIBS="-lresolv $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5
$as_echo_n "checking for sin in -lm... " >&6; }
if ${ac_cv_lib_m_sin+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sin ();
int
main ()
{
return sin ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_m_sin=yes
else
ac_cv_lib_m_sin=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sin" >&5
$as_echo "$ac_cv_lib_m_sin" >&6; }
if test "x$ac_cv_lib_m_sin" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBM 1
_ACEOF
LIBS="-lm $LIBS"
fi
# Checks for header files and functions
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if ${ac_cv_prog_CPP+:} false; then :
$as_echo_n "(cached) " >&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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i 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
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5; }
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
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#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))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
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=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
if ${ac_cv_c_const+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __cplusplus
/* Ultrix mips cc rejects this sort of thing. */
typedef int charset[2];
const charset cs = { 0, 0 };
/* SunOS 4.1.1 cc rejects this. */
char const *const *pcpcc;
char **ppc;
/* 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";
pcpcc = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++pcpcc;
ppc = (char**) pcpcc;
pcpcc = (char const *const *) ppc;
{ /* SCO 3.2v4 cc rejects this sort of thing. */
char tx;
char *t = &tx;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
if (s) return 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 sort of thing, saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; } bx;
struct s *b = &bx; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
if (!foo) return 0;
}
return !cs[0] && !zero.x;
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_const=yes
else
ac_cv_c_const=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
$as_echo "$ac_cv_c_const" >&6; }
if test $ac_cv_c_const = no; then
$as_echo "#define const /**/" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
if test "x$ac_cv_type_size_t" = xyes; then :
else
cat >>confdefs.h <<_ACEOF
#define size_t unsigned int
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
if ${ac_cv_header_time+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
int
main ()
{
if ((struct tm *) 0)
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_time=yes
else
ac_cv_header_time=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
$as_echo "$ac_cv_header_time" >&6; }
if test $ac_cv_header_time = yes; then
$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
if ${ac_cv_struct_tm+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
struct tm tm;
int *p = &tm.tm_sec;
return !p;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_struct_tm=time.h
else
ac_cv_struct_tm=sys/time.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
$as_echo "$ac_cv_struct_tm" >&6; }
if test $ac_cv_struct_tm = sys/time.h; then
$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
fi
if test $ac_cv_c_compiler_gnu = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
$as_echo_n "checking whether $CC needs -traditional... " >&6; }
if ${ac_cv_prog_gcc_traditional+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_pattern="Autoconf.*'x'"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
Autoconf TIOCGETP
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "$ac_pattern" >/dev/null 2>&1; then :
ac_cv_prog_gcc_traditional=yes
else
ac_cv_prog_gcc_traditional=no
fi
rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
Autoconf TCGETA
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "$ac_pattern" >/dev/null 2>&1; then :
ac_cv_prog_gcc_traditional=yes
fi
rm -f conftest*
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
$as_echo "$ac_cv_prog_gcc_traditional" >&6; }
if test $ac_cv_prog_gcc_traditional = yes; then
CC="$CC -traditional"
fi
fi
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
$as_echo_n "checking for working alloca.h... " >&6; }
if ${ac_cv_working_alloca_h+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
int
main ()
{
char *p = (char *) alloca (2 * sizeof (int));
if (p) return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_working_alloca_h=yes
else
ac_cv_working_alloca_h=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
$as_echo "$ac_cv_working_alloca_h" >&6; }
if test $ac_cv_working_alloca_h = yes; then
$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
$as_echo_n "checking for alloca... " >&6; }
if ${ac_cv_func_alloca_works+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef _MSC_VER
# include
# define alloca _alloca
# else
# ifdef HAVE_ALLOCA_H
# include
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
void *alloca (size_t);
# endif
# endif
# endif
# endif
#endif
int
main ()
{
char *p = (char *) alloca (1);
if (p) return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_func_alloca_works=yes
else
ac_cv_func_alloca_works=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
$as_echo "$ac_cv_func_alloca_works" >&6; }
if test $ac_cv_func_alloca_works = yes; then
$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
else
# The SVR3 libPW and SVR4 libucb both contain incompatible functions
# that cause trouble. Some versions do not even contain alloca or
# contain a buggy version. If you still want to use their alloca,
# use ar to extract alloca.o from them instead of compiling alloca.c.
ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
$as_echo "#define C_ALLOCA 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
if ${ac_cv_os_cray+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if defined CRAY && ! defined CRAY2
webecray
#else
wenotbecray
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "webecray" >/dev/null 2>&1; then :
ac_cv_os_cray=yes
else
ac_cv_os_cray=no
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
$as_echo "$ac_cv_os_cray" >&6; }
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define CRAY_STACKSEG_END $ac_func
_ACEOF
break
fi
done
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
$as_echo_n "checking stack direction for C alloca... " >&6; }
if ${ac_cv_c_stack_direction+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_c_stack_direction=0
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
find_stack_direction (int *addr, int depth)
{
int dir, dummy = 0;
if (! addr)
addr = &dummy;
*addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
dir = depth ? find_stack_direction (addr, depth - 1) : 0;
return dir + dummy;
}
int
main (int argc, char **argv)
{
return find_stack_direction (0, argc + !argv + 20) < 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_c_stack_direction=1
else
ac_cv_c_stack_direction=-1
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
$as_echo "$ac_cv_c_stack_direction" >&6; }
cat >>confdefs.h <<_ACEOF
#define STACK_DIRECTION $ac_cv_c_stack_direction
_ACEOF
fi
for ac_header in stdlib.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
if test "x$ac_cv_header_stdlib_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STDLIB_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
if ${ac_cv_func_malloc_0_nonnull+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_func_malloc_0_nonnull=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if defined STDC_HEADERS || defined HAVE_STDLIB_H
# include
#else
char *malloc ();
#endif
int
main ()
{
return ! malloc (0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_func_malloc_0_nonnull=yes
else
ac_cv_func_malloc_0_nonnull=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
if test $ac_cv_func_malloc_0_nonnull = yes; then :
$as_echo "#define HAVE_MALLOC 1" >>confdefs.h
else
$as_echo "#define HAVE_MALLOC 0" >>confdefs.h
case " $LIBOBJS " in
*" malloc.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS malloc.$ac_objext"
;;
esac
$as_echo "#define malloc rpl_malloc" >>confdefs.h
fi
for ac_header in stdlib.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
if test "x$ac_cv_header_stdlib_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STDLIB_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5
$as_echo_n "checking for GNU libc compatible realloc... " >&6; }
if ${ac_cv_func_realloc_0_nonnull+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_func_realloc_0_nonnull=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#if defined STDC_HEADERS || defined HAVE_STDLIB_H
# include
#else
char *realloc ();
#endif
int
main ()
{
return ! realloc (0, 0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_func_realloc_0_nonnull=yes
else
ac_cv_func_realloc_0_nonnull=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5
$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; }
if test $ac_cv_func_realloc_0_nonnull = yes; then :
$as_echo "#define HAVE_REALLOC 1" >>confdefs.h
else
$as_echo "#define HAVE_REALLOC 0" >>confdefs.h
case " $LIBOBJS " in
*" realloc.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS realloc.$ac_objext"
;;
esac
$as_echo "#define realloc rpl_realloc" >>confdefs.h
fi
for ac_header in sys/select.h sys/socket.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5
$as_echo_n "checking types of arguments for select... " >&6; }
if ${ac_cv_func_select_args+:} false; then :
$as_echo_n "(cached) " >&6
else
for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
#ifdef HAVE_SYS_SELECT_H
# include
#endif
#ifdef HAVE_SYS_SOCKET_H
# include
#endif
int
main ()
{
extern int select ($ac_arg1,
$ac_arg234, $ac_arg234, $ac_arg234,
$ac_arg5);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
done
done
# Provide a safe default value.
: "${ac_cv_func_select_args=int,int *,struct timeval *}"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5
$as_echo "$ac_cv_func_select_args" >&6; }
ac_save_IFS=$IFS; IFS=','
set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
IFS=$ac_save_IFS
shift
cat >>confdefs.h <<_ACEOF
#define SELECT_TYPE_ARG1 $1
_ACEOF
cat >>confdefs.h <<_ACEOF
#define SELECT_TYPE_ARG234 ($2)
_ACEOF
cat >>confdefs.h <<_ACEOF
#define SELECT_TYPE_ARG5 ($3)
_ACEOF
rm -f conftest*
for ac_func in strftime
do :
ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime"
if test "x$ac_cv_func_strftime" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRFTIME 1
_ACEOF
else
# strftime is in -lintl on SCO UNIX.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime in -lintl" >&5
$as_echo_n "checking for strftime in -lintl... " >&6; }
if ${ac_cv_lib_intl_strftime+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lintl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char strftime ();
int
main ()
{
return strftime ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_intl_strftime=yes
else
ac_cv_lib_intl_strftime=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_strftime" >&5
$as_echo "$ac_cv_lib_intl_strftime" >&6; }
if test "x$ac_cv_lib_intl_strftime" = xyes; then :
$as_echo "#define HAVE_STRFTIME 1" >>confdefs.h
LIBS="-lintl $LIBS"
fi
fi
done
for ac_func in bzero gethostbyaddr gethostbyname gettimeofday inet_ntoa memset select setenv socket strchr strdup strstr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
case "$host" in
*darwin*)
$as_echo "#define BSD_IP_STACK 1" >>confdefs.h
$as_echo "#define DARWIN 1" >>confdefs.h
;;
*netbsd*)
$as_echo "#define BSD_IP_STACK 1" >>confdefs.h
$as_echo "#define NETBSD 1" >>confdefs.h
;;
*openbsd*)
$as_echo "#define OPENBSD 1" >>confdefs.h
$as_echo "#define BSD_IP_STACK 1" >>confdefs.h
;;
*bsd*)
$as_echo "#define BSD_IP_STACK 1" >>confdefs.h
;;
*linux*)
$as_echo "#define _BSD_SOURCE 1" >>confdefs.h
;;
*solaris*)
case "$host" in
*solaris2.4*)
$as_echo "#define SOLARIS_LENGTH_IN_CHECKSUM 1" >>confdefs.h
;;
*solaris2.5*)
$as_echo "#define SOLARIS_LENGTH_IN_CHECKSUM 1" >>confdefs.h
;;
esac
;;
esac
case "$host" in
*cygwin*)
: we do not require pcap, but we do require special win32 libraries.
LIBS="-lws2_32 $LIBS"
;;
*)
# Check whether --enable-universal was given.
if test "${enable_universal+set}" = set; then :
enableval=$enable_universal; UNIVERSAL="$enableval"
else
UNIVERSAL="no"
fi
# Check whether --enable-gtod was given.
if test "${enable_gtod+set}" = set; then :
enableval=$enable_gtod; GTOD="$enableval"
else
GTOD="no"
fi
# Check whether --with-pcap was given.
if test "${with_pcap+set}" = set; then :
withval=$with_pcap;
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-pcap option" >&5
$as_echo_n "checking for --with-pcap option... " >&6; }
case "$withval" in
yes|no)
as_fn_error $? "please specify a PATH in --with-pcap option!" "$LINENO" 5
;;
*)
if test '!' -d "$withval"; then
as_fn_error $? "$withval does not exist!" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $withval" >&5
$as_echo "$withval" >&6; }
if test -d "$withval/include"; then
CFLAGS="$CFLAGS -I$withval/include"
CPPFLAGS="$CPPFLAGS -I$withval/include"
else
CFLAGS="$CFLAGS -I$withval"
CPPFLAGS="$CPPFLAGS -I$withval"
fi
if test -d "$withval/lib"; then
LIBS="$LIBS -L$withval/lib"
else
LIBS="$LIBS -L$withval"
fi
fi
;;
esac
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
# include
# include
int
main ()
{
u_int i = sizeof(((struct sockaddr *)0)->sa_len)
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_lookupdev in -lpcap" >&5
$as_echo_n "checking for pcap_lookupdev in -lpcap... " >&6; }
if ${ac_cv_lib_pcap_pcap_lookupdev+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcap $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pcap_lookupdev ();
int
main ()
{
return pcap_lookupdev ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pcap_pcap_lookupdev=yes
else
ac_cv_lib_pcap_pcap_lookupdev=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_lookupdev" >&5
$as_echo "$ac_cv_lib_pcap_pcap_lookupdev" >&6; }
if test "x$ac_cv_lib_pcap_pcap_lookupdev" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPCAP 1
_ACEOF
LIBS="-lpcap $LIBS"
else
as_fn_error $? "
Can't find the pcap developer library (libpcap); please install the pcap library or use
--with-pcap to specify the path to it on your system" "$LINENO" 5
fi
ac_fn_c_check_header_mongrel "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default"
if test "x$ac_cv_header_pcap_h" = xyes; then :
else
as_fn_error $? "
Can't find pcap.h; install the pcap library (from
ftp://ftp.ee.lbl.gov/libpcap.tar.Z ) and/or use
--with-pcap to specify the path to it on your system
When installing libpcap do both 'make install' and 'make install-incl'" "$LINENO" 5
fi
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should build universal binaries" >&5
$as_echo_n "checking if we should build universal binaries... " >&6; }
if test "$UNIVERSAL" = "yes"; then
case $host_os in
*darwin* )
CFLAGS="$CFLAGS -arch i386 -arch ppc"
LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
$as_echo "#define UNIVERSAL 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
;;
esac
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should gettimeofday for each packet" >&5
$as_echo_n "checking if we should gettimeofday for each packet... " >&6; }
if test "$GTOD" = "yes"; then
$as_echo "#define USE_GTOD 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
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, we kill variables containing newlines.
# 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.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}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 "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
if test "x$cache_file" != "x/dev/null"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
if test ! -f "$cache_file" || test -h "$cache_file"; then
cat confcache >"$cache_file"
else
case $cache_file in #(
*/* | ?:*)
mv -f confcache "$cache_file"$$ &&
mv -f "$cache_file"$$ "$cache_file" ;; #(
*)
mv -f confcache "$cache_file" ;;
esac
fi
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
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}'
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
U=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
as_write_fail=0
cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
#! $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}
export SHELL
_ASEOF
cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
as_myself=
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
IFS=$as_save_IFS
;;
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
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; 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
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# 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
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
_ASEOF
test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Save the log message, to keep $0 and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by $as_me, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration. Unless the files
and actions are specified as TAGs, all are instantiated by default.
Usage: $0 [OPTION]... [TAG]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
--config print configuration, then exit
-q, --quiet, --silent
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 the package provider."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
config.status
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
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=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--config | --confi | --conf | --con | --co | --c )
$as_echo "$ac_cs_config"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
'') as_fn_error $? "missing file argument" ;;
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
as_fn_append CONFIG_HEADERS " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
as_fn_error $? "ambiguous option: \`$1'
Try \`$0 --help' for more information.";;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;
*) as_fn_append ac_config_targets " $1"
ac_need_defaults=false ;;
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 || ac_write_fail=1
if \$ac_cs_recheck; then
set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config/acconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS config/acconfig.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
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 against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp= ac_tmp=
trap 'exit_status=$?
: "${ac_tmp:=$tmp}"
{ test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
|| as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF
# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
# ${srcdir} and @srcdir@ entries 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[ ]*=[ ]*/{
h
s///
s/^/:/
s/[ ]*$/:/
s/:\$(srcdir):/:/g
s/:\${srcdir}:/:/g
s/:@srcdir@:/:/g
s/^:*//
s/:*$//
x
s/\(=[ ]*\).*/\1/
G
s/\n//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_tt"; then
break
elif $ac_last_try; then
as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' >$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #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.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$ac_tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
done
# 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. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$ac_tmp/stdin" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
as_dir="$ac_dir"; as_fn_mkdir_p
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
*) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;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&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
>$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
rm -f "$ac_tmp/stdin"
case $ac_file in
-) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
*) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
esac \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
} >"$ac_tmp/config.h" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$ac_tmp/config.h" "$ac_file" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error $? "could not create -" "$LINENO" 5
fi
;;
esac
done # for ac_tag
as_fn_exit 0
_ACEOF
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
# 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 || as_fn_exit 1
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
lft-3.8/lft_types.h 000644 000766 000000 00000012426 12711662332 014263 0 ustar 00vic wheel 000000 000000 /*
* lft_types.h
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#ifndef LFT_TYPES_H
#define LFT_TYPES_H
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
#include "config/acconfig.win.h"
#else
#include "config/acconfig.h"
#endif
#include
#ifndef __FAVOR_BSD
# define __FAVOR_BSD 1
#endif
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
#define __USE_W32_SOCKETS
#include
#include
#include
#include
#define LITTLE_ENDIAN 1
#define BYTE_ORDER 1
typedef signed long n_long;
typedef signed short n_short;
typedef signed long n_time;
#include
#include
#include
#include
#ifdef __CYGWIN__
# include
#else
# include "include/win32/wingetopt.h"
# if defined(WIN32) || defined(_WIN32)
# define SIZEOF_CHAR 1
# define SIZEOF_SHORT 2
# define SIZEOF_LONG 4
# define SIZEOF_LONG_LONG 8
# include "include/libpcap/bittypes.h"
# include "include/libpcap/Gnuc.h"
# define bzero(buf,cnt) memset(buf,'\0',cnt);
# endif
#endif
#include "include/net/if_arp.h"
#include "include/netinet/if_ether.h"
#include "include/netinet/ip.h"
#include "include/netinet/ip_icmp.h"
#include "include/netinet/tcp.h"
#include "include/netinet/udp.h"
#else
#include
#include
#if TIME_WITH_SYS_TIME
# include
# include
#else
# if HAVE_SYS_TIME_H
# include
# else
# include
# endif
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef BSD
#include
#endif
#ifdef BSD_IP_STACK
#include
#include
#if !defined(DARWIN) && !defined(NETBSD)
#define HAVE_SNPRINTF
#define HAVE_VSNPRINTF
#if !defined(OPENBSD)
#include
#endif
#endif
#endif
#include
#ifdef sun
#include
#include
#endif
#endif
#include "lft_ifname.h"
#include "lft_lsrr.h"
#include "whois.h"
#if defined(__FreeBSD__)
#include
#elif !defined(DARWIN) && !defined(NETBSD)
#include "lft_queue.h"
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* holds the pseudo-header for generating checksums */
struct sumh
{
unsigned int src;
unsigned int dst;
unsigned char fill;
unsigned char protocol;
unsigned short len;
};
/* The actual packet data */
struct trace_packet_s
{
struct ip ip_hdr;
struct ip_lsrr lsrr; /* must go here for ip checksum to work */
struct tcphdr tcp_hdr;
struct udphdr udp_hdr;
int size;
char *payload;
int payload_len;
};
/* RFC 1393 type trace IP option */
struct rfc1393_ip_option_s
{
u_char optcode; //=82
u_char optlength; //=12
u_short id; //number to identify icmp trace messages
u_short ohc; //outbound hop count
u_short rhc; //return hop count
struct in_addr origip; //originator ip address
} __attribute__((packed));
/* ICMP echo header */
struct icmp_echo_header_s
{
u_char type;
u_char code;
u_short checksum;
u_short id;
u_short sequence;
} __attribute__((packed));
/* ICMP trace response header */
struct icmp_trace_reply_header_s
{
u_char type;
u_char code;
u_short checksum;
u_short id;
u_short unused;
u_short ohc; //outbound hop count
u_short rhc; //return hop count
u_long ols; //output link speed
u_long olmtu; //output link MTU
} __attribute__((packed));
/* Trace packet for RFC 1393 type and ICMP base trace */
struct icmp_trace_packet_s
{
char * packet;
int packet_len;
struct ip * ip_hdr;
struct rfc1393_ip_option_s * icmp_trace_opt;
struct ip_lsrr * lsrr;
struct icmp_echo_header_s * echo;
char * payload;
int payload_len;
};
/* Packet container with additional info */
struct trace_packet_info_s
{
int icmp_type; /* ICMP_UNREACH code, -1 if RST reply */
int is_done; /* is this a final hop? */
short hopno;
unsigned int seq;
struct timeval sent;
struct timeval recv; /* 0 if unreceived */
struct in_addr hopaddr; /* IP address of router */
/* copy of EvtPacketInfoParam */
int asnumber;
char netname[512];
struct in_addr last_hop;
/*----------------------------*/
union
{
struct trace_packet_s packet;
struct icmp_trace_packet_s icmp_packet;
} u;
SLIST_ENTRY(trace_packet_info_s) next_by_hop;
SLIST_ENTRY(trace_packet_info_s) next;
};
/* hop information, by ttl */
struct hop_info_s
{
int num_sent;
int all_sent, all_rcvd;
struct timeval ts_last_sent;
struct timeval ts_last_recv;
struct trace_packet_info_s * done_packet;
unsigned short state;
unsigned short flags;
SLIST_HEAD(hop_packets_s, trace_packet_info_s) packets;
};
#ifdef __cplusplus
}
#endif
#endif /*LFT_TYPES_H*/
lft-3.8/makefile.vc 000644 000766 000000 00000007322 11053131665 014205 0 ustar 00vic wheel 000000 000000 # =========================================================================
# This makefile was generated by
# Bakefile 0.2.2 (http://bakefile.sourceforge.net)
# Do not modify, all changes will be overwritten!
# =========================================================================
# -------------------------------------------------------------------------
# These are configurable options:
# -------------------------------------------------------------------------
# C compiler
CC = cl
# Standard flags for CC
CFLAGS =
# Standard preprocessor flags (common for CC and CXX)
CPPFLAGS =
# Standard linker flags
LDFLAGS =
# Set to 1 to build debug version [0,1]
# 0 - Release
# 1 - Debug
DEBUG = 0
# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------
### Variables: ###
LFT_CFLAGS = /MD$(____DEBUG_3) /DWIN32 $(____DEBUG) $(____DEBUG_0) \
$(____DEBUG_1) $(______DEBUG) /Fdlft.pdb /w $(CPPFLAGS) $(CFLAGS)
LFT_OBJECTS = \
lft_lft.obj \
lft_lft_btcptrace.obj \
lft_lft_icmptrace.obj \
lft_lft_ifname.obj \
lft_lft_lib.obj \
lft_whois.obj \
lft_wingetopt.obj \
lft_wingettimeofday.obj \
lft_winlft_ifname.obj
WHOB_CFLAGS = /MD$(____DEBUG_3) /DWIN32 $(____DEBUG) $(____DEBUG_0) \
$(____DEBUG_1) $(______DEBUG) /Fdwhob.pdb /DSTANDALONE $(CPPFLAGS) $(CFLAGS)
WHOB_OBJECTS = \
whob_whois.obj \
whob_wingetopt.obj
### Conditionally set variables: ###
!if "$(DEBUG)" == "0"
____DEBUG = /DNDEBUG
!endif
!if "$(DEBUG)" == "1"
____DEBUG =
!endif
!if "$(DEBUG)" == "0"
____DEBUG_0 = /O2
!endif
!if "$(DEBUG)" == "1"
____DEBUG_0 = /Od
!endif
!if "$(DEBUG)" == "0"
____DEBUG_1 =
!endif
!if "$(DEBUG)" == "1"
____DEBUG_1 = /Zi
!endif
!if "$(DEBUG)" == "0"
____DEBUG_2 =
!endif
!if "$(DEBUG)" == "1"
____DEBUG_2 = /DEBUG
!endif
!if "$(DEBUG)" == "0"
______DEBUG =
!endif
!if "$(DEBUG)" == "1"
______DEBUG = /D_DEBUG
!endif
!if "$(DEBUG)" == "0"
____DEBUG_3 =
!endif
!if "$(DEBUG)" == "1"
____DEBUG_3 = d
!endif
### Targets: ###
all: lft.exe whob.exe
clean:
-if exist .\*.obj del .\*.obj
-if exist .\*.res del .\*.res
-if exist .\*.pch del .\*.pch
-if exist lft.exe del lft.exe
-if exist lft.ilk del lft.ilk
-if exist lft.pdb del lft.pdb
-if exist whob.exe del whob.exe
-if exist whob.ilk del whob.ilk
-if exist whob.pdb del whob.pdb
lft.exe: $(LFT_OBJECTS)
link /NOLOGO /OUT:$@ $(LDFLAGS) $(____DEBUG_2) @<<
$(LFT_OBJECTS) ws2_32.lib Iphlpapi.lib imm32.lib winmm.lib advapi32.lib
<<
whob.exe: $(WHOB_OBJECTS)
link /NOLOGO /OUT:$@ $(LDFLAGS) $(____DEBUG_2) @<<
$(WHOB_OBJECTS) ws2_32.lib
<<
lft_lft.obj: .\lft.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_lft_btcptrace.obj: .\lft_btcptrace.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_lft_icmptrace.obj: .\lft_icmptrace.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_lft_ifname.obj: .\lft_ifname.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_lft_lib.obj: .\lft_lib.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_whois.obj: .\whois.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_wingetopt.obj: .\include\win32\wingetopt.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_wingettimeofday.obj: .\include\win32\wingettimeofday.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
lft_winlft_ifname.obj: .\include\win32\winlft_ifname.c
$(CC) /c /nologo /TC /Fo$@ $(LFT_CFLAGS) $**
whob_whois.obj: .\whois.c
$(CC) /c /nologo /TC /Fo$@ $(WHOB_CFLAGS) $**
whob_wingetopt.obj: .\include\win32\wingetopt.c
$(CC) /c /nologo /TC /Fo$@ $(WHOB_CFLAGS) $**
lft-3.8/CHANGELOG 000644 000766 000000 00000031035 13263006744 013312 0 ustar 00vic wheel 000000 000000
LFT CHANGELOG
lft 3.8 / WhoB 3.8
----------------------
- Added support for DLT_NULL interfaces
lft 3.79 / WhoB 3.79
----------------------
- Improved feature: 'whob me' and 'whob whoami' to display your public IP
lft 3.78 / WhoB 3.78
----------------------
- Added feature: 'whob me' to display your current public IP address
lft 3.77 / WhoB 3.77
----------------------
- Added feature: 'whob -gA' to show all prefixes TRANSITING an ASN
Very powerful, much-requested feature! Enjoy
Many thanks to Prefix WhoIs team!
lft 3.76 / WhoB 3.76
----------------------
- Remove compiler warnings using more casts (Victor)
- Autoremake ./configure script so everyone has a reasonable default
lft 3.75 / WhoB 3.75
----------------------
- Improved cross-compiling compatiblity (thanks to Gustavo Z.)
lft 3.74 / WhoB 3.74
----------------------
- Fixed source port randomizaiton with -z (thanks to Conor M.)
- Fixed compilation on OpenBSD (thanks to Renaud A.)
lft 3.71 / WhoB 3.71
----------------------
- WhoB: Autodetect input from STDIN (pipe) without '-f -'
- WhoB: Redirect some extraneous output to STDERR
lft 3.7 / WhoB 3.7
----------------------
- Added support for 4-byte ASNs
- Added support for whob reading bulk input from stdin using '-f -'
lft 3.6 / WhoB 3.6
----------------------
- Added support for 4-byte ASNs
lft 3.5 / WhoB 3.5
----------------------
- Roy T. provided DNS speed-ups
- Added GraphViz output option with -g
lft 3.35 / WhoB 3.5
----------------------
- Roy T. provided some clean-ups to avoid double free()s
- Bug fixes only
lft 3.33 / WhoB 3.5
----------------------
- Fixed free(sess->hostname) bug (segfault on unresolvable hostname)
- Improved error hanlding of pcap failures related to data link type
- Kurt's FreeBSD fix for pcap snprintf
- Bug fixes only
lft 3.32 / WhoB 3.5
----------------------
- Added support for several encapsulating protocols such as PPP
- no other changes
lft 3.31 / WhoB 3.5
----------------------
- Added #define for AI_NUMERICSERV undeclared on some platforms/versions
- No other changes
lft 3.3 / WhoB 3.5
----------------------
- Improved LFT target detection behind firewalls
- Updated LFT for newer pcap version defaults
- WhoB ignores comments [#,;] in input files
- Added LFT option -f to specify fake source address
- Applied many, many, many fixes from Juli M. of USA -- Thanks!
- Applied many, many, many fixes from Markus Gothe of Sweden -- Thanks!
lft 3.2 / WhoB 3.2
----------------------
- Added support for 802.1q tagged VLANs
- Manual page corrections (thanks to Brett)
- WhoB will use Prefix WhoIs for bulk file resolution in
Cymru-compatible format with '-c' but Cymru will be used
with '-C'
lft 3.1 / WhoB 3.1
----------------------
- New configure options:
--enable-gtod Forces LFT to use gettimeofday() on each packet instead of
using the BPF timestamp. This is critical on platforms that have enabled
'fastts' or that do not have high-precision BPF timestamping.
--enable-universal generates binaries including both PPC and Intel architecture
(for users running Mac OS X/Darwin)
- Improved compatibility with NetBSD and Darwin/Mac OS X
- Added autoconf support for NetBSD
- Improved compatibility with older compilers (thanks to Sean)
- Updated autoconf bits and pieces
- By popular request, reversed the -g option of WhoB
WhoB now uses gigo mode by default unless -g is specified which turns
ON its parser and enables the other various options
lft 3.0
----------------------
- Completely refactored and now a workable library
- LFT has a new (-b) TCP Basic trace method that makes TCP traces NAT-friendly
- LFT has a new (-p) ICMP trace method that uses echo requests to trace paths
- Many memory issues fixed
- Cleanup of several 2.6b5-3.0b features
lft 2.6 / WhoB 2.0
----------------------
- LFT prints 'open' in the target block if the target dest port is open
- LFT indicates the reason it marked ports open/closed in verbose(2) output
- LFT prints an asterisk when it retransmits a packet after a timeout
- LFT uses Prefix WhoIs (bulk) or RISWHOIS (bulk) for netname resolution
- LFT has a new (-u) traditional UDP-based tracing feature
- LFT displays start and finish times/dates when using the (-T) option
- LFT has a new (-U) feature to display all times in UTC/GMT0
- LFT only shows time spent tracing/resolving at verbosity level 1 or higher
- LFT sets the ToS bit on outgoing IP datagrams when (-I) option is used
- LFT gets timevals from packets instead of calling gettimeofday()
- LFT won't be fooled into thinking there's a firewall on a gateway just
because adaptive mode ups the state waiting for replies that never come
- Improved LFT performance (removed gettimeofday() on each packet)
- WhoB/library uses Prefix WhoIs to resolve OrgNames and NetNames
- WhoB/library has improved support for RIPE NCC RIS and Prefix WhoIs
- WhoB supports bulk resolution (-f option) from an input file
- WhoB also supports one-per-line output (-cf option) from a bulk input file
- WhoB will use putenv() on Solaris who is missing setenv() to set TZ
- WhoB has a new (-g) feature to take input directly from the command line
and print output directly from Prefix WhoIs (referred to as GIGO)
- Added $DESTDIR support to Makefile (thanks Daniel)
- Fixed an off-by-one bug in LFT related to ASN display encountered when
a trace contains one or more neglected TTLs
- Fixed an off-by-one bug in LFT's verbose output regarding TTLs
- Fixed variable ordering in whois.c from 2.6b1 (thanks Erick)
- Numerous platform-specific improvements
- Reconfigured autoconf and segregated ./config/
- Updated autoconf components to v2.59
lft 2.5 / WhoB 1.5
----------------------
- Inclusive of betas 2.32 to 2.4x
- Added -z option to pseudo-randomize source port
- Added behavior to automatically select the most appropriate interface
based on routing (this was on the most wanted list)
- Improved OpenBSD compatibility (IP length nonzero)
- OpenBSD is now detected by autoconf (for configuring the above)
- Darwin is now detected by autoconf and its definition disables
some BSD features to make it compatible with MacOS X and Darwin
- LFT now indicates it has reached the target by printing a 'T'
character in the status display (if status is enabled)
- Cleanups were made to the verbose output levels (-VVV)
- Significantly revamped whois framework makes it easy to include
whois functionality into other programs
- Added -C and -R and -r options to force alternate ASN sources:
- (r)IPE RIS - special thanks to Rene Wilhelm @ RIPE NCC
- (C)ymru
- (R)ADB
- Default ASN source (-A) is now Prefix WhoIs (see pwhois.org)
- LFT now queries for ASNs in bulk format after completing
a trace if pwhois (default), RIPE NCC RIS, or Cymru is selected
- Added dst/src port autoselection based on user-supplied hostname
- Vastly improved standalone whois client "whob" see whob.8 (whob manpage)
- Makefile now installs 'whob' no-frills whois client (try ./whob)
- "Smart" mode is now referred to as "Adaptive" mode (-E)
lft 2.31
--------------------
- Fixed time precision on FreeBSD 5.3 (Thanks to Kurt Jaeger)
lft 2.3:
--------------------
- added WSAIoctl() call to select proper IF on windows based on dest (thanks Graham!)
- lowered max_retries to a default of 2
- cleaned up formatting related to -S option
- cleaned up verbose output to be more friendly
- cleaned up error messages
- updated manpage
- updated spec file
lft 2.2:
--------------------
- removed dependence on regex library
- removed dependence on INT_MAX
- fixed whois code to get the most specific netblock instead of the least specific netblock
- can now specify interface by IP instead of by name
lft 2.1:
--------------------
- Added autoconf support
- Ported to cygwin
- Fixed the Solaris and BSD makefiles (manpage install errors)
- Modified the whois code to resolve ASN and netname lookup
problems with RIPE entries. (-A) and (-N) code...
- Modified the whois code to support local-as
- Vastly streamlined the (-V) verbose output to cover the
important information (sequence, etc) of all packets
sent and received
lft 2.0 (and betas):
--------------------
- (-E) and (-F) shouldn't be used at the same time, now LFT knows that
- Implemented fixes that enable LFT to run under Solaris/SPARC (Jim McKim)
- Changed name from FFT to LFT (layer four trace)
- Added ICMP messages for codes 13-15
- Changed the (-P) option added in 1.99 to (-E) in order to force use of
the new "smart" engine
- Enhanced stateful firewall (packet filter) detection en route
- Engine: "smart" mode now tries FIN, SYN, etc table to get packets through
which dramatically improves its "find a way" capability
- Engine: "smart" mode now detects the BSD bug properly
- Engine: "smart" mode now detects firewalls in transit
- Compilation: made lft_queue.h the default for all OSs
- UI: lots of user interface changes
lft 1.99-beta(s):
--------------------
- Added Loose Source Routing feature (LSRR) [ <...>]
- Added (-N) Netblock name lookup feature
- Added (-A) ASN lookup feature
- Added (-P) option to automatically send 3 probes for more stats
- Added (-V) lots of verbose debugging information
- Added (-F) feature to revert to sending FIN packets
- Added (-T) option to show trace and resolution timings (LFT is fast)
- Added BSD 4.[23] and derivative (bug) inappropriate TTL detection
- Engine: Use sequence numbers as packet ID instead of destination port
numbers. This achieves a number of goals:
Return ICMP and TCP packets are more uniquely identified.
It is now possible to check the route for specific destination
port, which is important if route varies based on port (such
as with transparent proxying using a load balancing switch on
port 80) (thank you Ugen!)
- Engine: Send SYN packets. Variety of firewalls and NAT devices won't
pass through a single TCP packet that is not a part of established
connection, unless it carries SYN flag only (initial packet).
Pitfall: this may create useless PCB blocks on destination host,
if it does not use SYN cookies or some other SYN flood protection.
However it's better then not being able to use lft from behind
firewalls. (thank you Ugen!)
- Renamed (-H) max hops/ttl option
- UI cleaned up in several areas, especially result list & RTT display
- Detect local packet filter
lft 1.91:
---------------------
- Fixed Makefile.solaris (last time we'll see this before autoconf)
- added for Solaris
lft 1.9:
--------------------
- Default source port is now 53/tcp (dns-xfer)
- Configurable source port on command line through -p or host:port
- Configurable initial destination port on command line using -d
- Source and Destination ports use /etc/services for lookup
- Fixed a bug that created a gethostbyaddr() call even when the user
specified NOT to do reverse DNS lookups -- makes -n option way faster!
- Changed the way lft auto-detects the IP address of the interface selected
* now, we determine what address is assigned to the interface instead of
just getting the hosts's primary/default address and using it
* thanks, Aaron, for bringing this to our attention!
* thanks, Lane, for coming up with a platform-independent
way of making it work.
lft 1.8:
--------------------
- added option to suppress status indicator and only show trace (or errors)
* people using lft from a web page wanted this
- added option to select the network interface used as hop zero
* string length of device is tested to avoid potential buffer overflows
- modified the status bar to display:
Send mode: ->( / )
Recv mode: <{ }
Additional testing platforms for this release:
- Aaron Bentley (Univ Toronto) tested lft successfully under Debian Woody Linux
* Aaron also contributed a variation of net device selection -- thanks
lft 1.7:
--------------------
- added option to disable reverse DNS host lookups
- made several areas slightly more user-friendly
- modified the status bar to display:
Send mode: ->( / )
Recv mode: <( )
- changed "source" port from tcp/80 to tcp/25
most firewalls today permit tcp_established implicitly, not traffic
from tcp/80 explicitly, therefore we figured sending packets from
tcp/25 would be more likely to get through.
- modified initialization of 32-bit unsigned integer used to
calculate checksum
LFT now builds again under Solaris, but still miscalculates checksums
- fixed round trip time calculation
- several other minor tweaks
- tested under RedHat Linux, Darwin 5.5 (MacOS X v10.1)
lft 1.6 (nils):
---------------
- Great idea.
lft-3.8/config/ 000755 000766 000000 00000000000 13263007004 013331 5 ustar 00vic wheel 000000 000000 lft-3.8/lft.c 000644 000766 000000 00000034335 13263006600 013026 0 ustar 00vic wheel 000000 000000 /*
This file is part of LFT.
The LFT software provided in this Distribution is
Copyright 2007 VOSTROM Holdings, Inc.
The full text of our legal notices is contained in the file called
COPYING, included with this Distribution.
Authors:
- Victor Oppleman
- Eugene Antsilevitch
Other copyrights and former authors:
- Portions copyright (c) Genuity, Inc.
- Portions copyright (c) Markus Gothe
- Portions copyright (c) Nils McCarthy
*/
#include "lft_lib.h"
/* BEGIN Added by Roy T. to improve DNS speed/reliability */
#include
extern struct __res_state _res;
/* END Added by Roy T. to improve DNS speed/reliability */
#if 0
static char def_payload[] = "\0\0\0\0\0\0\0\0\0\0"; /* default payload for UDP packets */
#endif
const char *version = "3.8"; /* set version string */
static const char *version_date = "(04/2018)"; /* date of this version */
static void
usage(lft_session_params * sess, char *prog)
{
fprintf (stderr,
"\nLayer Four Traceroute (LFT)\n\n"
" - the alternative traceroute tool for network [reverse] engineers\n"
" visit http://www.pwhois.org\n\n"
"Usage: %s [] [ <...>] \n"
"\nMainstream Options:\n"
" -s Source port number\n"
" -d Destination port number (same as using target:port as target)\n"
" -z Pseudo-randomize the source port number\n"
" -m Minimum number of probes to send per hop\n"
" -M Maximum number of probes to send per hop\n"
" -D Listen-on/use a device by name or address (\"en1\" or \"1.2.3.4\")\n"
" -L Set the length of the probe packet in bytes\n"
"\nAdvanced Tracing Options:\n"
" -F Use TCP FIN packets exclusively (defaults are SYN)\n"
" -f Send using a device by name or address (spoofing allowed)\n"
" -e | -E Use LFT's stateful engine to detect firewalls and path anomalies\n"
" -u Use traditional UDP (probes) for tracing instead of TCP\n"
" -b Basic TCP trace\n"
" -p Use traditional ICMP (probes) for tracing instead of TCP\n"
/*" -P Use RFC1393 IP option for tracing instead of TCP\n" */
" -a Number of hops forward to query before pausing to wait for replies\n"
" -c Minimum number of milliseconds between subsequent probes\n"
" -t Maximum RTT to wait before assuming packet was dropped\n"
" -l Minimum TTL to use on outgoing packets (skips close-proximity hops)\n"
" -H Maximum number of hops to traverse (max TTL of packets)\n"
" -q Set the initial sequence number (ISN) manually\n"
" -I Set the ToS field in the IP packet to minimize-delay\n"
" -i Disable \"stop on ICMP\" other than TTL expired\n"
"\nResolution Options:\n"
" -n Display hosts numerically; disable use of the DNS resolver\n"
" -h Display hosts symbolically; suppress IP address display\n"
" -N Display network or AS names where appropriate\n"
" -A Display AS numbers resolved by Prefix WhoIs\n"
"\nAdvanced Resolution Options:\n"
" -r Use RIPE NCC's RIS to resolve ASNs instead of Prefix WhoIs\n"
" -R Use the RADB to resolve ASNs instead of Prefix WhoIs\n"
" -C Use Cymru to resolve ASNs instead of Prefix WhoIs\n"
"\nVerbosity Options and Status:\n"
" -T Use execution timers and summarize where LFT spent its time\n"
" -U Display all times in UTC (GMT0). Activates -T option automatically\n"
" -S Disable the status bar (only show the completed trace)\n"
" -V Display verbose/debug output. Use more \'V\'s for additional detail\n"
" -x XML output\n"
" -g GraphViz output\n"
" -G Enable GraphViz output and override path to icons\n"
" -y Test destination upstream transition hop\n"
" -v Display LFT's version information and exit\n"
"\n"
"Default is: %s -s %d -d %d -m %d -M %d -a %d -c %.0f -t %d -H %d \n\n",
prog, prog, sess->sport, sess->dport, sess->retry_min, sess->retry_max, sess->ahead_limit,
sess->scatter_ms, sess->timeout_ms, sess->ttl_limit);
exit(EXIT_FAILURE);
}
static void
show_version (void)
{
fprintf (stderr, "\n"
"Layer Four Traceroute (LFT) - version %s %s\n\n - the alternative traceroute tool for network [reverse] engineers\n\n"
" Compile-time options:\n\n"
#if defined(DARWIN)
" + Darwin (or MacOS)\n"
#endif
#if defined(UNIVERSAL)
" + Universal binary\n"
#endif
#if defined(NETBSD)
" + NetBSD\n"
#endif
#if defined(OPENBSD)
" + OpenBSD\n"
#endif
#if defined(BSD_IP_STACK)
" + BSD IP stack\n"
#endif
#if defined(BSD)
" + BSD platform\n"
#endif
#if defined(linux)
" + Linux platform\n"
#endif
#if defined(sun)
" + SUN platform\n"
#endif
#if !defined(sun) && !defined(linux) && !defined(BSD_IP_STACK) && !defined(OPENBSD)
" (unknown architecture)\n"
#endif
#if defined(SCREWED_IP_LEN)
" + IP length big-endian\n"
#else
" + IP length little-endian\n"
#endif
#if defined(IP_HDRINCL)
" + Full IP headers for raw sockets\n"
#else
" + Without IP header inclusion\n"
#endif
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32) || defined( USE_GTOD )
" + Calling gettimeofday() on each packet\n"
#endif
" + " HOST_SYSTEM_TYPE "\n"
"\n", version, version_date);
exit(EXIT_SUCCESS);
}
extern int
main (int argc, char **argv)
{
lft_session_params * sess;
int ch;
char *cp = NULL;
struct timeval tb;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 2, 2 );
WSAStartup( wVersionRequested, &wsaData );
#endif
/* BEGIN Added by Roy T. to improve DNS speed/reliability */
res_init();
_res.retrans = 1;
_res.retry = 1;
/* END Added by Roy T. to improve DNS speed/reliability */
sess = LFTSessionOpen();
setbuf(stdout, NULL);
gettimeofday (&tb, NULL);
/* eventually this might want to use /dev/urandom or
* something on machines that have it. otherwise,
* this does a fairly decent job of using the system
* clock.
*
* multiply tv_usec (range 0-1000000) to be in range 0-2^31,
* and xor to randomize the high bits of tv_sec that don't
* change very much.
*/
srand(tb.tv_sec ^ (tb.tv_usec * 2147));
while ((ch = getopt(argc, argv, "Aa:bCc:D:d:EeFf:H:hIiL:l:M:m:NnPpq:RrSs:Tt:UuVvxw:zgG:y")) != EOF)
switch (ch) {
case 'f':
LFTSetupSendDevice(sess, optarg);
break;
case 'F':
LFTSetupFIN(sess);
break;
case 'h':
LFTSetupDispSymbHost(sess);
break;
case 'u':
LFTSetupUDPMode(sess);
break;
case 'r':
LFTSetupRISLookup(sess);
break;
case 'R':
LFTSetupRADBLookup(sess);
break;
case 'C':
LFTSetupCYMRULookup(sess);
break;
case 'd':
LFTSetupDestinationPort(sess, optarg);
break;
case 'L':
LFTSetupLengthOfPacket(sess, (int)strtol(optarg, (char **)NULL, 10));
break;
case 'q':
sess->seq_start = strtol(optarg, (char **)NULL, 10);
break;
case 'w':
sess->win_len = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'm':
sess->retry_min = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'M':
sess->retry_max = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'N':
sess->do_netlookup = 1;
break;
case 'A':
sess->do_aslookup = 1;
break;
case 'n':
LFTSetupDisableResolver(sess);
break;
case 'T':
sess->timetrace = 1;
break;
case 's':
LFTSetupSourcePort(sess, lft_resolve_port(sess,optarg));
break;
case 'E':
case 'e':
LFTSetupAdaptiveMode(sess);
break;
case 'S':
sess->nostatus = 1;
break;
case 'D':
LFTSetupDevice(sess,optarg);
break;
case 'a':
sess->ahead_limit = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'c':
sess->scatter_ms = (int)strtol(optarg, (char **)NULL, 10);
if (sess->scatter_ms < 1)
sess->scatter_ms = 1;
if (sess->scatter_ms > 100)
sess->scatter_ms = 100;
break;
case 't':
sess->timeout_ms = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'p':
sess->protocol = 2;
break;
/*case 'P': //We comment this option. Hardly any routers support this.
sess->protocol = 3;
break;*/
case 'b':
sess->protocol = 4;
break;
case 'H':
if (strtol(optarg, (char **)NULL, 10) > 255)
sess->ttl_limit = 255; else
sess->ttl_limit = (int)strtol(optarg, (char **)NULL, 10);
break;
case 'l':
sess->ttl_min = (int)strtol(optarg, (char **)NULL, 10);
sess->hop_info_length = sess->ttl_min;
if (sess->ttl_min > 0)
sess->ttl_min--;
break;
case 'i':
sess->break_on_icmp = 0;
break;
case 'I':
sess->set_tos = 1;
break;
case 'v':
show_version();
break;
case 'U': /* show all times in UTC */
LFTSetupUTCTimes(sess);
break;
case 'V':
sess->noisy++;
sess->nostatus = 1;
break;
case 'z':
sess->random_source = 1;
/* Yes, this is a ridiculous randomizer, but it's adequate */
sess->sport = rand()%32525+32525;
break;
case 'x':
setOutputStyle(1);
break;
case 'g':
setOutputStyle(2);
break;
case 'G':
setOutputStyle(2);
sess->graphviz_icon_path=optarg;
break;
case 'y':
sess->check_seam=1;
break;
default:
usage(sess, argv[0]);
}
if((argc - optind) < 1)
usage(sess, argv[0]);
if (sess->noisy && !outputStyleIsXML() && !outputStyleIsGraphViz())
printf ("Layer Four Traceroute (LFT) version %s", version);
if (sess->noisy > 1 && !outputStyleIsXML() && !outputStyleIsGraphViz())
printf (" ... (verbosity level %d)",sess->noisy);
if (sess->noisy && !outputStyleIsXML() && !outputStyleIsGraphViz())
printf ("\n");
if(outputStyleIsXML())
{
printf("\n",sess->noisy);
}
sess->hostname = argv[optind++];
sess->hostname_lsrr_size = 0;
while (optind < argc) {
sess->hostname_lsrr[sess->hostname_lsrr_size++] = argv[optind++];
if (sess->hostname_lsrr_size > IP_LSRR_DEST) {
if(outputStyleIsXML())
{
printf("Unknown host: Too many LSRR hosts - maximum is 8");
printf("\n");
}
else
{
fprintf(stderr, "LFT: Too many LSRR hosts - maximum is 8\n");
}
exit(EXIT_FAILURE);
}
}
if (sess->hostname_lsrr_size > 0) {
sess->hostname_lsrr[sess->hostname_lsrr_size++] = sess->hostname;
sess->hostname = sess->hostname_lsrr[0];
}
/* allow hostname:port if -d not specified and not using UDP */
if ((cp = strchr(sess->hostname, ':'))) {
if (!sess->dflag) {
*cp++ = '\0';
sess->dport = lft_resolve_port (sess,cp);
if (sess->protocol==1) {
sess->dport = (lft_resolve_port (sess,cp)) - 1;
if (sess->dport > (65535 - sess->ttl_limit)) {
sess->dport = (65535 - sess->ttl_limit) - 1;
if(outputStyleIsXML())
printf("Starting UDP port %d is too high. Will start with %d instead.",sess->dport, (65535 - sess->ttl_limit));
else
{
fprintf (stderr,
"LFT warning: Starting UDP port %d is too high. Will start with %d instead.\n", sess->dport, (65535 - sess->ttl_limit));
}
}
}
sess->auto_ports = 0;
}
}
LFTExecute(sess);
LFTSessionClose(sess);
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
WSACleanup();
#endif
if(outputStyleIsXML())
printf("\n");
//getch();
return 0;
}
lft-3.8/include/ 000755 000766 000000 00000000000 13263007004 013507 5 ustar 00vic wheel 000000 000000 lft-3.8/lft_icmptrace.h 000644 000766 000000 00000000567 11053131665 015067 0 ustar 00vic wheel 000000 000000 #ifndef LFT_ICMPTRACE_H
#define LFT_ICMPTRACE_H
#include "lft_lib.h"
#define ICMP_TRACE 30
int generateICMPPacket(
lft_session_params * sess,
LFT_CALLBACK err,
LFT_CALLBACK evt,
struct icmp_trace_packet_s * packet,
u_char ttlval,
u_short unique_id,
u_short seq);
void icmp_trace_main_loop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt);
#endif
lft-3.8/lft.spec 000644 000766 000000 00000006444 11053156744 013550 0 ustar 00vic wheel 000000 000000 # If you don't like the prefix '/usr' you can override it like this:
# rpm -ba|--rebuild --define 'prefix /usr/local'
%{?!prefix:%define prefix %{prefixdef}}
Name: lft
Version: 3.2
Release: 1
Vendor: VOSTROM
Packager: Victor Oppleman
URL: http://pwhois.org/lft/
Source: %{name}-%{version}.tar.gz
Group: Applications/Internet
License: VOSTROM Public License
Provides: lft whob
Requires: libpcap
BuildRoot: %{_tmppath}/root-%{name}-%{version}
Prefix: %{_prefix}
Summary: Alternative traceroute and whois tools for network (reverse) engineers
BuildRequires: libpcap
Obsoletes: fft
%description
LFT, short for Layer Four Traceroute, is a sort of 'traceroute' that
often works much faster (than the commonly-used Van Jacobson method) and
goes through many configurations of packet-filter based firewalls. LFT is the
all-in-one traceroute tool because it can use many different trace methods
and protocols such as ICMP, TCP, and UDP, as well as the RFC-1393 trace. More
importantly, LFT implements numerous other features including AS number
lookups based on global table prefix (not just the RIR), loose source routing,
netblock name lookups, et al. Also inlcudes a nifty whois client named 'whob'.
%prep
%setup
%build
%configure
%{__make} %{?_smp_mflags}
%install
%{__rm} -rf %{buildroot}
%makeinstall DESTDIR="%{buildroot}%{_bindir}" MANDIR="%{buildroot}%{_mandir}/man8"
%clean
%{__rm} -rf %{buildroot}
%files
%defattr(-, root, root, 0755)
%{_mandir}/man8/*
%doc CHANGELOG COPYING README TODO
%attr(4755, root, root) %{_bindir}/lft
%attr(0755, root, root) %{_bindir}/whob
%changelog
* Mon Aug 22 2005 Victor Oppleman
- Added -z option to pseudo-randomize source port
- Added behavior to automatically select the most appropriate interface
based on routing (this was on the most wanted list)
- Improved OpenBSD compatibility (IP length nonzero)
- OpenBSD is now detected by autoconf (for configuring the above)
- Darwin is now detected by autoconf and its definition disables
some BSD features to make it compatible with MacOS X and Darwin
- LFT now indicates it has reached the target by printing a 'T'
character in the status display (if status is enabled)
- Cleanups were made to the verbose output levels (-VVV)
- Significantly revamped whois framework makes it easy to include
whois functionality into other programs
- Added -C and -R and -r options to force alternate ASN sources:
- (r)IPE RIS
- (C)ymru
- (R)ADB
- Default ASN source (-A) is now Prefix WhoIs (see pwhois.org)
- LFT now queries for ASNs in bulk format after completing
a trace if pwhois (default), RIPE NCC RIS, or Cymru is selected
- Added dst/src port autoselection based on user-supplied hostname
- Vastly improved standalone whois client "whob" see whob.8 (whob manpage)
- Makefile now installs 'whob' no-frills whois client (try ./whob)
- "Smart" mode is now referred to as "Adaptive" mode (-E)
* Fri Nov 26 2004 Victor Oppleman
- Cleaned up various files, updated to support LFT 2.3
* Sun Apr 20 2003 Nils McCarthy
- Incorporated changes from Dag Wieers cleaning up
- a lot of the build process.
* Thu Mar 06 2003 Nils McCarthy
- revised to work with autoconf
* Mon Oct 28 2002 Florin Andrei
- first version
- v2.0-1
lft-3.8/lft_ifname.h 000644 000766 000000 00000001171 11053131665 014347 0 ustar 00vic wheel 000000 000000 /*
* lft_ifname.h
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#ifndef LFT_IFNAME_H
#define LFT_IFNAME_H
#ifdef __cplusplus
extern "C" {
#endif
#define STRNCPY(dst, src, len) { \
(dst)[(len)-1] = '\0'; \
strncpy((dst),(src),(len)-1); \
}
extern u_long lft_getifaddr (const char *);
extern char * lft_getifname (struct in_addr);
#ifdef __cplusplus
}
#endif
#endif /*LFT_IFNAME_H*/
lft-3.8/whob.8 000644 000766 000000 00000011432 13071535402 013122 0 ustar 00vic wheel 000000 000000 .Dd August 17, 2002
.Dt WHOB 8
.Os WHOB
.Sh NAME
.Nm whob
.Nd display whois-type information of interest to Internet operators
.Sh SYNOPSIS
.Nm whob
.Op Fl h Ar whois-server
.Op Fl g
.Op Fl AaCcfhNnOopRrstuVv
.Ar query
.Sh DESCRIPTION
.Nm
queries various sources of whois information for data of interest to network
operators and their tracing and debugging tools.
.Pp
.Nm
output is designed to be easily parsed, or better yet, its functionality
can be added directly into your programs (see whois.h).
.Pp
The only mandatory parameter is the target host name or IP number.
Options toggle the display of more interesting data or change the sources
used to obtain that data.
.Pp
One key advantage of
.Nm
is its lookup of ASN information derived from the
global Internet routing table itself, as opposed to relying solely on what
has been registered in the RADB/IRR (see below). This data is, by default,
sourced from the global pWhoIs service. See www.pwhois.org
.Pp
Other options are:
.Bl -tag -width Ds
.It Fl A Ar ASN
Display all routing advertisements transiting the respective ASN. The
ASN may be supplied as the target argument, or a hostname or IP address may
be supplied and
.Nm
will resolve the ASN automatically.
.It Fl a Ar ASN
Display all routing advertisements made by the respective Origin-AS. The
Origin-AS may be supplied as the target argument, or a hostname or IP address may
be supplied and
.Nm
will resolve the ASN automatically.
.It Fl P Ar prefix
Display all routing advertisements related to the CIDR prefix supplied by the user.
.It Fl N Ar ASN
Display all networks registered to the ASN supplied by the user.
.It Fl O Ar ASN
Display all contact information on file for the ASN supplied by the user.
.It Fl g
Disable GIGO mode. By popular request, whob takes input directly from the command line
and passes it without modification to pWhoIs or whatever whois server is requested (-h).
The exact output is returned without any parsing. To enable parsing and the other
useful switches, disable GIGO mode by passing this (-g) option.
.It Fl R
Display the Origin-AS on record at the RADB/IRR (Routing Arbiter Database/Internet Routing Registry)
in addition the the Origin-AS provided by the prefix-based whois data source.
.It Fl n
Display the network name on record with the IP network allocation registry also
such as ARIN, RIPE, or APNIC.
.It Fl o
Display the organization name on file at the registrar.
.It Fl p
Display the AS-Path from the perspective of the current pwhois server. The pwhois
server may automatically exclude the initial, least specific ASN received from
the operator of the network to which it is connected (unless that ASN is the only/origin
ASN or unless it has multiple peers). Of course, this AS-Path is subjective. If you
rely on this and want AS-Paths that correspond to *your* network infrastructure, you
may want to install your own pwhois server. See the (-w) option and www.pwhois.org
.It Fl t
Display the date the route was last cached by the pWhoIs server.
.It Fl u
When possible, display dates in UTC/GMT instead of local time.
.It Fl h/w Ar host
Change the source of prefix-based whois data from the default (pWhoIs) to any
whois-compatible server of your choice (like your own).
.It Fl f Ar file
Read from the specified file (or from stdin if the argument is '-') and submit its contents
as bulk input to pwhois. The input will be buffered accordingly and subject to the
constraints of the current pwhois server. Output is written to STDOUT (which may be
redirected) and will not be parsed. Additional instructions to pwhois may be placed at
the beginning of the file, however they will only apply to the first buffer of pwhois
input. The first (left-most) field in each line of the file must be the IP address and
lines may be up to 255 characters in length.
.It Fl c
Change the source of prefix-based whois data from the default (pWhoIs) to Cymru.
See www.cymru.com for more details. When used with the -f option, this switch causes
.Nm
to use Cymru whois for bulk file resolution instead of pwhois.
.It Fl r
Display the Origin-AS and prefix according to RIPE NCC RIS (see www.ripe.net/projects/ris/).
When used with the -f option, this switch causes
.Nm
to use RIPE NCC riswhois for bulk file resolution instead of pwhois.
.It Fl s
Show the status of the (respective) pWhoIs server and exit(0)
.It Fl V
Display verbose/debug output. Use multiple 'V's for additional verbosity.
.It Fl v
Display this client's version information and exit(1)
.It Fl me|whoami
Display this host's public IP address and exit(0)
.El
.Pp
.Sh AUTHORS
Victor Oppleman and Eugene Antsilevitch
.Sh REPORTING BUGS
To report bugs, send e-mail to
.Sh SEE ALSO
.Xr lft 8 ,
.Xr whois 1
.Sh HISTORY
The
.Nm
command first appeared in 2004. This whois framework has been a component of
LFT since 2002.
lft-3.8/lft_btcptrace.h 000644 000766 000000 00000000255 11053131665 015061 0 ustar 00vic wheel 000000 000000 #ifndef LFT_BTCPTRACE_H
#define LFT_BTCPTRACE_H
#include "lft_lib.h"
void tcp_base_trace_main_loop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt);
#endif
lft-3.8/README 000644 000766 000000 00000002017 11053131665 012752 0 ustar 00vic wheel 000000 000000
# This file is part of LFT.
#
# The LFT software provided in this Distribution is
# Copyright 2007 VOSTROM Holdings, Inc.
#
# The full text of our legal notices is contained in the file called
# COPYING, included with this Distribution.
1) LFT stands for "Layer Four Traceroute"
2) We advise you to acquire the latest version of LFT before installing
LFT's web site is located at http://pwhois.org/lft/
3) Please read the "INSTALL" file for instructions on installing LFT
4) Please read the LFT manual page for instructions on using LFT (lft.8)
5) LFT also includes "whob" (a whois client for Internet operators)
WhoB has its own manual page (whob.8).
6) The authors may be reached via e-mail at lft-bugs@oppleman.com
We welcome your feedback. We also welcome your contributions.
If you're interested in helping us make LFT better, please
contact us.
7) Our road map for where we're taking the software may be found in
the "TODO" file.
8) LFT's history of changes can be found in the "CHANGELOG"
ENJOY!
lft-3.8/TODO 000644 000766 000000 00000000603 12041511452 012553 0 ustar 00vic wheel 000000 000000
LFT TO-DO
---------
Features to ADD (not in any particular order)
- TCP-based tracing on windows doesn't work because of "security features"
- IPv6 support, or AF-independent source
- path MTU auto-discovery (RFC 1191)
- display min/avg/max/stddev RTT instead of just the sample
- asynchronus DNS queries
- implement target fingerprinting using TCP timestamps option (RFC 1323)
lft-3.8/lft_lib.h 000644 000766 000000 00000040455 12323066364 013672 0 ustar 00vic wheel 000000 000000 /*
* lft_lib.h
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#ifndef LFT_LIB_H
#define LFT_LIB_H
#include "lft_types.h"
/* not available in earlier darwin systems */
#ifndef AI_NUMERICSERV
#define AI_NUMERICSERV 0
#endif
/* As the trace progresses, each hope will attempt
to work through the states one by one until it
receives an answer (2 attempts per state).
Whatever state "works" - will be then set up on
following hops to continue from.
*/
#define HS_SEND_FIN 0x00
#define HS_SEND_SYN 0x01
#define HS_SEND_SYN_FIN 0x02
#define HS_SEND_RST 0x04
#define HS_SEND_SYN_ACK 0x12
#define HS_SEND_ACK 0x16
#define HS_MAX (HS_SEND_SYN)
#define HF_ENDPOINT 0x01
/* default timeout value */
#define DEFAULT_TIMEOUT_MS 250
/* Common EtherType values */
#ifndef ETHERTYPE_IP
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#endif
#ifndef ETHERTYPE_ARP
#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
#endif
#ifndef ETHERTYPE_REVARP
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
#endif
#ifndef ETHERTYPE_VLAN
#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd /* IPv6 */
#endif
/* Sometimes-missing BPF values */
#ifndef DLT_RAW
#define DLT_RAW 101 /* Raw IP */
#endif
#ifndef DLT_PPP_SERIAL
#define DLT_PPP_SERIAL 50 /* PPP with HDLC encapsulation */
#endif
#ifndef DLT_PPP_ETHER
#define DLT_PPP_ETHER 51 /* PPP over Ethernet */
#endif
#ifndef DLT_LINUX_SLL
#define DLT_LINUX_SLL 113 /* Linux cooked capture */
#endif
#ifndef DLT_PPP
#define DLT_PPP 9 /* PPP over Ethernet */
#endif
/* ToS (type of service) bits we can set on the IP datagram */
#define TOSMINDELAY 0x10
#define TOSMAXTHROUGH 0x08
#define TOSMAXRELIABLE 0x04
#define TOSMINCOST 0x02
/*Errors and warnings codes*/
#define WRN_CANT_SETUP_FIN -1
#define WRN_CANT_DISP_HOST_NAMES -2
#define WRN_ADAPTIVE_DISABLED_BY_UDP -3
#define WRN_FIN_DISABLED_BY_UDP -4
#define WRN_ONLY_ONE_ASN_LOOKUP -5
#define WRN_UDP_PORT_TOO_HIGH -6
#define WRN_PACKET_LENGTH_TOO_HIGH -7
#define WRN_PACKET_LENGTH_TOO_LOW -8
#define WRN_CANT_DISABLE_RESOLVER -9
#define WRN_ALREADY_RANDOM_SPORT -10
#define WRN_ADAPTIVE_DISABLED_BY_FIN -12
#define ERR_DEVNAME_TOO_LONG -13
#define WRN_UNABLE_SETUP_UTC -14
#define WRN_GETIFFORREMOTE_SOCKET -15
#define WRN_GETIFFORREMOTE_CONNECT -16
#define WRN_GETIFFORREMOTE_SOCKNAME -17
#define ERR_UNKNOWN_HOST -18
#define ERR_RAW_SOCKET -19
#define ERR_SOCKET_BIND -20
#define WRN_WSAIOCTL -21
#define ERR_IP_HDRINCL -22
#define ERR_NOT_ENOUGH_MEM -23
#define ERR_RAW_TCP_DISABLED -24
typedef struct _badhopstateparam
{
const struct hop_info_s *h;
short nhop;
}WrnBadHopStateParam;
#define WRN_BAD_HOP_STATE -25
#define WRN_NS_LOOKUP_FAILED -26
#define ERR_WIN_SELECT -27
#define ERR_WIN_RECV -28
#define ERR_WIN_WSASTARTUP -29
#define ERR_PCAP_ERROR -30
#define ERR_DISCOVER_INTERFACE -31
#define ERR_UNKNOWN_INTERFACE -32
#define ERR_UNKNOWN_SEND_INTERFACE -32
#define ERR_PCAP_DEV_UNAVAILABLE -33
#define WRN_BIOCIMMEDIATE -34
#define ERR_PCAP_NONBLOCK_ERROR -35
/*Events codes and their params structures*/
#define EVT_AUTOCONFIGURED_TO_PORTS 1
#define EVT_ADDRESS_INITIALIZED 2
typedef struct _sentpacketparams
{
short nhop;
unsigned int tseq;
unsigned char flags;
unsigned short tttl;
}EvtSentPacketParam;
#define EVT_SENT_PACKET 3
#define EVT_SHOW_PAYLOAD 4
#define EVT_SHOW_UDP_CHECKSUM 5
#define EVT_SHOW_TCP_CHECKSUM 6
#define EVT_SHOW_HOPS 7
#define EVT_SHOW_NUM_HOPS 8
#define EVT_TRACE_COMPLETED 9
#define EVT_ON_RESOLUTION 10
#define EVT_TRACE_REPORT_START 11
typedef struct _rptnoreplyparams
{
int hopno;
int noreply;
}EvtNoReplyParam;
#define EVT_RPT_NO_REPLY 12
#define EVT_RPT_FRW_INSPECT_PACKS 13
#define EVT_RPT_FRW_STATE_FILTER 14
#define EVT_RPT_BSD_BUG 15
#define EVT_RPT_HOP_INFO_START 16
typedef struct _packetinfoevtparam
{
int asnumber;
const char * netname;
struct in_addr last_hop;
int is_asseam;
int is_netseam;
int seam_traced;
int is_open;
int is_filtered;
const struct trace_packet_info_s * tp;
}EvtPacketInfoParam;
#define EVT_RPT_PACKET_INFO 17
#define EVT_RPT_PACKET_LIST_END 18
#define EVT_RPT_NO_HOPS 19
#define EVT_RPT_TIME_TRACE 20
#define EVT_ON_EXIT 21
#define EVT_TTL_NO_REPLY 22
#define EVT_PROGRESS_NO_REPLY 23
#define EVT_TTL_TOUT_RESEND 24
#define EVT_TTL_TOUT_GIVINGUP 25
typedef struct _debugchkpoint1
{
int last_return;
int no_reply;
int need_reply;
}EvtDebugCheckpoint1Param;
#define EVT_DBG_CHECKPOINT1 26
#define EVT_CANT_RELIABLY_RTRIP 27
#define EVT_HAVE_UNANSWERRED_HOPS 28
#define EVT_TOO_FAR_AHEAD 29
#define EVT_HAVE_GAPS 30
#define EVT_EITHER_RESP_OR_TOUT 31
#define EVT_LOOKFOR_UNINC_ACK 32
#define EVT_LOOKFOR_OFF_BY_LEN 33
#define EVT_LOOKFOR_LAST_RESORT 34
#define EVT_SKIP_PACKET 35
typedef struct _nonseqpack
{
struct in_addr ipaddr;
const struct trace_packet_info_s * tp;
}EvtNonSeqPacketParam;
#define EVT_ACK_WAS_NOT_INC 36
#define EVT_RST_REL_TO_ISN 37
#define EVT_ACK_WAS_WAY_OFF 38
#define EVT_DUPLICATE_PACKET 39
#define EVT_PROGRESS_DUPLICATE 40
typedef struct _recvpacket
{
struct in_addr ipaddr;
struct trace_packet_info_s * tp;
unsigned int seq;
}EvtRecvPacketParam;
#define EVT_RECV_PACKET 41
#define EVT_PROGRESS_OK 42
#define EVT_TCP_PORT_CLOSED 43
#define EVT_TCP_PORT_OPEN 44
#define EVT_PROCESS_PACKET_START 45
#define EVT_UDP_NOT_FOR_US 46
typedef struct _incomudpicmp
{
const struct ip * ip;
const struct ip * orig_ip;
const struct udphdr *udp;
const struct icmp *icmp;
}EvtIncomingICMPUDPParam;
#define EVT_INCOMING_ICMP_UDP 47
#define EVT_RCVD_ICMP_UDP 48
typedef struct _incomtcpicmp
{
const struct ip * ip;
const struct ip * orig_ip;
const struct tcphdr *tcp;
const struct icmp *icmp;
}EvtIncomingICMPTCPParam;
#define EVT_INCOMING_ICMP_TCP 49
#define EVT_RCVD_ICMP_TCP 50
#define EVT_RCVD_TCP 51
#define EVT_RCVD_UNKNOWN 52
#define EVT_DEVICE_SELECTED 53
#define EVT_SHOW_INITIAL_SEQNUM 54
#define EVT_TRACE_START 55
#define EVT_DBG_CHECKPOINT2 56
#define EVT_DBG_LOG_MESSAGE 57
#define EVT_PROGRESS_SKIP_PACKET 58
#define EVT_OPEN_CHECK_RESULT 59
#define ERR_BTCP_PROBE_PORT_IS_BUSY 60
#define ERR_BTCP_WRONG_PORT_VALUE 61
#define EVT_OCHECK_START 62
#define WRN_OCHECK_OPEN_SOCK 63
#define WRN_OCHECK_IOCTL 64
#define WRN_OCHECK_SELECT 65
#define WRN_OCHECK_GETERROR 66
#define WRN_OCHECK_SOCKERROR 67
#define WRN_OCHECK_TIMEOUT 68
#define EVT_OCHECK_OPEN 69
#define WRN_OCHECK_FCNTLGET 70
#define WRN_OCHECK_FCNTLSET 71
#define WRN_OCHECK_CONNECTERR 72
typedef struct _incomechoreplyicmp
{
const struct ip * ip;
const struct icmp_echo_header_s * echo;
}EvtIncomingICMPEchoParam;
#define EVT_INCOMING_ICMP_Echo 73
#define EVT_RCVD_ICMP_Echo 74
typedef struct _incomicmpicmp
{
const struct ip * ip;
const struct icmp * icmp;
const struct ip * orig_ip;
const struct icmp_echo_header_s * echo;
}EvtIncomingICMPICMPParam;
#define EVT_INCOMING_ICMP_ICMP 75
#define EVT_RCVD_ICMP_ICMP 76
#if defined(BSD_IP_STACK) && !defined(OPENBSD)
#define SCREWED_IP_LEN
#endif
typedef struct btcpmapentry
{
int nhop;
int port;
int sentcount;
}BasicTCPMapEntry;
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _btcp_debug_info
{
int type;
int hop;
int phop;
int port;
struct in_addr ip;
}btcp_debug_info;
/* Session parameters */
typedef struct _lft_session_params
{
struct timeval ts_last_sent;
struct timeval now;
double scatter_ms; /* milleseconds between sends */
int ttl_min; /* user may request to start at a higher TTL */
int hop_info_length;
unsigned short ip_id; /*not used*/
unsigned char tcp_flags;
int use_fins;
int seq_start; /* generate ISN internally by default */
int dport; /* set default destination to tcp/80 HTTP */
int sport; /* set default source to tcp/53 dns-xfer */
int auto_ports; /* enable port autoselection by default */
int random_source; /* disable random source port by default */
int set_tos; /* disable set ToS bit by default */
int userlen; /* user-requested packet length */
int payloadlen; /* the final probe payloadlength */
int win_len;
int timeout_ms; /* timeout between retries */
int retry_max; /* number of retries before giving up */
int retry_min; /* minimum number of checks per hop */
int ahead_limit; /* number of probes we can send
* without replies if we don't know
* the number of hops */
int dflag;
int ttl_limit; /* max # hops to traverse (highest TTL) */
int break_on_icmp; /* break on icmp other than time exceeded */
int noisy; /* disable verbose debug by default */
int nostatus; /* print status bar by default */
int userdevsel; /* by default, we'll select the device */
int senddevsel; /* by default, we'll select the device */
int resolve_names; /* dns resolution enabled by default */
int hostnames_only; /* disable printing of IP addresses */
int timetrace; /* disable tracer timing by default */
int adaptive; /* disable state engine by default */
int protocol; /* 0 - TCP, 1 - UDP, 2 - ICMP base, 3 - ICMP RFC 1393, 4 - TCP basic */
int do_netlookup; /* disable netname lookup by default */
int do_aslookup; /* disable asn lookup by default */
int use_radb; /* use RADB instead of pwhois */
int use_cymru; /* use Cymru instead of pwhois */
int use_ris; /* use RIPE NCC RIS instead of pwhois */
char *payload;
int send_sock;
int skip_header_len;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
int recv_sock;
int wsastarted;
#else
pcap_t * pcapdescr;
#endif
int UseLocalTime;
int num_hops;
/*int num_sent;*/
int num_rcvd;
int target_open;
int target_filtered;
int target_anomaly;
char *hostname;
char *hostname_lsrr[9];
int hostname_lsrr_size;
struct in_addr local_address;
struct in_addr remote_address;
struct timeval begin_time, trace_done_time;
/* The actual packet data (one of..)*/
struct trace_packet_s trace_packet;
struct icmp_trace_packet_s icmp_packet;
/* Packet container with additional info */
/* struct trace_packet_info_s * trace_packet_info;*/ /* indexed by dport - dport NOT USED*/
/* list of packet containers */
SLIST_HEAD(packets_s, trace_packet_info_s) trace_packets;
int trace_packets_num;
/* Map of ports for basic TCP trace */
BasicTCPMapEntry * btcpmap;
int latestmapchoice;
int btcpmapsize;
int btcpdpucnt;
int trg_probe_is_sent;
/* btcp_debug_info debugmap[1000]; */
/* int debugmapidx; */
/* hop information, by ttl */
struct hop_info_s * hop_info;
const char * pcap_dev;
/* data link type as in pcap_datalink() */
int pcap_datalink;
const char * pcap_send_dev;
const char * userdev;
const char * senddev;
/*WHOIS parameters*/
whois_session_params * wsess;
/*User's data*/
void * UsersDataCookie;
/* GraphViz subquery. Disables any output. */
int is_graphviz_subquery;
int check_seam;
char * graphviz_icon_path;
/*Exit status. When this field has value <0 lft will end work as soon as possible*/
int exit_state;
}lft_session_params;
extern const char * icmp_messages[];
extern const char *version;
extern const char *appname;
extern const int maxpacklen;
/*--------------------------- Callbacks definition ---------------------------*/
/*
Paramaters:
lft_session_params * sess - session handle,
int code - code of error or event,
const void * param - additional parameters, depend on code
*/
typedef void (*LFT_CALLBACK)(lft_session_params *, int, const void *);
/*----------------------------------------------------------------------------*/
void LFTInitializeCallbacks(LFT_CALLBACK error_handler, LFT_CALLBACK event_handler);
lft_session_params * LFTSessionOpen(void);
void LFTSessionClose(lft_session_params * sess);
double timediff_ms (struct timeval prior, struct timeval latter);
unsigned int get_address(lft_session_params * sess, const char *host);
#ifndef SCREWED_IP_LEN
u_int32_t ip_cksum (const struct ip *ip);
#endif
u_int32_t tcp_cksum (struct ip *ip, struct tcphdr *tcp, const char * payload, int payload_len);
int hop_state_up (lft_session_params * sess, short nhop);
int hop_state_copy(lft_session_params * sess, short nhop);
unsigned int new_seq(lft_session_params * sess);
/*----------------------------------------------------------------------------*/
/* Safe setting of parameters */
/*----------------------------------------------------------------------------*/
/*Use TCP FIN packets exclusively (defaults are SYN)*/
int LFTSetupFIN(lft_session_params * sess);
/*Display hosts symbolically; suppress IP address display*/
int LFTSetupDispSymbHost(lft_session_params * sess);
/*Use traditional UDP (probes) for tracing instead of TCP*/
int LFTSetupUDPMode(lft_session_params * sess);
#define ASN_LOOKUP_RIS 0
#define ASN_LOOKUP_RADB 1
#define ASN_LOOKUP_CYMRU 2
/*Use RIPE NCC's RIS to resolve ASNs instead of Prefix WhoIs*/
int LFTSetupRISLookup(lft_session_params * sess);
/*Use the RADB to resolve ASNs instead of Prefix WhoIs*/
int LFTSetupRADBLookup(lft_session_params * sess);
/*Use Cymru to resolve ASNs instead of Prefix WhoIs*/
int LFTSetupCYMRULookup(lft_session_params * sess);
/*Destination port number (same as using target:port as target)*/
int LFTSetupDestinationPort(lft_session_params * sess, char * userport);
/*Set the length of the probe packet in bytes*/
int LFTSetupLengthOfPacket(lft_session_params * sess, int plen);
/*Display hosts numerically; disable use of the DNS resolver*/
int LFTSetupDisableResolver(lft_session_params * sess);
/*Source port number*/
int LFTSetupSourcePort(lft_session_params * sess, int port);
/*Use LFT's stateful engine to detect firewalls and path anomalies*/
int LFTSetupAdaptiveMode(lft_session_params * sess);
/*Use a specific device by name or IP address (\"en1\" or \"1.2.3.4\")*/
int LFTSetupDevice(lft_session_params * sess,char * udev);
/*Use a specific device by name or IP address (\"en1\" or \"1.2.3.4\")*/
int LFTSetupSendDevice(lft_session_params * sess,char * sdev);
/*Display all times in UTC (GMT0). Activates -T option automatically*/
int LFTSetupUTCTimes(lft_session_params * sess);
/*----------------------------------------------------------------------------*/
int lft_resolve_port (lft_session_params * sess, const char *strport);
void LFTExecute(lft_session_params * sess);
void lft_printf(lft_session_params * sess, const char *templ, ...);
/*----------------------------------------------------------------------------*/
void setOutputStyle(int nstyle); /* 0 - ordinary output, 1 - xml output */
int outputStyleIsXML(void);
int outputStyleIsGraphViz(void);
int getOutputStyle(void);
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /*LFT_LIB_H*/
lft-3.8/COPYING 000644 000766 000000 00000006151 11053131665 013130 0 ustar 00vic wheel 000000 000000
VOSTROM Public License for Open Source
----------
Copyright (c) 2007 VOSTROM Holdings, Inc.
This VOSTROM Holdings, Inc. (VOSTROM) Distribution (code and documentation)
is made available to the open source community as a public service by VOSTROM.
Contact VOSTROM at license@vostrom.com for information on other licensing
arrangements (e.g. for use in proprietary applications).
Under this license, this Distribution may be modified and the original
version and modified versions may be copied, distributed, publicly displayed
and performed provided that the following conditions are met:
1. Modified versions are distributed with source code and documentation and
with permission for others to use any code and documentation (whether in
original or modified versions) as granted under this license;
2. if modified, the source code, documentation, and user run-time elements
should be clearly labeled by placing an identifier of origin (such as a name,
initial, or other tag) after the version number;
3. users, modifiers, distributors, and others coming into possession or
using the Distribution in original or modified form accept the entire risk
as to the possession, use, and performance of the Distribution;
4. this copyright management information (software identifier and version
number, copyright notice and license) shall be retained in all versions of
the Distribution;
5. VOSTROM may make modifications to the Distribution that are
substantially similar to modified versions of the Distribution, and may
make, use, sell, copy, distribute, publicly display, and perform such
modifications, including making such modifications available under this or
other licenses, without obligation or restriction;
6. modifications incorporating code, libraries, and/or documentation subject
to any other open source license may be made, and the resulting work may be
distributed under the terms of such open source license if required by that
open source license, but doing so will not affect this Distribution, other
modifications made under this license or modifications made under other
VOSTROM licensing arrangements;
7. no permission is granted to distribute, publicly display, or publicly
perform modifications to the Distribution made using proprietary materials
that cannot be released in source format under conditions of this license;
8. the name of VOSTROM may not be used in advertising or publicity
pertaining to Distribution of the software without specific, prior written
permission.
This software is made available "as is", and
VOSTROM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS
SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL
VOSTROM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
lft-3.8/icons/ 000755 000766 000000 00000000000 13263007003 013176 5 ustar 00vic wheel 000000 000000 lft-3.8/whois.h 000644 000766 000000 00000006756 12773061772 013425 0 ustar 00vic wheel 000000 000000 /*
* whois.h
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#ifndef WHOIS_H
#define WHOIS_H
struct ip_list_array {
struct in_addr ipaddr[1024];
int asn[1024];
char netName[1024][32];
char orgName[1024][100];
char application[1024];
int numItems;
};
struct ext_ip_list_array {
struct in_addr ipaddr[1024];
int asn[1024];
char prefix[1024][20];
char netName[1024][32];
char orgName[1024][100];
char application[1024];
double latitude[1024];
double longitude[1024];
char country[1024][50];
char state[1024][50];
char city[1024][50];
char asOrgNameSource[1024][100];
char orgNameSource[1024][100];
char netNameSource[1024][100];
int geoavailable;
int numItems;
};
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _whoissessionparams
{
int w_noisy; /* Don't show debug msgs by default */
char pw_serv[256]; /* User can specify his own pwhois server */
char consolidated_asn[256]; /* ASN returned from pwhois */
char consolidated_asp[256]; /* AS-PATH returned from pwhois */
char consolidated_route[256]; /* Prefix returned from pwhois */
char consolidated_orgname[256]; /* OrgName returned from pwhois */
char consolidated_netname[256]; /* NetName returned from pwhois */
char tbuf[128];
time_t tval;
void * logprintfCookie;
}whois_session_params;
/* must be called BEFORE making any queries */
whois_session_params * w_init(void);
whois_session_params * w_reinit(whois_session_params * wsess);
void w_close(whois_session_params * wsess);
/* return the origin-asn according to the RADB in "3356" format */
int w_lookup_as(whois_session_params * wsess, char *);
/* return the origin-asn according to Cyrmu in "3356" format */
int w_lookup_as_cymru(whois_session_params * wsess, char *);
/* return the origin-asn according to the RIPE RIS in "3356" format */
int w_lookup_as_riswhois(whois_session_params * wsess, char *);
/* return the origin-asn according to pwhois in "3356" format */
int w_lookup_as_pwhois(whois_session_params * wsess, char *);
/* return the network name from the registrar in a string */
char *w_lookup_netname(whois_session_params * wsess, char *);
/* return the organization name from the registrar in a string */
char *w_lookup_orgname(whois_session_params * wsess, char *);
/* return a pointer to an ip_list_array (see above) containing
an 'asn' to each corresponding 'ipaddr' according to Cymru */
int w_lookup_as_cymru_bulk(whois_session_params * wsess, struct ip_list_array*);
/* return a pointer to an ip_list_array (see above) containing
all ip_list_array vars to each corresponding 'ipaddr' according to pwhois */
int w_lookup_all_pwhois_bulk(whois_session_params * wsess, struct ip_list_array*);
int w_lookup_all_pwhois_bulk_ext(whois_session_params * wsess, struct ext_ip_list_array *iplist);
/* return a pointer to an ip_list_array (see above) containing
all ip_list_array vars to each corresponding 'ipaddr' according to RIS whois */
int w_lookup_all_riswhois_bulk(whois_session_params * wsess, struct ip_list_array*);
int w_lookup_all_pwhois(whois_session_params * wsess, char *addr);
int w_lookup_all_riswhois(whois_session_params * wsess, char *addr);
#ifdef __cplusplus
}
#endif
#endif
lft-3.8/lft_icmptrace.c 000644 000766 000000 00000101464 12323066364 015064 0 ustar 00vic wheel 000000 000000 #include "lft_icmptrace.h"
static LFT_CALLBACK LFTErrHandler = NULL;
static LFT_CALLBACK LFTEvtHandler = NULL;
unsigned int icmp_rfc_send_request(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt);
unsigned int icmp_base_send_hop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt, short nhop);
static void icmp_finish(lft_session_params *sess);
static u_short in_cksum(u_short *addr, int len)
{
register int nleft = len;
register u_short *w = addr;
register u_short answer;
register int sum = 0;
while(nleft > 1)
{
sum += *w++;
nleft -= 2;
}
if(nleft == 1)
{
u_short u = 0;
*(u_char *)(&u) = *(u_char *)w;
sum += u;
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;
return answer;
}
/*
struct icmp_trace_packet_s
{
char * packet;
int packet_len;
struct ip * ip_hdr;
struct rfc1393_ip_option_s * icmp_trace_opt;
struct ip_lsrr * lsrr;
struct icmp_echo_header_s * echo;;
char * payload;
int payload_len;
};
*/
#ifndef IPDEFTTL
#define IPDEFTTL 200
#endif
static const char payload_fill[]="VOSTROM";
int generateICMPPacket(
lft_session_params * sess,
LFT_CALLBACK err,
LFT_CALLBACK evt,
struct icmp_trace_packet_s * packet,
u_char ttlval,
u_short unique_id,
u_short seq)
{
char * currptr;
int i,j;
int userlen;
(void)evt;
if(packet->packet)
free(packet->packet);
//size of ip header
packet->packet_len=20; //initial ip header
if(sess->protocol==3)
packet->packet_len+=12; //trace option
if(sess->hostname_lsrr_size)
packet->packet_len+=(sess->hostname_lsrr_size + 1)*4; //lsrr option
//size of icmp header
packet->packet_len+=sizeof(struct icmp_echo_header_s); //icmp header
//size of payload
userlen=sess->userlen;
if(userlen)
{
userlen -= packet->packet_len;
if(userlen<0)
userlen = 0;
if(userlen%4)
userlen+=4-(userlen%4);
}
packet->packet_len+=userlen;
if(!(packet->packet=malloc(packet->packet_len)))
{
err(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
memset(packet->packet, 0,packet->packet_len);
//initialize ip header
currptr = packet->packet;
packet->ip_hdr = (struct ip *)(void *)packet->packet;
packet->ip_hdr->ip_v = 4;
packet->ip_hdr->ip_hl = 5;
if(sess->hostname_lsrr_size)
packet->ip_hdr->ip_hl += sess->hostname_lsrr_size + 1;
if(sess->protocol == 3)
packet->ip_hdr->ip_hl += 3;
packet->ip_hdr->ip_id = unique_id;
if(sess->set_tos)
packet->ip_hdr->ip_tos = TOSMINDELAY;
else
packet->ip_hdr->ip_tos = 0;
packet->ip_hdr->ip_off = IP_DF;
packet->ip_hdr->ip_len = packet->packet_len;
#ifndef SCREWED_IP_LEN
packet->ip_hdr->ip_off = htons(packet->ip_hdr->ip_off);
packet->ip_hdr->ip_len = htons(packet->ip_hdr->ip_len);
#endif
packet->ip_hdr->ip_p = IPPROTO_ICMP;
packet->ip_hdr->ip_src = sess->local_address;
packet->ip_hdr->ip_dst = sess->remote_address;
if(sess->protocol==3)
packet->ip_hdr->ip_ttl = IPDEFTTL;
else
packet->ip_hdr->ip_ttl = ttlval;
currptr += sizeof(struct ip);
//initialize ip option for rfc1393 trace
/*
struct rfc1393_ip_option_s
{
u_char optcode; //=82
u_char optlength; //=12
u_short id; //number to identify icmp trace messages
u_short ohc; //outbound hop count
u_short rhc; //return hop count
struct in_addr origip; //originator ip address
};
*/
if(sess->protocol == 3)
{
packet->icmp_trace_opt = (struct rfc1393_ip_option_s *)(void *)currptr;
packet->icmp_trace_opt->optcode = 82;
packet->icmp_trace_opt->optlength = 12;
packet->icmp_trace_opt->id = seq;
packet->icmp_trace_opt->ohc = 0;
packet->icmp_trace_opt->rhc = 0xFFFF;
packet->icmp_trace_opt->origip = sess->local_address;
currptr+=sizeof(struct rfc1393_ip_option_s);
}
else
packet->icmp_trace_opt = NULL;
/*
struct ip_lsrr {
u_int8_t ipl_code;
u_int8_t ipl_len;
u_int8_t ipl_ptr;
u_int32_t data[9];
char padding[1];
} __attribute__((packed));
*/
if(sess->hostname_lsrr_size)
{
packet->lsrr=(struct ip_lsrr *)(void *)currptr;
currptr+=(sess->hostname_lsrr_size + 1)*4;
for(i = 0; i < sess->hostname_lsrr_size; i++)
packet->lsrr->data[i] = get_address(sess, sess->hostname_lsrr[i]);
packet->lsrr->ipl_code = IPOPT_LSRR;
packet->lsrr->ipl_len = sess->hostname_lsrr_size * 4 + 3;
packet->lsrr->ipl_ptr = 4;
}
packet->ip_hdr->ip_sum = 0;
#ifndef SCREWED_IP_LEN
packet->ip_hdr->ip_sum = ip_cksum(packet->ip_hdr);
#endif
/*
struct icmp_echo_header_s
{
u_char type;
u_char code;
u_short checksum;
u_short id;
u_short sequence;
};
*/
packet->echo=(struct icmp_echo_header_s *)(void *)currptr;
currptr+=sizeof(struct icmp_echo_header_s);
packet->echo->type=ICMP_ECHO;
packet->echo->code=0;
packet->echo->checksum=0;
packet->echo->id=unique_id;
packet->echo->sequence=seq;
if(userlen)
{
packet->payload=currptr;
for(i=0,j=0;ipayload=NULL;
packet->payload_len = userlen;
sess->payload = NULL;
sess->payloadlen = userlen;
packet->echo->checksum=in_cksum((u_short *)(void *)packet->echo, sizeof(struct icmp_echo_header_s)+packet->payload_len);
/*#ifndef SCREWED_IP_LEN
packet->echo->checksum = htons(packet->echo->checksum);
#endif*/
return packet->packet_len;
}
static int icmp_check_timeouts (lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt)
{
int nhop;
int need_reply = 0;
int no_reply = 0;
int last_return = 0;
LFTErrHandler=err;
LFTEvtHandler=evt;
gettimeofday (&(sess->now), NULL);
if (timediff_ms(sess->ts_last_sent, sess->now) < sess->scatter_ms)
return 0; /* not ready to send another packet yet */
if(sess->protocol==2)
{
for(nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++)
{
if(!sess->hop_info[nhop].num_sent)
{
icmp_base_send_hop(sess, err, evt, nhop);
return 0;
}
}
for(nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++)
{
if(sess->hop_info[nhop].num_sent <= sess->retry_max && !sess->hop_info[nhop].ts_last_recv.tv_sec)
{
if(sess->noisy > 4)
{
evt(sess,EVT_TTL_NO_REPLY,&nhop);
if(sess->exit_state<0)
return 0;
}
if(timediff_ms(sess->hop_info[nhop].ts_last_sent, sess->now) >= sess->timeout_ms)
{
/* we timed out waiting for this hop -- retry if we have any
* more tries */
if(sess->hop_info[nhop].num_sent < sess->retry_max)
{
if(!sess->noisy && !sess->nostatus)
evt(sess,EVT_PROGRESS_NO_REPLY,NULL);
if(sess->noisy > 2)
evt(sess,EVT_TTL_TOUT_RESEND,&nhop);
if(sess->exit_state<0)
return 0;
icmp_base_send_hop(sess, err, evt, nhop);
return 0;
}
else
{
no_reply++;
}
}
else
need_reply++; /* we have to wait for this one to timeout */
}
else /* have reply */
last_return = nhop;
}
}
else
{
if(!sess->hop_info[255].num_sent)
{
icmp_rfc_send_request(sess, err, evt);
return 0;
}
if(sess->hop_info[255].num_sent <= sess->retry_max && !sess->hop_info[255].ts_last_recv.tv_sec)
{
if(sess->noisy > 4)
{
evt(sess,EVT_TTL_NO_REPLY,&nhop);
if(sess->exit_state<0)
return 0;
}
if(timediff_ms(sess->hop_info[255].ts_last_sent, sess->now) >= sess->timeout_ms)
{
/* we timed out waiting for this hop -- retry if we have any
* more tries */
if(sess->hop_info[255].num_sent < sess->retry_max)
{
if(!sess->noisy && !sess->nostatus)
evt(sess,EVT_PROGRESS_NO_REPLY,NULL);
if(sess->noisy > 2)
evt(sess,EVT_TTL_TOUT_RESEND,&nhop);
if(sess->exit_state<0)
return 0;
icmp_rfc_send_request(sess, err, evt);
return 0;
}
else
no_reply++;
}
else
need_reply++; /* we have to wait for this one to timeout */
}
else /* have reply */
last_return = 0;
}
if(sess->noisy > 4)
{
EvtDebugCheckpoint1Param edcp;
edcp.last_return=last_return;
edcp.need_reply=need_reply;
edcp.no_reply=no_reply;
evt(sess,EVT_DBG_CHECKPOINT1,&edcp);
if(sess->exit_state<0)
return 0;
}
if(no_reply >= sess->ahead_limit)
{ /* we timed out. */
if((last_return + 3) * 2 < sess->hop_info_length)
{
if((need_reply < 3) && (sess->num_rcvd < 2))
evt(sess,EVT_CANT_RELIABLY_RTRIP,NULL);
if(sess->exit_state<0)
return 0;
icmp_finish(sess);
return 1;
}
}
if((!sess->num_hops || sess->hop_info_length < sess->num_hops || need_reply) && sess->hop_info_length < sess->ttl_limit)
{
if(sess->noisy > 4)
evt(sess,EVT_HAVE_UNANSWERRED_HOPS,NULL);
if(need_reply >= sess->ahead_limit){
if(sess->noisy > 4)
evt(sess,EVT_TOO_FAR_AHEAD,NULL);
return 0; /* wait for some replies before we go on */
}
if(sess->exit_state<0)
return 0;
if(sess->num_hops > 0 && sess->hop_info_length >= sess->num_hops)
{
if(sess->noisy > 3)
evt(sess,EVT_HAVE_GAPS,NULL);
return 0; /* we know how long the path is - wait to fill in the blanks */
}
nhop = sess->hop_info_length++;
if(sess->protocol==2)
icmp_base_send_hop(sess, err, evt, nhop);
else
{
icmp_rfc_send_request(sess, err, evt);
}
}
else
{
if (sess->noisy >= 4)
{
evt(sess, EVT_EITHER_RESP_OR_TOUT, NULL);
if(sess->exit_state < 0)
return 0;
}
if(sess->protocol == 2)
{
for(nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++)
{
if (sess->hop_info[nhop].num_sent < sess->retry_min && sess->hop_info[nhop].num_sent <= sess->retry_max)
{
icmp_base_send_hop(sess, err, evt, nhop);
return 0;
}
}
}
else
{
if(sess->hop_info[255].num_sent < sess->retry_min && sess->hop_info[255].num_sent <= sess->retry_max)
{
icmp_rfc_send_request(sess, err, evt);
return 0;
}
}
icmp_finish(sess);
return 1;
}
return 0;
}
unsigned int icmp_rfc_send_request(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt)
{
struct trace_packet_info_s *pinfo = NULL;
struct sockaddr_in dest;
u_short rfc_unique_seq;
unsigned int nseq;
dest.sin_family = AF_INET;
dest.sin_addr = sess->remote_address;
dest.sin_port = 0;
if(!(pinfo = (struct trace_packet_info_s *)malloc(sizeof(struct trace_packet_info_s))))
{
err(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
memset(pinfo, 0, sizeof(struct trace_packet_info_s));
nseq = new_seq(sess);
nseq &= 0xFFFF;
rfc_unique_seq = nseq;
generateICMPPacket(sess, err, evt, &pinfo->u.icmp_packet, 0, sess->icmp_packet.echo->id, rfc_unique_seq);
/* Packet is ready, fire away */
if(sendto(sess->send_sock, pinfo->u.icmp_packet.packet, pinfo->u.icmp_packet.packet_len, 0, (const struct sockaddr *)(const void *)&dest, sizeof (dest)) < 0)
{
LFTErrHandler(sess, ERR_RAW_TCP_DISABLED, NULL);
free(pinfo);
return 0;
}
pinfo->hopno = 0;
pinfo->seq = rfc_unique_seq;
pinfo->sent = sess->now;
SLIST_INSERT_HEAD(&(sess->trace_packets), pinfo, next);
sess->trace_packets_num++;
/* we use special hop_info #255 */
SLIST_INSERT_HEAD(&(sess->hop_info[255].packets), pinfo, next_by_hop);
sess->hop_info[255].num_sent++;
sess->hop_info[255].all_sent++;
sess->hop_info[255].ts_last_sent = sess->now;
return 1;
}
unsigned int icmp_base_send_hop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt, short nhop)
{
struct trace_packet_info_s *pinfo = NULL;
struct sockaddr_in dest;
u_short base_unique_seq;
unsigned int nseq;
EvtSentPacketParam espparam;
dest.sin_family = AF_INET;
dest.sin_addr = sess->remote_address;
dest.sin_port = 0;
nseq = new_seq(sess);
nseq &= 0xFFFF;
base_unique_seq = nseq;
sess->ts_last_sent = sess->now;
if(!(pinfo = (struct trace_packet_info_s *)malloc(sizeof(struct trace_packet_info_s))))
{
err(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
memset(pinfo, 0, sizeof(struct trace_packet_info_s));
espparam.flags=0;
espparam.nhop=nhop;
espparam.tseq=base_unique_seq;
espparam.tttl=nhop+1;
if (sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_SENT_PACKET, &espparam);
if(sess->exit_state <0 )
{
free(pinfo);
return 0;
}
}
generateICMPPacket(sess, err, evt, &pinfo->u.icmp_packet, nhop+1, sess->icmp_packet.echo->id, base_unique_seq);
/* Packet is ready, fire away */
if(sendto(sess->send_sock, pinfo->u.icmp_packet.packet, pinfo->u.icmp_packet.packet_len, 0, (const struct sockaddr *)(const void *)&dest, sizeof (dest)) < 0)
{
/* printf("errno=%d\n",errno); */
LFTErrHandler(sess, ERR_RAW_TCP_DISABLED, NULL);
free(pinfo);
return 0;
}
pinfo->hopno = nhop;
pinfo->seq = base_unique_seq;
pinfo->sent = sess->now;
SLIST_INSERT_HEAD(&(sess->trace_packets), pinfo, next);
sess->trace_packets_num++;
if(nhop != -1)
{
SLIST_INSERT_HEAD(&(sess->hop_info[nhop].packets), pinfo, next_by_hop);
sess->hop_info[nhop].num_sent++;
sess->hop_info[nhop].all_sent++;
sess->hop_info[nhop].ts_last_sent = sess->now;
}
return 1;
}
static int icmp_recv_packet (lft_session_params * sess, unsigned int seq, struct in_addr ipaddr, int icmp_type, const void * pack, const struct pcap_pkthdr *hdr)
{
struct trace_packet_info_s *tp = NULL, *pinfo = NULL;
const struct icmp_trace_reply_header_s *icmpheader = (const struct icmp_trace_reply_header_s *)pack;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
gettimeofday (&(sess->now), NULL);
#else
sess->now.tv_sec = hdr->ts.tv_sec;
sess->now.tv_usec = hdr->ts.tv_usec;
#endif
/* First, search every probe to find an exact sequence match */
SLIST_FOREACH(tp, &(sess->trace_packets), next)
{
if(tp->seq == seq)
{
break;
}
}
if(!tp)
{
if (sess->noisy)
LFTEvtHandler(sess,EVT_SKIP_PACKET,NULL);
else
if (!sess->nostatus)
LFTEvtHandler(sess,EVT_PROGRESS_SKIP_PACKET,NULL);
return 0;
}
if (tp->recv.tv_sec)
{
if (sess->noisy)
LFTEvtHandler(sess,EVT_DUPLICATE_PACKET, NULL);
else
if (!sess->nostatus)
LFTEvtHandler(sess,EVT_PROGRESS_DUPLICATE,NULL);
return 0;
}
if (sess->noisy > 1)
{
EvtRecvPacketParam erpp;
erpp.ipaddr=ipaddr;
erpp.seq=seq;
erpp.tp=tp;
LFTEvtHandler(sess,EVT_RECV_PACKET,&erpp);
}
else
{
if (!sess->nostatus)
{
LFTEvtHandler(sess,EVT_PROGRESS_OK,NULL);
}
}
if(sess->exit_state < 0)
return 0;
/* increment received packet counter */
sess->num_rcvd++;
tp->recv = sess->now;
if (tp->hopno != -1)
{
if(sess->protocol==3 && icmp_type == ICMP_TRACE)
{
tp->hopno=icmpheader->ohc;
sess->hop_info[tp->hopno].num_sent = sess->hop_info[255].num_sent;
sess->hop_info[tp->hopno].all_sent = sess->hop_info[255].all_sent;
sess->hop_info[tp->hopno].ts_last_sent = sess->hop_info[255].ts_last_sent;
sess->hop_info[tp->hopno].state = sess->hop_info[255].state;
sess->hop_info[tp->hopno].flags = sess->hop_info[255].flags;
}
sess->hop_info[tp->hopno].ts_last_recv = sess->now;
sess->hop_info[tp->hopno].all_rcvd++;
/* indicate this hop has a sequence anomaly */
if(icmp_type==ICMP_UNREACH || icmp_type==ICMP_TIMXCEED)
sess->hop_info[tp->hopno].flags |= HF_ENDPOINT;
}
tp->recv = sess->now;
tp->hopaddr = ipaddr;
if(icmp_type==ICMP_TIMXCEED)
tp->icmp_type = -2;
else
if(icmp_type == ICMP_ECHOREPLY)
tp->icmp_type = -1;
else
tp->icmp_type = icmp_type;
if(icmp_type == ICMP_ECHOREPLY && ipaddr.s_addr == sess->remote_address.s_addr)
{
if(sess->protocol==3)
{
tp->hopno=sess->num_hops+1;
sess->hop_info[tp->hopno].num_sent = sess->hop_info[255].num_sent;
sess->hop_info[tp->hopno].all_sent = sess->hop_info[255].all_sent;
sess->hop_info[tp->hopno].ts_last_sent = sess->hop_info[255].ts_last_sent;
sess->hop_info[tp->hopno].state = sess->hop_info[255].state;
sess->hop_info[tp->hopno].flags = sess->hop_info[255].flags;
sess->hop_info[tp->hopno].ts_last_recv = sess->now;
sess->hop_info[tp->hopno].all_rcvd++;
}
if(!sess->num_hops)
{
sess->num_hops = tp->hopno;
if(!sess->num_hops)
sess->num_hops=1;
}
tp->is_done = 1;
}
else
{
if(icmp_type == ICMP_UNREACH || icmp_type == ICMP_TIMXCEED)
return 1;
if(sess->protocol == 3 && icmp_type == ICMP_TRACE)
{
if(icmpheader->rhc == 0xFFFF) /* outbound packet */
{
if(!(pinfo = (struct trace_packet_info_s *)malloc(sizeof(struct trace_packet_info_s))))
{
LFTErrHandler(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
memcpy(pinfo, tp, sizeof(struct trace_packet_info_s));
SLIST_INSERT_HEAD(&(sess->hop_info[tp->hopno].packets), pinfo, next_by_hop);
}
else
return 1; //while ignore return packets
}
}
return 1;
}
static void icmp_process_packet(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt, const u_char *packet, const struct pcap_pkthdr *hdr)
{
const struct ip *ip, *orig_ip;
const struct icmp *icmp;
const struct icmp_echo_header_s *orig_echo, *resp_echo;
LFTErrHandler=err;
LFTEvtHandler=evt;
if(sess->noisy > 4)
{
LFTEvtHandler(sess,EVT_PROCESS_PACKET_START,NULL);
if(sess->exit_state<0)
return;
}
icmp_check_timeouts(sess, err, evt);
if(sess->exit_state<0)
return;
packet += sess->skip_header_len;
ip = (const void *) packet;
packet += 4 * ip->ip_hl;
switch(ip->ip_p){
case IPPROTO_ICMP:
orig_ip = ip;
icmp = (const void *) packet;
if(icmp->icmp_type != ICMP_ECHOREPLY && icmp->icmp_type != ICMP_UNREACH && !(sess->protocol==2 && icmp->icmp_type == ICMP_TIMXCEED) && !(sess->protocol==3 && icmp->icmp_type == ICMP_TRACE))
return;
if(icmp->icmp_type == ICMP_ECHOREPLY)
{
resp_echo=(const struct icmp_echo_header_s *)icmp;
if(resp_echo->id != sess->icmp_packet.echo->id)
return;
if (sess->noisy > 2) {
EvtIncomingICMPEchoParam echo;
echo.ip=orig_ip;
echo.echo=resp_echo;
LFTEvtHandler(sess,EVT_INCOMING_ICMP_Echo,&echo);
if(sess->exit_state<0)
return;
}
if (sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_RCVD_ICMP_Echo,resp_echo);
if(sess->exit_state<0)
return;
}
icmp_recv_packet(sess, resp_echo->sequence, orig_ip->ip_src, ICMP_ECHOREPLY, NULL, hdr);
return;
}
if(icmp->icmp_type == ICMP_UNREACH || icmp->icmp_type == ICMP_TIMXCEED)
{
ip = &icmp->icmp_ip;
if(ip->ip_p != IPPROTO_ICMP)
return;
packet = (const u_char *) ip;
packet += 4 * ip->ip_hl;
orig_echo = (const struct icmp_echo_header_s *)packet;
if(orig_echo->type != ICMP_ECHO)
return;
if(sess->icmp_packet.echo->id != orig_echo->id)
return;
if (sess->noisy > 2) {
EvtIncomingICMPICMPParam icmpicmp;
icmpicmp.ip=orig_ip;
icmpicmp.icmp=icmp;
icmpicmp.orig_ip=ip;
icmpicmp.echo=orig_echo;
LFTEvtHandler(sess,EVT_INCOMING_ICMP_ICMP,&icmpicmp);
if(sess->exit_state<0)
return;
}
if (sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_RCVD_ICMP_ICMP,icmp);
if(sess->exit_state<0)
return;
}
icmp_recv_packet(sess, orig_echo->sequence, orig_ip->ip_src, icmp->icmp_type, NULL, hdr);
return;
}
if(icmp->icmp_type == ICMP_TRACE)
{
const struct icmp_trace_reply_header_s * itrh=(const struct icmp_trace_reply_header_s *)icmp;
icmp_recv_packet(sess, itrh->id, orig_ip->ip_src, itrh->type, itrh, hdr);
return;
}
default:
if(sess->noisy > 3)
LFTEvtHandler(sess,EVT_RCVD_UNKNOWN,ip);
}
}
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
void win_icmp_process(lft_session_params * sess)
{
fd_set fds;
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 100000;
FD_ZERO(&fds);
FD_SET(sess->recv_sock, &fds);
if (select(sess->recv_sock+1, &fds, 0, 0, &tm) < 0)
{
LFTErrHandler(sess, ERR_WIN_SELECT, NULL);
return;
}
if (FD_ISSET(sess->recv_sock, &fds))
{
/* read packet */
char packetbuf[2048];
int nread;
memset(packetbuf, 0, sizeof(packetbuf));
nread = recv(sess->recv_sock, packetbuf, sizeof(packetbuf), 0);
if (nread <= 0)
{
LFTErrHandler(sess, ERR_WIN_RECV, NULL);
return;
}
icmp_process_packet(sess, LFTErrHandler, LFTEvtHandler, packetbuf, NULL);
}
}
#else
static void pcap_icmp_process_packet(u_char * user_data, const struct pcap_pkthdr *hdr, const u_char * packet)
{
lft_session_params * sess=(lft_session_params *)(void *)user_data;
if(sess->exit_state<0)
return;
icmp_process_packet(sess, LFTErrHandler, LFTEvtHandler, packet, hdr);
}
#endif
void icmp_trace_main_loop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt)
{
LFTErrHandler=err;
LFTEvtHandler=evt;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
while(1)
{
win_icmp_process(sess);
if(sess->exit_state < 0)
break;
if(icmp_check_timeouts(sess, err, evt))
break;
if(sess->exit_state < 0)
break;
}
#else
while(pcap_dispatch(sess->pcapdescr, -1, pcap_icmp_process_packet, (u_char *)sess) >= 0)
{
if(sess->exit_state < 0)
break;
if(sess->noisy > 6)
{
LFTEvtHandler(sess, EVT_DBG_CHECKPOINT2, NULL);
if(sess->exit_state < 0)
break;
}
if(icmp_check_timeouts(sess,err,evt))
break;
if(sess->exit_state<0)
break;
}
#endif
}
static
void icmp_finish(lft_session_params *sess)
{
int hopno;
int maxhop;
int reply, noreply;
int as_for_hop = 0;
struct trace_packet_info_s *tp;
char *netname;
/* int ocres; */
char *myApp = (char *)malloc((strlen(version) * sizeof(char)) + 1 + (strlen(appname) * sizeof(char)));
struct ip_list_array *ipaslist = (struct ip_list_array *)malloc(sizeof(struct ip_list_array));
/* Variables for seam detection */
int icmpcode;
int asseam_hopno=-1;
struct in_addr asseam_hopaddr;
int netseam_hopno=-1;
struct in_addr netseam_hopaddr;
struct in_addr classbmask;
struct in_addr masked_target;
int prevasn=-1;
struct in_addr prevasn_hopaddr;
int prevasn_hopno;
int lastishole;
int netreached=0;
int isseam;
/* ---------------------------- */
inet_aton("255.255.0.0", &classbmask);
masked_target.s_addr=sess->remote_address.s_addr & classbmask.s_addr;
EvtPacketInfoParam ehip;
memset(ipaslist, 0, sizeof(struct ip_list_array));
gettimeofday (&(sess->trace_done_time), NULL);
/*
ocres=open_check(sess);
LFTEvtHandler(sess,EVT_OPEN_CHECK_RESULT,&ocres);
if(ocres==1)
sess->target_open=1;
else
sess->target_open=0;
*/
if (sess->noisy > 3)
{
LFTEvtHandler(sess, EVT_SHOW_NUM_HOPS, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
if(sess->num_hops)
{
maxhop = sess->num_hops;
/* display all packets we received from this host */
SLIST_FOREACH(tp, &(sess->trace_packets), next)
{
if (tp->is_done)
{
tp->hopno = maxhop;
break;
}
}
}
else
{
maxhop = sess->hop_info_length - 1;
}
LFTEvtHandler(sess,EVT_TRACE_COMPLETED, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
/* if user wants ASN resolution from pwhois/cymru/riswhois, do it in bulk */
if (sess->do_aslookup || sess->do_netlookup)
{
if(sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_ON_RESOLUTION, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
if (!sess->use_radb)
{
/* populate bulk ip_addr_list structure */
for (hopno = sess->ttl_min; hopno <= maxhop; hopno++)
{
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop)
{
if (tp->recv.tv_usec)
{
(*ipaslist).ipaddr[as_for_hop] = tp->hopaddr;
as_for_hop++;
(*ipaslist).numItems = (as_for_hop);
break;
}
}
}
if (sess->use_cymru)
{ /* use cymru bulk service */
if (w_lookup_as_cymru_bulk(sess->wsess, &(*ipaslist)) != 0)
if (sess->noisy) LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
}
else
if (sess->use_ris)
{ /* use RIPE NCC RIS service */
if (w_lookup_all_riswhois_bulk(sess->wsess, &(*ipaslist)) != 0)
if (sess->noisy)
LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
}
else
{ /* use pwhois bulk service */
if ((strlen(version) * sizeof(char)) + 1 + (strlen(appname) * sizeof(char)) < 254)
{
*myApp = '\0';
strcat(myApp, appname);
strcat(myApp, " ");
strcat(myApp, version);
strncpy((*ipaslist).application, myApp, 511);
}
if (w_lookup_all_pwhois_bulk(sess->wsess, &(*ipaslist)) != 0)
if (sess->noisy)
LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
}
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
}
free(myApp);
LFTEvtHandler(sess,EVT_TRACE_REPORT_START, &maxhop);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
/* seam detection */
as_for_hop=0;
for(hopno = sess->ttl_min; hopno < sess->hop_info_length; hopno++)
{
struct in_addr last_hop;
icmpcode=-100;
last_hop.s_addr = 0;
if(sess->hop_info[hopno].all_rcvd)
{
lastishole=0;
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop)
{
if(tp->recv.tv_sec)
{
if(hopno<=maxhop)
icmpcode=tp->icmp_type;
if(last_hop.s_addr != tp->hopaddr.s_addr)
{
if((tp->hopaddr.s_addr & classbmask.s_addr) == masked_target.s_addr)
netreached=1;
else
{
netseam_hopno=hopno;
netseam_hopaddr=tp->hopaddr;
}
if(sess->do_aslookup || sess->do_netlookup)
{
if (sess->use_radb)
{
/* using RADB/IRR */
tp->asnumber = w_lookup_as(sess->wsess, inet_ntoa(tp->hopaddr));
}
else
{
/* using pwhois by default */
tp->asnumber = (*ipaslist).asn[as_for_hop];
}
if(prevasn==-1)
{
if(tp->asnumber)
{
prevasn=tp->asnumber;
prevasn_hopno=hopno;
prevasn_hopaddr=tp->hopaddr;
}
}
else
{
if(tp->asnumber)
{
if(tp->asnumber!=prevasn)
{
asseam_hopno=prevasn_hopno;
asseam_hopaddr=prevasn_hopaddr;
}
prevasn=tp->asnumber;
prevasn_hopno=hopno;
prevasn_hopaddr=tp->hopaddr;
}
}
}
last_hop=tp->hopaddr;
}
}
}
as_for_hop++;
}
else
lastishole=1;
if(icmpcode==-1)
break;
}
if(!netreached)
netseam_hopno=-1;
if(lastishole)
asseam_hopno=-1;
/* -------------- */
noreply = 0;
reply = 0;
as_for_hop = 0; /* this correlates the hopno to the asn stored in ipaslist */
for (hopno = sess->ttl_min; hopno <= maxhop; hopno++)
{
struct in_addr last_hop;
if (sess->hop_info[hopno].all_rcvd != 0)
{
if (noreply >= 1)
{
EvtNoReplyParam nrp;
nrp.hopno=hopno;
nrp.noreply=noreply;
LFTEvtHandler(sess,EVT_RPT_NO_REPLY, &nrp);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
}
last_hop.s_addr = 0;
if ((sess->hop_info[hopno].state == HS_SEND_FIN) && (sess->hop_info[hopno+1].state == HS_SEND_SYN) && (sess->hop_info[hopno+1].ts_last_recv.tv_sec))
{
LFTEvtHandler(sess,EVT_RPT_FRW_INSPECT_PACKS, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if ((sess->hop_info[hopno].state != HS_SEND_SYN_ACK) && (sess->hop_info[hopno+1].state == HS_SEND_SYN_ACK) && (hopno == (sess->num_hops - 1)))
{
LFTEvtHandler(sess,EVT_RPT_FRW_STATE_FILTER, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if ((sess->hop_info[hopno].flags & HF_ENDPOINT) && (noreply >= ((maxhop - sess->ttl_min)/2)) && sess->num_hops > 3)
{
LFTEvtHandler(sess,EVT_RPT_BSD_BUG, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if (sess->hop_info[hopno].all_rcvd == 0)
{
reply = 0;
}
else
{
LFTEvtHandler(sess,EVT_RPT_HOP_INFO_START,&hopno);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
//printf("hopno=%d all_rcvd=%d",hopno,sess->hop_info[hopno].all_rcvd);
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop)
{
if (tp->recv.tv_sec)
{
reply = 1;
if (last_hop.s_addr != tp->hopaddr.s_addr)
{
ehip.asnumber = 0; /* init/clear the ASN */
if (sess->do_aslookup)
{
if (sess->use_radb)
{
/* using RADB/IRR */
ehip.asnumber = w_lookup_as(sess->wsess, inet_ntoa(tp->hopaddr));
}
else
{
/* using pwhois by default */
ehip.asnumber = (*ipaslist).asn[as_for_hop];
}
}
tp->asnumber=ehip.asnumber;
ehip.netname=NULL;
if (sess->do_netlookup)
{
if (!sess->do_aslookup || (sess->do_aslookup && !sess->use_cymru && !sess->use_radb))
{
netname = (*ipaslist).netName[as_for_hop];
}
else
{
netname = w_lookup_netname(sess->wsess, inet_ntoa(tp->hopaddr));
}
ehip.netname = netname;
}
if(ehip.netname)
strncpy(tp->netname, ehip.netname, 511);
else
tp->netname[0]=0;
}
ehip.last_hop = last_hop;
tp->last_hop=ehip.last_hop;
last_hop = tp->hopaddr;
}
ehip.tp = tp;
/* seam processing */
isseam=0;
ehip.is_asseam=0;
ehip.is_netseam=0;
ehip.is_open=0;
ehip.is_filtered=0;
ehip.seam_traced=0;
if(sess->check_seam && hopno==asseam_hopno && tp->hopaddr.s_addr==asseam_hopaddr.s_addr)
{
isseam=1;
ehip.is_asseam=1;
}
if(sess->check_seam && hopno==netseam_hopno && tp->hopaddr.s_addr==netseam_hopaddr.s_addr)
{
isseam=1;
ehip.is_netseam=1;
}
if(isseam)
{
if(sess->check_seam)
{
int curroutputstyle=getOutputStyle();
char hostname[100];
ehip.seam_traced=1;
setOutputStyle(2);
lft_session_params * subsess=LFTSessionOpen();
strncpy(hostname, inet_ntoa(tp->hopaddr),100);
subsess->senddevsel = 1;
subsess->senddev = sess->pcap_send_dev;
subsess->userdevsel = 1;
subsess->userdev = sess->pcap_dev;
subsess->auto_ports=0;
subsess->dport=179;
subsess->seq_start=30;
subsess->retry_min=1;
subsess->retry_max=1;
subsess->resolve_names=0;
subsess->ahead_limit=1;
subsess->break_on_icmp = 0;
subsess->is_graphviz_subquery=1;
subsess->hostname=hostname;
subsess->hostname_lsrr_size = 0;
LFTExecute(subsess);
ehip.is_open=subsess->target_open;
ehip.is_filtered=subsess->target_filtered;
LFTSessionClose(subsess);
setOutputStyle(curroutputstyle);
}
}
/* --------------- */
LFTEvtHandler(sess,EVT_RPT_PACKET_INFO,&ehip);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
LFTEvtHandler(sess,EVT_RPT_PACKET_LIST_END,NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if (reply)
{
noreply = 0;
as_for_hop++;
}
else
noreply++;
reply = 0;
} /* for(...) */
if (!sess->num_hops)
{
LFTEvtHandler(sess,EVT_RPT_NO_HOPS,&maxhop);
}
if (sess->timetrace)
{
LFTEvtHandler(sess,EVT_RPT_TIME_TRACE,NULL);
}
LFTEvtHandler(sess,EVT_ON_EXIT,NULL);
free(ipaslist);
return;
}
lft-3.8/lft_lsrr.h 000644 000766 000000 00000001265 11053131665 014076 0 ustar 00vic wheel 000000 000000 /*
* lft_lsrr.h
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#ifndef LFT_LSRR_H
#define LFT_LSRR_H
#if defined(sun)
typedef uint8_t u_int8_t;
typedef uint32_t u_int32_t;
#endif
struct ip_lsrr {
u_int8_t ipl_code; /* IPOPT_TS */
u_int8_t ipl_len; /* size of structure (variable) */
u_int8_t ipl_ptr; /* index of current entry */
u_int32_t data[9];
char padding[1];
} __attribute__((packed));
#define IP_LSRR_DEST 8
#endif
lft-3.8/lft.8 000644 000766 000000 00000040262 12051071703 012747 0 ustar 00vic wheel 000000 000000 .Dd August 17, 2002
.Dt LFT 8
.Os LFT
.Sh NAME
.Nm lft
.Nd display the route packets take to a network host/socket using one of several
layer-4 protocols and methods; optionally show heuristic network information in transitu
.Sh SYNOPSIS
.Nm lft
.Op Fl d Ar dport
.Op Fl s Ar sport
.Op Fl m Ar retry min
.Op Fl M Ar retry max
.Op Fl a Ar ahead
.Op Fl c Ar scatter ms
.Op Fl t Ar timeout ms
.Op Fl l Ar min ttl
.Op Fl H Ar max ttl
.Op Fl L Ar length
.Op Fl q Ar ISN
.Op Fl D Ar device
.Op Fl f Ar device
.Op Fl G Ar icons path
.Op Fl ACEINPRSTUVbeghinpruvxyz
.Ar [ <...>]
.Ar target:dport
.Sh DESCRIPTION
The Internet is a large and complex aggregation of network hardware,
connected together by gateways. Tracking the route one's packets follow
(or finding the miscreant gateway that's discarding your packets) can be
difficult. (from traceroute(8))
.Pp
.Nm
was developed to automate a solution to the above, taking into
account that modern networks contain many configurations of load balancers,
proxies, and stateful firewalls.
.Pp
.Nm
implements numerous network tracing methods and strategies. Generally,
.Nm
sends various types of layer-4 probes utilizing the IP protocol `time to live'
field and attempts to elicit an
.Tn ICMP `time exceeded in transit'
response from each gateway along the path to some host. RFC 1393 Traceroute
Using an IP Option is also available as one of several tracing methods.
.Pp
.Nm
additionally listens for various messages along the way to assist network
managers in ascertaining per-protocol heuristic routing information.
.Nm
can optionally retrieve various information about the networks it traverses using
a variety of sources such as registries, routing arbiters, etc.
.Pp
The only mandatory parameter is the target host name or IP number.
Options toggle the display of more interesting data or change the variables
of the trace itself. The (-E/-e) adaptive option tries several combinations
of TCP states (changing flags inside the probes it sends) in order to improve
the chances of a successful trace and expose stateful packet filters.
.Pp
Other options are:
.Bl -tag -width Ds
.It Fl d Ar dport
Set
.Ar dport
as the destination TCP port of the probes LFT generates. Default is 80. This option is useful to see if packets follow a different route based on protocol destination, a likely scenario when load balancers or proxies are involved. This option may also bypass less sophisticated packet filter configurations.
.It Fl s Ar sport
Set
.Ar sport
as the origin TCP port of the probes LFT generates. Default is 53. This option is useful to see if packets follow a different route based on protocol source. This option may also bypass less sophisticated packet filter configurations.
.It Fl z
Automatically select a pseudo-random source port. This option may be useful if your local
packet filter or proxy doesn't allow you to use source ports outside of the dymanic range allocation.
.It Fl m Ar min
Set
.Ar min
as the minimum number of re-attempts to send per host. Default is 1 unless adaptive
(-E) mode is used.
.It Fl M Ar max
Set
.Ar max
as the maximum number of re-attempts to send per host. Default is 3.
.It Fl a Ar ahead
Set
.Ar ahead
as the number of hops forward to query before waiting for a response. Default
is 5.
.It Fl c Ar scatter ms
Set
.Ar scatter ms
as the minimum number of milliseconds to wait between sending probes. Default
is 20.
.It Fl t Ar timeout ms
Set
.Ar timeout ms
as the maximum number of milliseconds to wait before assuming a probe was
lost/discarded. Default is 1000.
.It Fl l Ar min ttl
Set
.Ar min tll
as the minimum TTL (time-to-live) on outgoing probes (essentially, the
first hop in the line that you want to display). Default is 1.
.It Fl q Ar ISN
Set
.Ar ISN
as the ISN (initial sequence number) of the first probe. If unset, one will be
automatically generated using a pseudo-random, time-seeded algorithm.
.It Fl L Ar length
Set
.Ar length
as the size of probe packets in bytes. This includes layer-3 and layer-4 headers, but
does not include layer-2 headers. For example, setting the length to 1500 would create
a 1500-byte probe packet which would result in a 1514-byte frame on an Ethernet network.
.It Fl D Ar device
Set
.Ar device
as the network device or address to receive traffic. (e.g., "en1" or "1.2.3.4") If unset,
.Nm
will attempt to determine and acquire the appropriate interface based on routing.
.It Fl f Ar device
Set
.Ar device
as the network device or address to transmit traffic. (e.g., "en1" or "1.2.3.4") If unset,
.Nm
will attempt to determine and acquire the appropriate interface based on routing.
This serves to operate
.Nm
in a passive mode where you may transmit from a (potentially) spoofed IP address on one
interface, yet receive on another. This allows you to trace from a different
IP address whose traffic you can see in order to intercept replies.
.It Fl H Ar ttl
Set
.Ar ttl
as the maximum TTL, essentially the maximum route traversal distance in
hops. Default is 30.
.It Fl G Ar icons path
Set
.Ar icons path
as the path to GraphViz icons in connection with GraphViz output.
.It Fl I
Set the ToS (Type of Serice) bit on outgoing IP datagrams. The ToS will
be set to the differentiated services request minimize-delay.
.It Fl i
Disable "stop" on ICMP other than TTL expired.
.It Fl n
Print addresses numerically rather than symbolically and numerically.
Disables use of the DNS resolver completely.
.It Fl h
Print addresses symbolically rather than symbolically and numerically. If
the DNS resolver fails to resolve an address, the address is printed numerically.
.It Fl E/e
Enable use of the adaptive engine which tries several combinations of TCP states
(changing flags inside the probes it sends) in order to improve
the chances of a successful trace. The engine also displays other useful
information such as stateful inspection firewalls or broken IP stacks
encountered along the way.
.It Fl F
Enable use of TCP packets with the FIN flag set. This strategy fools unsophisticated
packet filters that don't maintain a proper state table. Such devices will forward the packet
to its destination rather than filter it, assuming a handshake has already taken place and
the probes are part of an existing and valid TCP stream.
.It Fl u
Enable use of UDP-based probes instead of TCP-based probes. This strategy is similar
to the traditional traceroute method, but many of LFT's other options (such as source
and destination port selection) are still available. By default, LFT's UDP probes
have a small payload (unlike LFT's TCP probes that carry no payload).
.It Fl N
Enable lookup and display of network or AS names (e.g., [GNTY-NETBLK-4]). This
option queries Prefix WhoIs, RIPE NCC, or the RADB (as requested). In the case of
Prefix WhoIs or RADB, the network name is displayed. In the case of RIPE NCC, the
AS name is displayed.
.It Fl P
Enable RFC 1393 tracing method using ICMP and an IP option. While this strategy
has been formalized in an RFC, few network equipment vendors support it.
.It Fl p
Enable use of ICMP-based probes instead of TCP-based probes. This strategy
is sometimes the fastest, however firewalls commonly filter ICMP at network borders.
ICMP probes are echo request (ping) packets.
.It Fl b
Enable TCP basic tracing method. Unlike the default method, the basic method generates
TCP probes without relying upon sequence numbers being conveyed correctly. This
makes LFT more comptabile with networks employing NAT, but is slower than the default
method. TCP basic may also be used with adaptive mode (-E).
.It Fl A
Enable lookup and display of of AS (autonomous system) numbers (e.g., [1]).
This option queries one of several whois servers (see options 'C' and 'r')
in order to ascertain the origin ASN of the IP address in question. By
default, LFT uses the pWhoIs service whose ASN data tends to be more accurate
and more timely than using the RADB as it is derived from the Internet's global
routing table. See www.pwhois.org
.It Fl r
Force use of the RIPE NCC RIS whois service to lookup ASNs. This is an alternative
source of timely ASN-related information built using the Internet's global
routing table. See www.ripe.net/projects/ris
.It Fl C
Force use of the Cymru whois service to lookup ASNs. This is an
alternative source of timely ASN-related information built using the
Internet's global routing table. See www.cymru.com
.It Fl R
Force use of the RADB whois service to lookup ASNs. This tends to be quick,
but incomplete and usually inaccurate with regard to the 'actual' Internet
routing table. See www.radb.net
.It Fl T
Enable display of LFT's execution timer. This option places timers on the
trace itself and on lookups and name resolution to show where LFT is spending
its time, waiting on resolvers, or processing trace packets. Use with -V (verbose)
to display additional detail.
.It Fl U
Display all times in UTC/GMT0. This option also enables the -T option automatically.
.It Fl S
Suppress display of the real-time status bar. This option makes LFT show its
completed trace output only, no-frills.
.It Fl x
Enable XML output and suppress all other output to stdout.
.It Fl g
Enable GraphViz output and suppress all other output to stdout.
.It Fl y
Enable network seam testing in connection with GraphViz output.
.It Fl V
Display verbose output. Use more V's for more info.
.It Fl v
Display version information, then exit(1).
.El
.Pp
Any hosts listed after these options and before the final host/target will comprise
the loose source route. Since network operators have security concerns
regarding the use of source routing, don't expect the LSRR options
to do anything for you in most public networks.
.Sh EXAMPLES
A sample use and output might be:
.Bd -literal
[edge.lax]$ lft -S 4.2.2.2
Hop LFT trace to vnsc-bak.sys.gtei.net (4.2.2.2):80/tcp
1 ln-gateway.centergate.com (206.117.161.1) 0.5ms
2 isi-acg.ln.net (130.152.136.1) 2.3ms
3 isi-1-lngw2-atm.ln.net (130.152.180.21) 2.5ms
4 gigabitethernet5-0.lsanca1-cr3.bbnplanet.net (4.24.4.249) 3.0ms
5 p6-0.lsanca1-cr6.bbnplanet.net (4.24.4.2) 3.4ms
6 p6-0.lsanca2-br1.bbnplanet.net (4.24.5.49) 3.3ms
7 p15-0.snjpca1-br1.bbnplanet.net (4.24.5.58) 10.9ms
8 so-3-0-0.mtvwca1-br1.bbnplanet.net (4.24.7.33) 11.1ms
9 p7-0.mtvwca1-dc-dbe1.bbnplanet.net (4.24.9.166) 11.0ms
10 vlan40.mtvwca1-dc1-dfa1-rc1.bbnplanet.net (128.11.193.67) 11.1ms
** [neglected] no reply packets received from TTLs 11 through 20
** [4.2-3 BSD bug] the next gateway may errantly reply with reused TTLs
21 [target] vnsc-bak.sys.gtei.net (4.2.2.2) 11.2ms
.Ed
.Pp
The (-S) option was used to suppress the real-time status bar for clean output.
LFT's "**" notifiers in between hops 10 and 21 represent additional useful information: the first is a "[neglected]" indicator that lets us know that none of the probes sent with the TTLs indicated elicited responses. This could be for a variety of reasons, but the cause of this specific occurrence is described in the next informative message which indicates that this is likely the result of a bug in
the 4.[23]
.Tn BSD
network code (and its derivatives): BSD 4.x (x < 3)
sends an unreachable message using whatever TTL remains in the
original datagram. Since, for gateways, the remaining TTL is
zero, the
.Tn ICMP
"time exceeded" is guaranteed to not make it back
to us. LFT does its best to identify this condition rather than print
lots and lots of hops that don't exist (trying to reach a high enough TTL).
.Pp
Now, using the adaptive engine option:
.Bd -literal
[edge.lax]$ lft -E -S 4.2.2.1
Hop LFT trace to vnsc-pri.sys.gtei.net (4.2.2.1):80/tcp
1 ln-gateway.centergate.com (206.117.161.1) 0.5/0.5ms
2 isi-acg.ln.net (130.152.136.1) 2.1/2.3ms
3 isi-1-lngw2-atm.ln.net (130.152.180.21) 2.6/7.1ms
4 gigabitethernet5-0.lsanca1-cr3.bbnplanet.net (4.24.4.249) 6.1/3.9ms
** [firewall] the next gateway may statefully inspect packets
5 p0-0-0.lsanca1-csr1.bbnplanet.net (4.24.4.10) 155.4/3.7ms
6 [target] vnsc-pri.sys.gtei.net (4.2.2.1) 22.6/3.7/*/*/*/*/*ms
.Ed
.Pp
In the scenario above, the adaptive engine was able to identify a stateful, packet-inspecting firewall in the path. Another example with more options:
.Bd -literal
[edge.lax]$ lft -S -A -T -m 2 -d 80 -s 53 www.yahoo.com
Hop LFT trace to w9.scd.yahoo.com (66.218.71.88):80/tcp
1 [226] ln-gateway.centergate.com (206.117.161.1) 1 ms
2 [226] isi-acg.ln.net (130.152.136.1) 2 ms
3 [226] isi-1-lngw2-atm.ln.net (130.152.180.21) 3 ms
4 [1] gigether5-0.lsanca1-cr3.bbnplanet.net (4.24.4.249) 3 ms
5 [1] p6-0.lsanca1-cr6.bbnplanet.net (4.24.4.2) 5 ms
6 [1] p6-0.lsanca2-br1.bbnplanet.net (4.24.5.49) 3 ms
7 [1] p1-0.lsanca2-cr2.bbnplanet.net (4.25.112.1) 3 ms
8 [16852] pos4-0.core1.LosAngeles1.Level3.net (209.0.227.57) 3 ms
9 [3356] so-4-0-0.mp1.LosAngeles1.Level3.net (209.247.10.193) 3 ms
10 [3356] so-3-0-0.mp2.SanJose1.Level3.net (64.159.1.130) 11 ms
11 [3356] gige10-0.ipcolo4.SanJose1.Level3.net (64.159.2.42) 11 ms
12 [3356] cust-int.level3.net (64.152.81.62) 52 ms
13 [10310] vl17.bas2.scd.yahoo.com (66.218.64.150) 53 ms
14 [10310] w9.scd.yahoo.com (66.218.71.88) [target] 54 ms
.Pp
LFT's trace took 5.23 seconds. Resolution required 3.58 seconds.
.Ed
.Pp
Note the -Ar above displays ASNs using the RADB as a whois source. A better option may have been
to use the -A alone or perhaps -AC.
.Pp
And why not request netblock lookups?
.Bd -literal
[edge.lax]$ lft -S -N www.microsoft.com
Hop LFT trace to www.us.microsoft.com (207.46.197.113):80/tcp
1 [LOS-NETTOS-BLK4] ln-gateway.centergate.com (206.117.161.1) 2 ms
2 [LOS-NETTOS] isi-acg.ln.net (130.152.136.1) 3 ms
3 [LOS-NETTOS] isi-1-lngw2-pos.ln.net (130.152.80.30) 5 ms
4 [GNTY-4-0] gigether5-0.lsanca1-cr3.bbnplanet.net (4.24.4.249) 4 ms
5 [GNTY-4-0] p6-0.lsanca1-cr6.bbnplanet.net (4.24.4.2) 3 ms
6 [GNTY-4-0] p6-0.lsanca2-br1.bbnplanet.net (4.24.5.49) 3 ms
7 [GNTY-4-0] p15-0.snjpca1-br1.bbnplanet.net (4.24.5.58) 10 ms
8 [GNTY-4-0] p9-0.snjpca1-br2.bbnplanet.net (4.24.9.130) 11 ms
9 [GNTY-4-0] so-1-0-0.sttlwa2-br1.bbnplanet.net (4.0.3.229) 27 ms
10 [GNTY-4-0] so-0-0-0.sttlwa1-hcr1.bbnplanet.net (4.24.11.202) 28 ms
11 [GNTY-4-0] so-7-0-0.sttlwa1-hcr2.bbnplanet.net (4.24.10.234) 28 ms
12 [GNTY-4-0] p1-0.sttlwa1-cr2.bbnplanet.net (4.24.10.241) 29 ms
13 [GNTY-4-0] p2-0.msseattle.bbnplanet.net (4.25.89.6) 32 ms
14 [MICROSOFT-GLOBAL-NET] 207.46.154.9 32 ms
15 [MICROSOFT-GLOBAL-NET] 207.46.155.17 33 ms
16 [MICROSOFT-GLOBAL-NET] 207.46.129.51 [prohibited] 35 ms
.Ed
.Pp
.Sh TROUBLESHOOTING
If traces don't appear to go anywhere, there are a number of things to try.
If you are receiving an error related to permissions, be sure the
.Nm
executable is set-uid root so it may execute with root-level permissions
required to utilize raw sockets on most operating systems.
.Pp
If you do not receive permissions-related errors, but traces still don't go
anywhere, first activate verbose output by adding -VV to your command line
options. Then, reading the verbose output, if you see trace
probes going out, but no replies being detected (as indicated by "RCVD" tags),
you may: Use the TCP basic (-b) method if you wish to use TCP probes and you
fear NAT may be causing your trace to fail. Alternatively, select a different
trace method and protocol such as UDP (-u) or ICMP (-p).
.Pp
If you are attempting to use RFC 1393 (-P) and your trace is failing, this is
likely because network equipment somewhere in the path does not conform to
RFC 1393. Your only option is to select an alternative tracing method or protocol.
.Pp
If you are attempting to utilize adaptive mode (-E/-e) and traces fail, first
try enabling NAT compatibility using TCP basic (-b). If traces still fail, the
most likely reason is a close-proximity stateful firewall in your network, which
prevents this feature from working.
.Pp
.Sh AUTHORS
Victor Oppleman, Eugene Antsilevitch, Sergey Kondryukov and other helpers around the world.
.Sh REPORTING BUGS
To report bugs, send e-mail to
.Sh SEE ALSO
.Xr traceroute 8 ,
.Xr netstat 1 ,
.Xr whois 1 ,
.Xr whob 8
.Sh HISTORY
The
.Nm
command first appeared in 1998 as 'fft'. Renamed as a result of confusion with fast fourier transforms,
.Nm
stands for 'layer four traceroute.' Thanks also to Nils McCarthy for writing 'FFT', LFT's predecessor.
lft-3.8/Makefile.in 000644 000766 000000 00000003611 12716654514 014152 0 ustar 00vic wheel 000000 000000 #
# This file is part of LFT.
#
# The LFT software provided in this Distribution is
# Copyright 2007 VOSTROM Holdings, Inc.
#
# The full text of our legal notices is contained in the file called
# COPYING, included with this Distribution.
# Directories where LFT will be installed:
prefix=@prefix@
datarootdir = @datarootdir@
datadir = @datadir@
exec_prefix=@exec_prefix@
bindir=@bindir@
mandir=@mandir@
INSTALL=@INSTALL@
LN=@LN_S@
# Commands/References
CC=@CC@
CFLAGS=@CFLAGS@
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@
CAT=cat
CD=cd
MKDIR=mkdir -p
BUILDTYPE=build
RM=rm -rf
SH=sh
SYSTEM=unix
TOOLS=tools
TOUCH=touch
STRIP ?= strip
@SET_MAKE@
# Specifics
OBJS=lft.o lft_ifname.o whois.o lft_lib.o lft_icmptrace.o lft_btcptrace.o
all: lft whob
lft: $(OBJS)
$(CC) $(CFLAGS) -o lft $(OBJS) $(LDFLAGS) $(LIBS)
whob: whois.o
$(CC) $(CFLAGS) -o whob whois.c -DSTANDALONE $(LDFLAGS) $(LIBS)
install: lft lft.8 whob whob.8
@echo "LFT and WhoB"
@echo " \_Stripping binaries"
@$(STRIP) lft whob
@echo " \_Copying files to their intended destinations"
@test -d $(DESTDIR)$(bindir)/. || $(MKDIR) $(DESTDIR)$(bindir)
$(INSTALL) lft $(DESTDIR)$(bindir)/lft
$(INSTALL) whob $(DESTDIR)$(bindir)/whob
@ ( echo chown root $(DESTDIR)$(bindir)/lft && chown root $(DESTDIR)$(bindir)/lft && echo chmod u+s $(DESTDIR)$(bindir)/lft && chmod u+s $(DESTDIR)$(bindir)/lft ) || echo "***" WARNING: could not set $(bindir) suid to root
@test -d $(DESTDIR)$(mandir)/man8/. || $(MKDIR) $(DESTDIR)$(mandir)/man8
@echo "Installing manual pages"
$(INSTALL) lft.8 $(DESTDIR)$(mandir)/man8/lft.8
$(INSTALL) whob.8 $(DESTDIR)$(mandir)/man8/whob.8
clean:
$(RM) *.o core* lft whob *~ *.dSYM
distclean:
$(RM) Makefile config.log config.status config/acconfig.h
better:
@echo "Sorry, this is the best I can do."
work:
@echo "Sorry, I didn't write this. I'm only a Makefile."
love:
@echo "What do you think I was doing before you bothered me?"
lft-3.8/lft_btcptrace.c 000644 000766 000000 00000076736 12323066364 015101 0 ustar 00vic wheel 000000 000000 #include "lft_btcptrace.h"
#include "lft_lib.h"
static LFT_CALLBACK LFTErrHandler=0;
static LFT_CALLBACK LFTEvtHandler=0;
static int getFreePort(lft_session_params * sess, int startfrom)
{
int i;
if(sess->btcpmap == NULL)
{
if(!(sess->btcpmap = malloc(sizeof(BasicTCPMapEntry) * (sess->ttl_limit * sess->retry_max + 1))))
{
LFTErrHandler(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
sess->btcpmapsize=sess->ttl_limit * sess->retry_max + 1;
for(i=0;ibtcpmapsize;i++)
{
sess->btcpmap[i].nhop = -1;
sess->btcpmap[i].port = sess->dport + i;
sess->btcpmap[i].sentcount=0;
}
sess->latestmapchoice=0;
/*sess->debugmapidx=0;*/
}
for(i=(startfrom && sess->latestmapchoice>=startfrom)?sess->latestmapchoice+1:startfrom;ibtcpmapsize;i++)
{
if(sess->btcpmap[i].nhop==-1)
{
if(startfrom)
sess->latestmapchoice=i;
return sess->btcpmap[i].port;
}
}
return sess->dport;
}
static int probeIsSent(lft_session_params * sess, int port, int nhop)
{
int i = port - sess->dport;
if(i<0 || i>=sess->btcpmapsize)
{
LFTErrHandler(sess, ERR_BTCP_WRONG_PORT_VALUE, NULL);
return 0;
}
if(sess->btcpmap[i].nhop!=-1 && sess->btcpmap[i].nhop!=nhop)
{
LFTErrHandler(sess, ERR_BTCP_PROBE_PORT_IS_BUSY, NULL);
return 0;
}
sess->btcpmap[i].nhop=nhop;
sess->btcpmap[i].sentcount++;
return sess->btcpmap[i].sentcount;
}
static int probeIsRecvd(lft_session_params * sess, int port)
{
int nhop;
int i = port - sess->dport;
if(i<0 || i>=sess->btcpmapsize)
{
LFTErrHandler(sess, ERR_BTCP_WRONG_PORT_VALUE, NULL);
return 0;
}
nhop=sess->btcpmap[i].nhop;
sess->btcpmap[i].sentcount--;
if(sess->btcpmap[i].sentcount<1)
{
sess->btcpmap[i].nhop=-1;
sess->btcpmap[i].sentcount=0;
}
return nhop;
}
#if 0
static int hopByPort(lft_session_params * sess, int port)
{
int nhop;
int i = port - sess->dport;
if(i<0 || i>=sess->btcpmapsize)
return -1;
nhop=sess->btcpmap[i].nhop;
if(sess->btcpmap[i].port != port || sess->btcpmap[i].sentcount<1)
return -1;
return nhop;
}
#endif
static unsigned int tcp_base_send_hop(lft_session_params * sess, short nhop, int searchfrom)
{
struct sockaddr_in dest;
unsigned int tseq=0;
unsigned short tttl=0;
char * buf;
char* bptr = NULL;
int blen = 0;
int port;
EvtSentPacketParam espparam;
struct trace_packet_info_s *pinfo = NULL;
struct trace_packet_s *packet = NULL;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
buf=(char *)_alloca(maxpacklen+64);
#else
buf=(char *)alloca(maxpacklen+64);
#endif
if (!(pinfo = (struct trace_packet_info_s *)malloc(sizeof(struct trace_packet_info_s)))) {
LFTErrHandler(sess, ERR_NOT_ENOUGH_MEM, NULL);
return 0;
}
memset(pinfo, 0, sizeof(struct trace_packet_info_s));
packet = &(pinfo->u.packet);
memcpy(packet, &(sess->trace_packet), sizeof(struct trace_packet_s));
bptr = buf;
dest.sin_family = AF_INET;
dest.sin_addr = sess->remote_address;
port=getFreePort(sess, searchfrom);
dest.sin_port = htons(port);
tseq = new_seq(sess);
tttl = nhop + 1;
sess->ts_last_sent = sess->now;
packet->ip_hdr.ip_ttl = tttl;
packet->ip_hdr.ip_src = sess->local_address;
packet->ip_hdr.ip_dst = sess->remote_address;
espparam.flags=sess->tcp_flags;
if(sess->adaptive)
{
struct hop_info_s *h = &(sess->hop_info[nhop]);
if(h->state == HS_SEND_FIN)
espparam.flags = TH_FIN;
else
if(h->state == HS_SEND_SYN)
espparam.flags = TH_SYN;
else
if(h->state == HS_SEND_SYN_ACK)
espparam.flags = HS_SEND_SYN_ACK;
else
{
WrnBadHopStateParam wbhsp;
wbhsp.h=h;
wbhsp.nhop=nhop;
LFTErrHandler(sess, WRN_BAD_HOP_STATE, &wbhsp);
}
}
espparam.nhop=nhop;
espparam.tseq=tseq;
espparam.tttl=tttl;
if (sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_SENT_PACKET, &espparam);
if(sess->exit_state<0)
{
free(pinfo);
return 0;
}
}
packet->ip_hdr.ip_sum = 0;
#if !defined(SCREWED_IP_LEN)
packet->ip_hdr.ip_sum = ip_cksum (&packet->ip_hdr);
#endif
memcpy(bptr, &(packet->ip_hdr), sizeof(struct ip));
bptr += sizeof(struct ip);
if (packet->lsrr.ipl_len > 0) {
memcpy(bptr, &(packet->lsrr), packet->lsrr.ipl_len + 1);
bptr += (packet->lsrr.ipl_len + 1); /* PADDING !!! */
}
/* Layer-4 preparation */
/* Construct TCP (no payload needed) */
if (sess->noisy > 5)
{
LFTEvtHandler(sess,EVT_SHOW_PAYLOAD, packet);
if(sess->exit_state < 0)
{
free(pinfo);
return 0;
}
}
packet->tcp_hdr.th_dport = dest.sin_port;
packet->tcp_hdr.th_seq = htonl (tseq);
packet->tcp_hdr.th_sport = htons (sess->sport);
packet->tcp_hdr.th_flags = espparam.flags;
#if defined(SOLARIS_LENGTH_IN_CHECKSUM)
packet->tcp_hdr.th_sum = htons (sizeof (struct tcphdr)) + packet->payload_len;
#else
packet->tcp_hdr.th_sum = 0;
packet->tcp_hdr.th_sum = tcp_cksum (&packet->ip_hdr, &packet->tcp_hdr, packet->payload, packet->payload_len);
#endif
if (sess->noisy > 5)
{
LFTEvtHandler(sess,EVT_SHOW_TCP_CHECKSUM, packet);
if(sess->exit_state<0)
{
free(pinfo);
return 0;
}
}
memcpy(bptr, &(packet->tcp_hdr), sizeof(struct tcphdr));
bptr += sizeof(packet->tcp_hdr);
memcpy(bptr, packet->payload, packet->payload_len);
blen = sizeof(struct ip) + packet->lsrr.ipl_len + sizeof(struct tcphdr) + packet->payload_len;
/* Packet is ready, fire away */
if (sendto (sess->send_sock, buf, blen, 0, (const struct sockaddr *)(const void *)&dest, sizeof (dest)) < 0) {
LFTErrHandler(sess, ERR_RAW_TCP_DISABLED, NULL);
free(pinfo);
return 0;
}
/*sess->debugmap[sess->debugmapidx].type=0;
sess->debugmap[sess->debugmapidx].hop=nhop;
sess->debugmap[sess->debugmapidx++].port=port;*/
probeIsSent(sess, port, nhop);
pinfo->hopno = nhop;
pinfo->seq = tseq;
pinfo->sent = sess->now;
SLIST_INSERT_HEAD(&(sess->trace_packets), pinfo, next);
sess->trace_packets_num++;
if (nhop != -1) {
SLIST_INSERT_HEAD(&(sess->hop_info[nhop].packets), pinfo, next_by_hop);
sess->hop_info[nhop].num_sent++;
sess->hop_info[nhop].all_sent++;
sess->hop_info[nhop].ts_last_sent = sess->now;
}
return tseq;
}
static void tcp_base_recv_packet (lft_session_params * sess, unsigned int seq, struct in_addr ipaddr, int icmp_type, const struct pcap_pkthdr *hdr)
{
double ms;
struct trace_packet_info_s *tp = NULL;
EvtNonSeqPacketParam ensp;
/* Depending on the platform, we can use
* the pcap header's timeval or we must call
gettimeofday() for each packet */
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
gettimeofday (&(sess->now), NULL);
#else
sess->now.tv_sec = hdr->ts.tv_sec;
sess->now.tv_usec = hdr->ts.tv_usec;
/* gettimeofday (&now, NULL); */
#endif
/* First, search every probe to find an exact sequence match */
SLIST_FOREACH(tp, &(sess->trace_packets), next)
{
if(tp->seq == seq)
break;
}
#if 0
if(tp == NULL)
{
/* Second, search every probe to find an exact port match */
SLIST_FOREACH(tp, &(sess->trace_packets), next)
{
if(hopByPort(sess, htons(tp->packet.tcp_hdr.th_dport)) == tp->hopno)
break;
}
}
#endif
/* Last resort. Catch any response from the target */
if (tp == NULL) {
if (sess->noisy > 3)
{
LFTEvtHandler(sess,EVT_LOOKFOR_LAST_RESORT,NULL);
if(sess->exit_state < 0)
return;
}
SLIST_FOREACH(tp, &(sess->trace_packets), next) {
/* Special case: look for a response to our SYN_ACK */
if (tp->u.packet.tcp_hdr.th_flags == HS_SEND_SYN_ACK) {
if (!tp->recv.tv_sec) {
break;
}
}
/* Truly the last resort: packet from the target with a wacky ACK sequence */
if ((ipaddr.s_addr == sess->remote_address.s_addr) && (tp->hopaddr.s_addr == 0) && (icmp_type == -1)) {
sess->target_anomaly = 1;
}
}
}
/* This packet is not even close, drop it and move on */
if (!tp) {
if (sess->noisy)
LFTEvtHandler(sess, EVT_SKIP_PACKET, NULL);
else
if (!sess->nostatus)
LFTEvtHandler(sess, EVT_PROGRESS_SKIP_PACKET, NULL);
return;
}
if (tp->seq != seq) {
ensp.ipaddr=ipaddr;
ensp.tp=tp;
if (((tp->seq) == (seq + 1)) && (icmp_type == -1)) {
if (sess->noisy > 1) {
LFTEvtHandler(sess,EVT_ACK_WAS_NOT_INC,&ensp);
if(sess->exit_state<0)
return;
}
/* return; */
} else if (((tp->seq) == (seq - sess->payloadlen)) && (icmp_type == -1)) {
if (sess->noisy > 1) {
LFTEvtHandler(sess,EVT_RST_REL_TO_ISN,&ensp);
if(sess->exit_state<0)
return;
}
/* return; */
} else if ((ipaddr.s_addr == sess->remote_address.s_addr) && (icmp_type == -1)) {
if (sess->noisy > 1) {
LFTEvtHandler(sess,EVT_ACK_WAS_WAY_OFF,&ensp);
if(sess->exit_state<0)
return;
}
/* return; */
}
}
if (tp->recv.tv_sec) {
if (sess->noisy)
LFTEvtHandler(sess,EVT_DUPLICATE_PACKET, NULL);
else
if (!sess->nostatus)
LFTEvtHandler(sess,EVT_PROGRESS_DUPLICATE,NULL);
return;
}
/*sess->debugmap[sess->debugmapidx].type=1;
sess->debugmap[sess->debugmapidx].hop=tp->hopno;
sess->debugmap[sess->debugmapidx].phop=hopByPort(sess, htons(tp->packet.tcp_hdr.th_dport));
sess->debugmap[sess->debugmapidx].port=htons(tp->packet.tcp_hdr.th_dport);
sess->debugmap[sess->debugmapidx++].ip=ipaddr;*/
probeIsRecvd(sess, htons(tp->u.packet.tcp_hdr.th_dport));
if (sess->noisy > 1)
{
EvtRecvPacketParam erpp;
erpp.ipaddr=ipaddr;
erpp.seq=seq;
erpp.tp=tp;
LFTEvtHandler(sess,EVT_RECV_PACKET,&erpp);
}
else {
if (!sess->nostatus)
LFTEvtHandler(sess,EVT_PROGRESS_OK,NULL);
}
if(sess->exit_state<0)
return;
/* increment received packet counter */
sess->num_rcvd++;
tp->recv = sess->now;
if (tp->hopno != -1) {
sess->hop_info[tp->hopno].ts_last_recv = sess->now;
sess->hop_info[tp->hopno].all_rcvd++;
hop_state_copy(sess, tp->hopno);
/* indicate this hop has a sequence anomaly */
if (icmp_type == -1)
sess->hop_info[tp->hopno].flags |= HF_ENDPOINT;
}
tp->hopaddr = ipaddr;
tp->icmp_type = icmp_type;
if (icmp_type != -2 && (!sess->num_hops || sess->num_hops > tp->hopno))
if (sess->break_on_icmp || (icmp_type == -1)) {
if (tp->hopno != -1) { /* we set fake type -1 when we get actual
* tcp packet in return - meaning destination */
sess->num_hops = tp->hopno;
tp->is_done = 1;
sess->hop_info[tp->hopno].done_packet = tp;
if (sess->noisy > 1 && sess->target_open < 1)
LFTEvtHandler(sess,EVT_TCP_PORT_CLOSED,NULL);
else
if (sess->noisy > 1 && sess->target_open > 0)
LFTEvtHandler(sess,EVT_TCP_PORT_OPEN,NULL);
if(sess->exit_state<0)
return;
}
}
/* adjust scatter if we have fast reply times */
ms = timediff_ms (tp->sent, tp->recv);
sess->scatter_ms = (sess->scatter_ms * (sess->ahead_limit - 1) + ms) / sess->ahead_limit;
}
static void tcp_base_finish(lft_session_params * sess)
{
int hopno;
int maxhop;
int reply, noreply;
int as_for_hop = 0;
struct trace_packet_info_s *tp;
char *netname;
/*int ocres;*/
char *myApp = (char *)malloc((strlen(version) * sizeof(char)) + 1 + (strlen(appname) * sizeof(char)));
struct ip_list_array *ipaslist = (struct ip_list_array *)malloc(sizeof(struct ip_list_array));
/* Variables for seam detection */
int icmpcode;
int asseam_hopno=-1;
struct in_addr asseam_hopaddr;
int netseam_hopno=-1;
struct in_addr netseam_hopaddr;
struct in_addr classbmask;
struct in_addr masked_target;
int prevasn=-1;
struct in_addr prevasn_hopaddr;
int prevasn_hopno;
int lastishole;
int netreached=0;
int isseam;
/* ---------------------------- */
inet_aton("255.255.0.0", &classbmask);
masked_target.s_addr=sess->remote_address.s_addr & classbmask.s_addr;
EvtPacketInfoParam ehip;
memset(ipaslist, '0', sizeof(struct ip_list_array));
gettimeofday (&(sess->trace_done_time), NULL);
/*ocres=open_check(sess, LFTErrHandler, LFTEvtHandler);
LFTEvtHandler(sess,EVT_OPEN_CHECK_RESULT,&ocres);
if(ocres==1)
{
sess->target_open=1;
sess->target_filtered=0;
}
else
{
sess->target_open=0;
if(ocres<0)
sess->target_filtered=0;
else
sess->target_filtered=1;
}*/
if (sess->noisy > 3)
{
LFTEvtHandler(sess,EVT_SHOW_NUM_HOPS, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
if (sess->num_hops) {
maxhop = sess->num_hops;
/* display all packets we received from this host */
SLIST_FOREACH(tp, &(sess->trace_packets), next)
{
if (tp->is_done)
{
tp->hopno = maxhop;
break;
}
}
} else {
maxhop = sess->hop_info_length - 1;
}
LFTEvtHandler(sess,EVT_TRACE_COMPLETED, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
/* if user wants ASN resolution from pwhois/cymru/riswhois, do it in bulk */
if (sess->do_aslookup || sess->do_netlookup) {
if(sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_ON_RESOLUTION, NULL);
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
if (!sess->use_radb) {
/* populate bulk ip_addr_list structure */
for (hopno = sess->ttl_min; hopno <= maxhop; hopno++) {
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop) {
if (tp->recv.tv_usec) {
(*ipaslist).ipaddr[as_for_hop] = tp->hopaddr;
as_for_hop++;
(*ipaslist).numItems = (as_for_hop);
break;
}
}
}
if (sess->use_cymru) { /* use cymru bulk service */
if (w_lookup_as_cymru_bulk(sess->wsess, &(*ipaslist)) != 0)
if (sess->noisy) LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
} else if (sess->use_ris) { /* use RIPE NCC RIS service */
if (w_lookup_all_riswhois_bulk(sess->wsess, &(*ipaslist)) != 0)
if (sess->noisy) LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
} else { /* use pwhois bulk service */
if ((strlen(version) * sizeof(char)) + 1 + (strlen(appname) * sizeof(char)) < 254) {
*myApp = '\0';
strcat(myApp,appname); strcat(myApp," ");
strcat(myApp,version);
strncpy((*ipaslist).application, myApp, 511);
}
if (w_lookup_all_pwhois_bulk(sess->wsess, &(*ipaslist)) != 0)
if(sess->noisy)
LFTErrHandler(sess, WRN_NS_LOOKUP_FAILED, NULL);
}
if(sess->exit_state < 0)
{
free(ipaslist);
free(myApp);
return;
}
}
}
free(myApp);
LFTEvtHandler(sess,EVT_TRACE_REPORT_START, &maxhop);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
/* seam detection */
as_for_hop=0;
for(hopno = sess->ttl_min; hopno < sess->hop_info_length; hopno++)
{
struct in_addr last_hop;
icmpcode=-100;
last_hop.s_addr = 0;
if(sess->hop_info[hopno].all_rcvd)
{
lastishole=0;
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop)
{
if(tp->recv.tv_sec)
{
if(hopno<=maxhop)
icmpcode=tp->icmp_type;
if(last_hop.s_addr != tp->hopaddr.s_addr)
{
if((tp->hopaddr.s_addr & classbmask.s_addr) == masked_target.s_addr)
netreached=1;
else
{
netseam_hopno=hopno;
netseam_hopaddr=tp->hopaddr;
}
if(sess->do_aslookup || sess->do_netlookup)
{
if (sess->use_radb)
{
/* using RADB/IRR */
tp->asnumber = w_lookup_as(sess->wsess, inet_ntoa(tp->hopaddr));
}
else
{
/* using pwhois by default */
tp->asnumber = (*ipaslist).asn[as_for_hop];
}
if(prevasn==-1)
{
if(tp->asnumber)
{
prevasn=tp->asnumber;
prevasn_hopno=hopno;
prevasn_hopaddr=tp->hopaddr;
}
}
else
{
if(tp->asnumber)
{
if(tp->asnumber!=prevasn)
{
asseam_hopno=prevasn_hopno;
asseam_hopaddr=prevasn_hopaddr;
}
prevasn=tp->asnumber;
prevasn_hopno=hopno;
prevasn_hopaddr=tp->hopaddr;
}
}
}
last_hop=tp->hopaddr;
}
}
}
as_for_hop++;
}
else
lastishole=1;
if(icmpcode==-1)
break;
}
if(!netreached)
netseam_hopno=-1;
if(lastishole)
asseam_hopno=-1;
/* -------------- */
noreply = 0;
reply = 0;
as_for_hop = 0; /* this correlates the hopno to the asn stored in ipaslist */
for (hopno = sess->ttl_min; hopno <= maxhop; hopno++) {
struct in_addr last_hop;
if (sess->hop_info[hopno].all_rcvd != 0) {
if (noreply >= 1)
{
EvtNoReplyParam nrp;
nrp.hopno=hopno;
nrp.noreply=noreply;
LFTEvtHandler(sess,EVT_RPT_NO_REPLY, &nrp);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
}
last_hop.s_addr = 0;
if ((sess->hop_info[hopno].state == HS_SEND_FIN) && (sess->hop_info[hopno+1].state == HS_SEND_SYN) && (sess->hop_info[hopno+1].ts_last_recv.tv_sec)) {
LFTEvtHandler(sess,EVT_RPT_FRW_INSPECT_PACKS, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if ((sess->hop_info[hopno].state != HS_SEND_SYN_ACK) && (sess->hop_info[hopno+1].state == HS_SEND_SYN_ACK) && (hopno == (sess->num_hops - 1))) {
LFTEvtHandler(sess,EVT_RPT_FRW_STATE_FILTER, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if ((sess->hop_info[hopno].flags & HF_ENDPOINT) && (noreply >= ((maxhop - sess->ttl_min)/2)) && sess->num_hops > 3) {
LFTEvtHandler(sess,EVT_RPT_BSD_BUG, NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if (sess->hop_info[hopno].all_rcvd == 0) {
reply = 0;
} else {
LFTEvtHandler(sess,EVT_RPT_HOP_INFO_START,&hopno);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
SLIST_FOREACH(tp, &(sess->hop_info[hopno].packets), next_by_hop) {
if (tp->recv.tv_sec) {
reply = 1;
if (last_hop.s_addr != tp->hopaddr.s_addr) {
ehip.asnumber = 0; /* init/clear the ASN */
if (sess->do_aslookup) {
if (sess->use_radb) {
/* using RADB/IRR */
ehip.asnumber = w_lookup_as(sess->wsess, inet_ntoa(tp->hopaddr));
} else {
/* using pwhois by default */
ehip.asnumber = (*ipaslist).asn[as_for_hop];
}
}
tp->asnumber=ehip.asnumber;
ehip.netname=NULL;
if (sess->do_netlookup) {
if (!sess->do_aslookup || (sess->do_aslookup && !sess->use_cymru && !sess->use_radb)) {
netname = (*ipaslist).netName[as_for_hop];
} else {
netname = w_lookup_netname(sess->wsess, inet_ntoa(tp->hopaddr));
}
ehip.netname=netname;
}
if(ehip.netname)
strncpy(tp->netname, ehip.netname, 511);
else
tp->netname[0]=0;
}
ehip.last_hop=last_hop;
tp->last_hop=ehip.last_hop;
last_hop = tp->hopaddr;
}
ehip.tp=tp;
/* seam processing */
isseam=0;
ehip.is_asseam=0;
ehip.is_netseam=0;
ehip.is_open=0;
ehip.is_filtered=0;
ehip.seam_traced=0;
if(sess->check_seam && hopno==asseam_hopno && tp->hopaddr.s_addr==asseam_hopaddr.s_addr)
{
isseam=1;
ehip.is_asseam=1;
}
if(sess->check_seam && hopno==netseam_hopno && tp->hopaddr.s_addr==netseam_hopaddr.s_addr)
{
isseam=1;
ehip.is_netseam=1;
}
if(isseam)
{
if(sess->check_seam)
{
int curroutputstyle=getOutputStyle();
char hostname[100];
ehip.seam_traced=1;
setOutputStyle(2);
lft_session_params * subsess=LFTSessionOpen();
strncpy(hostname, inet_ntoa(tp->hopaddr),100);
subsess->senddevsel = 1;
subsess->senddev = sess->pcap_send_dev;
subsess->userdevsel = 1;
subsess->userdev = sess->pcap_dev;
subsess->auto_ports=0;
subsess->dport=179;
subsess->seq_start=30;
subsess->retry_min=1;
subsess->retry_max=1;
subsess->resolve_names=0;
subsess->ahead_limit=1;
subsess->break_on_icmp = 0;
subsess->is_graphviz_subquery=1;
subsess->hostname=hostname;
subsess->hostname_lsrr_size = 0;
LFTExecute(subsess);
ehip.is_open=subsess->target_open;
ehip.is_filtered=subsess->target_filtered;
LFTSessionClose(subsess);
setOutputStyle(curroutputstyle);
}
}
/* --------------- */
LFTEvtHandler(sess,EVT_RPT_PACKET_INFO,&ehip);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
LFTEvtHandler(sess,EVT_RPT_PACKET_LIST_END,NULL);
if(sess->exit_state < 0){
free(ipaslist);
return;
}
}
if (reply) {
noreply = 0;
as_for_hop++;
} else
noreply++;
reply = 0;
}
if (!sess->num_hops) {
LFTEvtHandler(sess,EVT_RPT_NO_HOPS,&maxhop);
}
if (sess->timetrace) {
LFTEvtHandler(sess,EVT_RPT_TIME_TRACE,NULL);
}
LFTEvtHandler(sess,EVT_ON_EXIT,NULL);
if(ipaslist != NULL)
free(ipaslist);
}
static int tcp_base_check_timeouts(lft_session_params * sess)
{
int nhop;
int need_reply = 0;
int no_reply = 0;
int last_return = 0;
gettimeofday (&(sess->now), NULL);
if (timediff_ms (sess->ts_last_sent, sess->now) < sess->scatter_ms)
return 0; /* not ready to send another packet yet */
for (nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++) {
if (!sess->hop_info[nhop].num_sent) {
tcp_base_send_hop(sess, nhop, 1);
return 0;
}
}
for (nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++) {
if (sess->hop_info[nhop].num_sent <= sess->retry_max && !sess->hop_info[nhop].ts_last_recv.tv_sec) {
if (sess->noisy > 4)
{
LFTEvtHandler(sess,EVT_TTL_NO_REPLY,&nhop);
if(sess->exit_state<0)
return 0;
}
if (timediff_ms (sess->hop_info[nhop].ts_last_sent, sess->now) >= sess->timeout_ms) {
/* we timed out waiting for this hop -- retry if we have any
* more tries */
if (sess->hop_info[nhop].num_sent < sess->retry_max) {
if (!sess->noisy && !sess->nostatus)
LFTEvtHandler(sess,EVT_PROGRESS_NO_REPLY,NULL);
if (sess->noisy > 2)
LFTEvtHandler(sess,EVT_TTL_TOUT_RESEND,&nhop);
if(sess->exit_state<0)
return 0;
if(sess->hop_info[nhop].num_sent < sess->retry_max - 1)
tcp_base_send_hop(sess, nhop, 1);
else
{
sess->btcpdpucnt++;
if(sess->btcpdpucnt>4)
{
sess->btcpdpucnt=0;
sess->btcpmap[0].nhop=-1;
sess->btcpmap[0].sentcount=0;
tcp_base_send_hop(sess, nhop, 0);
}
}
return 0;
}
else
{
if (!sess->adaptive || hop_state_up(sess, nhop)) {
if (sess->noisy > 3)
LFTEvtHandler(sess,EVT_TTL_TOUT_GIVINGUP,&nhop);
if(sess->exit_state<0)
return 0;
no_reply++;
}
}
} else {
need_reply++; /* we have to wait for this one to timeout */
}
} else { /* have reply */
last_return = nhop;
}
}
if (sess->noisy > 4) {
EvtDebugCheckpoint1Param edcp;
edcp.last_return=last_return;
edcp.need_reply=need_reply;
edcp.no_reply=no_reply;
LFTEvtHandler(sess,EVT_DBG_CHECKPOINT1,&edcp);
if(sess->exit_state<0)
return 0;
}
if (no_reply >= sess->ahead_limit) { /* we timed out. */
if ((last_return + 3) * 2 < sess->hop_info_length) {
if ((need_reply < 3) && (sess->num_rcvd < 2))
LFTEvtHandler(sess,EVT_CANT_RELIABLY_RTRIP,NULL);
if(sess->exit_state < 0)
return 0;
tcp_base_finish(sess);
return 1;
}
}
if ((!sess->num_hops || sess->hop_info_length < sess->num_hops || need_reply) && sess->hop_info_length < sess->ttl_limit) {
if (sess->noisy > 4)
LFTEvtHandler(sess,EVT_HAVE_UNANSWERRED_HOPS,NULL);
if (need_reply >= sess->ahead_limit) {
if (sess->noisy > 4)
LFTEvtHandler(sess,EVT_TOO_FAR_AHEAD,NULL);
return 0; /* wait for some replies before we go on */
}
if(sess->exit_state<0)
return 0;
if (sess->num_hops > 0 && sess->hop_info_length >= sess->num_hops) {
if (sess->noisy > 3)
LFTEvtHandler(sess,EVT_HAVE_GAPS,NULL);
return 0; /* we know how long the path is --
* wait to fill in the blanks */
}
nhop = sess->hop_info_length++;
tcp_base_send_hop(sess, nhop, 1);
} else
{
if (sess->noisy >= 4)
{
LFTEvtHandler(sess,EVT_EITHER_RESP_OR_TOUT,NULL);
if(sess->exit_state<0)
return 0;
}
for (nhop = sess->ttl_min; nhop < sess->hop_info_length; nhop++)
{
if (sess->hop_info[nhop].num_sent < sess->retry_min)
{
tcp_base_send_hop(sess, nhop, 1);
return 0;
}
if(sess->hop_info[nhop].done_packet)
{
if(sess->trg_probe_is_sentretry_min || (sess->trg_probe_is_sentretry_max && ntohs(sess->hop_info[nhop].done_packet->u.packet.tcp_hdr.th_dport)!=sess->dport))
{
sess->btcpdpucnt++;
if(sess->btcpdpucnt>4)
{
sess->btcpdpucnt=0;
sess->btcpmap[0].nhop=-1;
sess->btcpmap[0].sentcount=0;
sess->trg_probe_is_sent++;
tcp_base_send_hop(sess, nhop, 0);
}
return 0;
}
}
}
tcp_base_finish(sess);
return 1;
}
return 0;
}
static void tcp_base_process_packet(lft_session_params * sess, const u_char *packet, const struct pcap_pkthdr *hdr)
{
const struct ip *ip, *orig_ip;
const struct tcphdr *tcp;
const struct icmp *icmp;
if (sess->noisy > 4)
{
LFTEvtHandler(sess,EVT_PROCESS_PACKET_START,NULL);
if(sess->exit_state<0)
return;
}
tcp_base_check_timeouts(sess);
if(sess->exit_state<0)
return;
packet += sess->skip_header_len;
ip = (const void *) packet;
packet += 4 * ip->ip_hl;
switch (ip->ip_p) {
case IPPROTO_ICMP:
orig_ip = ip;
icmp = (const void *) packet;
if (icmp->icmp_type != ICMP_UNREACH && icmp->icmp_type != ICMP_TIMXCEED)
return;
ip = &icmp->icmp_ip;
if (ip->ip_p != IPPROTO_TCP)
return; /* not a response to our tcp probe */
packet = (const u_char *) ip;
packet += 4 * ip->ip_hl;
tcp = (const void *) packet;
if (ip->ip_src.s_addr != sess->local_address.s_addr || ip->ip_dst.s_addr != sess->remote_address.s_addr)
return; /* not for us */
if (sess->noisy > 2) {
EvtIncomingICMPTCPParam eiitp;
eiitp.icmp=icmp;
eiitp.ip=ip;
eiitp.orig_ip=orig_ip;
eiitp.tcp=tcp;
LFTEvtHandler(sess,EVT_INCOMING_ICMP_TCP,&eiitp);
if(sess->exit_state<0)
return;
}
if (sess->noisy > 1)
{
LFTEvtHandler(sess,EVT_RCVD_ICMP_TCP,tcp);
if(sess->exit_state<0)
return;
}
tcp_base_recv_packet(sess, ntohl (tcp->th_seq) , orig_ip->ip_src,
(icmp->icmp_type == ICMP_TIMXCEED) ? -2 : icmp->icmp_code, hdr);
return;
case IPPROTO_TCP:
tcp = (const void *) packet;
if (!(tcp->th_flags & TH_RST) && !(tcp->th_flags & TH_ACK) && !(tcp->th_flags & TH_SYN))
return; /* not what we're looking for */
if (ip->ip_src.s_addr != sess->remote_address.s_addr || ip->ip_dst.s_addr != sess->local_address.s_addr) {
return; /* not the right connection */
}
if (sess->noisy > 1) {
LFTEvtHandler(sess,EVT_RCVD_TCP,tcp);
if(sess->exit_state<0)
return;
}
if(ntohs(tcp->th_sport)==sess->dport)
{
/* Check for SYN,ACK in response to determine if target is listening */
if ((tcp->th_flags & TH_ACK) && (tcp->th_flags & TH_SYN) && !(tcp->th_flags & TH_RST))
sess->target_open++;
if ((tcp->th_flags & TH_ACK) && !(tcp->th_flags & TH_SYN) && (tcp->th_flags & TH_RST))
sess->target_open = 0;
}
tcp_base_recv_packet(sess, ntohl (tcp->th_ack) - 1, ip->ip_src, -1, hdr);
return;
default:
if (sess->noisy > 3)
LFTEvtHandler(sess,EVT_RCVD_UNKNOWN,ip);
}
}
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
void win_tcp_base_process(lft_session_params * sess)
{
fd_set fds;
struct timeval tm;
tm.tv_sec = 0;
tm.tv_usec = 100000;
FD_ZERO(&fds);
FD_SET(sess->recv_sock, &fds);
if (select(sess->recv_sock+1, &fds, 0, 0, &tm) < 0)
{
LFTErrHandler(sess, ERR_WIN_SELECT, NULL);
return;
}
if (FD_ISSET(sess->recv_sock, &fds))
{
/* read packet */
char packetbuf[2048];
int nread;
memset(packetbuf, 0, sizeof(packetbuf));
nread = recv(sess->recv_sock, packetbuf, sizeof(packetbuf), 0);
if (nread <= 0)
{
LFTErrHandler(sess, ERR_WIN_RECV, NULL);
return;
}
tcp_base_process_packet(sess, packetbuf, NULL);
}
}
#else
static void pcap_tcp_base_process_packet(u_char * user_data, const struct pcap_pkthdr *hdr, const u_char * packet)
{
lft_session_params * sess=(lft_session_params *)(void *)user_data;
if(sess->exit_state<0)
return;
tcp_base_process_packet(sess, packet, hdr);
}
#endif
void tcp_base_trace_main_loop(lft_session_params * sess, LFT_CALLBACK err, LFT_CALLBACK evt)
{
LFTErrHandler=err;
LFTEvtHandler=evt;
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
while(1)
{
win_tcp_base_process(sess);
if(sess->exit_state<0)
break;
if(tcp_base_check_timeouts(sess))
break;
if(sess->exit_state<0)
break;
}
#else
while(pcap_dispatch(sess->pcapdescr, -1, pcap_tcp_base_process_packet, (u_char *)sess) >= 0)
{
if(sess->exit_state<0)
break;
if(sess->noisy > 6)
{
LFTEvtHandler(sess,EVT_DBG_CHECKPOINT2,NULL);
if(sess->exit_state<0)
break;
}
if(tcp_base_check_timeouts(sess))
break;
if(sess->exit_state<0)
break;
}
#endif
}
lft-3.8/lft_ifname.c 000644 000766 000000 00000005437 11711612447 014356 0 ustar 00vic wheel 000000 000000 /*
* lft_ifname.c
* Layer Four Traceroute
*
* This file is part of LFT.
*
* The LFT software provided in this Distribution is
* Copyright 2007 VOSTROM Holdings, Inc.
*
* The full text of our legal notices is contained in the file called
* COPYING, included with this Distribution.
*
*/
#if !defined(WIN32) && !defined(_WIN32)
#include
#include
#include
#include
#if !defined(linux) && !defined(__CYGWIN__)
#include
#endif
#include
#include
#include
#include
#include
#include "lft_ifname.h"
#if defined( __CYGWIN__ ) || defined( WIN32 ) || defined(_WIN32)
#include "config/acconfig.win.h"
#else
#include "config/acconfig.h"
#endif
static int sock = -1;
u_long
lft_getifaddr (const char *ifname)
{
struct ifreq ifr;
struct sockaddr_in addr;
/* Only do this once of course */
if (sock < 0) {
if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0) {
perror ("socket");
return -1;
}
}
STRNCPY(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(sock, SIOCGIFADDR, &ifr) < 0) {
perror("ioctl");
return -1;
}
if (ifr.ifr_addr.sa_family != AF_INET) {
fprintf (stderr, "%s: Interface not configured with IPv4 address.\n", ifname);
fflush (stderr);
return -1;
}
memcpy(&addr, &ifr.ifr_addr, sizeof addr);
return (addr.sin_addr.s_addr);
}
char *
lft_getifname (struct in_addr addr)
{
struct ifconf ifc;
char buffer[2048];
int i, skip;
/* Only do this once of course */
if (sock < 0) {
if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0) {
perror ("socket");
return NULL;
}
}
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
perror("ioctl");
return NULL;
}
for (i = 0; i < ifc.ifc_len; i += skip) {
struct ifreq ifr;
struct in_addr thisaddr;
memcpy(&ifr, ifc.ifc_buf + i, sizeof(struct ifreq));
skip = sizeof(struct ifreq);
#ifdef HAVE_SOCKADDR_SA_LEN
if (ifr.ifr_addr.sa_len > sizeof(struct sockaddr)) {
skip = ifr.ifr_addr.sa_len + IFNAMSIZ;
}
#endif
if (ifr.ifr_addr.sa_family != AF_INET) continue;
thisaddr = ((const struct sockaddr_in *)(const void *)(&(ifr.ifr_addr)))->sin_addr;
if (thisaddr.s_addr == addr.s_addr)
return strdup(ifr.ifr_name);
}
/* not found */
return NULL;
}
#ifdef LFT_IFADDR_TESTING
extern int
main (int argc, char *argv[])
{
struct in_addr in;
char *addr;
if (argc > 1)
addr = strdup (argv[1]);
else
addr = strdup ("eth0");
in.s_addr = lft_getifaddr (addr);
if (in.s_addr == -1) {
fprintf (stderr, "%s: Error reading ifname\n", addr);
fflush (stderr);
free(addr);
exit (-1);
}
fprintf (stdout, "%s: %s\n", addr,
inet_ntoa (in));
fflush (stdout);
free (addr);
exit (0);
}
#endif /*LFT_IFNAME_TESTING*/
#endif
lft-3.8/lft_queue.h 000644 000766 000000 00000041345 11053131665 014243 0 ustar 00vic wheel 000000 000000 /*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
* $FreeBSD: src/sys/sys/queue.h,v 1.32.2.4 2001/03/31 03:33:39 hsu Exp $
*/
#ifndef _LFT_QUEUE_H_
#define _LFT_QUEUE_H_
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
/*
* This file defines five types of data structures: singly-linked lists,
* singly-linked tail queues, lists, tail queues, and circular queues.
*
* A singly-linked list is headed by a single forward pointer. The elements
* are singly linked for minimum space and pointer manipulation overhead at
* the expense of O(n) removal for arbitrary elements. New elements can be
* added to the list after an existing element or at the head of the list.
* Elements being removed from the head of the list should use the explicit
* macro for this purpose for optimum efficiency. A singly-linked list may
* only be traversed in the forward direction. Singly-linked lists are ideal
* for applications with large datasets and few or no removals or for
* implementing a LIFO queue.
*
* A singly-linked tail queue is headed by a pair of pointers, one to the
* head of the list and the other to the tail of the list. The elements are
* singly linked for minimum space and pointer manipulation overhead at the
* expense of O(n) removal for arbitrary elements. New elements can be added
* to the list after an existing element, at the head of the list, or at the
* end of the list. Elements being removed from the head of the tail queue
* should use the explicit macro for this purpose for optimum efficiency.
* A singly-linked tail queue may only be traversed in the forward direction.
* Singly-linked tail queues are ideal for applications with large datasets
* and few or no removals or for implementing a FIFO queue.
*
* A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked
* so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before
* or after an existing element or at the head of the list. A list
* may only be traversed in the forward direction.
*
* A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction.
*
* A circle queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the list.
* A circle queue may be traversed in either direction, but has a more
* complex end of list detection.
*
* For details on the use of these macros, see the queue(3) manual page.
*
*
* SLIST LIST STAILQ TAILQ CIRCLEQ
* _HEAD + + + + +
* _ENTRY + + + + +
* _INIT + + + + +
* _EMPTY + + + + +
* _FIRST + + + + +
* _NEXT + + + + +
* _PREV - - - + +
* _LAST - - + + +
* _FOREACH + + + + +
* _FOREACH_REVERSE - - - + +
* _INSERT_HEAD + + + + +
* _INSERT_BEFORE - + - + +
* _INSERT_AFTER + + + + +
* _INSERT_TAIL - - + + +
* _REMOVE_HEAD + - + - -
* _REMOVE + + + + +
*
*/
/*
* Singly-linked List definitions.
*/
#define SLIST_HEAD(name, type) \
struct name { \
struct type *slh_first; /* first element */ \
}
#define SLIST_HEAD_INITIALIZER(head) \
{ NULL }
#undef SLIST_ENTRY
#define SLIST_ENTRY(type) \
struct { \
struct type *sle_next; /* next element */ \
}
/*
* Singly-linked List functions.
*/
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
#define SLIST_FIRST(head) ((head)->slh_first)
#define SLIST_FOREACH(var, head, field) \
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
#define SLIST_INIT(head) { \
(head)->slh_first = NULL; \
}
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
(elm)->field.sle_next = (slistelm)->field.sle_next; \
(slistelm)->field.sle_next = (elm); \
} while (0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \
(elm)->field.sle_next = (head)->slh_first; \
(head)->slh_first = (elm); \
} while (0)
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define SLIST_REMOVE_HEAD(head, field) do { \
(head)->slh_first = (head)->slh_first->field.sle_next; \
} while (0)
#define SLIST_REMOVE(head, elm, type, field) do { \
if ((head)->slh_first == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \
} \
else { \
struct type *curelm = (head)->slh_first; \
while( curelm->field.sle_next != (elm) ) \
curelm = curelm->field.sle_next; \
curelm->field.sle_next = \
curelm->field.sle_next->field.sle_next; \
} \
} while (0)
/*
* Singly-linked Tail queue definitions.
*/
#define STAILQ_HEAD(name, type) \
struct name { \
struct type *stqh_first;/* first element */ \
struct type **stqh_last;/* addr of last next element */ \
}
#define STAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).stqh_first }
#define STAILQ_ENTRY(type) \
struct { \
struct type *stqe_next; /* next element */ \
}
/*
* Singly-linked Tail queue functions.
*/
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
#define STAILQ_INIT(head) do { \
(head)->stqh_first = NULL; \
(head)->stqh_last = &(head)->stqh_first; \
} while (0)
#define STAILQ_FIRST(head) ((head)->stqh_first)
#ifndef STAILQ_LAST
#define STAILQ_LAST(head, type, field) \
(STAILQ_EMPTY(head) ? \
NULL : \
((struct type *) \
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
#endif
#define STAILQ_FOREACH(var, head, field) \
for((var) = (head)->stqh_first; (var); (var) = (var)->field.stqe_next)
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
(head)->stqh_last = &(elm)->field.stqe_next; \
(head)->stqh_first = (elm); \
} while (0)
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.stqe_next = NULL; \
*(head)->stqh_last = (elm); \
(head)->stqh_last = &(elm)->field.stqe_next; \
} while (0)
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\
(head)->stqh_last = &(elm)->field.stqe_next; \
(tqelm)->field.stqe_next = (elm); \
} while (0)
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
#define STAILQ_REMOVE_HEAD(head, field) do { \
if (((head)->stqh_first = \
(head)->stqh_first->field.stqe_next) == NULL) \
(head)->stqh_last = &(head)->stqh_first; \
} while (0)
#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
if (((head)->stqh_first = (elm)->field.stqe_next) == NULL) \
(head)->stqh_last = &(head)->stqh_first; \
} while (0)
#define STAILQ_REMOVE(head, elm, type, field) do { \
if ((head)->stqh_first == (elm)) { \
STAILQ_REMOVE_HEAD(head, field); \
} \
else { \
struct type *curelm = (head)->stqh_first; \
while( curelm->field.stqe_next != (elm) ) \
curelm = curelm->field.stqe_next; \
if((curelm->field.stqe_next = \
curelm->field.stqe_next->field.stqe_next) == NULL) \
(head)->stqh_last = &(curelm)->field.stqe_next; \
} \
} while (0)
/*
* List definitions.
*/
#define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
#define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \
}
/*
* List functions.
*/
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
#define LIST_FIRST(head) ((head)->lh_first)
#define LIST_FOREACH(var, head, field) \
for((var) = (head)->lh_first; (var); (var) = (var)->field.le_next)
#define LIST_INIT(head) do { \
(head)->lh_first = NULL; \
} while (0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \
(elm)->field.le_prev = &(listelm)->field.le_next; \
} while (0)
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.le_prev = (listelm)->field.le_prev; \
(elm)->field.le_next = (listelm); \
*(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &(elm)->field.le_next; \
} while (0)
#define LIST_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \
} while (0)
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
#define LIST_REMOVE(elm, field) do { \
if ((elm)->field.le_next != NULL) \
(elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = (elm)->field.le_next; \
} while (0)
/*
* Tail queue definitions.
*/
#define TAILQ_HEAD(name, type) \
struct name { \
struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \
}
#define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first }
#define TAILQ_ENTRY(type) \
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
}
/*
* Tail queue functions.
*/
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define TAILQ_FOREACH(var, head, field) \
for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
#ifndef TAILQ_FOREACH_REVERSE
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = TAILQ_LAST((head), headname); \
(var); \
(var) = TAILQ_PREV((var), headname, field))
#endif
#define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#define TAILQ_INIT(head) do { \
(head)->tqh_first = NULL; \
(head)->tqh_last = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
(head)->tqh_first->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(head)->tqh_first = (elm); \
(elm)->field.tqe_prev = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.tqe_next = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
(elm)->field.tqe_next->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(listelm)->field.tqe_next = (elm); \
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
(elm)->field.tqe_next = (listelm); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_REMOVE(head, elm, field) do { \
if (((elm)->field.tqe_next) != NULL) \
(elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \
else \
(head)->tqh_last = (elm)->field.tqe_prev; \
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
} while (0)
/*
* Circular queue definitions.
*/
#define CIRCLEQ_HEAD(name, type) \
struct name { \
struct type *cqh_first; /* first element */ \
struct type *cqh_last; /* last element */ \
}
#define CIRCLEQ_ENTRY(type) \
struct { \
struct type *cqe_next; /* next element */ \
struct type *cqe_prev; /* previous element */ \
}
/*
* Circular queue functions.
*/
#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
#define CIRCLEQ_FOREACH(var, head, field) \
for((var) = (head)->cqh_first; \
(var) != (void *)(head); \
(var) = (var)->field.cqe_next)
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
for((var) = (head)->cqh_last; \
(var) != (void *)(head); \
(var) = (var)->field.cqe_prev)
#define CIRCLEQ_INIT(head) do { \
(head)->cqh_first = (void *)(head); \
(head)->cqh_last = (void *)(head); \
} while (0)
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
(elm)->field.cqe_prev = (listelm); \
if ((listelm)->field.cqe_next == (void *)(head)) \
(head)->cqh_last = (elm); \
else \
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
(listelm)->field.cqe_next = (elm); \
} while (0)
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm); \
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
if ((listelm)->field.cqe_prev == (void *)(head)) \
(head)->cqh_first = (elm); \
else \
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
(listelm)->field.cqe_prev = (elm); \
} while (0)
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
(elm)->field.cqe_next = (head)->cqh_first; \
(elm)->field.cqe_prev = (void *)(head); \
if ((head)->cqh_last == (void *)(head)) \
(head)->cqh_last = (elm); \
else \
(head)->cqh_first->field.cqe_prev = (elm); \
(head)->cqh_first = (elm); \
} while (0)
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.cqe_next = (void *)(head); \
(elm)->field.cqe_prev = (head)->cqh_last; \
if ((head)->cqh_first == (void *)(head)) \
(head)->cqh_first = (elm); \
else \
(head)->cqh_last->field.cqe_next = (elm); \
(head)->cqh_last = (elm); \
} while (0)
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
#define CIRCLEQ_NEXT(elm,field) ((elm)->field.cqe_next)
#define CIRCLEQ_PREV(elm,field) ((elm)->field.cqe_prev)
#define CIRCLEQ_REMOVE(head, elm, field) do { \
if ((elm)->field.cqe_next == (void *)(head)) \
(head)->cqh_last = (elm)->field.cqe_prev; \
else \
(elm)->field.cqe_next->field.cqe_prev = \
(elm)->field.cqe_prev; \
if ((elm)->field.cqe_prev == (void *)(head)) \
(head)->cqh_first = (elm)->field.cqe_next; \
else \
(elm)->field.cqe_prev->field.cqe_next = \
(elm)->field.cqe_next; \
} while (0)
#endif /* !_LFT_QUEUE_H_ */
lft-3.8/icons/72x72/ 000755 000766 000000 00000000000 13263007004 013770 5 ustar 00vic wheel 000000 000000 lft-3.8/icons/144x144/ 000755 000766 000000 00000000000 13263007004 014130 5 ustar 00vic wheel 000000 000000 lft-3.8/icons/144x144/blank.png 000644 000766 000000 00000006422 12062431750 015736 0 ustar 00vic wheel 000000 000000 ‰PNG
IHDR çF⸠pHYs .# .#x¥?v
OiCCPPhotoshop ICC profile xÚSgTSé=÷ÞôBKˆ€”KoR RB‹€‘&*! Jˆ!¡ÙQÁEEÈ ˆŽŽ€ŒQ,Š
Øä!¢Žƒ£ˆŠÊûá{£kÖ¼÷æÍþµ×>ç¬ó³ÏÀ–H3Q5€©BàƒÇÄÆáä.@
$p ³d!sý# ø~<<+"À¾ xÓ ÀM›À0‡ÿêB™\€„Àt‘8K€ @zŽB¦ @F€˜&S |