lft-3.35/ 0000755 0000000 0000024 00000000000 12056766314 007220 5 0000000 0000000 lft-3.35/lft.c 0000644 0000000 0000000 00000032561 12055663775 010100 0000000 0000000 /*
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"
#include
extern struct __res_state _res;
#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.35"; /* set version string */
const char *version_date = "(10/2012)"; /* 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"
" -v Display LFT's version information and exit\n"
" -x XML output\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
res_init();
_res.retrans = 1;
_res.retry = 1;
sess = LFTSessionOpen();
setbuf(stdout, NULL);
while ((ch = getopt(argc, argv, "Aa:bCc:D:d:EeFf:H:hIiL:l:M:m:NnPpq:RrSs:Tt:UuVvxw:z")) != 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;
default:
usage(sess, argv[0]);
}
if((argc - optind) < 1)
usage(sess, argv[0]);
if (sess->noisy && !outputStyleIsXML())
printf ("Layer Four Traceroute (LFT) version %s", version);
if (sess->noisy > 1 && !outputStyleIsXML())
printf (" ... (verbosity level %d)",sess->noisy);
if (sess->noisy && !outputStyleIsXML())
printf ("\n");
if(outputStyleIsXML())
{
printf("\n",sess->noisy);
}
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));
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.35/lft_btcptrace.h 0000644 0000000 0000024 00000000255 11053131665 012116 0000000 0000000 #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.35/whois.h 0000644 0000000 0000024 00000006755 11461547027 010454 0000000 0000000 /*
* 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.35/lft_lib.h 0000644 0000000 0000024 00000037734 11660616410 010731 0000000 0000000 /*
* 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;
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;
const 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;
/*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[];
/*--------------------------- 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);
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /*LFT_LIB_H*/
lft-3.35/lft_lsrr.h 0000644 0000000 0000024 00000001265 11053131665 011133 0000000 0000000 /*
* 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.35/lft_queue.h 0000644 0000000 0000024 00000041345 11053131665 011300 0000000 0000000 /*
* 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.35/whois.c 0000644 0000000 0000024 00000234360 11711614244 010434 0000000 0000000 /*
* 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) 2011 Markus Gothe
* Portions (c) 2007 Victor Oppleman (lft@oppleman.com)
* 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 const char *version = "3.5"; /* set version string for library and client */
#ifndef STANDALONE
static const char appname[] = "pWhoIs C Library"; /* set application name */
#endif
static char pwhois_server[] = "whois.pwhois.org";
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
static const char appname[] = "WhoB"; /* set application name */
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_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 const unsigned int max_hostname_input = 200; /* Maximum length of input from user */
static const int max_lines = 1000; /* 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;
}
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
printf("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
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[(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_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 for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
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 for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
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 for bulk query input.\n");
free(lines);
free(this_line);
free(whob_query);
exit(EXIT_FAILURE);
}
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)
printf("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_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)
printf("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 ((*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 ((*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
printf("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 ((*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 ((*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
printf("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
printf("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
printf("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 the specified file 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 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"
"\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) {
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, "aCcfgNnOopPRrstuVvh:w:")) != EOF)
switch (ch) {
case 'a':
show_routes_byasn = 1;
break;
case 'N':
show_networks_byasn = 1;
break;
case 'O':
show_contacts_byasn = 1;
break;
case 's':
show_server_status = 1;
break;
case 'P':
show_routes_byprefix = 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;
break;
case 'r':
use_riswhois = 1;
riswhoisfromfile = 1;
break;
case 'R':
display_radb_as = 1;
break;
case 'o':
display_orgname = 0;
break;
case 'p':
display_aspath = 1;
break;
case 'f':
read_from_file = 1;
break;
case 'V':
wsess->w_noisy++;
break;
case 'g':
use_gigo = 0;
break;
default:
usage (av[0]);
}
if (((ac - optind) < 1) && (show_server_status != 1))
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 (strlen(av[optind]) > max_hostname_input) {
fprintf(stderr,"Sorry, the host 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) {
w_display_pwhois_gigo(wsess, hostname);
exit(EXIT_SUCCESS);
}
if ((show_routes_byasn || show_contacts_byasn || show_networks_byasn) && (strlen(hostname) <= 5) && atoi(hostname)) {
user_asn = atoi(hostname);
if (wsess->w_noisy > 1) printf("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 (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_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.35/README 0000644 0000000 0000024 00000002017 11053131665 010007 0000000 0000000
# 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.35/INSTALL 0000644 0000000 0000024 00000023563 11053131665 010171 0000000 0000000 #######################################################
## 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.35/config.status 0000755 0000000 0000000 00000061442 12055642565 011656 0000000 0000000 #! /bin/sh
# Generated by configure.
# 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-/bin/sh}
## --------------------- ##
## 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=:
# Zsh 3.x and 4.x performs 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
# PATH needs CR
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
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.)
as_nl='
'
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
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
echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
{ (exit 1); exit 1; }
fi
# Work around bugs in pre-3.0 UWIN ksh.
for as_var in ENV MAIL MAILPATH
do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
for as_var in \
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME
do
if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
eval $as_var=C; export $as_var
else
($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
fi
done
# Required to use basename.
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
# Name of the executable.
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# CDPATH.
$as_unset CDPATH
as_lineno_1=$LINENO
as_lineno_2=$LINENO
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line after each line using $LINENO; the second 'sed'
# does the real work. The second script uses 'N' to pair each
# line-number line with the line containing $LINENO, and appends
# trailing '-' during substitution so that $LINENO is not a special
# case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# scripts with optimization help from Paolo Bonzini. 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" ||
{ echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in
-n*)
case `echo 'x\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
*) ECHO_C='\c';;
esac;;
*)
ECHO_N='-n';;
esac
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
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
fi
echo >conf$$.file
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 -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# 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
# 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.61. 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`
"
# Files that config.status was made for.
config_files=" Makefile"
config_headers=" config/acconfig.h"
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
-q, --quiet do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to ."
ac_cs_version="\
config.status
configured by ./configure, generated by GNU Autoconf 2.61,
with options \"\"
Copyright (C) 2006 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='/root/lft-3.35'
srcdir='.'
INSTALL='/usr/bin/install -c'
# If no file are specified by the user, then we need to provide default
# value. By we need to know if files were specified by the user.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
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 )
echo "$ac_cs_version"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
CONFIG_FILES="$CONFIG_FILES $ac_optarg"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
{ echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1"
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
if $ac_cs_recheck; then
echo "running CONFIG_SHELL=/bin/sh /bin/sh ./configure " $ac_configure_extra_args " --no-create --no-recursion" >&6
CONFIG_SHELL=/bin/sh
export CONFIG_SHELL
exec /bin/sh "./configure" $ac_configure_extra_args --no-create --no-recursion
fi
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
echo "$ac_log"
} >&5
# 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" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason 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=
trap 'exit_status=$?
{ test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} ||
{
echo "$me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
#
# Set up the sed scripts for CONFIG_FILES section.
#
# No need to generate the scripts if there are no CONFIG_FILES.
# This happens for instance when ./config.status config.h
if test -n "$CONFIG_FILES"; then
cat >"$tmp/subs-1.sed" <<\CEOF
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
s,@SHELL@,|#_!!_#|/bin/sh,g
s,@PATH_SEPARATOR@,|#_!!_#|:,g
s,@PACKAGE_NAME@,|#_!!_#|,g
s,@PACKAGE_TARNAME@,|#_!!_#|,g
s,@PACKAGE_VERSION@,|#_!!_#|,g
s,@PACKAGE_STRING@,|#_!!_#|,g
s,@PACKAGE_BUGREPORT@,|#_!!_#|,g
s,@exec_prefix@,|#_!!_#|${prefix},g
s,@prefix@,|#_!!_#|/usr/local,g
s,@program_transform_name@,|#_!!_#|s\,x\,x\,,g
s,@bindir@,|#_!!_#|${exec_prefix}/bin,g
s,@sbindir@,|#_!!_#|${exec_prefix}/sbin,g
s,@libexecdir@,|#_!!_#|${exec_prefix}/libexec,g
s,@datarootdir@,|#_!!_#|${prefix}/share,g
s,@datadir@,|#_!!_#|${datarootdir},g
s,@sysconfdir@,|#_!!_#|${prefix}/etc,g
s,@sharedstatedir@,|#_!!_#|${prefix}/com,g
s,@localstatedir@,|#_!!_#|${prefix}/var,g
s,@includedir@,|#_!!_#|${prefix}/include,g
s,@oldincludedir@,|#_!!_#|/usr/include,g
s,@docdir@,|#_!!_#|${datarootdir}/doc/${PACKAGE},g
s,@infodir@,|#_!!_#|${datarootdir}/info,g
s,@htmldir@,|#_!!_#|${docdir},g
s,@dvidir@,|#_!!_#|${docdir},g
s,@pdfdir@,|#_!!_#|${docdir},g
s,@psdir@,|#_!!_#|${docdir},g
s,@libdir@,|#_!!_#|${exec_prefix}/lib,g
s,@localedir@,|#_!!_#|${datarootdir}/locale,g
s,@mandir@,|#_!!_#|${datarootdir}/man,g
s,@DEFS@,|#_!!_#|-DHAVE_CONFIG_H,g
s,@ECHO_C@,|#_!!_#|,g
s,@ECHO_N@,|#_!!_#|-n,g
s,@ECHO_T@,|#_!!_#|,g
s,@LIBS@,|#_!!_#|-lpcap -lm -lresolv -lnsl ,g
s,@build_alias@,|#_!!_#|,g
s,@host_alias@,|#_!!_#|,g
s,@target_alias@,|#_!!_#|,g
s,@build@,|#_!!_#|i686-pc-linux-gnu,g
s,@build_cpu@,|#_!!_#|i686,g
s,@build_vendor@,|#_!!_#|pc,g
s,@build_os@,|#_!!_#|linux-gnu,g
s,@host@,|#_!!_#|i686-pc-linux-gnu,g
s,@host_cpu@,|#_!!_#|i686,g
s,@host_vendor@,|#_!!_#|pc,g
s,@host_os@,|#_!!_#|linux-gnu,g
s,@CC@,|#_!!_#|gcc,g
s,@CFLAGS@,|#_!!_#|-g -O2,g
s,@LDFLAGS@,|#_!!_#|,g
s,@CPPFLAGS@,|#_!!_#|,g
s,@ac_ct_CC@,|#_!!_#|gcc,g
s,@EXEEXT@,|#_!!_#|,g
s,@OBJEXT@,|#_!!_#|o,g
s,@LN_S@,|#_!!_#|ln -s,g
s,@SET_MAKE@,|#_!!_#|,g
s,@INSTALL_PROGRAM@,|#_!!_#|${INSTALL},g
s,@INSTALL_SCRIPT@,|#_!!_#|${INSTALL},g
s,@INSTALL_DATA@,|#_!!_#|${INSTALL} -m 644,g
s,@CPP@,|#_!!_#|gcc -E,g
s,@GREP@,|#_!!_#|/bin/grep,g
s,@EGREP@,|#_!!_#|/bin/grep -E,g
s,@ALLOCA@,|#_!!_#|,g
s,@LIBOBJS@,|#_!!_#|,g
s,@LTLIBOBJS@,|#_!!_#|,g
:end
s/|#_!!_#|//g
CEOF
fi # test -n "$CONFIG_FILES"
for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
echo "$as_me: error: Invalid tag $ac_tag." >&2;}
{ (exit 1); exit 1; }; };;
:[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="$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 ||
{ { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
echo "$as_me: error: cannot find input file: $ac_f" >&2;}
{ (exit 1); exit 1; }; };;
esac
ac_file_inputs="$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 "`IFS=:
echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
fi
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin";;
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 ||
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"
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`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 ||
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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
echo "$as_me: error: cannot create directory $as_dir" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`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
sed "/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/
s/:*\${srcdir}:*/:/
s/:*@srcdir@:*/:/
s/^\([^=]*=[ ]*\):*/\1/
s/:*$//
s/^[^=]*=[ ]*$//
}
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s&@configure_input@&$configure_input&;t t
s&@top_builddir@&$ac_top_builddir_sub&;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
" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out"; rm -f "$tmp/out";;
*) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
esac
;;
:H)
#
# CONFIG_HEADER
#
# First, check the format of the line:
cat >"$tmp/defines.sed" <<\CEOF
/^[ ]*#[ ]*undef[ ][ ]*[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*[ ]*$/b def
/^[ ]*#[ ]*define[ ][ ]*[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*[( ]/b def
b
:def
s/$/ /
s,^\([ #]*\)[^ ]*\([ ]*PACKAGE_NAME\)[ (].*,\1define\2 "" ,
s,^\([ #]*\)[^ ]*\([ ]*PACKAGE_TARNAME\)[ (].*,\1define\2 "" ,
s,^\([ #]*\)[^ ]*\([ ]*PACKAGE_VERSION\)[ (].*,\1define\2 "" ,
s,^\([ #]*\)[^ ]*\([ ]*PACKAGE_STRING\)[ (].*,\1define\2 "" ,
s,^\([ #]*\)[^ ]*\([ ]*PACKAGE_BUGREPORT\)[ (].*,\1define\2 "" ,
s,^\([ #]*\)[^ ]*\([ ]*HOST_SYSTEM_TYPE\)[ (].*,\1define\2 "i686-pc-linux-gnu" ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_LIBNSL\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_LIBRESOLV\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_LIBM\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*STDC_HEADERS\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_TYPES_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_STAT_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STDLIB_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRING_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_MEMORY_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRINGS_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_INTTYPES_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STDINT_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_UNISTD_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_ARPA_INET_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_FCNTL_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_LIMITS_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_NETDB_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_NETINET_IN_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STDLIB_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRING_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRINGS_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_IOCTL_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_SOCKET_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_TIME_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_UNISTD_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*TIME_WITH_SYS_TIME\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_ALLOCA_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_ALLOCA\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STDLIB_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_MALLOC\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STDLIB_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_REALLOC\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_SELECT_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SYS_SOCKET_H\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*SELECT_TYPE_ARG1\)[ (].*,\1define\2 int ,
s,^\([ #]*\)[^ ]*\([ ]*SELECT_TYPE_ARG234\)[ (].*,\1define\2 (fd_set *) ,
s,^\([ #]*\)[^ ]*\([ ]*SELECT_TYPE_ARG5\)[ (].*,\1define\2 (struct timeval *) ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRFTIME\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_BZERO\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_GETHOSTBYADDR\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_GETHOSTBYNAME\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_GETTIMEOFDAY\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_INET_NTOA\)[ (].*,\1define\2 1 ,
CEOF
sed -f "$tmp/defines.sed" $ac_file_inputs >"$tmp/out1"
# First, check the format of the line:
cat >"$tmp/defines.sed" <<\CEOF
/^[ ]*#[ ]*undef[ ][ ]*[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*[ ]*$/b def
/^[ ]*#[ ]*define[ ][ ]*[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*[( ]/b def
b
:def
s,^\([ #]*\)[^ ]*\([ ]*HAVE_MEMSET\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SELECT\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SETENV\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_SOCKET\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRCHR\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRDUP\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_STRSTR\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*_BSD_SOURCE\)[ (].*,\1define\2 1 ,
s,^\([ #]*\)[^ ]*\([ ]*HAVE_LIBPCAP\)[ (].*,\1define\2 1 ,
s/ $//
s,^[ #]*u.*,/* & */,
CEOF
sed -f "$tmp/defines.sed" "$tmp/out1" >"$tmp/out2"
ac_result="$tmp/out2"
if test x"$ac_file" != x-; then
echo "/* $configure_input */" >"$tmp/config.h"
cat "$ac_result" >>"$tmp/config.h"
if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
{ echo "$as_me:$LINENO: $ac_file is unchanged" >&5
echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f $ac_file
mv "$tmp/config.h" $ac_file
fi
else
echo "/* $configure_input */"
cat "$ac_result"
fi
rm -f "$tmp/out12"
;;
esac
done # for ac_tag
{ (exit 0); exit 0; }
lft-3.35/config/ 0000755 0000000 0000024 00000000000 12055664006 010457 5 0000000 0000000 lft-3.35/config/config.sub 0000755 0000000 0000024 00000077460 11053131665 012375 0000000 0000000 #! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2006-09-20'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64vr | mips64vrel \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| mt \
| msp430 \
| nios | nios2 \
| ns16k | ns32k \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \
| mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \
| ymp-* \
| z8k-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16c)
basic_machine=cr16c-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
openrisc | openrisc-*)
basic_machine=or32-unknown
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
lft-3.35/config/config.guess 0000755 0000000 0000024 00000126260 11053131665 012723 0000000 0000000 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2006-07-02'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner .
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
exit ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
*:SolidBSD:*:*)
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c &&
dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`$dummy $dummyarg` &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos${UNAME_RELEASE}
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
then
echo "$SYSTEM_NAME"
else
echo rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
eval $set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
i*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
x86:Interix*:[3456]*)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
EM64T:Interix*:[3456]*)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i586-pc-interix
exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
mips:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit ;;
"")
# Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help.
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
exit ;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^LIBC/{
s: ::g
p
}'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
}
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
echo ${UNAME_MACHINE}-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
exit ;;
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <
# include
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
exit ;;
esac
fi
cat >&2 < in order to provide the needed
information to handle your system.
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = ${UNAME_MACHINE}
UNAME_RELEASE = ${UNAME_RELEASE}
UNAME_SYSTEM = ${UNAME_SYSTEM}
UNAME_VERSION = ${UNAME_VERSION}
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
lft-3.35/config/config/ 0000755 0000000 0000024 00000000000 12041511503 011710 5 0000000 0000000 lft-3.35/config/acconfig.h 0000644 0000000 0000000 00000012471 12055642565 012326 0000000 0000000 /* config/acconfig.h. Generated from acconfig.h.in by configure. */
/* acconfig.h.in. */
/* Host system type */
#define HOST_SYSTEM_TYPE "i686-pc-linux-gnu"
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Linux requires this in order to have the right network structures. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the socket function. */
#define HAVE_SOCKET 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define if you have the header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the m library (-lm). */
#define HAVE_LIBM 1
/* Define if you have the nsl library (-lnsl). */
#define HAVE_LIBNSL 1
/* Define if you have the pcap library (-lpcap). */
#define HAVE_LIBPCAP 1
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Define if this is a BSD TCP/IP stack */
/* #undef BSD_IP_STACK */
/* Define if this is Darwin */
/* #undef DARWIN */
/* Define if this is NetBSD */
/* #undef NETBSD */
/* Define if user enabled gettimeofday (GTOD) */
/* #undef USE_GTOD */
/* Define if building universal binaries */
/* #undef UNIVERSAL */
/* Define if this is OpenBSD */
/* #undef OPENBSD */
/* Define if solaris munges the th_sum field in its own special way */
/* #undef SOLARIS_LENGTH_IN_CHECKSUM */
/* Define if your system has a sa_len member in struct sockaddr */
/* #undef HAVE_SOCKADDR_SA_LEN */
/* Define if an IPv6 network stack is detected */
/* #undef INET6 */
lft-3.35/config/configure.ac 0000644 0000000 0000024 00000012014 11053131665 012660 0000000 0000000 dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([lft_ifname.h])
AC_CONFIG_HEADER(config/acconfig.h)
AC_CONFIG_AUX_DIR([config])
dnl This keeps configure quiet about the datarootdir setting
AC_DEFUN([AC_DATAROOTDIR_CHECKED])
AC_DIAGNOSE([obsolete],[AC_CYGWIN is obsolete: use AC_CANONICAL_HOST and check if $host_os
matches *cygwin*])dnl
AC_CANONICAL_HOST
case $host_os in
*cygwin* ) CYGWIN=yes;;
* ) CYGWIN=no;;
esac
AC_DEFINE_UNQUOTED(HOST_SYSTEM_TYPE, "$host")
dnl Checks for programs.
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(resolv, inet_aton)
AC_CHECK_LIB(m, sin)
# Checks for header files and functions
AC_HEADER_STDC
AC_CHECK_HEADERS([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])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_ALLOCA
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([bzero gethostbyaddr gethostbyname gettimeofday inet_ntoa memset select setenv socket strchr strdup strstr])
dnl OS specific checks
case "$host" in
*darwin*)
AC_DEFINE(BSD_IP_STACK)
dnl we need to define DARWIN to turn off
dnl some BSD-type features like BIOC_IMMEDIATE
AC_DEFINE(DARWIN)
;;
*netbsd*)
AC_DEFINE(BSD_IP_STACK)
dnl we need to define NETBSD to turn off
dnl some BSD-type features like BIOC_IMMEDIATE
AC_DEFINE(NETBSD)
;;
*openbsd*)
AC_DEFINE(OPENBSD)
AC_DEFINE(BSD_IP_STACK)
;;
*bsd*)
AC_DEFINE(BSD_IP_STACK)
;;
*linux*)
AC_DEFINE(_BSD_SOURCE)
;;
*solaris*)
dnl some versions of solaris need special treatment
dnl for the th_sum field, and it varies
dnl between versions...
case "$host" in
*solaris2.4*)
AC_DEFINE(SOLARIS_LENGTH_IN_CHECKSUM)
;;
*solaris2.5*)
AC_DEFINE(SOLARIS_LENGTH_IN_CHECKSUM)
;;
esac
;;
esac
case "$host" in
*cygwin*)
: we do not require pcap, but we do require special win32 libraries.
LIBS="-lws2_32 $LIBS"
;;
*)
dnl Option to build universal binaries on Mac OS X
AC_ARG_ENABLE(universal,[ --enable-universal whether to include intel and ppc arch for Mac OS X],[UNIVERSAL="$enableval"],[UNIVERSAL="no"])
dnl Option to enable gettimeofday checks in addition to pcap header timestamp
AC_ARG_ENABLE(gtod,[ --enable-gtod use gettimeofday instead of pcap timestamps], [GTOD="$enableval"],[GTOD="no"])
dnl Make sure we have pcap
AC_ARG_WITH(pcap,
[ --with-pcap=PATH specify path to pcap library],
[
AC_MSG_CHECKING(for --with-pcap option)
case "$withval" in
yes|no)
AC_MSG_ERROR(PATH required with pcap option)
;;
*)
if test '!' -d "$withval"; then
AC_MSG_ERROR($withval does not exist!)
else
AC_MSG_RESULT($withval)
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
]
)
for incdir in /usr/local/include /usr/include
do
if test -d $incdir/pcap
then
CFLAGS="$CFLAGS -I$incdir/pcap"
CPPFLAGS="$CFLAGS -I$incdir/pcap"
fi
done
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
# include
# include ]], [[u_int i = sizeof(((struct sockaddr *)0)->sa_len)]])],[AC_DEFINE(HAVE_SOCKADDR_SA_LEN)],[])
AC_CHECK_LIB(pcap, pcap_lookupdev, , [
AC_MSG_ERROR([
Can't find the pcap library (libpcap.a); 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'])
])
AC_CHECK_HEADER(pcap.h, , [
AC_MSG_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'])
])
esac
dnl Set universal binary options
AC_MSG_CHECKING(if we should build universal binaries)
if test "$UNIVERSAL" = "yes"; then
case $host_os in
*darwin* )
CFLAGS="$CFLAGS -arch i386 -arch ppc"
LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
AC_DEFINE(UNIVERSAL)
AC_MSG_RESULT([yes])
;;
esac
else
AC_MSG_RESULT([no])
fi
dnl Use gettimeofday() on each packet
AC_MSG_CHECKING(if we should gettimeofday for each packet)
if test "$GTOD" = "yes"; then
AC_DEFINE(USE_GTOD)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
lft-3.35/config/acconfig.win.h 0000644 0000000 0000024 00000012235 11053131665 013115 0000000 0000000 /* config/acconfig.h. Generated by configure. */
/* acconfig.h.in. */
/* Host system type */
#define HOST_SYSTEM_TYPE "i686-pc-cygwin"
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Linux requires this in order to have the right network structures. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the socket function. */
#define HAVE_SOCKET 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define if you have the header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the m library (-lm). */
#define HAVE_LIBM 1
/* Define if you have the nsl library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define if you have the pcap library (-lpcap). */
/* #undef HAVE_LIBPCAP */
/* Define if you have the socket library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Define if this is a BSD TCP/IP stack */
/* #undef BSD_IP_STACK */
/* Define if this is Darwin */
/* #undef DARWIN */
/* Define if this is NETBSD */
/* #undef NETBSD */
/* Define if this is OpenBSD */
/* #undef OPENBSD */
/* Define if solaris munges the th_sum field in its own special way */
/* #undef SOLARIS_LENGTH_IN_CHECKSUM */
/* Define if your system has a sa_len member in struct sockaddr */
/* #undef HAVE_SOCKADDR_SA_LEN */
/* Define if an IPv6 network stack is detected */
/* #undef INET6 */
lft-3.35/config/install-sh 0000755 0000000 0000024 00000031600 11053131665 012400 0000000 0000000 #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2006-10-14.15
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
posix_glob=
posix_mkdir=
# Desired mode of installed file.
mode=0755
chmodcmd=$chmodprog
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
shift
shift
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
done
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix=/ ;;
-*) prefix=./ ;;
*) prefix= ;;
esac
case $posix_glob in
'')
if (set -f) 2>/dev/null; then
posix_glob=true
else
posix_glob=false
fi ;;
esac
oIFS=$IFS
IFS=/
$posix_glob && set -f
set fnord $dstdir
shift
$posix_glob && set +f
IFS=$oIFS
prefixes=
for d
do
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dst"; then
$doit $rmcmd -f "$dst" 2>/dev/null \
|| { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
&& { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
|| {
echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
} || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
lft-3.35/config/acconfig.h.in 0000644 0000000 0000024 00000012116 11053131665 012724 0000000 0000000 /* acconfig.h.in. */
/* Host system type */
#undef HOST_SYSTEM_TYPE
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to empty if the keyword does not work. */
#undef const
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define to `unsigned' if doesn't define. */
#undef size_t
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you can safely include both and . */
#undef TIME_WITH_SYS_TIME
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Define if using alloca.c. */
/* #undef C_ALLOCA */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
/* #undef CRAY_STACKSEG_END */
/* Define if you have alloca, as a function or macro. */
#define HAVE_ALLOCA 1
/* Define if you have and it should be used (not on Ultrix). */
#define HAVE_ALLOCA_H 1
/* Define to `unsigned' if doesn't define. */
/* #undef size_t */
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
/* #undef STACK_DIRECTION */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both and . */
#define TIME_WITH_SYS_TIME 1
/* Linux requires this in order to have the right network structures. */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the socket function. */
#undef HAVE_SOCKET
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the header file. */
#undef HAVE_FCNTL_H
/* Define if you have the header file. */
#undef HAVE_LIMITS_H
/* Define if you have the header file. */
#undef HAVE_STRINGS_H
/* Define if you have the header file. */
#undef HAVE_SYS_IOCTL_H
/* Define if you have the header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the header file. */
#undef HAVE_UNISTD_H
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the pcap library (-lpcap). */
#undef HAVE_LIBPCAP
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define if this is a BSD TCP/IP stack */
#undef BSD_IP_STACK
/* Define if this is Darwin */
#undef DARWIN
/* Define if this is NetBSD */
#undef NETBSD
/* Define if user enabled gettimeofday (GTOD) */
#undef USE_GTOD
/* Define if building universal binaries */
#undef UNIVERSAL
/* Define if this is OpenBSD */
#undef OPENBSD
/* Define if solaris munges the th_sum field in its own special way */
#undef SOLARIS_LENGTH_IN_CHECKSUM
/* Define if your system has a sa_len member in struct sockaddr */
#undef HAVE_SOCKADDR_SA_LEN
/* Define if an IPv6 network stack is detected */
#undef INET6
lft-3.35/shortdns.diff 0000644 0000000 0000000 00000002347 12055664047 011635 0000000 0000000 --- lft.c 2012-10-23 20:52:58.000000000 +0800
+++ lft.c.shortdns 2012-11-29 21:49:49.000000000 +0800
@@ -17,16 +17,19 @@
- Portions copyright (c) Genuity, Inc.
- Portions copyright (c) Markus Gothe
- Portions copyright (c) Nils McCarthy
*/
#include "lft_lib.h"
+#include
+extern struct __res_state _res;
+
#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.35"; /* set version string */
const char *version_date = "(10/2012)"; /* date of this version */
static void
@@ -143,17 +146,21 @@
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
-
+
+ res_init();
+ _res.retrans = 1;
+ _res.retry = 1;
+
sess = LFTSessionOpen();
setbuf(stdout, NULL);
while ((ch = getopt(argc, argv, "Aa:bCc:D:d:EeFf:H:hIiL:l:M:m:NnPpq:RrSs:Tt:UuVvxw:z")) != EOF)
switch (ch) {
case 'f':
LFTSetupSendDevice(sess, optarg);
break;
lft-3.35/TODO 0000644 0000000 0000024 00000000603 12041511452 007610 0000000 0000000
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.35/Makefile 0000644 0000000 0000000 00000003627 12055642565 010602 0000000 0000000 #
# 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=/usr/local
datarootdir = ${prefix}/share
datadir = ${datarootdir}
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
mandir=${datarootdir}/man
INSTALL=/usr/bin/install -c
LN=ln -s
# Commands/References
CC=gcc
CFLAGS=-g -O2
LIBS=-lpcap -lm -lresolv -lnsl
LDFLAGS=
CAT=cat
CD=cd
MKDIR=mkdir -p
BUILDTYPE=build
RM=rm -rf
SH=sh
SYSTEM=unix
TOOLS=tools
TOUCH=touch
# 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.35/include/ 0000755 0000000 0000024 00000000000 12041511503 010621 5 0000000 0000000 lft-3.35/include/win32/ 0000755 0000000 0000024 00000000000 12041511503 011563 5 0000000 0000000 lft-3.35/include/win32/wingetopt.c 0000755 0000000 0000024 00000002155 11053131665 013706 0000000 0000000 #if defined(WIN32) || defined(_WIN32)
#include "wingetopt.h"
#include
char *optarg; // global argument pointer
int optind = 0; // global argv index
int getopt(int argc, char *argv[], char *optstring)
{
static char *next = NULL;
char c, * cp;
if (optind == 0)
next = NULL;
optarg = NULL;
if (next == NULL || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return -1;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return -1;
}
next = argv[optind];
next++; // skip past -
optind++;
}
c = *next++;
cp = strchr(optstring, c);
if (cp == NULL || c == ':')
return '?';
cp++;
if (*cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}
#endif
lft-3.35/include/win32/wingettimeofday.h 0000755 0000000 0000024 00000000322 11053131665 015064 0000000 0000000 #ifndef WINGETTIMEOFDAY_H
#define WINGETTIMEOFDAY_H
#include
#ifdef __cplusplus
extern "C"{
#endif
int gettimeofday(struct timeval* tp, void* tzp);
#ifdef __cplusplus
}
#endif
#endif
lft-3.35/include/win32/winlft_ifname.c 0000755 0000000 0000024 00000052302 11053131665 014507 0000000 0000000 #if defined(WIN32) || defined(_WIN32)
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../lft_ifname.h"
typedef enum {
KWV_UNKNOWN, //while unknown (before first call of this module)
KWV_VISTA, //Vista
KWV_2K, //98/ME, NTSP4, W2K and XP
KWV_NT4, //NT4 with SP<4
KWV_95 //Win95
}KNOWN_WIN_VERSION;
static KNOWN_WIN_VERSION VerifyWindowsVersion()
{
static KNOWN_WIN_VERSION WinVersion=KWV_UNKNOWN;
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
if(WinVersion!=KWV_UNKNOWN)
return WinVersion;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi)))
{
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(!GetVersionEx( (OSVERSIONINFO *) &osvi))
return KWV_UNKNOWN;
}
switch(osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT: //Test for the Windows NT product family
if(osvi.dwMajorVersion<=4) //NT4
{
if(osvi.wServicePackMajor<4)
WinVersion=KWV_NT4;
else
WinVersion=KWV_2K;
}
else
{
if(osvi.dwMajorVersion>5)
WinVersion=KWV_VISTA;
else
WinVersion=KWV_2K; //2K and XP
}
break;
case VER_PLATFORM_WIN32_WINDOWS: //Test for the Windows Me/98/95
default:
WinVersion=KWV_95;
break;
}
return WinVersion;
}
static u_long lft_getifaddr_95(const char *argifname)
{
HKEY key;
char ethname[5]="eth/";
char pppname[5]="ppp/";
int i;
FILETIME update;
LONG res;
DWORD size;
u_long ret;
char ifname[256];
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Enum\\Network\\MSTCP", 0, KEY_READ, &key) != ERROR_SUCCESS)
return -1;
size = sizeof(ifname);
for(i=0;(res = RegEnumKeyEx(key, i, (LPTSTR)ifname, &size, 0, 0, 0, &update))!=ERROR_NO_MORE_ITEMS;i++)
{
HKEY ifkey, subkey;
DWORD dsize,ipsize,npsize,asize;
char driver[256], classname[256], netname[256];
char adapter[256], ip[256], np[256];
if(res != ERROR_SUCCESS || RegOpenKeyEx(key, (LPCTSTR)ifname, 0, KEY_READ, &ifkey) != ERROR_SUCCESS)
continue;
dsize = sizeof(driver);
if(RegQueryValueEx(ifkey, L"Driver", 0, NULL, (unsigned char *)driver, &dsize) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
strcpy(classname, "System\\CurrentControlSet\\Services\\Class\\");
strcat(classname, driver);
if((res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)classname, 0, KEY_READ, &subkey)) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
ipsize=sizeof(ip);
npsize=sizeof(np);
if(RegQueryValueEx(subkey, L"IPAddress", 0, NULL, (unsigned char *) ip, &ipsize) == ERROR_SUCCESS)
{
ret=inet_addr(ip);
RegCloseKey (subkey);
strcpy(netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
strcat(netname, ifname);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)netname, 0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
asize=sizeof(adapter);
if( RegQueryValueEx (subkey, L"AdapterName", 0, NULL, (unsigned char *) adapter, &asize) == ERROR_SUCCESS &&
!strcmp(adapter, "MS$PPP"))
{
pppname[3]++;
}
else
{
ethname[3]++;
}
RegCloseKey(subkey);
RegCloseKey(ifkey);
if(!strcmp(pppname,argifname) || !strcmp(ethname,argifname))
break;
else
ret=-1;
}
}
RegCloseKey(key);
return ret;
}
static char * lft_getifname_95(struct in_addr addr)
{
HKEY key;
char ethname[5]="eth/";
char pppname[5]="ppp/";
int i;
FILETIME update;
LONG res;
DWORD size;
u_long ret;
int isethaddr,isfound;
char ifname[256];
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Enum\\Network\\MSTCP", 0, KEY_READ, &key) != ERROR_SUCCESS)
return NULL;
size = sizeof(ifname);
for(i=0;(res = RegEnumKeyEx(key, i, (TCHAR *)ifname, &size, 0, 0, 0, &update))!=ERROR_NO_MORE_ITEMS;i++)
{
HKEY ifkey, subkey;
DWORD dsize,ipsize,npsize,asize;
char driver[256], classname[256], netname[256];
char adapter[256], ip[256], np[256];
if(res != ERROR_SUCCESS || RegOpenKeyEx(key, (LPCTSTR)ifname, 0, KEY_READ, &ifkey) != ERROR_SUCCESS)
continue;
dsize = sizeof(driver);
if(RegQueryValueEx(ifkey, L"Driver", 0, NULL, (unsigned char *)driver, &dsize) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
strcpy(classname, "System\\CurrentControlSet\\Services\\Class\\");
strcat(classname, driver);
if((res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)classname, 0, KEY_READ, &subkey)) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
ipsize=sizeof(ip);
npsize=sizeof(np);
if(RegQueryValueEx(subkey, L"IPAddress", 0, NULL, (unsigned char *) ip, &ipsize) == ERROR_SUCCESS)
{
ret=inet_addr(ip);
RegCloseKey (subkey);
strcpy(netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
strcat(netname, ifname);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)netname, 0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey(ifkey);
continue;
}
asize=sizeof(adapter);
if( RegQueryValueEx (subkey, L"AdapterName", 0, NULL, (unsigned char *) adapter, &asize) == ERROR_SUCCESS &&
!strcmp(adapter, "MS$PPP"))
{
pppname[3]++;
isethaddr=0;
}
else
{
ethname[3]++;
isethaddr=1;
}
RegCloseKey(subkey);
RegCloseKey(ifkey);
if(ret==addr.s_addr)
{
isfound=1;
break;
}
else
isfound=0;
}
}
RegCloseKey(key);
if(!isfound)
return NULL;
if(isethaddr)
return strdup(ethname);
return strdup(pppname);
}
static u_long lft_getifaddr_NT4(const char *ifname)
{
HKEY key;
char devname[256];
struct sockaddr_in *sa = NULL;
struct sockaddr *so = NULL;
DWORD size;
int cnt = 1,isfound;
u_long ret;
char *binding = (char *)0;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &key) == ERROR_SUCCESS)
{
if(RegQueryValueEx(key, L"Bind", NULL, NULL, NULL, &size) == ERROR_SUCCESS)
{
binding = (char *)_alloca(size);
if(RegQueryValueEx (key, L"Bind", NULL, NULL, (unsigned char *)binding, &size) != ERROR_SUCCESS)
binding = NULL;
}
RegCloseKey(key);
}
if(binding)
{
char *bp, eth[2] = "/";
int ipsize;
char cardkey[256], ipaddress[256];
for(bp = binding; *bp; bp+=strlen(bp)+1)
{
bp += strlen("\\Device\\");
strcpy(cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
strcat(cardkey, bp);
strcat(cardkey, "\\Parameters\\Tcpip");
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)cardkey, 0, KEY_READ, &key) != ERROR_SUCCESS)
continue;
ipsize=256;
if(RegQueryValueEx(key, L"IPAddress", NULL, NULL, (unsigned char *) ipaddress, &ipsize) == ERROR_SUCCESS)
{
char *ip;
for(ip = ipaddress; *ip; ip += strlen(ip)+1)
{
if(!strncmp(bp, "NdisWan", 7))
{
strcpy(devname, "ppp");
strcat(devname, bp + 7);
}
else
{
eth[0]++;
strcpy(devname, "eth");
strcat(devname, eth);
}
ret=inet_addr(ipaddress);
if(!ret)
{
ipsize=256;
if(RegQueryValueEx (key, L"DhcpIPAddress", NULL, NULL, (unsigned char *) ipaddress, &ipsize) == ERROR_SUCCESS)
{
ret=inet_addr(ipaddress);
}
}
if(!strcmp(devname,ifname))
{
isfound=1;
break;
}
else
isfound=0;
}
}
RegCloseKey(key);
if(isfound)
return ret;
}
}
return -1;
}
static char * lft_getifname_NT4(struct in_addr addr)
{
HKEY key;
char devname[256];
struct sockaddr_in *sa = NULL;
struct sockaddr *so = NULL;
DWORD size;
int cnt = 1,isfound;
u_long ret;
char *binding = (char *)0;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, KEY_READ, &key) == ERROR_SUCCESS)
{
if(RegQueryValueEx(key, L"Bind", NULL, NULL, NULL, &size) == ERROR_SUCCESS)
{
binding = (char *)_alloca(size);
if(RegQueryValueEx (key, L"Bind", NULL, NULL, (unsigned char *)binding, &size) != ERROR_SUCCESS)
binding = NULL;
}
RegCloseKey(key);
}
if(binding)
{
char *bp, eth[2] = "/";
int ipsize;
char cardkey[256];
char ipaddress[256];
for(bp = binding; *bp; bp+=strlen(bp)+1)
{
bp += strlen("\\Device\\");
strcpy(cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
strcat(cardkey, bp);
strcat(cardkey, "\\Parameters\\Tcpip");
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)cardkey, 0, KEY_READ, &key) != ERROR_SUCCESS)
continue;
ipsize=256;
if(RegQueryValueEx(key, L"IPAddress", NULL, NULL, (unsigned char *) ipaddress, &ipsize) == ERROR_SUCCESS)
{
char *ip;
for(ip = ipaddress; *ip; ip += strlen(ip)+1)
{
if(!strncmp(bp, "NdisWan", 7))
{
strcpy(devname, "ppp");
strcat(devname, bp + 7);
}
else
{
eth[0]++;
strcpy(devname, "eth");
strcat(devname, eth);
}
ret=inet_addr(ipaddress);
if(!ret)
{
ipsize=256;
if(RegQueryValueEx (key, L"DhcpIPAddress", NULL, NULL, (unsigned char *) ipaddress, &ipsize) == ERROR_SUCCESS)
{
ret=inet_addr(ipaddress);
}
}
if(addr.s_addr==ret)
{
isfound=1;
break;
}
else
isfound=0;
}
}
RegCloseKey(key);
if(isfound)
return strdup(devname);
}
}
return NULL;
}
static u_long lft_getifaddr_2K(const char *ifname)
{
int cnt = 0;
int ethId = 0, pppId = 0, slpId = 0, tokId = 0;
DWORD ip_cnt;
DWORD siz_ip_table = 0;
PMIB_IPADDRTABLE ipt;
PMIB_IFROW ifrow;
char devname[256];
typedef struct
{
DWORD ifIndex;
size_t count;
unsigned int enumerated; // for eth0:1
unsigned int classId; // for eth0, tok0 ...
} ifcount_t;
ifcount_t *iflist, *ifEntry;
if(GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER)
{
ifrow = (PMIB_IFROW)_alloca(sizeof(MIB_IFROW));
ipt = (PMIB_IPADDRTABLE)_alloca(siz_ip_table);
}
if(GetIpAddrTable (ipt, &siz_ip_table, TRUE) != NO_ERROR)
return -1;
iflist = (ifcount_t *) alloca(sizeof(ifcount_t)*(ipt->dwNumEntries + 1));
memset(iflist, 0, sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
for(ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
{
ifEntry = iflist;
/* search for matching entry (and stop at first free entry) */
while(ifEntry->count != 0)
{
if(ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
break;
ifEntry++;
}
if(ifEntry->count == 0)
{
ifEntry->count = 1;
ifEntry->ifIndex = ipt->table[ip_cnt].dwIndex;
}
else
{
ifEntry->count++;
}
}
// reset the last element. This is just the stopper for the loop.
iflist[ipt->dwNumEntries].count = 0;
for(ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ip_cnt++)
{
ifcount_t *ifEntry = iflist;
memset(ifrow, 0, sizeof(MIB_IFROW));
ifrow->dwIndex = ipt->table[ip_cnt].dwIndex;
if(GetIfEntry(ifrow) != NO_ERROR)
continue;
/* search for matching entry (and stop at first free entry) */
while(ifEntry->count != 0)
{
if(ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
break;
ifEntry++;
}
/* Setup the interface name */
switch(ifrow->dwType)
{
case MIB_IF_TYPE_TOKENRING:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = tokId++;
sprintf(devname, "tok%u", ifEntry->classId);
}
else
{
sprintf(devname, "tok%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
#ifdef IF_TYPE_IEEE80211
case IF_TYPE_IEEE80211:
#endif
case MIB_IF_TYPE_ETHERNET:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = ethId++;
sprintf(devname, "eth%u", ifEntry->classId);
}
else
{
sprintf(devname, "eth%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_PPP:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = pppId++;
sprintf(devname, "ppp%u", ifEntry->classId);
}
else
{
sprintf(devname, "ppp%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_SLIP:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = slpId++;
sprintf(devname, "slp%u", ifEntry->classId);
}
else
{
sprintf(devname, "slp%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_LOOPBACK:
strcpy(devname, "lo");
break;
default:
continue;
}
if(!strcmp(devname,ifname))
{
return ipt->table[ip_cnt].dwAddr;
}
}
return -1;
}
static char * lft_getifname_2K(struct in_addr addr)
{
int cnt = 0;
int ethId = 0, pppId = 0, slpId = 0, tokId = 0;
DWORD ip_cnt;
DWORD siz_ip_table = 0;
PMIB_IPADDRTABLE ipt;
PMIB_IFROW ifrow;
static char devname[256];
static struct in_addr savedaddr;
static int FirstTime=1;
typedef struct
{
DWORD ifIndex;
size_t count;
unsigned int enumerated; // for eth0:1
unsigned int classId; // for eth0, tok0 ...
} ifcount_t;
ifcount_t *iflist, *ifEntry;
if(!FirstTime && savedaddr.s_addr==addr.s_addr)
{
return strdup(devname);
}
savedaddr.s_addr=addr.s_addr;
if(GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER)
{
ifrow = (PMIB_IFROW)_alloca(sizeof(MIB_IFROW));
ipt = (PMIB_IPADDRTABLE)_alloca(siz_ip_table);
}
if(GetIpAddrTable (ipt, &siz_ip_table, TRUE) != NO_ERROR)
return NULL;
iflist = (ifcount_t *) alloca(sizeof(ifcount_t)*(ipt->dwNumEntries + 1));
memset(iflist, 0, sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
for(ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
{
ifEntry = iflist;
/* search for matching entry (and stop at first free entry) */
while(ifEntry->count != 0)
{
if(ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
break;
ifEntry++;
}
if(ifEntry->count == 0)
{
ifEntry->count = 1;
ifEntry->ifIndex = ipt->table[ip_cnt].dwIndex;
}
else
{
ifEntry->count++;
}
}
// reset the last element. This is just the stopper for the loop.
iflist[ipt->dwNumEntries].count = 0;
for(ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ip_cnt++)
{
ifcount_t *ifEntry = iflist;
memset(ifrow, 0, sizeof(MIB_IFROW));
ifrow->dwIndex = ipt->table[ip_cnt].dwIndex;
if(GetIfEntry(ifrow) != NO_ERROR)
continue;
/* search for matching entry (and stop at first free entry) */
while(ifEntry->count != 0)
{
if(ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
break;
ifEntry++;
}
/* Setup the interface name */
switch(ifrow->dwType)
{
case MIB_IF_TYPE_TOKENRING:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = tokId++;
sprintf(devname, "tok%u", ifEntry->classId);
}
else
{
sprintf(devname, "tok%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
#ifdef IF_TYPE_IEEE80211
case IF_TYPE_IEEE80211:
#endif
case MIB_IF_TYPE_ETHERNET:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = ethId++;
sprintf(devname, "eth%u", ifEntry->classId);
}
else
{
sprintf(devname, "eth%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_PPP:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = pppId++;
sprintf(devname, "ppp%u", ifEntry->classId);
}
else
{
sprintf(devname, "ppp%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_SLIP:
if(ifEntry->enumerated == 0)
{
ifEntry->classId = slpId++;
sprintf(devname, "slp%u", ifEntry->classId);
}
else
{
sprintf(devname, "slp%u:%u", ifEntry->classId, ifEntry->enumerated - 1);
}
ifEntry->enumerated++;
break;
case MIB_IF_TYPE_LOOPBACK:
strcpy(devname, "lo");
break;
default:
continue;
}
if(addr.s_addr==ipt->table[ip_cnt].dwAddr)
{
FirstTime=0;
return strdup(devname);
}
}
return NULL;
}
u_long lft_getifaddr (const char *ifname)
{
switch(VerifyWindowsVersion())
{
case KWV_95:
return lft_getifaddr_95(ifname);
case KWV_2K:
case KWV_VISTA:
return lft_getifaddr_2K(ifname);
case KWV_NT4:
return lft_getifaddr_NT4(ifname);
}
return -1;
}
char * lft_getifname (struct in_addr addr)
{
static char ifname[256];
static struct in_addr savedaddr;
static int FirstTime=1;
char * ret;
if(!FirstTime && savedaddr.s_addr==addr.s_addr)
{
return strdup(ifname);
}
switch(VerifyWindowsVersion())
{
case KWV_95:
ret=lft_getifname_95(addr);
break;
case KWV_2K:
case KWV_VISTA:
ret=lft_getifname_2K(addr);
break;
case KWV_NT4:
ret=lft_getifname_NT4(addr);
break;
}
savedaddr.s_addr=addr.s_addr;
FirstTime=0;
strncpy(ifname,ret,255);
return ret;
}
#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.35/include/win32/wingetopt.h 0000755 0000000 0000024 00000000350 11053131665 013706 0000000 0000000 #ifndef WINGETOPT_H
#define WINGETOPT_H
#ifdef __cplusplus
extern "C"{
#endif
extern int optind, opterr;
extern char *optarg;
int getopt(int argc, char *argv[], char *optstring);
#ifdef __cplusplus
}
#endif
#endif
lft-3.35/include/win32/wingettimeofday.c 0000755 0000000 0000024 00000004461 11053131665 015067 0000000 0000000 #if defined(WIN32) || defined(_WIN32)
#include "wingettimeofday.h"
#include
#ifndef __GNUC__
#define EPOCHFILETIME (116444736000000000i64)
#else
#define EPOCHFILETIME (116444736000000000LL)
#endif
int __gettimeofday(struct timeval* tv, void * tz)
{
struct _timeb currSysTime;
_ftime(&currSysTime);
tv->tv_sec = currSysTime.time;
tv->tv_usec = currSysTime.millitm * 1000;
return 0;
}
LARGE_INTEGER getFILETIMEoffset()
{
SYSTEMTIME s;
FILETIME f;
LARGE_INTEGER t;
s.wYear = 1970;
s.wMonth = 1;
s.wDay = 1;
s.wHour = 0;
s.wMinute = 0;
s.wSecond = 0;
s.wMilliseconds = 0;
SystemTimeToFileTime(&s, &f);
t.QuadPart = f.dwHighDateTime;
t.QuadPart <<= 32;
t.QuadPart |= f.dwLowDateTime;
return (t);
}
int gettimeofday(struct timeval *tv, void * tz)
{
LARGE_INTEGER t;
FILETIME f;
double microseconds;
static LARGE_INTEGER offset;
static LARGE_INTEGER base;
static double frequencyToMicroseconds;
static int initialized = 0;
static BOOL usePerformanceCounter = 0;
if(!initialized)
{
LARGE_INTEGER performanceFrequency;
initialized = 1;
usePerformanceCounter = QueryPerformanceFrequency(&performanceFrequency);
if(usePerformanceCounter)
{
LARGE_INTEGER tmpoffs;
QueryPerformanceCounter(&offset);
frequencyToMicroseconds = (double)performanceFrequency.QuadPart / 1000000.;
tmpoffs = getFILETIMEoffset();
GetSystemTimeAsFileTime(&f);
base.QuadPart = f.dwHighDateTime;
base.QuadPart <<= 32;
base.QuadPart |= f.dwLowDateTime;
base.QuadPart -= tmpoffs.QuadPart;
microseconds = (double)base.QuadPart / 10;
base.QuadPart = microseconds;
tv->tv_sec = base.QuadPart / 1000000;
tv->tv_usec = base.QuadPart % 1000000;
}
else
{
offset = getFILETIMEoffset();
frequencyToMicroseconds = 10.;
base.QuadPart=0i64;
}
}
if(usePerformanceCounter)
QueryPerformanceCounter(&t);
else
{
GetSystemTimeAsFileTime(&f);
t.QuadPart = f.dwHighDateTime;
t.QuadPart <<= 32;
t.QuadPart |= f.dwLowDateTime;
}
t.QuadPart -= offset.QuadPart;
microseconds = (double)t.QuadPart / frequencyToMicroseconds;
t.QuadPart = microseconds + base.QuadPart;
tv->tv_sec = t.QuadPart / 1000000;
tv->tv_usec = t.QuadPart % 1000000;
return (0);
}
#endif
lft-3.35/include/sys/ 0000755 0000000 0000024 00000000000 12055664006 011453 5 0000000 0000000 lft-3.35/include/sys/mbuf.h 0000755 0000000 0000024 00000000105 11053131665 012471 0000000 0000000 #ifndef MLEN
#define MLEN 128 /* needed for slcompress.h */
#endif
lft-3.35/include/netinet/ 0000755 0000000 0000024 00000000000 12055664006 012303 5 0000000 0000000 lft-3.35/include/netinet/tcp_var.h 0000755 0000000 0000024 00000027663 11053131665 014050 0000000 0000000 /*
* Copyright (c) 1982, 1986, 1993, 1994, 1995
* 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.
*
* @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
*/
/*
* Kernel variables for tcp.
*/
/*
* Tcp control block, one per tcp; fields:
*/
struct tcpcb {
struct tcpiphdr *seg_next; /* sequencing queue */
struct tcpiphdr *seg_prev;
short t_state; /* state of this connection */
short t_timer[TCPT_NTIMERS]; /* tcp timers */
short t_rxtshift; /* log(2) of rexmt exp. backoff */
short t_rxtcur; /* current retransmit value */
short t_dupacks; /* consecutive dup acks recd */
u_short t_maxseg; /* maximum segment size */
char t_force; /* 1 if forcing out a byte */
u_short t_flags;
#define TF_ACKNOW 0x0001 /* ack peer immediately */
#define TF_DELACK 0x0002 /* ack, but try to delay it */
#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */
#define TF_NOOPT 0x0008 /* don't use tcp options */
#define TF_SENTFIN 0x0010 /* have sent FIN */
#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */
#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */
#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */
#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */
#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */
struct tcpiphdr *t_template; /* skeletal packet for transmit */
struct inpcb *t_inpcb; /* back pointer to internet pcb */
/*
* The following fields are used as in the protocol specification.
* See RFC783, Dec. 1981, page 21.
*/
/* send sequence variables */
tcp_seq snd_una; /* send unacknowledged */
tcp_seq snd_nxt; /* send next */
tcp_seq snd_up; /* send urgent pointer */
tcp_seq snd_wl1; /* window update seg seq number */
tcp_seq snd_wl2; /* window update seg ack number */
tcp_seq iss; /* initial send sequence number */
u_long snd_wnd; /* send window */
/* receive sequence variables */
u_long rcv_wnd; /* receive window */
tcp_seq rcv_nxt; /* receive next */
tcp_seq rcv_up; /* receive urgent pointer */
tcp_seq irs; /* initial receive sequence number */
/*
* Additional variables for this implementation.
*/
/* receive variables */
tcp_seq rcv_adv; /* advertised window */
/* retransmit variables */
tcp_seq snd_max; /* highest sequence number sent;
* used to recognize retransmits
*/
/* congestion control (for slow start, source quench, retransmit after loss) */
u_long snd_cwnd; /* congestion-controlled window */
u_long snd_ssthresh; /* snd_cwnd size threshhold for
* for slow start exponential to
* linear switch
*/
/*
* transmit timing stuff. See below for scale of srtt and rttvar.
* "Variance" is actually smoothed difference.
*/
u_short t_idle; /* inactivity time */
short t_rtt; /* round trip time */
tcp_seq t_rtseq; /* sequence number being timed */
short t_srtt; /* smoothed round-trip time */
short t_rttvar; /* variance in round-trip time */
u_short t_rttmin; /* minimum rtt allowed */
u_long max_sndwnd; /* largest window peer has offered */
/* out-of-band data */
char t_oobflags; /* have some */
char t_iobc; /* input character */
#define TCPOOB_HAVEDATA 0x01
#define TCPOOB_HADDATA 0x02
short t_softerror; /* possible error not yet reported */
/* RFC 1323 variables */
u_char snd_scale; /* window scaling for send window */
u_char rcv_scale; /* window scaling for recv window */
u_char request_r_scale; /* pending window scaling */
u_char requested_s_scale;
u_long ts_recent; /* timestamp echo data */
u_long ts_recent_age; /* when last updated */
tcp_seq last_ack_sent;
/* TUBA stuff */
caddr_t t_tuba_pcb; /* next level down pcb for TCP over z */
};
#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
/*
* The smoothed round-trip time and estimated variance
* are stored as fixed point numbers scaled by the values below.
* For convenience, these scales are also used in smoothing the average
* (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
* With these scales, srtt has 3 bits to the right of the binary point,
* and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
* binary point, and is smoothed with an ALPHA of 0.75.
*/
#define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */
#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
#define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */
#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
/*
* The initial retransmission should happen at rtt + 4 * rttvar.
* Because of the way we do the smoothing, srtt and rttvar
* will each average +1/2 tick of bias. When we compute
* the retransmit timer, we want 1/2 tick of rounding and
* 1 extra tick because of +-1/2 tick uncertainty in the
* firing of the timer. The bias will give us exactly the
* 1.5 tick we need. But, because the bias is
* statistical, we have to test that we don't drop below
* the minimum feasible timer (which is 2 ticks).
* This macro assumes that the value of TCP_RTTVAR_SCALE
* is the same as the multiplier for rttvar.
*/
#define TCP_REXMTVAL(tp) \
(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
/* XXX
* We want to avoid doing m_pullup on incoming packets but that
* means avoiding dtom on the tcp reassembly code. That in turn means
* keeping an mbuf pointer in the reassembly queue (since we might
* have a cluster). As a quick hack, the source & destination
* port numbers (which are no longer needed once we've located the
* tcpcb) are overlayed with an mbuf pointer.
*/
#define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t))
/*
* TCP statistics.
* Many of these should be kept per connection,
* but that's inconvenient at the moment.
*/
struct tcpstat {
u_long tcps_connattempt; /* connections initiated */
u_long tcps_accepts; /* connections accepted */
u_long tcps_connects; /* connections established */
u_long tcps_drops; /* connections dropped */
u_long tcps_conndrops; /* embryonic connections dropped */
u_long tcps_closed; /* conn. closed (includes drops) */
u_long tcps_segstimed; /* segs where we tried to get rtt */
u_long tcps_rttupdated; /* times we succeeded */
u_long tcps_delack; /* delayed acks sent */
u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
u_long tcps_rexmttimeo; /* retransmit timeouts */
u_long tcps_persisttimeo; /* persist timeouts */
u_long tcps_keeptimeo; /* keepalive timeouts */
u_long tcps_keepprobe; /* keepalive probes sent */
u_long tcps_keepdrops; /* connections dropped in keepalive */
u_long tcps_sndtotal; /* total packets sent */
u_long tcps_sndpack; /* data packets sent */
u_long tcps_sndbyte; /* data bytes sent */
u_long tcps_sndrexmitpack; /* data packets retransmitted */
u_long tcps_sndrexmitbyte; /* data bytes retransmitted */
u_long tcps_sndacks; /* ack-only packets sent */
u_long tcps_sndprobe; /* window probes sent */
u_long tcps_sndurg; /* packets sent with URG only */
u_long tcps_sndwinup; /* window update-only packets sent */
u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
u_long tcps_rcvtotal; /* total packets received */
u_long tcps_rcvpack; /* packets received in sequence */
u_long tcps_rcvbyte; /* bytes received in sequence */
u_long tcps_rcvbadsum; /* packets received with ccksum errs */
u_long tcps_rcvbadoff; /* packets received with bad offset */
u_long tcps_rcvshort; /* packets received too short */
u_long tcps_rcvduppack; /* duplicate-only packets received */
u_long tcps_rcvdupbyte; /* duplicate-only bytes received */
u_long tcps_rcvpartduppack; /* packets with some duplicate data */
u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
u_long tcps_rcvoopack; /* out-of-order packets received */
u_long tcps_rcvoobyte; /* out-of-order bytes received */
u_long tcps_rcvpackafterwin; /* packets with data after window */
u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */
u_long tcps_rcvafterclose; /* packets rcvd after "close" */
u_long tcps_rcvwinprobe; /* rcvd window probe packets */
u_long tcps_rcvdupack; /* rcvd duplicate acks */
u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */
u_long tcps_rcvackpack; /* rcvd ack packets */
u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */
u_long tcps_rcvwinupd; /* rcvd window update packets */
u_long tcps_pawsdrop; /* segments dropped due to PAWS */
u_long tcps_predack; /* times hdr predict ok for acks */
u_long tcps_preddat; /* times hdr predict ok for data pkts */
u_long tcps_pcbcachemiss;
u_long tcps_persistdrop; /* timeout in persist state */
u_long tcps_badsyn; /* bogus SYN, e.g. premature ACK */
};
#ifdef KERNEL
struct inpcb tcb; /* head of queue of active tcpcb's */
struct tcpstat tcpstat; /* tcp statistics */
u_long tcp_now; /* for RFC 1323 timestamps */
int tcp_attach __P((struct socket *));
void tcp_canceltimers __P((struct tcpcb *));
struct tcpcb *
tcp_close __P((struct tcpcb *));
void tcp_ctlinput __P((int, struct sockaddr *, struct ip *));
int tcp_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
struct tcpcb *
tcp_disconnect __P((struct tcpcb *));
struct tcpcb *
tcp_drop __P((struct tcpcb *, int));
void tcp_dooptions __P((struct tcpcb *,
u_char *, int, struct tcpiphdr *, int *, u_long *, u_long *));
void tcp_drain __P((void));
void tcp_fasttimo __P((void));
void tcp_init __P((void));
void tcp_input __P((struct mbuf *, int));
int tcp_mss __P((struct tcpcb *, u_int));
struct tcpcb *
tcp_newtcpcb __P((struct inpcb *));
void tcp_notify __P((struct inpcb *, int));
int tcp_output __P((struct tcpcb *));
void tcp_pulloutofband __P((struct socket *,
struct tcpiphdr *, struct mbuf *));
void tcp_quench __P((struct inpcb *, int));
int tcp_reass __P((struct tcpcb *, struct tcpiphdr *, struct mbuf *));
void tcp_respond __P((struct tcpcb *,
struct tcpiphdr *, struct mbuf *, u_long, u_long, int));
void tcp_setpersist __P((struct tcpcb *));
void tcp_slowtimo __P((void));
struct tcpiphdr *
tcp_template __P((struct tcpcb *));
struct tcpcb *
tcp_timers __P((struct tcpcb *, int));
void tcp_trace __P((int, int, struct tcpcb *, struct tcpiphdr *, int));
struct tcpcb *
tcp_usrclosed __P((struct tcpcb *));
int tcp_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
void tcp_xmit_timer __P((struct tcpcb *, int));
#endif
lft-3.35/include/netinet/ip_icmp.h 0000755 0000000 0000024 00000014530 11053131665 014017 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
*/
/*
* Interface Control Message Protocol Definitions.
* Per RFC 792, September 1981.
*/
/*
* Structure of an icmp header.
*/
struct icmp {
u_char icmp_type; /* type of message, see below */
u_char icmp_code; /* type sub code */
u_short icmp_cksum; /* ones complement cksum of struct */
union {
u_char ih_pptr; /* ICMP_PARAMPROB */
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
struct ih_idseq {
n_short icd_id;
n_short icd_seq;
} ih_idseq;
int ih_void;
/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
struct ih_pmtu {
n_short ipm_void;
n_short ipm_nextmtu;
} ih_pmtu;
} icmp_hun;
#define icmp_pptr icmp_hun.ih_pptr
#define icmp_gwaddr icmp_hun.ih_gwaddr
#define icmp_id icmp_hun.ih_idseq.icd_id
#define icmp_seq icmp_hun.ih_idseq.icd_seq
#define icmp_void icmp_hun.ih_void
#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
union {
struct id_ts {
n_time its_otime;
n_time its_rtime;
n_time its_ttime;
} id_ts;
struct id_ip {
struct ip idi_ip;
/* options and then 64 bits of data */
} id_ip;
u_long id_mask;
char id_data[1];
} icmp_dun;
#define icmp_otime icmp_dun.id_ts.its_otime
#define icmp_rtime icmp_dun.id_ts.its_rtime
#define icmp_ttime icmp_dun.id_ts.its_ttime
#define icmp_ip icmp_dun.id_ip.idi_ip
#define icmp_mask icmp_dun.id_mask
#define icmp_data icmp_dun.id_data
};
/*
* Lower bounds on packet lengths for various types.
* For the error advice packets must first insure that the
* packet is large enought to contain the returned ip header.
* Only then can we do the check to see if 64 bits of packet
* data have been returned, since we need to check the returned
* ip header length.
*/
#define ICMP_MINLEN 8 /* abs minimum */
#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
#define ICMP_MASKLEN 12 /* address mask */
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
/* N.B.: must separately check that ip_hl >= 5 */
/*
* Definition of type and code field values.
*/
#define ICMP_ECHOREPLY 0 /* echo reply */
#define ICMP_UNREACH 3 /* dest unreachable, codes: */
#define ICMP_UNREACH_NET 0 /* bad net */
#define ICMP_UNREACH_HOST 1 /* bad host */
#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
#define ICMP_UNREACH_PORT 3 /* bad port */
#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
#define ICMP_REDIRECT 5 /* shorter route, codes: */
#define ICMP_REDIRECT_NET 0 /* for network */
#define ICMP_REDIRECT_HOST 1 /* for host */
#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
#define ICMP_ECHO 8 /* echo service */
#define ICMP_ROUTERADVERT 9 /* router advertisement */
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
#define ICMP_TIMXCEED 11 /* time exceeded, code: */
#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
#define ICMP_PARAMPROB 12 /* ip header bad */
#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
#define ICMP_TSTAMP 13 /* timestamp request */
#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
#define ICMP_IREQ 15 /* information request */
#define ICMP_IREQREPLY 16 /* information reply */
#define ICMP_MASKREQ 17 /* address mask request */
#define ICMP_MASKREPLY 18 /* address mask reply */
#define ICMP_MAXTYPE 18
#define ICMP_INFOTYPE(type) \
((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
#ifdef KERNEL
void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
void icmp_input __P((struct mbuf *, int));
void icmp_reflect __P((struct mbuf *));
void icmp_send __P((struct mbuf *, struct mbuf *));
int icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
#endif
lft-3.35/include/netinet/if_ether.h 0000755 0000000 0000024 00000006352 11053131665 014167 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)if_ether.h 8.3 (Berkeley) 5/2/95
*/
/*
* Ethernet address - 6 octets
*/
struct ether_addr {
u_char ether_addr_octet[6];
};
/*
* Structure of a 10Mb/s Ethernet header.
*/
struct ether_header {
u_char ether_dhost[6];
u_char ether_shost[6];
u_short ether_type;
};
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
/*
* The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
* (type-ETHERTYPE_TRAIL)*512 bytes of data followed
* by an ETHER type (as given above) and then the (variable-length) header.
*/
#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
#define ETHERTYPE_NTRAILER 16
#define ETHERMTU 1500
#define ETHERMIN (60-14)
/*
* Ethernet Address Resolution Protocol.
*
* See RFC 826 for protocol description. Structure below is adapted
* to resolving internet addresses. Field names used correspond to
* RFC 826.
*/
struct ether_arp {
struct arphdr ea_hdr; /* fixed-size header */
u_char arp_sha[6]; /* sender hardware address */
u_char arp_spa[4]; /* sender protocol address */
u_char arp_tha[6]; /* target hardware address */
u_char arp_tpa[4]; /* target protocol address */
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
lft-3.35/include/netinet/in_systm.h 0000755 0000000 0000024 00000004662 11053131665 014251 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)in_systm.h 8.1 (Berkeley) 6/10/93
*/
/*
* Miscellaneous internetwork
* definitions for kernel.
*/
/*
* Network types.
*
* Internally the system keeps counters in the headers with the bytes
* swapped so that VAX instructions will work on them. It reverses
* the bytes before transmission at each protocol level. The n_ types
* represent the types with the bytes in ``high-ender'' order.
*/
typedef u_short n_short; /* short as received from the net */
typedef u_long n_long; /* long as received from the net */
typedef u_long n_time; /* ms since 00:00 GMT, byte rev */
#ifdef KERNEL
n_time iptime __P((void));
#endif
lft-3.35/include/netinet/ip.h 0000755 0000000 0000024 00000013215 11053131665 013006 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
/*
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
*/
#define IPVERSION 4
/*
* Structure of an internet header, naked of options.
*
* We declare ip_len and ip_off to be short, rather than u_short
* pragmatically since otherwise unsigned comparisons can result
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
#if BYTE_ORDER == LITTLE_ENDIAN
u_char ip_hl:4, /* header length */
ip_v:4; /* version */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char ip_v:4, /* version */
ip_hl:4; /* header length */
#endif
u_char ip_tos; /* type of service */
short ip_len; /* total length */
u_short ip_id; /* identification */
short ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_char ip_ttl; /* time to live */
u_char ip_p; /* protocol */
u_short ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
* Definitions for IP type of service (ip_tos)
*/
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
/*
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
*/
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/*
* Definitions for options.
*/
#define IPOPT_COPIED(o) ((o)&0x80)
#define IPOPT_CLASS(o) ((o)&0x60)
#define IPOPT_NUMBER(o) ((o)&0x1f)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_DEBMEAS 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_EOL 0 /* end of option list */
#define IPOPT_NOP 1 /* no operation */
#define IPOPT_RR 7 /* record packet route */
#define IPOPT_TS 68 /* timestamp */
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
#define IPOPT_LSRR 131 /* loose source route */
#define IPOPT_SATID 136 /* satnet id */
#define IPOPT_SSRR 137 /* strict source route */
/*
* Offsets to fields in options other than EOL and NOP.
*/
#define IPOPT_OPTVAL 0 /* option ID */
#define IPOPT_OLEN 1 /* option length */
#define IPOPT_OFFSET 2 /* offset within option */
#define IPOPT_MINOFF 4 /* min value of above */
/*
* Time stamp option structure.
*/
struct ip_timestamp {
u_char ipt_code; /* IPOPT_TS */
u_char ipt_len; /* size of structure (variable) */
u_char ipt_ptr; /* index of current entry */
#if BYTE_ORDER == LITTLE_ENDIAN
u_char ipt_flg:4, /* flags, see below */
ipt_oflw:4; /* overflow counter */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char ipt_oflw:4, /* overflow counter */
ipt_flg:4; /* flags, see below */
#endif
union ipt_timestamp {
n_long ipt_time[1];
struct ipt_ta {
struct in_addr ipt_addr;
n_long ipt_time;
} ipt_ta[1];
} ipt_timestamp;
};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
/* bits for security (not byte swapped) */
#define IPOPT_SECUR_UNCLASS 0x0000
#define IPOPT_SECUR_CONFID 0xf135
#define IPOPT_SECUR_EFTO 0x789a
#define IPOPT_SECUR_MMMM 0xbc4d
#define IPOPT_SECUR_RESTR 0xaf13
#define IPOPT_SECUR_SECRET 0xd788
#define IPOPT_SECUR_TOPSECRET 0x6bc5
/*
* Internet implementation parameters.
*/
#define MAXTTL 255 /* maximum time to live (seconds) */
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
lft-3.35/include/netinet/ip_var.h 0000755 0000000 0000024 00000015652 11053131665 013665 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)ip_var.h 8.2 (Berkeley) 1/9/95
*/
#include
/*
* Overlay for ip header used by other protocols (tcp, udp).
*/
struct ipovly {
caddr_t ih_next, ih_prev; /* for protocol sequence q's */
u_char ih_x1; /* (unused) */
u_char ih_pr; /* protocol */
short ih_len; /* protocol length */
struct in_addr ih_src; /* source internet address */
struct in_addr ih_dst; /* destination internet address */
};
/*
* Ip reassembly queue structure. Each fragment
* being reassembled is attached to one of these structures.
* They are timed out after ipq_ttl drops to 0, and may also
* be reclaimed if memory becomes tight.
*/
struct ipq {
struct ipq *next,*prev; /* to other reass headers */
u_char ipq_ttl; /* time for reass q to live */
u_char ipq_p; /* protocol of this fragment */
u_short ipq_id; /* sequence id for reassembly */
struct ipasfrag *ipq_next,*ipq_prev;
/* to ip headers of fragments */
struct in_addr ipq_src,ipq_dst;
};
/*
* Ip header, when holding a fragment.
*
* Note: ipf_next must be at same offset as ipq_next above
*/
struct ipasfrag {
#if BYTE_ORDER == LITTLE_ENDIAN
u_char ip_hl:4,
ip_v:4;
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char ip_v:4,
ip_hl:4;
#endif
u_char ipf_mff; /* XXX overlays ip_tos: use low bit
* to avoid destroying tos;
* copied from (ip_off&IP_MF) */
short ip_len;
u_short ip_id;
short ip_off;
u_char ip_ttl;
u_char ip_p;
u_short ip_sum;
struct ipasfrag *ipf_next; /* next fragment */
struct ipasfrag *ipf_prev; /* previous fragment */
};
/*
* Structure stored in mbuf in inpcb.ip_options
* and passed to ip_output when ip options are in use.
* The actual length of the options (including ipopt_dst)
* is in m_len.
*/
#define MAX_IPOPTLEN 40
struct ipoption {
struct in_addr ipopt_dst; /* first-hop dst if source routed */
char ipopt_list[MAX_IPOPTLEN]; /* options proper */
};
struct ipstat {
u_long ips_total; /* total packets received */
u_long ips_badsum; /* checksum bad */
u_long ips_tooshort; /* packet too short */
u_long ips_toosmall; /* not enough data */
u_long ips_badhlen; /* ip header length < data size */
u_long ips_badlen; /* ip length < ip header length */
u_long ips_fragments; /* fragments received */
u_long ips_fragdropped; /* frags dropped (dups, out of space) */
u_long ips_fragtimeout; /* fragments timed out */
u_long ips_forward; /* packets forwarded */
u_long ips_cantforward; /* packets rcvd for unreachable dest */
u_long ips_redirectsent; /* packets forwarded on same net */
u_long ips_noproto; /* unknown or unsupported protocol */
u_long ips_delivered; /* datagrams delivered to upper level*/
u_long ips_localout; /* total ip packets generated here */
u_long ips_odropped; /* lost packets due to nobufs, etc. */
u_long ips_reassembled; /* total packets reassembled ok */
u_long ips_fragmented; /* datagrams sucessfully fragmented */
u_long ips_ofragments; /* output fragments created */
u_long ips_cantfrag; /* don't fragment flag was set, etc. */
u_long ips_badoptions; /* error in option processing */
u_long ips_noroute; /* packets discarded due to no route */
u_long ips_badvers; /* ip version != 4 */
u_long ips_rawout; /* total raw ip packets generated */
};
#ifdef KERNEL
/* flags passed to ip_output as last parameter */
#define IP_FORWARDING 0x1 /* most of ip header exists */
#define IP_RAWOUTPUT 0x2 /* raw ip header exists */
#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
struct ipstat ipstat;
struct ipq ipq; /* ip reass. queue */
u_short ip_id; /* ip packet ctr, for ids */
int ip_defttl; /* default IP ttl */
int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
void ip_deq __P((struct ipasfrag *));
int ip_dooptions __P((struct mbuf *));
void ip_drain __P((void));
void ip_enq __P((struct ipasfrag *, struct ipasfrag *));
void ip_forward __P((struct mbuf *, int));
void ip_freef __P((struct ipq *));
void ip_freemoptions __P((struct ip_moptions *));
int ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
void ip_init __P((void));
int ip_mforward __P((struct mbuf *, struct ifnet *));
int ip_optcopy __P((struct ip *, struct ip *));
int ip_output __P((struct mbuf *,
struct mbuf *, struct route *, int, struct ip_moptions *));
int ip_pcbopts __P((struct mbuf **, struct mbuf *));
struct ip *
ip_reass __P((struct ipasfrag *, struct ipq *));
struct in_ifaddr *
ip_rtaddr __P((struct in_addr));
int ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *));
void ip_slowtimo __P((void));
struct mbuf *
ip_srcroute __P((void));
void ip_stripoptions __P((struct mbuf *, struct mbuf *));
int ip_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
void ipintr __P((void));
int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
void rip_init __P((void));
void rip_input __P((struct mbuf *));
int rip_output __P((struct mbuf *, struct socket *, u_long));
int rip_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
#endif
lft-3.35/include/netinet/tcp.h 0000755 0000000 0000024 00000007154 11053131665 013171 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)tcp.h 8.1 (Berkeley) 6/10/93
*/
typedef u_long tcp_seq;
/*
* TCP header.
* Per RFC 793, September, 1981.
*/
struct tcphdr {
u_short th_sport; /* source port */
u_short th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
#if BYTE_ORDER == LITTLE_ENDIAN
u_char th_x2:4, /* (unused) */
th_off:4; /* data offset */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_char th_off:4, /* data offset */
th_x2:4; /* (unused) */
#endif
u_char th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
u_short th_win; /* window */
u_short th_sum; /* checksum */
u_short th_urp; /* urgent pointer */
};
#define TCPOPT_EOL 0
#define TCPOPT_NOP 1
#define TCPOPT_MAXSEG 2
#define TCPOLEN_MAXSEG 4
#define TCPOPT_WINDOW 3
#define TCPOLEN_WINDOW 3
#define TCPOPT_SACK_PERMITTED 4 /* Experimental */
#define TCPOLEN_SACK_PERMITTED 2
#define TCPOPT_SACK 5 /* Experimental */
#define TCPOPT_TIMESTAMP 8
#define TCPOLEN_TIMESTAMP 10
#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
#define TCPOPT_TSTAMP_HDR \
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
/*
* Default maximum segment size for TCP.
* With an IP MSS of 576, this is 536,
* but 512 is probably more convenient.
* This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
*/
#define TCP_MSS 512
#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */
#define TCP_MAX_WINSHIFT 14 /* maximum window shift */
/*
* User-settable options (used with setsockopt).
*/
#ifndef TCP_NODELAY
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
#endif
#ifndef TCP_MAXSEG
#define TCP_MAXSEG 0x02 /* set maximum segment size */
#endif
lft-3.35/include/netinet/udp.h 0000755 0000000 0000024 00000004101 11053131665 013160 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)udp.h 8.1 (Berkeley) 6/10/93
*/
/*
* Udp protocol header.
* Per RFC 768, September, 1981.
*/
struct udphdr {
u_short uh_sport; /* source port */
u_short uh_dport; /* destination port */
short uh_ulen; /* udp length */
u_short uh_sum; /* udp checksum */
};
lft-3.35/include/netinet/udp_var.h 0000755 0000000 0000024 00000006774 11053131665 014052 0000000 0000000 /*
* Copyright (c) 1982, 1986, 1989, 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.
*
* @(#)udp_var.h 8.1 (Berkeley) 6/10/93
*/
/*
* UDP kernel structures and variables.
*/
struct udpiphdr {
struct ipovly ui_i; /* overlaid ip structure */
struct udphdr ui_u; /* udp header */
};
#define ui_next ui_i.ih_next
#define ui_prev ui_i.ih_prev
#define ui_x1 ui_i.ih_x1
#define ui_pr ui_i.ih_pr
#define ui_len ui_i.ih_len
#define ui_src ui_i.ih_src
#define ui_dst ui_i.ih_dst
#define ui_sport ui_u.uh_sport
#define ui_dport ui_u.uh_dport
#define ui_ulen ui_u.uh_ulen
#define ui_sum ui_u.uh_sum
struct udpstat {
/* input statistics: */
u_long udps_ipackets; /* total input packets */
u_long udps_hdrops; /* packet shorter than header */
u_long udps_badsum; /* checksum error */
u_long udps_badlen; /* data length larger than packet */
u_long udps_noport; /* no socket on port */
u_long udps_noportbcast; /* of above, arrived as broadcast */
u_long udps_fullsock; /* not delivered, input socket full */
u_long udpps_pcbcachemiss; /* input packets missing pcb cache */
/* output statistics: */
u_long udps_opackets; /* total output packets */
};
/*
* Names for UDP sysctl objects
*/
#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */
#define UDPCTL_MAXID 2
#define UDPCTL_NAMES { \
{ 0, 0 }, \
{ "checksum", CTLTYPE_INT }, \
}
#ifdef KERNEL
struct inpcb udb;
struct udpstat udpstat;
void udp_ctlinput __P((int, struct sockaddr *, struct ip *));
void udp_init __P((void));
void udp_input __P((struct mbuf *, int));
int udp_output __P((struct inpcb *,
struct mbuf *, struct mbuf *, struct mbuf *));
int udp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
int udp_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
#endif
lft-3.35/include/netinet/tcpip.h 0000755 0000000 0000024 00000004734 11053131665 013523 0000000 0000000 /*
* Copyright (c) 1982, 1986, 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.
*
* @(#)tcpip.h 8.1 (Berkeley) 6/10/93
*/
/*
* Tcp+ip header, after ip options removed.
*/
struct tcpiphdr {
struct ipovly ti_i; /* overlaid ip structure */
struct tcphdr ti_t; /* tcp header */
};
#define ti_next ti_i.ih_next
#define ti_prev ti_i.ih_prev
#define ti_x1 ti_i.ih_x1
#define ti_pr ti_i.ih_pr
#define ti_len ti_i.ih_len
#define ti_src ti_i.ih_src
#define ti_dst ti_i.ih_dst
#define ti_sport ti_t.th_sport
#define ti_dport ti_t.th_dport
#define ti_seq ti_t.th_seq
#define ti_ack ti_t.th_ack
#define ti_x2 ti_t.th_x2
#define ti_off ti_t.th_off
#define ti_flags ti_t.th_flags
#define ti_win ti_t.th_win
#define ti_sum ti_t.th_sum
#define ti_urp ti_t.th_urp
lft-3.35/include/net/ 0000755 0000000 0000024 00000000000 12055664006 011423 5 0000000 0000000 lft-3.35/include/net/if_arp.h 0000755 0000000 0000024 00000015037 11053131665 012762 0000000 0000000 /* Definitions for Address Resolution Protocol.
Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper , 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* Based on the 4.4BSD and Linux version of this file. */
#ifndef _NET_IF_ARP_H
#define _NET_IF_ARP_H 1
/* Some internals from deep down in the kernel. */
#define MAX_ADDR_LEN 7
/* This structure defines an ethernet arp header. */
/* ARP protocol opcodes. */
#define ARPOP_REQUEST 1 /* ARP request. */
#define ARPOP_REPLY 2 /* ARP reply. */
#define ARPOP_RREQUEST 3 /* RARP request. */
#define ARPOP_RREPLY 4 /* RARP reply. */
#define ARPOP_InREQUEST 8 /* InARP request. */
#define ARPOP_InREPLY 9 /* InARP reply. */
#define ARPOP_NAK 10 /* (ATM)ARP NAK. */
/* See RFC 826 for protocol description. ARP packets are variable
in size; the arphdr structure defines the fixed-length portion.
Protocol type values are the same as those for 10 Mb/s Ethernet.
It is followed by the variable-sized fields ar_sha, arp_spa,
arp_tha and arp_tpa in that order, according to the lengths
specified. Field names used correspond to RFC 826. */
struct arphdr
{
unsigned short int ar_hrd; /* Format of hardware address. */
unsigned short int ar_pro; /* Format of protocol address. */
unsigned char ar_hln; /* Length of hardware address. */
unsigned char ar_pln; /* Length of protocol address. */
unsigned short int ar_op; /* ARP opcode (command). */
#if 0
/* Ethernet looks like this : This bit is variable sized
however... */
unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */
unsigned char __ar_sip[4]; /* Sender IP address. */
unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */
unsigned char __ar_tip[4]; /* Target IP address. */
#endif
};
/* ARP protocol HARDWARE identifiers. */
#define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */
#define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */
#define ARPHRD_EETHER 2 /* Experimental Ethernet. */
#define ARPHRD_AX25 3 /* AX.25 Level 2. */
#define ARPHRD_PRONET 4 /* PROnet token ring. */
#define ARPHRD_CHAOS 5 /* Chaosnet. */
#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */
#define ARPHRD_ARCNET 7 /* ARCnet. */
#define ARPHRD_APPLETLK 8 /* APPLEtalk. */
#define ARPHRD_DLCI 15 /* Frame Relay DLCI. */
#define ARPHRD_ATM 19 /* ATM. */
#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */
/* Dummy types for non ARP hardware */
#define ARPHRD_SLIP 256
#define ARPHRD_CSLIP 257
#define ARPHRD_SLIP6 258
#define ARPHRD_CSLIP6 259
#define ARPHRD_RSRVD 260 /* Notional KISS type. */
#define ARPHRD_ADAPT 264
#define ARPHRD_ROSE 270
#define ARPHRD_X25 271 /* CCITT X.25. */
#define ARPHDR_HWX25 272 /* Boards with X.25 in firmware. */
#define ARPHRD_PPP 512
#define ARPHRD_CISCO 513 /* Cisco HDLC. */
#define ARPHRD_HDLC ARPHRD_CISCO
#define ARPHRD_LAPB 516 /* LAPB. */
#define ARPHRD_DDCMP 517 /* Digital's DDCMP. */
#define ARPHRD_RAWHDLC 518 /* Raw HDLC. */
#define ARPHRD_TUNNEL 768 /* IPIP tunnel. */
#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */
#define ARPHRD_FRAD 770 /* Frame Relay Access Device. */
#define ARPHRD_SKIP 771 /* SKIP vif. */
#define ARPHRD_LOOPBACK 772 /* Loopback device. */
#define ARPHRD_LOCALTLK 773 /* Localtalk device. */
#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */
#define ARPHRD_BIF 775 /* AP1000 BIF. */
#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */
#define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */
#define ARPHRD_IPGRE 778 /* GRE over IP. */
#define ARPHRD_PIMREG 779 /* PIMSM register interface. */
#define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */
#define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */
#define ARPHRD_ECONET 782 /* Acorn Econet. */
#define ARPHRD_IRDA 783 /* Linux-IrDA. */
#define ARPHRD_FCPP 784 /* Point to point fibrechanel. */
#define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */
#define ARPHRD_FCPL 786 /* Fibrechanel public loop. */
#define ARPHRD_FCPFABRIC 787 /* Fibrechanel fabric. */
#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
#define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
/* ARP ioctl request. */
struct arpreq
{
struct sockaddr arp_pa; /* Protocol address. */
struct sockaddr arp_ha; /* Hardware address. */
int arp_flags; /* Flags. */
struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
char arp_dev[16];
};
struct arpreq_old
{
struct sockaddr arp_pa; /* Protocol address. */
struct sockaddr arp_ha; /* Hardware address. */
int arp_flags; /* Flags. */
struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */
};
/* ARP Flag values. */
#define ATF_COM 0x02 /* Completed entry (ha valid). */
#define ATF_PERM 0x04 /* Permanent entry. */
#define ATF_PUBL 0x08 /* Publish entry. */
#define ATF_USETRAILERS 0x10 /* Has requested trailers. */
#define ATF_NETMASK 0x20 /* Want to use a netmask (only
for proxy entries). */
#define ATF_DONTPUB 0x40 /* Don't answer this addresses. */
#define ATF_MAGIC 0x80 /* Automatically added entry. */
/* Support for the user space arp daemon, arpd. */
#define ARPD_UPDATE 0x01
#define ARPD_LOOKUP 0x02
#define ARPD_FLUSH 0x03
struct arpd_request
{
unsigned short int req; /* Request type. */
u_int32_t ip; /* IP address of entry. */
unsigned long int dev; /* Device entry is tied to. */
unsigned long int stamp;
unsigned long int updated;
unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */
};
#endif /* net/if_arp.h */
lft-3.35/include/net/slcompress.h 0000755 0000000 0000024 00000013166 11053131665 013715 0000000 0000000 /*
* Definitions for tcp compression routines.
*
* Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of
* California. All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Van Jacobson (van@ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*/
#define MAX_STATES 16 /* must be > 2 and < 256 */
#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */
/*
* Compressed packet format:
*
* The first octet contains the packet type (top 3 bits), TCP
* 'push' bit, and flags that indicate which of the 4 TCP sequence
* numbers have changed (bottom 5 bits). The next octet is a
* conversation number that associates a saved IP/TCP header with
* the compressed packet. The next two octets are the TCP checksum
* from the original datagram. The next 0 to 15 octets are
* sequence number changes, one change per bit set in the header
* (there may be no changes and there are two special cases where
* the receiver implicitly knows what changed -- see below).
*
* There are 5 numbers which can change (they are always inserted
* in the following order): TCP urgent pointer, window,
* acknowlegement, sequence number and IP ID. (The urgent pointer
* is different from the others in that its value is sent, not the
* change in value.) Since typical use of SLIP links is biased
* toward small packets (see comments on MTU/MSS below), changes
* use a variable length coding with one octet for numbers in the
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
* range 256 - 65535 or 0. (If the change in sequence number or
* ack is more than 65535, an uncompressed packet is sent.)
*/
/*
* Packet types (must not conflict with IP protocol version)
*
* The top nibble of the first octet is the packet type. There are
* three possible types: IP (not proto TCP or tcp with one of the
* control flags set); uncompressed TCP (a normal IP/TCP packet but
* with the 8-bit protocol field replaced by an 8-bit connection id --
* this type of packet syncs the sender & receiver); and compressed
* TCP (described above).
*
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
* is logically part of the 4-bit "changes" field that follows. Top
* three bits are actual packet type. For backward compatibility
* and in the interest of conserving bits, numbers are chosen so the
* IP protocol version number (4) which normally appears in this nibble
* means "IP packet".
*/
/* packet types */
#define TYPE_IP 0x40
#define TYPE_UNCOMPRESSED_TCP 0x70
#define TYPE_COMPRESSED_TCP 0x80
#define TYPE_ERROR 0x00
/* Bits in first octet of compressed packet */
#define NEW_C 0x40 /* flag bits for what changed in a packet */
#define NEW_I 0x20
#define NEW_S 0x08
#define NEW_A 0x04
#define NEW_W 0x02
#define NEW_U 0x01
/* reserved, special-case values of above */
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
#define TCP_PUSH_BIT 0x10
/*
* "state" data for each active tcp conversation on the wire. This is
* basically a copy of the entire IP/TCP header from the last packet
* we saw from the conversation together with a small identifier
* the transmit & receive ends of the line use to locate saved header.
*/
struct cstate {
struct cstate *cs_next; /* next most recently used cstate (xmit only) */
u_short cs_hlen; /* size of hdr (receive only) */
u_char cs_id; /* connection # associated with this state */
u_char cs_filler;
union {
char csu_hdr[MAX_HDR];
struct ip csu_ip; /* ip/tcp hdr from most recent packet */
} slcs_u;
};
#define cs_ip slcs_u.csu_ip
#define cs_hdr slcs_u.csu_hdr
/*
* all the state data for one serial line (we need one of these
* per line).
*/
struct slcompress {
struct cstate *last_cs; /* most recently used tstate */
u_char last_recv; /* last rcvd conn. id */
u_char last_xmit; /* last sent conn. id */
u_short flags;
#ifndef SL_NO_STATS
u_int sls_packets; /* outbound packets */
u_int sls_compressed; /* outbound compressed packets */
u_int sls_searches; /* searches for connection state */
u_int sls_misses; /* times couldn't find conn. state */
u_int sls_uncompressedin;/* inbound uncompressed packets */
u_int sls_compressedin; /* inbound compressed packets */
u_int sls_errorin; /* inbound unknown type packets */
u_int sls_tossed; /* inbound packets tossed because of error */
#endif
struct cstate tstate[MAX_STATES]; /* xmit connection states */
struct cstate rstate[MAX_STATES]; /* receive connection states */
};
/* flag values */
#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
#ifdef KERNEL
#ifdef __STDC__
extern void sl_compress_init(struct slcompress *);
extern u_char sl_compress_tcp(struct mbuf *, struct ip *, struct slcompress *);
extern int sl_uncompress_tcp(struct mbuf *, int, u_int, struct slcompress *);
#else
extern void sl_compress_init();
extern u_char sl_compress_tcp();
extern int sl_uncompress_tcp();
#endif
#endif
lft-3.35/include/net/slip.h 0000755 0000000 0000024 00000002632 11053131665 012466 0000000 0000000 /*
* Definitions that user level programs might need to know to interact
* with serial line IP (slip) lines.
*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* ioctl to get slip interface unit number (e.g., sl0, sl1, etc.)
* assigned to some terminal line with a slip module pushed on it.
*/
#ifdef __STDC__
#define SLIOGUNIT _IOR('B', 1, int)
#else
#define SLIOGUNIT _IOR(B, 1, int)
#endif
/*
* definitions of the pseudo- link-level header attached to slip
* packets grabbed by the packet filter (bpf) traffic monitor.
*/
#define SLIP_HDRLEN 16
#define SLX_DIR 0
#define SLX_CHDR 1
#define CHDR_LEN 15
#define SLIPDIR_IN 0
#define SLIPDIR_OUT 1
lft-3.35/include/libpcap/ 0000755 0000000 0000024 00000000000 12055664006 012247 5 0000000 0000000 lft-3.35/include/libpcap/Gnuc.h 0000755 0000000 0000024 00000001417 11053131665 013237 0000000 0000000 /* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002/08/01 08:33:05 risso Exp $ (LBL) */
/* Define __P() macro, if necessary */
#ifndef __P
#if __STDC__
#define __P(protos) protos
#else
#define __P(protos) ()
#endif
#endif
/* inline foo */
#ifndef __cplusplus
#ifdef __GNUC__
#define inline __inline
#else
#define inline
#endif
#endif
/*
* Handle new and old "dead" routine prototypes
*
* For example:
*
* __dead void foo(void) __attribute__((volatile));
*
*/
#ifdef __GNUC__
#ifndef __dead
#define __dead volatile
#endif
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
#ifndef __attribute__
#define __attribute__(args)
#endif
#endif
#else
#ifndef __dead
#define __dead
#endif
#ifndef __attribute__
#define __attribute__(args)
#endif
#endif
lft-3.35/include/libpcap/bittypes.h 0000755 0000000 0000024 00000007445 11053131665 014215 0000000 0000000 /*
* Copyright (C) 1999 WIDE Project.
* 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
*/
#ifndef _BITTYPES_H
#define _BITTYPES_H
#ifndef HAVE_U_INT8_T
#if SIZEOF_CHAR == 1
typedef unsigned char u_int8_t;
typedef signed char int8_t;
#elif SIZEOF_INT == 1
typedef unsigned int u_int8_t;
typedef signed int int8_t;
#else /* XXX */
#error "there's no appropriate type for u_int8_t"
#endif
#define HAVE_U_INT8_T 1
#define HAVE_INT8_T 1
#endif /* HAVE_U_INT8_T */
#ifndef HAVE_U_INT16_T
#if SIZEOF_SHORT == 2
typedef unsigned short u_int16_t;
typedef signed short int16_t;
#elif SIZEOF_INT == 2
typedef unsigned int u_int16_t;
typedef signed int int16_t;
#elif SIZEOF_CHAR == 2
typedef unsigned char u_int16_t;
typedef signed char int16_t;
#else /* XXX */
#error "there's no appropriate type for u_int16_t"
#endif
#define HAVE_U_INT16_T 1
#define HAVE_INT16_T 1
#endif /* HAVE_U_INT16_T */
#ifndef HAVE_U_INT32_T
#if SIZEOF_INT == 4
typedef unsigned int u_int32_t;
typedef signed int int32_t;
#elif SIZEOF_LONG == 4
typedef unsigned long u_int32_t;
typedef signed long int32_t;
#elif SIZEOF_SHORT == 4
typedef unsigned short u_int32_t;
typedef signed short int32_t;
#else /* XXX */
#error "there's no appropriate type for u_int32_t"
#endif
#define HAVE_U_INT32_T 1
#define HAVE_INT32_T 1
#endif /* HAVE_U_INT32_T */
#ifndef HAVE_U_INT64_T
#if SIZEOF_LONG_LONG == 8
typedef unsigned long long u_int64_t;
#elif defined(_MSC_EXTENSIONS)
typedef unsigned _int64 u_int64_t;
#elif SIZEOF_INT == 8
typedef unsigned int u_int64_t;
#elif SIZEOF_LONG == 8
typedef unsigned long u_int64_t;
#elif SIZEOF_SHORT == 8
typedef unsigned short u_int64_t;
#else /* XXX */
#error "there's no appropriate type for u_int64_t"
#endif
#endif /* HAVE_U_INT64_T */
#ifndef PRId64
#ifdef _MSC_EXTENSIONS
#define PRId64 "I64d"
#else /* _MSC_EXTENSIONS */
#define PRId64 "lld"
#endif /* _MSC_EXTENSIONS */
#endif /* PRId64 */
#ifndef PRIo64
#ifdef _MSC_EXTENSIONS
#define PRIo64 "I64o"
#else /* _MSC_EXTENSIONS */
#define PRIo64 "llo"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIo64 */
#ifndef PRIx64
#ifdef _MSC_EXTENSIONS
#define PRIx64 "I64x"
#else /* _MSC_EXTENSIONS */
#define PRIx64 "llx"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIx64 */
#ifndef PRIu64
#ifdef _MSC_EXTENSIONS
#define PRIu64 "I64u"
#else /* _MSC_EXTENSIONS */
#define PRIu64 "llu"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIu64 */
#endif /* _BITTYPES_H */
lft-3.35/whob 0000755 0000000 0000000 00000222675 12055644132 010025 0000000 0000000 ELF ðŒ4 ´
4 ( &