ttt-1.7.orig/0040755000273700007640000000000007645011436011755 5ustar scheffedvttt-1.7.orig/display.c0100644000273700007640000001572507220141160013560 0ustar scheffedv/* $Id: display.c,v 0.4 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* display.c -- drawing graphs */ #include #include #include #include "ttt.h" #include "ttt_tk.h" #include "ttt_node.h" #include "ttt_account.h" #include "ttt_window.h" /* get NUM_RANKS entries at each interval and show NUM_GRAPHS entries */ #define NUM_GRAPHS 6 #define NUM_RANKS 10 /* * tcl variables: we assume the following tcl variables are defined * in ttt.tcl. * * vector X, P0-P5, H0-H5: floating arrays to keep graph values. * .graph, .graph2: graph objects * p0-p5, h0-h5: graph elements for .graph and .graph2 */ #if (BLT_MAJOR_VERSION == 2) && (BLT_MINOR_VERSION == 1) static Blt_Vector X, Protos[NUM_GRAPHS], Hosts[NUM_GRAPHS]; #else /* blt2.3 */ static Blt_Vector *X, *Protos[NUM_GRAPHS], *Hosts[NUM_GRAPHS]; static double Xarr[WG_WIN_SIZE]; static double Parr[NUM_GRAPHS][WG_WIN_SIZE], Harr[NUM_GRAPHS][WG_WIN_SIZE]; #endif /* blt2.3 */ static struct wg_entry *proto_ranking[NUM_RANKS], *proto_oldranking[NUM_RANKS]; static struct wg_entry *host_ranking[NUM_RANKS], *host_oldranking[NUM_RANKS]; void display_init(void) { int i; char buf[16]; #if (BLT_MAJOR_VERSION == 2) && (BLT_MINOR_VERSION == 1) /* allocate space for the vectors */ X.arraySize = WG_WIN_SIZE; X.valueArr = (double *)malloc(sizeof(double) * WG_WIN_SIZE); for (i=0; i= WG_WIN_SIZE) { for (i=0; i < WG_WIN_SIZE-1; i++) #if (BLT_MAJOR_VERSION == 2) && (BLT_MINOR_VERSION == 1) X.valueArr[i] = X.valueArr[i+1]; #else Xarr[i] = Xarr[i+1]; #endif n = WG_WIN_SIZE - 1; } else n = time_tick; /* get the top 10 traffic of this interval. */ stat_record(TTTTYPE_PROTO, NUM_RANKS); stat_record(TTTTYPE_HOST, NUM_RANKS); /* next, get the top 10 traffic of the time window. */ protos = stat_ranking(TTTTYPE_IP, proto_ranking, NUM_GRAPHS); hosts = stat_ranking(TTTTYPE_HOST, host_ranking, NUM_GRAPHS); cur_time = get_timeindouble(); #if (BLT_MAJOR_VERSION == 2) && (BLT_MINOR_VERSION == 1) X.numValues = n; X.valueArr[n] = cur_time; if (Blt_ResetVector(ttt_interp, "X", &X, TCL_DYNAMIC) != TCL_OK) { printf("ResetVector: error\n"); } #else /* blt2.3 */ Xarr[n] = cur_time; if (Blt_ResetVector(X, Xarr, n, WG_WIN_SIZE, TCL_STATIC) != TCL_OK) { printf("ResetVector: error\n"); } #endif /* blt2.3 */ /* draw each graph. data values are stored in the ring buffer of wg_entries. */ interval = cur_time - last_time; for (i=0; iwg_name, wgp->wg_color); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) printf("display: %s\n", ttt_interp->result); } stat_update(host_ranking, host_oldranking, update_list, hosts); for (i=0; iwg_name, wgp->wg_color); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) printf("display: %s\n", ttt_interp->result); } /* get pcap stats */ if (get_pcapstat(&recvpkts, &droppkts, &lostpkts) == 0) ttt_showstat(recvpkts, droppkts, lostpkts); for (i=0; i #include "ttt.h" #include "ttt_node.h" #include "ttt_account.h" static struct t_node *eth_root, *ip_root, *udp_root, *tcp_root, *host_root; #ifdef IPV6 static struct t_node *ip6_root, *udp6_root, *tcp6_root, *host6_root; #endif void netacc_init(void) { node_init(); eth_root = node_createroot(TTTTYPE_ETHER); ip_root = node_createroot(TTTTYPE_IP); udp_root = node_createroot(TTTTYPE_UDP); tcp_root = node_createroot(TTTTYPE_TCP); host_root = node_createroot(TTTTYPE_IPHOST); #ifdef IPV6 ip6_root = node_createroot(TTTTYPE_IPV6); udp6_root = node_createroot(TTTTYPE_UDPV6); tcp6_root = node_createroot(TTTTYPE_TCPV6); host6_root = node_createroot(TTTTYPE_IPV6HOST); #endif } void netacc_cleanup(void) { node_cleanup(); node_destroyroot(eth_root); node_destroyroot(ip_root); node_destroyroot(udp_root); node_destroyroot(tcp_root); node_destroyroot(host_root); #ifdef IPV6 node_destroyroot(ip6_root); node_destroyroot(udp6_root); node_destroyroot(tcp6_root); node_destroyroot(host6_root); #endif } int eth_addsize(int etype, int pkt_len) { struct t_node *np; long id[4]; id[0] = etype; #ifdef IPV6 id[1] = id[2] = id[3] = 0; #endif np = node_findnode(eth_root, TTTTYPE_ETHER, id); return node_addsize(np, pkt_len); } int ip_addsize(int proto, int pkt_len) { struct t_node *np; long id[4]; id[0] = proto; #ifdef IPV6 id[1] = id[2] = id[3] = 0; #endif np = node_findnode(ip_root, TTTTYPE_IP, id); return node_addsize(np, pkt_len); } int udp_addsize(int port, int pkt_len) { struct t_node *np; long id[4]; id[0] = port; #ifdef IPV6 id[1] = id[2] = id[3] = 0; #endif np = node_findnode(udp_root, TTTTYPE_UDP, id); return node_addsize(np, pkt_len); } int tcp_addsize(int port, int pkt_len) { struct t_node *np; long id[4]; id[0] = port; #ifdef IPV6 id[1] = id[2] = id[3] = 0; #endif np = node_findnode(tcp_root, TTTTYPE_TCP, id); return node_addsize(np, pkt_len); } int host_addsize(u_long addr, int pkt_len) { struct t_node *np; u_long id[4]; id[0] = addr; #ifdef IPV6 id[1] = id[2] = id[3] = 0; #endif np = node_findnode(host_root, TTTTYPE_IPHOST, id); return node_addsize(np, pkt_len); } #ifdef IPV6 int ipv6_addsize(int proto, int pkt_len) { struct t_node *np; long id[4]; id[0] = proto; id[1] = id[2] = id[3] = 0; np = node_findnode(ip6_root, TTTTYPE_IPV6, id); return node_addsize(np, pkt_len); } int udpv6_addsize(int port, int pkt_len) { struct t_node *np; long id[4]; id[0] = port; id[1] = id[2] = id[3] = 0; np = node_findnode(udp6_root, TTTTYPE_UDPV6, id); return node_addsize(np, pkt_len); } int tcpv6_addsize(int port, int pkt_len) { struct t_node *np; long id[4]; id[0] = port; id[1] = id[2] = id[3] = 0; np = node_findnode(tcp6_root, TTTTYPE_TCPV6, id); return node_addsize(np, pkt_len); } int hostv6_addsize(u_long *addr, int pkt_len) { struct t_node *np; np = node_findnode(host6_root, TTTTYPE_IPV6HOST, addr); return node_addsize(np, pkt_len); } #endif /* IPV6 */ ttt-1.7.orig/bsd_sys_queue.h0100644000273700007640000003434107220141155014771 0ustar scheffedv/* * 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 * $Id: bsd_sys_queue.h,v 1.1 1997/08/17 08:52:43 kjc Exp $ */ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ /* * This file defines five types of data structures: singly-linked lists, * slingly-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 only be traversed in the forward 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. */ /* * Singly-linked List definitions. */ #define SLIST_HEAD(name, type) \ struct name { \ struct type *slh_first; /* first element */ \ } #define SLIST_ENTRY(type) \ struct { \ struct type *sle_next; /* next element */ \ } /* * Singly-linked List functions. */ #define SLIST_INIT(head) { \ (head)->slh_first = NULL; \ } #define SLIST_INSERT_AFTER(slistelm, elm, field) { \ (elm)->field.sle_next = (slistelm)->field.sle_next; \ (slistelm)->field.sle_next = (elm); \ } #define SLIST_INSERT_HEAD(head, elm, field) { \ (elm)->field.sle_next = (head)->slh_first; \ (head)->slh_first = (elm); \ } #define SLIST_REMOVE_HEAD(head, field) { \ (head)->slh_first = (head)->slh_first->field.sle_next; \ } #define SLIST_REMOVE(head, elm, type, field) { \ 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; \ } \ } /* * 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_ENTRY(type) \ struct { \ struct type *stqe_next; /* next element */ \ } /* * Singly-linked Tail queue functions. */ #define STAILQ_INIT(head) { \ (head)->stqh_first = NULL; \ (head)->stqh_last = &(head)->stqh_first; \ } #define STAILQ_INSERT_HEAD(head, elm, field) { \ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ (head)->stqh_last = &(elm)->field.stqe_next; \ (head)->stqh_first = (elm); \ } #define STAILQ_INSERT_TAIL(head, elm, field) { \ (elm)->field.stqe_next = NULL; \ *(head)->stqh_last = (elm); \ (head)->stqh_last = &(elm)->field.stqe_next; \ } #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) { \ if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\ (head)->stqh_last = &(elm)->field.stqe_next; \ (tqelm)->field.stqe_next = (elm); \ } #define STAILQ_REMOVE_HEAD(head, field) { \ if (((head)->stqh_first = \ (head)->stqh_first->field.stqe_next) == NULL) \ (head)->stqh_last = &(head)->stqh_first; \ } #define STAILQ_REMOVE(head, elm, type, field) { \ 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; \ } \ } /* * List definitions. */ #define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } #define LIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } /* * List functions. */ #define LIST_INIT(head) { \ (head)->lh_first = NULL; \ } #define LIST_INSERT_AFTER(listelm, elm, field) { \ 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; \ } #define LIST_INSERT_BEFORE(listelm, elm, field) { \ (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; \ } #define LIST_INSERT_HEAD(head, elm, field) { \ 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; \ } #define LIST_REMOVE(elm, field) { \ 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; \ } /* * 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_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_FIRST(head) ((head)->tqh_first) #define TAILQ_LAST(head) ((head)->tqh_last) #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define TAILQ_PREV(elm, field) ((elm)->field.tqe_prev) #define TAILQ_INIT(head) { \ (head)->tqh_first = NULL; \ (head)->tqh_last = &(head)->tqh_first; \ } #define TAILQ_INSERT_HEAD(head, elm, field) { \ 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; \ } #define TAILQ_INSERT_TAIL(head, elm, field) { \ (elm)->field.tqe_next = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &(elm)->field.tqe_next; \ } #define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \ 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; \ } #define TAILQ_INSERT_BEFORE(listelm, elm, field) { \ (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; \ } #define TAILQ_REMOVE(head, elm, field) { \ 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; \ } /* * 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_INIT(head) { \ (head)->cqh_first = (void *)(head); \ (head)->cqh_last = (void *)(head); \ } #define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \ (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); \ } #define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \ (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); \ } #define CIRCLEQ_INSERT_HEAD(head, elm, field) { \ (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); \ } #define CIRCLEQ_INSERT_TAIL(head, elm, field) { \ (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); \ } #define CIRCLEQ_REMOVE(head, elm, field) { \ 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; \ } #ifdef KERNEL /* * XXX insque() and remque() are an old way of handling certain queues. * They bogusly assumes that all queue heads look alike. */ struct quehead { struct quehead *qh_link; struct quehead *qh_rlink; }; #ifdef __GNUC__ static __inline void insque(void *a, void *b) { struct quehead *element = a, *head = b; element->qh_link = head->qh_link; element->qh_rlink = head; head->qh_link = element; element->qh_link->qh_rlink = element; } static __inline void remque(void *a) { struct quehead *element = a; element->qh_link->qh_rlink = element->qh_rlink; element->qh_rlink->qh_link = element->qh_link; element->qh_rlink = 0; } #else /* !__GNUC__ */ void insque __P((void *a, void *b)); void remque __P((void *a)); #endif /* __GNUC__ */ #endif /* KERNEL */ #endif /* !_SYS_QUEUE_H_ */ ttt-1.7.orig/common.c0100644000273700007640000000363607220141157013407 0ustar scheffedv/* $Id: common.c,v 0.5 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* common.c -- globals and routines common to all ttt programs. */ #include #include #include #include #include "ttt.h" #ifndef NULL #define NULL 0 #endif char *ttt_version = TTT_VERSION; /* globals which can set by tcl */ int ttt_interval = 1000; /* 1 sec interval to update graph */ int ttt_nohostname = 0; /* don't lookup host names */ int ttt_filter = 0; /* trace filter */ /* only used at startup */ char *ttt_interface = NULL; /* interface name for packet capturing */ char *ttt_dumpfile = NULL; /* tcpdump file to replay */ int ttt_speed = 1; /* replay speed */ struct timeval ttt_dumptime; char *ttt_viewname = NULL; char *ttt_mcastif = NULL; int ttt_portno = TTT_PORT; /* receiver's port number */ int ttt_yscale = 1000000; /* scale of y axis (Mbps by default) */ #include #include #include void fatal_error(va_alist) va_dcl { va_list ap; char *fmt; if (errno != 0) perror("fatal_error"); else fprintf(stderr, "fatal_error: "); va_start(ap); fmt = va_arg(ap, char *); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); exit(1); } ttt-1.7.orig/bitmaps/0040755000273700007640000000000006153531357013416 5ustar scheffedvttt-1.7.orig/bitmaps/rain.gif0100644000273700007640000000731106153522035015026 0ustar scheffedvGIF87allwwf?,ll@P) yVp1vee`NUv@簸(dYby5g|& [/(5#2]֢јNP~@||D|}Q6EN~T^x2;"04opA[uZ\;:jeS>LCTxs6Vf %WG=8Z%jL:FJ5XIP6YJ^OQEUQU:@gdSަZрJkj2рp DYW'ֈè B HFlcvw,( }ca/8F*ar6 kN0k9F~apւ7(D 1.Mq vᓏZ lm7, 9ԩr>."A"ͥYAbF:o}W$#G<?l?&xC2cX`c^*栊YdEn7p1~~pdJפ1xD{, )QYQ1YR"HH)R1*7z"*% Bd)yR]!]cD,dOb"*QtZ%%g5Ƃ}K@*IXKMuUs,/TOr'LP4GtZ_x]`[AM$76PQ"\UE=D.h x!6XKŒ{[=S)df QB7Ձf5XhF-(X .ÂY~=/73jI8NBbXwK/N I))Y O#GKwI@8%cveX9aY`F$aP%CZKy#SDJT 3 :3% 9[زFqJP4 :hqC"qPD 6rlQCHfKd,',gQDM:֌ٱ <`2@KM5&/ja)' 2D!xC F R+4ȉ4B@%2DiPH :a ٕY'M:6ЂkN  Cg>74"A؄4>|jbq¬Рp"M @Ć 2s#(a82 &q*nD 4cS:TlڱXm"&kX% oX$-(x*]L< }^UIdB e x )!വD 5F> -L 9XQ6M2;vD,9$(psLC-GĞ 'Xl/ e8{rD(L;:4 f4;5 pFD2$$)Hh2p)4H(1'[GWqMa4(LS&e"rXæB  G8Cv&`T(R>4C8D@1/-_jLg.5ƒcl_GB/j!iDd06-Gj HOK1[`@F FlnT:{'J8 .pA:P 1ĩ  :%kp3%Dn ]H fح-E;h(>ˆ́64 eE'` `Ԁ'6V@F  ָ @IIL@F*p PC BI hD#D`91c)kۗH@yaRpTbl:PCZLjUsnX$ Hp[#h--xkbD|_i(~!mAy3D>Rm:XW`Z^ TK$`Ԡ~9h] BAg&p9q4ti :``|3[d $p,8A؂=%< x`^$!G ZM]F3W/,69"  ;ҀIny .GI͉2ѕ B@uOrqQV5z(e<O`.Ly>r09p`tEB@ a6E#a:f|`s"A07(2йbQ ¡ah0'ZCb80zT@5С__2xo#m&މx. )eqVjd\S!H-V"D:VY Hn" P23b |f' Wp-fqGu(>X/N&(7aZaŰz f 4JyaihpdB 8!w/g&36q8RJP:@AgЀDYf%0qA"N1 F'C[ BP4 JgAg{1'+$`M!yD al/X2Xd3h{Ji ՌL_( M@FҐA:HCdPj28`;@*uB(`D+([6HTlll E3́b9t簞‚T=5jMXa 5@#!76gCi 8qPt 2.0@ B8/ZUH?'+x}XF[$(M Li8!* t`vxl.qxKnsr$'c 7PPA64`&Afx 0%)v`,(. @F@F\CSY 4QRˎP HMRP41ԇD1Y: X3``Ї2!~pn0 ~  #gpwԆ qt3(@;Bg075a "L\B1!D$7Vc D4r/'pP$ @DEbu" S\K R LR7`,{5=/ )@԰C5!DqD4 b1eb:N`$R*i)5(` /ŠY>0.@0\'zvr )|0 cgTa*0 5 Q T 3;D$o ˰4I2T x.BW9:!3( 4(x(Tj}Aq7 )@ !@-!( XM3!48PR<7PSZAfBe j.7ETR1`\4O~0EɐG"J0,f@=e}gH .p Dq -)Re!@x[a 9p+.[w0. B,2){84"H7K?H #1.Iy(p^&)p+l?ޠp760 q`7 DB>0z2) jq *E fQe20$*c("dh! [MwpNG :PgivP qs<1h&gpP{D[ :x(`'H Ex|{I{=0.p>P"ao?p:X]6-+͓ P![*J'(#@+D1C#&h'0"=Haԓtq/D  CG92C;,5tEig$YZ`\Z&sCR8(Ng2ЉDT#@->0J#20tU fH>cߑ19.  bj7;#P Ќk/_%P tq򣨹VSF?+õ: Eq"`#@<ѢH"S,=qS930E01pm ]*6@&r6 hp`\@&$1B2S.I'jed6BL/)^'ptPA;wK)f6rXA ` (৩5  DaVMcK!b Z: 165,C*,pp w4Pa (anv^4,0,0 +IZ2:6 lP 0@V `+$< @1>AOw+q"p0P [` 8H,/'F>I[O N6pG 2ҭCwJea(H!h z\[2?  ;Pq{>x5@Ib a enPC!ϐEu\klMj1@QerXRq+vCv&ZB(0zp+1I >Ngp9t6 R pjpW Z-<g3.1)JH M5XW Q JPD  iYP )@,$ߑF* v19V(Hq6 i)t/GX:P>ܢ=*G iD(gA;tԯF (xH1;#t)t%\9`D = 1R?+R! H'D5y@(!`yE20@:LUJp#6;e5@V G b +o+1 >F = *_U*..%'Pq3N ,a\!\; 77'C=5< / :ɋj |;)c F S4+RDCWE5Xztf@b6*I ̓"Y>WTP>p~3x'J2{l5ȐP))Um,6( pfQ'0 *NJR E*1z!bd/H%5@CW$aq$yo kZ!!E7m0KwۘTHC]fXEs$Z];P4 CYh/3:B>o0X?f/9g6RDPH-5@0 ofMZ6beZb8Q |,0 8;1!pi  `P9T"HE,Bq6C 1!Ćˢ)2Log^{IEP 4(074<::g)@@@i)6FD@:e,&(4COU55>:0?I3A%9?c I 74RZ|6-h ڰ?1ҏ=뼴<.vT9fIq^C|n`AycW S| UYbȈ4i#"O&C$O:W |&H%O9㱣(YX+O 8~J4P`u]`  5P [.G:( s ' 0;%Iu[UWN+\&Sۙ@!CO͓CD a .9@T`[2(%#@9|ċ"ԯ4- . 45؃0tJTCp`F#y#B?~pBJjX,, V-b,.=R[ETԕ%^X03p"VR|78z`h%dUiU`sV<@ @apH<%b5D娄F؉jDD'&A5xƊ!g8@΀Mr2Z n.iT wB6`!Hn#c@xFHFh' %'9z~Ã. :xD !T $ u+!jp5(In@`yd:E v asy7!{%kF3Y0 M[rD 3\GE?`2A<*tM /7epH eKh  gmf3xzV:= "C|>\ 8`p& Y vpJ] hmV s7bL>.7SHUB ͮNUZCtQn#M9A18aHcyP\ w/>Z#G-Δ\E@ VP1x?`B| 4bEkFƴa07\h:0Nę.xш'!#EaˀLFCEr?)"2 zyC$*S44\XCLE3D| ~58jvpY?gp.& աi(|!(rb~ 440_0]JQ8Tu@+?9vYj,\UUpO#e6)+ P"k.B!P3& P<4wE5` $t"q?Pa;$ |4 +k0\210id<) MrR~7p0CW4`_?09"ǀ!D # @ @v+5[1WcC&d0B^Q<#q$V$`l! GB[=&"7@$t]o0&E?FZ (3Q ~x<t6ϢV' !eua!1"<A?D1\EV&aK30Ly0KdXF@('X+d*D5+d4kiRsΰ6Ʀ94b !20 ) }̐ i?`Kq*qR `1 y4ז ( aHz0vd6e$I eG 4KuyB d pHsopo5-A50p4%2/<1PKx.ãio02C-A&'P 40 s! TLZԵ},AJ2l]6 ΈA\ 8r"# `pr 0\B2 @ #`opV (?X2F!b 5 $B" $ -~3dWA.qfi+tSaH\ 2,)^^w(r37@`O % S# ,DY a +tw x[T:pkD]Z,#/|v$]@+]B k2b0Z -4{7)WsK * Y(w:@r x ?Ip&`Zɀ5 #/Jc#$1PXo?p) 4CZ(:/Q7,+:i@q ۅ -pYA4GvP[C %Dp#Ӓ:6"h[jzH]M2 DQ<A# e+-@F u*`4P xH2V CrڤiiP@2[0\P Pb",0RVJ6 Wzf:Sh6Ab! NE7'F1 weiV+$"e @! It=s #! ? `}E@۰rXj:kgxH*BnV?u#9}wv@O4'Hy #`4@$ bj%)68Lk@qH\)X gP:GQC`B0r\E/Q^!TFS:5qɑDw OL(~Ѳ&-08A# o  -dTl4i+#CJRL93j2 A:3A! `9ų8B(iYi! y>k_# 7i/Ƿ a @Фyb9е l!6 G#8kХda"4[L}!Icpk)zn[ AMFrDi( !#J՝X3nAM@K1b $.^u& 5gcc, _`Sv,:}q R!~2$]nt,&࿖1id up/+)&  C@p4- [ [pJ$ @ o `U  ?}4:LE12`!0U & iKvq vpT'e` K V7q;P9}6PPИ'Ed"-v 7 lDcF" qYZ0,`+ct`#@U C)2 -! 9'L0z7@.C)C3dbD xC;=P0P!$Ovfi @+3ZȀS"*k? @0t kRKh$2HDA }T)$l6*;M@=>+(D!HS55<֤$$Hs\F62)(@ ~+@u+33 y!!R3.0٧4z,zyx^Wx$w=AT14@UdI̸ouS# yW_r$Y1Y3;^9Nq .$姚qH{,e(@~0!D/qԵ1P "v0< 5Av~R5(2pdk$^E+J:@D#pE3 e&j 6t$DR +r!p(w*&%'L AW],$iѯ"05s$.Q!N"ުQLMz! ݂4r. " tؠyH0\f@bІ! ! I$o` _ n58)S&Yg(i_? 6Vk#Piқ):0jvu@K FJk::(+!"(6NG@@:@G[7:702<@7"!('"-6((!)422F?72q:200Y?57.0 ''&,2)o"+4(q$v"")):$!664:6@<+o<v@&? nvB6BԔ (0*aS iTa& SӠ@C6($j䠆 P(s]6D6~DD$*K b)PhqsN8i4ԏ`n& G˲q$p> g+T s̬ 40O+1L %B6ر@r$D+Jb8 C$Ll4JkDIf< $,`<  "^;+Oi&qvV48]$kL^54?Ԑ#$|PvrΘ^"IJ &ZEx1?ñc:QF0@h%J:0'̄h8 !`+@i@/,! " 9espF)VAJ@f1eO u޵_"QHwT/ PaądX `ҏ0 t18 H9| hc0р5SРxh"}:@R \eP C h=$R!jbJY/p "ڠ.aZ' hVP: S4`D`N (+-T)D(r'DB &AI}D!~!>Q&*&#$IK@r<Ť/P n2iH L@b>0A@6Wءv4Hi 3u"fqA@B o SA"ZPDb"QGr+(bIB φd=~`zex1@H,TZ'( 1 D9X@L$j8Z< 9c/LgMxҁ&X:kfe5 !0èShB)>8BvK9 C0њ PHZ@ (] 4ӊ7xTv$HA #!.1/1 ~ !.5h0 t(K8DrpleԱxh]ZhC.B;'Ԃv(.<t+`;AmRI^ BT2(0*pHTZ.8a5DS#n8AܐYp$B"1̳D -x6Hrg K ^!\4=Vm@ =0f􅐻ȥ< : lC24<&0Ov~T1 @Zf< 1 a 0 6.P@r34oQZ<?@q @:6C#<0?`OQ@:=`2p(B8[+@{a&sT5R-B<@`AHmXq0Ey@2e'9"+7g ;E0r0`1(<$S;633` bҡnbA<-N03 }KaFDF/2OׂGN%-TU;i :01*z*pvI7P~KB<[ti5Eq) ]D'!v!|!S +p Mi Q;(1f q`ZAMU" ' 0ݣe4PO$05ȴ'dvFe wqGp4j9LA!| 76]HCMs'cs--^J&(>?0!>/Ja3A Ef`eNB e-tIe(@ sbrkyX8[D |yEޱ@O@1RI zI'z4Y2'3fpͳv/-@3CPNsQғ2q*G Kb PDP@@5( w2]J /)&tpYZQ<$8lfx/N33CQ >(yZODq B6~jpQbyoTB@?9hO6y2+ | 5pnpsQ_UA$By%`P%!4 6 .t0i>#$F1 QGsXD:R2b ˧@?p9v s }*.D;o}JM;4  @ ~q; vP.E&Pu0Q'-x Ō0(vjW0iYQ!ʐUJ1D i0 D[t Ba fzpac#a2#?b` uPL$|%Иm6 +8XAs`(Fu@  DGXOS /lYb :p=7@aT@D'0. ̩(.&0P!620 ?{N!G yiY [DSNOB 0ZA~*[bl6u-p pe G 0@%JA> Q=r-`10HUfCV@²i>@Vk *^ @PFJ,s~z)Hآ1l :C/)PhB-JkJ#)4yBj(A8ײ%6+#h!rO[ M/ >tījlj 9 `+3(Iv-b[)5U i yq@5\MSprBs G͡=]U1@&j TYnlw|U b'~y" p P1)CGRŇ1+MÕa'6nP&0Pa!kFZ`B8!W};آ4!$Eq ^ Ҹ4RE}{3^biP}HI(<5DV(Ci8KU`Gif8 `:G?p6A.5.M ߣA=66_֪z2 D;1 /݇PdvBta8@{O$ d QG" ,%FI>д0p p kE0,B{vsC-ݫ y&  #+'#QXh;xiHd.>R~RRA:a)^EOMƎ%7&2r%Z1}pk٬C-X 4 67A sYoOeJc/ 1{*-X^& &bFZ00+.܂W@SMOgFM*9[kr2)wKZia RV3A{,ae0-jxA86b7"QG avQ 7&>~tfdk B]|Ia פ]UzijQ1K~8kБnAa$SoƼ*7*087pk $PЛ:ųja2.& eb~ Z'I'nF9o<O)(49@0.(2225Z:@6C:Fa@2:k:>7: g?:7E?^̇@jCF$j 5D>Itc*+z]< 5I4zc O IQQd4;X)Mdn<(4c}q*2!t($7?"8P0Lh )RG'[J U>_*XqL)(*XΊMoPZ@gaq#<# yt e$SDHUe<(٧Ȧ5@A@#tliLI6'UP1Si|"%_ 2_gdO!xqF "HE]P5 [9$kEZi4I<%LCH [UKdJ>t$[W H8 #H7ԑ]q$-Z6c I2CN( g@ vP&PbQ6>DBQ4 :7p 1ȃl5c 3&p%]qIqv\= =P236FL<20sߐl H2C_C&T/:| O|a>0Cp#DF!NJu%g\ CC0PQ y vaԜ$פa EHIًt`%BD3(p ^w&G57 jz" 8ikP'8@(]t&W<Ddƃ##$Tp0qo3x03iZZXwFFLXњkD@kbX*ب쨡)My*D3 ;8AK(@欠fGZ)o8 ‘ü(f4z/  E,T[0_(cP@''GH8Պ$ N*DQwN wHM4i#RdSDK' dX:@P$x9t?@xfE~J( ЃR V9x6H_IUG208:(^< Qs\7 l #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if STDC_HEADERS #include #else #include #endif #include "ttt.h" #include "ttt_account.h" #ifdef IPV6 #include "ttt_ipv6.h" #endif #ifdef HAVE_GETHOSTENT /* some systems (e.g. bsd) don't have gethostent(3) any more, assuming dns be a way to lookup host names. but some systems (e.g. sunos) still have it. if it does, it may be a good idea to initialize the name table at the startup. */ #define INIT_HOSTNAME_TAB /* create host name table beforehand */ #endif static u_long f_localnet, f_netmask; static char *tcpport_string(u_short port); static char *udpport_string(register u_short port); static void init_servarray(void); static void init_hostarray(void); static char *getname(const u_long addr); static char *intoa(u_long addr); void netname_init(u_long netaddr, u_long netmask) { /* save localnet address and netmask */ f_localnet = netaddr; f_netmask = netmask; /* initialize tcp/udp service table */ init_servarray(); #ifdef INIT_HOSTNAME_TAB /* initialize host name table */ if (!ttt_nohostname) init_hostarray(); #endif } #ifndef ETHERTYPE_LOOPBACK #define ETHERTYPE_LOOPBACK 0x9000 #endif #ifndef ETHERTYPE_ATALK #define ETHERTYPE_ATALK 0x809b #endif struct pname_tab { char *pn_name; int pn_value; }; static struct pname_tab eth_tab[] = { "ip", ETHERTYPE_IP, /* IP protocol */ "arp", ETHERTYPE_ARP, /* Addr. resolution protocol */ #ifdef IPV6 "ipv6", ETHERTYPE_IPV6, /* IPv6 protocol */ #endif "pup", ETHERTYPE_PUP, /* PUP protocol */ "revarp", ETHERTYPE_REVARP, /* Reverse ARP */ "loop", ETHERTYPE_LOOPBACK, /* Loopback */ "atalk", ETHERTYPE_ATALK, /* AppleTalk */ NULL, 0 }; /* stick to RFC1700. some systems has wrong numbers. */ #undef IPPROTO_IP #define IPPROTO_IP 4 /* IP in IP (encasulation) */ #undef IPPROTO_IPIP #define IPPROTO_IPIP 94 /* IP-within-IP Encapsulation Protocol */ #undef IPPROTO_ENCAP #define IPPROTO_ENCAP 98 /* Encapsulation Header */ /* other protocols we are interested in */ #ifndef IPPROTO_RSVP #define IPPROTO_RSVP 46 /* RSVP Reservation Protocol */ #endif #ifndef IPPROTO_GRE #define IPPROTO_GRE 47 /* General Routing Encapsulation */ #endif #ifndef IPPROTO_ESP #define IPPROTO_ESP 50 /* encapsulating security payload */ #endif #ifndef IPPROTO_OSPFIGP #define IPPROTO_OSPFIGP 89 /* OSPFIGP */ #endif static struct pname_tab ip_tab[] = { "tcp", IPPROTO_TCP, /* tcp */ "udp", IPPROTO_UDP, /* user datagram protocol */ "icmp", IPPROTO_ICMP, /* control message protocol */ "igmp", IPPROTO_IGMP, /* group control protocol */ #ifdef IPPROTO_GGP "ggp", IPPROTO_GGP, /* gateway^2 (deprecated) */ #endif "egp", IPPROTO_EGP, /* exterior gateway protocol */ "pup", IPPROTO_PUP, /* pup */ "ospf", IPPROTO_OSPFIGP, /* OSPFIGP */ "rsvp", IPPROTO_RSVP, /* RSVP */ "gre", IPPROTO_GRE, /* GRE */ "esp", IPPROTO_ESP, /* encapsulating security payload */ "ip", IPPROTO_IP, /* IP in IP */ "ipip", IPPROTO_IPIP, /* IP-within-IP */ "encap", IPPROTO_ENCAP, /* Encapsulation Header */ #ifdef IPV6 "icmp6", IPPROTO_ICMPV6, /* ICMP version 6 */ #endif NULL, 0 }; static char *pname_lookup(struct pname_tab *tab, long id) { struct pname_tab *tp = tab; while (tp->pn_name != NULL) { if (tp->pn_value == id) return (tp->pn_name); tp++; } return NULL; } char *net_getname(long type, long *id) { char *buf, *name; u_short portno; switch(type) { case TTTTYPE_ETHER: if ((buf = malloc(sizeof("revarp/ether "))) == NULL) fatal_error("get_protoname: no memory\n"); name = pname_lookup(eth_tab, id[0]); if (name != NULL) sprintf(buf, "%s/ether", name); else sprintf(buf, "0x%x/ether", id[0]); break; case TTTTYPE_IP: if ((buf = malloc(sizeof("encap/ip "))) == NULL) fatal_error("get_protoname: no memory\n"); name = pname_lookup(ip_tab, id[0]); if (name != NULL) sprintf(buf, "%s/ip", name); else sprintf(buf, "%d/ip", id[0]); break; case TTTTYPE_UDP: if ((buf = malloc(sizeof("some-long-service-name/udp"))) == NULL) fatal_error("get_protoname: no memory\n"); portno = id[0]; if ((name = udpport_string(portno)) != NULL) sprintf(buf, "%s/udp", name); else sprintf(buf, "%d/udp", id[0]); break; case TTTTYPE_TCP: if ((buf = malloc(sizeof("some-long-service-name/tcp"))) == NULL) fatal_error("get_protoname: no memory\n"); portno = id[0]; if ((name = tcpport_string(portno)) != NULL) sprintf(buf, "%s/tcp", name); else sprintf(buf, "%d/tcp", id[0]); break; case TTTTYPE_IPHOST: { u_long addr; if ((buf = malloc(sizeof("xxx.xxx.xxx.xxx"))) == NULL) fatal_error("get_protoname: no memory\n"); addr = htonl(id[0]); #ifdef DONT_LOOKUP_HOSTNAME if (!ttt_nohostname && (name = getname(addr)) != NULL) { #else /* lookup the hostname only when (1) the address is local. (otherwise, it might take a long time to lookup dns) (2) the host portion is not 0 (i.e., a network address). (3) the host portion is not broadcast. */ if (!ttt_nohostname && (addr & f_netmask) == f_localnet && (addr &~ f_localnet) != 0 && (addr | f_netmask) != 0xffffffff && ((name = getname(addr)) != NULL)) { #endif /* !DONT_LOOKUP_HOSTNAME */ strcpy(buf, name); } else sprintf(buf, "%s", intoa(addr)); } break; #ifdef IPV6 case TTTTYPE_IPV6: if ((buf = malloc(sizeof("icmp6/ip6 "))) == NULL) fatal_error("get_protoname: no memory\n"); name = pname_lookup(ip_tab, id[0]); if (name != NULL) sprintf(buf, "%s/ip6", name); else sprintf(buf, "%d/ip6", id[0]); break; case TTTTYPE_UDPV6: if ((buf = malloc(sizeof("some-long-service-name/udp6"))) == NULL) fatal_error("get_protoname: no memory\n"); portno = id[0]; if ((name = udpport_string(portno)) != NULL) sprintf(buf, "%s/udp6", name); else sprintf(buf, "%d/udp6", id[0]); break; case TTTTYPE_TCPV6: if ((buf = malloc(sizeof("some-long-service-name/tcp6"))) == NULL) fatal_error("get_protoname: no memory\n"); portno = id[0]; if ((name = tcpport_string(portno)) != NULL) sprintf(buf, "%s/tcp6", name); else sprintf(buf, "%d/tcp6", id[0]); break; case TTTTYPE_IPV6HOST: { u_long tmp[4]; static char *inet6_ntoa(u_long *addr); /* should be replaced by addr2ascii */ if ((buf = malloc(sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx"))) == NULL) fatal_error("get_protoname: no memory\n"); tmp[0] = htonl(id[0]); tmp[1] = htonl(id[1]); tmp[2] = htonl(id[2]); tmp[3] = htonl(id[3]); sprintf(buf, "%s", inet6_ntoa(tmp)); } break; #endif /* IPV6 */ default: if ((buf = malloc(sizeof("unknown"))) == NULL) sprintf(buf, "unknown"); break; } return buf; } /* cache tables for udp/tcp services and host names derived from tcpdump. we don't manage memory space since - tcp/udp services has limited entries. - only local host names are looked up. */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994 * 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: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Internet, ethernet, port, and protocol string to address * and address to string conversion routines */ typedef unsigned long u_int32; /* * hash tables for whatever-to-name translations */ #define HASHNAMESIZE 4096 struct hnamemem { u_int32 addr; char *name; struct hnamemem *nxt; }; static struct hnamemem hnametable[HASHNAMESIZE]; static struct hnamemem tporttable[HASHNAMESIZE]; static struct hnamemem uporttable[HASHNAMESIZE]; static char *tcpport_string(u_short port) { struct hnamemem *tp; u_long i = port; for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); return NULL; } static char *udpport_string(register u_short port) { struct hnamemem *tp; u_long i = port; for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); return NULL; } static void init_servarray(void) { struct servent *sv; struct hnamemem *table; int i, n = 0; setservent(1); while ((sv = getservent()) != NULL) { int port = ntohs(sv->s_port); i = port & (HASHNAMESIZE-1); if (strcmp(sv->s_proto, "tcp") == 0) table = &tporttable[i]; else if (strcmp(sv->s_proto, "udp") == 0) table = &uporttable[i]; else continue; while (table->name) { if (table->addr == port) { /* dup entry! */ break; } table = table->nxt; } if (table->name == NULL) { table->name = strdup(sv->s_name); table->addr = port; table->nxt = (struct hnamemem *)calloc(1, sizeof(*table)); n++; } } endservent(); #ifdef REMOTE_DEBUG printf("[debug] initialized serv table %d entries\n", n); #endif } #ifdef INIT_HOSTNAME_TAB static void init_hostarray(void) { struct hostent *hp; struct hnamemem *p; int n = 0; sethostent(1); while ((hp = gethostent()) != NULL) { u_int32 addr; if (hp->h_length != 4) continue; bcopy(hp->h_addr, &addr, hp->h_length); addr = ntohl(addr); p = &hnametable[addr & (HASHNAMESIZE-1)]; while (p->name) { if (p->addr == addr) { /* dup entry! */ break; } p = p->nxt; } if (p->name == NULL) { char *dotp; p->name = strdup(hp->h_name); p->addr = addr; p->nxt = (struct hnamemem *)calloc(1, sizeof(*p)); /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = 0; n++; } } endhostent(); #ifdef REMOTE_DEBUG printf("[debug] initialized host name table %d entries\n", n); #endif } #endif /* INIT_HOSTNAME_TAB */ /* * Return a name for the IP address. This address * is assumed to be in network byte order. */ static char *getname(const u_int32 addr) { struct hnamemem *p; p = &hnametable[addr & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (p->addr == addr) return (p->name); } #ifndef DONT_LOOKUP_HOSTNAME { struct hostent *hp; p->addr = addr; p->nxt = (struct hnamemem *)calloc(1, sizeof (*p)); hp = gethostbyaddr((char *)&addr, 4, AF_INET); if (hp) { char *dotp; p->name = strdup(hp->h_name); /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = 0; return (p->name); } } #endif /* DONT_LOOKUP_HOSTNAME */ return NULL; } /* * A faster replacement for inet_ntoa(). */ static char *intoa(u_int32 addr) { register char *cp; register u_int byte; register int n; static char buf[sizeof(".xxx.xxx.xxx.xxx")]; addr = ntohl(addr); cp = &buf[sizeof buf]; *--cp = '\0'; n = 4; do { byte = addr & 0xff; *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) { *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) *--cp = byte + '0'; } *--cp = '.'; addr >>= 8; } while (--n > 0); return cp + 1; } #ifdef IPV6 /* derived from ascii_addr.c */ #if !defined(BSD4_4) && !(defined(__linux__) && defined(__USE_BSD)) typedef u_long u_int32_t; typedef u_short u_int16_t; #endif /* * Copyright (c) 1994 Bell Communications Research Inc. (Bellcore). * * Permission to use, copy, modify and distribute this material for any * purpose and without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, * and the name of Bellcore not be used in advertising or publicity * pertaining to this material without the specific, prior written * permission of an authorized representative of Bellcore. BELLCORE * MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS MATERIAL * FOR ANY PURPOSE. IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES. */ static char digits[] = "0123456789abcdef"; static char buf[128]; static char * inet6_ntoa(u_int32_t *addr) { register int i; register char *cp = buf; register u_int16_t *a = (u_int16_t *)addr; register u_char *d; int zeros, h, dcolon = 0; for (i = 0; i < 8; i++) { if (dcolon == 1) { if (*a == 0) { /* trailing zeros */ if (i == 7) *cp++ = ':'; a++; continue; } else dcolon = 2; } if (*a == 0) { if (dcolon == 0 && *(a + 1) == 0) { /* leading zeros */ if (i == 0) *cp++ = ':'; *cp++ = ':'; dcolon = 1; } else { *cp++ = '0'; *cp++ = ':'; } a++; continue; } d = (u_char *)a; zeros = 0; if ((h = (*d >> 4)) == 0) zeros = 1; else *cp++ = digits[h]; if (((h = (*d++ & 0xf)) == 0) && (zeros == 1)) zeros = 2; else *cp++ = digits[h]; if (((h = (*d >> 4)) == 0) && (zeros == 2)) zeros = 3; else *cp++ = digits[h]; *cp++ = digits[*d & 0xf]; *cp++ = ':'; a++; } *--cp = 0; return (buf); } #endif /* IPV6 */ ttt-1.7.orig/net_read.c0100644000273700007640000007267107555410233013712 0ustar scheffedv/* $Id: net_read.c,v 0.13 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* net_read.c -- a module to read ethernet packets. most parts are derived from tcpdump. */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994\nThe Regents of the University of California. All rights reserved.\n"; #endif /* * tcpdump - monitor tcp/ip traffic on an ethernet. * * First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory. * Mercilessly hacked and occasionally improved since then via the * combined efforts of Van, Steve McCanne and Craig Leres of LBL. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef PCAP_HEADERS #include "llc.h" #include "fddi.h" #else #include "ttt_pcap.h" #endif #include "ttt.h" #include "ttt_account.h" #ifdef IPV6 #include "ttt_ipv6.h" #endif /* for tailqueue macros */ #if defined(HAVE_SYS_QUEUE_H) && !defined(__linux__) #include #else #include "bsd_sys_queue.h" #endif /* * The default snapshot length. This value allows most printers to print * useful information while keeping the amount of unwanted data down. * In particular, it allows for an ethernet header, tcp/ip header, and * 14 bytes of data (assuming no ip options). */ #ifdef IPV6 #define DEFAULT_SNAPLEN (68+20) /* is this big enough? */ #else #define DEFAULT_SNAPLEN 68 #endif #ifndef ETHERTYPE_PPPOE #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #endif char errbuf[PCAP_ERRBUF_SIZE]; char *device; char *cmdbuf; pcap_t *pd; int pcapfd; static int packet_length; /* length of current packet */ /* a function switch to read different types of frames */ void (*ttt_netreader)(u_char *user, const struct pcap_pkthdr *h, const u_char *p); /* needed by libpacp */ int fddipad = FDDIPAD; /* for proper alignment of header */ struct ip4_frag { TAILQ_ENTRY(ip4_frag) ip4f_chain; char ip4f_valid; u_char ip4f_proto; u_short ip4f_id; struct in_addr ip4f_src, ip4f_dst; struct udphdr ip4f_udphdr; }; static TAILQ_HEAD(ip4f_list, ip4_frag) ip4f_list; /* IPv4 fragment cache */ #define IP4F_TABSIZE 8 /* IPv4 fragment cache size */ /* * the following macros are FreeBSD extension. there are two incompatible * TAILQ_LAST defines in FreeBSD (changed after 2.2.6), so use the new one. */ #ifndef TAILQ_EMPTY #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) #endif #undef TAILQ_LAST #define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) void net_read(int clientdata, int mask); static void ttt_dumpreader(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static void ether_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static void fddi_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static void atm_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static void sl_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static void ppp_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); #ifdef DLT_RAW static void raw_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p); #endif #ifdef DLT_PPP_BSDOS static void ppp_bsdos_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); #endif #ifdef DLT_PPP_SERIAL /* netbsd specific */ static void ppp_netbsd_serial_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); #endif static void null_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static int ether_encap_read(const u_short ethtype, const u_char *p, const int length, const int caplen); static int llc_read(const u_char *p, const int length, const int caplen); static int pppoe_read(const u_char *bp, const int length, const int caplen); static int ip_read(const u_char *bp, const int length, const int caplen); static void ip4f_cache(struct ip *, struct udphdr *); static struct udphdr *ip4f_lookup(struct ip *); static int ip4f_init(void); static struct ip4_frag *ip4f_alloc(void); static void ip4f_free(struct ip4_frag *); #ifdef IPV6 static int ipv6_read(const u_char *bp, const int length, const int caplen); static int read_ipv6hdr(struct ipv6 *ipv6, int *proto, int caplen); #endif /* wrapper for tcl callback */ void net_read(int clientdata, int mask) { if (pcap_dispatch(pd, 1, ttt_netreader, 0) < 0) (void)fprintf(stderr, "pcap_dispatch:%s\n", pcap_geterr(pd)); } int dumpfile_read(void) { struct timeval end; int rval; end = ttt_dumptime; end.tv_sec += ttt_interval / 1000; end.tv_usec += (ttt_interval % 1000) * 1000; if (end.tv_usec > 1000000) { end.tv_sec++; end.tv_usec -= 1000000; } while ((rval = pcap_dispatch(pd, 1, ttt_dumpreader, 0)) > 0) { if (ttt_dumptime.tv_sec > end.tv_sec || (ttt_dumptime.tv_sec == end.tv_sec && ttt_dumptime.tv_usec >= end.tv_usec)) /* end of the interval */ return (rval); } if (rval < 0) (void)fprintf(stderr, "pcap_dispatch:%s\n", pcap_geterr(pd)); return (rval); } static void ttt_dumpreader(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { ttt_dumptime = h->ts; (*ttt_netreader)(user, h, p); } static void ether_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; struct ether_header *ep; u_short ether_type; packet_length = length; /* save data link level packet length */ if (caplen < sizeof(struct ether_header)) { return; } ep = (struct ether_header *)p; p += sizeof(struct ether_header); length -= sizeof(struct ether_header); caplen -= sizeof(struct ether_header); ether_type = ntohs(ep->ether_type); if (ether_type < ETHERMTU) { if (llc_read(p, length, caplen) == 0) { /* ether_type not known */ } } else if (ether_encap_read(ether_type, p, length, caplen) == 0) { /* ether_type not known */ } } static int ether_encap_read(const u_short ethtype, const u_char *p, const int length, const int caplen) { #if 0 /* people love to see the total traffic! */ if (ethtype != ETHERTYPE_IP) #endif eth_addsize(ethtype, packet_length); recurse: switch (ethtype) { case ETHERTYPE_IP: ip_read(p, length, caplen); break; #ifdef IPV6 case ETHERTYPE_IPV6: ipv6_read(p, length, caplen); break; #endif #ifdef ETHERTYPE_8021Q case ETHERTYPE_8021Q: ethtype = ntohs(*(unsigned short*)(p+2)); p += 4; length -= 4; caplen -= 4; if (ethtype <= ETHERMTU) /* ether_type not known */ break; goto recurse; break; #endif case ETHERTYPE_PPPOE: pppoe_read(p, length, caplen); break; default: break; } return (1); } static void fddi_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; const struct fddi_header *fddip = (struct fddi_header *)p; packet_length = length; /* save data link level packet length */ if (caplen < FDDI_HDRLEN) return; /* Skip over FDDI MAC header */ length -= FDDI_HDRLEN; p += FDDI_HDRLEN; caplen -= FDDI_HDRLEN; /* Frame Control field determines interpretation of packet */ if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { /* Try to print the LLC-layer header & higher layers */ if (llc_read(p, length, caplen) == 0) { /* some kinds of LLC packet we cannot handle intelligently */ } } else { /* Some kinds of FDDI packet we cannot handle intelligently */ } } #ifndef min #define min(a, b) (((a)<(b))?(a):(b)) #endif static int llc_read(const u_char *p, const int length, const int caplen) { struct llc llc; register u_short et; register int ret; if (caplen < 3) { return(0); } /* Watch out for possible alignment problems */ bcopy((char *)p, (char *)&llc, min(caplen, sizeof(llc))); #if 0 /* we are not interested in these */ if (llc.ssap == LLCSAP_GLOBAL && llc.dsap == LLCSAP_GLOBAL) { /* ipx */ return (1); } else if (p[0] == 0xf0 && p[1] == 0xf0) { /* netbios */ } if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS && llc.llcui == LLC_UI) { /* iso */ } #endif /* 0 */ if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP && llc.llcui == LLC_UI) { /* snap */ if (caplen < sizeof(llc)) { return (0); } /* This is an encapsulated Ethernet packet */ #ifdef ALIGN_WORD { u_short tmp; bcopy(&llc.ethertype[0], &tmp, sizeof(u_short)); et = ntohs(tmp); } #else et = ntohs(*(u_short *)&llc.ethertype[0]); #endif ret = ether_encap_read(et, p + sizeof(llc), length - sizeof(llc), caplen - sizeof(llc)); if (ret) return (ret); } /* llcsap */ return(0); } static void atm_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; u_short ether_type; packet_length = length; /* save data link level packet length */ if (caplen < 8) return; if (p[0] != 0xaa || p[1] != 0xaa || p[2] != 0x03) { /* unknown format! */ return; } ether_type = p[6] << 8 | p[7]; eth_addsize(ether_type, packet_length); length -= 8; caplen -= 8; p += 8; switch (ether_type) { case ETHERTYPE_IP: ip_read(p, length, caplen); break; #ifdef IPV6 case ETHERTYPE_IPV6: ipv6_read(p, length, caplen); break; #endif } } #ifndef SLIP_HDRLEN #define SLIP_HDRLEN 16 #endif static void sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; packet_length = length; /* save data link level packet length */ if (caplen < SLIP_HDRLEN) return; length -= SLIP_HDRLEN; caplen -= SLIP_HDRLEN; p += SLIP_HDRLEN; ip_read(p, length, caplen); } #ifndef PPP_HDRLEN #define PPP_HDRLEN 4 #endif #define PPP_IP 0x21 /* Internet Protocol */ #define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ static void ppp_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; const struct ip *ip; u_int proto; packet_length = length; /* save data link level packet length */ if (caplen < PPP_HDRLEN) return; proto = ntohs(*(u_short *)&p[2]); length -= PPP_HDRLEN; caplen -= PPP_HDRLEN; p += PPP_HDRLEN; ip = (struct ip *)p; switch (proto) { case ETHERTYPE_IP: case PPP_IP: ip_read(p, length, caplen); break; #ifdef IPV6 case ETHERTYPE_IPV6: case PPP_IPV6: ipv6_read(p, length, caplen); break; #endif } } #ifdef DLT_PPP_BSDOS /* BSD/OS specific PPP printer */ #ifndef PPP_BSDI_HDRLEN #define PPP_BSDI_HDRLEN 24 #endif #define PPP_ADDRESS 0xff /* The address byte value */ #define PPP_CONTROL 0x03 /* The control byte value */ /* BSD/OS specific PPP printer */ static void ppp_bsdos_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; int hdrlength; u_short ptype; packet_length = length; /* save data link level packet length */ if (caplen < PPP_BSDI_HDRLEN) return; hdrlength = 0; if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) { p += 2; hdrlength = 2; } /* Retrieve the protocol type */ if (*p & 01) { /* Compressed protocol field */ ptype = *p; p++; hdrlength += 1; } else { /* Un-compressed protocol field */ ptype = ntohs(*(u_short *)p); p += 2; hdrlength += 2; } length -= hdrlength; caplen -= hdrlength; switch (ptype) { case PPP_IP: ip_read(p, length, caplen); break; #ifdef IPV6 case PPP_IPV6: ipv6_read(p, length, caplen); break; #endif } } #endif /* DLT_PPP_BSDOS */ #ifdef DLT_PPP_SERIAL /* netbsd specific */ /* * NetBSD-specific PPP printers. Handles multiple PPP encaps, and * Cisco frames. */ #define PPP_NETBSD_SERIAL_HDRLEN 4 /* Actual address byte values */ #define PPP_ADDR_ALLSTATIONS 0xff /* all stations broadcast addr */ #define PPP_ADDR_CISCO_MULTICAST 0x8f /* Cisco multicast address */ #define PPP_ADDR_CISCO_UNICAST 0x0f /* Cisco unicast address */ /* * XXX Note, this is overloaded with VINESCP, but we can tell based on * XXX the address byte if we're using Cisco protocol numbers (i.e. * XXX Ethertypes). */ #define PPP_CISCO_KEEPALIVE 0x8035 /* Cisco keepalive protocol */ static void ppp_netbsd_serial_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { int caplen = h->caplen; int length = h->len; u_short ptype; u_char addr, ctrl; packet_length = length; /* save data link level packet length */ if (caplen < PPP_NETBSD_SERIAL_HDRLEN) return; addr = p[0]; ctrl = p[1]; switch (addr) { case PPP_ADDR_ALLSTATIONS: /* * Regular serial PPP packet. */ ptype = (p[2] << 8) | p[3]; p += PPP_NETBSD_SERIAL_HDRLEN; length -= PPP_NETBSD_SERIAL_HDRLEN; caplen -= PPP_NETBSD_SERIAL_HDRLEN; switch (ptype) { case PPP_IP: ip_read(p, length, caplen); break; #ifdef IPV6 case PPP_IPV6: ipv6_read(p, length, caplen); break; #endif } break; case PPP_ADDR_CISCO_MULTICAST: case PPP_ADDR_CISCO_UNICAST: ptype = (p[2] << 8) | p[3]; p += PPP_NETBSD_SERIAL_HDRLEN; length -= PPP_NETBSD_SERIAL_HDRLEN; caplen -= PPP_NETBSD_SERIAL_HDRLEN; switch (ptype) { case PPP_CISCO_KEEPALIVE: break; default: if (ether_encap_read(ptype, p, length, caplen) == 0) { /* ether_type not known */ } } break; default: /* Address not known, print raw packet. */ break; } } #endif /* DLT_PPP_SERIAL */ #ifndef NULL_HDRLEN #define NULL_HDRLEN 4 /* DLT_NULL header length */ #endif static void null_if_read(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { int length = h->len; int caplen = h->caplen; const struct ip *ip; packet_length = length; /* save data link level packet length */ length -= NULL_HDRLEN; caplen -= NULL_HDRLEN; ip = (struct ip *)(p + NULL_HDRLEN); switch (ip->ip_v) { case 4: ip_read((const u_char *)ip, length, caplen); break; #ifdef IPV6 case 6: ipv6_read((const u_char *)ip, length, caplen); break; #endif } } #ifdef DLT_RAW static void raw_if_read(u_char *pcap, const struct pcap_pkthdr *h, const u_char *p) { packet_length = h->len; /* save data link level packet length */ switch (((struct ip *)p)->ip_v) { case 4: ip_read(p, h->len, h->caplen); break; #ifdef IPV6 case 6: ipv6_read(p, h->len, h->caplen); break; #endif } } #endif #ifndef PPPOE_HDRLEN #define PPPOE_HDRLEN 6 #endif static int pppoe_read(const u_char *bp, const int length, const int caplen) { u_short version, type, code, ptype; const u_char *p; int hdrlen; if (caplen < PPPOE_HDRLEN) return (0); p = bp; version = p[0] & 0xf0; type = p[0] & 0x0f; code = p[1]; if (version != 1 || type != 1 || code != 0) return (0); hdrlen = PPPOE_HDRLEN; p += PPPOE_HDRLEN; if (p[0] & 0x1) { ptype = p[0]; hdrlen += 1; } else if (p[1] & 0x1) { ptype = ntohs(*(u_short *)p); hdrlen += 2; } else return (0); if (caplen < hdrlen) return (0); switch (ptype) { case PPP_IP: ip_read(bp + hdrlen, length - hdrlen, caplen - hdrlen); break; #ifdef IPV6 case PPP_IPV6: ipv6_read(bp + hdrlen, length - hdrlen, caplen - hdrlen); break; #endif } return (1); } static int ip_read(const u_char *bp, const int length, const int caplen) { struct ip *ip; int hlen, len, proto, off; u_long srcaddr, dstaddr; u_short srcport, dstport; struct tcphdr *tcp; struct udphdr *udp; ip = (struct ip *)bp; if (length < sizeof (struct ip)) return 0; #ifdef ALIGN_WORD /* * The IP header is not word aligned, so copy into abuf. * This will never happen with BPF. It does happen raw packet * dumps from -r. */ if ((int)ip & (sizeof(long)-1)) { static u_char *abuf; if (abuf == 0) abuf = (u_char *)malloc(DEFAULT_SNAPLEN); bcopy((char *)ip, (char *)abuf, caplen); ip = (struct ip *)abuf; } #endif /* ALIGN_WORD */ hlen = ip->ip_hl * 4; len = min(ntohs(ip->ip_len), length); len -= hlen; if (len < 0) return 0; bp = (u_char *)ip + hlen; srcaddr = ntohl(ip->ip_src.s_addr); dstaddr = ntohl(ip->ip_dst.s_addr); proto = ip->ip_p; if (!(ttt_filter & TTTFILTER_SRCHOST)) { host_addsize(srcaddr, packet_length); if (!(ttt_filter & TTTFILTER_DSTHOST) && srcaddr != dstaddr) host_addsize(dstaddr, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTHOST)) host_addsize(dstaddr, packet_length); if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) ip_addsize(proto, packet_length); else { /* if this is fragment zero, hand it to the next higher level protocol. */ off = ntohs(ip->ip_off); if (off & 0x1fff) { /* process fragments */ if ((bp = (u_char *)ip4f_lookup(ip)) == NULL) /* lookup failed */ return 1; } if (proto == IPPROTO_TCP) { if (len < sizeof (struct tcphdr)) return 0; tcp = (struct tcphdr *)bp; srcport = ntohs(tcp->th_sport); dstport = ntohs(tcp->th_dport); if (!(ttt_filter & TTTFILTER_SRCPORT)) { tcp_addsize(srcport, packet_length); if (dstport != srcport && !(ttt_filter & TTTFILTER_DSTPORT)) tcp_addsize(dstport, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTPORT)) tcp_addsize(dstport, packet_length); } else { if (len < sizeof (struct udphdr)) return 0; udp = (struct udphdr *)bp; srcport = ntohs(udp->uh_sport); dstport = ntohs(udp->uh_dport); if (!(ttt_filter & TTTFILTER_SRCPORT)) { udp_addsize(srcport, packet_length); if (dstport != srcport && !(ttt_filter & TTTFILTER_DSTPORT)) udp_addsize(dstport, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTPORT)) udp_addsize(dstport, packet_length); } /* if this is a first fragment, cache it. */ if ((off & IP_MF) && (off & 0x1fff) == 0) ip4f_cache(ip, (struct udphdr *)bp); } #ifdef IPV6 /* sould we do this? or is it better to see only that ipv6 being encapsulated? another idea is to make another class TTTTYPE_IPV6INIP. */ if (proto == IPPROTO_IPV6) { /* ipv6 in ipv4 */ ipv6_read(bp, len, caplen-hlen); } #endif /* IPV6 */ return 1; } /* * helper functions to handle IPv4 fragments. * currently only in-sequence fragments are handled. * - fragment info is cached in a LRU list. * - when a first fragment is found, cache its flow info. * - when a non-first fragment is found, lookup the cache. */ static void ip4f_cache(ip, udp) struct ip *ip; struct udphdr *udp; { struct ip4_frag *fp; if (TAILQ_EMPTY(&ip4f_list)) { /* first time call, allocate fragment cache entries. */ if (ip4f_init() < 0) /* allocation failed! */ return; } fp = ip4f_alloc(); fp->ip4f_proto = ip->ip_p; fp->ip4f_id = ip->ip_id; fp->ip4f_src = ip->ip_src; fp->ip4f_dst = ip->ip_dst; fp->ip4f_udphdr.uh_sport = udp->uh_sport; fp->ip4f_udphdr.uh_dport = udp->uh_dport; } static struct udphdr *ip4f_lookup(ip) struct ip *ip; { struct ip4_frag *fp; struct udphdr *udphdr; for (fp = TAILQ_FIRST(&ip4f_list); fp != NULL && fp->ip4f_valid; fp = TAILQ_NEXT(fp, ip4f_chain)) if (ip->ip_id == fp->ip4f_id && ip->ip_src.s_addr == fp->ip4f_src.s_addr && ip->ip_dst.s_addr == fp->ip4f_dst.s_addr && ip->ip_p == fp->ip4f_proto) { /* found the matching entry */ udphdr = &fp->ip4f_udphdr; if ((ntohs(ip->ip_off) & IP_MF) == 0) /* this is the last fragment, release the entry. */ ip4f_free(fp); return (udphdr); } /* no matching entry found */ return (NULL); } static int ip4f_init(void) { struct ip4_frag *fp; int i; TAILQ_INIT(&ip4f_list); for (i=0; iip4f_valid = 0; TAILQ_INSERT_TAIL(&ip4f_list, fp, ip4f_chain); } return (0); } static struct ip4_frag *ip4f_alloc(void) { struct ip4_frag *fp; /* reclaim an entry at the tail, put it at the head */ fp = TAILQ_LAST(&ip4f_list, ip4f_list); TAILQ_REMOVE(&ip4f_list, fp, ip4f_chain); fp->ip4f_valid = 1; TAILQ_INSERT_HEAD(&ip4f_list, fp, ip4f_chain); return (fp); } static void ip4f_free(fp) struct ip4_frag *fp; { TAILQ_REMOVE(&ip4f_list, fp, ip4f_chain); fp->ip4f_valid = 0; TAILQ_INSERT_TAIL(&ip4f_list, fp, ip4f_chain); } #ifdef IPV6 /* this version doesn't handle fragments */ static int ipv6_read(const u_char *bp, const int length, const int caplen) { struct ipv6 *ipv6; int hlen, len, proto; u_long srcaddr[4], dstaddr[4]; u_short srcport, dstport; struct tcphdr *tcp; struct udphdr *udp; ipv6 = (struct ipv6 *)bp; if (length < sizeof (struct ipv6)) return 0; #ifdef ALIGN_WORD /* * The IP header is not word aligned, so copy into abuf. * This will never happen with BPF. It does happen raw packet * dumps from -r. */ if ((int)ipv6 & (sizeof(long)-1)) { static u_char *abuf; if (abuf == 0) abuf = (u_char *)malloc(DEFAULT_SNAPLEN); bcopy((char *)ipv6, (char *)abuf, caplen); ipv6 = (struct ipv6 *)abuf; } #endif /* ALIGN_WORD */ hlen = read_ipv6hdr(ipv6, &proto, caplen); len = min(ntohs(ipv6->ipv6_len) + sizeof(struct ipv6), length) - hlen; if (len < 0) return 0; bp = (u_char *)ipv6 + hlen; bcopy(&ipv6->ipv6_src, srcaddr, sizeof(struct in6_addr)); srcaddr[0] = ntohl(srcaddr[0]); srcaddr[1] = ntohl(srcaddr[1]); srcaddr[2] = ntohl(srcaddr[2]); srcaddr[3] = ntohl(srcaddr[3]); bcopy(&ipv6->ipv6_dst, dstaddr, sizeof(struct in6_addr)); dstaddr[0] = ntohl(dstaddr[0]); dstaddr[1] = ntohl(dstaddr[1]); dstaddr[2] = ntohl(dstaddr[2]); dstaddr[3] = ntohl(dstaddr[3]); if (!(ttt_filter & TTTFILTER_SRCHOST)) { hostv6_addsize(srcaddr, packet_length); if (!(ttt_filter & TTTFILTER_DSTHOST) && bcmp(srcaddr, dstaddr, sizeof(srcaddr))) hostv6_addsize(dstaddr, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTHOST)) hostv6_addsize(dstaddr, packet_length); if (proto != IPPROTO_TCP && proto != IPPROTO_UDP) ipv6_addsize(proto, packet_length); else if (proto == IPPROTO_TCP) { if (len < sizeof (struct tcphdr)) return 0; tcp = (struct tcphdr *)bp; srcport = ntohs(tcp->th_sport); dstport = ntohs(tcp->th_dport); if (!(ttt_filter & TTTFILTER_SRCPORT)) { tcpv6_addsize(srcport, packet_length); if (dstport != srcport && !(ttt_filter & TTTFILTER_DSTPORT)) tcpv6_addsize(dstport, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTPORT)) tcpv6_addsize(dstport, packet_length); } else { if (len < sizeof (struct udphdr)) return 0; udp = (struct udphdr *)bp; srcport = ntohs(udp->uh_sport); dstport = ntohs(udp->uh_dport); if (!(ttt_filter & TTTFILTER_SRCPORT)) { udpv6_addsize(srcport, packet_length); if (dstport != srcport && !(ttt_filter & TTTFILTER_DSTPORT)) udpv6_addsize(dstport, packet_length); } else if (!(ttt_filter & TTTFILTER_DSTPORT)) udpv6_addsize(dstport, packet_length); } return 1; } static int read_ipv6hdr(struct ipv6 *ipv6, int *proto, int caplen) { int hlen, opt_len; struct ipv6_ext *ipv6ext; u_char nh; hlen = sizeof(struct ipv6); caplen -= hlen; nh = ipv6->ipv6_nh; ipv6ext = (struct ipv6_ext *)(ipv6 + 1); while (nh == IPV6_NH_HOP || nh == IPV6_NH_RT || nh == IPV6_NH_AUTH || nh == IPV6_NH_DST) { if (nh == IPV6_NH_AUTH) opt_len = 8 + (ipv6ext->i6ext_len * 4); else opt_len = (ipv6ext->i6ext_len + 1) * 8; hlen += opt_len; if ((caplen -= opt_len) < 0) break; nh = ipv6ext->i6ext_nh; ipv6ext = (struct ipv6_ext *)((caddr_t)ipv6ext + opt_len); } *proto = (int)nh; return hlen; } #endif /* IPV6 */ struct printer { pcap_handler f; int type; }; static struct printer printers[] = { { ether_if_read, DLT_EN10MB }, { fddi_if_read, DLT_FDDI }, #ifdef DLT_ATM_RFC1483 { atm_if_read, DLT_ATM_RFC1483 }, #endif { sl_if_print, DLT_SLIP }, { ppp_if_read, DLT_PPP }, #ifdef DLT_PPP_BSDOS { ppp_bsdos_if_read, DLT_PPP_BSDOS }, #endif #ifdef DLT_PPP_SERIAL /* netbsd specific */ { ppp_netbsd_serial_if_read, DLT_PPP_SERIAL }, #endif { null_if_read, DLT_NULL }, #ifdef DLT_RAW { raw_if_read, DLT_RAW }, #endif { NULL, 0 }, }; static pcap_handler lookup_printer(int type) { struct printer *p; for (p = printers; p->f; ++p) if (type == p->type) return p->f; fatal_error("lookup_printer: unknown data link type 0x%x", type); /* NOTREACHED */ return NULL; } int open_pf(char *interface) { int snaplen, fd; struct bpf_program fcode; u_int localnet, netmask; struct in_addr inaddr; if (interface == NULL) { device = pcap_lookupdev(errbuf); if (device == NULL) fatal_error(errbuf); } else device = interface; printf("packet filter: using device %s\n", device); snaplen = DEFAULT_SNAPLEN; pd = pcap_open_live(device, snaplen, 1, 0, errbuf); if (pd == NULL) fatal_error(errbuf); if (pcap_lookupnet(device, &localnet, &netmask, errbuf) < 0) fatal_error(errbuf); netname_init(localnet, netmask); inaddr.s_addr = localnet; printf("local network is %s", inet_ntoa(inaddr)); inaddr.s_addr = netmask; printf(" netmask is %s\n", inet_ntoa(inaddr)); /* * Let user own process after socket has been opened. */ setuid(getuid()); #ifdef notyet /* bpfcode not yet supported */ if (pcap_compile(pd, &fcode, cmdbuf, 1, localnetmask.s_addr) < 0) fatal_error(pcap_geterr(pd)); if (pcap_setfilter(pd, &fcode) < 0) fatal_error(pcap_geterr(pd)); #endif /* noyet */ ttt_netreader = lookup_printer(pcap_datalink(pd)); fd = pcap_fileno(pd); #if defined(BSD) && defined(BPF_MAXBUFSIZE) { /* check the buffer size */ u_int bufsize; if (ioctl(fd, BIOCGBLEN, (caddr_t)&bufsize) < 0) perror("BIOCGBLEN"); else printf("bpf buffer size is %d\n", bufsize); } #endif /* BSD */ return fd; } void close_pf(void) { pcap_close(pd); } int open_dump(char *file, char *interface) { int fd; struct bpf_program fcode; u_int localnet, netmask; struct in_addr inaddr; printf("packet filter: using dump file %s\n", file); pd = pcap_open_offline(file, errbuf); if (pd == NULL) fatal_error(errbuf); /* try to get local network address to print host names */ localnet = 0; netmask = 0xffffffff; if (interface == NULL) { device = pcap_lookupdev(errbuf); } else device = interface; if (device != NULL) (void)pcap_lookupnet(device, &localnet, &netmask, errbuf); netname_init(localnet, netmask); inaddr.s_addr = localnet; printf("local network is %s", inet_ntoa(inaddr)); inaddr.s_addr = netmask; printf(" netmask is %s\n", inet_ntoa(inaddr)); #ifdef notyet /* bpfcode not yet supported */ if (pcap_compile(pd, &fcode, cmdbuf, 1, localnetmask.s_addr) < 0) fatal_error(pcap_geterr(pd)); if (pcap_setfilter(pd, &fcode) < 0) fatal_error(pcap_geterr(pd)); #endif /* noyet */ ttt_netreader = lookup_printer(pcap_datalink(pd)); fd = fileno(pcap_file(pd)); return fd; } int get_pcapstat(u_long *recvp, u_long *dropp, u_long *lostp) { struct pcap_stat pc_stat; if (pcap_stats(pd, &pc_stat) == 0) { *recvp = pc_stat.ps_recv; *dropp = pc_stat.ps_drop; *lostp = 0; /* no lost report for ttt */ return 0; } return (-1); } ttt-1.7.orig/node.c0100644000273700007640000004047107220141163013037 0ustar scheffedv/* $Id: node.c,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* node mudule: each node keeps total packet size of the corresponding protocol or host during a time interval. implementation requiremets: (1) quick search by its id. for each incoming packet, the corresponding node should be searched by its id. (2) quick search by size order. after each interval cycle, nodes should be sorted by size. (3) I don't want to clear all nodes at the end of each interval. so, I decided to implement the node structure as a combination of tree and list. (1) nodes are stored in a binary tree by its id. (2) nodes are also stored in lists sorted by its size. the size table holds 32 bucket heads for log2(size). (3) a node which has old timestatmp gets cleared only when it is accessed. for each incoming packet, the corresponding node is binary searched by its id, and then, the node is pulled from the size list, added the packet size and stored back to the size list. kjc@csl.sony.co.jp 96/06/11 */ #include #include #include #include "ttt.h" #include "ttt_node.h" #define SIZETAB_SIZE (sizeof(int)*8) #ifdef IPV6 static long minus_one[4] = {-1, -1, -1, -1}; #else static long minus_one[1] = {-1}; #endif /* 2 independent tables for protocol-info and host-info */ static struct t_node size_tab[2][SIZETAB_SIZE]; /* macro to select protocol-table or host-table */ #define TYPE2TAB(type) ((type) >= TTTTYPE_HOST) #define NODE2TAB(np) TYPE2TAB((np)->t_type) static int current_time = 0; static int nodes_allocated[2]; #ifdef NODE_DEBUG static int node_in_use = 0; #endif /* private function prototypes */ static void t_init(void); static void t_remtree(struct t_node *node); static struct t_node *t_newnode(struct t_node *parent, long type, long *id); static void t_deletenode(struct t_node *np); static void t_makefree(int tab_no); static struct t_node *t_findnode(struct t_node *root, long type, long *id); static int b_alloc_nodes(int tab_no, int n); static void b_init_tab(void); static void b_resettime (struct t_node *np); static int b_addsize(struct t_node *np, int delta); static void b_insbucket(struct t_node *np); static void b_insq(struct t_node *prev, struct t_node *np); static struct t_node *b_remq(struct t_node *np); struct t_node *b_getbiggest(int tab_no); struct t_node *b_getnext(struct t_node *np); static int b_collectgarbage(int tab_no); static int b_countfree(int tab_no); static struct t_node *b_getfree(int tab_no); static int fls(int i); #ifdef IPV6 static int node_comp_id(long *a, long *b); #endif #ifdef NODE_DEBUG static void dumptree(struct t_node *root); #endif void node_init(void) { t_init(); } /* discard all nodes */ void node_cleanup(void) { int tab_no; struct t_node *np; for (tab_no=0; tab_no<2; tab_no++) while ((np = b_getfree(tab_no)) != NULL) t_deletenode(np); } struct t_node *node_getbiggest(long type) { return b_getbiggest(TYPE2TAB(type)); } struct t_node *node_getnext(struct t_node *np) { return b_getnext(np); } struct t_node *node_findnode(struct t_node *root, long type, long *id) { return t_findnode(root, type, id); } int node_addsize(struct t_node *np, int delta) { return b_addsize(np, delta); } struct t_node *node_createroot(long type) { struct t_node *np; np = t_newnode(NULL, type, minus_one); b_remq(np); /* remove the root node from size_tab */ #ifdef NODE_DEBUG np->t_bigger = np->t_smaller = np; #endif return np; } void node_destroyroot(struct t_node *root) { int tab_no = NODE2TAB(root); assert(root->t_left == NULL && root->t_right == NULL); free(root); --nodes_allocated[tab_no]; #ifdef NODE_DEBUG printf("node_destroyroot: total nodes=%d for tab[%d]\n", nodes_allocated[tab_no], tab_no); #endif } void node_bumptime(void) { current_time++; /* do garbage collection every 5 minutes */ if ((current_time % 300) == 0) node_collectgarbage(); } void node_collectgarbage(void) { int tab_no, n, i; struct t_node *np; for (tab_no=0; tab_no<2; tab_no++) { n = b_collectgarbage(tab_no); /* count the nodes on the free list. if more than 100 nodes are free, keep 50 and discard the rest. */ n = b_countfree(tab_no); if (n > 100) { #ifdef NODE_DEBUG printf("[debug] too much nodes. discard %d nodes\n", n-50); #endif for (i=0; it_parent); assert(np != np->t_left); assert(np != np->t_right); if (np->t_parent == NULL) { /* don't remove root */ printf("t_remtree: try to remove root!\n"); return; } if (np->t_left == NULL || np->t_right == NULL) victim = np; else { /* the node has two children. we have to find its successor */ victim = np->t_right; while (victim->t_left != NULL) victim = victim->t_left; assert(COMP_ID(np->t_id, victim->t_id) < 0); } /* victim has at most one child. just make a new link between its parent and child. */ if (victim->t_left != NULL) { child = victim->t_left; assert(victim->t_right == NULL); } else child = victim->t_right; if (child != NULL) child->t_parent = victim->t_parent; if (victim == victim->t_parent->t_left) victim->t_parent->t_left = child; else { assert(victim == victim->t_parent->t_right); victim->t_parent->t_right = child; } if (victim != np) { /* replace node with its successor */ victim->t_parent = np->t_parent; if (np == np->t_parent->t_left) np->t_parent->t_left = victim; else { assert(np == np->t_parent->t_right); np->t_parent->t_right = victim; } if ((victim->t_left = np->t_left) != NULL) np->t_left->t_parent = victim; if ((victim->t_right = np->t_right) != NULL) np->t_right->t_parent = victim; } np->t_parent = np->t_left = np->t_right = NULL; #ifdef NODE_DEBUG --node_in_use; #endif } /* make sure that the node at the tail of the size 0 bucket is not in the tree. */ static void t_makefree(int tab_no) { struct t_node *head; int n; head = &size_tab[tab_no][0]; if (head->t_bigger == head) { static int too_few_nodes; /* the size 0 bucket is empty */ n = b_collectgarbage(tab_no); if (n == 1) { /* we are running out of free nodes */ too_few_nodes++; if (too_few_nodes > 30 && nodes_allocated[tab_no] < ttt_max_nodes) { /* too few nodes available */ b_alloc_nodes(tab_no, 50); #ifdef NODE_DEBUG printf("[debug] too few nodes. allocated another 50 nodes\n"); printf("\ttotal nodes=%d for %s tab\n", nodes_allocated[tab_no], (tab_no?"proto":"host")); if (nodes_allocated[tab_no] >= ttt_max_nodes) { printf("!total nodes[%d] for %s tab hit the limit[%d]!\n", nodes_allocated[tab_no],(tab_no?"proto":"host"), ttt_max_nodes); } #endif } } else too_few_nodes = 0; } assert (head->t_bigger != head); if (head->t_bigger->t_parent != NULL) t_remtree(head->t_bigger); } static struct t_node *t_newnode(struct t_node *parent, long type, long *id) { struct t_node *np; np = b_getfree(TYPE2TAB(type)); assert(np->t_parent == NULL && np->t_left == NULL && np->t_right == NULL); np->t_parent = parent; np->t_type = type; np->t_id[0] = id[0]; #ifdef IPV6 np->t_id[1] = id[1]; np->t_id[2] = id[2]; np->t_id[3] = id[3]; #endif #ifdef NODE_DEBUG node_in_use++; #endif return np; } static void t_deletenode(struct t_node *np) { /* first remove from the size table. then, if it's on the tree, remove it from the binary tree */ int tab_no = NODE2TAB(np); b_remq(np); if (np->t_parent != NULL) t_remtree(np); free(np); --nodes_allocated[tab_no]; } /* look up the node by id in the binary tree. if a node doesn't exist, create one. */ static struct t_node *t_findnode(struct t_node *root, long type, long *id) { struct t_node *np = root; /* make sure we have at least one free node before we start tree-search.*/ t_makefree(TYPE2TAB(type)); while (!ISSAME_ID(np->t_id, id)) { if (COMP_ID(np->t_id, id) > 0) { if (np->t_left == NULL) { np->t_left = t_newnode(np, type, id); return np->t_left; } np = np->t_left; } else { if (np->t_right == NULL) { np->t_right = t_newnode(np, type, id); return np->t_right; } np = np->t_right; } } /* found */ if (np == root) { /* special case for root. we don't use the root node since removing the root node is trickier than this. */ if (root->t_left == NULL) { root->t_left = t_newnode(np, type, id); return root->t_left; } else if (ISSAME_ID(root->t_left->t_id, id)) { /* this avoids recursive root match */ return root->t_left; } else return t_findnode(root->t_left, type, id); } return np; } /* size bucket implementation: the size bucket keeps all the items by size order. each bucket head "size_tab[i][n]" holds items whose log2(size) is "n-1". bucket_head[0] -- 0 -- 0 -- free -- free bucket_head[1] | bucket_head[7] -- 124 -- 98 bucket_head[8] -- 255 -- 190 -- 154 | bucket_head[20] -- (1M-n)(byte) | bucket_head[31] */ #define B_INSFREEQ(tab_no, np) b_insq((&size_tab[tab_no][0]), np) static int b_alloc_nodes(int tab_no, int n) { struct t_node *np; int i; for (i=0; it_type = (tab_no == 0) ? TTTTYPE_PROTO : TTTTYPE_HOST; B_INSFREEQ(tab_no, np); } nodes_allocated[tab_no] += n; return 0; } #define T_INIT_NODES 100 static void b_init_tab(void) { struct t_node *np; int tab_no, i; long type; /* init size tables */ for (tab_no=0; tab_no<2; tab_no++) { type = (tab_no == 0) ? TTTTYPE_PROTO : TTTTYPE_HOST; for (i=0; it_bigger = np->t_smaller = np; np->t_size = -1; np->t_type = type; } /* allocate nodes */ b_alloc_nodes(tab_no, T_INIT_NODES); } } static void b_resettime(struct t_node *np) { np->t_time = current_time; if (np->t_size != 0) { b_remq(np); np->t_size = 0; B_INSFREEQ(NODE2TAB(np), np); } } static int b_addsize(struct t_node *np, int delta) { b_remq(np); if (np->t_time != current_time) { /* size is obsolete, clear the size */ np->t_size = 0; np->t_time = current_time; } np->t_size += delta; assert(np->t_size >= 0); b_insbucket(np); return np->t_size; } static void b_insbucket(struct t_node *np) { struct t_node *head, *prev; head = &size_tab[NODE2TAB(np)][fls(np->t_size)]; for (prev = head; prev->t_smaller != head; prev = prev->t_smaller) if (prev->t_smaller->t_size <= np->t_size) break; b_insq(prev, np); } static void b_insq(struct t_node *prev, struct t_node *np) { np->t_bigger = prev; np->t_smaller = prev->t_smaller; prev->t_smaller = np; np->t_smaller->t_bigger = np; } static struct t_node *b_remq(struct t_node *np) { assert(np->t_size >= 0); np->t_bigger->t_smaller = np->t_smaller; np->t_smaller->t_bigger = np->t_bigger; return np; } struct t_node *b_getbiggest(int tab_no) { return b_getnext(&size_tab[tab_no][SIZETAB_SIZE-1]); } struct t_node *b_getnext(struct t_node *np) { while (1) { while (np->t_smaller->t_size == -1) { /* smaller node must be a bucket head. go down to the smaller size. */ np = np->t_smaller - 1; if (np == &size_tab[NODE2TAB(np)][0]) { /* we came down all the way to the bucket size 0. */ return NULL; } assert(np >= &size_tab[NODE2TAB(np)][0] && np <= &size_tab[NODE2TAB(np)][31]); } if (np->t_smaller->t_time != current_time) { /* this entry is obsolete. reset its time and size. since b_resettime removes the node from the bucket, we have to check t_smaller again. */ b_resettime(np->t_smaller); continue; } return np->t_smaller; } } static int b_collectgarbage(int tab_no) { struct t_node *head, *np; int i, n, limit; n = 0; limit = current_time - 20; /* 20 sec */ for (i=1; it_bigger != head) { if (np->t_bigger->t_time < limit) { b_resettime(np->t_bigger); n++; continue; } np = np->t_bigger; } } if (n == 0) { /* no node expired. we should guarantee at least one node is free. */ np = b_getfree(tab_no); n++; } return n; } /* return the count of free nodes */ static int b_countfree(int tab_no) { struct t_node *head, *np; int n = 0; head = &size_tab[tab_no][0]; for (np = head->t_bigger; np != head; np = np->t_bigger) n++; return n; } /* reallocate the smallest node as a free node */ static struct t_node *b_getfree(int tab_no) { struct t_node *np; np = &size_tab[tab_no][0]; if (np->t_bigger != np) return np->t_bigger; /* size 0 bucket is empty. get the smallest node and put it on the size 0 bucket. */ while (np->t_bigger == np) { if (np == &size_tab[tab_no][31]) { #ifdef NODE_DEBUG printf("size table[%d]: empty! total nodes=%d\n", tab_no, nodes_allocated[tab_no]); #endif return NULL; } np = np + 1; assert(np >= &size_tab[tab_no][1] && np <= &size_tab[tab_no][31]); } np = np->t_bigger; assert(np->t_size >= 0); b_resettime(np); assert(size_tab[tab_no][0].t_bigger == np); return np; } /* fls - find last set bit --- reverse function of vax ffs */ static int fls(int i) { int index; assert(i >= 0); if (i == 0) return 0; index = 32; while ((i & 0xff000000) == 0) { index -= 8; i <<= 8; } do { if (i & 0x80000000) { assert(index < 32); return index; } i <<= 1; } while (--index); assert(0); return 0; } static int node_comp_id(long *a, long *b) { #ifdef IPV6 if (a[0] == b[0]) { if (a[1] == b[1]) { if (a[2] == b[2]) { if (a[3] == b[3]) return 0; else if (a[3] < b[3]) return (-1); else return (1); } else if (a[2] < b[2]) return (-1); else return (1); } else if (a[1] < b[1]) return (-1); else return (1); } else if (a[0] < b[0]) return (-1); else return (1); #else if (a < b) return (-1); if (a == b) return 0; return (1); #endif } #ifdef NODE_DEBUG static void dumptree(struct t_node *root) { struct t_node *np = root; struct t_node *last = NULL; int n = 0, up = 0; while (1) { printf("node[%d][0x%x] type[%d] id[%6d] left[%x] right[%x] p[%x]\n", n, np, np->t_type, np->t_id[0], np->t_left, np->t_right, np->t_parent); if (np->t_left != NULL && up == 0) { last = np; np = np->t_left; } else if (np->t_right != NULL && np->t_right != last) { last = np; np = np->t_right; up = 0; } else { last = np; np = np->t_parent; up = 1; if (np->t_parent == NULL) { printf("dump abnormal end\n"); break; } } n++; if (np == root && (np->t_right == NULL || np->t_right == last)) { printf("dump end\n"); break; } } } #endif /* NODE_DEBUG */ ttt-1.7.orig/node_emu.c0100644000273700007640000000234507220141163013703 0ustar scheffedv/* $Id: node_emu.c,v 0.1 1996/06/30 12:52:56 kjc Exp $ */ /* node_emu.c -- dummy routines of node.c used by viewers */ #include #include "ttt.h" #include "ttt_node.h" static int nhosts, nprotos, rhosts, rprotos; static struct t_node node_tab[2][30]; void node_bumptime(void) { nprotos = nhosts = 0; } void node_record(long type, long *id, int size) { struct t_node *np; if (type < TTTTYPE_HOST) { if (nprotos >= 30) return; np = &node_tab[0][nprotos++]; } else { if (nhosts >= 30) return; np = &node_tab[1][nhosts++]; } np->t_type = type; np->t_size = size; np->t_id[0] = id[0]; #ifdef IPV6 np->t_id[1] = id[1]; np->t_id[2] = id[2]; np->t_id[3] = id[3]; #endif } struct t_node *node_getbiggest(long type) { if (type < TTTTYPE_HOST) { if (nprotos == 0) return NULL; rprotos = 1; return &node_tab[0][0]; } else { if (nhosts == 0) return NULL; rhosts = 1; return &node_tab[1][0]; } } struct t_node *node_getnext(struct t_node *np) { if (np->t_type < TTTTYPE_HOST) { if (rprotos >= nprotos) return NULL; return &node_tab[0][rprotos++]; } else { if (rhosts >= nhosts) return NULL; return &node_tab[1][rhosts++]; } } ttt-1.7.orig/pcap_inet.c0100644000273700007640000001354107220141163014052 0ustar scheffedv/* $Id: pcap_inet.c,v 0.4 1998/07/08 13:17:09 kjc Exp $ */ /* completely derived from libpcap in order that viewers can be compiled without libpcap installed. */ /* * Copyright (c) 1994 * 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 Computer Systems * Engineering Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory 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. */ #include #include #include #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #include #include #include #include #include #include #include #include #include /* Not all systems have IFF_LOOPBACK */ #ifdef IFF_LOOPBACK #define ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK) #else #define ISLOOPBACK(p) ((p)->ifr_name[0] == 'l' && (p)->ifr_name[1] == 'o' && \ (isdigit((p)->ifr_name[2]) || (p)->ifr_name[2] == '\0')) #endif #define pcap_strerror(errno) strerror(errno) /* * Return the name of a network interface attached to the system, or NULL * if none can be found. The interface must be configured up; the * lowest unit number is preferred; loopback is ignored. */ char * pcap_lookupdev(errbuf) register char *errbuf; { register int fd, minunit, n; register char *cp; register struct ifreq *ifrp, *ifend, *ifnext, *mp; struct ifconf ifc; struct ifreq ibuf[16], ifr; static char device[sizeof(ifrp->ifr_name) + 1]; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { (void)sprintf(errbuf, "socket: %s", pcap_strerror(errno)); return (NULL); } ifc.ifc_len = sizeof ibuf; ifc.ifc_buf = (caddr_t)ibuf; if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 || ifc.ifc_len < sizeof(struct ifreq)) { (void)sprintf(errbuf, "SIOCGIFCONF: %s", pcap_strerror(errno)); (void)close(fd); return (NULL); } ifrp = ibuf; ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len); mp = NULL; minunit = 666; for (; ifrp < ifend; ifrp = ifnext) { #if BSD - 0 >= 199006 n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name); if (n < sizeof(*ifrp)) ifnext = ifrp + 1; else ifnext = (struct ifreq *)((char *)ifrp + n); if (ifrp->ifr_addr.sa_family != AF_INET) continue; #else ifnext = ifrp + 1; #endif /* * Need a template to preserve address info that is * used below to locate the next entry. (Otherwise, * SIOCGIFFLAGS stomps over it because the requests * are returned in a union.) */ strncpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { (void)sprintf(errbuf, "SIOCGIFFLAGS: %s", pcap_strerror(errno)); (void)close(fd); return (NULL); } /* Must be up and not the loopback */ if ((ifr.ifr_flags & IFF_UP) == 0 || ISLOOPBACK(&ifr)) continue; for (cp = ifrp->ifr_name; !isdigit(*cp); ++cp) continue; n = atoi(cp); if (n < minunit) { minunit = n; mp = ifrp; } } (void)close(fd); if (mp == NULL) { (void)strcpy(errbuf, "no suitable device found"); return (NULL); } (void)strncpy(device, mp->ifr_name, sizeof(device) - 1); device[sizeof(device) - 1] = '\0'; return (device); } int pcap_lookupnet(device, netp, maskp, errbuf) register char *device; register u_int *netp, *maskp; register char *errbuf; { register int fd; register struct sockaddr_in *sin; struct ifreq ifr; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { (void)sprintf(errbuf, "socket: %s", pcap_strerror(errno)); return (-1); } (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { (void)sprintf(errbuf, "SIOCGIFADDR: %s: %s", device, pcap_strerror(errno)); (void)close(fd); return (-1); } sin = (struct sockaddr_in *)&ifr.ifr_addr; *netp = sin->sin_addr.s_addr; if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) { (void)sprintf(errbuf, "SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno)); (void)close(fd); return (-1); } (void)close(fd); *maskp = sin->sin_addr.s_addr; if (*maskp == 0) { if (IN_CLASSA(*netp)) *maskp = IN_CLASSA_NET; else if (IN_CLASSB(*netp)) *maskp = IN_CLASSB_NET; else if (IN_CLASSC(*netp)) *maskp = IN_CLASSC_NET; else { (void)sprintf(errbuf, "inet class for 0x%x unknown", *netp); return (-1); } } *netp &= *maskp; return (0); } ttt-1.7.orig/probe.c0100644000273700007640000002053607220141164013222 0ustar scheffedv/* $Id: probe.c,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* probe.c -- a probe program main module for remote-monitoring. */ #include #include #include #include #include #include #include #include "ttt.h" #include "ttt_node.h" #include "ttt_remote.h" #include extern pcap_t *pd; extern void (*ttt_netreader)(u_char *user, const struct pcap_pkthdr *h, const u_char *p); static int sockfd; static struct sockaddr_in view_addr; static u_long f_localnet, f_netmask; static void probe_loop(int pcapfd, int sock_fd); static int send_report(int sock_fd, int seq_no, struct timeval *tvp); static int write_record(struct t_node *np, struct ttt_record *trp); static void probe_cleanup(void); /* a net_subr compatible procudure just to save localnet address */ void netname_init(u_long netaddr, u_long netmask) { /* save localnet address and netmask */ f_localnet = netaddr; f_netmask = netmask; } static void usage(void) { printf("usage: probe [options] dest\n"); printf(" or probe [options] -multicast\n"); printf(" options:\n"); printf(" [-interface device]\n"); printf(" [-port dest_port]\n"); printf(" [-ttl time-to-live]\n"); printf(" [-interval msec]\n"); exit(1); } int main(int argc, char **argv) { struct sockaddr_in my_addr; int pcapfd; u_char ttl = 1; /* time-to-live field for mcast */ int port_no = TTT_PORT; /* receiver's port number */ int multicast = 0; /* use multicast */ char *view_name = NULL; char *my_name = NULL; while (--argc > 0) { if (strcmp(*++argv, "-interface") == 0 && --argc > 0) ttt_interface = *++argv; else if (strncmp(*argv, "-multicast", 4) == 0) view_name = TTT_MCASTADDR; else if (strncmp(*argv, "-port", 4) == 0 && --argc > 0) port_no = atoi(*++argv); else if (strcmp(*argv, "-interval") == 0 && --argc > 0) ttt_interval = atoi(*++argv); else if (strcmp(*argv, "-ttl") == 0 && --argc > 0) ttl = atoi(*++argv); else if (view_name == NULL) view_name = *argv; else usage(); } if (view_name == NULL) { printf("no destination specified!\n"); usage(); } if (name2sockaddrin(my_name, 0, &my_addr) < 0) fatal_error("can't get my address!"); if (name2sockaddrin(view_name, port_no, &view_addr) < 0) fatal_error("can't get viewer's address!"); #ifdef IN_MULTICAST if (IN_MULTICAST(ntohl(view_addr.sin_addr.s_addr))) multicast = 1; #endif if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) fatal_error("sender: can't open socket"); #ifdef IP_MULTICAST_TTL if (multicast && ttl != 1) if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) fatal_error("can't set ttl"); #endif if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(my_addr)) < 0) fatal_error("sender: can't bind"); netacc_init(); pcapfd = open_pf(ttt_interface); printf("probe started. sending to %s:%d ....\n", inet_ntoa(view_addr.sin_addr), port_no); probe_loop(pcapfd, sockfd); /* never returns */ probe_cleanup(); return 0; } static void probe_cleanup(void) { close(sockfd); close_pf(); netacc_cleanup(); } #define BUFFER_SIZE 4096 /* big enough */ static char buffer[BUFFER_SIZE]; /* timeval macros from Xt */ #define ADD_TIME(dest, src1, src2) { \ if(((dest).tv_usec = (src1).tv_usec + (src2).tv_usec) >= 1000000) {\ (dest).tv_usec -= 1000000;\ (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1 ; \ } else { (dest).tv_sec = (src1).tv_sec + (src2).tv_sec ; \ if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \ (dest).tv_sec --;(dest).tv_usec += 1000000; } } } #define TIMEDELTA(dest, src1, src2) { \ if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) {\ (dest).tv_usec += 1000000;\ (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1;\ } else (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; } #define IS_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec > (t1).tv_usec))) #define IS_AT_OR_AFTER(t1, t2) (((t2).tv_sec > (t1).tv_sec) \ || (((t2).tv_sec == (t1).tv_sec)&& ((t2).tv_usec >= (t1).tv_usec))) static void probe_loop(int pcapfd, int sock_fd) { struct timeval cur_time, wait_time, expr_time, interval; fd_set rmaskfd; int seq_no, nfound; interval.tv_sec = ttt_interval/1000; interval.tv_usec = (ttt_interval%1000)*1000; (void) gettimeofday(&cur_time, NULL); ADD_TIME(expr_time, cur_time, interval); seq_no = 1; while (1) { (void) gettimeofday(&cur_time, NULL); /* check time to send a ttt report */ if (IS_AT_OR_AFTER(expr_time, cur_time)) { if (send_report(sockfd, seq_no, &cur_time) > 0) seq_no++; ADD_TIME(expr_time, cur_time, interval); } wait_time.tv_sec = wait_time.tv_usec = 0; TIMEDELTA(wait_time, expr_time, cur_time); FD_ZERO(&rmaskfd); FD_SET(pcapfd, &rmaskfd); nfound = select(pcapfd+1, &rmaskfd, NULL, NULL, &wait_time); if (nfound == -1) { /* interrupt occured recalculate time value and select again. */ perror("select"); continue; } if (FD_ISSET(pcapfd, &rmaskfd)) { if (pcap_dispatch(pd, 1, ttt_netreader, 0) < 0) (void)fprintf(stderr, "pcap_dispatch:%s\n", pcap_geterr(pd)); } } } /* create a report packet and send it out */ static int send_report(int sock_fd, int seq_no, struct timeval *tvp) { struct ttt_hdr *hdr; int protos, hosts, rsize, rval; char *cp; struct t_node *np; struct pcap_stat pc_stat; static int last_sent = 1; /* how many records sent last time. initial value 1 is to send first packet */ hdr = (struct ttt_hdr *)buffer; hdr->th_magic = htons(TTT_MAGIC); hdr->th_version = htons((TTT_MAJOR<<8) | TTT_MINOR); hdr->th_network = f_localnet; hdr->th_seqno = htonl(seq_no); hdr->th_tvsec = htonl(tvp->tv_sec); hdr->th_tvusec = htonl(tvp->tv_usec); /* get pcap statistics */ if (pcap_stats(pd, &pc_stat) == 0) { hdr->th_recvpkts = htonl(pc_stat.ps_recv); hdr->th_droppkts = htonl(pc_stat.ps_drop); } else { hdr->th_recvpkts = 0; hdr->th_droppkts = 0; } /* get the top 10 traffic of this interval. */ cp = buffer + sizeof(struct ttt_hdr); for (protos=0, np = node_getbiggest(TTTTYPE_PROTO); protos<10 && np != NULL; protos++, np = node_getnext(np)) { rsize = write_record(np, (struct ttt_record *)cp); cp += rsize; } for (hosts=0, np = node_getbiggest(TTTTYPE_HOST); hosts<10 && np != NULL; hosts++, np = node_getnext(np)) { rsize = write_record(np, (struct ttt_record *)cp); cp += rsize; } hdr->th_nrecords = htonl(protos + hosts); node_bumptime(); /* give a time tick to the node module */ #if 0 /* if the traffic is this low, why bothering to send a packet? */ if ((protos+hosts) == 0 && last_sent == 0) { /* no traffic, nothing to send */ return 0; } last_sent = protos + hosts; #endif if ((rval = sendto(sock_fd, buffer, cp - buffer, 0, (struct sockaddr *)&view_addr, sizeof(view_addr))) < 0) perror("sendto"); return rval; } /* write node info to ttt_record */ static int write_record(struct t_node *np, struct ttt_record *trp) { struct ttt_record6 *tr6p; if (np->t_type != TTTTYPE_IPV6HOST) { trp->tr_type = htonl(np->t_type); trp->tr_size = htonl(np->t_size); trp->tr_id[0] = htonl(np->t_id[0]); return sizeof(struct ttt_record); } else { tr6p = (struct ttt_record6 *)trp; tr6p->tr_type = htonl(np->t_type); tr6p->tr_size = htonl(np->t_size); tr6p->tr_id[0] = htonl(np->t_id[0]); tr6p->tr_id[1] = htonl(np->t_id[1]); tr6p->tr_id[2] = htonl(np->t_id[2]); tr6p->tr_id[3] = htonl(np->t_id[3]); return sizeof(struct ttt_record6); } } ttt-1.7.orig/relay.c0100644000273700007640000002526207220141165013231 0ustar scheffedv/* $Id: relay.c,v 0.4 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* a standalone tool to relay ttt packets */ #include #include #include #include #include #include #include #include /* for address family independent socket address structure */ union sockunion { struct sockinet { u_char si_len; u_char si_family; u_short si_port; } su_si; struct sockaddr_in su_sin; #ifdef INET6 struct sockaddr_in6 su_sin6; #endif }; #define su_len su_si.si_len #define su_family su_si.si_family #define su_port su_si.si_port #define TTT_PORT 7288 /* receiver port */ #define BUFFER_SIZE 4096 /* big enough */ static char buffer[BUFFER_SIZE]; int name2sockaddr(char *name, int port, union sockunion *addrp, int family) { unsigned long inaddr; struct hostent *hep; bzero(addrp, sizeof(union sockunion)); #ifdef INET6 { struct addrinfo hints, *res; char portstr[64]; int error; sprintf(portstr, "%d", port); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; if (name == NULL) hints.ai_flags = AI_PASSIVE; if ((error = getaddrinfo(name, portstr, &hints, &res)) != 0) { fprintf(stderr, "can't get addrinfo for %s: %s\n", name, gai_strerror(error)); return (-1); } *addrp = *(union sockunion *)res->ai_addr; freeaddrinfo(res); } #else /* INET6 */ addrp->su_sin.sin_family = AF_INET; addrp->su_sin.sin_len = sizeof(struct sockaddr_in); if (name != NULL) { if ((inaddr = inet_addr(name)) != -1) bcopy(&inaddr, &addrp->su_sin.sin_addr, sizeof(inaddr)); else if ((hep = gethostbyname(name)) != NULL) bcopy(hep->h_addr, &addrp->su_sin.sin_addr, hep->h_length); else return (-1); } else addrp->su_sin.sin_addr.s_addr = htonl(INADDR_ANY); addrp->su_sin.sin_port = htons(port); #endif /* INET6 */ return 0; } int usage() { printf("usage: tttrelay [options] dest\n"); printf(" options:\n"); printf(" [-addr addr]\n"); printf(" [-mcastifaddr addr]\n"); printf(" [-out addr]\n"); printf(" [-port recv_port]\n"); printf(" [-dport dest_port]\n"); printf(" [-probe addr]\n"); printf(" [-mloop {0|1}]\n"); exit(1); } int main(argc, argv) int argc; char **argv; { union sockunion my_addr, probe_addr, view_addr; int in_fd, out_fd; int in_port = TTT_PORT; /* my port number */ int dest_port = TTT_PORT; /* receiver's port number */ char *my_name = NULL; char *out_name = NULL; char *mcastif_name = NULL; char *view_name = NULL; char *probe_name = NULL; int shared_port = 1; u_char ttl = 1; u_char mloop = 0; int in_family = AF_UNSPEC; int out_family = AF_UNSPEC; int packets = 0; const char *ptr; #ifdef INET6 char str[INET6_ADDRSTRLEN]; #else char str[16]; #endif while (--argc > 0) { if (strncmp(*++argv, "-port", 4) == 0 && --argc > 0) in_port = atoi(*++argv); else if (strncmp(*argv, "-addr", 4) == 0 && --argc > 0) my_name = *++argv; else if (strncmp(*argv, "-out", 4) == 0 && --argc > 0) out_name = *++argv; else if (strncmp(*argv, "-mcastifaddr", 4) == 0 && --argc > 0) mcastif_name = *++argv; else if (strncmp(*argv, "-probe", 4) == 0 && --argc > 0) probe_name = *++argv; else if (strncmp(*argv, "-ttl", 4) == 0 && --argc > 0) ttl = atoi(*++argv); else if (strncmp(*argv, "-dport", 4) == 0 && --argc > 0) dest_port = atoi(*++argv); else if (strncmp(*argv, "-mloop", 4) == 0 && --argc > 0) mloop = atoi(*++argv); else if (view_name == NULL) view_name = *argv; else usage(); } if (view_name == NULL) { printf("no destination specified!\n"); usage(); } /* set up input socket */ if (name2sockaddr(my_name, in_port, &my_addr, in_family) < 0) fatal_error("can't get my address!"); if ((in_fd = socket(my_addr.su_family, SOCK_DGRAM, 0)) < 0) fatal_error("can't open socket"); #ifdef IP_ADD_MEMBERSHIP if (my_addr.su_family == AF_INET && IN_MULTICAST(ntohl(my_addr.su_sin.sin_addr.s_addr))) { struct ip_mreq mreq; union sockunion ifaddr; mreq.imr_multiaddr.s_addr = my_addr.su_sin.sin_addr.s_addr; if (mcastif_name == NULL) { mreq.imr_interface.s_addr = htonl(INADDR_ANY); /* use default if */ } else { if (name2sockaddr(mcastif_name, in_port, &ifaddr, AF_INET) < 0) fatal_error("can't get local address!"); mreq.imr_interface.s_addr = ifaddr.su_sin.sin_addr.s_addr; } if (setsockopt(in_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) < 0) fatal_error("can't join group"); printf("joined multicast group: %s\n", my_name); } #endif /* IP_ADD_MEMBERSHIP */ #ifdef INET6 else if (my_addr.su_family == AF_INET6 && IN6_IS_ADDR_MULTICAST(&my_addr.su_sin6.sin6_addr)) { struct ipv6_mreq mreq6; union sockunion ifaddr; mreq6.ipv6mr_multiaddr = my_addr.su_sin6.sin6_addr; if (mcastif_name == NULL) { mreq6.ipv6mr_interface = 0; /* use default if */ } else { if (name2sockaddr(mcastif_name, in_port, &ifaddr, AF_INET6) < 0) fatal_error("can't get local address!"); mreq6.ipv6mr_interface = ifaddr.su_sin6.sin6_ifindex; } if (setsockopt(in_fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&mreq6, sizeof(mreq6)) < 0) fatal_error("can't join group"); printf("joined multicast group: %s\n", view_name); } #endif /* INET6 */ if (shared_port) { int one = 1; if (setsockopt(in_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) fatal_error("can't share the port"); printf("port %d is shared.\n", in_port); } if (bind(in_fd, (struct sockaddr *)&my_addr, my_addr.su_len) < 0) fatal_error("can't bind"); /* set up output socket */ if (name2sockaddr(view_name, dest_port, &view_addr, out_family) < 0) fatal_error("can't get viewer's address!"); if (name2sockaddr(out_name, 0, &my_addr, view_addr.su_family) < 0) fatal_error("can't get my address!"); if ((out_fd = socket(my_addr.su_family, SOCK_DGRAM, 0)) < 0) fatal_error("can't open socket"); #ifdef IP_MULTICAST_TTL if (view_addr.su_family == AF_INET && IN_MULTICAST(ntohl(view_addr.su_sin.sin_addr.s_addr))) { if (ttl != 1) { if (setsockopt(out_fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) fatal_error("can't set ttl"); } #ifdef IP_MULTICAST_LOOP if (setsockopt(out_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &mloop, sizeof(mloop)) < 0) fatal_error("can't disable mcast loop"); #endif } #endif #ifdef INET6 else if (view_addr.su_family == AF_INET6 && IN6_IS_ADDR_MULTICAST(&view_addr.su_sin6.sin6_addr)) { int hops = ttl; u_int loop = mloop; if (hops != 1) { if (setsockopt(out_fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hops, sizeof(hops)) < 0) fatal_error("can't set ttl"); } if (setsockopt(out_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop, sizeof(loop)) < 0) fatal_error("can't disable mcast loop"); } #endif /* INET6 */ if (bind(out_fd, (struct sockaddr *)&my_addr, my_addr.su_len) < 0) fatal_error("can't bind"); switch (view_addr.su_family) { case AF_INET: ptr = inet_ntop(AF_INET, &view_addr.su_sin.sin_addr, str, sizeof(str)); break; #ifdef INET6 case AF_INET6: ptr = inet_ntop(AF_INET6, &view_addr.su_sin6.sin6_addr, str, sizeof(str)); break; #endif } printf("relay started. sending to %s:%d ....\n", ptr, dest_port); if (probe_name != NULL) { if (name2sockaddr(probe_name, 0, &probe_addr, my_addr.su_family) < 0) fatal_error("can't get probe address!"); printf("reading from [%s] ....\n", probe_name); } else bzero(&probe_addr, sizeof(probe_addr)); while (1) { int nbytes, fromlen; union sockunion from_addr; fromlen = sizeof(from_addr); if ((nbytes = recvfrom(in_fd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&from_addr, &fromlen)) == -1) { perror("recvfrom"); continue; } if (probe_addr.su_family == 0) { probe_addr = from_addr; switch (from_addr.su_family) { case AF_INET: ptr = inet_ntop(AF_INET, &from_addr.su_sin.sin_addr, str, sizeof(str)); break; #ifdef INET6 case AF_INET6: ptr = inet_ntop(AF_INET6, &from_addr.su_sin6.sin6_addr, str, sizeof(str)); break; #endif } printf("reading from probe [%s] ....\n", ptr); } /* is this the probe we are reading from? */ if (from_addr.su_family != probe_addr.su_family || (from_addr.su_family == AF_INET && from_addr.su_sin.sin_addr.s_addr != probe_addr.su_sin.sin_addr.s_addr) #ifdef INET6 || (from_addr.su_family == AF_INET6 && (from_addr.su_sin6.sin6_addr.s6_addr32[0] != probe_addr.su_sin6.sin6_addr.s6_addr32[0] || from_addr.su_sin6.sin6_addr.s6_addr32[1] != probe_addr.su_sin6.sin6_addr.s6_addr32[1] || from_addr.su_sin6.sin6_addr.s6_addr32[2] != probe_addr.su_sin6.sin6_addr.s6_addr32[2] || from_addr.su_sin6.sin6_addr.s6_addr32[3] != probe_addr.su_sin6.sin6_addr.s6_addr32[3])) #endif ) { static int warned = 0; if (!warned) { printf("[warning] there are multiple probes.\n"); switch (from_addr.su_family) { case AF_INET: ptr = inet_ntop(AF_INET, &from_addr.su_sin.sin_addr, str, sizeof(str)); break; #ifdef INET6 case AF_INET6: ptr = inet_ntop(AF_INET6, &from_addr.su_sin6.sin6_addr, str, sizeof(str)); break; #endif } printf("\tignoring probe: %s\n", ptr); warned = 1; } continue; } if ((nbytes = sendto(out_fd, buffer, nbytes, 0, (struct sockaddr *)&view_addr, view_addr.su_len)) < 0) perror("sendto"); packets++; #if 1 printf("*"); fflush(stdout); if ((packets % 60) == 0) printf("\n"); #endif } } #include #include fatal_error(va_alist) va_dcl { va_list ap; char *fmt; if (errno != 0) perror("fatal_error"); else fprintf(stderr, "fatal_error: "); va_start(ap); fmt = va_arg(ap, char *); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); exit(1); } ttt-1.7.orig/remote.c0100644000273700007640000000307007220141165013401 0ustar scheffedv/* $Id: remote.c,v 0.3 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* remote.c -- a module common for remote-monitoring */ #include #include #include #include #include #include #include "ttt.h" #include "ttt_remote.h" /* convert a string name to struct sockaddr_in */ int name2sockaddrin(char *name, int port, struct sockaddr_in *addrp) { unsigned long inaddr; struct hostent *hep; bzero(addrp, sizeof(struct sockaddr_in)); addrp->sin_family = PF_INET; if (name != NULL) { if ((inaddr = inet_addr(name)) != -1) bcopy(&inaddr, &addrp->sin_addr, sizeof(inaddr)); else if ((hep = gethostbyname(name)) != NULL) bcopy(hep->h_addr, &addrp->sin_addr, hep->h_length); else return (-1); } else addrp->sin_addr.s_addr = htonl(INADDR_ANY); addrp->sin_port = htons(port); return 0; } ttt-1.7.orig/textview.c0100644000273700007640000000430707220141166013772 0ustar scheffedv/* $Id: textview.c,v 0.3 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* textview.c -- a text-based viewer program. just for debug */ #include #include #include #include #include #include #include "ttt.h" #include "ttt_node.h" #include "ttt_remote.h" static int sockfd; static void cleanup(void); int main(int argc, char **argv) { view_parseargs(argc, argv); sockfd = view_opensock(); while (1) { view_sockread(sockfd, 0); } cleanup(); } static void cleanup(void) { close(sockfd); } void ttt_textview(int seq_no) { struct t_node *np; int i; double cur_time, get_timeindouble(); u_long recvpkts, droppkts, lostpkts; cur_time = get_timeindouble(); printf("ranking at time %.2f\n", cur_time); if (get_pcapstat(&recvpkts, &droppkts, &lostpkts) == 0) printf("pcap stat: recv[%d] drop[%d] ttt report: drop[%d]\n", recvpkts, droppkts, lostpkts); printf("proto ranking"); for (i=0, np = node_getbiggest(TTTTYPE_PROTO); i<10 && np != NULL; i++, np = node_getnext(np)) { printf("rank[%d]: [%d:%6d] size=%d\n", i+1, np->t_type, np->t_id[0], np->t_size); } printf("host ranking\n"); for (i=0, np = node_getbiggest(TTTTYPE_HOST); i<10 && np != NULL; i++, np = node_getnext(np)) { struct in_addr inaddr; inaddr.s_addr = htonl(np->t_id[0]); printf("rank[%d]: [%d:%15s] size=%d\n", i+1, np->t_type, inet_ntoa(inaddr), np->t_size); } printf("\n"); node_bumptime(); } ttt-1.7.orig/tk_ttt.c0100644000273700007640000003160007220141167013421 0ustar scheffedv/* $Id: tk_ttt.c,v 0.8 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* tk_ttt.c -- tcl/tk related module. this module is shared by ttt and tttview but TTT_VIEW flag is set for tttview.*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ttt.h" #include "ttt_tk.h" Tcl_Interp *ttt_interp; /* Interpreter for application. */ static int sockfd; #ifndef TTT_VIEW static Tk_TimerToken timer_token; static Tk_TimerProc call_display; static Tk_TimerProc call_dumpread; #endif void TttCleanup(void); static int TttCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]); static int Ttt_Init(Tcl_Interp *interp); static int Ttt_Init(Tcl_Interp *interp) { char *ttt_dir, *colors; #ifdef TTT_VIEW char *port_no; #else char *interval; #endif char buf[128]; ttt_interp = interp; Tcl_CreateCommand(interp, "ttt", TttCmd, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); /* create labels of graph axis before reading ttt.tcl */ Tcl_SetVar(interp, "ttt_x_label", "Time (sec)", TCL_GLOBAL_ONLY); if (ttt_yscale == 1000000) sprintf(buf, "Traffic (Mbps)"); else if (ttt_yscale == 1000) sprintf(buf, "Traffic (Kbps)"); else sprintf(buf, "Traffic (bps/%d)", ttt_yscale); Tcl_SetVar(interp, "ttt_y_label", buf, TCL_GLOBAL_ONLY); /* read ttt.tcl file: first try the current dir, then, install dir. */ ttt_dir = getenv("TTT_LIBRARY"); if (ttt_dir == NULL) { ttt_dir = TTT_LIBRARY; } if (Tcl_EvalFile(interp, "./ttt.tcl") != TCL_OK) { if (errno == ENOENT) { sprintf(buf, "%s/ttt.tcl", ttt_dir); if (Tcl_EvalFile(interp, buf) != TCL_OK) { printf("error in %s/ttt.tcl: %s\n", ttt_dir, ttt_interp->result); printf("perhaps you need to install TTT\nor set your TTT_LIBRARY environment variable.\n"); exit(1); } } else { printf("error in ./ttt.tcl: %s\n",ttt_interp->result); exit(1); } } /* get ttt variables */ if (colors = Tcl_GetVar(interp, "ttt_colors", TCL_LEAVE_ERR_MSG)) stat_set_colors(colors); if (Tcl_GetVar(interp, "ttt_nohostname", TCL_LEAVE_ERR_MSG) != NULL) ttt_nohostname = 1; #ifdef TTT_VIEW if (port_no = Tcl_GetVar(interp, "ttt_portno", TCL_LEAVE_ERR_MSG)) ttt_portno = atoi(port_no); if (ttt_viewname == NULL) ttt_viewname = Tcl_GetVar(interp, "ttt_viewname", TCL_LEAVE_ERR_MSG); display_init(); wg_init(); sockfd = view_opensock(); Tk_CreateFileHandler(sockfd, TK_READABLE, view_sockread, (ClientData)sockfd); #else /* TTT */ if (ttt_interface == NULL) ttt_interface = Tcl_GetVar(interp, "ttt_interface", TCL_LEAVE_ERR_MSG); if (interval = Tcl_GetVar(interp, "ttt_interval", TCL_LEAVE_ERR_MSG)) ttt_interval = atoi(interval); display_init(); netacc_init(); wg_init(); if (ttt_dumpfile == NULL) { sockfd = open_pf(ttt_interface); Tk_CreateFileHandler(sockfd, TK_READABLE, net_read, (ClientData)sockfd); timer_token = Tk_CreateTimerHandler(2000, call_display, 0); } else { /* replay tcpdump file */ sockfd = open_dump(ttt_dumpfile, ttt_interface); timer_token = Tk_CreateTimerHandler(2000, call_dumpread, 0); } #endif /* !TTT_VIEW */ /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ #if (TCL_MAJOR_VERSION >= 8) || ((TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION >= 5)) Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); #else tcl_RcFileName = "~/.wishrc"; #endif return TCL_OK; } void TttCleanup(void) { #ifdef TTT_VIEW Tk_DeleteFileHandler(sockfd); view_closesock(sockfd); wg_cleanup(); #else /* !TTT_VIEW */ Tk_DeleteTimerHandler(timer_token); Tk_DeleteFileHandler(sockfd); close_pf(); wg_cleanup(); netacc_cleanup(); #endif /* !TTT_VIEW */ } #ifndef TTT_VIEW /* wrapper to call display routine */ void call_display(ClientData client_data) { int time_tick = (int)client_data; ttt_display(time_tick); timer_token = Tk_CreateTimerHandler(ttt_interval, call_display, (ClientData)(time_tick+1)); } void call_dumpread(ClientData client_data) { int time_tick = (int)client_data; int interval, rval; rval = dumpfile_read(); ttt_display(time_tick); if (rval > 0) { if (ttt_speed == 0) interval = 0; else interval = ttt_interval / ttt_speed; timer_token = Tk_CreateTimerHandler(interval, call_dumpread, (ClientData)(time_tick+1)); } } #endif /* !TTT_VIEW */ static int TttCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { if (argc == 1) return TCL_OK; if (strcmp(argv[1], "cleanup") == 0) { TttCleanup(); interp->result = "ttt cleanup"; return TCL_OK; } else if (strcmp(argv[1], "set") == 0) { if (strcmp(argv[2], "interval") == 0) { ttt_interval = atoi(argv[3]); interp->result = argv[3]; return TCL_OK; } else if (strcmp(argv[2], "nohostname") == 0) { ttt_nohostname = atoi(argv[3]); interp->result = argv[3]; return TCL_OK; } } else if (strcmp(argv[1], "get") == 0) { char buf[128]; if (strcmp(argv[2], "interval") == 0) { sprintf(buf, "%d", ttt_interval); interp->result = buf; return TCL_OK; } else if (strcmp(argv[2], "nohostname") == 0) { sprintf(buf, "%d", ttt_nohostname); interp->result = buf; return TCL_OK; } } else if (strcmp(argv[1], "filter") == 0) { if (strcmp(argv[2], "src") == 0) { ttt_filter |= TTTFILTER_SRCHOST; interp->result = "src hosts filtered out"; return TCL_OK; } else if (strcmp(argv[2], "dst") == 0) { ttt_filter |= TTTFILTER_DSTHOST; interp->result = "dst hosts filtered out"; return TCL_OK; } else if (strcmp(argv[2], "sport") == 0) { ttt_filter |= TTTFILTER_SRCPORT; interp->result = "src ports filtered out"; return TCL_OK; } else if (strcmp(argv[2], "dport") == 0) { ttt_filter |= TTTFILTER_DSTPORT; interp->result = "dst ports filtered out"; return TCL_OK; } } else if (strcmp(argv[1], "unfilter") == 0) { if (strcmp(argv[2], "src") == 0) { ttt_filter &= ~TTTFILTER_SRCHOST; interp->result = "unfilter src hosts"; return TCL_OK; } else if (strcmp(argv[2], "dst") == 0) { ttt_filter &= ~TTTFILTER_DSTHOST; interp->result = "unfilter dst hosts"; return TCL_OK; } else if (strcmp(argv[2], "sport") == 0) { ttt_filter &= ~TTTFILTER_SRCPORT; interp->result = "unfilter src ports"; return TCL_OK; } else if (strcmp(argv[2], "dport") == 0) { ttt_filter &= ~TTTFILTER_DSTPORT; interp->result = "unfilter dst ports"; return TCL_OK; } } interp->result = "ttt # bad args"; return TCL_ERROR; } /* show string at the bottom of the graph widget */ int ttt_showmessage(char *string) { char buf[128]; sprintf(buf, "set ttt_message {%s}", string); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) { printf("showmessage: %s\n", ttt_interp->result); return (-1); } return 0; } /* show stat info */ int ttt_showstat(u_long recvpkts, u_long droppkts, u_long report_drop) { char buf[128]; static recved, dropped, report_dropped; if (recvpkts != recved) { sprintf(buf, "set ttt_packets %d", recvpkts); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) { printf("showstat: %s\n", ttt_interp->result); return (-1); } recved = recvpkts; } if (droppkts != dropped) { sprintf(buf, "set ttt_drops %d", droppkts); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) { printf("showstat: %s\n", ttt_interp->result); return (-1); } dropped = droppkts; } if (report_drop != report_dropped) { sprintf(buf, "set ttt_reportdrops %d", report_drop); if (Tcl_GlobalEval(ttt_interp, buf) != TCL_OK) { printf("showstat: %s\n", ttt_interp->result); return (-1); } report_dropped = report_drop; } return 0; } #include "tk.h" #include "blt.h" #if !defined(TTT_VERSION) /* not required for ttt */ #include "src/bltConfig.h" #endif #if (TK_MAJOR_VERSION > 3) #if HAVE_ITCL_H #include "itcl.h" #endif #if HAVE_ITK_H #include "itk.h" #endif #endif #if (TK_MAJOR_VERSION > 3) /* * The following variable is a special hack that is needed in order for * Sun shared libraries to be used for Tcl. */ #ifdef NEED_MATHERR extern int matherr(); int *tclDummyMathPtr = (int *) matherr; #endif /* *---------------------------------------------------------------------- * * main -- * * This is the main program for the application. * * Results: * None: Tk_Main never returns here, so this procedure never * returns either. * * Side effects: * Whatever the application does. * *---------------------------------------------------------------------- */ extern int Blt_Init _ANSI_ARGS_((Tcl_Interp *interp)); extern int Blt_SafeInit _ANSI_ARGS_((Tcl_Interp *interp)); extern int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); int main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Vector of command-line arguments. */ { #if defined(TTT_VERSION) /* process ttt options */ #ifndef TTT_VIEW ttt_parseargs(argc, argv); #else /* !TTT_VIEW */ view_parseargs(argc, argv); #endif /* !TTT_VIEW */ #endif Tk_Main(argc, argv, Tcl_AppInit); return 0; /* Needed only to prevent compiler warning. */ } #else /* * The following variable is a special hack that allows applications * to be linked using the procedure "main" from the Tk library. The * variable generates a reference to "main", which causes main to * be brought in from the library (and all of Tk and Tcl with it). */ extern int main(); int *tclDummyMainPtr = (int *) main; #endif /* TK_MAJOR_VERSION >= 4 */ /* *---------------------------------------------------------------------- * * Tcl_AppInit -- * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional * packages, will have their own version of this procedure. * * Results: * Returns a standard Tcl completion code, and leaves an error * message in interp->result if an error occurs. * * Side effects: * Depends on the startup script. * *---------------------------------------------------------------------- */ int Tcl_AppInit(interp) Tcl_Interp *interp; /* Interpreter for application. */ { if (Tcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Tk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } /* * Call the init procedures for included packages. Each call should * look like this: * * if (Mod_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * where "Mod" is the name of the module. */ #if defined(ITCL_MAJOR_VERSION) && (ITCL_MAJOR_VERSION == 2) if (Itcl_Init(interp) == TCL_ERROR) { return TCL_ERROR; } if (Itk_Init(interp) == TCL_ERROR) { return TCL_ERROR; } #endif if (Blt_Init(interp) == TCL_ERROR) { return TCL_ERROR; } #if (BLT_MAJOR_VERSION == 2) && (BLT_MINOR_VERSION == 1) /* no Blt_SafeInit */ #else Tcl_StaticPackage(interp, "BLT", Blt_Init, Blt_SafeInit); #endif if (Ttt_Init(interp) == TCL_ERROR) { return TCL_ERROR; } /* * Call Tcl_CreateCommand for application-specific commands, if * they weren't already created by the init procedures called above. */ /* * Specify a user-specific startup file to invoke if the application * is run interactively. Typically the startup file is "~/.apprc" * where "app" is the name of the application. If this line is deleted * then no user-specific startup file will be run under any conditions. */ #if (TCL_MAJOR_VERSION >= 8) || ((TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION >= 5)) Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); #else tcl_RcFileName = "~/.wishrc"; #endif return TCL_OK; } ttt-1.7.orig/ttt.c0100644000273700007640000000516207555410021012726 0ustar scheffedv/* $Id: ttt.c,v 0.8 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* ttt.c -- ttt stand alone program main module */ #include #include #include #include #include #include "ttt.h" static void usage(void) { printf("usage: ttt [options]\n"); printf(" options:\n"); printf(" [-interface device]\n"); printf(" [-interval ms]\n"); printf(" [-dumpfile filename [-speed N]]\n"); printf(" [-filter filter_value]\n"); printf(" [-yscale 'K'|'M'|n]\n"); exit(1); } void ttt_parseargs(int argc, char **argv) { int i; for (i=1; i #define TTT_MAJOR 1 #define TTT_MINOR 7 #define TTT_VERSION "1.7" /* default path for ttt.tcl */ #ifndef TTT_LIBRARY #define TTT_LIBRARY "/usr/local/lib/ttt" #endif /* uncommnet the following line not to lookup hostnames. */ /* * #define DONT_LOOKUP_HOSTNAME */ /* ttt protocol types */ #define TTTTYPE_PROTO 0 /* wild card for protocol type */ #define TTTTYPE_ETHER 1 #define TTTTYPE_FDDI 2 #define TTTTYPE_IP 8 #define TTTTYPE_TCP 16 #define TTTTYPE_UDP 17 #define TTTTYPE_IPV6 32 #define TTTTYPE_UDPV6 40 #define TTTTYPE_TCPV6 41 /* all protocols should be below TTTTYPE_HOST */ /* ttt host types */ #define TTTTYPE_HOST 128 /* wild card for host type */ #define TTTTYPE_IPHOST 129 #define TTTTYPE_IPV6HOST 130 /* trace filter */ #define TTTFILTER_SRCHOST 0x01 #define TTTFILTER_DSTHOST 0x02 #define TTTFILTER_SRCPORT 0x04 #define TTTFILTER_DSTPORT 0x08 /* for remote monitoring */ #define TTT_PORT 7288 /* receiver port */ #define TTT_MCASTADDR "224.8.8.0" /* default multicast address */ /* parameters */ #define TTT_MAX_NODES 1000 /* globals */ extern char *ttt_version; extern int ttt_interval; /* graph update interval in ms */ extern char *ttt_interface; /* interface name for packet capture */ extern int ttt_max_nodes; /* limit of max nodes */ extern char *ttt_viewname; /* view address */ extern char *ttt_mcastif; /* multicast interface address */ extern int ttt_portno; /* viewer's port number */ extern int ttt_nohostname; /* don't lookup host names */ extern int ttt_filter; /* trace filter */ extern char *ttt_dumpfile; /* tcpdump file to replay */ extern int ttt_speed; /* replay speed */ extern int ttt_yscale; /* scale of y axis */ extern struct timeval ttt_dumptime; extern void fatal_error(/*const char *fmt, ...*/); /* function prototypes */ /* ttt.c */ extern void ttt_parseargs(int argc, char **argv); extern double get_timeindouble(void); /* display.c */ extern void display_init(void); extern void ttt_display(int time_tick); /* net_names.c */ extern void netname_init(unsigned long netaddr, unsigned long netmask); extern char *net_getname(long type, long *id); /* net_read.c */ extern int open_pf(char *interface); extern void close_pf(void); extern int open_dump(char *file, char *interface); extern int get_pcapstat(u_long *recvp, u_long *dropp, u_long *lostp); extern int dumpfile_read(void); /* viewer.c */ extern int view_opensock(void); extern void view_closesock(int sockfd); /* int get_pcapstat(u_long *recvp, u_long *dropp, u_long *lostp); */ /* textview.c */ extern void ttt_textview(int seq_no); /* endian defines in case they are missing from the system headers */ #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 #define LITTLE_ENDIAN 1234 #endif #ifndef BYTE_ORDER #if defined(_BIG_ENDIAN) || defined(sparc) #define BYTE_ORDER BIG_ENDIAN #endif #if defined(_LITTLE_ENDIAN) || defined(i386) #define BYTE_ORDER LITTLE_ENDIAN #endif #endif /* BYTE_ORDER */ #endif /* _TTT_H_ */ ttt-1.7.orig/README0100644000273700007640000004410607555237123012642 0ustar scheffedv TTT: Tele Traffic Tapper (version 1.7) 2002/10/22 ttt is yet another descendant of tcpdump but it is capable of real-time, graphical, and remote traffic-monitoring. ttt won't replace tcpdump, rather, it helps you find out what to look into with tcpdump. Features: - Automatic Ranking of Protocols and Hosts: ttt monitors the network and automatically picks up the main contributors of the traffic within the time window (60 sec by default). You can see the behavior of the traffic of the past 60 seconds. The graphs are updated every second by default. ttt presents two separate graphs in a window. One for a protocol breakdown and the other for an ip-host breakdown. By doing this, you can tell from the graphs something like "hey, the traffic jumps up! host A and host B are talking over ftp." - Real-Time Monitoring: The key mechanism of ttt is the real-time traffic ranking. The scheme is twofold: (1) 1st stage: For each interval (1 sec by default), ttt adds up the packet length of each protocol and host within the interval. At the end of the interval, the top 10 contributors are picked up by both protocol and host. (2) 2nd stage: ttt keeps track of the ranking by the peak traffic within the time window (60 sec by default), and updates the top 6 in the auto-scaled graphs at every interval. - Remote Monitoring with IP-Multicast support: Because the 1st stage process reduces the traffic information to a minimum, the output of the 1st stage can be transferred over the network to a remote host and the 2nd stage process can be done at the remote host. The max packet size is 272 bytes. With the 1 sec default interval, it takes about 2Kbps, which would be negligible for most LAN settings and would be acceptable even for WAN settings. The ttt traffic can be reduced further with a longer interval. It's my intension to make ttt a useful tool to monitor heavily- congested backbone networks from my desktop. ttt uses UDP to send the traffic info and supports IP-Multicast. If you install a ttt probe with multicast, a group of people can see the traffic graph on his/her own desktop. (yes, you don't need to be a "root" to see the graph any more!) - IPv6 Aware: ttt knows about IPv6 packets. For example, an IPv6 host name is shown like "fe80::0800:2001:a237" and a ftp over IPv6 is shown as "ftp-data/ip6". When you enable the IPv6 option, the system takes a bit more memory to keep 128-bit IPv6 addresses. - Portable: ttt uses two portable libraries for packet-capturing and graph-drawing, and ttt itself is fairly portable. For packet capturing, "libpcap" of tcpdump from Lawrence Berkeley Laboratory is used. For auto-scale graphs, "libBLT" for Tcl/Tk from AT&T Bell Laboratories is used. So, if you already have tcpdump and Tcl/Tk on your machine, there would be no problem to install ttt. - Easy to customize: Many network administrators have their own requirements. Customizing ttt to trace some specific protocol would be straightforward. (so, I have skipped analysis of apple talk, decnet, osi, etc.) Also, since GUI part is based on Tcl/Tk, you can set parameters from a Tcl script, or you can set some parameters afterwards from Tcl Shell. Currently, ttt understands ethernet frame, llc/snap frame of 802.3, FDDI, ppp and ATM. - Can read tcpdump output: ttt can replay traffic trace produced by "tcpdump -w". Installing TTT: Getting the source code: http://www.csl.sony.co.jp/person/kjc/software.html or ftp://ftp.csl.sony.co.jp/pub/kjc/ttt-1.6.tar.gz First, you have to install "libpcap" and "libBLT (2.4 recommended)" (and, of course, Tcl/Tk). Those are placed in the ttt distribution directory at SonyCSL or they can be found at: http://www.tcpdump.org/ http://www.tcltk.com/blt/ I myself is currently using libpcap-0.7.1 and blt2.4u with Tcl8.3 and Tk8.3 on FreeBSD-4.7. libpcap is available for most platforms. (it comes with tcpdump.) This release has been compiled and tested with versions: Tcl 7.5 / Tk 4.1 Tcl 7.6 / Tk 4.2 Tcl/Tk 8.0.2 thru 8.0.5 Tcl/Tk 8.1.0 thru 8.1.1 Tcl/Tk 8.2.0 thru 8.2.3 Tcl/Tk 8.3.0 thru 8.3.1 Building TTT: Run ./configure By default, the ttt files are installed in "/usr/local/{bin,lib/ttt,man}". use "--prefix=path" to change the install directory. available switches are: --with-tcl=DIR --with-tk=DIR --with-blt=DIR --with-pcap=DIR --with-cc=CC --enable-ipv6, --disable-ipv6 Then, just type "make". It will create 3 programs. ttt -- a standalone traffic monitor program. tttprobe -- a network probe program for remote-monitoring. tttview -- a viewer program for remote-monitoring You can create other tools manually: tttrelay -- a program which just relays ttt packets, which might be useful when you have a probe behind a firewall or to bridge multicast-capable networks. ttttextview -- a text based viewer for debugging. Running TTT: To run "ttt" or "tttprobe", you must be a "root" for most systems since only root is allowed to access the network filter device. To run "ttt", just type "./ttt" in the ttt directory, a window with two graphs will pop up. You need to be in the ttt directory since some scripts are required in the current directory. To specify an interface to monitor, use "-interface ". To see the throughput in Kbps, use "-yscale K". To disable auto-scale of y-axis, see the comments in ttt.tcl. To do remote-monitoring, run a probe on one machine by typing "./tttprobe hostname" where the hostname is the name of the other machine. On the remote machine, just type "./tttview". To use multicast, use "./tttprobe -multi" and "./tttview -multi" instead. Command Line Options: (I haven't made man pages yet. So I include the brief explanations here.) ttt [options] possible options are: [-interface device] specifies the interface for packet capture. if not specified, the default interface is chosen. only useful when there are more than two interfaces. [-interval ms] sets the interval in msec. the default is 1000 msec. [-dumpfile file [-speed N]] use a dumpfile (produced by "tcpdump -w") as input. the speed option specifies the acceleration factor of the replay speed. [-yscale 'K'|'M'|n] change the scale of y-axis. 'K' and 'M' represent 1000 and 1000000 respectively. tttprobe [options] [dest] [dest] specifies the remote host (viewer). dest may be a multicast address. dest should be specified unless -multicast is specified. possible options are: [-interface device] specifies the interface for packet capture. if not specified, the default interface is chosen. only useful when there are more than two interfaces. [-multicast] shorthand for the default multicast dest. equivalent to "224.8.8.0" [-port dest_port] specifies the udp port number of the remote host. the default is 7288. [-ttl time-to-live] specifies the time-to-live for multicast. the default is 1. (subnet local) [-interval ms] specifies the report interval in msec. the default is 1000 msec. tttview [options] (NOTE: command options do not work with Tk version 3.x) possible options are: [-addr recv_addr] specifies the local address. addr may be a multicast address. if not specified, the default address is chosen. only useful for multicast address. [-mcastifaddr addr] specifies the multicast interface address. only useful when you select an interface to join a multicast group. [-port recv_port] specifies the udp port to receive the report. the default is 7288. [-multicast] shorthand for the default multicast address. equivalent to "-addr 224.8.8.0" [-probe addr] specifies the address of a probe. only useful to select one among multiple probes. [-yscale 'K'|'M'|n] change the scale of y-axis. 'K' and 'M' represent 1000 and 1000000 respectively. ttttextview [options] possible options are: [-addr recv_addr] specifies the local address. addr may be a multicast address. if not specified, the default address is chosen. only useful for multicast address. [-mcastifaddr addr] specifies the multicast interface address. only useful when you select an interface to join a multicast group. [-port recv_port] specifies the udp port to receive the report. the default is 7288. [-multicast] shorthand for the default multicast address. equivalent to "-addr 224.8.8.0" [-probe addr] specifies the address of a probe. only useful to select one among multiple probes. tttrelay [option] dest dest specifies the receiver (viewer). dest may be a multicast address. possible options are: [-addr addr] specifies the local address. addr may be a multicast address. if not specified, the default address is chosen. only useful for multicast address. [-mcastifaddr addr] specifies the multicast interface address. only useful when you select an interface to join a multicast group. [-port recv_port] specifies the udp port to receive the report. the default is 7288. [-probe addr] specifies the address of a probe. only useful to select one among multiple probes. Examples: point-to-point monitoring: when you run a probe on hostA and a viewer on hostB: [hostA]# tttprobe hostB [hostB]% tttview you can also use dotted ip address for A. [hostA]# tttprobe 43.27.98.80 multicast: when using the default multicast address: [hostA]# tttprobe -multi [hostB]% tttview -multi this is equivalent to [hostA]# tttprobe 224.8.8.0 [hostB]% tttview -addr 224.8.8.0 to set the interval to 3 sec. [hostA]# tttprobe -interval 3000 hostB to specify interface "ef1": [hostA]# tttprobe -interface ef1 hostB relaying packets: if hostA can't talk to hostB directly, but hostC can reach both hostA and hostB: [hostA]# tttprobe hostC [hostC]% tttrelay hostB [hostB]% tttview multicast relay: [hostA]# tttprobe -multi [hostC]% tttrelay -addr 224.8.8.0 hostD [hostD]% tttrelay 224.8.8.0 [hostB]% tttview -multi if you are getting paranoid on long-latency: [hostA]# tttprobe -port 6000 hostB [hostB]% tttrelay -port 6000 hostA -dport 6001 [hostA]% tttrelay -port 6001 hostB -dport 6001 ........... [hostB]% tttrelay -port 6008 hostA -dport 6009 [hostA]% tttrelay -port 6009 hostB -dport 6009 [hostB]% tttview -addr 6009 Tcl vars: ttt and tttview read a tcl script "ttt.tcl" at startup. you can set some parameters in this file. if the following tcl variables are set, they are read as ttt parameters. ttt_colors: colors to use. ttt_nohostname: no hostname translation. (ttt only) ttt_interface: packet capture interface device. ttt_interval: interval in msec. (tttview only) ttt_portno: udp port number to receive ttt reports. ttt_viewname: my address to receive ttt reports. (same as -addr option) also you can change some parameters from Tcl Shell of "ttt" and "tttview" as a ttt command. currently, only interval (ttt only) and no hostname translation are supported. examples: % ttt get interval 1000 % ttt set interval 3000 3000 % ttt get nohostname 0 % ttt set nohostname 1 1 How to read graphs: The basic rule of the protocol breakdown is that when ttt does further breakdown, ttt doesn't show the parent protocol. For example, ttt shows "icmp/ip" but not "udp/ip" since udp is further decomposed to udp services. One exception is "ip/ether" which is a good indicator of the total traffic. (why not using the total ethernet frames? currently, the underlying systems do not report consistent information other than IP. for now, using the IP traffic seems to be much better.) For the IP traffic, src and dest are ORed. Thus, when you see two hosts have same traffic pattern, it is most likely that those two talk to each other. Similarly, when you see two protocols (e.g. nfsd/udp and 1023/udp) have same traffic pattern, they are most likely the server and the client. You can filter out src hosts or dst hosts from tcl shell. % ttt filter src % ttt filter dst % ttt unfilter src % ttt unfilter dst tcp/udp service names are read into the internal tables at the startup. If your system supports gethostent(3) and HAVE_GETHOSTENT is set for compilation, host names are also read at the startup. Pcap stat line shows the capture status from "libpcap", "recv" means how many packets are received by the packet filter and "drop" means how many packets are dropped in the kernel. Ttt stat reports how many reports are lost. Packet Capture Performance: The biggest problem seems to be the performance of the packet filter. If the traffic seems too low, it is likely that the kernel drops packets before ttt gets them. If the kernel drops too many packets, try to increase the buffer size of the packet filter. Send bug reports, suggestions, etc. to kjc@csl.sony.co.jp Kenjiro Cho Sony Computer Science Laboratories, Inc. WIDE Project CHANGES: 02/10/22 set "-D_BSD_SOURCE" for linux, which eliminates the use of tcpdump headers. 01/12/15 net_read.c: add DLT_RAW support submitted by Jean-Daniel PAUGET 01/01/05 net_read.c: fix a length check bug in ip_read() 00/12/23 configure.in: add /usr/pkg to search path for netbsd 00/12/21 version 1.6 update copyright: - 1996 -> 1996-2000 - Sony Computer Science Laboratory --> Laboratories 00/12/20 yscale support to display throughput in Kbps also requested by hubertf@netbsd.org add comment in ttt.tcl on how to disable auto-scale 00/12/16 net_read.c: - additional ppp dlt types DLT_PPP_BSDOS /* bsd/os specific */ DLT_PPP_SERIAL /* netbsd specific */ - add 802.1Q and PPPoE support requested by hubertf@netbsd.org ttt_ipv6.h, net_names.c: resolve ipv6 related conflicts in linux report by Shashidhar Patil 00/06/09 version-1.5 always use link level packet size to record traffic. 00/04/24 support tcl-8.2/tk-8.2. change the compiler optimization flag from O6 to O2. 00/01/05 net_read.c: check the total length field in the ip header. we found illegal values in our traffic traces which causes assertion in b_addsize to fail. 98/04/12 version-1.4 99/04/12 support BLT2.4h (autoconf checks libBLT24.a as well as libBLT.a) 99/02/08 make autoconf more linux-friendly 98/09/22 version-1.3 98/09/21 add a function to read tcpdump output. configure.in: add "-ldl" for solaris. tk_ttt.c: support BLT2.4[ef] by providing missing prototypes. 98/07/15 version-1.2 fix duplicated byte counting for fragmented UDP. fix to make net_read.c compiled under FreeBSD's new queue macros. 98/07/09 version-1.1 98/07/08 add autoconf support (finally!) make it default to lookup hostnames. to disable it, uncomment DONT_LOOKUP_HOSTNAME in ttt.h. 98/07/07 add BLT2.4, tcl8.0/tk8.0 support. contributed by Kimio Ishii . the graphs can scale with BLT2.4! but compile option "-fwritable-strings" is required. 98/04/03 make this release 1.0. 98/03/06 fix IPv6 option header handling; hlen shows (entries - 1) not byte-count. 98/03/03 merge viewer fixes from cbqmonitor. comment out cursor functions in ttt.tcl; they are a bit annoying. 97/10/17 version-0.4.1 add man pages add BLT2.3 support make ttt installable by "make install". (no major change in the code.) 97/08/17 version-0.4 add simple ipv4 fragment support. 97/05/14 version-0.3 minor update (no major change in the code.) 96/09/02 version-0.2 first public release COPYRIGHT: /* * Copyright (c) 1996 * Sony Computer Science Laboratory Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ part of the source code is derived from other sources (mostly from tcpdump), and copyrighted by the following notices. /* * Copyright (c) 1990, 1991, 1992, 1993, 1994 * 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: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * Copyright (c) 1994 Bell Communications Research Inc. (Bellcore). * * Permission to use, copy, modify and distribute this material for any * purpose and without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, * and the name of Bellcore not be used in advertising or publicity * pertaining to this material without the specific, prior written * permission of an authorized representative of Bellcore. BELLCORE * MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS MATERIAL * FOR ANY PURPOSE. IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES. */ ttt-1.7.orig/TODO0100644000273700007640000000066206212474056012446 0ustar scheffedv - check default address of viewer default multicast address default port number - rewrite node.c simple binary trees and 32-entry size-tables are too inefficient for backbone networks. use heap-sort or balanced-tree. - ip fragmentation: current version supports only udp. WISH-LIST: - bar graph support - it would be nice if the system can be configured hierarchically and the total traffic of subnets can be displayed. ttt-1.7.orig/ttt.tcl0100755000273700007640000001444107555233171013302 0ustar scheffedv#!/usr/local/bin/bltwish -f # # ttt variables # ### set interface to use #set ttt_interface "le0" ### set colors to use #set ttt_colors "red green blue cyan magenta yellow" ### set interval in milli second #set ttt_interval 2000 ### set no host name translation #set ttt_nohostname 1 ### set udp port number #set ttt_portno 6544 ### set address #set ttt_viewaddr 224.6.6.6 ### set labels of graph axis #set ttt_x_label = "Time (sec)" #set ttt_y_label = "Traffic (Mbps)" # # set blt library path # if { [file exists /usr/local/blt/lib/blt2.1] } { global blt_library set blt_library /usr/local/blt/lib/blt2.1 } if { [file exists /usr/local/lib/blt2.4] } { global blt_library set blt_library /usr/local/lib/blt2.4 } global auto_path lappend auto_path $blt_library # Try to import the blt namespace into the global scope. If it # fails, we'll assume BLT was loaded into the global scope. if { $tcl_version >= 8.0 } { catch {namespace import blt::*} } else { catch { import add blt } } # Add a binding for convenience to let you exit with pressing # the "quit" button. wm protocol . WM_DELETE_WINDOW { DoExit 0 } bind all { DoExit 0 } bind all { DoExit 0 } focus . proc DoExit { code } { exit $code } if { [info commands "namespace"] == "namespace" } { if { $tcl_version >= 8.0 } { catch {namespace import -force blt::tile::*} } else { catch { import add blt::tile } } } else { foreach cmd { button checkbutton radiobutton frame label scrollbar toplevel menubutton listbox } { if { [info command tile${cmd}] == "tile${cmd}" } { rename ${cmd} "" rename tile${cmd} ${cmd} } } } #image create photo bgTexture -file ./bitmaps/rain.gif #option add *Graph.Tile bgTexture #option add *Label.Tile bgTexture #option add *Frame.Tile bgTexture #option add *Htext.Tile bgTexture option add *TileOffset 0 option add *HighlightThickness 0 option add *takeFocus yes set visual [winfo screenvisual .] if { $visual != "staticgray" } { option add *print.background yellow option add *quit.background red } proc FormatLabel { w value } { puts stderr "tick is $value" return $value } frame .f set remote {} set graph .graph set graph2 .graph2 set num 0 graph $graph -title "Protocol Breakdown" -bufferelements false -plotbackground gray90 $graph xaxis configure \ -loose 1 \ -title $ttt_x_label $graph yaxis configure \ -title $ttt_y_label # to disable auto scale, specify the range by "-min" and "-max" # $graph yaxis configure -title $ttt_y_label -min 0 -max 5 $graph legend configure \ -activerelief sunken \ -background "" graph $graph2 -title "Host Breakdown" -bufferelements false -plotbackground gray90 $graph2 xaxis configure \ -loose 1 \ -title $ttt_x_label $graph2 yaxis configure \ -title $ttt_y_label # to disable auto scale, specify the range by "-min" and "-max" # $graph2 yaxis configure -title $ttt_y_label -min 0 -max 5 $graph2 legend configure \ -activerelief sunken \ -background "" htext .footer -text {\ Hit the %% button $htext(widget).quit -text quit -command { send [winfo name .] {ttt cleanup} catch "send GraphConfig after 1 exit" exit } $htext(widget) append $htext(widget).quit %% button when you've seen enough. To create postscript files "/tmp/{proto_*, host_*}.ps", press the %% button $htext(widget).print -text print -command { .graph postscript output "/tmp/proto_${num}.ps" \ -maxpect 1 -landscape 0 -center 1 -decorations 0 .graph2 postscript output "/tmp/host_${num}.ps" \ -maxpect 1 -landscape 0 -center 1 -decorations 0 incr num } $htext(widget) append $htext(widget).print %% button.} # vectors X:time P:protocols H:hosts if { $blt_version == 2.1 } { vector X vector P0 P1 P2 P3 P4 P5 vector H0 H1 H2 H3 H4 H5 } else { # blt_version >= 2.3 vector create X -variable "" for { set i 0 } { $i <= 5 } {incr i } { vector create P${i} -variable "" vector create H${i} -variable "" } } $graph element create p0 -xdata X -ydata P0 \ -symbol none -label "" -color red $graph element create p1 -xdata X -ydata P1 \ -symbol none -label "" -color green -dashes { 8 4 } $graph element create p2 -xdata X -ydata P2 \ -symbol none -label "" -color blue -dashes { 5 4 } $graph element create p3 -xdata X -ydata P3 \ -symbol none -label "" -color orange -dashes { 3 5 } $graph element create p4 -xdata X -ydata P4 \ -symbol none -label "" -color purple -dashes { 3 6 } $graph element create p5 -xdata X -ydata P5 \ -symbol none -label "" -color yellow -dashes { 2 9 } $graph2 element create h0 -xdata X -ydata H0 \ -symbol none -label "" -color red $graph2 element create h1 -xdata X -ydata H1 \ -symbol none -label "" -color green -dashes { 8 4 } $graph2 element create h2 -xdata X -ydata H2 \ -symbol none -label "" -color blue -dashes { 5 4 } $graph2 element create h3 -xdata X -ydata H3 \ -symbol none -label "" -color orange -dashes { 3 5 } $graph2 element create h4 -xdata X -ydata H4 \ -symbol none -label "" -color purple -dashes { 3 6 } $graph2 element create h5 -xdata X -ydata H5 \ -symbol none -label "" -color yellow -dashes { 2 8 } # capture stat: set ttt_packets "0" set ttt_drops "0" set ttt_reportdrops "0" label .packets -textvariable ttt_packets label .drops -textvariable ttt_drops label .reportdrops -textvariable ttt_reportdrops htext .stat -text {\ pcap stat: recv [ %% label $htext(widget).packets -textvariable ttt_packets $htext(widget) append $htext(widget).packets \ %%] \ drop [ %% label $htext(widget).drops -textvariable ttt_drops $htext(widget) append $htext(widget).drops \ %%] ttt report: lost [ %% label $htext(widget).reportdrops -textvariable ttt_reportdrops $htext(widget) append $htext(widget).reportdrops \ %%] \ } # ttt message shown at the bottom of the window set ttt_message "" label .bottomlabel -textvariable ttt_message -fg yellow table .f \ .graph 0,0 \ .graph2 1,0 \ .stat 2,0 -padx 20 \ .footer 4,0 -padx 20 \ .bottomlabel 5,0 -padx 30 table configure .f .graph .graph2 .stat \ .footer .bottomlabel -fill both table . .f -fill both wm min . 0 0 #Blt_ZoomStack $graph #Blt_Crosshairs $graph #Blt_ActiveLegend $graph #Blt_ClosestPoint $graph #Blt_ZoomStack $graph2 #Blt_Crosshairs $graph2 #Blt_ActiveLegend $graph2 #Blt_ClosestPoint $graph2 ttt-1.7.orig/ttt_account.h0100644000273700007640000000111507220141170014434 0ustar scheffedv/* $Id: ttt_account.h,v 0.1 1996/06/30 12:52:32 kjc Exp $ */ #ifndef _TTT_ACCOUNT_H_ #define _TTT_ACCOUNT_H_ void netacc_init(void); void netacc_cleanup(void); int eth_addsize(int etype, int pkt_len); int ip_addsize(int proto, int pkt_len); int udp_addsize(int port, int pkt_len); int tcp_addsize(int port, int pkt_len); int host_addsize(u_long addr, int pkt_len); #ifdef IPV6 int ipv6_addsize(int proto, int pkt_len); int udpv6_addsize(int port, int pkt_len); int tcpv6_addsize(int port, int pkt_len); int hostv6_addsize(u_long *addr, int pkt_len); #endif #endif /* _TTT_ACCOUNT_H_ */ ttt-1.7.orig/ttt_ipv6.h0100644000273700007640000000375107220141171013675 0ustar scheffedv/* $Id: ttt_ipv6.h,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* ttt_ipv6.h -- minimum defines and data structures to understand ipv6 packets */ #ifndef ETHERTYPE_IPV6 #define ETHERTYPE_IPV6 0x86dd #endif #ifndef IPPROTO_IPV6 #define IPPROTO_IPV6 41 /* IPv6 encapsulated in IP */ #define IPPROTO_ICMPV6 58 /* ICMP for IPv6 */ #endif /* !IPPROTO_IPV6 */ #ifndef INET6_ADDRSTRLEN /* * IPv6 address data structures. */ struct in6_addr { u_char s6_addr[16]; /* IPv6 address */ }; #endif /* !INET6_ADDRSTRLEN */ #ifndef IPV6_NH_HOP #define IPV6_NH_HOP 0 /* Hop-by-hop option header */ #define IPV6_NH_RT 43 /* Routing header */ #define IPV6_NH_FRAG 44 /* Fragment header */ #define IPV6_NH_ESP 50 /* Encapsulated Security Payload */ #define IPV6_NH_AUTH 51 /* Authentication header */ #define IPV6_NH_NONH 59 /* No next header */ #define IPV6_NH_DST 60 /* Destination option header */ #endif /* IPV6_NH_HOP */ #if !defined(IPV6VERSION) && (IPVERSION != 6) /* * IPv6 code by keiiti-s@is.aist-nara.ac.jp * $Id: ttt_ipv6.h,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ #define IPV6VERSION 6 struct ipv6 { union { #if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN) u_long i6vpf_v:4, /* version */ i6vpf_pri:4, /* priority */ i6vpf_flbl:24; /* flowlabel */ #endif #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) u_long i6vpf_flbl:24, /* flowlabel */ i6vpf_v:4, /* version */ i6vpf_pri:4; /* priority */ #endif u_long i6vpf_head; /* version, priority and flowlabel */ } ipv6_vpf; u_short ipv6_len; /* payload length */ u_char ipv6_nh; /* next header */ u_char ipv6_hlim; /* hop limit */ struct in6_addr ipv6_src; /* source address */ struct in6_addr ipv6_dst; /* destination address */ }; #define ipv6_v ipv6_vpf.i6vpf_v #define ipv6_pri ipv6_vpf.i6vpf_pri #define ipv6_flbl ipv6_vpf.i6vpf_flbl #define ipv6_head ipv6_vpf.i6vpf_head struct ipv6_ext { u_char i6ext_nh; u_char i6ext_len; }; #endif /* !defined(IPV6VERSION) && (IPVERSION != 6) */ ttt-1.7.orig/ttt_node.h0100644000273700007640000000424507220141172013736 0ustar scheffedv/* $Id: ttt_node.h,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* ttt_node.h -- node module header */ #ifndef _TTT_NODE_H_ #define _TTT_NODE_H_ /* node structure to hold accounting info */ struct t_node { /* fields for the protocol binary tree */ struct t_node *t_left; struct t_node *t_right; struct t_node *t_parent; long t_type; /* ttt types defined in ttt.h */ #ifdef IPV6 long t_id[4]; /* all id is 16 byte long */ #else long t_id[1]; /* type specific id (e.g. proto number) */ #endif /* fields for the size table */ struct t_node *t_bigger; struct t_node *t_smaller; long t_size; /* total packet size */ long t_time; /* time stamp */ }; #ifdef IPV6 #define ISSAME_ID(a, b) ((a)[0] == (b)[0] && \ (a)[1] == (b)[1] && \ (a)[2] == (b)[2] && \ (a)[3] == (b)[3]) #define COMP_ID(a, b) node_comp_id(a, b) #else #define ISSAME_ID(a, b) ((a)[0] == (b)[0]) #define COMP_ID(a, b) (((a)[0]<(b)[0])?-1:((a)==(b))?0:1) #endif /* public function prototypes */ void node_init(void); void node_cleanup(void); struct t_node *node_createroot(long type); void node_destroyroot(struct t_node *root); int node_addsize(struct t_node *np, int delta); struct t_node *node_findnode(struct t_node *root, long type, long *id); struct t_node *node_getbiggest(long type); struct t_node *node_getnext(struct t_node *np); void node_bumptime(void); void node_collectgarbage(void); void node_record(long type, long *id, int size); /* node_emu only */ #endif /* _TTT_NODE_H_ */ ttt-1.7.orig/cf/0040755000273700007640000000000006544616201012343 5ustar scheffedvttt-1.7.orig/cf/config.sub0100755000273700007640000004544406356024412014334 0ustar scheffedv#! /bin/sh # Configuration validation subroutine script, version 1.1. # Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # 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. if [ x$1 = x ] then echo Configuration name missing. 1>&2 echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 echo "or $0 ALIAS" 1>&2 echo where ALIAS is a recognized configuration type. 1>&2 exit 1 fi # First pass through any local machine types. case $1 in *local*) echo $1 exit 0 ;; *) ;; 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 linux-gnu*) 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) os= basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -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 ;; 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. tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \ | arme[lb] | pyramid \ | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ | alpha | we32k | ns16k | clipper | i370 | sh \ | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \ | pdp11 | mips64el | mips64orion | mips64orionel \ | sparc | sparclet | sparclite | sparc64) basic_machine=$basic_machine-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[3456]86) 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. vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \ | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ | hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* | f301-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-cbm ;; amigados) basic_machine=m68k-cbm os=-amigados ;; amigaunix | amix) basic_machine=m68k-cbm os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [ctj]90-cray) basic_machine=c90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-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 ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; i370-ibm* | ibm*) basic_machine=i370-ibm os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i[3456]86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i[3456]86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i[3456]86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i[3456]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; 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 ;; miniframe) basic_machine=m68000-convergent ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; 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 ;; 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 ;; np1) basic_machine=np1-gould ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5) basic_machine=i586-intel ;; pentiumpro | p6) basic_machine=i686-intel ;; pentium-* | p5-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; k5) # We don't have specific support for AMD's K5 yet, so just call it a Pentium basic_machine=i586-amd ;; nexen) # We don't have specific support for Nexgen yet, so just call it a Pentium basic_machine=i586-nexgen ;; pn) basic_machine=pn-gould ;; power) basic_machine=rs6000-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/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; 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 ;; symmetry) basic_machine=i386-sequent os=-dynix ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; 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 ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; 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. mips) basic_machine=mips-mips ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sparc) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; *) 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 ;; -unixware* | svr4*) os=-sysv4 ;; -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* \ | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -linux-gnu* | -uxpv*) # Remember, each alternative MUST END IN *, to match a version number. ;; -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|'` ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -xenix) os=-xenix ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-semi) os=-aout ;; 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 ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-ibm) os=-aix ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigados ;; *-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 ;; f301-fujitsu) os=-uxpv ;; *) 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 ;; -hpux*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os ttt-1.7.orig/cf/config.guess0100755000273700007640000004762206356024411014670 0ustar scheffedv#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # The master version of this file is at the FSF in /home/gd/gnu/lib. # # 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 system type (host/target name). # # Only a few systems have been added to this list; please add others # (but try to keep the structure clean). # # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) 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 trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in alpha:OSF1:*:*) # 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 alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'` exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-cbm-sysv4 exit 0;; amiga:NetBSD:*:*) echo m68k-cbm-netbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-cbm-openbsd${UNAME_RELEASE} exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:NetBSD:*:*) echo m68k-atari-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-atari-openbsd${UNAME_RELEASE} exit 0 ;; sun3*:NetBSD:*:*) echo m68k-sun-netbsd${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-sun-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:NetBSD:*:*) echo m68k-apple-netbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-apple-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >dummy.c int main (argc, argv) int argc; char **argv; { #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-cc} dummy.c -o dummy \ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i?86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:4) if /usr/sbin/lsattr -EHl proc0 | 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=4.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[3478]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i?86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F300:UNIX_System_V:*:*) FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; F301:UNIX_System_V:*:*) echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; hp3[0-9][05]:OpenBSD:*:*) echo m68k-hp-openbsd${UNAME_RELEASE} exit 0 ;; i?86:BSD/386:*:* | *:BSD/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo i386-pc-cygwin32 exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin32 exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then echo "powerpc-unknown-linux-gnu" ; exit 0 elif test "${UNAME_MACHINE}" = "alpha" ; then echo alpha-unknown-linux-gnu ; exit 0 elif test "${UNAME_MACHINE}" = "sparc" ; then echo sparc-unknown-linux-gnu ; exit 0 else # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us # useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout. test ! -d /usr/lib/ldscripts/. \ && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 # Determine whether the default compiler is a.out or elf cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 rm -f dummy.c dummy fi ;; # 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. i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; i?86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i?86:LynxOS:2.*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; printf ("%s-next-nextstep%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) printf ("vax-dec-bsd\n"); exit (0); #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-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi #echo '(Unable to guess system type)' 1>&2 exit 1 ttt-1.7.orig/cf/ldAix0100755000273700007640000000507706427750346013351 0ustar scheffedv#!/bin/sh # # ldAix ldCmd ldArg ldArg ... # # This shell script provides a wrapper for ld under AIX in order to # create the .exp file required for linking. Its arguments consist # of the name and arguments that would normally be provided to the # ld command. This script extracts the names of the object files # from the argument list, creates a .exp file describing all of the # symbols exported by those files, and then invokes "ldCmd" to # perform the real link. # # SCCS: @(#) ldAix 1.8 97/02/21 14:50:27 # Extract from the arguments the names of all of the object files. args=$* ofiles="" for i do x=`echo $i | grep '[^.].o$'` if test "$x" != ""; then ofiles="$ofiles $i" fi done # Create the export file from all of the object files, using nm followed # by sed editing. Here are some tricky aspects of this: # # 1. Nm produces different output under AIX 4.1 than under AIX 3.2.5; # the following statements handle both versions. # 2. Use the -g switch to nm instead of -e under 4.1 (this shows just # externals, not statics; -g isn't available under 3.2.5, though). # 3. Eliminate lines that end in ":": these are the names of object # files (relevant in 4.1 only). # 4. Eliminate entries with the "U" key letter; these are undefined # symbols (relevant in 4.1 only). # 5. Eliminate lines that contain the string "0|extern" preceded by space; # in 3.2.5, these are undefined symbols (address 0). # 6. Eliminate lines containing the "unamex" symbol. In 3.2.5, these # are also undefined symbols. # 7. If a line starts with ".", delete the leading ".", since this will # just cause confusion later. # 8. Eliminate everything after the first field in a line, so that we're # left with just the symbol name. nmopts="-g -C" osver=`uname -v` if test $osver -eq 3; then nmopts="-e" fi rm -f lib.exp echo "#! " >lib.exp /usr/ccs/bin/nm $nmopts -h $ofiles | sed -e '/:$/d' -e '/ U /d' -e '/[ ]0|extern/d' -e '/unamex/d' -e 's/^\.//' -e 's/[ |].*//' | sort | uniq >>lib.exp # Extract the name of the object file that we're linking. If it's a .a # file, then link all the objects together into a single file "shr.o" # and then put that into the archive. Otherwise link the object files # directly into the .a file. outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'` noDotA=`echo $outputFile | sed -e '/\.a$/d'` echo "noDotA=\"$noDotA\"" if test "$noDotA" = "" ; then linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'` echo $linkArgs eval $linkArgs echo ar cr $outputFile shr.o ar cr $outputFile shr.o rm -f shr.o else eval $args fi ttt-1.7.orig/cf/install-sh0100755000273700007640000001272106356024413014346 0ustar scheffedv#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 ttt-1.7.orig/cf/install.sh0100755000273700007640000001124506353571550014355 0ustar scheffedv#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # 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. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 ttt-1.7.orig/ttt_pcap.h0100644000273700007640000000437507220141172013740 0ustar scheffedv/* $Id: ttt_pcap.h,v 0.1 1996/06/30 12:52:32 kjc Exp $ */ /* ttt_pcap.h -- minimum set from tcpdump to read 802.3 frames */ /* * Copyright (c) 1993, 1994 * 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: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * */ /* from llc.h */ struct llc { u_char dsap; u_char ssap; union { u_char u_ctl; u_short is_ctl; struct { u_char snap_ui; u_char snap_pi[5]; } snap; struct { u_char snap_ui; u_char snap_orgcode[3]; u_char snap_ethertype[2]; } snap_ether; } ctl; }; #define llcui ctl.snap.snap_ui #define ethertype ctl.snap_ether.snap_ethertype #ifndef LLCSAP_SNAP #define LLCSAP_SNAP 0xaa #endif #ifndef LLC_UI #define LLC_UI 0x03 #endif /* * @(#) $Header: /src/kjc/ttt/RCS/ttt_pcap.h,v 0.1 1996/06/30 12:52:32 kjc Exp $ (LBL) */ struct fddi_header { #if defined(ultrix) || defined(__alpha) /* Ultrix pads to make everything line up on a nice boundary */ #define FDDIPAD 3 u_char fddi_ph[FDDIPAD]; #else #define FDDIPAD 0 #endif u_char fddi_fc; /* frame control */ u_char fddi_dhost[6]; u_char fddi_shost[6]; }; #define FDDI_HDRLEN (sizeof(struct fddi_header)) #define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */ #define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */ ttt-1.7.orig/ttt_remote.h0100644000273700007640000000176707220141172014312 0ustar scheffedv/* $Id: ttt_remote.h,v 0.1 1996/06/30 12:52:32 kjc Exp $ */ /* ttt_remote.h -- ttt report protocol packet format. */ #ifndef _TTT_REMOTE_H_ #define _TTT_REMOTE_H_ #define TTT_MAGIC 0x3845 struct ttt_hdr { u_short th_magic; /* magic number */ u_short th_version; /* version no */ u_long th_network; /* network address probed */ u_long th_recvpkts; /* recieved packets of pcap stats */ u_long th_droppkts; /* dropped packets of pcap stats */ long th_seqno; /* sequence number */ long th_nrecords; /* number of records */ long th_tvsec; /* time-stamp (sec) */ long th_tvusec; /* time-stamp (usec) */ /* follows ttt_record array */ }; struct ttt_record { long tr_type; long tr_size; long tr_id[1]; }; /* for ipv6 host type */ struct ttt_record6 { long tr_type; long tr_size; long tr_id[4]; }; extern int name2sockaddrin(char *name, int port, struct sockaddr_in *addrp); extern void view_parseargs(int argc, char **argv); #endif /* _TTT_REMOTE_H_ */ ttt-1.7.orig/ttt_tk.h0100644000273700007640000000076507220141172013432 0ustar scheffedv/* $Id: ttt_tk.h,v 0.1 1996/06/30 12:52:32 kjc Exp $ */ /* ttt_tk.h -- tk-related header */ #ifndef _TTT_TK_H_ #define _TTT_TK_H_ #include "tk.h" #include "blt.h" extern Tcl_Interp *ttt_interp; /* Interpreter for application. */ extern Tk_FileProc net_read; /* read proc for pcap */ extern Tk_FileProc view_sockread; /* read proc for ttt packet */ extern int ttt_showmessage(char *string); extern int ttt_showstat(u_long recvpkts, u_long droppkts, u_long report_drop); #endif /* _TTT_TK_H_ */ ttt-1.7.orig/ttt_window.h0100644000273700007640000000431407220141173014316 0ustar scheffedv/* $Id: ttt_window.h,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* ttt_window.h -- a module header to keep ranking by peak size within a time-window. */ #ifndef _TTT_WINDOW_H_ #define _TTT_WINDOW_H_ #define WG_WIN_SIZE 60 /* structure to keep track of the peak traffic in a time window */ struct w_ent { struct w_ent *w_next, *w_prev; int w_time; /* time stamp */ int w_size; /* size in bytes */ }; /* structure to hold ranking info in a time window */ struct wg_entry { struct wg_entry *wg_next, *wg_prev; long wg_type; #ifdef IPV6 long wg_id[4]; #else long wg_id[1]; #endif struct w_ent wg_list; char *wg_name; /* name string (e.g. host name) */ char *wg_color; /* color name */ int wg_colorindex; /* color index used for color allocation */ int *wg_ringbuf; /* ring data buffer to keep traffic size in the time-window. */ }; void stat_record(long type, int n); int stat_ranking(long type, struct wg_entry **rank_list, int n); int stat_update(struct wg_entry **ranking, struct wg_entry **old_ranking, int *update_list, int n); int stat_set_colors(char *string); void wg_init(void); void wg_cleanup(void); struct wg_entry *wg_lookup(long type, long *id); struct wg_entry *wg_getbiggest(long type); struct wg_entry *wg_getnext(struct wg_entry *wgp); void wg_record(struct wg_entry *wgp, int size); int wg_getmaxsize(struct wg_entry *wgp); int wg_gettime(void); void wg_bumptime(void); int wg_copybuf(struct wg_entry *wgp, double *vec, double interval, int n); #endif /* _TTT_WINDOW_H_ */ ttt-1.7.orig/viewer.c0100644000273700007640000002500007220141174013404 0ustar scheffedv/* $Id: viewer.c,v 0.6 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* viewer.c -- a viewer module for remote-monitoring. this module is shared by tttview and ttttextview but TTT_TEXT flag is set for ttttextview. */ #include #include #include #include #include #include #include "ttt.h" #include "ttt_node.h" #include "ttt_remote.h" #define BUFFER_SIZE 4096 /* big enough */ static char buffer[BUFFER_SIZE]; /* receive buffer */ static struct sockaddr_in probe_addr; static char *probe_name = NULL; static int packets_received; static struct timeval remote_time; static int shared_port = 1; /* share the multicast port */ static int multicast = 0; /* use multicast */ void view_sockread(int clientdata, int mask); static int check_seqno(int seq_no); static int read_record(struct ttt_record *trp); double get_remotetime(void); extern char *pcap_lookupdev(char *errbuf); extern int pcap_lookupnet(char *device, u_long *netp, u_long *maskp, char *errbuf); static void usage() { printf("usage: tttview [options]\n"); printf(" options:\n"); printf(" [-multicast]\n"); printf(" [-addr recv_addr]\n"); printf(" [-mcastifaddr mcast_if_addr]\n"); printf(" [-port recv_port]\n"); printf(" [-probe probe_addr]\n"); printf(" [-yscale 'K'|'M'|n]\n"); exit(1); } void view_parseargs(int argc, char **argv) { int i; for (i=1; i last_seqno+1) { /* packet loss */ lost_count = seq_no - last_seqno -1; if (last_seqno == 0) { /* this is the first packet */ lost_packets = 0; } else { lost_packets += lost_count; #ifdef REMOTE_DEBUG printf("[warning] lost %d packets\n", lost_count); #endif } last_seqno = seq_no; return (lost_count); } else { /* out of order report */ if (seq_no < 10 || (last_seqno - seq_no) > 100) { /* seq_no gets too small. the probe must have restarted. */ #ifdef TTT_TEXT printf("[warning] probe seems to have restarted.\n"); #else sprintf(buf, "probe[%s] seems to have restarted.", inet_ntoa(probe_addr.sin_addr)); ttt_showmessage(buf); #endif last_seqno = seq_no; lost_packets = out_of_order = 0; return 9999; } out_of_order++; #ifdef REMOTE_DEBUG printf("[warning] got out-of-order packet\n"); #endif return (-1); } } void view_sockread(int clientdata, int mask) { int sockfd, nbytes, fromlen, rsize, seq_no, nrecords, i; struct sockaddr_in from_addr; struct ttt_hdr *hdr; char *cp; sockfd = (int)clientdata; fromlen = sizeof(from_addr); if ((nbytes = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&from_addr, &fromlen)) == -1) { perror("recvfrom"); return; } if (probe_addr.sin_addr.s_addr == 0) { probe_addr = from_addr; printf("reading from probe [%s] ....\n", inet_ntoa(from_addr.sin_addr)); } /* is this the probe we are reading from? */ if (from_addr.sin_addr.s_addr != probe_addr.sin_addr.s_addr) { static int warned = 0; if (!warned) { printf("[warning] there are multiple probes.\n"); printf("\tignoring probe: %s\n", inet_ntoa(from_addr.sin_addr)); warned = 1; } return; } if (nbytes < sizeof(struct ttt_hdr)) { printf("sockread: packet too short size=%d\n", nbytes); return; } hdr = (struct ttt_hdr *)buffer; if (ntohs(hdr->th_magic) != TTT_MAGIC) { printf("[warning] bad magic!\n"); return; } pcap_stats_recv = ntohl(hdr->th_recvpkts); pcap_stats_drop = ntohl(hdr->th_droppkts); seq_no = ntohl(hdr->th_seqno); if (check_seqno(seq_no) < 0) return; nrecords = ntohl(hdr->th_nrecords); remote_time.tv_sec = ntohl(hdr->th_tvsec); remote_time.tv_usec = ntohl(hdr->th_tvusec); cp = buffer + sizeof(struct ttt_hdr); for (i=0; itr_type != TTTTYPE_IPV6HOST) { type = ntohl(trp->tr_type); size = ntohl(trp->tr_size); id[0] = ntohl(trp->tr_id[0]); #ifdef IPV6 id[1] = 0; id[2] = 0; id[3] = 0; #endif rval = sizeof(struct ttt_record); } else { tr6p = (struct ttt_record6 *)trp; type = ntohl(tr6p->tr_type); size = ntohl(tr6p->tr_size); id[0] = ntohl(tr6p->tr_id[0]); #ifdef IPV6 id[1] = ntohl(tr6p->tr_id[1]); id[2] = ntohl(tr6p->tr_id[2]); id[3] = ntohl(tr6p->tr_id[3]); #endif rval = sizeof(struct ttt_record6); } node_record(type, id, size); return rval; } double get_timeindouble(void) { double sec; static struct timeval start; static int first = 1; if (first) { start = remote_time; first = 0; } sec = (double)(remote_time.tv_sec - start.tv_sec) + (double)(remote_time.tv_usec - start.tv_usec) / 1000000.0; return sec; } ttt-1.7.orig/window.c0100644000273700007640000003554007220141175013425 0ustar scheffedv/* $Id: window.c,v 0.2 2000/12/20 14:29:45 kjc Exp kjc $ */ /* * Copyright (c) 1996-2000 * Sony Computer Science Laboratories, Inc. All rights reserved. * * Redistribution and use in source and binary forms of parts of or the * whole original or derived work are permitted provided that the above * copyright notice is retained and the original work is properly * attributed to the author. The name of the author 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* window graph module: keep track of the top ranking protocols or hosts within the time window. kjc@csl.sony.co.jp 96/06/11 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ttt.h" #include "ttt_node.h" #include "ttt_account.h" #include "ttt_window.h" #define WG_MAX_ENTRIES 30 /* max list size */ #define WG_LIST(type) \ (((type) < TTTTYPE_HOST) ? &wg_proto_list : &wg_host_list) static struct wg_entry wg_proto_list, wg_host_list; static int wg_proto_entries, wg_host_entries; static int wg_cur_time; static struct wg_entry *wg_create(long type, long *id); static void wg_delete(struct wg_entry *wgp); static void wg_qinit(struct wg_entry *wgp); static void wg_insq(struct wg_entry *prev, struct wg_entry *wgp); static struct wg_entry *wg_remq(struct wg_entry *wgp); static void wg_setrank(struct wg_entry *wgp); static void w_insq(struct w_ent *prev, struct w_ent *ep); static struct w_ent *w_remq(struct w_ent *ep); static void w_insert(struct w_ent *head, struct w_ent *entry); static void w_alloc_entries(int n); static void w_init(void); static void w_qinit(struct w_ent *head); static void w_removesublist(struct w_ent *head, struct w_ent *list); static int w_getmaxsize(struct w_ent *head); static struct w_ent *w_getent(void); static int w_countfree(void); static void w_collectgarbage(void); static void w_cleanup(void); /* get the top n protocols or hosts during this interval. */ void stat_record(long type, int n) { struct t_node *np; struct wg_entry *wgp; int i; for (i=0, np = node_getbiggest(type); it_type, np->t_id)) == NULL) break; wg_record(wgp, np->t_size); } } int stat_ranking(long type, struct wg_entry **rank_list, int n) { struct wg_entry *wgp; int i, rval; #ifdef PRINT_RANKING printf("%s ranking at time %d\n", (type < TTTTYPE_HOST) ? "proto" : "host", wg_cur_time); #endif if (n > WG_MAX_ENTRIES) n = WG_MAX_ENTRIES; for (i=0, wgp = wg_getbiggest(type); iwg_name, (double)wg_getmaxsize(wgp)/(1000.0*1000.0)); #endif } #ifdef PRINT_RANKING printf("\n"); #endif rval = i; for (; iwg_colorindex] = 1; } else { for (j=0; jwg_colorindex] = 1; count++; break; } if (j == n) { /* this is a new entry, assign a new color and update label */ update_list[i] = 2; count++; } } } /* assign unused colors to newly rank-in entries */ if (count > 0) { for (i=0; iwg_color = color_list[color_index]; ranking[i]->wg_colorindex = color_index; color_index = (color_index + 1) % color_list_size; } } return count; } int wg_copybuf(struct wg_entry *wgp, double *vec, double interval, int n) { int i, index; /* get the start index to the ring buf */ index = (wg_cur_time - n + 1) % WG_WIN_SIZE; for (i=0; iwg_ringbuf[index] * 8; vec[i] = (double)bits / interval / ttt_yscale; if (++index == WG_WIN_SIZE) index = 0; } return i; } void wg_init(void) { w_init(); wg_qinit(&wg_proto_list); w_qinit(&wg_proto_list.wg_list); wg_proto_list.wg_type = TTTTYPE_PROTO; wg_qinit(&wg_host_list); w_qinit(&wg_host_list.wg_list); wg_host_list.wg_type = TTTTYPE_HOST; } void wg_cleanup(void) { struct wg_entry *head; head = WG_LIST(TTTTYPE_PROTO); while (head->wg_prev != head) wg_delete(head->wg_prev); head = WG_LIST(TTTTYPE_HOST); while (head->wg_prev != head) wg_delete(head->wg_prev); w_cleanup(); } int wg_gettime(void) { return wg_cur_time; } void wg_bumptime(void) { struct wg_entry *wgp; wg_cur_time++; /* clear ringbuf slot */ for (wgp = wg_proto_list.wg_next; wgp != &wg_proto_list; wgp = wgp->wg_next) wgp->wg_ringbuf[wg_cur_time%WG_WIN_SIZE] = 0; for (wgp = wg_host_list.wg_next; wgp != &wg_host_list; wgp = wgp->wg_next) wgp->wg_ringbuf[wg_cur_time%WG_WIN_SIZE] = 0; /* do garbage collection every 7 minutes */ if ((wg_cur_time % 420) == 0) w_collectgarbage(); } static struct wg_entry *wg_create(long type, long *id) { struct wg_entry *wgp; wgp = malloc(sizeof(struct wg_entry)); if (wgp == NULL) fatal_error("wg_create: no memory!"); wgp->wg_ringbuf = malloc(WG_WIN_SIZE*sizeof(int)); if (wgp->wg_ringbuf == NULL) fatal_error("wg_create: no memory!"); bzero(wgp->wg_ringbuf, WG_WIN_SIZE*sizeof(int)); wgp->wg_type = type; wgp->wg_id[0] = id[0]; #ifdef IPV6 wgp->wg_id[1] = id[1]; wgp->wg_id[2] = id[2]; wgp->wg_id[3] = id[3]; #endif w_qinit(&wgp->wg_list); wgp->wg_name = net_getname(type, id); /* put this at the tail of the rank list */ if (type < TTTTYPE_HOST) { wg_insq(wg_proto_list.wg_prev, wgp); wg_proto_entries++; } else { wg_insq(wg_host_list.wg_prev, wgp); wg_host_entries++; } return wgp; } static void wg_delete(struct wg_entry *wgp) { wg_remq(wgp); if (wgp->wg_type < TTTTYPE_HOST) --wg_proto_entries; else --wg_host_entries; /* if the history list is not empty, discard the list. */ if (wgp->wg_list.w_next != &wgp->wg_list) w_removesublist(&wgp->wg_list, wgp->wg_list.w_next); free(wgp->wg_name); free(wgp->wg_ringbuf); free(wgp); } struct wg_entry *wg_lookup(long type, long *id) { struct wg_entry *head, *wgp; head = WG_LIST(type); for (wgp = head->wg_next; wgp != head; wgp = wgp->wg_next) if (wgp->wg_type == type && ISSAME_ID(wgp->wg_id, id)) return wgp; /* if we already have too many entries, delete one. */ if ((type < TTTTYPE_HOST && wg_proto_entries >= WG_MAX_ENTRIES) || (type >= TTTTYPE_HOST && wg_host_entries >= WG_MAX_ENTRIES)) wg_delete(head->wg_prev); wgp = wg_create(type, id); return wgp; } int wg_getmaxsize(struct wg_entry *wgp) { return w_getmaxsize(&wgp->wg_list); } static void wg_qinit(struct wg_entry *wgp) { wgp->wg_next = wgp->wg_prev = wgp; } static void wg_insq(struct wg_entry *prev, struct wg_entry *wgp) { wgp->wg_next = prev->wg_next; wgp->wg_prev = prev; prev->wg_next = wgp; wgp->wg_next->wg_prev = wgp; } static struct wg_entry *wg_remq(struct wg_entry *wgp) { wgp->wg_prev->wg_next = wgp->wg_next; wgp->wg_next->wg_prev = wgp->wg_prev; return wgp; } struct wg_entry *wg_getbiggest(long type) { struct wg_entry *wgp; struct wg_entry *head; head = WG_LIST(type); /* recalculate all the ranks since the current entries may have obsolete entries. kludge: call wg_setrank from the bottom of the list to clear continuous size 0 entries in one sweep. */ for (wgp = head->wg_prev; wgp != head; wgp = wgp->wg_prev) wg_setrank(wgp); return wg_getnext(head); } struct wg_entry *wg_getnext(struct wg_entry *wgp) { struct wg_entry *head; head = WG_LIST(wgp->wg_type); if (wgp->wg_next == head) return NULL; return wgp->wg_next; } void wg_record(struct wg_entry *wgp, int size) { struct w_ent *ep; ep = w_getent(); ep->w_size = size; ep->w_time = wg_cur_time; w_insert(&wgp->wg_list, ep); wgp->wg_ringbuf[wg_cur_time % WG_WIN_SIZE] = size; wg_setrank(wgp); } static void wg_setrank(struct wg_entry *wgp) { struct wg_entry *head; int size; head = WG_LIST(wgp->wg_type); /* move the rank if necessary */ /* note that swapping with a neighbor doesn't set the corrent rank but it eventually converges. it is enough for us, isn't it? */ size = w_getmaxsize(&wgp->wg_list); while (wgp->wg_prev != head && size > w_getmaxsize(&wgp->wg_prev->wg_list)) { wg_insq(wgp, wg_remq(wgp->wg_prev)); } while (wgp->wg_next != head && size < w_getmaxsize(&wgp->wg_next->wg_list)) { wg_insq(wgp->wg_prev, wg_remq(wgp->wg_next)); } } /* entry list: entries are sorted by time and size like this: list_head -- 1st -- 2nd -- 3rd -- 4th timestamp 3 8 25 89 size 8200 6500 5032 120 this list has properties: (1) the timestamp fields are monotonically growing from the top. (2) the size fields are monotonically shrinking from the top. when adding a new entry, check the entries from the top of the list and discard (1) smaller entries than the new entry. (2) entries with time-stamp which became out of the time window. by doing this, the biggest size is always kept on the top of the list. */ static struct w_ent free_list; static int w_ent_allocated; static void w_insq(struct w_ent *prev, struct w_ent *ep) { ep->w_next = prev->w_next; ep->w_prev = prev; prev->w_next = ep; ep->w_next->w_prev = ep; } static struct w_ent *w_remq(struct w_ent *ep) { ep->w_prev->w_next = ep->w_next; ep->w_next->w_prev = ep->w_prev; return ep; } static void w_insert(struct w_ent *head, struct w_ent *entry) { struct w_ent *ep; /* if the list has a sublist whose max size is smaller than entry, remove the sublist. */ #ifdef WG_DEBUG int tmp_size; tmp_size = 0x0fffffff; /* big enough */ #endif ep = head; while (ep->w_next != head) { #ifdef WG_DEBUG assert(ep->w_next->w_size < tmp_size); #endif if (ep->w_next->w_size <= entry->w_size) { w_removesublist(head, ep->w_next); break; } #ifdef WG_DEBUG tmp_size = ep->w_next->w_size; #endif if (ep->w_next->w_time <= entry->w_time - WG_WIN_SIZE) { w_insq(free_list.w_prev, w_remq(ep->w_next)); continue; } ep = ep->w_next; } /* insert this entry at the tail */ w_insq(head->w_prev, entry); } static void w_alloc_entries(int n) { struct w_ent *ep; int i; for (i=0; iw_next = head->w_prev = head; } static void w_removesublist(struct w_ent *head, struct w_ent *list) { struct w_ent *top, *tail; /* top and tail of the sublist */ top = list; tail = head->w_prev; /* remove the sublist from the original list */ head->w_prev = top->w_prev; top->w_prev->w_next = head; /* add this sublist to the free list */ top->w_prev = free_list.w_prev; top->w_prev->w_next = top; free_list.w_prev = tail; tail->w_next = &free_list; } static int w_getmaxsize(struct w_ent *head) { struct w_ent *ep; /* expire old entries */ ep = head; while (ep->w_next != head) { if (ep->w_next->w_time <= wg_cur_time - WG_WIN_SIZE) { w_insq(free_list.w_prev, w_remq(ep->w_next)); continue; } ep = ep->w_next; } if (head->w_next == head) return 0; return head->w_next->w_size; } static struct w_ent *w_getent(void) { struct w_ent *ep = free_list.w_next; if (ep == &free_list) { /* free list is empty */ w_alloc_entries(50); #ifdef WG_DEBUG printf("[debug] allocated another 50 entries\n"); printf("\ttotal entries=%d\n", w_ent_allocated); #endif ep = free_list.w_next; } return w_remq(ep); } static int w_countfree(void) { struct w_ent *ep; int n = 0; for (ep = free_list.w_next; ep != &free_list; ep = ep->w_next) n++; return n; } static void w_collectgarbage(void) { int n; /* if there are more than 100 free entries, keep 50 and discard the rest. */ n = w_countfree(); if (n > 100) { n = n - 50; #ifdef WG_DEBUG printf("[debug] too much entries. discard %d out of %d\n", n, w_ent_allocated); #endif while (n-- > 0) { free(w_remq(free_list.w_next)); w_ent_allocated--; } #ifdef WG_DEBUG printf("\ttotal entries=%d\n", w_ent_allocated); #endif } } /* delete all the entries on the free list */ static void w_cleanup(void) { #ifdef WG_DEBUG printf("w_cleanup:\n"); #endif while (free_list.w_next != &free_list) { free(w_remq(free_list.w_next)); w_ent_allocated--; } #ifdef WG_DEBUG printf("total entries=%d\n", w_ent_allocated); #endif } ttt-1.7.orig/configure.in0100644000273700007640000004630007555227756014304 0ustar scheffedvAC_INIT() AC_CONFIG_AUX_DIR(cf) # ----------------------------------------------------------------------- # # Handle command line options # # --with-tcl=DIR # --with-tk=DIR # --with-blt=DIR # --with-pcap=DIR # --with-cc=CC # --enable-ipv6, --disable-ipv6 # # ----------------------------------------------------------------------- tttIncludes="" tttLibraries="" tttAuxLibs="" tttRunPath="" tttFlags="" ttt_ckcmd_tcl_home="" ttt_ckcmd_tk_home="" ttt_ckcmd_blt_home="no" ttt_ckcmd_pcap_home="yes" ttt_ckcmd_cc="" ttt_ckcmd_ipv6="auto" AC_ARG_WITH(tcl, [ --with-tcl=DIR find Tcl headers and libraries in DIR], ttt_ckcmd_tcl_home=$withval) AC_ARG_WITH(tk, [ --with-tk=DIR find Tk headers and libraries in DIR], ttt_ckcmd_tk_home=$withval) AC_ARG_WITH(blt, [ --with-blt=DIR find BLT headers and libraries in DIR], ttt_ckcmd_blt_home=$withval) AC_ARG_WITH(pcap, [ --with-pcap=DIR find pcap headers and libraries in DIR], ttt_ckcmd_pcap_home=$withval) AC_ARG_WITH(cc, [ --with-cc=CC set C compiler to CC], [ ttt_ckcmd_cc=$with_cc unset ac_cv_prog_CC unset ac_cv_prog_CPP ]) AC_ARG_ENABLE(ipv6, [ --enable-ipv6 ipv6 support.], [ttt_ckcmd_ipv6=$enableval], [ttt_ckcmd_ipv6="auto"]) AC_CANONICAL_SYSTEM # ----------------------------------------------------------------------- # # Set a variable containing current working directory if /bin/sh # doesn't do it already. # # ----------------------------------------------------------------------- PWD=`pwd` # ----------------------------------------------------------------------- # # C compiler and debugging flags # # ----------------------------------------------------------------------- ttt_ckenv_cc=$CC # # CC search order # # 1. command line (--with-cc) # 2. environment variable ($CC) # 3. cached variable ($ttt_cv_prog_cc) # 4. check for program (AC_PROG_CC) # 4. default to cc # AC_MSG_CHECKING([which C compiler]) if test "x${ttt_ckcmd_cc}" != "x" ; then CC=${ttt_ckcmd_cc} unset ac_cv_prog_CPP unset ac_cv_prog_CC elif test "x${ttt_ckenv_cc}" != "x" ; then unset ac_cv_prog_CPP unset ac_cv_prog_CC elif test "x${ttt_cv_prog_cc}" != "x" ; then CC=${ttt_cv_prog_cc} unset ac_cv_prog_CC else AC_PROG_CC fi if test "x${CC}" = "x" ; then CC=cc fi AC_MSG_RESULT([$CC]) unset ttt_cv_prog_cc AC_CACHE_VAL(ttt_cv_prog_cc, ttt_cv_prog_cc=$CC) AC_SUBST(CC) AC_PROG_CPP if test "x${GCC}" != "x" ; then tttHaveGcc="yes" else AC_MSG_CHECKING([if C compiler is really gcc]) AC_EGREP_CPP(_cc_is_gcc_, [ #ifdef __GNUC__ _cc_is_gcc_ #endif ], [tttHaveGcc=yes], [tttHaveGcc=no]) AC_MSG_RESULT([$tttHaveGcc]) fi if test "${tttHaveGcc}" = "yes" ; then GCCFLAGS="-Wwrite-strings -fwritable-strings" else GCCFLAGS="" fi AC_SUBST(GCCFLAGS) # # CFLAGS search order # # 1. command line (--with-cflags) # 2. cached variable ($ttt_cv_prog_cflags) # 3. set to "-O2" if using gcc ($tttHaveGcc) # 4. otherwise, default to "-O" # AC_MSG_CHECKING([default compiler flags]) if test "x${ttt_ckcmd_cflags}" != "x" ; then CFLAGS=${ttt_ckcmd_cflags} elif test "x${ttt_cv_prog_cflags}" != "x" ; then CFLAGS=${ttt_cv_prog_cflags} elif test "${tttHaveGcc}" = "yes" ; then CFLAGS="-O2" else CFLAGS="-O" fi AC_MSG_RESULT([$CFLAGS]) unset ttt_cv_prog_cflags AC_CACHE_VAL(ttt_cv_prog_cflags, ttt_cv_prog_cflags=$CFLAGS) AC_SUBST(CFLAGS) # ----------------------------------------------------------------------- # # Programs: Check for existence of install program # # ----------------------------------------------------------------------- AC_PROG_INSTALL # ----------------------------------------------------------------------- # # Headers: Check for header files used # # ----------------------------------------------------------------------- AC_HEADER_STDC AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(sys/queue.h) # ----------------------------------------------------------------------- # # Functions: Check for gethostent # # ----------------------------------------------------------------------- AC_HAVE_FUNCS(gethostent) # ----------------------------------------------------------------------- # # Find the Tcl build configuration file "tclConfig.sh" # # ----------------------------------------------------------------------- AC_MSG_CHECKING([for tclConfig.sh]) tclConfigFile="" guesses="\ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tcl_lib \ /usr/local/lib/tcl8.4 \ /usr/local/lib/tcl8.3 \ /usr/local/lib/tcl8.2 \ /usr/pkg/lib \ /usr/local/tcl/lib \ /usr/local/tcl/tcl8.4/lib \ /usr/local/tcl/tcl8.3/lib \ /usr/local/tcl/tcl8.2/lib \ /usr/lib/tcl8.4 \ /usr/lib/tcl8.3 \ /usr/lib/tcl8.2 \ $PWD/../tcl8.4 \ $PWD/../tcl8.3 \ $PWD/../tcl8.2 \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/tclConfig.sh" ; then tclConfigFile="$dir/tclConfig.sh" break fi done AC_MSG_RESULT([${tclConfigFile}]) if test "x$tclConfigFile" = "x" ; then echo "can't find Tcl configuration script \"tclConfig.sh\"" exit 1 fi # ----------------------------------------------------------------------- # # Find the X11R6 includes and libraries # # ----------------------------------------------------------------------- AC_PATH_X # ----------------------------------------------------------------------- # # Find the Tk build configuration file "tkConfig.sh" # # ----------------------------------------------------------------------- AC_MSG_CHECKING([for tkConfig.sh]) tkConfigFile="" guesses="\ $ttt_ckcmd_tk_home \ $ttt_ckcmd_tk_home/lib \ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tk_lib \ /usr/local/lib/tk8.4 \ /usr/local/lib/tk8.3 \ /usr/local/lib/tk8.2 \ /usr/pkg/lib \ /usr/local/tcl/lib \ /usr/local/tcl/tk8.4/lib \ /usr/local/tcl/tk8.3/lib \ /usr/local/tcl/tk8.2/lib \ /usr/lib/tk8.4 \ /usr/lib/tk8.3 \ /usr/lib/tk8.2 \ $PWD/../tk8.4 \ $PWD/../tk8.3 \ $PWD/../tk8.2 \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/tkConfig.sh" ; then tkConfigFile="$dir/tkConfig.sh" break fi done AC_MSG_RESULT([${tkConfigFile}]) # ----------------------------------------------------------------------- # # Find the [incr Tcl] build configuration file "itclConfig.sh" # # If we find one, use this directory's versions of tclConfig.sh # and tkConfig.sh. This will point us to versions of Tcl and # Tk with namespace support. # # ----------------------------------------------------------------------- AC_MSG_CHECKING([for itclConfig.sh]) itclConfigFile="" guesses="\ $ttt_ckcmd_tk_home \ $ttt_ckcmd_tk_home/lib \ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tk_lib \ /usr/local/lib/tk8.4 \ /usr/local/lib/tk8.3 \ /usr/local/lib/tk8.2 \ /usr/local/lib/tcl8.4 \ /usr/local/lib/tcl8.3 \ /usr/local/lib/tcl8.2 \ /usr/local/tcl/lib \ /usr/pkg/lib \ /usr/local/tcl/tk8.4/lib \ /usr/local/tcl/tk8.3/lib \ /usr/local/tcl/tk8.2/lib \ /usr/local/tcl/tcl8.4/lib \ /usr/local/tcl/tcl8.3/lib \ /usr/local/tcl/tcl8.2/lib \ /usr/lib/tk8.4 \ /usr/lib/tk8.3 \ /usr/lib/tk8.2 \ $prefix/lib \ $exec_prefix/lib \ $XLIBDIR \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/itclConfig.sh" ; then itclConfigFile="$dir/itclConfig.sh" if test -r "$dir/tclConfig.sh" ; then tclConfigFile="$dir/tclConfig.sh" fi if test -r "$dir/tkConfig.sh" ; then tkConfigFile="$dir/tkConfig.sh" fi break fi done AC_MSG_RESULT([${itclConfigFile}]) # ----------------------------------------------------------------------- # # Source in the Tcl/Tk/[incr Tcl] configuration scripts. # # First source the Tcl/Tk scripts. Then source the [incr Tcl] # scripts, if needed. The variables [incr Tcl] script will # override those of the the tclConfig.sh or tkConfig.sh # # BTW: Does anyone actually use the tclConfig.sh and tkConfig.sh # scripts? They seem to be always missing something. For example, # why don't they say where to find the Tcl and Tk header files? # # For example, give me the library directory paths separately # (I can't easily parse "-Ldir", but I can always paste a -L # on the front). If I want to specify equivalent of the -R flag, # I need the build a path of the library directories. Such as # # "-R $(BLTLIB):$(TKLIB):$(TCLLIB):($XLIB)" # # ----------------------------------------------------------------------- if test "x$tkConfigFile" != "x" ; then . $tclConfigFile . $tkConfigFile fi tclIncSpec="-I${TCL_PREFIX}/include" tkIncSpec="-I${TK_PREFIX}/include" tclLibDir=${TCL_PREFIX}/lib tkLibDir=${TK_PREFIX}/lib case $target in *-freebsd*|*-netbsd*|*-openbsd*|*-sunos4*|*-linux-*) tclIncSpec="-I${TCL_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" tkIncSpec="-I${TK_PREFIX}/include/tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}" ;; esac itclLibSpec="" itclIncSpec="" itclSuffix="" if test "x$itclConfigFile" != "x" ; then . $itclConfigFile tclIncSpec="-I${TCL_PREFIX}/include/itcl" tkIncSpec="-I${TK_PREFIX}/include/itcl" tclLibDir=${TCL_PREFIX}/lib/itcl tkLibDir=${TK_PREFIX}/lib/itcl itclSuffix="i" fi tclLibSpec=${TCL_LIB_SPEC} tkLibSpec=${TK_LIB_SPEC} case $target in *-freebsd*|*-netbsd*|*-openbsd*|*-sunos4*) tclLib="-ltcl${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${itclSuffix}" tkLib="-ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${itclSuffix}" ;; *) tclLib="-ltcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${itclSuffix}" tkLib="-ltk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${itclSuffix}" ;; esac # ----------------------------------------------------------------------- # # Tk libraries and header files # # ----------------------------------------------------------------------- if test "${bltIncSpec}" != "${tkIncSpec}" ; then tttIncludes="${tttIncludes} ${tkIncSpec}" fi if test "${bltLibDir}" = "${tkLibDir}" ; then tttLibraries="${tttLibraries} ${tkLib}" else tttLibraries="${tttLibraries} ${tkLibSpec}" if test "x${tkLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${tkLibDir}" fi fi # ----------------------------------------------------------------------- # # Tcl libraries and header files # # Add a header file directory specification only if the Tcl headers reside # in a different directory from Tk's. # # # ----------------------------------------------------------------------- if test "${tkIncSpec}" != "${tclIncSpec}" ; then tttIncludes="${tttIncludes} ${tclIncSpec}" fi if test "${tkLibDir}" = "${tclLibDir}" ; then tttLibraries="${tttLibraries} ${tclLib}" else tttLibraries="${tttLibraries} ${tclLibSpec}" if test "x${tclLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${tclLibDir}" fi fi # ----------------------------------------------------------------------- # # [incr Tcl] include files # # ----------------------------------------------------------------------- if test "x${itclIncSpec}" != "x" ; then tttIncludes="${itclIncSpec} ${tttIncludes}" fi # ----------------------------------------------------------------------- # # [incr Tcl] libraries # # ----------------------------------------------------------------------- if test "x${itclLibSpec}" != "x" ; then tttLibraries="${itclLibSpec} ${tttLibraries}" fi # ----------------------------------------------------------------------- # # Find the BLT header "blt.h" and library "libBLT.a" # # ----------------------------------------------------------------------- bltIncDir="" bltLibDir="" bltIncSpec="" bltLibSpec="" AC_MSG_CHECKING([for blt.h]) bltHdrFile="" guesses="\ $ttt_ckcmd_blt_home \ $ttt_ckcmd_blt_home/include \ $prefix/include \ $exec_prefix/include \ /usr/local/include \ /usr/local/blt/include \ /usr/pkg/include \ /usr/include" for dir in $guesses; do if test -r "$dir/blt.h" ; then bltHdrFile="$dir/blt.h" bltIncDir="$dir" bltIncSpec="-I$dir" break fi done AC_MSG_RESULT([${bltHdrFile}]) if test "x$bltHdrFile" = "x" ; then echo "can't find BLT header file \"blt.h\"" exit 1 fi AC_MSG_CHECKING([for libBLT.a]) bltLibFile="" guesses="\ $ttt_ckcmd_blt_home \ $ttt_ckcmd_blt_home/lib \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib \ /usr/local/blt/lib \ /usr/pkg/lib \ /usr/lib" for dir in $guesses; do if test -r "$dir/libBLT24.a" ; then bltLibFile="$dir/libBLT24.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT24" break elif test -r "$dir/libBLT.2.4.a" ; then bltLibFile="$dir/libBLT.2.4.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT.2.4" break elif test -r "$dir/libBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}.a" ; then bltLibFile="$dir/libBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" break elif test -r "$dir/libBLT.a" ; then bltLibFile="$dir/libBLT.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT" break fi done AC_MSG_RESULT([${bltLibFile}]) if test "x$bltLibFile" = "x" ; then echo "can't find BLT library file \"libBLT.a\"" exit 1 fi # ----------------------------------------------------------------------- # # BLT include files and libraries # # ----------------------------------------------------------------------- tttIncludes="${tttIncludes} ${bltIncSpec}" tttLibraries="${tttLibraries} ${bltLibSpec}" tttRunPath="${tttRunPath}:${bltLibDir}" # ----------------------------------------------------------------------- # # -lX11 # # ----------------------------------------------------------------------- if test "${tkLibDir}" = "${x_libraries}" ; then tttLibraries="${tttLibraries} -lX11" else tttLibraries="${tttLibraries} -L${x_libraries} -lX11" if test "x${tclLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${x_libraries}" fi fi if test "${tkIncDir}" != "${x_includes}" ; then tttIncludes="${tttIncludes} -I${x_includes}" fi # ----------------------------------------------------------------------- # # PCAP header and library # # ----------------------------------------------------------------------- AC_MSG_CHECKING([for pcap.h]) pcapHdrFile="" guesses="\ $ttt_ckcmd_pcap_home \ $ttt_ckcmd_pcap_home/include \ $prefix/include \ /usr/local/include /usr/include" for dir in $guesses; do if test -r "$dir/pcap.h" ; then pcapHdrFile="$dir/pcap.h" break fi done AC_MSG_RESULT([${pcapHdrFile}]) if test "x$pcapHdrFile" = "x" ; then echo "can't find pcap header \"pcap.h\"" echo "use \"--with-pcap=DIR\" to specify pcap directory" exit 1 fi if test "${dir}" != "/usr/include" ; then tttIncludes="${tttIncludes} -I${dir}" fi if test "${ttt_ckcmd_pcap_home}" != "no" ; then if test "${ttt_ckcmd_pcap_home}" = "yes" ; then spec="-lpcap" dir="" else spec="-L${ttt_ckcmd_pcap_home} -lpcap" dir=${ttt_ckcmd_pcap_home} fi AC_CHECK_LIB(pcap, main, [found=yes], [found=no], $spec) if test "${found}" = "yes" ; then tttLibraries="${tttLibraries} ${spec}" if test "x${dir}" != "x" ; then tttRunPath="${tttRunPath}:${dir}" fi else echo "can't find pcap library file \"libpcap.a\"" exit 1 fi fi # ----------------------------------------------------------------------- # # -lsocket # # ----------------------------------------------------------------------- AC_CHECK_LIB(socket, main) # ----------------------------------------------------------------------- # # -lnsl # # ----------------------------------------------------------------------- AC_CHECK_LIB(nsl, main) # ----------------------------------------------------------------------- # # -lm # # ----------------------------------------------------------------------- AC_CHECK_LIB(m, main) # ----------------------------------------------------------------------- # # -ldl # # ----------------------------------------------------------------------- AC_CHECK_LIB(dl, main) # ----------------------------------------------------------------------- # # Set up a new default prefix to installation path. The ways # the prefix can be set and their precedence are as follows: # # 1. --prefix option given to ./configure. (prefix != NONE) # 2. use previously configured Tk prefix # # ----------------------------------------------------------------------- if test "$prefix" = "NONE" ; then prefix=${TK_PREFIX} fi if test "$exec_prefix" = "NONE" ; then exec_prefix=$prefix fi # ------------------------------------------------------------------------- # # Check for [incr Tcl] header files # # ------------------------------------------------------------------------- oldFlags=$CPPFLAGS CPPFLAGS="$CPPFLAGS $tttIncludes" AC_CHECK_HEADERS(itcl.h) AC_CHECK_HEADERS(itk.h) CPPFLAGS=$oldFlags #--------------------------------------------------------------- # # IPv6 support # #--------------------------------------------------------------- AC_MSG_CHECKING(for IPv6 support) if test "$ttt_ckcmd_ipv6" = auto; then AC_TRY_COMPILE([#define INET6 #include #include ], [int x = IPPROTO_IPV6; struct in6_addr a;], [ac_cv_ipv6="yes"], [ac_cv_ipv6="no"]) else ac_cv_ipv6="$ttt_ckcmd_ipv6" fi if test "$ac_cv_ipv6" = yes; then tttFlags="-DIPV6 ${tttFlags}" fi AC_MSG_RESULT($ac_cv_ipv6) # ------------------------------------------------------------------------- # # misaligned access # # ------------------------------------------------------------------------- case "$target_cpu" in alpha|hp*|mips|sparc) tttFlags="-DALIGN_WORD ${tttFlags}" ;; esac # ------------------------------------------------------------------------- # # compilation environment # # ------------------------------------------------------------------------- tttLibraries="${tttLibraries} ${LIBS}" case $target in *-solaris2*) LDFLAGS="-R ${tttRunPath}" tttLibraries="${tttLibraries} -ldl" ;; *-freebsd*) ;; *-netbsd*|*-openbsd*) LDFLAGS="-R ${tttRunPath}" ;; *-bsdi*) tttLibraries="${tttLibraries} -ldl" ;; *-linux*) tttFlags="-D_BSD_SOURCE ${tttFlags}" tttLibraries="${tttLibraries} -ldl" ;; *) ;; esac AC_SUBST(LDFLAGS) INCLUDES=${tttIncludes} AC_SUBST(INCLUDES) LIBS=${tttLibraries} AC_SUBST(LIBS) TTT_LIBDIR="$libdir/ttt" AC_SUBST(TTT_LIBDIR) TTT_FLAGS=${tttFlags} AC_SUBST(TTT_FLAGS) #-------------------------------------------------------------------- # Print out some of the more important settings #-------------------------------------------------------------------- echo "" echo "Configuration results:" echo "" echo " tcl.h found in $tclIncSpec" echo " tk.h found in $tkIncSpec" echo " blt.h found in $bltIncSpec" echo " X11/Xlib.h found in -I$x_includes" echo " libtcl.a found in $tclLibSpec" echo " libtk.a found in $tkLibSpec" echo " libBLT.a found in $bltLibSpec" echo " libX11.a found in -L$x_libraries -lX11" echo "" echo "Directories where TTT is to be installed:" echo "" echo " \"\$prefix\" is $prefix" echo " \"\$exec_prefix\" is $exec_prefix" echo "" echo " ttt to be installed in $bindir" echo " scripts to be installed in $TTT_LIBDIR" echo " manual pages to be installed in $mandir" echo "" #echo " DEFS: $DEFS" #echo " INCLUDES: $INCLUDES" #echo " LIBS: $LIBS" #echo " LDFLAGS: $LDFLAGS" #echo " TTT_FLAGS: $TTT_FLAGS" echo "" #-------------------------------------------------------------------- # # Generate Makefile # #-------------------------------------------------------------------- AC_OUTPUT(Makefile) ttt-1.7.orig/ttt.10100644000273700007640000000377207217712134012656 0ustar scheffedv.TH TTT 1 "14 November 1997" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME ttt \- Tele Traffic Tapper .SH SYNOPSIS .na .B ttt [ .B \-interface .I device ] [ .B \-interval .I ms ] [ .B \-dumpfile .I file ] [ .B \-speed .I factor ] ] [ .B \-yscale .I 'K'|'M'|n ] .br .SH DESCRIPTION .LP \fITtt\fP monitors the network and automatically picks up the main contributors of the traffic within the time window (60 sec by default). You can see the behavior of the traffic of the past 60 seconds. The graphs are updated every second by default. \fITtt\fP presents two separate graphs in a window. One for a protocol breakdown and the other for an ip-host breakdown. \fITtt\fP also accepts a \fItcpdump\fR output as input. To run .I ttt You must have read access to .IR /dev/bpf* . .br \fITtt\fP reads a startup script named \fIttt.tcl\fP in the current directory or in the system default directory (default is \fI/usr/local/lib/ttt\fP). Once started, \fIttt\fP goes into Tcl Shell. To quit \fIttt\fP, type \fIquit\fP. You can change \fIttt variables\fP from Tcl Shell or from the startup script. See the comments in \fIttt.tcl\fP for more details. Also, you can do remote monitoring using \fItttprobe\fP and \fItttview\fP programs. \fITtt\fP requires libpcap and libBLT. libBLT requires Tcl/Tk. .SH OPTIONS .TP .B \-interface Listen on \fIdevice\fP. If unspecified, \fIttt\fP searches the system interface list for the lowest numbered, configured up interface (excluding loopback). Ties are broken by choosing the earliest match. .TP .B \-interval Sets the interval to update the graph in \fImsec\fP. The default is 1000 msec. .TP .B \-dumpfile Uses a dumpfile produced by \fItcpdump -w\fR as input. .TP .B \-speed Specifies the acceleration factor of the replay speed. \fI-speed 10\fR will replay a 10-minute-dumpfile in 1 minute. .TP .B \-yscale Specifies the scale of y axis. \fIK\fR and \fIM\fR represent 1000 and 1000000 respectively. .SH SEE ALSO tttprobe(1), tttview(1), pcap(3), BLT(n) .SH BUGS ttt-1.7.orig/Makefile.manual0100644000273700007640000000731106550670210014663 0ustar scheffedv# Top level hierarchy prefix = /usr/local # Pathname of directory to install the binary BINDEST = ${prefix}/bin # Pathname of directory to install the man page MANDEST = ${prefix}/man # Pathname of directory to install the library LIBDEST = ${prefix}/lib/ttt INSTALL = install -c SHELL="/bin/sh" # # Site Dependent Configuration # #CC= gcc # specify STATICLINK if you want tttprobe and tttrelay statically linked #STATICLINK= -static #WARNINGS= -Wreturn-type -Wshadow -Wpointer-arith -Wunused \ # -Wmissing-prototypes # # include file path for blt, tcl, tk, and X11. # TK_INCLUDES= -I/usr/local/include/tcl7.6 -I/usr/local/include/tk4.2 \ -I/usr/local/blt/lib TK_LIBS= -lBLT -ltk42 -ltcl76 -lX11 SITE_INCLUDES= -I. -I/usr/X11R6/include -I/usr/local/include $(TK_INCLUDES) SITE_LDFLAGS= -L/usr/X11R6/lib -L/usr/local/lib -L/usr/local/blt/lib # # System Dependent Configuration # # -DALIGN_WORD: for risc machines (e.g. sparc, alpha) # -DHAVE_GETHOSTENT: turn on if the system has gethostent(3). # # for FreeBSD # (nothing required) # for BSD/OS #SYS_LIBS= -lipc # for BSD/OS dynamic libraries #SYS_LIBS= -lipc -ldl # for Solaris #SYS_DEFINES= -DALIGN_WORD -DHAVE_GETHOSTENT -DHAVE_SYS_SOCKIO_H #SYS_LIBS= -lsocket -lnsl # for SunOS4.x #SYS_DEFINES= -DALIGN_WORD -DHAVE_GETHOSTENT # for NewsOS6.x #SYS_DEFINES= -DSVR4 -DALIGN_WORD -DHAVE_GETHOSTENT -DHAVE_SYS_SOCKIO_H #SYS_LIBS= -lsocket -lnsl # for Linux (Slackware3.0 + tcpdump-3.0.4 for linux) (should be site-dependent) #SYS_INCLUDES= -I/usr/include/tcl -I/src/tcpdump-3.0.4/linux-include # # ttt related flags # # -DIPV6: for IPv6 support # -DTTT_LIBRARY="your_ttt.tcl_path" # TTT_DEFINES= #TTT_DEFINES= -DIPV6 #TTT_DEBUG_FLAGS= -DNODE_DEBUG -DWG_DEBUG -DREMOTE_DEBUG PCAP_LIB= -lpcap #DEBUG_FLAGS= -g $(TTT_DEBUG_FLAGS) $(WARNINGS) DEBUG_FLAGS= -O2 -DNDEBUG $(TTT_DEBUG_FLAGS) CFLAGS= $(DEBUG_FLAGS) $(SITE_CFLAGS) $(SYS_CFLAGS) LDFLAGS= $(SITE_LDFLAGS) $(SYS_LDFLAGS) DEFINES= $(TTT_DEFINES) $(SITE_DEFINES) $(SYS_DEFINES) INCLUDES= $(SITE_INCLUDES) $(SYS_INCLUDES) LIBS= $(SITE_LIBS) $(SYS_LIBS) TTT_OBJS= ttt.o tk_ttt.o common.o display.o account.o net_names.o \ window.o node.o net_read.o PROBE_OBJS= probe.o common.o account.o remote.o node.o net_read.o VIEW_OBJS= tk_view.o common.o remote.o display.o net_names.o \ window.o viewer.o node_emu.o pcap_inet.o TEXTVIEW_OBJS= textview.o common.o net_names.o remote.o \ window.o text_viewer.o node_emu.o pcap_inet.o TTT_HEADERS= ttt.h ttt_tk.h ttt_remote.h ttt_window.h ttt_node.h PROG= ttt tttprobe tttview all: $(PROG) ttt: $(TTT_OBJS) $(CC) -o $@ $(TTT_OBJS) $(LDFLAGS) $(TK_LIBS) $(PCAP_LIB) $(LIBS) -lm tttprobe: $(PROBE_OBJS) $(CC) -o $@ $(PROBE_OBJS) $(STATICLINK) $(LDFLAGS) $(PCAP_LIB) $(LIBS) $(SYSLIBS) tttview: $(VIEW_OBJS) $(CC) -o $@ $(VIEW_OBJS) $(LDFLAGS) $(TK_LIBS) $(LIBS) $(SYSLIBS) -lm ttttextview: $(TEXTVIEW_OBJS) $(CC) -o $@ $(TEXTVIEW_OBJS) $(LDFLAGS) $(LIBS) $(SYSLIBS) tttrelay: relay.o $(CC) -o $@ relay.o $(STATICLINK) $(LDFLAGS) $(LIBS) $(SYSLIBS) tk_view.o: tk_ttt.c $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -DTTT_VIEW -o $@ -c tk_ttt.c text_viewer.o: viewer.c $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -DTTT_TEXT -o $@ -c viewer.c .c.o: $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c install: all for i in ttt tttprobe tttview; do \ $(INSTALL) -m 555 -o bin -g bin $$i $(DESTDIR)$(BINDEST); \ done if [ ! -d $(DESTDIR)$(LIBDEST) ]; then \ mkdir $(DESTDIR)$(LIBDEST); \ fi $(INSTALL) -m 444 -o bin -g bin ttt.tcl $(DESTDIR)$(LIBDEST) install-man: for i in ttt tttprobe tttview; do \ $(INSTALL) -m 444 -o bin -g bin $$i.1 \ $(DESTDIR)$(MANDEST)/man1; \ done cleanobj:; -rm -f *.o core *.core *.bak ,* *~ "#"* clean:; -rm -f $(PROG) *.o core *.core *.bak ,* *~ "#"* ttt-1.7.orig/Makefile.in0100644000273700007640000000646406550666471014042 0ustar scheffedv# ------------------------------------------------------------------------ # Makefile for TTT # ------------------------------------------------------------------------ # ------------------------------------------------------------------------ # C Compiler options # ------------------------------------------------------------------------ DEFINES = @DEFS@ @TTT_FLAGS@ -DTTT_LIBRARY=\"@TTT_LIBDIR@\" CFLAGS = @CFLAGS@ EXTRA_CFLAGS = @GCCFLAGS@ CC = @CC@ # ------------------------------------------------------------------------ # Source and target installation directories # ------------------------------------------------------------------------ prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ bindir = @bindir@ libdir = @TTT_LIBDIR@ mandir = @mandir@ # ------------------------------------------------------------------------ # Include directives for Tcl, Tk, and X include files # ------------------------------------------------------------------------ INCLUDES = -I. @INCLUDES@ # ------------------------------------------------------------------------ # Libraries directives for Tcl, Tk, X11, and BLT # ------------------------------------------------------------------------ LIBRARIES = @LIBS@ # ------------------------------------------------------------------------ # Don't edit anything beyond this point # ------------------------------------------------------------------------ CC_SWITCHES = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES) LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ SHELL = /bin/sh RM = rm -f LN_S = @LN_S@ TTT_OBJS= ttt.o tk_ttt.o common.o display.o account.o net_names.o \ window.o node.o net_read.o PROBE_OBJS= probe.o common.o account.o remote.o node.o net_read.o VIEW_OBJS= tk_view.o common.o remote.o display.o net_names.o \ window.o viewer.o node_emu.o pcap_inet.o TEXTVIEW_OBJS= textview.o common.o net_names.o remote.o \ window.o text_viewer.o node_emu.o pcap_inet.o TTT_HEADERS= ttt.h ttt_tk.h ttt_remote.h ttt_window.h ttt_node.h PROG= ttt tttprobe tttview all: $(PROG) ttt: $(TTT_OBJS) $(CC) -o $@ $(TTT_OBJS) $(LDFLAGS) $(LIBRARIES) tttprobe: $(PROBE_OBJS) $(CC) -o $@ $(PROBE_OBJS) $(STATICLINK) $(LDFLAGS) $(LIBRARIES) tttview: $(VIEW_OBJS) $(CC) -o $@ $(VIEW_OBJS) $(LDFLAGS) $(LIBRARIES) ttttextview: $(TEXTVIEW_OBJS) $(CC) -o $@ $(TEXTVIEW_OBJS) $(LDFLAGS) $(LIBRARIES) tttrelay: relay.o $(CC) -o $@ relay.o $(STATICLINK) $(LDFLAGS) $(LIBRARIES) tk_view.o: tk_ttt.c $(CC) $(CC_SWITCHES) -DTTT_VIEW -o $@ -c tk_ttt.c text_viewer.o: viewer.c $(CC) $(CC_SWITCHES) -DTTT_TEXT -o $@ -c viewer.c .c.o: $(CC) $(CC_SWITCHES) -c $*.c install: all for i in ttt tttprobe tttview; do \ $(INSTALL) -m 555 -o bin -g bin $$i $(bindir); \ done if [ ! -d $(libdir) ]; then \ mkdir $(libdir); \ fi $(INSTALL) -m 444 -o bin -g bin ttt.tcl $(libdir) install-man: for i in ttt tttprobe tttview; do \ $(INSTALL) -m 444 -o bin -g bin $$i.1 \ $(mandir)/man1; \ done clean: $(RM) $(PROG) *.o core *.core *.bak *\~ "#"* *pure* .pure* GENERATED_FILES = \ config.status config.cache config.log \ Makefile distclean: $(RM) $(PROG) *.o core *.core *.bak *\~ "#"* *pure* .pure* $(RM) $(GENERATED_FILES) ttt-1.7.orig/tttprobe.10100644000273700007640000000271306551027427013704 0ustar scheffedv.TH TTTPROBE 1 "14 November 1997" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME tttprobe \- probe program for Tele Traffic Tapper .SH SYNOPSIS .na .B tttprobe [ .B \-interface .I device ] [ .B \-multicast ] .br .ti +9 [ .B \-port .I dest_port ] [ .B \-ttl .I time-to-live ] .br .ti +9 [ .B \-interval .I ms ] [ .B dest ] .br .SH DESCRIPTION .LP \fITttprobe\fP is a network probe program for remote traffic monitoring, used with \fItttview(1)\fP. You must have read access to .IR /dev/bpf* . .br \fITttprobe\fP requires libpcap. .SH OPTIONS .TP .B \-interface Listen on \fIdevice\fP. If unspecified, \fIttt\fP searches the system interface list for the lowest numbered, configured up interface (excluding loopback). Ties are broken by choosing the earliest match. .TP .B \-multicast Shorthand for the default multicast destination address and the destination address can be omitted. It is equivalent to setting the destination to \fI224.8.8.0\fP. .TP .B \-port Specifies the udp port number of the remote viewer. The default is 7288. .TP .B \-ttl Sets the time-to-live for multicast. The default is 1 (subnet local). .TP .B \-interval Sets the interval to update the graph in \fImsec\fP. The default is 1000 msec. .TP .B dest Specifies the address of the remote viewer. The destination address can be a hostname or a dotted IP address. The destination address can be a multicast address. .SH SEE ALSO ttt(1), tttview(1), pcap(3) .SH BUGS ttt-1.7.orig/configure0100755000273700007640000024505007555227777013710 0ustar scheffedv#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --with-tcl=DIR find Tcl headers and libraries in DIR" ac_help="$ac_help --with-tk=DIR find Tk headers and libraries in DIR" ac_help="$ac_help --with-blt=DIR find BLT headers and libraries in DIR" ac_help="$ac_help --with-pcap=DIR find pcap headers and libraries in DIR" ac_help="$ac_help --with-cc=CC set C compiler to CC" ac_help="$ac_help --enable-ipv6 ipv6 support." ac_help="$ac_help --with-x use the X Window System" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file= # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi ac_aux_dir= for ac_dir in cf $srcdir/cf; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in cf $srcdir/cf" 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # ----------------------------------------------------------------------- # # Handle command line options # # --with-tcl=DIR # --with-tk=DIR # --with-blt=DIR # --with-pcap=DIR # --with-cc=CC # --enable-ipv6, --disable-ipv6 # # ----------------------------------------------------------------------- tttIncludes="" tttLibraries="" tttAuxLibs="" tttRunPath="" tttFlags="" ttt_ckcmd_tcl_home="" ttt_ckcmd_tk_home="" ttt_ckcmd_blt_home="no" ttt_ckcmd_pcap_home="yes" ttt_ckcmd_cc="" ttt_ckcmd_ipv6="auto" # Check whether --with-tcl or --without-tcl was given. if test "${with_tcl+set}" = set; then withval="$with_tcl" ttt_ckcmd_tcl_home=$withval fi # Check whether --with-tk or --without-tk was given. if test "${with_tk+set}" = set; then withval="$with_tk" ttt_ckcmd_tk_home=$withval fi # Check whether --with-blt or --without-blt was given. if test "${with_blt+set}" = set; then withval="$with_blt" ttt_ckcmd_blt_home=$withval fi # Check whether --with-pcap or --without-pcap was given. if test "${with_pcap+set}" = set; then withval="$with_pcap" ttt_ckcmd_pcap_home=$withval fi # Check whether --with-cc or --without-cc was given. if test "${with_cc+set}" = set; then withval="$with_cc" ttt_ckcmd_cc=$with_cc unset ac_cv_prog_CC unset ac_cv_prog_CPP fi # Check whether --enable-ipv6 or --disable-ipv6 was given. if test "${enable_ipv6+set}" = set; then enableval="$enable_ipv6" ttt_ckcmd_ipv6=$enableval else ttt_ckcmd_ipv6="auto" fi # Do some error checking and defaulting for the host and target type. # The inputs are: # configure --host=HOST --target=TARGET --build=BUILD NONOPT # # The rules are: # 1. You are not allowed to specify --host, --target, and nonopt at the # same time. # 2. Host defaults to nonopt. # 3. If nonopt is not specified, then host defaults to the current host, # as determined by config.guess. # 4. Target and build default to nonopt. # 5. If nonopt is not specified, then target and build default to host. # The aliases save the names the user supplied, while $host etc. # will get canonicalized. case $host---$target---$nonopt in NONE---*---* | *---NONE---* | *---*---NONE) ;; *) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; esac # Make sure we can run config.sub. if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 echo "configure:656: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 echo "configure:677: checking target system type" >&5 target_alias=$target case "$target_alias" in NONE) case $nonopt in NONE) target_alias=$host_alias ;; *) target_alias=$nonopt ;; esac ;; esac target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 echo "configure:695: checking build system type" >&5 build_alias=$build case "$build_alias" in NONE) case $nonopt in NONE) build_alias=$host_alias ;; *) build_alias=$nonopt ;; esac ;; esac build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$build" 1>&6 test "$host_alias" != "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- # ----------------------------------------------------------------------- # # Set a variable containing current working directory if /bin/sh # doesn't do it already. # # ----------------------------------------------------------------------- PWD=`pwd` # ----------------------------------------------------------------------- # # C compiler and debugging flags # # ----------------------------------------------------------------------- ttt_ckenv_cc=$CC # # CC search order # # 1. command line (--with-cc) # 2. environment variable ($CC) # 3. cached variable ($ttt_cv_prog_cc) # 4. check for program (AC_PROG_CC) # 4. default to cc # echo $ac_n "checking which C compiler""... $ac_c" 1>&6 echo "configure:746: checking which C compiler" >&5 if test "x${ttt_ckcmd_cc}" != "x" ; then CC=${ttt_ckcmd_cc} unset ac_cv_prog_CPP unset ac_cv_prog_CC elif test "x${ttt_ckenv_cc}" != "x" ; then unset ac_cv_prog_CPP unset ac_cv_prog_CC elif test "x${ttt_cv_prog_cc}" != "x" ; then CC=${ttt_cv_prog_cc} unset ac_cv_prog_CC else # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:761: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:791: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:842: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:874: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 885 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:916: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:921: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:949: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi fi if test "x${CC}" = "x" ; then CC=cc fi echo "$ac_t""$CC" 1>&6 unset ttt_cv_prog_cc if eval "test \"`echo '$''{'ttt_cv_prog_cc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ttt_cv_prog_cc=$CC fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:995: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1016: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1033: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1050: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 if test "x${GCC}" != "x" ; then tttHaveGcc="yes" else echo $ac_n "checking if C compiler is really gcc""... $ac_c" 1>&6 echo "configure:1078: checking if C compiler is really gcc" >&5 cat > conftest.$ac_ext <&5 | egrep "_cc_is_gcc_" >/dev/null 2>&1; then rm -rf conftest* tttHaveGcc=yes else rm -rf conftest* tttHaveGcc=no fi rm -f conftest* echo "$ac_t""$tttHaveGcc" 1>&6 fi if test "${tttHaveGcc}" = "yes" ; then GCCFLAGS="-Wwrite-strings -fwritable-strings" else GCCFLAGS="" fi # # CFLAGS search order # # 1. command line (--with-cflags) # 2. cached variable ($ttt_cv_prog_cflags) # 3. set to "-O2" if using gcc ($tttHaveGcc) # 4. otherwise, default to "-O" # echo $ac_n "checking default compiler flags""... $ac_c" 1>&6 echo "configure:1117: checking default compiler flags" >&5 if test "x${ttt_ckcmd_cflags}" != "x" ; then CFLAGS=${ttt_ckcmd_cflags} elif test "x${ttt_cv_prog_cflags}" != "x" ; then CFLAGS=${ttt_cv_prog_cflags} elif test "${tttHaveGcc}" = "yes" ; then CFLAGS="-O2" else CFLAGS="-O" fi echo "$ac_t""$CFLAGS" 1>&6 unset ttt_cv_prog_cflags if eval "test \"`echo '$''{'ttt_cv_prog_cflags'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ttt_cv_prog_cflags=$CFLAGS fi # ----------------------------------------------------------------------- # # Programs: Check for existence of install program # # ----------------------------------------------------------------------- # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:1155: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # ----------------------------------------------------------------------- # # Headers: Check for header files used # # ----------------------------------------------------------------------- echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:1215: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1228: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:1295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_hdr in sys/sockio.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1322: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1332: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_hdr in sys/queue.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1362: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1372: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done # ----------------------------------------------------------------------- # # Functions: Check for gethostent # # ----------------------------------------------------------------------- for ac_func in gethostent do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1408: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done # ----------------------------------------------------------------------- # # Find the Tcl build configuration file "tclConfig.sh" # # ----------------------------------------------------------------------- echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6 echo "configure:1468: checking for tclConfig.sh" >&5 tclConfigFile="" guesses="\ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tcl_lib \ /usr/local/lib/tcl8.4 \ /usr/local/lib/tcl8.3 \ /usr/local/lib/tcl8.2 \ /usr/pkg/lib \ /usr/local/tcl/lib \ /usr/local/tcl/tcl8.4/lib \ /usr/local/tcl/tcl8.3/lib \ /usr/local/tcl/tcl8.2/lib \ /usr/lib/tcl8.4 \ /usr/lib/tcl8.3 \ /usr/lib/tcl8.2 \ $PWD/../tcl8.4 \ $PWD/../tcl8.3 \ $PWD/../tcl8.2 \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/tclConfig.sh" ; then tclConfigFile="$dir/tclConfig.sh" break fi done echo "$ac_t""${tclConfigFile}" 1>&6 if test "x$tclConfigFile" = "x" ; then echo "can't find Tcl configuration script \"tclConfig.sh\"" exit 1 fi # ----------------------------------------------------------------------- # # Find the X11R6 includes and libraries # # ----------------------------------------------------------------------- # If we find X, set shell vars x_includes and x_libraries to the # paths, otherwise set no_x=yes. # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 echo "configure:1517: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" : fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=NO ac_x_libraries=NO rm -fr conftestdir if mkdir conftestdir; then cd conftestdir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat > Imakefile <<'EOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' EOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case "$ac_im_incroot" in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; esac case "$ac_im_usrlibdir" in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; esac fi cd .. rm -fr conftestdir fi if test "$ac_x_includes" = NO; then # Guess where to find include files, by looking for this one X11 .h file. test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1584: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* # We can compile using X headers with no special include directory. ac_x_includes= else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Look for the header file in a standard set of common directories. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in \ /usr/X11/include \ /usr/X11R6/include \ /usr/X11R5/include \ /usr/X11R4/include \ \ /usr/include/X11 \ /usr/include/X11R6 \ /usr/include/X11R5 \ /usr/include/X11R4 \ \ /usr/local/X11/include \ /usr/local/X11R6/include \ /usr/local/X11R5/include \ /usr/local/X11R4/include \ \ /usr/local/include/X11 \ /usr/local/include/X11R6 \ /usr/local/include/X11R5 \ /usr/local/include/X11R4 \ \ /usr/X386/include \ /usr/x386/include \ /usr/XFree86/include/X11 \ \ /usr/include \ /usr/local/include \ /usr/unsupported/include \ /usr/athena/include \ /usr/local/x11r5/include \ /usr/lpp/Xamples/include \ \ /usr/openwin/include \ /usr/openwin/share/include \ ; \ do if test -r "$ac_dir/$x_direct_test_include"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest* fi # $ac_x_includes = NO if test "$ac_x_libraries" = NO; then # Check for the libraries. test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. ac_x_libraries= else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="$ac_save_LIBS" # First see if replacing the include by lib works. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ /usr/X11/lib \ /usr/X11R6/lib \ /usr/X11R5/lib \ /usr/X11R4/lib \ \ /usr/lib/X11 \ /usr/lib/X11R6 \ /usr/lib/X11R5 \ /usr/lib/X11R4 \ \ /usr/local/X11/lib \ /usr/local/X11R6/lib \ /usr/local/X11R5/lib \ /usr/local/X11R4/lib \ \ /usr/local/lib/X11 \ /usr/local/lib/X11R6 \ /usr/local/lib/X11R5 \ /usr/local/lib/X11R4 \ \ /usr/X386/lib \ /usr/x386/lib \ /usr/XFree86/lib/X11 \ \ /usr/lib \ /usr/local/lib \ /usr/unsupported/lib \ /usr/athena/lib \ /usr/local/x11r5/lib \ /usr/lpp/Xamples/lib \ /lib/usr/lib/X11 \ \ /usr/openwin/lib \ /usr/openwin/share/lib \ ; \ do for ac_extension in a so sl; do if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest* fi # $ac_x_libraries = NO if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$ac_t""$have_x" 1>&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 fi # ----------------------------------------------------------------------- # # Find the Tk build configuration file "tkConfig.sh" # # ----------------------------------------------------------------------- echo $ac_n "checking for tkConfig.sh""... $ac_c" 1>&6 echo "configure:1754: checking for tkConfig.sh" >&5 tkConfigFile="" guesses="\ $ttt_ckcmd_tk_home \ $ttt_ckcmd_tk_home/lib \ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tk_lib \ /usr/local/lib/tk8.4 \ /usr/local/lib/tk8.3 \ /usr/local/lib/tk8.2 \ /usr/pkg/lib \ /usr/local/tcl/lib \ /usr/local/tcl/tk8.4/lib \ /usr/local/tcl/tk8.3/lib \ /usr/local/tcl/tk8.2/lib \ /usr/lib/tk8.4 \ /usr/lib/tk8.3 \ /usr/lib/tk8.2 \ $PWD/../tk8.4 \ $PWD/../tk8.3 \ $PWD/../tk8.2 \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/tkConfig.sh" ; then tkConfigFile="$dir/tkConfig.sh" break fi done echo "$ac_t""${tkConfigFile}" 1>&6 # ----------------------------------------------------------------------- # # Find the [incr Tcl] build configuration file "itclConfig.sh" # # If we find one, use this directory's versions of tclConfig.sh # and tkConfig.sh. This will point us to versions of Tcl and # Tk with namespace support. # # ----------------------------------------------------------------------- echo $ac_n "checking for itclConfig.sh""... $ac_c" 1>&6 echo "configure:1799: checking for itclConfig.sh" >&5 itclConfigFile="" guesses="\ $ttt_ckcmd_tk_home \ $ttt_ckcmd_tk_home/lib \ $ttt_ckcmd_tcl_home \ $ttt_ckcmd_tcl_home/lib \ $ttt_cv_tk_lib \ /usr/local/lib/tk8.4 \ /usr/local/lib/tk8.3 \ /usr/local/lib/tk8.2 \ /usr/local/lib/tcl8.4 \ /usr/local/lib/tcl8.3 \ /usr/local/lib/tcl8.2 \ /usr/local/tcl/lib \ /usr/pkg/lib \ /usr/local/tcl/tk8.4/lib \ /usr/local/tcl/tk8.3/lib \ /usr/local/tcl/tk8.2/lib \ /usr/local/tcl/tcl8.4/lib \ /usr/local/tcl/tcl8.3/lib \ /usr/local/tcl/tcl8.2/lib \ /usr/lib/tk8.4 \ /usr/lib/tk8.3 \ /usr/lib/tk8.2 \ $prefix/lib \ $exec_prefix/lib \ $XLIBDIR \ /usr/local/lib /usr/lib" for dir in $guesses; do if test -r "$dir/itclConfig.sh" ; then itclConfigFile="$dir/itclConfig.sh" if test -r "$dir/tclConfig.sh" ; then tclConfigFile="$dir/tclConfig.sh" fi if test -r "$dir/tkConfig.sh" ; then tkConfigFile="$dir/tkConfig.sh" fi break fi done echo "$ac_t""${itclConfigFile}" 1>&6 # ----------------------------------------------------------------------- # # Source in the Tcl/Tk/[incr Tcl] configuration scripts. # # First source the Tcl/Tk scripts. Then source the [incr Tcl] # scripts, if needed. The variables [incr Tcl] script will # override those of the the tclConfig.sh or tkConfig.sh # # BTW: Does anyone actually use the tclConfig.sh and tkConfig.sh # scripts? They seem to be always missing something. For example, # why don't they say where to find the Tcl and Tk header files? # # For example, give me the library directory paths separately # (I can't easily parse "-Ldir", but I can always paste a -L # on the front). If I want to specify equivalent of the -R flag, # I need the build a path of the library directories. Such as # # "-R $(BLTLIB):$(TKLIB):$(TCLLIB):($XLIB)" # # ----------------------------------------------------------------------- if test "x$tkConfigFile" != "x" ; then . $tclConfigFile . $tkConfigFile fi tclIncSpec="-I${TCL_PREFIX}/include" tkIncSpec="-I${TK_PREFIX}/include" tclLibDir=${TCL_PREFIX}/lib tkLibDir=${TK_PREFIX}/lib case $target in *-freebsd*|*-netbsd*|*-openbsd*|*-sunos4*|*-linux-*) tclIncSpec="-I${TCL_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" tkIncSpec="-I${TK_PREFIX}/include/tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}" ;; esac itclLibSpec="" itclIncSpec="" itclSuffix="" if test "x$itclConfigFile" != "x" ; then . $itclConfigFile tclIncSpec="-I${TCL_PREFIX}/include/itcl" tkIncSpec="-I${TK_PREFIX}/include/itcl" tclLibDir=${TCL_PREFIX}/lib/itcl tkLibDir=${TK_PREFIX}/lib/itcl itclSuffix="i" fi tclLibSpec=${TCL_LIB_SPEC} tkLibSpec=${TK_LIB_SPEC} case $target in *-freebsd*|*-netbsd*|*-openbsd*|*-sunos4*) tclLib="-ltcl${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${itclSuffix}" tkLib="-ltk${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${itclSuffix}" ;; *) tclLib="-ltcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${itclSuffix}" tkLib="-ltk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${itclSuffix}" ;; esac # ----------------------------------------------------------------------- # # Tk libraries and header files # # ----------------------------------------------------------------------- if test "${bltIncSpec}" != "${tkIncSpec}" ; then tttIncludes="${tttIncludes} ${tkIncSpec}" fi if test "${bltLibDir}" = "${tkLibDir}" ; then tttLibraries="${tttLibraries} ${tkLib}" else tttLibraries="${tttLibraries} ${tkLibSpec}" if test "x${tkLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${tkLibDir}" fi fi # ----------------------------------------------------------------------- # # Tcl libraries and header files # # Add a header file directory specification only if the Tcl headers reside # in a different directory from Tk's. # # # ----------------------------------------------------------------------- if test "${tkIncSpec}" != "${tclIncSpec}" ; then tttIncludes="${tttIncludes} ${tclIncSpec}" fi if test "${tkLibDir}" = "${tclLibDir}" ; then tttLibraries="${tttLibraries} ${tclLib}" else tttLibraries="${tttLibraries} ${tclLibSpec}" if test "x${tclLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${tclLibDir}" fi fi # ----------------------------------------------------------------------- # # [incr Tcl] include files # # ----------------------------------------------------------------------- if test "x${itclIncSpec}" != "x" ; then tttIncludes="${itclIncSpec} ${tttIncludes}" fi # ----------------------------------------------------------------------- # # [incr Tcl] libraries # # ----------------------------------------------------------------------- if test "x${itclLibSpec}" != "x" ; then tttLibraries="${itclLibSpec} ${tttLibraries}" fi # ----------------------------------------------------------------------- # # Find the BLT header "blt.h" and library "libBLT.a" # # ----------------------------------------------------------------------- bltIncDir="" bltLibDir="" bltIncSpec="" bltLibSpec="" echo $ac_n "checking for blt.h""... $ac_c" 1>&6 echo "configure:1978: checking for blt.h" >&5 bltHdrFile="" guesses="\ $ttt_ckcmd_blt_home \ $ttt_ckcmd_blt_home/include \ $prefix/include \ $exec_prefix/include \ /usr/local/include \ /usr/local/blt/include \ /usr/pkg/include \ /usr/include" for dir in $guesses; do if test -r "$dir/blt.h" ; then bltHdrFile="$dir/blt.h" bltIncDir="$dir" bltIncSpec="-I$dir" break fi done echo "$ac_t""${bltHdrFile}" 1>&6 if test "x$bltHdrFile" = "x" ; then echo "can't find BLT header file \"blt.h\"" exit 1 fi echo $ac_n "checking for libBLT.a""... $ac_c" 1>&6 echo "configure:2006: checking for libBLT.a" >&5 bltLibFile="" guesses="\ $ttt_ckcmd_blt_home \ $ttt_ckcmd_blt_home/lib \ $prefix/lib \ $exec_prefix/lib \ /usr/local/lib \ /usr/local/blt/lib \ /usr/pkg/lib \ /usr/lib" for dir in $guesses; do if test -r "$dir/libBLT24.a" ; then bltLibFile="$dir/libBLT24.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT24" break elif test -r "$dir/libBLT.2.4.a" ; then bltLibFile="$dir/libBLT.2.4.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT.2.4" break elif test -r "$dir/libBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}.a" ; then bltLibFile="$dir/libBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT.2.4.${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}" break elif test -r "$dir/libBLT.a" ; then bltLibFile="$dir/libBLT.a" bltLibDir="$dir" bltLibSpec="-L$dir -lBLT" break fi done echo "$ac_t""${bltLibFile}" 1>&6 if test "x$bltLibFile" = "x" ; then echo "can't find BLT library file \"libBLT.a\"" exit 1 fi # ----------------------------------------------------------------------- # # BLT include files and libraries # # ----------------------------------------------------------------------- tttIncludes="${tttIncludes} ${bltIncSpec}" tttLibraries="${tttLibraries} ${bltLibSpec}" tttRunPath="${tttRunPath}:${bltLibDir}" # ----------------------------------------------------------------------- # # -lX11 # # ----------------------------------------------------------------------- if test "${tkLibDir}" = "${x_libraries}" ; then tttLibraries="${tttLibraries} -lX11" else tttLibraries="${tttLibraries} -L${x_libraries} -lX11" if test "x${tclLibDir}" != "x" ; then tttRunPath="${tttRunPath}:${x_libraries}" fi fi if test "${tkIncDir}" != "${x_includes}" ; then tttIncludes="${tttIncludes} -I${x_includes}" fi # ----------------------------------------------------------------------- # # PCAP header and library # # ----------------------------------------------------------------------- echo $ac_n "checking for pcap.h""... $ac_c" 1>&6 echo "configure:2081: checking for pcap.h" >&5 pcapHdrFile="" guesses="\ $ttt_ckcmd_pcap_home \ $ttt_ckcmd_pcap_home/include \ $prefix/include \ /usr/local/include /usr/include" for dir in $guesses; do if test -r "$dir/pcap.h" ; then pcapHdrFile="$dir/pcap.h" break fi done echo "$ac_t""${pcapHdrFile}" 1>&6 if test "x$pcapHdrFile" = "x" ; then echo "can't find pcap header \"pcap.h\"" echo "use \"--with-pcap=DIR\" to specify pcap directory" exit 1 fi if test "${dir}" != "/usr/include" ; then tttIncludes="${tttIncludes} -I${dir}" fi if test "${ttt_ckcmd_pcap_home}" != "no" ; then if test "${ttt_ckcmd_pcap_home}" = "yes" ; then spec="-lpcap" dir="" else spec="-L${ttt_ckcmd_pcap_home} -lpcap" dir=${ttt_ckcmd_pcap_home} fi echo $ac_n "checking for main in -lpcap""... $ac_c" 1>&6 echo "configure:2117: checking for main in -lpcap" >&5 ac_lib_var=`echo pcap'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lpcap $spec $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 found=yes else echo "$ac_t""no" 1>&6 found=no fi if test "${found}" = "yes" ; then tttLibraries="${tttLibraries} ${spec}" if test "x${dir}" != "x" ; then tttRunPath="${tttRunPath}:${dir}" fi else echo "can't find pcap library file \"libpcap.a\"" exit 1 fi fi # ----------------------------------------------------------------------- # # -lsocket # # ----------------------------------------------------------------------- echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 echo "configure:2170: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo socket | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi # ----------------------------------------------------------------------- # # -lnsl # # ----------------------------------------------------------------------- echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 echo "configure:2219: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo nsl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi # ----------------------------------------------------------------------- # # -lm # # ----------------------------------------------------------------------- echo $ac_n "checking for main in -lm""... $ac_c" 1>&6 echo "configure:2268: checking for main in -lm" >&5 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi # ----------------------------------------------------------------------- # # -ldl # # ----------------------------------------------------------------------- echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 echo "configure:2317: checking for main in -ldl" >&5 ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi # ----------------------------------------------------------------------- # # Set up a new default prefix to installation path. The ways # the prefix can be set and their precedence are as follows: # # 1. --prefix option given to ./configure. (prefix != NONE) # 2. use previously configured Tk prefix # # ----------------------------------------------------------------------- if test "$prefix" = "NONE" ; then prefix=${TK_PREFIX} fi if test "$exec_prefix" = "NONE" ; then exec_prefix=$prefix fi # ------------------------------------------------------------------------- # # Check for [incr Tcl] header files # # ------------------------------------------------------------------------- oldFlags=$CPPFLAGS CPPFLAGS="$CPPFLAGS $tttIncludes" for ac_hdr in itcl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2390: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_hdr in itk.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:2430: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:2440: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done CPPFLAGS=$oldFlags #--------------------------------------------------------------- # # IPv6 support # #--------------------------------------------------------------- echo $ac_n "checking for IPv6 support""... $ac_c" 1>&6 echo "configure:2474: checking for IPv6 support" >&5 if test "$ttt_ckcmd_ipv6" = auto; then cat > conftest.$ac_ext < #include int main() { int x = IPPROTO_IPV6; struct in6_addr a; ; return 0; } EOF if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_ipv6="yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_ipv6="no" fi rm -f conftest* else ac_cv_ipv6="$ttt_ckcmd_ipv6" fi if test "$ac_cv_ipv6" = yes; then tttFlags="-DIPV6 ${tttFlags}" fi echo "$ac_t""$ac_cv_ipv6" 1>&6 # ------------------------------------------------------------------------- # # misaligned access # # ------------------------------------------------------------------------- case "$target_cpu" in alpha|hp*|mips|sparc) tttFlags="-DALIGN_WORD ${tttFlags}" ;; esac # ------------------------------------------------------------------------- # # compilation environment # # ------------------------------------------------------------------------- tttLibraries="${tttLibraries} ${LIBS}" case $target in *-solaris2*) LDFLAGS="-R ${tttRunPath}" tttLibraries="${tttLibraries} -ldl" ;; *-freebsd*) ;; *-netbsd*|*-openbsd*) LDFLAGS="-R ${tttRunPath}" ;; *-bsdi*) tttLibraries="${tttLibraries} -ldl" ;; *-linux*) tttFlags="-D_BSD_SOURCE ${tttFlags}" tttLibraries="${tttLibraries} -ldl" ;; *) ;; esac INCLUDES=${tttIncludes} LIBS=${tttLibraries} TTT_LIBDIR="$libdir/ttt" TTT_FLAGS=${tttFlags} #-------------------------------------------------------------------- # Print out some of the more important settings #-------------------------------------------------------------------- echo "" echo "Configuration results:" echo "" echo " tcl.h found in $tclIncSpec" echo " tk.h found in $tkIncSpec" echo " blt.h found in $bltIncSpec" echo " X11/Xlib.h found in -I$x_includes" echo " libtcl.a found in $tclLibSpec" echo " libtk.a found in $tkLibSpec" echo " libBLT.a found in $bltLibSpec" echo " libX11.a found in -L$x_libraries -lX11" echo "" echo "Directories where TTT is to be installed:" echo "" echo " \"\$prefix\" is $prefix" echo " \"\$exec_prefix\" is $exec_prefix" echo "" echo " ttt to be installed in $bindir" echo " scripts to be installed in $TTT_LIBDIR" echo " manual pages to be installed in $mandir" echo "" #echo " DEFS: $DEFS" #echo " INCLUDES: $INCLUDES" #echo " LIBS: $LIBS" #echo " LDFLAGS: $LDFLAGS" #echo " TTT_FLAGS: $TTT_FLAGS" echo "" #-------------------------------------------------------------------- # # Generate Makefile # #-------------------------------------------------------------------- trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. cat > conftest.defs <<\EOF s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g s%\[%\\&%g s%\]%\\&%g s%\$%$$%g EOF DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` rm -f conftest.defs # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g s%@target@%$target%g s%@target_alias@%$target_alias%g s%@target_cpu@%$target_cpu%g s%@target_vendor@%$target_vendor%g s%@target_os@%$target_os%g s%@build@%$build%g s%@build_alias@%$build_alias%g s%@build_cpu@%$build_cpu%g s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@GCCFLAGS@%$GCCFLAGS%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@INCLUDES@%$INCLUDES%g s%@TTT_LIBDIR@%$TTT_LIBDIR%g s%@TTT_FLAGS@%$TTT_FLAGS%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 ttt-1.7.orig/tttview.10100644000273700007640000000312207217712232013535 0ustar scheffedv.TH TTTVIEW 1 "14 November 1997" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME ttt \- remote viewer for Tele Traffic Tapper .SH SYNOPSIS .na .B tttview [ .B \-addr .I addr ] [ .B \-mcastifaddr .I addr ] .br .ti +8 [ .B \-port .I recv_port ] [ .B \-probe .I addr ] [ .B \-yscale .I 'K'|'M'|n ] .br .SH DESCRIPTION .LP \fITttview\fP is a viewer for remote traffic monitoring, used with \fItttprobe(1)\fP. .br \fITttview\fP reads a startup script named \fIttt.tcl\fP in the current directory or in the system default directory (default is \fI/usr/local/lib/ttt\fP). Once started, \fItttview\fP goes into Tcl Shell. To quit \fItttview\fP, type \fIquit\fP. You can change \fIttt variables\fP from Tcl Shell or from the startup script. See the comments in \fIttt.tcl\fP for more details. \fITttview\fP requires libBLT. libBLT requires Tcl/Tk. .SH OPTIONS .TP .B \-addr Specifies the \fIdestination address\fP to receive multicast report packets from \fItttprobe(1)\fP. If not specified, the default address is chosen. .TP .B \-mcastifaddr Specifies the multicast interface address to receive multicast report packets from \fItttprobe(1)\fP. Only useful when you select an interface to join a multicast group. .TP .B \-port Specifies the UDP port to receive report packets from \fItttprobe(1)\fP. The default is 7288. .TP .B \-probe Specifies the address of \fItttprobe(1)\fP. Only useful to select one among multiple probes. .TP .B \-yscale Specifies the scale of y axis. \fIK\fR and \fIM\fR represent 1000 and 1000000 respectively. .SH SEE ALSO ttt(1), tttprobe(1), BLT(n) .SH BUGS