Codebase list nfdump / 2b15a32
Imported Upstream version 1.4.1 Erik Wenzel 15 years ago
49 changed file(s) with 21493 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Peter Haag haag@switch.ch
0 *
1 * The nfdump project is distributed under the BSD license:
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
0 2005-08-22 v1.4
1 - nfreplay: Bug fix sending flows.
2 - nfdump: Add CryptoPAn code to anonymize IP addresses. New option -K
3 - nfdump: Change time format in output to ISO 8601 compatible: e.g. 1981-04-05 14:30:30.100
4 - nfdump: Add scaling factor k,m,g to number in filter syntax: e.g. bytes > 1m
5 - nfdump: Create new output format extended with additional fields pps, bps and bpp
6 - nfdump: Rename output format extended to raw
7 - nfdump: More than one single flow element statistic ( -s ) is now possible
8 - nfdump: Add user defined sort order in flow element statistic
9 - nfdump: Flow element statistic can be ordered by more than one order in the same run
10 - nfdump: Add pps, bps and bpp fields in flow element statistics
11 - nfdump: Add more symbolic protocols ESP, AH, GRP and RVSP to filter syntax
12 - nfdump: Add duration, pps, bps and bpp to filter syntax
13 - nfdump: Make nfdump miliseconds aware. Older versions skipped msecs.
14 Binary nfdump file format changed due to this.
15 output formats changed, due to this.
16 - nfdump: Add interface in/out if <num> syntax to filter
17 - nfcapd: Add flow_sequence check. Reports missing flows now.
18 - nfcapd: Report statistics to syslog LOG_INFO when data file is rotated.
19 - ft2nfdump: Add ft2nfdump to read netflow data from flow-tools
20
21 2005-04-21 v1.3
22 - Add option -A for more flexible aggregation.
23 - Correct spelling errors :(
24
25 2005-03-04 v1.2.1
26 Bug fix release
27 - nfcapd: launcher subprocess may hang on Linux 2.6.x kernels.
28 Cleaned up interrupt handling.
29 - nfcapd: fix include order of socket.h and types.h in order to
30 compile cleanly under FreeBSD 4.x
31 - nfcapd: clean up syslog logging.
32 - nfdump: Multiple sources ( -M ) and sort flows ( -m ) with
33 -c <limit> did not list the correct flows.
34 - nfprofile: Profiling with multiple sources may produce incorrect
35 profiles.
36
37 2004-12-20 v1.2
38 - nfcapd handles transparent v5 and v7 flows. v7 gets converted into v5
39 - nfcapd can execute any command at the end of interval. New option -x
40 - nfdump Extended filter syntax for flags, to, bytes and packets
41 - Rearrange output formats in nfdump: new switch -o, remove switch -E
42 output formats: 'line', 'long', 'extended' and 'pipe'
43 - More flexible statistic handling in nfdump: cleanup ugly -s -s -s
44 syntax. Replaced by -s <stat> option. New statistics for Port and AS.
45
46 2004-09-20 v 1.1
47 First public Version.
0 Installation:
1 -------------
2 The tools should work on any *nix flavor. They have been compiled
3 and tested on Linux, Solaris (32/64bit), OpenBSD (32/64bit) as well
4 as MacOSX.
5
6 ./configure
7 make
8 make install
9
10 should do the job.
11
12 configure options:
13 --enable-64
14 When using Snore CC on Solaris, you may compile 64 bit code.
15 default is NO
16
17 --enable-ftconv
18 Build ft2nfdump converter. The flow-tools sources are required
19 to build ft2nfdump.
20
21 --with-ftpath[=flow-tools sources]
22 When building ft2nfdump, configure expects to find the
23 flow-tools sources in ../flow-tools-0.67. In case of another
24 path, the flow-tools directory is specified.
25
26 The parser code produced by yacc or bison can generate some
27 warnings, when being compiled. These can safely be ignored.
28
29 On any Solaris, make sure you have flex installed, as lex
30 on Solaris does not compile the scanner properly.
31
32 Uninstalling:
33
34 make uninstall
35
36 Notes on compatibility:
37 nfdump 1.4 introduces milisecond resolution. This resulted in a small
38 change of the binary format of nfdump files. However, this change is
39 fully transparent to the user, which means, nfdump 1.4 is able to read
40 and process older files, and nfdump < 1.4 is able to read and process
41 nfdump 1,4 files. But note: The milisecond resolution is only available
42 in data files captured with nfcapd v1.4 and processed with nfdump 1.4.
0 # Building Open Source Network Security Tools
1 #
2 # This file is part of the nfdump project.
3 #
4 # Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # * Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation
14 # and/or other materials provided with the distribution.
15 # * Neither the name of SWITCH nor the names of its contributors may be
16 # used to endorse or promote products derived from this software without
17 # specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30 #
31 #
32 # $Author: peter $
33 #
34 # $Id: Makefile.in 40 2005-08-24 08:07:54Z peter $
35 #
36
37 srcdir = .
38 DESTDIR =
39 CC = @CC@
40 YACC = @YACC@
41 LEX = @LEX@
42 INSTALL = @INSTALL@
43 CFLAGS = @CFLAGS@
44 CPPFLAGS = -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
45 YFLAGS = -d -v
46 LFLAGS = @LFLAGS@
47 LDFLAGS = @LIBS@
48 prefix = @prefix@
49 PREFIX = $(DESTDIR)/$(prefix)
50 MANDIR = $(DESTDIR)/@mandir@
51 CRYPTO_PAN_OBJ = panonymizer.o rijndael.o
52 FILTER_OBJ = grammar.o scanner.o nftree.o
53 NFDUMP_OBJ = nfdump.o $(FILTER_OBJ) nf_common.o nfstat.o nfprof.o util.o $(CRYPTO_PAN_OBJ)
54 NFPROF_OBJ = nfprofile.o profile.o $(FILTER_OBJ) nf_common.o util.o $(CRYPTO_PAN_OBJ)
55 NFRPLY_OBJ = nfreplay.o $(FILTER_OBJ) nf_common.o util.o $(CRYPTO_PAN_OBJ)
56 NFCAPD_OBJ = nfcapd.o nf_common.o launch.o $(CRYPTO_PAN_OBJ)
57 FT2NF_OBJ = ft2nfdump.o nf_common.o $(CRYPTO_PAN_OBJ)
58 OBJECTS = nfcapd nfdump nfprofile nfreplay nftree_check nfgen @opt_objects@
59 INCS = @FT_INCLUDES@
60 LIBS =
61 FT_LIBS = -lft -lz
62 FT_LDFLAGS = @FT_LDFLAGS@
63
64 .c.o:
65 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(INCS) $<
66
67 all: $(OBJECTS)
68
69 nfcapd: $(NFCAPD_OBJ)
70 $(CC) $(CFLAGS) -o $@ $(NFCAPD_OBJ) $(LDFLAGS)
71
72 nftree_check: nftree_check.o $(FILTER_OBJ)
73 $(CC) $(CFLAGS) $(INCS) -o $@ nftree_check.o $(FILTER_OBJ) $(LDFLAGS)
74
75 nfgen: nfgen.o
76 $(CC) $(CFLAGS) $(INCS) -o $@ $? $(LDFLAGS)
77
78 nfdump: $(NFDUMP_OBJ)
79 $(CC) $(CFLAGS) $(INCS) -o $@ $(NFDUMP_OBJ) $(LDFLAGS)
80
81 nfprofile: $(NFPROF_OBJ)
82 $(CC) $(CFLAGS) $(INCS) -o $@ $(NFPROF_OBJ) $(LDFLAGS)
83
84 nfreplay: $(NFRPLY_OBJ)
85 $(CC) $(CFLAGS) $(INCS) -o $@ $(NFRPLY_OBJ) $(LDFLAGS)
86
87 ft2nfdump: $(FT2NF_OBJ)
88 $(CC) $(CFLAGS) -o $@ $(FT2NF_OBJ) $(FT_LDFLAGS) $(FT_LIBS)
89
90 install: $(OBJECTS)
91 test -d $(PREFIX) || install -d -o root -g bin -m 755 $(PREFIX)
92 test -d $(PREFIX)/bin || install -d -o root -g bin -m 755 $(PREFIX)/bin
93 test -d $(MANDIR) || install -d -o root -g bin -m 755 $(MANDIR)
94 test -d $(MANDIR)/man1 || install -d -o root -g bin -m 755 $(MANDIR)/man1
95 $(INSTALL) -o root -g bin -m 755 nfcapd $(PREFIX)/bin
96 $(INSTALL) -o root -g bin -m 755 nfdump $(PREFIX)/bin
97 $(INSTALL) -o root -g bin -m 755 nfprofile $(PREFIX)/bin
98 $(INSTALL) -o root -g bin -m 755 nfreplay $(PREFIX)/bin
99 test -f $(PREFIX)/bin/nfclean.pl || $(INSTALL) -o root -g bin -m 755 nfclean.pl $(PREFIX)/bin
100
101 $(INSTALL) -o root -g bin -m 644 nfcapd.1 $(MANDIR)/man1
102 $(INSTALL) -o root -g bin -m 644 nfdump.1 $(MANDIR)/man1
103 $(INSTALL) -o root -g bin -m 644 nfprofile.1 $(MANDIR)/man1
104 $(INSTALL) -o root -g bin -m 644 nfreplay.1 $(MANDIR)/man1
105 if test -f ft2nfdump; then \
106 $(INSTALL) -o root -g bin -m 755 ft2nfdump $(PREFIX)/bin; \
107 $(INSTALL) -o root -g bin -m 644 ft2nfdump.1 $(MANDIR)/man1; \
108 fi;
109
110 uninstall:
111 /bin/rm -f $(PREFIX)/bin/nfcapd
112 /bin/rm -f $(PREFIX)/bin/nfdump
113 /bin/rm -f $(PREFIX)/bin/nfprofile
114 /bin/rm -f $(PREFIX)/bin/nfreplay
115 /bin/rm -f $(PREFIX)/bin/nfclean.pl
116
117 /bin/rm -f $(MANDIR)/man1/nfcapd.1
118 /bin/rm -f $(MANDIR)/man1/nfdump.1
119 /bin/rm -f $(MANDIR)/man1/nfprofile.1
120 /bin/rm -f $(MANDIR)/man1/nfreplay.1
121
122 test: nftree_check
123 ./nftree_check
124 ./nfgen | ./nfdump -o extended | head -17 > test1.out
125 diff test1.out nfdump.test.out
126 ./nfgen > test.flows
127 ./nfdump -r test.flows -o extended | head -17 > test2.out
128 diff test2.out nfdump.test.out
129 rm -r test1.out test2.out
130
131 clean:
132 rm -f *.o *~ y.* *.tab.* *core* $(OBJECTS) grammar.h grammar.c scanner.c
133
134 distclean:
135 rm -f *.o *~ y.* *.tab.* *core* $(OBJECTS) grammar.h grammar.c scanner.c
136 rm -f config.log config.h config.status Makefile
137
138 lint:
139 splint -warnposix $(FSRC)
140
141 grammar.h: grammar.c
142 grammar.c: grammar.y
143 @rm -f grammar.c grammar.h
144 $(YACC) $(YFLAGS) $<
145 mv y.tab.c grammar.c
146 mv y.tab.h grammar.h
147
148 scanner.c: scanner.l
149 @rm -f $@
150 $(LEX) $(LFLAGS) $<
151 mv lex.yy.c $@
152
153 depend: grammar.c scanner.c
154 makedepend $(CPPFLAGS) -- $(ASRC)
155
156 # EOF
157 # DO NOT DELETE
0 This is a small description, what the nfdump tools do and how they work.
1 Nfdump is distributed under the BSD license - see BSD-license.txt
2
3 The nfdump tools collect and process netflow data on the command line.
4 They are part of the NFSEN project which is explained more detailed at
5 http://www.terena.nl/tech/task-forces/tf-csirt/meeting12/nfsen-Haag.pdf
6
7 The Web interface mentioned is not part of nfdump and will be released
8 separately.
9
10 nfdump tools overview:
11 ----------------------
12
13 nfcapd - netflow capture daemon.
14 Reads the netflow data from the network and stores the data into files.
15 Automatically rotate files every n minutes. ( typically ever 5 min )
16 nfcapd reads netflow v5 and v7 flows transparently. v7 flows are
17 converted into v5 flows. You need one nfcapd process for each netflow
18 stream.
19
20 nfdump - netflow dump.
21 Reads the netflow data from the files stored by nfcapd. It's syntax is
22 similar to tcpdump. If you like tcpdump you will like nfdump.
23 Displays netflow data and creates top N statistics of flow, bytes,
24 packets and IP addresses.
25
26 nfprofile - netflow profiler.
27 Reads the netflow data from the files stored by nfcapd. Filters the
28 netflow data according to the specified filter sets ( profiles ) and
29 stores the filtered data into files for later use.
30
31 nfreplay - netflow replay
32 Reads the netflow data from the files stored by nfcapd and sends it
33 over the network to another host.
34
35 nfclean.pl - cleanup old data
36 Sample script to cleanup old data. You may run this script every
37 hour or so.
38
39 ft2nfdump - read flow-tools format - Optional tool
40 ft2nfdump acts as a pipe converter for flow-tools data. It allows
41 to read any flow-tools data and process and save it in nfdump format.
42
43
44 Principle of Operation:
45 -----------------------
46 The goal of the design is to able to analyze netflow data from
47 the past as well as to track interesting traffic patterns
48 continuously. The amount of time back in the past is limited only
49 by the disk storage available for all the netflow data. The tools
50 are optimized for speed for efficient filtering. The filter rules
51 should look familiar to the syntax of tcpdump ( pcap compatible ).
52
53 All data is stored to disk, before it gets analyzed. This separates
54 the process of storing and analyzing the data.
55
56 The data is organized in a time based fashion. Every n minutes
57 - typically 5 min - nfcapd rotates and renames the output file
58 with the timestamp nfcapd.YYYYMMddhhmm of the interval e.g.
59 nfcapd.200407110845 contains data from July 11th 2004 08:45 onward.
60 Based on a 5min time interval, this results in 288 files per day.
61
62 Analyzing the data can be done for a single file, or by concatenating
63 several files for a single output. The output is either ASCII text
64 or binary data, when saved into a file, ready to be processed again
65 with the same tools.
66
67 You may have several netflow sources - let's say 'router1' 'router2'
68 and so on. The data is organized as follows:
69
70 /flow_base_dir/router1
71 /flow_base_dir/router2
72
73 which means router1 and router2 are subdirs of the flow_base_dir.
74 For each of the netflow sources you have to start an nfcpad process:
75
76 nfcapd -w -D -l /flow_base_dir/router1 -p 23456
77 nfcapd -w -D -l /flow_base_dir/router2 -p 23457
78
79 Security: none of the tools requires root privileges, unless you have
80 a port < 1024. However, there is no access control mechanism in nfcapd.
81 It is assumed, that host level security is in place to filter the
82 proper IP addresses.
83
84 See the manual pages or use the -h switch for details on using
85 each of the programs. For any questions send email to haag@switch.ch
86
87 Configure your router to export netflow. See the relevant documentation
88 for your model.
89
90 A generic Cisco sample configuration enabling NetFlow on an interface:
91
92 interface fastethernet 0/0
93 ip route-cache flow
94
95 To tell the router where to send the NetFlow data, enter the following
96 global configuration command:
97
98 ip flow-export <ip-address> <udp-port>
99 ip flow-export version 5
100
101 ip flow-cache timeout active 5
102
103 This breaks up long-lived flows into 5-minute segments. You can choose
104 any number of minutes between 1 and 60;
105
106 See the relevant documentation for a full description of netflow commands
107
108 Note: Netflow version v5 and v7 have 32 bit counter values. The number of
109 packets or bytes may overflow this value, within the flow-cache timeout
110 on very busy routers. To prevent overflow, you may consider to reduce the
111 flow-cache timeout to lower values. All nfdump tools use 64 bit counters
112 internally, which means, all aggregated values are correctly reported.
113
114 The binary format of the data files is similar to the v5 netflow format
115 except the date fields, which are converted into UNIX time format. For
116 speed reasons the binary format is machine architecture dependent, and
117 as such can not be exchanged between little and big endian systems.
118
119 Flow-tools compatibility
120 ------------------------
121 When building with configure option --enable-ftconv, the flow-tools converter
122 is included. Using this converter, any flow-tools created data can be read
123 and processed and stored by nfdump.
124
125 Example:
126
127 flow-cat [options] | ft2nfdump | nfdump [options]
128
129
130 See the INSTALL file for installation details.
0 /* config.h.in. Generated from configure.in by autoheader. */
1
2 /* Define to 1 if the `closedir' function returns void instead of `int'. */
3 #undef CLOSEDIR_VOID
4
5 /* Define to 1 if you have the `alarm' function. */
6 #undef HAVE_ALARM
7
8 /* Define to 1 if you have the <arpa/inet.h> header file. */
9 #undef HAVE_ARPA_INET_H
10
11 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
12 */
13 #undef HAVE_DIRENT_H
14
15 /* Define to 1 if you have the <fcntl.h> header file. */
16 #undef HAVE_FCNTL_H
17
18 /* Define to 1 if you have the `fork' function. */
19 #undef HAVE_FORK
20
21 /* Define to 1 if you have the `gethostbyname' function. */
22 #undef HAVE_GETHOSTBYNAME
23
24 /* Define to 1 if you have the `inet_ntoa' function. */
25 #undef HAVE_INET_NTOA
26
27 /* Define to 1 if you have the <inttypes.h> header file. */
28 #undef HAVE_INTTYPES_H
29
30 /* Define to 1 if you have the <iso/limits_iso.h> header file. */
31 #undef HAVE_ISO_LIMITS_ISO_H
32
33 /* Define to 1 if you have the `nsl' library (-lnsl). */
34 #undef HAVE_LIBNSL
35
36 /* Define to 1 if you have the `socket' library (-lsocket). */
37 #undef HAVE_LIBSOCKET
38
39 /* Define to 1 if you have the `z' library (-lz). */
40 #undef HAVE_LIBZ
41
42 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and
43 to 0 otherwise. */
44 #undef HAVE_MALLOC
45
46 /* Define to 1 if you have the <memory.h> header file. */
47 #undef HAVE_MEMORY_H
48
49 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
50 #undef HAVE_NDIR_H
51
52 /* Define to 1 if you have the <netinet/in.h> header file. */
53 #undef HAVE_NETINET_IN_H
54
55 /* Define to 1 if your system has a GNU libc compatible `realloc' function,
56 and to 0 otherwise. */
57 #undef HAVE_REALLOC
58
59 /* Define to 1 if you have the `scandir' function. */
60 #undef HAVE_SCANDIR
61
62 /* Define to 1 if you have the `setsockopt' function. */
63 #undef HAVE_SETSOCKOPT
64
65 /* Define to 1 if you have the `socket' function. */
66 #undef HAVE_SOCKET
67
68 /* Define to 1 if `stat' has the bug that it succeeds when given the
69 zero-length file name argument. */
70 #undef HAVE_STAT_EMPTY_STRING_BUG
71
72 /* Define to 1 if stdbool.h conforms to C99. */
73 #undef HAVE_STDBOOL_H
74
75 /* Define to 1 if you have the <stdint.h> header file. */
76 #undef HAVE_STDINT_H
77
78 /* Define to 1 if you have the <stdlib.h> header file. */
79 #undef HAVE_STDLIB_H
80
81 /* Define to 1 if you have the `strchr' function. */
82 #undef HAVE_STRCHR
83
84 /* Define to 1 if you have the `strdup' function. */
85 #undef HAVE_STRDUP
86
87 /* Define to 1 if you have the `strerror' function. */
88 #undef HAVE_STRERROR
89
90 /* Define to 1 if you have the `strftime' function. */
91 #undef HAVE_STRFTIME
92
93 /* Define to 1 if you have the <strings.h> header file. */
94 #undef HAVE_STRINGS_H
95
96 /* Define to 1 if you have the <string.h> header file. */
97 #undef HAVE_STRING_H
98
99 /* Define to 1 if you have the `strrchr' function. */
100 #undef HAVE_STRRCHR
101
102 /* Define to 1 if you have the `strstr' function. */
103 #undef HAVE_STRSTR
104
105 /* Define to 1 if you have the <syslog.h> header file. */
106 #undef HAVE_SYSLOG_H
107
108 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
109 */
110 #undef HAVE_SYS_DIR_H
111
112 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
113 */
114 #undef HAVE_SYS_NDIR_H
115
116 /* Define to 1 if you have the <sys/socket.h> header file. */
117 #undef HAVE_SYS_SOCKET_H
118
119 /* Define to 1 if you have the <sys/stat.h> header file. */
120 #undef HAVE_SYS_STAT_H
121
122 /* Define to 1 if you have the <sys/time.h> header file. */
123 #undef HAVE_SYS_TIME_H
124
125 /* Define to 1 if you have the <sys/types.h> header file. */
126 #undef HAVE_SYS_TYPES_H
127
128 /* Define to 1 if you have the <unistd.h> header file. */
129 #undef HAVE_UNISTD_H
130
131 /* Define to 1 if you have the `vfork' function. */
132 #undef HAVE_VFORK
133
134 /* Define to 1 if you have the <vfork.h> header file. */
135 #undef HAVE_VFORK_H
136
137 /* Define to 1 if `fork' works. */
138 #undef HAVE_WORKING_FORK
139
140 /* Define to 1 if `vfork' works. */
141 #undef HAVE_WORKING_VFORK
142
143 /* Define to 1 if the system has the type `_Bool'. */
144 #undef HAVE__BOOL
145
146 /* Define to 1 if `lstat' dereferences a symlink specified with a trailing
147 slash. */
148 #undef LSTAT_FOLLOWS_SLASHED_SYMLINK
149
150 /* Define to the address where bug reports for this package should be sent. */
151 #undef PACKAGE_BUGREPORT
152
153 /* Define to the full name of this package. */
154 #undef PACKAGE_NAME
155
156 /* Define to the full name and version of this package. */
157 #undef PACKAGE_STRING
158
159 /* Define to the one symbol short name of this package. */
160 #undef PACKAGE_TARNAME
161
162 /* Define to the version of this package. */
163 #undef PACKAGE_VERSION
164
165 /* The size of a `void *', as computed by sizeof. */
166 #undef SIZEOF_VOID_P
167
168 /* Define to 1 if you have the ANSI C header files. */
169 #undef STDC_HEADERS
170
171 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
172 #undef TIME_WITH_SYS_TIME
173
174 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
175 #undef TM_IN_SYS_TIME
176
177 /* Define to 1 if your processor stores words with the most significant byte
178 first (like Motorola and SPARC, unlike Intel and VAX). */
179 #undef WORDS_BIGENDIAN
180
181 /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
182 `char[]'. */
183 #undef YYTEXT_POINTER
184
185 /* Define to empty if `const' does not conform to ANSI C. */
186 #undef const
187
188 /* Define to `__inline__' or `__inline' if that's what the C compiler
189 calls it, or to nothing if 'inline' is not supported under any name. */
190 #ifndef __cplusplus
191 #undef inline
192 #endif
193
194 /* Define to rpl_malloc if the replacement function should be used. */
195 #undef malloc
196
197 /* Define to `int' if <sys/types.h> does not define. */
198 #undef pid_t
199
200 /* Define to rpl_realloc if the replacement function should be used. */
201 #undef realloc
202
203 /* Define to `unsigned' if <sys/types.h> does not define. */
204 #undef size_t
205
206 /* Define as `fork' if `vfork' does not work. */
207 #undef vfork
0 #! /bin/sh
1 # From configure.in Revision: 40 .
2 # Guess values for system-dependent variables and create Makefiles.
3 # Generated by GNU Autoconf 2.59 for nfdump 1.4.
4 #
5 # Report bugs to <haag@switch.ch>.
6 #
7 # Copyright (C) 2003 Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software Foundation
9 # gives unlimited permission to copy, distribute and modify it.
10 ## --------------------- ##
11 ## M4sh Initialization. ##
12 ## --------------------- ##
13
14 # Be Bourne compatible
15 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
16 emulate sh
17 NULLCMD=:
18 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
19 # is contrary to our usage. Disable this feature.
20 alias -g '${1+"$@"}'='"$@"'
21 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
22 set -o posix
23 fi
24 DUALCASE=1; export DUALCASE # for MKS sh
25
26 # Support unset when possible.
27 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
28 as_unset=unset
29 else
30 as_unset=false
31 fi
32
33
34 # Work around bugs in pre-3.0 UWIN ksh.
35 $as_unset ENV MAIL MAILPATH
36 PS1='$ '
37 PS2='> '
38 PS4='+ '
39
40 # NLS nuisances.
41 for as_var in \
42 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
43 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
44 LC_TELEPHONE LC_TIME
45 do
46 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
47 eval $as_var=C; export $as_var
48 else
49 $as_unset $as_var
50 fi
51 done
52
53 # Required to use basename.
54 if expr a : '\(a\)' >/dev/null 2>&1; then
55 as_expr=expr
56 else
57 as_expr=false
58 fi
59
60 if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
61 as_basename=basename
62 else
63 as_basename=false
64 fi
65
66
67 # Name of the executable.
68 as_me=`$as_basename "$0" ||
69 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
70 X"$0" : 'X\(//\)$' \| \
71 X"$0" : 'X\(/\)$' \| \
72 . : '\(.\)' 2>/dev/null ||
73 echo X/"$0" |
74 sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
75 /^X\/\(\/\/\)$/{ s//\1/; q; }
76 /^X\/\(\/\).*/{ s//\1/; q; }
77 s/.*/./; q'`
78
79
80 # PATH needs CR, and LINENO needs CR and PATH.
81 # Avoid depending upon Character Ranges.
82 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
83 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
84 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
85 as_cr_digits='0123456789'
86 as_cr_alnum=$as_cr_Letters$as_cr_digits
87
88 # The user is always right.
89 if test "${PATH_SEPARATOR+set}" != set; then
90 echo "#! /bin/sh" >conf$$.sh
91 echo "exit 0" >>conf$$.sh
92 chmod +x conf$$.sh
93 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
94 PATH_SEPARATOR=';'
95 else
96 PATH_SEPARATOR=:
97 fi
98 rm -f conf$$.sh
99 fi
100
101
102 as_lineno_1=$LINENO
103 as_lineno_2=$LINENO
104 as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
105 test "x$as_lineno_1" != "x$as_lineno_2" &&
106 test "x$as_lineno_3" = "x$as_lineno_2" || {
107 # Find who we are. Look in the path if we contain no path at all
108 # relative or not.
109 case $0 in
110 *[\\/]* ) as_myself=$0 ;;
111 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
112 for as_dir in $PATH
113 do
114 IFS=$as_save_IFS
115 test -z "$as_dir" && as_dir=.
116 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
117 done
118
119 ;;
120 esac
121 # We did not find ourselves, most probably we were run as `sh COMMAND'
122 # in which case we are not to be found in the path.
123 if test "x$as_myself" = x; then
124 as_myself=$0
125 fi
126 if test ! -f "$as_myself"; then
127 { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
128 { (exit 1); exit 1; }; }
129 fi
130 case $CONFIG_SHELL in
131 '')
132 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
133 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
134 do
135 IFS=$as_save_IFS
136 test -z "$as_dir" && as_dir=.
137 for as_base in sh bash ksh sh5; do
138 case $as_dir in
139 /*)
140 if ("$as_dir/$as_base" -c '
141 as_lineno_1=$LINENO
142 as_lineno_2=$LINENO
143 as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
144 test "x$as_lineno_1" != "x$as_lineno_2" &&
145 test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
146 $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
147 $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
148 CONFIG_SHELL=$as_dir/$as_base
149 export CONFIG_SHELL
150 exec "$CONFIG_SHELL" "$0" ${1+"$@"}
151 fi;;
152 esac
153 done
154 done
155 ;;
156 esac
157
158 # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
159 # uniformly replaced by the line number. The first 'sed' inserts a
160 # line-number line before each line; the second 'sed' does the real
161 # work. The second script uses 'N' to pair each line-number line
162 # with the numbered line, and appends trailing '-' during
163 # substitution so that $LINENO is not a special case at line end.
164 # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
165 # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
166 sed '=' <$as_myself |
167 sed '
168 N
169 s,$,-,
170 : loop
171 s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
172 t loop
173 s,-$,,
174 s,^['$as_cr_digits']*\n,,
175 ' >$as_me.lineno &&
176 chmod +x $as_me.lineno ||
177 { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
178 { (exit 1); exit 1; }; }
179
180 # Don't try to exec as it changes $[0], causing all sort of problems
181 # (the dirname of $[0] is not the place where we might find the
182 # original and so on. Autoconf is especially sensible to this).
183 . ./$as_me.lineno
184 # Exit status is that of the last command.
185 exit
186 }
187
188
189 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
190 *c*,-n*) ECHO_N= ECHO_C='
191 ' ECHO_T=' ' ;;
192 *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
193 *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
194 esac
195
196 if expr a : '\(a\)' >/dev/null 2>&1; then
197 as_expr=expr
198 else
199 as_expr=false
200 fi
201
202 rm -f conf$$ conf$$.exe conf$$.file
203 echo >conf$$.file
204 if ln -s conf$$.file conf$$ 2>/dev/null; then
205 # We could just check for DJGPP; but this test a) works b) is more generic
206 # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
207 if test -f conf$$.exe; then
208 # Don't use ln at all; we don't have any links
209 as_ln_s='cp -p'
210 else
211 as_ln_s='ln -s'
212 fi
213 elif ln conf$$.file conf$$ 2>/dev/null; then
214 as_ln_s=ln
215 else
216 as_ln_s='cp -p'
217 fi
218 rm -f conf$$ conf$$.exe conf$$.file
219
220 if mkdir -p . 2>/dev/null; then
221 as_mkdir_p=:
222 else
223 test -d ./-p && rmdir ./-p
224 as_mkdir_p=false
225 fi
226
227 as_executable_p="test -f"
228
229 # Sed expression to map a string onto a valid CPP name.
230 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
231
232 # Sed expression to map a string onto a valid variable name.
233 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
234
235
236 # IFS
237 # We need space, tab and new line, in precisely that order.
238 as_nl='
239 '
240 IFS=" $as_nl"
241
242 # CDPATH.
243 $as_unset CDPATH
244
245
246 # Name of the host.
247 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
248 # so uname gets run too.
249 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
250
251 exec 6>&1
252
253 #
254 # Initializations.
255 #
256 ac_default_prefix=/usr/local
257 ac_config_libobj_dir=.
258 cross_compiling=no
259 subdirs=
260 MFLAGS=
261 MAKEFLAGS=
262 SHELL=${CONFIG_SHELL-/bin/sh}
263
264 # Maximum number of lines to put in a shell here document.
265 # This variable seems obsolete. It should probably be removed, and
266 # only ac_max_sed_lines should be used.
267 : ${ac_max_here_lines=38}
268
269 # Identity of this package.
270 PACKAGE_NAME='nfdump'
271 PACKAGE_TARNAME='nfdump'
272 PACKAGE_VERSION='1.4'
273 PACKAGE_STRING='nfdump 1.4'
274 PACKAGE_BUGREPORT='haag@switch.ch'
275
276 ac_unique_file="grammar.y"
277 # Factoring default headers for most tests.
278 ac_includes_default="\
279 #include <stdio.h>
280 #if HAVE_SYS_TYPES_H
281 # include <sys/types.h>
282 #endif
283 #if HAVE_SYS_STAT_H
284 # include <sys/stat.h>
285 #endif
286 #if STDC_HEADERS
287 # include <stdlib.h>
288 # include <stddef.h>
289 #else
290 # if HAVE_STDLIB_H
291 # include <stdlib.h>
292 # endif
293 #endif
294 #if HAVE_STRING_H
295 # if !STDC_HEADERS && HAVE_MEMORY_H
296 # include <memory.h>
297 # endif
298 # include <string.h>
299 #endif
300 #if HAVE_STRINGS_H
301 # include <strings.h>
302 #endif
303 #if HAVE_INTTYPES_H
304 # include <inttypes.h>
305 #else
306 # if HAVE_STDINT_H
307 # include <stdint.h>
308 # endif
309 #endif
310 #if HAVE_UNISTD_H
311 # include <unistd.h>
312 #endif"
313
314 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC LEX LEXLIB LEX_OUTPUT_ROOT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA opt_objects FT_INCLUDES FT_LDFLAGS LFLAGS CPP EGREP LIBOBJS HA_HAVE_SCANDIR LTLIBOBJS'
315 ac_subst_files=''
316
317 # Initialize some variables set by options.
318 ac_init_help=
319 ac_init_version=false
320 # The variables have the same names as the options, with
321 # dashes changed to underlines.
322 cache_file=/dev/null
323 exec_prefix=NONE
324 no_create=
325 no_recursion=
326 prefix=NONE
327 program_prefix=NONE
328 program_suffix=NONE
329 program_transform_name=s,x,x,
330 silent=
331 site=
332 srcdir=
333 verbose=
334 x_includes=NONE
335 x_libraries=NONE
336
337 # Installation directory options.
338 # These are left unexpanded so users can "make install exec_prefix=/foo"
339 # and all the variables that are supposed to be based on exec_prefix
340 # by default will actually change.
341 # Use braces instead of parens because sh, perl, etc. also accept them.
342 bindir='${exec_prefix}/bin'
343 sbindir='${exec_prefix}/sbin'
344 libexecdir='${exec_prefix}/libexec'
345 datadir='${prefix}/share'
346 sysconfdir='${prefix}/etc'
347 sharedstatedir='${prefix}/com'
348 localstatedir='${prefix}/var'
349 libdir='${exec_prefix}/lib'
350 includedir='${prefix}/include'
351 oldincludedir='/usr/include'
352 infodir='${prefix}/info'
353 mandir='${prefix}/man'
354
355 ac_prev=
356 for ac_option
357 do
358 # If the previous option needs an argument, assign it.
359 if test -n "$ac_prev"; then
360 eval "$ac_prev=\$ac_option"
361 ac_prev=
362 continue
363 fi
364
365 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
366
367 # Accept the important Cygnus configure options, so we can diagnose typos.
368
369 case $ac_option in
370
371 -bindir | --bindir | --bindi | --bind | --bin | --bi)
372 ac_prev=bindir ;;
373 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
374 bindir=$ac_optarg ;;
375
376 -build | --build | --buil | --bui | --bu)
377 ac_prev=build_alias ;;
378 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
379 build_alias=$ac_optarg ;;
380
381 -cache-file | --cache-file | --cache-fil | --cache-fi \
382 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
383 ac_prev=cache_file ;;
384 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
385 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
386 cache_file=$ac_optarg ;;
387
388 --config-cache | -C)
389 cache_file=config.cache ;;
390
391 -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
392 ac_prev=datadir ;;
393 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
394 | --da=*)
395 datadir=$ac_optarg ;;
396
397 -disable-* | --disable-*)
398 ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
399 # Reject names that are not valid shell variable names.
400 expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
401 { echo "$as_me: error: invalid feature name: $ac_feature" >&2
402 { (exit 1); exit 1; }; }
403 ac_feature=`echo $ac_feature | sed 's/-/_/g'`
404 eval "enable_$ac_feature=no" ;;
405
406 -enable-* | --enable-*)
407 ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
408 # Reject names that are not valid shell variable names.
409 expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
410 { echo "$as_me: error: invalid feature name: $ac_feature" >&2
411 { (exit 1); exit 1; }; }
412 ac_feature=`echo $ac_feature | sed 's/-/_/g'`
413 case $ac_option in
414 *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
415 *) ac_optarg=yes ;;
416 esac
417 eval "enable_$ac_feature='$ac_optarg'" ;;
418
419 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
420 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
421 | --exec | --exe | --ex)
422 ac_prev=exec_prefix ;;
423 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
424 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
425 | --exec=* | --exe=* | --ex=*)
426 exec_prefix=$ac_optarg ;;
427
428 -gas | --gas | --ga | --g)
429 # Obsolete; use --with-gas.
430 with_gas=yes ;;
431
432 -help | --help | --hel | --he | -h)
433 ac_init_help=long ;;
434 -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
435 ac_init_help=recursive ;;
436 -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
437 ac_init_help=short ;;
438
439 -host | --host | --hos | --ho)
440 ac_prev=host_alias ;;
441 -host=* | --host=* | --hos=* | --ho=*)
442 host_alias=$ac_optarg ;;
443
444 -includedir | --includedir | --includedi | --included | --include \
445 | --includ | --inclu | --incl | --inc)
446 ac_prev=includedir ;;
447 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
448 | --includ=* | --inclu=* | --incl=* | --inc=*)
449 includedir=$ac_optarg ;;
450
451 -infodir | --infodir | --infodi | --infod | --info | --inf)
452 ac_prev=infodir ;;
453 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
454 infodir=$ac_optarg ;;
455
456 -libdir | --libdir | --libdi | --libd)
457 ac_prev=libdir ;;
458 -libdir=* | --libdir=* | --libdi=* | --libd=*)
459 libdir=$ac_optarg ;;
460
461 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
462 | --libexe | --libex | --libe)
463 ac_prev=libexecdir ;;
464 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
465 | --libexe=* | --libex=* | --libe=*)
466 libexecdir=$ac_optarg ;;
467
468 -localstatedir | --localstatedir | --localstatedi | --localstated \
469 | --localstate | --localstat | --localsta | --localst \
470 | --locals | --local | --loca | --loc | --lo)
471 ac_prev=localstatedir ;;
472 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
473 | --localstate=* | --localstat=* | --localsta=* | --localst=* \
474 | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
475 localstatedir=$ac_optarg ;;
476
477 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
478 ac_prev=mandir ;;
479 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
480 mandir=$ac_optarg ;;
481
482 -nfp | --nfp | --nf)
483 # Obsolete; use --without-fp.
484 with_fp=no ;;
485
486 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
487 | --no-cr | --no-c | -n)
488 no_create=yes ;;
489
490 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
491 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
492 no_recursion=yes ;;
493
494 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
495 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
496 | --oldin | --oldi | --old | --ol | --o)
497 ac_prev=oldincludedir ;;
498 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
499 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
500 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
501 oldincludedir=$ac_optarg ;;
502
503 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
504 ac_prev=prefix ;;
505 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
506 prefix=$ac_optarg ;;
507
508 -program-prefix | --program-prefix | --program-prefi | --program-pref \
509 | --program-pre | --program-pr | --program-p)
510 ac_prev=program_prefix ;;
511 -program-prefix=* | --program-prefix=* | --program-prefi=* \
512 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
513 program_prefix=$ac_optarg ;;
514
515 -program-suffix | --program-suffix | --program-suffi | --program-suff \
516 | --program-suf | --program-su | --program-s)
517 ac_prev=program_suffix ;;
518 -program-suffix=* | --program-suffix=* | --program-suffi=* \
519 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
520 program_suffix=$ac_optarg ;;
521
522 -program-transform-name | --program-transform-name \
523 | --program-transform-nam | --program-transform-na \
524 | --program-transform-n | --program-transform- \
525 | --program-transform | --program-transfor \
526 | --program-transfo | --program-transf \
527 | --program-trans | --program-tran \
528 | --progr-tra | --program-tr | --program-t)
529 ac_prev=program_transform_name ;;
530 -program-transform-name=* | --program-transform-name=* \
531 | --program-transform-nam=* | --program-transform-na=* \
532 | --program-transform-n=* | --program-transform-=* \
533 | --program-transform=* | --program-transfor=* \
534 | --program-transfo=* | --program-transf=* \
535 | --program-trans=* | --program-tran=* \
536 | --progr-tra=* | --program-tr=* | --program-t=*)
537 program_transform_name=$ac_optarg ;;
538
539 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
540 | -silent | --silent | --silen | --sile | --sil)
541 silent=yes ;;
542
543 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
544 ac_prev=sbindir ;;
545 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
546 | --sbi=* | --sb=*)
547 sbindir=$ac_optarg ;;
548
549 -sharedstatedir | --sharedstatedir | --sharedstatedi \
550 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
551 | --sharedst | --shareds | --shared | --share | --shar \
552 | --sha | --sh)
553 ac_prev=sharedstatedir ;;
554 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
555 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
556 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
557 | --sha=* | --sh=*)
558 sharedstatedir=$ac_optarg ;;
559
560 -site | --site | --sit)
561 ac_prev=site ;;
562 -site=* | --site=* | --sit=*)
563 site=$ac_optarg ;;
564
565 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
566 ac_prev=srcdir ;;
567 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
568 srcdir=$ac_optarg ;;
569
570 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
571 | --syscon | --sysco | --sysc | --sys | --sy)
572 ac_prev=sysconfdir ;;
573 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
574 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
575 sysconfdir=$ac_optarg ;;
576
577 -target | --target | --targe | --targ | --tar | --ta | --t)
578 ac_prev=target_alias ;;
579 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
580 target_alias=$ac_optarg ;;
581
582 -v | -verbose | --verbose | --verbos | --verbo | --verb)
583 verbose=yes ;;
584
585 -version | --version | --versio | --versi | --vers | -V)
586 ac_init_version=: ;;
587
588 -with-* | --with-*)
589 ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
590 # Reject names that are not valid shell variable names.
591 expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
592 { echo "$as_me: error: invalid package name: $ac_package" >&2
593 { (exit 1); exit 1; }; }
594 ac_package=`echo $ac_package| sed 's/-/_/g'`
595 case $ac_option in
596 *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
597 *) ac_optarg=yes ;;
598 esac
599 eval "with_$ac_package='$ac_optarg'" ;;
600
601 -without-* | --without-*)
602 ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
603 # Reject names that are not valid shell variable names.
604 expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
605 { echo "$as_me: error: invalid package name: $ac_package" >&2
606 { (exit 1); exit 1; }; }
607 ac_package=`echo $ac_package | sed 's/-/_/g'`
608 eval "with_$ac_package=no" ;;
609
610 --x)
611 # Obsolete; use --with-x.
612 with_x=yes ;;
613
614 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
615 | --x-incl | --x-inc | --x-in | --x-i)
616 ac_prev=x_includes ;;
617 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
618 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
619 x_includes=$ac_optarg ;;
620
621 -x-libraries | --x-libraries | --x-librarie | --x-librari \
622 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
623 ac_prev=x_libraries ;;
624 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
625 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
626 x_libraries=$ac_optarg ;;
627
628 -*) { echo "$as_me: error: unrecognized option: $ac_option
629 Try \`$0 --help' for more information." >&2
630 { (exit 1); exit 1; }; }
631 ;;
632
633 *=*)
634 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
635 # Reject names that are not valid shell variable names.
636 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
637 { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
638 { (exit 1); exit 1; }; }
639 ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
640 eval "$ac_envvar='$ac_optarg'"
641 export $ac_envvar ;;
642
643 *)
644 # FIXME: should be removed in autoconf 3.0.
645 echo "$as_me: WARNING: you should use --build, --host, --target" >&2
646 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
647 echo "$as_me: WARNING: invalid host type: $ac_option" >&2
648 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
649 ;;
650
651 esac
652 done
653
654 if test -n "$ac_prev"; then
655 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
656 { echo "$as_me: error: missing argument to $ac_option" >&2
657 { (exit 1); exit 1; }; }
658 fi
659
660 # Be sure to have absolute paths.
661 for ac_var in exec_prefix prefix
662 do
663 eval ac_val=$`echo $ac_var`
664 case $ac_val in
665 [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
666 *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
667 { (exit 1); exit 1; }; };;
668 esac
669 done
670
671 # Be sure to have absolute paths.
672 for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
673 localstatedir libdir includedir oldincludedir infodir mandir
674 do
675 eval ac_val=$`echo $ac_var`
676 case $ac_val in
677 [\\/$]* | ?:[\\/]* ) ;;
678 *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
679 { (exit 1); exit 1; }; };;
680 esac
681 done
682
683 # There might be people who depend on the old broken behavior: `$host'
684 # used to hold the argument of --host etc.
685 # FIXME: To remove some day.
686 build=$build_alias
687 host=$host_alias
688 target=$target_alias
689
690 # FIXME: To remove some day.
691 if test "x$host_alias" != x; then
692 if test "x$build_alias" = x; then
693 cross_compiling=maybe
694 echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
695 If a cross compiler is detected then cross compile mode will be used." >&2
696 elif test "x$build_alias" != "x$host_alias"; then
697 cross_compiling=yes
698 fi
699 fi
700
701 ac_tool_prefix=
702 test -n "$host_alias" && ac_tool_prefix=$host_alias-
703
704 test "$silent" = yes && exec 6>/dev/null
705
706
707 # Find the source files, if location was not specified.
708 if test -z "$srcdir"; then
709 ac_srcdir_defaulted=yes
710 # Try the directory containing this script, then its parent.
711 ac_confdir=`(dirname "$0") 2>/dev/null ||
712 $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
713 X"$0" : 'X\(//\)[^/]' \| \
714 X"$0" : 'X\(//\)$' \| \
715 X"$0" : 'X\(/\)' \| \
716 . : '\(.\)' 2>/dev/null ||
717 echo X"$0" |
718 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
719 /^X\(\/\/\)[^/].*/{ s//\1/; q; }
720 /^X\(\/\/\)$/{ s//\1/; q; }
721 /^X\(\/\).*/{ s//\1/; q; }
722 s/.*/./; q'`
723 srcdir=$ac_confdir
724 if test ! -r $srcdir/$ac_unique_file; then
725 srcdir=..
726 fi
727 else
728 ac_srcdir_defaulted=no
729 fi
730 if test ! -r $srcdir/$ac_unique_file; then
731 if test "$ac_srcdir_defaulted" = yes; then
732 { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
733 { (exit 1); exit 1; }; }
734 else
735 { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
736 { (exit 1); exit 1; }; }
737 fi
738 fi
739 (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
740 { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
741 { (exit 1); exit 1; }; }
742 srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
743 ac_env_build_alias_set=${build_alias+set}
744 ac_env_build_alias_value=$build_alias
745 ac_cv_env_build_alias_set=${build_alias+set}
746 ac_cv_env_build_alias_value=$build_alias
747 ac_env_host_alias_set=${host_alias+set}
748 ac_env_host_alias_value=$host_alias
749 ac_cv_env_host_alias_set=${host_alias+set}
750 ac_cv_env_host_alias_value=$host_alias
751 ac_env_target_alias_set=${target_alias+set}
752 ac_env_target_alias_value=$target_alias
753 ac_cv_env_target_alias_set=${target_alias+set}
754 ac_cv_env_target_alias_value=$target_alias
755 ac_env_CC_set=${CC+set}
756 ac_env_CC_value=$CC
757 ac_cv_env_CC_set=${CC+set}
758 ac_cv_env_CC_value=$CC
759 ac_env_CFLAGS_set=${CFLAGS+set}
760 ac_env_CFLAGS_value=$CFLAGS
761 ac_cv_env_CFLAGS_set=${CFLAGS+set}
762 ac_cv_env_CFLAGS_value=$CFLAGS
763 ac_env_LDFLAGS_set=${LDFLAGS+set}
764 ac_env_LDFLAGS_value=$LDFLAGS
765 ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
766 ac_cv_env_LDFLAGS_value=$LDFLAGS
767 ac_env_CPPFLAGS_set=${CPPFLAGS+set}
768 ac_env_CPPFLAGS_value=$CPPFLAGS
769 ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
770 ac_cv_env_CPPFLAGS_value=$CPPFLAGS
771 ac_env_CPP_set=${CPP+set}
772 ac_env_CPP_value=$CPP
773 ac_cv_env_CPP_set=${CPP+set}
774 ac_cv_env_CPP_value=$CPP
775
776 #
777 # Report the --help message.
778 #
779 if test "$ac_init_help" = "long"; then
780 # Omit some internal or obsolete options to make the list less imposing.
781 # This message is too long to be a string in the A/UX 3.1 sh.
782 cat <<_ACEOF
783 \`configure' configures nfdump 1.4 to adapt to many kinds of systems.
784
785 Usage: $0 [OPTION]... [VAR=VALUE]...
786
787 To assign environment variables (e.g., CC, CFLAGS...), specify them as
788 VAR=VALUE. See below for descriptions of some of the useful variables.
789
790 Defaults for the options are specified in brackets.
791
792 Configuration:
793 -h, --help display this help and exit
794 --help=short display options specific to this package
795 --help=recursive display the short help of all the included packages
796 -V, --version display version information and exit
797 -q, --quiet, --silent do not print \`checking...' messages
798 --cache-file=FILE cache test results in FILE [disabled]
799 -C, --config-cache alias for \`--cache-file=config.cache'
800 -n, --no-create do not create output files
801 --srcdir=DIR find the sources in DIR [configure dir or \`..']
802
803 _ACEOF
804
805 cat <<_ACEOF
806 Installation directories:
807 --prefix=PREFIX install architecture-independent files in PREFIX
808 [$ac_default_prefix]
809 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
810 [PREFIX]
811
812 By default, \`make install' will install all the files in
813 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
814 an installation prefix other than \`$ac_default_prefix' using \`--prefix',
815 for instance \`--prefix=\$HOME'.
816
817 For better control, use the options below.
818
819 Fine tuning of the installation directories:
820 --bindir=DIR user executables [EPREFIX/bin]
821 --sbindir=DIR system admin executables [EPREFIX/sbin]
822 --libexecdir=DIR program executables [EPREFIX/libexec]
823 --datadir=DIR read-only architecture-independent data [PREFIX/share]
824 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
825 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
826 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
827 --libdir=DIR object code libraries [EPREFIX/lib]
828 --includedir=DIR C header files [PREFIX/include]
829 --oldincludedir=DIR C header files for non-gcc [/usr/include]
830 --infodir=DIR info documentation [PREFIX/info]
831 --mandir=DIR man documentation [PREFIX/man]
832 _ACEOF
833
834 cat <<\_ACEOF
835 _ACEOF
836 fi
837
838 if test -n "$ac_init_help"; then
839 case $ac_init_help in
840 short | recursive ) echo "Configuration of nfdump 1.4:";;
841 esac
842 cat <<\_ACEOF
843
844 Optional Features:
845 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
846 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
847 --enable-64 compile 64 bit on solaris with SUNPRO cc; default is NO
848 --enable-ftconv Build the flow-tools to nfdump converter; default is NO
849
850 Optional Packages:
851 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
852 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
853 --with-ftpath=PATH Expect flow-tool sources in PATH; default ../flow-tools-0.67
854
855 Some influential environment variables:
856 CC C compiler command
857 CFLAGS C compiler flags
858 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
859 nonstandard directory <lib dir>
860 CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
861 headers in a nonstandard directory <include dir>
862 CPP C preprocessor
863
864 Use these variables to override the choices made by `configure' or to help
865 it to find libraries and programs with nonstandard names/locations.
866
867 Report bugs to <haag@switch.ch>.
868 _ACEOF
869 fi
870
871 if test "$ac_init_help" = "recursive"; then
872 # If there are subdirs, report their specific --help.
873 ac_popdir=`pwd`
874 for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
875 test -d $ac_dir || continue
876 ac_builddir=.
877
878 if test "$ac_dir" != .; then
879 ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
880 # A "../" for each directory in $ac_dir_suffix.
881 ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
882 else
883 ac_dir_suffix= ac_top_builddir=
884 fi
885
886 case $srcdir in
887 .) # No --srcdir option. We are building in place.
888 ac_srcdir=.
889 if test -z "$ac_top_builddir"; then
890 ac_top_srcdir=.
891 else
892 ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
893 fi ;;
894 [\\/]* | ?:[\\/]* ) # Absolute path.
895 ac_srcdir=$srcdir$ac_dir_suffix;
896 ac_top_srcdir=$srcdir ;;
897 *) # Relative path.
898 ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
899 ac_top_srcdir=$ac_top_builddir$srcdir ;;
900 esac
901
902 # Do not use `cd foo && pwd` to compute absolute paths, because
903 # the directories may not exist.
904 case `pwd` in
905 .) ac_abs_builddir="$ac_dir";;
906 *)
907 case "$ac_dir" in
908 .) ac_abs_builddir=`pwd`;;
909 [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
910 *) ac_abs_builddir=`pwd`/"$ac_dir";;
911 esac;;
912 esac
913 case $ac_abs_builddir in
914 .) ac_abs_top_builddir=${ac_top_builddir}.;;
915 *)
916 case ${ac_top_builddir}. in
917 .) ac_abs_top_builddir=$ac_abs_builddir;;
918 [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
919 *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
920 esac;;
921 esac
922 case $ac_abs_builddir in
923 .) ac_abs_srcdir=$ac_srcdir;;
924 *)
925 case $ac_srcdir in
926 .) ac_abs_srcdir=$ac_abs_builddir;;
927 [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
928 *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
929 esac;;
930 esac
931 case $ac_abs_builddir in
932 .) ac_abs_top_srcdir=$ac_top_srcdir;;
933 *)
934 case $ac_top_srcdir in
935 .) ac_abs_top_srcdir=$ac_abs_builddir;;
936 [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
937 *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
938 esac;;
939 esac
940
941 cd $ac_dir
942 # Check for guested configure; otherwise get Cygnus style configure.
943 if test -f $ac_srcdir/configure.gnu; then
944 echo
945 $SHELL $ac_srcdir/configure.gnu --help=recursive
946 elif test -f $ac_srcdir/configure; then
947 echo
948 $SHELL $ac_srcdir/configure --help=recursive
949 elif test -f $ac_srcdir/configure.ac ||
950 test -f $ac_srcdir/configure.in; then
951 echo
952 $ac_configure --help
953 else
954 echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
955 fi
956 cd "$ac_popdir"
957 done
958 fi
959
960 test -n "$ac_init_help" && exit 0
961 if $ac_init_version; then
962 cat <<\_ACEOF
963 nfdump configure 1.4
964 generated by GNU Autoconf 2.59
965
966 Copyright (C) 2003 Free Software Foundation, Inc.
967 This configure script is free software; the Free Software Foundation
968 gives unlimited permission to copy, distribute and modify it.
969 _ACEOF
970 exit 0
971 fi
972 exec 5>config.log
973 cat >&5 <<_ACEOF
974 This file contains any messages produced by compilers while
975 running configure, to aid debugging if configure makes a mistake.
976
977 It was created by nfdump $as_me 1.4, which was
978 generated by GNU Autoconf 2.59. Invocation command line was
979
980 $ $0 $@
981
982 _ACEOF
983 {
984 cat <<_ASUNAME
985 ## --------- ##
986 ## Platform. ##
987 ## --------- ##
988
989 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
990 uname -m = `(uname -m) 2>/dev/null || echo unknown`
991 uname -r = `(uname -r) 2>/dev/null || echo unknown`
992 uname -s = `(uname -s) 2>/dev/null || echo unknown`
993 uname -v = `(uname -v) 2>/dev/null || echo unknown`
994
995 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
996 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
997
998 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
999 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
1000 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1001 hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
1002 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
1003 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
1004 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
1005
1006 _ASUNAME
1007
1008 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1009 for as_dir in $PATH
1010 do
1011 IFS=$as_save_IFS
1012 test -z "$as_dir" && as_dir=.
1013 echo "PATH: $as_dir"
1014 done
1015
1016 } >&5
1017
1018 cat >&5 <<_ACEOF
1019
1020
1021 ## ----------- ##
1022 ## Core tests. ##
1023 ## ----------- ##
1024
1025 _ACEOF
1026
1027
1028 # Keep a trace of the command line.
1029 # Strip out --no-create and --no-recursion so they do not pile up.
1030 # Strip out --silent because we don't want to record it for future runs.
1031 # Also quote any args containing shell meta-characters.
1032 # Make two passes to allow for proper duplicate-argument suppression.
1033 ac_configure_args=
1034 ac_configure_args0=
1035 ac_configure_args1=
1036 ac_sep=
1037 ac_must_keep_next=false
1038 for ac_pass in 1 2
1039 do
1040 for ac_arg
1041 do
1042 case $ac_arg in
1043 -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
1044 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1045 | -silent | --silent | --silen | --sile | --sil)
1046 continue ;;
1047 *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
1048 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
1049 esac
1050 case $ac_pass in
1051 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
1052 2)
1053 ac_configure_args1="$ac_configure_args1 '$ac_arg'"
1054 if test $ac_must_keep_next = true; then
1055 ac_must_keep_next=false # Got value, back to normal.
1056 else
1057 case $ac_arg in
1058 *=* | --config-cache | -C | -disable-* | --disable-* \
1059 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
1060 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
1061 | -with-* | --with-* | -without-* | --without-* | --x)
1062 case "$ac_configure_args0 " in
1063 "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
1064 esac
1065 ;;
1066 -* ) ac_must_keep_next=true ;;
1067 esac
1068 fi
1069 ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
1070 # Get rid of the leading space.
1071 ac_sep=" "
1072 ;;
1073 esac
1074 done
1075 done
1076 $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
1077 $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
1078
1079 # When interrupted or exit'd, cleanup temporary files, and complete
1080 # config.log. We remove comments because anyway the quotes in there
1081 # would cause problems or look ugly.
1082 # WARNING: Be sure not to use single quotes in there, as some shells,
1083 # such as our DU 5.0 friend, will then `close' the trap.
1084 trap 'exit_status=$?
1085 # Save into config.log some information that might help in debugging.
1086 {
1087 echo
1088
1089 cat <<\_ASBOX
1090 ## ---------------- ##
1091 ## Cache variables. ##
1092 ## ---------------- ##
1093 _ASBOX
1094 echo
1095 # The following way of writing the cache mishandles newlines in values,
1096 {
1097 (set) 2>&1 |
1098 case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
1099 *ac_space=\ *)
1100 sed -n \
1101 "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
1102 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
1103 ;;
1104 *)
1105 sed -n \
1106 "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
1107 ;;
1108 esac;
1109 }
1110 echo
1111
1112 cat <<\_ASBOX
1113 ## ----------------- ##
1114 ## Output variables. ##
1115 ## ----------------- ##
1116 _ASBOX
1117 echo
1118 for ac_var in $ac_subst_vars
1119 do
1120 eval ac_val=$`echo $ac_var`
1121 echo "$ac_var='"'"'$ac_val'"'"'"
1122 done | sort
1123 echo
1124
1125 if test -n "$ac_subst_files"; then
1126 cat <<\_ASBOX
1127 ## ------------- ##
1128 ## Output files. ##
1129 ## ------------- ##
1130 _ASBOX
1131 echo
1132 for ac_var in $ac_subst_files
1133 do
1134 eval ac_val=$`echo $ac_var`
1135 echo "$ac_var='"'"'$ac_val'"'"'"
1136 done | sort
1137 echo
1138 fi
1139
1140 if test -s confdefs.h; then
1141 cat <<\_ASBOX
1142 ## ----------- ##
1143 ## confdefs.h. ##
1144 ## ----------- ##
1145 _ASBOX
1146 echo
1147 sed "/^$/d" confdefs.h | sort
1148 echo
1149 fi
1150 test "$ac_signal" != 0 &&
1151 echo "$as_me: caught signal $ac_signal"
1152 echo "$as_me: exit $exit_status"
1153 } >&5
1154 rm -f core *.core &&
1155 rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
1156 exit $exit_status
1157 ' 0
1158 for ac_signal in 1 2 13 15; do
1159 trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
1160 done
1161 ac_signal=0
1162
1163 # confdefs.h avoids OS command line length limits that DEFS can exceed.
1164 rm -rf conftest* confdefs.h
1165 # AIX cpp loses on an empty file, so make sure it contains at least a newline.
1166 echo >confdefs.h
1167
1168 # Predefined preprocessor variables.
1169
1170 cat >>confdefs.h <<_ACEOF
1171 #define PACKAGE_NAME "$PACKAGE_NAME"
1172 _ACEOF
1173
1174
1175 cat >>confdefs.h <<_ACEOF
1176 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
1177 _ACEOF
1178
1179
1180 cat >>confdefs.h <<_ACEOF
1181 #define PACKAGE_VERSION "$PACKAGE_VERSION"
1182 _ACEOF
1183
1184
1185 cat >>confdefs.h <<_ACEOF
1186 #define PACKAGE_STRING "$PACKAGE_STRING"
1187 _ACEOF
1188
1189
1190 cat >>confdefs.h <<_ACEOF
1191 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
1192 _ACEOF
1193
1194
1195 # Let the site file select an alternate cache file if it wants to.
1196 # Prefer explicitly selected file to automatically selected ones.
1197 if test -z "$CONFIG_SITE"; then
1198 if test "x$prefix" != xNONE; then
1199 CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
1200 else
1201 CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
1202 fi
1203 fi
1204 for ac_site_file in $CONFIG_SITE; do
1205 if test -r "$ac_site_file"; then
1206 { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
1207 echo "$as_me: loading site script $ac_site_file" >&6;}
1208 sed 's/^/| /' "$ac_site_file" >&5
1209 . "$ac_site_file"
1210 fi
1211 done
1212
1213 if test -r "$cache_file"; then
1214 # Some versions of bash will fail to source /dev/null (special
1215 # files actually), so we avoid doing that.
1216 if test -f "$cache_file"; then
1217 { echo "$as_me:$LINENO: loading cache $cache_file" >&5
1218 echo "$as_me: loading cache $cache_file" >&6;}
1219 case $cache_file in
1220 [\\/]* | ?:[\\/]* ) . $cache_file;;
1221 *) . ./$cache_file;;
1222 esac
1223 fi
1224 else
1225 { echo "$as_me:$LINENO: creating cache $cache_file" >&5
1226 echo "$as_me: creating cache $cache_file" >&6;}
1227 >$cache_file
1228 fi
1229
1230 # Check that the precious variables saved in the cache have kept the same
1231 # value.
1232 ac_cache_corrupted=false
1233 for ac_var in `(set) 2>&1 |
1234 sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
1235 eval ac_old_set=\$ac_cv_env_${ac_var}_set
1236 eval ac_new_set=\$ac_env_${ac_var}_set
1237 eval ac_old_val="\$ac_cv_env_${ac_var}_value"
1238 eval ac_new_val="\$ac_env_${ac_var}_value"
1239 case $ac_old_set,$ac_new_set in
1240 set,)
1241 { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
1242 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
1243 ac_cache_corrupted=: ;;
1244 ,set)
1245 { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
1246 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
1247 ac_cache_corrupted=: ;;
1248 ,);;
1249 *)
1250 if test "x$ac_old_val" != "x$ac_new_val"; then
1251 { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
1252 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
1253 { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
1254 echo "$as_me: former value: $ac_old_val" >&2;}
1255 { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
1256 echo "$as_me: current value: $ac_new_val" >&2;}
1257 ac_cache_corrupted=:
1258 fi;;
1259 esac
1260 # Pass precious variables to config.status.
1261 if test "$ac_new_set" = set; then
1262 case $ac_new_val in
1263 *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
1264 ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
1265 *) ac_arg=$ac_var=$ac_new_val ;;
1266 esac
1267 case " $ac_configure_args " in
1268 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
1269 *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
1270 esac
1271 fi
1272 done
1273 if $ac_cache_corrupted; then
1274 { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
1275 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
1276 { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
1277 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
1278 { (exit 1); exit 1; }; }
1279 fi
1280
1281 ac_ext=c
1282 ac_cpp='$CPP $CPPFLAGS'
1283 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
1284 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
1285 ac_compiler_gnu=$ac_cv_c_compiler_gnu
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314 ac_config_headers="$ac_config_headers config.h"
1315
1316
1317 # Check whether --enable-64 or --disable-64 was given.
1318 if test "${enable_64+set}" = set; then
1319 enableval="$enable_64"
1320
1321 fi;
1322
1323 # Checks for programs.
1324 ac_ext=c
1325 ac_cpp='$CPP $CPPFLAGS'
1326 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
1327 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
1328 ac_compiler_gnu=$ac_cv_c_compiler_gnu
1329 if test -n "$ac_tool_prefix"; then
1330 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
1331 set dummy ${ac_tool_prefix}gcc; ac_word=$2
1332 echo "$as_me:$LINENO: checking for $ac_word" >&5
1333 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1334 if test "${ac_cv_prog_CC+set}" = set; then
1335 echo $ECHO_N "(cached) $ECHO_C" >&6
1336 else
1337 if test -n "$CC"; then
1338 ac_cv_prog_CC="$CC" # Let the user override the test.
1339 else
1340 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1341 for as_dir in $PATH
1342 do
1343 IFS=$as_save_IFS
1344 test -z "$as_dir" && as_dir=.
1345 for ac_exec_ext in '' $ac_executable_extensions; do
1346 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1347 ac_cv_prog_CC="${ac_tool_prefix}gcc"
1348 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1349 break 2
1350 fi
1351 done
1352 done
1353
1354 fi
1355 fi
1356 CC=$ac_cv_prog_CC
1357 if test -n "$CC"; then
1358 echo "$as_me:$LINENO: result: $CC" >&5
1359 echo "${ECHO_T}$CC" >&6
1360 else
1361 echo "$as_me:$LINENO: result: no" >&5
1362 echo "${ECHO_T}no" >&6
1363 fi
1364
1365 fi
1366 if test -z "$ac_cv_prog_CC"; then
1367 ac_ct_CC=$CC
1368 # Extract the first word of "gcc", so it can be a program name with args.
1369 set dummy gcc; ac_word=$2
1370 echo "$as_me:$LINENO: checking for $ac_word" >&5
1371 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1372 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
1373 echo $ECHO_N "(cached) $ECHO_C" >&6
1374 else
1375 if test -n "$ac_ct_CC"; then
1376 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
1377 else
1378 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1379 for as_dir in $PATH
1380 do
1381 IFS=$as_save_IFS
1382 test -z "$as_dir" && as_dir=.
1383 for ac_exec_ext in '' $ac_executable_extensions; do
1384 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1385 ac_cv_prog_ac_ct_CC="gcc"
1386 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1387 break 2
1388 fi
1389 done
1390 done
1391
1392 fi
1393 fi
1394 ac_ct_CC=$ac_cv_prog_ac_ct_CC
1395 if test -n "$ac_ct_CC"; then
1396 echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
1397 echo "${ECHO_T}$ac_ct_CC" >&6
1398 else
1399 echo "$as_me:$LINENO: result: no" >&5
1400 echo "${ECHO_T}no" >&6
1401 fi
1402
1403 CC=$ac_ct_CC
1404 else
1405 CC="$ac_cv_prog_CC"
1406 fi
1407
1408 if test -z "$CC"; then
1409 if test -n "$ac_tool_prefix"; then
1410 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
1411 set dummy ${ac_tool_prefix}cc; ac_word=$2
1412 echo "$as_me:$LINENO: checking for $ac_word" >&5
1413 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1414 if test "${ac_cv_prog_CC+set}" = set; then
1415 echo $ECHO_N "(cached) $ECHO_C" >&6
1416 else
1417 if test -n "$CC"; then
1418 ac_cv_prog_CC="$CC" # Let the user override the test.
1419 else
1420 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1421 for as_dir in $PATH
1422 do
1423 IFS=$as_save_IFS
1424 test -z "$as_dir" && as_dir=.
1425 for ac_exec_ext in '' $ac_executable_extensions; do
1426 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1427 ac_cv_prog_CC="${ac_tool_prefix}cc"
1428 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1429 break 2
1430 fi
1431 done
1432 done
1433
1434 fi
1435 fi
1436 CC=$ac_cv_prog_CC
1437 if test -n "$CC"; then
1438 echo "$as_me:$LINENO: result: $CC" >&5
1439 echo "${ECHO_T}$CC" >&6
1440 else
1441 echo "$as_me:$LINENO: result: no" >&5
1442 echo "${ECHO_T}no" >&6
1443 fi
1444
1445 fi
1446 if test -z "$ac_cv_prog_CC"; then
1447 ac_ct_CC=$CC
1448 # Extract the first word of "cc", so it can be a program name with args.
1449 set dummy cc; ac_word=$2
1450 echo "$as_me:$LINENO: checking for $ac_word" >&5
1451 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1452 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
1453 echo $ECHO_N "(cached) $ECHO_C" >&6
1454 else
1455 if test -n "$ac_ct_CC"; then
1456 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
1457 else
1458 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1459 for as_dir in $PATH
1460 do
1461 IFS=$as_save_IFS
1462 test -z "$as_dir" && as_dir=.
1463 for ac_exec_ext in '' $ac_executable_extensions; do
1464 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1465 ac_cv_prog_ac_ct_CC="cc"
1466 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1467 break 2
1468 fi
1469 done
1470 done
1471
1472 fi
1473 fi
1474 ac_ct_CC=$ac_cv_prog_ac_ct_CC
1475 if test -n "$ac_ct_CC"; then
1476 echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
1477 echo "${ECHO_T}$ac_ct_CC" >&6
1478 else
1479 echo "$as_me:$LINENO: result: no" >&5
1480 echo "${ECHO_T}no" >&6
1481 fi
1482
1483 CC=$ac_ct_CC
1484 else
1485 CC="$ac_cv_prog_CC"
1486 fi
1487
1488 fi
1489 if test -z "$CC"; then
1490 # Extract the first word of "cc", so it can be a program name with args.
1491 set dummy cc; ac_word=$2
1492 echo "$as_me:$LINENO: checking for $ac_word" >&5
1493 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1494 if test "${ac_cv_prog_CC+set}" = set; then
1495 echo $ECHO_N "(cached) $ECHO_C" >&6
1496 else
1497 if test -n "$CC"; then
1498 ac_cv_prog_CC="$CC" # Let the user override the test.
1499 else
1500 ac_prog_rejected=no
1501 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1502 for as_dir in $PATH
1503 do
1504 IFS=$as_save_IFS
1505 test -z "$as_dir" && as_dir=.
1506 for ac_exec_ext in '' $ac_executable_extensions; do
1507 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1508 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
1509 ac_prog_rejected=yes
1510 continue
1511 fi
1512 ac_cv_prog_CC="cc"
1513 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1514 break 2
1515 fi
1516 done
1517 done
1518
1519 if test $ac_prog_rejected = yes; then
1520 # We found a bogon in the path, so make sure we never use it.
1521 set dummy $ac_cv_prog_CC
1522 shift
1523 if test $# != 0; then
1524 # We chose a different compiler from the bogus one.
1525 # However, it has the same basename, so the bogon will be chosen
1526 # first if we set CC to just the basename; use the full file name.
1527 shift
1528 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
1529 fi
1530 fi
1531 fi
1532 fi
1533 CC=$ac_cv_prog_CC
1534 if test -n "$CC"; then
1535 echo "$as_me:$LINENO: result: $CC" >&5
1536 echo "${ECHO_T}$CC" >&6
1537 else
1538 echo "$as_me:$LINENO: result: no" >&5
1539 echo "${ECHO_T}no" >&6
1540 fi
1541
1542 fi
1543 if test -z "$CC"; then
1544 if test -n "$ac_tool_prefix"; then
1545 for ac_prog in cl
1546 do
1547 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
1548 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
1549 echo "$as_me:$LINENO: checking for $ac_word" >&5
1550 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1551 if test "${ac_cv_prog_CC+set}" = set; then
1552 echo $ECHO_N "(cached) $ECHO_C" >&6
1553 else
1554 if test -n "$CC"; then
1555 ac_cv_prog_CC="$CC" # Let the user override the test.
1556 else
1557 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1558 for as_dir in $PATH
1559 do
1560 IFS=$as_save_IFS
1561 test -z "$as_dir" && as_dir=.
1562 for ac_exec_ext in '' $ac_executable_extensions; do
1563 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1564 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
1565 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1566 break 2
1567 fi
1568 done
1569 done
1570
1571 fi
1572 fi
1573 CC=$ac_cv_prog_CC
1574 if test -n "$CC"; then
1575 echo "$as_me:$LINENO: result: $CC" >&5
1576 echo "${ECHO_T}$CC" >&6
1577 else
1578 echo "$as_me:$LINENO: result: no" >&5
1579 echo "${ECHO_T}no" >&6
1580 fi
1581
1582 test -n "$CC" && break
1583 done
1584 fi
1585 if test -z "$CC"; then
1586 ac_ct_CC=$CC
1587 for ac_prog in cl
1588 do
1589 # Extract the first word of "$ac_prog", so it can be a program name with args.
1590 set dummy $ac_prog; ac_word=$2
1591 echo "$as_me:$LINENO: checking for $ac_word" >&5
1592 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
1593 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
1594 echo $ECHO_N "(cached) $ECHO_C" >&6
1595 else
1596 if test -n "$ac_ct_CC"; then
1597 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
1598 else
1599 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1600 for as_dir in $PATH
1601 do
1602 IFS=$as_save_IFS
1603 test -z "$as_dir" && as_dir=.
1604 for ac_exec_ext in '' $ac_executable_extensions; do
1605 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
1606 ac_cv_prog_ac_ct_CC="$ac_prog"
1607 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
1608 break 2
1609 fi
1610 done
1611 done
1612
1613 fi
1614 fi
1615 ac_ct_CC=$ac_cv_prog_ac_ct_CC
1616 if test -n "$ac_ct_CC"; then
1617 echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
1618 echo "${ECHO_T}$ac_ct_CC" >&6
1619 else
1620 echo "$as_me:$LINENO: result: no" >&5
1621 echo "${ECHO_T}no" >&6
1622 fi
1623
1624 test -n "$ac_ct_CC" && break
1625 done
1626
1627 CC=$ac_ct_CC
1628 fi
1629
1630 fi
1631
1632
1633 test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
1634 See \`config.log' for more details." >&5
1635 echo "$as_me: error: no acceptable C compiler found in \$PATH
1636 See \`config.log' for more details." >&2;}
1637 { (exit 1); exit 1; }; }
1638
1639 # Provide some information about the compiler.
1640 echo "$as_me:$LINENO:" \
1641 "checking for C compiler version" >&5
1642 ac_compiler=`set X $ac_compile; echo $2`
1643 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
1644 (eval $ac_compiler --version </dev/null >&5) 2>&5
1645 ac_status=$?
1646 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1647 (exit $ac_status); }
1648 { (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
1649 (eval $ac_compiler -v </dev/null >&5) 2>&5
1650 ac_status=$?
1651 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1652 (exit $ac_status); }
1653 { (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
1654 (eval $ac_compiler -V </dev/null >&5) 2>&5
1655 ac_status=$?
1656 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1657 (exit $ac_status); }
1658
1659 cat >conftest.$ac_ext <<_ACEOF
1660 /* confdefs.h. */
1661 _ACEOF
1662 cat confdefs.h >>conftest.$ac_ext
1663 cat >>conftest.$ac_ext <<_ACEOF
1664 /* end confdefs.h. */
1665
1666 int
1667 main ()
1668 {
1669
1670 ;
1671 return 0;
1672 }
1673 _ACEOF
1674 ac_clean_files_save=$ac_clean_files
1675 ac_clean_files="$ac_clean_files a.out a.exe b.out"
1676 # Try to create an executable without -o first, disregard a.out.
1677 # It will help us diagnose broken compilers, and finding out an intuition
1678 # of exeext.
1679 echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
1680 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
1681 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
1682 if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
1683 (eval $ac_link_default) 2>&5
1684 ac_status=$?
1685 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1686 (exit $ac_status); }; then
1687 # Find the output, starting from the most likely. This scheme is
1688 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
1689 # resort.
1690
1691 # Be careful to initialize this variable, since it used to be cached.
1692 # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
1693 ac_cv_exeext=
1694 # b.out is created by i960 compilers.
1695 for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
1696 do
1697 test -f "$ac_file" || continue
1698 case $ac_file in
1699 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
1700 ;;
1701 conftest.$ac_ext )
1702 # This is the source file.
1703 ;;
1704 [ab].out )
1705 # We found the default executable, but exeext='' is most
1706 # certainly right.
1707 break;;
1708 *.* )
1709 ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
1710 # FIXME: I believe we export ac_cv_exeext for Libtool,
1711 # but it would be cool to find out if it's true. Does anybody
1712 # maintain Libtool? --akim.
1713 export ac_cv_exeext
1714 break;;
1715 * )
1716 break;;
1717 esac
1718 done
1719 else
1720 echo "$as_me: failed program was:" >&5
1721 sed 's/^/| /' conftest.$ac_ext >&5
1722
1723 { { echo "$as_me:$LINENO: error: C compiler cannot create executables
1724 See \`config.log' for more details." >&5
1725 echo "$as_me: error: C compiler cannot create executables
1726 See \`config.log' for more details." >&2;}
1727 { (exit 77); exit 77; }; }
1728 fi
1729
1730 ac_exeext=$ac_cv_exeext
1731 echo "$as_me:$LINENO: result: $ac_file" >&5
1732 echo "${ECHO_T}$ac_file" >&6
1733
1734 # Check the compiler produces executables we can run. If not, either
1735 # the compiler is broken, or we cross compile.
1736 echo "$as_me:$LINENO: checking whether the C compiler works" >&5
1737 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
1738 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
1739 # If not cross compiling, check that we can run a simple program.
1740 if test "$cross_compiling" != yes; then
1741 if { ac_try='./$ac_file'
1742 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1743 (eval $ac_try) 2>&5
1744 ac_status=$?
1745 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1746 (exit $ac_status); }; }; then
1747 cross_compiling=no
1748 else
1749 if test "$cross_compiling" = maybe; then
1750 cross_compiling=yes
1751 else
1752 { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
1753 If you meant to cross compile, use \`--host'.
1754 See \`config.log' for more details." >&5
1755 echo "$as_me: error: cannot run C compiled programs.
1756 If you meant to cross compile, use \`--host'.
1757 See \`config.log' for more details." >&2;}
1758 { (exit 1); exit 1; }; }
1759 fi
1760 fi
1761 fi
1762 echo "$as_me:$LINENO: result: yes" >&5
1763 echo "${ECHO_T}yes" >&6
1764
1765 rm -f a.out a.exe conftest$ac_cv_exeext b.out
1766 ac_clean_files=$ac_clean_files_save
1767 # Check the compiler produces executables we can run. If not, either
1768 # the compiler is broken, or we cross compile.
1769 echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
1770 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
1771 echo "$as_me:$LINENO: result: $cross_compiling" >&5
1772 echo "${ECHO_T}$cross_compiling" >&6
1773
1774 echo "$as_me:$LINENO: checking for suffix of executables" >&5
1775 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
1776 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
1777 (eval $ac_link) 2>&5
1778 ac_status=$?
1779 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1780 (exit $ac_status); }; then
1781 # If both `conftest.exe' and `conftest' are `present' (well, observable)
1782 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
1783 # work properly (i.e., refer to `conftest.exe'), while it won't with
1784 # `rm'.
1785 for ac_file in conftest.exe conftest conftest.*; do
1786 test -f "$ac_file" || continue
1787 case $ac_file in
1788 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
1789 *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
1790 export ac_cv_exeext
1791 break;;
1792 * ) break;;
1793 esac
1794 done
1795 else
1796 { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
1797 See \`config.log' for more details." >&5
1798 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
1799 See \`config.log' for more details." >&2;}
1800 { (exit 1); exit 1; }; }
1801 fi
1802
1803 rm -f conftest$ac_cv_exeext
1804 echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
1805 echo "${ECHO_T}$ac_cv_exeext" >&6
1806
1807 rm -f conftest.$ac_ext
1808 EXEEXT=$ac_cv_exeext
1809 ac_exeext=$EXEEXT
1810 echo "$as_me:$LINENO: checking for suffix of object files" >&5
1811 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
1812 if test "${ac_cv_objext+set}" = set; then
1813 echo $ECHO_N "(cached) $ECHO_C" >&6
1814 else
1815 cat >conftest.$ac_ext <<_ACEOF
1816 /* confdefs.h. */
1817 _ACEOF
1818 cat confdefs.h >>conftest.$ac_ext
1819 cat >>conftest.$ac_ext <<_ACEOF
1820 /* end confdefs.h. */
1821
1822 int
1823 main ()
1824 {
1825
1826 ;
1827 return 0;
1828 }
1829 _ACEOF
1830 rm -f conftest.o conftest.obj
1831 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1832 (eval $ac_compile) 2>&5
1833 ac_status=$?
1834 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1835 (exit $ac_status); }; then
1836 for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
1837 case $ac_file in
1838 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
1839 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
1840 break;;
1841 esac
1842 done
1843 else
1844 echo "$as_me: failed program was:" >&5
1845 sed 's/^/| /' conftest.$ac_ext >&5
1846
1847 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
1848 See \`config.log' for more details." >&5
1849 echo "$as_me: error: cannot compute suffix of object files: cannot compile
1850 See \`config.log' for more details." >&2;}
1851 { (exit 1); exit 1; }; }
1852 fi
1853
1854 rm -f conftest.$ac_cv_objext conftest.$ac_ext
1855 fi
1856 echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
1857 echo "${ECHO_T}$ac_cv_objext" >&6
1858 OBJEXT=$ac_cv_objext
1859 ac_objext=$OBJEXT
1860 echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
1861 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
1862 if test "${ac_cv_c_compiler_gnu+set}" = set; then
1863 echo $ECHO_N "(cached) $ECHO_C" >&6
1864 else
1865 cat >conftest.$ac_ext <<_ACEOF
1866 /* confdefs.h. */
1867 _ACEOF
1868 cat confdefs.h >>conftest.$ac_ext
1869 cat >>conftest.$ac_ext <<_ACEOF
1870 /* end confdefs.h. */
1871
1872 int
1873 main ()
1874 {
1875 #ifndef __GNUC__
1876 choke me
1877 #endif
1878
1879 ;
1880 return 0;
1881 }
1882 _ACEOF
1883 rm -f conftest.$ac_objext
1884 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1885 (eval $ac_compile) 2>conftest.er1
1886 ac_status=$?
1887 grep -v '^ *+' conftest.er1 >conftest.err
1888 rm -f conftest.er1
1889 cat conftest.err >&5
1890 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1891 (exit $ac_status); } &&
1892 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
1893 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1894 (eval $ac_try) 2>&5
1895 ac_status=$?
1896 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1897 (exit $ac_status); }; } &&
1898 { ac_try='test -s conftest.$ac_objext'
1899 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1900 (eval $ac_try) 2>&5
1901 ac_status=$?
1902 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1903 (exit $ac_status); }; }; then
1904 ac_compiler_gnu=yes
1905 else
1906 echo "$as_me: failed program was:" >&5
1907 sed 's/^/| /' conftest.$ac_ext >&5
1908
1909 ac_compiler_gnu=no
1910 fi
1911 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1912 ac_cv_c_compiler_gnu=$ac_compiler_gnu
1913
1914 fi
1915 echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
1916 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
1917 GCC=`test $ac_compiler_gnu = yes && echo yes`
1918 ac_test_CFLAGS=${CFLAGS+set}
1919 ac_save_CFLAGS=$CFLAGS
1920 CFLAGS="-g"
1921 echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
1922 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
1923 if test "${ac_cv_prog_cc_g+set}" = set; then
1924 echo $ECHO_N "(cached) $ECHO_C" >&6
1925 else
1926 cat >conftest.$ac_ext <<_ACEOF
1927 /* confdefs.h. */
1928 _ACEOF
1929 cat confdefs.h >>conftest.$ac_ext
1930 cat >>conftest.$ac_ext <<_ACEOF
1931 /* end confdefs.h. */
1932
1933 int
1934 main ()
1935 {
1936
1937 ;
1938 return 0;
1939 }
1940 _ACEOF
1941 rm -f conftest.$ac_objext
1942 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1943 (eval $ac_compile) 2>conftest.er1
1944 ac_status=$?
1945 grep -v '^ *+' conftest.er1 >conftest.err
1946 rm -f conftest.er1
1947 cat conftest.err >&5
1948 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1949 (exit $ac_status); } &&
1950 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
1951 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1952 (eval $ac_try) 2>&5
1953 ac_status=$?
1954 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1955 (exit $ac_status); }; } &&
1956 { ac_try='test -s conftest.$ac_objext'
1957 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
1958 (eval $ac_try) 2>&5
1959 ac_status=$?
1960 echo "$as_me:$LINENO: \$? = $ac_status" >&5
1961 (exit $ac_status); }; }; then
1962 ac_cv_prog_cc_g=yes
1963 else
1964 echo "$as_me: failed program was:" >&5
1965 sed 's/^/| /' conftest.$ac_ext >&5
1966
1967 ac_cv_prog_cc_g=no
1968 fi
1969 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1970 fi
1971 echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
1972 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
1973 if test "$ac_test_CFLAGS" = set; then
1974 CFLAGS=$ac_save_CFLAGS
1975 elif test $ac_cv_prog_cc_g = yes; then
1976 if test "$GCC" = yes; then
1977 CFLAGS="-g -O2"
1978 else
1979 CFLAGS="-g"
1980 fi
1981 else
1982 if test "$GCC" = yes; then
1983 CFLAGS="-O2"
1984 else
1985 CFLAGS=
1986 fi
1987 fi
1988 echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
1989 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
1990 if test "${ac_cv_prog_cc_stdc+set}" = set; then
1991 echo $ECHO_N "(cached) $ECHO_C" >&6
1992 else
1993 ac_cv_prog_cc_stdc=no
1994 ac_save_CC=$CC
1995 cat >conftest.$ac_ext <<_ACEOF
1996 /* confdefs.h. */
1997 _ACEOF
1998 cat confdefs.h >>conftest.$ac_ext
1999 cat >>conftest.$ac_ext <<_ACEOF
2000 /* end confdefs.h. */
2001 #include <stdarg.h>
2002 #include <stdio.h>
2003 #include <sys/types.h>
2004 #include <sys/stat.h>
2005 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
2006 struct buf { int x; };
2007 FILE * (*rcsopen) (struct buf *, struct stat *, int);
2008 static char *e (p, i)
2009 char **p;
2010 int i;
2011 {
2012 return p[i];
2013 }
2014 static char *f (char * (*g) (char **, int), char **p, ...)
2015 {
2016 char *s;
2017 va_list v;
2018 va_start (v,p);
2019 s = g (p, va_arg (v,int));
2020 va_end (v);
2021 return s;
2022 }
2023
2024 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
2025 function prototypes and stuff, but not '\xHH' hex character constants.
2026 These don't provoke an error unfortunately, instead are silently treated
2027 as 'x'. The following induces an error, until -std1 is added to get
2028 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
2029 array size at least. It's necessary to write '\x00'==0 to get something
2030 that's true only with -std1. */
2031 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
2032
2033 int test (int i, double x);
2034 struct s1 {int (*f) (int a);};
2035 struct s2 {int (*f) (double a);};
2036 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
2037 int argc;
2038 char **argv;
2039 int
2040 main ()
2041 {
2042 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
2043 ;
2044 return 0;
2045 }
2046 _ACEOF
2047 # Don't try gcc -ansi; that turns off useful extensions and
2048 # breaks some systems' header files.
2049 # AIX -qlanglvl=ansi
2050 # Ultrix and OSF/1 -std1
2051 # HP-UX 10.20 and later -Ae
2052 # HP-UX older versions -Aa -D_HPUX_SOURCE
2053 # SVR4 -Xc -D__EXTENSIONS__
2054 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
2055 do
2056 CC="$ac_save_CC $ac_arg"
2057 rm -f conftest.$ac_objext
2058 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2059 (eval $ac_compile) 2>conftest.er1
2060 ac_status=$?
2061 grep -v '^ *+' conftest.er1 >conftest.err
2062 rm -f conftest.er1
2063 cat conftest.err >&5
2064 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2065 (exit $ac_status); } &&
2066 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2067 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2068 (eval $ac_try) 2>&5
2069 ac_status=$?
2070 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2071 (exit $ac_status); }; } &&
2072 { ac_try='test -s conftest.$ac_objext'
2073 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2074 (eval $ac_try) 2>&5
2075 ac_status=$?
2076 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2077 (exit $ac_status); }; }; then
2078 ac_cv_prog_cc_stdc=$ac_arg
2079 break
2080 else
2081 echo "$as_me: failed program was:" >&5
2082 sed 's/^/| /' conftest.$ac_ext >&5
2083
2084 fi
2085 rm -f conftest.err conftest.$ac_objext
2086 done
2087 rm -f conftest.$ac_ext conftest.$ac_objext
2088 CC=$ac_save_CC
2089
2090 fi
2091
2092 case "x$ac_cv_prog_cc_stdc" in
2093 x|xno)
2094 echo "$as_me:$LINENO: result: none needed" >&5
2095 echo "${ECHO_T}none needed" >&6 ;;
2096 *)
2097 echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
2098 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
2099 CC="$CC $ac_cv_prog_cc_stdc" ;;
2100 esac
2101
2102 # Some people use a C++ compiler to compile C. Since we use `exit',
2103 # in C++ we need to declare it. In case someone uses the same compiler
2104 # for both compiling C and C++ we need to have the C++ compiler decide
2105 # the declaration of exit, since it's the most demanding environment.
2106 cat >conftest.$ac_ext <<_ACEOF
2107 #ifndef __cplusplus
2108 choke me
2109 #endif
2110 _ACEOF
2111 rm -f conftest.$ac_objext
2112 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2113 (eval $ac_compile) 2>conftest.er1
2114 ac_status=$?
2115 grep -v '^ *+' conftest.er1 >conftest.err
2116 rm -f conftest.er1
2117 cat conftest.err >&5
2118 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2119 (exit $ac_status); } &&
2120 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2121 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2122 (eval $ac_try) 2>&5
2123 ac_status=$?
2124 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2125 (exit $ac_status); }; } &&
2126 { ac_try='test -s conftest.$ac_objext'
2127 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2128 (eval $ac_try) 2>&5
2129 ac_status=$?
2130 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2131 (exit $ac_status); }; }; then
2132 for ac_declaration in \
2133 '' \
2134 'extern "C" void std::exit (int) throw (); using std::exit;' \
2135 'extern "C" void std::exit (int); using std::exit;' \
2136 'extern "C" void exit (int) throw ();' \
2137 'extern "C" void exit (int);' \
2138 'void exit (int);'
2139 do
2140 cat >conftest.$ac_ext <<_ACEOF
2141 /* confdefs.h. */
2142 _ACEOF
2143 cat confdefs.h >>conftest.$ac_ext
2144 cat >>conftest.$ac_ext <<_ACEOF
2145 /* end confdefs.h. */
2146 $ac_declaration
2147 #include <stdlib.h>
2148 int
2149 main ()
2150 {
2151 exit (42);
2152 ;
2153 return 0;
2154 }
2155 _ACEOF
2156 rm -f conftest.$ac_objext
2157 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2158 (eval $ac_compile) 2>conftest.er1
2159 ac_status=$?
2160 grep -v '^ *+' conftest.er1 >conftest.err
2161 rm -f conftest.er1
2162 cat conftest.err >&5
2163 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2164 (exit $ac_status); } &&
2165 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2166 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2167 (eval $ac_try) 2>&5
2168 ac_status=$?
2169 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2170 (exit $ac_status); }; } &&
2171 { ac_try='test -s conftest.$ac_objext'
2172 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2173 (eval $ac_try) 2>&5
2174 ac_status=$?
2175 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2176 (exit $ac_status); }; }; then
2177 :
2178 else
2179 echo "$as_me: failed program was:" >&5
2180 sed 's/^/| /' conftest.$ac_ext >&5
2181
2182 continue
2183 fi
2184 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
2185 cat >conftest.$ac_ext <<_ACEOF
2186 /* confdefs.h. */
2187 _ACEOF
2188 cat confdefs.h >>conftest.$ac_ext
2189 cat >>conftest.$ac_ext <<_ACEOF
2190 /* end confdefs.h. */
2191 $ac_declaration
2192 int
2193 main ()
2194 {
2195 exit (42);
2196 ;
2197 return 0;
2198 }
2199 _ACEOF
2200 rm -f conftest.$ac_objext
2201 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2202 (eval $ac_compile) 2>conftest.er1
2203 ac_status=$?
2204 grep -v '^ *+' conftest.er1 >conftest.err
2205 rm -f conftest.er1
2206 cat conftest.err >&5
2207 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2208 (exit $ac_status); } &&
2209 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2210 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2211 (eval $ac_try) 2>&5
2212 ac_status=$?
2213 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2214 (exit $ac_status); }; } &&
2215 { ac_try='test -s conftest.$ac_objext'
2216 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2217 (eval $ac_try) 2>&5
2218 ac_status=$?
2219 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2220 (exit $ac_status); }; }; then
2221 break
2222 else
2223 echo "$as_me: failed program was:" >&5
2224 sed 's/^/| /' conftest.$ac_ext >&5
2225
2226 fi
2227 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
2228 done
2229 rm -f conftest*
2230 if test -n "$ac_declaration"; then
2231 echo '#ifdef __cplusplus' >>confdefs.h
2232 echo $ac_declaration >>confdefs.h
2233 echo '#endif' >>confdefs.h
2234 fi
2235
2236 else
2237 echo "$as_me: failed program was:" >&5
2238 sed 's/^/| /' conftest.$ac_ext >&5
2239
2240 fi
2241 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
2242 ac_ext=c
2243 ac_cpp='$CPP $CPPFLAGS'
2244 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2245 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2246 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2247
2248
2249 echo "$as_me:$LINENO: checking whether we are using SunPro C" >&5
2250 echo $ECHO_N "checking whether we are using SunPro C... $ECHO_C" >&6
2251
2252 cat >conftest.$ac_ext <<_ACEOF
2253 /* confdefs.h. */
2254 _ACEOF
2255 cat confdefs.h >>conftest.$ac_ext
2256 cat >>conftest.$ac_ext <<_ACEOF
2257 /* end confdefs.h. */
2258
2259 int
2260 main ()
2261 {
2262 #ifndef __SUNPRO_C
2263 #error Not a SunPro compiler :-(
2264 #endif
2265
2266 ;
2267 return 0;
2268 }
2269 _ACEOF
2270 rm -f conftest.$ac_objext
2271 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2272 (eval $ac_compile) 2>conftest.er1
2273 ac_status=$?
2274 grep -v '^ *+' conftest.er1 >conftest.err
2275 rm -f conftest.er1
2276 cat conftest.err >&5
2277 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2278 (exit $ac_status); } &&
2279 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2280 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2281 (eval $ac_try) 2>&5
2282 ac_status=$?
2283 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2284 (exit $ac_status); }; } &&
2285 { ac_try='test -s conftest.$ac_objext'
2286 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2287 (eval $ac_try) 2>&5
2288 ac_status=$?
2289 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2290 (exit $ac_status); }; }; then
2291 __sunpro_c=yes
2292 else
2293 echo "$as_me: failed program was:" >&5
2294 sed 's/^/| /' conftest.$ac_ext >&5
2295
2296 __sunpro_c=no
2297 fi
2298 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
2299 echo "$as_me:$LINENO: result: $__sunpro_c" >&5
2300 echo "${ECHO_T}$__sunpro_c" >&6
2301
2302 CFLAGS="${CFLAGS=}"
2303 if test $ac_cv_c_compiler_gnu = yes -a "x$CFLAGS" = "x"; then
2304 CFLAGS="-Wall -O2"
2305 fi
2306
2307 if test $__sunpro_c = yes -a "x$CFLAGS" = "x-g"; then
2308 CFLAGS="$CFLAGS -xO2"
2309 if test "${enable_64}" = "yes" ; then
2310 CFLAGS="-xarch=v9 $CFLAGS"
2311 fi
2312 fi
2313
2314 for ac_prog in 'bison -y' byacc
2315 do
2316 # Extract the first word of "$ac_prog", so it can be a program name with args.
2317 set dummy $ac_prog; ac_word=$2
2318 echo "$as_me:$LINENO: checking for $ac_word" >&5
2319 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
2320 if test "${ac_cv_prog_YACC+set}" = set; then
2321 echo $ECHO_N "(cached) $ECHO_C" >&6
2322 else
2323 if test -n "$YACC"; then
2324 ac_cv_prog_YACC="$YACC" # Let the user override the test.
2325 else
2326 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2327 for as_dir in $PATH
2328 do
2329 IFS=$as_save_IFS
2330 test -z "$as_dir" && as_dir=.
2331 for ac_exec_ext in '' $ac_executable_extensions; do
2332 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2333 ac_cv_prog_YACC="$ac_prog"
2334 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2335 break 2
2336 fi
2337 done
2338 done
2339
2340 fi
2341 fi
2342 YACC=$ac_cv_prog_YACC
2343 if test -n "$YACC"; then
2344 echo "$as_me:$LINENO: result: $YACC" >&5
2345 echo "${ECHO_T}$YACC" >&6
2346 else
2347 echo "$as_me:$LINENO: result: no" >&5
2348 echo "${ECHO_T}no" >&6
2349 fi
2350
2351 test -n "$YACC" && break
2352 done
2353 test -n "$YACC" || YACC="yacc"
2354
2355 for ac_prog in flex lex
2356 do
2357 # Extract the first word of "$ac_prog", so it can be a program name with args.
2358 set dummy $ac_prog; ac_word=$2
2359 echo "$as_me:$LINENO: checking for $ac_word" >&5
2360 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
2361 if test "${ac_cv_prog_LEX+set}" = set; then
2362 echo $ECHO_N "(cached) $ECHO_C" >&6
2363 else
2364 if test -n "$LEX"; then
2365 ac_cv_prog_LEX="$LEX" # Let the user override the test.
2366 else
2367 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2368 for as_dir in $PATH
2369 do
2370 IFS=$as_save_IFS
2371 test -z "$as_dir" && as_dir=.
2372 for ac_exec_ext in '' $ac_executable_extensions; do
2373 if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2374 ac_cv_prog_LEX="$ac_prog"
2375 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2376 break 2
2377 fi
2378 done
2379 done
2380
2381 fi
2382 fi
2383 LEX=$ac_cv_prog_LEX
2384 if test -n "$LEX"; then
2385 echo "$as_me:$LINENO: result: $LEX" >&5
2386 echo "${ECHO_T}$LEX" >&6
2387 else
2388 echo "$as_me:$LINENO: result: no" >&5
2389 echo "${ECHO_T}no" >&6
2390 fi
2391
2392 test -n "$LEX" && break
2393 done
2394 test -n "$LEX" || LEX=":"
2395
2396 if test -z "$LEXLIB"
2397 then
2398 echo "$as_me:$LINENO: checking for yywrap in -lfl" >&5
2399 echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6
2400 if test "${ac_cv_lib_fl_yywrap+set}" = set; then
2401 echo $ECHO_N "(cached) $ECHO_C" >&6
2402 else
2403 ac_check_lib_save_LIBS=$LIBS
2404 LIBS="-lfl $LIBS"
2405 cat >conftest.$ac_ext <<_ACEOF
2406 /* confdefs.h. */
2407 _ACEOF
2408 cat confdefs.h >>conftest.$ac_ext
2409 cat >>conftest.$ac_ext <<_ACEOF
2410 /* end confdefs.h. */
2411
2412 /* Override any gcc2 internal prototype to avoid an error. */
2413 #ifdef __cplusplus
2414 extern "C"
2415 #endif
2416 /* We use char because int might match the return type of a gcc2
2417 builtin and then its argument prototype would still apply. */
2418 char yywrap ();
2419 int
2420 main ()
2421 {
2422 yywrap ();
2423 ;
2424 return 0;
2425 }
2426 _ACEOF
2427 rm -f conftest.$ac_objext conftest$ac_exeext
2428 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2429 (eval $ac_link) 2>conftest.er1
2430 ac_status=$?
2431 grep -v '^ *+' conftest.er1 >conftest.err
2432 rm -f conftest.er1
2433 cat conftest.err >&5
2434 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2435 (exit $ac_status); } &&
2436 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2437 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2438 (eval $ac_try) 2>&5
2439 ac_status=$?
2440 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2441 (exit $ac_status); }; } &&
2442 { ac_try='test -s conftest$ac_exeext'
2443 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2444 (eval $ac_try) 2>&5
2445 ac_status=$?
2446 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2447 (exit $ac_status); }; }; then
2448 ac_cv_lib_fl_yywrap=yes
2449 else
2450 echo "$as_me: failed program was:" >&5
2451 sed 's/^/| /' conftest.$ac_ext >&5
2452
2453 ac_cv_lib_fl_yywrap=no
2454 fi
2455 rm -f conftest.err conftest.$ac_objext \
2456 conftest$ac_exeext conftest.$ac_ext
2457 LIBS=$ac_check_lib_save_LIBS
2458 fi
2459 echo "$as_me:$LINENO: result: $ac_cv_lib_fl_yywrap" >&5
2460 echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6
2461 if test $ac_cv_lib_fl_yywrap = yes; then
2462 LEXLIB="-lfl"
2463 else
2464 echo "$as_me:$LINENO: checking for yywrap in -ll" >&5
2465 echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6
2466 if test "${ac_cv_lib_l_yywrap+set}" = set; then
2467 echo $ECHO_N "(cached) $ECHO_C" >&6
2468 else
2469 ac_check_lib_save_LIBS=$LIBS
2470 LIBS="-ll $LIBS"
2471 cat >conftest.$ac_ext <<_ACEOF
2472 /* confdefs.h. */
2473 _ACEOF
2474 cat confdefs.h >>conftest.$ac_ext
2475 cat >>conftest.$ac_ext <<_ACEOF
2476 /* end confdefs.h. */
2477
2478 /* Override any gcc2 internal prototype to avoid an error. */
2479 #ifdef __cplusplus
2480 extern "C"
2481 #endif
2482 /* We use char because int might match the return type of a gcc2
2483 builtin and then its argument prototype would still apply. */
2484 char yywrap ();
2485 int
2486 main ()
2487 {
2488 yywrap ();
2489 ;
2490 return 0;
2491 }
2492 _ACEOF
2493 rm -f conftest.$ac_objext conftest$ac_exeext
2494 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2495 (eval $ac_link) 2>conftest.er1
2496 ac_status=$?
2497 grep -v '^ *+' conftest.er1 >conftest.err
2498 rm -f conftest.er1
2499 cat conftest.err >&5
2500 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2501 (exit $ac_status); } &&
2502 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2503 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2504 (eval $ac_try) 2>&5
2505 ac_status=$?
2506 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2507 (exit $ac_status); }; } &&
2508 { ac_try='test -s conftest$ac_exeext'
2509 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2510 (eval $ac_try) 2>&5
2511 ac_status=$?
2512 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2513 (exit $ac_status); }; }; then
2514 ac_cv_lib_l_yywrap=yes
2515 else
2516 echo "$as_me: failed program was:" >&5
2517 sed 's/^/| /' conftest.$ac_ext >&5
2518
2519 ac_cv_lib_l_yywrap=no
2520 fi
2521 rm -f conftest.err conftest.$ac_objext \
2522 conftest$ac_exeext conftest.$ac_ext
2523 LIBS=$ac_check_lib_save_LIBS
2524 fi
2525 echo "$as_me:$LINENO: result: $ac_cv_lib_l_yywrap" >&5
2526 echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6
2527 if test $ac_cv_lib_l_yywrap = yes; then
2528 LEXLIB="-ll"
2529 fi
2530
2531 fi
2532
2533 fi
2534
2535 if test "x$LEX" != "x:"; then
2536 echo "$as_me:$LINENO: checking lex output file root" >&5
2537 echo $ECHO_N "checking lex output file root... $ECHO_C" >&6
2538 if test "${ac_cv_prog_lex_root+set}" = set; then
2539 echo $ECHO_N "(cached) $ECHO_C" >&6
2540 else
2541 # The minimal lex program is just a single line: %%. But some broken lexes
2542 # (Solaris, I think it was) want two %% lines, so accommodate them.
2543 cat >conftest.l <<_ACEOF
2544 %%
2545 %%
2546 _ACEOF
2547 { (eval echo "$as_me:$LINENO: \"$LEX conftest.l\"") >&5
2548 (eval $LEX conftest.l) 2>&5
2549 ac_status=$?
2550 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2551 (exit $ac_status); }
2552 if test -f lex.yy.c; then
2553 ac_cv_prog_lex_root=lex.yy
2554 elif test -f lexyy.c; then
2555 ac_cv_prog_lex_root=lexyy
2556 else
2557 { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5
2558 echo "$as_me: error: cannot find output from $LEX; giving up" >&2;}
2559 { (exit 1); exit 1; }; }
2560 fi
2561 fi
2562 echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5
2563 echo "${ECHO_T}$ac_cv_prog_lex_root" >&6
2564 rm -f conftest.l
2565 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
2566
2567 echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5
2568 echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6
2569 if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then
2570 echo $ECHO_N "(cached) $ECHO_C" >&6
2571 else
2572 # POSIX says lex can declare yytext either as a pointer or an array; the
2573 # default is implementation-dependent. Figure out which it is, since
2574 # not all implementations provide the %pointer and %array declarations.
2575 ac_cv_prog_lex_yytext_pointer=no
2576 echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
2577 ac_save_LIBS=$LIBS
2578 LIBS="$LIBS $LEXLIB"
2579 cat >conftest.$ac_ext <<_ACEOF
2580 `cat $LEX_OUTPUT_ROOT.c`
2581 _ACEOF
2582 rm -f conftest.$ac_objext conftest$ac_exeext
2583 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2584 (eval $ac_link) 2>conftest.er1
2585 ac_status=$?
2586 grep -v '^ *+' conftest.er1 >conftest.err
2587 rm -f conftest.er1
2588 cat conftest.err >&5
2589 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2590 (exit $ac_status); } &&
2591 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2592 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2593 (eval $ac_try) 2>&5
2594 ac_status=$?
2595 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2596 (exit $ac_status); }; } &&
2597 { ac_try='test -s conftest$ac_exeext'
2598 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2599 (eval $ac_try) 2>&5
2600 ac_status=$?
2601 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2602 (exit $ac_status); }; }; then
2603 ac_cv_prog_lex_yytext_pointer=yes
2604 else
2605 echo "$as_me: failed program was:" >&5
2606 sed 's/^/| /' conftest.$ac_ext >&5
2607
2608 fi
2609 rm -f conftest.err conftest.$ac_objext \
2610 conftest$ac_exeext conftest.$ac_ext
2611 LIBS=$ac_save_LIBS
2612 rm -f "${LEX_OUTPUT_ROOT}.c"
2613
2614 fi
2615 echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5
2616 echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6
2617 if test $ac_cv_prog_lex_yytext_pointer = yes; then
2618
2619 cat >>confdefs.h <<\_ACEOF
2620 #define YYTEXT_POINTER 1
2621 _ACEOF
2622
2623 fi
2624
2625 fi
2626 ac_aux_dir=
2627 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
2628 if test -f $ac_dir/install-sh; then
2629 ac_aux_dir=$ac_dir
2630 ac_install_sh="$ac_aux_dir/install-sh -c"
2631 break
2632 elif test -f $ac_dir/install.sh; then
2633 ac_aux_dir=$ac_dir
2634 ac_install_sh="$ac_aux_dir/install.sh -c"
2635 break
2636 elif test -f $ac_dir/shtool; then
2637 ac_aux_dir=$ac_dir
2638 ac_install_sh="$ac_aux_dir/shtool install -c"
2639 break
2640 fi
2641 done
2642 if test -z "$ac_aux_dir"; then
2643 { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
2644 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
2645 { (exit 1); exit 1; }; }
2646 fi
2647 ac_config_guess="$SHELL $ac_aux_dir/config.guess"
2648 ac_config_sub="$SHELL $ac_aux_dir/config.sub"
2649 ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
2650
2651 # Find a good install program. We prefer a C program (faster),
2652 # so one script is as good as another. But avoid the broken or
2653 # incompatible versions:
2654 # SysV /etc/install, /usr/sbin/install
2655 # SunOS /usr/etc/install
2656 # IRIX /sbin/install
2657 # AIX /bin/install
2658 # AmigaOS /C/install, which installs bootblocks on floppy discs
2659 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
2660 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
2661 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
2662 # OS/2's system install, which has a completely different semantic
2663 # ./install, which can be erroneously created by make from ./install.sh.
2664 echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
2665 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
2666 if test -z "$INSTALL"; then
2667 if test "${ac_cv_path_install+set}" = set; then
2668 echo $ECHO_N "(cached) $ECHO_C" >&6
2669 else
2670 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2671 for as_dir in $PATH
2672 do
2673 IFS=$as_save_IFS
2674 test -z "$as_dir" && as_dir=.
2675 # Account for people who put trailing slashes in PATH elements.
2676 case $as_dir/ in
2677 ./ | .// | /cC/* | \
2678 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
2679 ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
2680 /usr/ucb/* ) ;;
2681 *)
2682 # OSF1 and SCO ODT 3.0 have their own names for install.
2683 # Don't use installbsd from OSF since it installs stuff as root
2684 # by default.
2685 for ac_prog in ginstall scoinst install; do
2686 for ac_exec_ext in '' $ac_executable_extensions; do
2687 if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
2688 if test $ac_prog = install &&
2689 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2690 # AIX install. It has an incompatible calling convention.
2691 :
2692 elif test $ac_prog = install &&
2693 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2694 # program-specific install script used by HP pwplus--don't use.
2695 :
2696 else
2697 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
2698 break 3
2699 fi
2700 fi
2701 done
2702 done
2703 ;;
2704 esac
2705 done
2706
2707
2708 fi
2709 if test "${ac_cv_path_install+set}" = set; then
2710 INSTALL=$ac_cv_path_install
2711 else
2712 # As a last resort, use the slow shell script. We don't cache a
2713 # path for INSTALL within a source directory, because that will
2714 # break other packages using the cache if that directory is
2715 # removed, or if the path is relative.
2716 INSTALL=$ac_install_sh
2717 fi
2718 fi
2719 echo "$as_me:$LINENO: result: $INSTALL" >&5
2720 echo "${ECHO_T}$INSTALL" >&6
2721
2722 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
2723 # It thinks the first close brace ends the variable substitution.
2724 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
2725
2726 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
2727
2728 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
2729
2730
2731 if test "x$ac_cv_prog_LEX" = "xflex"; then
2732 LFLAGS=-i
2733 fi
2734
2735 # Check if we need to build the flow-tools converter
2736
2737
2738 # Check whether --with-ftpath or --without-ftpath was given.
2739 if test "${with_ftpath+set}" = set; then
2740 withval="$with_ftpath"
2741 if test "x$with_ftpath" = "xyes" ; then
2742 WHERE_FTPATH="../flow-tools-0.67"
2743 else
2744 WHERE_FTPATH=$with_ftpath
2745 fi
2746
2747 else
2748 WHERE_FTPATH="../flow-tools-0.67"
2749
2750 fi;
2751
2752
2753 # Check whether --enable-ftconv or --disable-ftconv was given.
2754 if test "${enable_ftconv+set}" = set; then
2755 enableval="$enable_ftconv"
2756
2757 echo "$as_me:$LINENO: checking for zlibVersion in -lz" >&5
2758 echo $ECHO_N "checking for zlibVersion in -lz... $ECHO_C" >&6
2759 if test "${ac_cv_lib_z_zlibVersion+set}" = set; then
2760 echo $ECHO_N "(cached) $ECHO_C" >&6
2761 else
2762 ac_check_lib_save_LIBS=$LIBS
2763 LIBS="-lz $LIBS"
2764 cat >conftest.$ac_ext <<_ACEOF
2765 /* confdefs.h. */
2766 _ACEOF
2767 cat confdefs.h >>conftest.$ac_ext
2768 cat >>conftest.$ac_ext <<_ACEOF
2769 /* end confdefs.h. */
2770
2771 /* Override any gcc2 internal prototype to avoid an error. */
2772 #ifdef __cplusplus
2773 extern "C"
2774 #endif
2775 /* We use char because int might match the return type of a gcc2
2776 builtin and then its argument prototype would still apply. */
2777 char zlibVersion ();
2778 int
2779 main ()
2780 {
2781 zlibVersion ();
2782 ;
2783 return 0;
2784 }
2785 _ACEOF
2786 rm -f conftest.$ac_objext conftest$ac_exeext
2787 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2788 (eval $ac_link) 2>conftest.er1
2789 ac_status=$?
2790 grep -v '^ *+' conftest.er1 >conftest.err
2791 rm -f conftest.er1
2792 cat conftest.err >&5
2793 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2794 (exit $ac_status); } &&
2795 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2796 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2797 (eval $ac_try) 2>&5
2798 ac_status=$?
2799 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2800 (exit $ac_status); }; } &&
2801 { ac_try='test -s conftest$ac_exeext'
2802 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2803 (eval $ac_try) 2>&5
2804 ac_status=$?
2805 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2806 (exit $ac_status); }; }; then
2807 ac_cv_lib_z_zlibVersion=yes
2808 else
2809 echo "$as_me: failed program was:" >&5
2810 sed 's/^/| /' conftest.$ac_ext >&5
2811
2812 ac_cv_lib_z_zlibVersion=no
2813 fi
2814 rm -f conftest.err conftest.$ac_objext \
2815 conftest$ac_exeext conftest.$ac_ext
2816 LIBS=$ac_check_lib_save_LIBS
2817 fi
2818 echo "$as_me:$LINENO: result: $ac_cv_lib_z_zlibVersion" >&5
2819 echo "${ECHO_T}$ac_cv_lib_z_zlibVersion" >&6
2820 if test $ac_cv_lib_z_zlibVersion = yes; then
2821 cat >>confdefs.h <<_ACEOF
2822 #define HAVE_LIBZ 1
2823 _ACEOF
2824
2825 LIBS="-lz $LIBS"
2826
2827 else
2828 { { echo "$as_me:$LINENO: error: Link with \"-lz\" failed! (Need zlib >= 1.0.2)" >&5
2829 echo "$as_me: error: Link with \"-lz\" failed! (Need zlib >= 1.0.2)" >&2;}
2830 { (exit 1); exit 1; }; }
2831
2832 fi
2833
2834 if test -d "$WHERE_FTPATH"; then
2835 if test ! -f "$WHERE_FTPATH/lib/ftlib.h"; then
2836 { { echo "$as_me:$LINENO: error: ftlib.h file not found in flow-tools directory '$WHERE_FTPATH'. Use --with-ftpath=PATH" >&5
2837 echo "$as_me: error: ftlib.h file not found in flow-tools directory '$WHERE_FTPATH'. Use --with-ftpath=PATH" >&2;}
2838 { (exit 1); exit 1; }; }
2839 fi
2840 if test ! -f "$WHERE_FTPATH/lib/libft.a"; then
2841 { { echo "$as_me:$LINENO: error: libft.a not found in flow-tools directory '$WHERE_FTPATH'. Build flow tools first" >&5
2842 echo "$as_me: error: libft.a not found in flow-tools directory '$WHERE_FTPATH'. Build flow tools first" >&2;}
2843 { (exit 1); exit 1; }; }
2844 fi
2845 FT_INCLUDES="-I$WHERE_FTPATH/src -I$WHERE_FTPATH/lib"
2846 FT_LDFLAGS="-L$WHERE_FTPATH/lib"
2847 else
2848 { { echo "$as_me:$LINENO: error: flow-tools directory '$WHERE_FTPATH' does not exists. Use --with-ftpath=PATH" >&5
2849 echo "$as_me: error: flow-tools directory '$WHERE_FTPATH' does not exists. Use --with-ftpath=PATH" >&2;}
2850 { (exit 1); exit 1; }; }
2851 fi
2852 opt_objects=ft2nfdump
2853
2854 else
2855 opt_objects=
2856
2857 fi;
2858
2859
2860
2861
2862
2863
2864
2865 # Checks for libraries.
2866
2867 for ac_func in gethostbyname
2868 do
2869 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
2870 echo "$as_me:$LINENO: checking for $ac_func" >&5
2871 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
2872 if eval "test \"\${$as_ac_var+set}\" = set"; then
2873 echo $ECHO_N "(cached) $ECHO_C" >&6
2874 else
2875 cat >conftest.$ac_ext <<_ACEOF
2876 /* confdefs.h. */
2877 _ACEOF
2878 cat confdefs.h >>conftest.$ac_ext
2879 cat >>conftest.$ac_ext <<_ACEOF
2880 /* end confdefs.h. */
2881 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
2882 For example, HP-UX 11i <limits.h> declares gettimeofday. */
2883 #define $ac_func innocuous_$ac_func
2884
2885 /* System header to define __stub macros and hopefully few prototypes,
2886 which can conflict with char $ac_func (); below.
2887 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
2888 <limits.h> exists even on freestanding compilers. */
2889
2890 #ifdef __STDC__
2891 # include <limits.h>
2892 #else
2893 # include <assert.h>
2894 #endif
2895
2896 #undef $ac_func
2897
2898 /* Override any gcc2 internal prototype to avoid an error. */
2899 #ifdef __cplusplus
2900 extern "C"
2901 {
2902 #endif
2903 /* We use char because int might match the return type of a gcc2
2904 builtin and then its argument prototype would still apply. */
2905 char $ac_func ();
2906 /* The GNU C library defines this for functions which it implements
2907 to always fail with ENOSYS. Some functions are actually named
2908 something starting with __ and the normal name is an alias. */
2909 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
2910 choke me
2911 #else
2912 char (*f) () = $ac_func;
2913 #endif
2914 #ifdef __cplusplus
2915 }
2916 #endif
2917
2918 int
2919 main ()
2920 {
2921 return f != $ac_func;
2922 ;
2923 return 0;
2924 }
2925 _ACEOF
2926 rm -f conftest.$ac_objext conftest$ac_exeext
2927 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2928 (eval $ac_link) 2>conftest.er1
2929 ac_status=$?
2930 grep -v '^ *+' conftest.er1 >conftest.err
2931 rm -f conftest.er1
2932 cat conftest.err >&5
2933 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2934 (exit $ac_status); } &&
2935 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
2936 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2937 (eval $ac_try) 2>&5
2938 ac_status=$?
2939 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2940 (exit $ac_status); }; } &&
2941 { ac_try='test -s conftest$ac_exeext'
2942 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2943 (eval $ac_try) 2>&5
2944 ac_status=$?
2945 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2946 (exit $ac_status); }; }; then
2947 eval "$as_ac_var=yes"
2948 else
2949 echo "$as_me: failed program was:" >&5
2950 sed 's/^/| /' conftest.$ac_ext >&5
2951
2952 eval "$as_ac_var=no"
2953 fi
2954 rm -f conftest.err conftest.$ac_objext \
2955 conftest$ac_exeext conftest.$ac_ext
2956 fi
2957 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
2958 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
2959 if test `eval echo '${'$as_ac_var'}'` = yes; then
2960 cat >>confdefs.h <<_ACEOF
2961 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
2962 _ACEOF
2963
2964 else
2965
2966 echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
2967 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
2968 if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
2969 echo $ECHO_N "(cached) $ECHO_C" >&6
2970 else
2971 ac_check_lib_save_LIBS=$LIBS
2972 LIBS="-lnsl $LIBS"
2973 cat >conftest.$ac_ext <<_ACEOF
2974 /* confdefs.h. */
2975 _ACEOF
2976 cat confdefs.h >>conftest.$ac_ext
2977 cat >>conftest.$ac_ext <<_ACEOF
2978 /* end confdefs.h. */
2979
2980 /* Override any gcc2 internal prototype to avoid an error. */
2981 #ifdef __cplusplus
2982 extern "C"
2983 #endif
2984 /* We use char because int might match the return type of a gcc2
2985 builtin and then its argument prototype would still apply. */
2986 char gethostbyname ();
2987 int
2988 main ()
2989 {
2990 gethostbyname ();
2991 ;
2992 return 0;
2993 }
2994 _ACEOF
2995 rm -f conftest.$ac_objext conftest$ac_exeext
2996 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
2997 (eval $ac_link) 2>conftest.er1
2998 ac_status=$?
2999 grep -v '^ *+' conftest.er1 >conftest.err
3000 rm -f conftest.er1
3001 cat conftest.err >&5
3002 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3003 (exit $ac_status); } &&
3004 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3005 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3006 (eval $ac_try) 2>&5
3007 ac_status=$?
3008 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3009 (exit $ac_status); }; } &&
3010 { ac_try='test -s conftest$ac_exeext'
3011 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3012 (eval $ac_try) 2>&5
3013 ac_status=$?
3014 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3015 (exit $ac_status); }; }; then
3016 ac_cv_lib_nsl_gethostbyname=yes
3017 else
3018 echo "$as_me: failed program was:" >&5
3019 sed 's/^/| /' conftest.$ac_ext >&5
3020
3021 ac_cv_lib_nsl_gethostbyname=no
3022 fi
3023 rm -f conftest.err conftest.$ac_objext \
3024 conftest$ac_exeext conftest.$ac_ext
3025 LIBS=$ac_check_lib_save_LIBS
3026 fi
3027 echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
3028 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
3029 if test $ac_cv_lib_nsl_gethostbyname = yes; then
3030 cat >>confdefs.h <<_ACEOF
3031 #define HAVE_LIBNSL 1
3032 _ACEOF
3033
3034 LIBS="-lnsl $LIBS"
3035
3036 else
3037
3038 echo "$as_me:$LINENO: checking for gethostbyname in -lsocket" >&5
3039 echo $ECHO_N "checking for gethostbyname in -lsocket... $ECHO_C" >&6
3040 if test "${ac_cv_lib_socket_gethostbyname+set}" = set; then
3041 echo $ECHO_N "(cached) $ECHO_C" >&6
3042 else
3043 ac_check_lib_save_LIBS=$LIBS
3044 LIBS="-lsocket $LIBS"
3045 cat >conftest.$ac_ext <<_ACEOF
3046 /* confdefs.h. */
3047 _ACEOF
3048 cat confdefs.h >>conftest.$ac_ext
3049 cat >>conftest.$ac_ext <<_ACEOF
3050 /* end confdefs.h. */
3051
3052 /* Override any gcc2 internal prototype to avoid an error. */
3053 #ifdef __cplusplus
3054 extern "C"
3055 #endif
3056 /* We use char because int might match the return type of a gcc2
3057 builtin and then its argument prototype would still apply. */
3058 char gethostbyname ();
3059 int
3060 main ()
3061 {
3062 gethostbyname ();
3063 ;
3064 return 0;
3065 }
3066 _ACEOF
3067 rm -f conftest.$ac_objext conftest$ac_exeext
3068 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3069 (eval $ac_link) 2>conftest.er1
3070 ac_status=$?
3071 grep -v '^ *+' conftest.er1 >conftest.err
3072 rm -f conftest.er1
3073 cat conftest.err >&5
3074 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3075 (exit $ac_status); } &&
3076 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3077 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3078 (eval $ac_try) 2>&5
3079 ac_status=$?
3080 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3081 (exit $ac_status); }; } &&
3082 { ac_try='test -s conftest$ac_exeext'
3083 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3084 (eval $ac_try) 2>&5
3085 ac_status=$?
3086 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3087 (exit $ac_status); }; }; then
3088 ac_cv_lib_socket_gethostbyname=yes
3089 else
3090 echo "$as_me: failed program was:" >&5
3091 sed 's/^/| /' conftest.$ac_ext >&5
3092
3093 ac_cv_lib_socket_gethostbyname=no
3094 fi
3095 rm -f conftest.err conftest.$ac_objext \
3096 conftest$ac_exeext conftest.$ac_ext
3097 LIBS=$ac_check_lib_save_LIBS
3098 fi
3099 echo "$as_me:$LINENO: result: $ac_cv_lib_socket_gethostbyname" >&5
3100 echo "${ECHO_T}$ac_cv_lib_socket_gethostbyname" >&6
3101 if test $ac_cv_lib_socket_gethostbyname = yes; then
3102 cat >>confdefs.h <<_ACEOF
3103 #define HAVE_LIBSOCKET 1
3104 _ACEOF
3105
3106 LIBS="-lsocket $LIBS"
3107
3108 fi
3109
3110 fi
3111
3112 fi
3113 done
3114
3115
3116 for ac_func in setsockopt
3117 do
3118 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
3119 echo "$as_me:$LINENO: checking for $ac_func" >&5
3120 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
3121 if eval "test \"\${$as_ac_var+set}\" = set"; then
3122 echo $ECHO_N "(cached) $ECHO_C" >&6
3123 else
3124 cat >conftest.$ac_ext <<_ACEOF
3125 /* confdefs.h. */
3126 _ACEOF
3127 cat confdefs.h >>conftest.$ac_ext
3128 cat >>conftest.$ac_ext <<_ACEOF
3129 /* end confdefs.h. */
3130 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
3131 For example, HP-UX 11i <limits.h> declares gettimeofday. */
3132 #define $ac_func innocuous_$ac_func
3133
3134 /* System header to define __stub macros and hopefully few prototypes,
3135 which can conflict with char $ac_func (); below.
3136 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
3137 <limits.h> exists even on freestanding compilers. */
3138
3139 #ifdef __STDC__
3140 # include <limits.h>
3141 #else
3142 # include <assert.h>
3143 #endif
3144
3145 #undef $ac_func
3146
3147 /* Override any gcc2 internal prototype to avoid an error. */
3148 #ifdef __cplusplus
3149 extern "C"
3150 {
3151 #endif
3152 /* We use char because int might match the return type of a gcc2
3153 builtin and then its argument prototype would still apply. */
3154 char $ac_func ();
3155 /* The GNU C library defines this for functions which it implements
3156 to always fail with ENOSYS. Some functions are actually named
3157 something starting with __ and the normal name is an alias. */
3158 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
3159 choke me
3160 #else
3161 char (*f) () = $ac_func;
3162 #endif
3163 #ifdef __cplusplus
3164 }
3165 #endif
3166
3167 int
3168 main ()
3169 {
3170 return f != $ac_func;
3171 ;
3172 return 0;
3173 }
3174 _ACEOF
3175 rm -f conftest.$ac_objext conftest$ac_exeext
3176 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3177 (eval $ac_link) 2>conftest.er1
3178 ac_status=$?
3179 grep -v '^ *+' conftest.er1 >conftest.err
3180 rm -f conftest.er1
3181 cat conftest.err >&5
3182 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3183 (exit $ac_status); } &&
3184 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3185 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3186 (eval $ac_try) 2>&5
3187 ac_status=$?
3188 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3189 (exit $ac_status); }; } &&
3190 { ac_try='test -s conftest$ac_exeext'
3191 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3192 (eval $ac_try) 2>&5
3193 ac_status=$?
3194 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3195 (exit $ac_status); }; }; then
3196 eval "$as_ac_var=yes"
3197 else
3198 echo "$as_me: failed program was:" >&5
3199 sed 's/^/| /' conftest.$ac_ext >&5
3200
3201 eval "$as_ac_var=no"
3202 fi
3203 rm -f conftest.err conftest.$ac_objext \
3204 conftest$ac_exeext conftest.$ac_ext
3205 fi
3206 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
3207 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
3208 if test `eval echo '${'$as_ac_var'}'` = yes; then
3209 cat >>confdefs.h <<_ACEOF
3210 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
3211 _ACEOF
3212
3213 else
3214
3215 echo "$as_me:$LINENO: checking for setsockopt in -lsocket" >&5
3216 echo $ECHO_N "checking for setsockopt in -lsocket... $ECHO_C" >&6
3217 if test "${ac_cv_lib_socket_setsockopt+set}" = set; then
3218 echo $ECHO_N "(cached) $ECHO_C" >&6
3219 else
3220 ac_check_lib_save_LIBS=$LIBS
3221 LIBS="-lsocket $LIBS"
3222 cat >conftest.$ac_ext <<_ACEOF
3223 /* confdefs.h. */
3224 _ACEOF
3225 cat confdefs.h >>conftest.$ac_ext
3226 cat >>conftest.$ac_ext <<_ACEOF
3227 /* end confdefs.h. */
3228
3229 /* Override any gcc2 internal prototype to avoid an error. */
3230 #ifdef __cplusplus
3231 extern "C"
3232 #endif
3233 /* We use char because int might match the return type of a gcc2
3234 builtin and then its argument prototype would still apply. */
3235 char setsockopt ();
3236 int
3237 main ()
3238 {
3239 setsockopt ();
3240 ;
3241 return 0;
3242 }
3243 _ACEOF
3244 rm -f conftest.$ac_objext conftest$ac_exeext
3245 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3246 (eval $ac_link) 2>conftest.er1
3247 ac_status=$?
3248 grep -v '^ *+' conftest.er1 >conftest.err
3249 rm -f conftest.er1
3250 cat conftest.err >&5
3251 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3252 (exit $ac_status); } &&
3253 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3254 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3255 (eval $ac_try) 2>&5
3256 ac_status=$?
3257 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3258 (exit $ac_status); }; } &&
3259 { ac_try='test -s conftest$ac_exeext'
3260 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3261 (eval $ac_try) 2>&5
3262 ac_status=$?
3263 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3264 (exit $ac_status); }; }; then
3265 ac_cv_lib_socket_setsockopt=yes
3266 else
3267 echo "$as_me: failed program was:" >&5
3268 sed 's/^/| /' conftest.$ac_ext >&5
3269
3270 ac_cv_lib_socket_setsockopt=no
3271 fi
3272 rm -f conftest.err conftest.$ac_objext \
3273 conftest$ac_exeext conftest.$ac_ext
3274 LIBS=$ac_check_lib_save_LIBS
3275 fi
3276 echo "$as_me:$LINENO: result: $ac_cv_lib_socket_setsockopt" >&5
3277 echo "${ECHO_T}$ac_cv_lib_socket_setsockopt" >&6
3278 if test $ac_cv_lib_socket_setsockopt = yes; then
3279 cat >>confdefs.h <<_ACEOF
3280 #define HAVE_LIBSOCKET 1
3281 _ACEOF
3282
3283 LIBS="-lsocket $LIBS"
3284
3285 fi
3286
3287 fi
3288 done
3289
3290
3291 # Checks for header files.
3292
3293
3294
3295
3296
3297 ac_header_dirent=no
3298 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
3299 as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
3300 echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
3301 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
3302 if eval "test \"\${$as_ac_Header+set}\" = set"; then
3303 echo $ECHO_N "(cached) $ECHO_C" >&6
3304 else
3305 cat >conftest.$ac_ext <<_ACEOF
3306 /* confdefs.h. */
3307 _ACEOF
3308 cat confdefs.h >>conftest.$ac_ext
3309 cat >>conftest.$ac_ext <<_ACEOF
3310 /* end confdefs.h. */
3311 #include <sys/types.h>
3312 #include <$ac_hdr>
3313
3314 int
3315 main ()
3316 {
3317 if ((DIR *) 0)
3318 return 0;
3319 ;
3320 return 0;
3321 }
3322 _ACEOF
3323 rm -f conftest.$ac_objext
3324 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
3325 (eval $ac_compile) 2>conftest.er1
3326 ac_status=$?
3327 grep -v '^ *+' conftest.er1 >conftest.err
3328 rm -f conftest.er1
3329 cat conftest.err >&5
3330 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3331 (exit $ac_status); } &&
3332 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3333 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3334 (eval $ac_try) 2>&5
3335 ac_status=$?
3336 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3337 (exit $ac_status); }; } &&
3338 { ac_try='test -s conftest.$ac_objext'
3339 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3340 (eval $ac_try) 2>&5
3341 ac_status=$?
3342 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3343 (exit $ac_status); }; }; then
3344 eval "$as_ac_Header=yes"
3345 else
3346 echo "$as_me: failed program was:" >&5
3347 sed 's/^/| /' conftest.$ac_ext >&5
3348
3349 eval "$as_ac_Header=no"
3350 fi
3351 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
3352 fi
3353 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
3354 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
3355 if test `eval echo '${'$as_ac_Header'}'` = yes; then
3356 cat >>confdefs.h <<_ACEOF
3357 #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
3358 _ACEOF
3359
3360 ac_header_dirent=$ac_hdr; break
3361 fi
3362
3363 done
3364 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
3365 if test $ac_header_dirent = dirent.h; then
3366 echo "$as_me:$LINENO: checking for library containing opendir" >&5
3367 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6
3368 if test "${ac_cv_search_opendir+set}" = set; then
3369 echo $ECHO_N "(cached) $ECHO_C" >&6
3370 else
3371 ac_func_search_save_LIBS=$LIBS
3372 ac_cv_search_opendir=no
3373 cat >conftest.$ac_ext <<_ACEOF
3374 /* confdefs.h. */
3375 _ACEOF
3376 cat confdefs.h >>conftest.$ac_ext
3377 cat >>conftest.$ac_ext <<_ACEOF
3378 /* end confdefs.h. */
3379
3380 /* Override any gcc2 internal prototype to avoid an error. */
3381 #ifdef __cplusplus
3382 extern "C"
3383 #endif
3384 /* We use char because int might match the return type of a gcc2
3385 builtin and then its argument prototype would still apply. */
3386 char opendir ();
3387 int
3388 main ()
3389 {
3390 opendir ();
3391 ;
3392 return 0;
3393 }
3394 _ACEOF
3395 rm -f conftest.$ac_objext conftest$ac_exeext
3396 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3397 (eval $ac_link) 2>conftest.er1
3398 ac_status=$?
3399 grep -v '^ *+' conftest.er1 >conftest.err
3400 rm -f conftest.er1
3401 cat conftest.err >&5
3402 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3403 (exit $ac_status); } &&
3404 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3405 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3406 (eval $ac_try) 2>&5
3407 ac_status=$?
3408 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3409 (exit $ac_status); }; } &&
3410 { ac_try='test -s conftest$ac_exeext'
3411 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3412 (eval $ac_try) 2>&5
3413 ac_status=$?
3414 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3415 (exit $ac_status); }; }; then
3416 ac_cv_search_opendir="none required"
3417 else
3418 echo "$as_me: failed program was:" >&5
3419 sed 's/^/| /' conftest.$ac_ext >&5
3420
3421 fi
3422 rm -f conftest.err conftest.$ac_objext \
3423 conftest$ac_exeext conftest.$ac_ext
3424 if test "$ac_cv_search_opendir" = no; then
3425 for ac_lib in dir; do
3426 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
3427 cat >conftest.$ac_ext <<_ACEOF
3428 /* confdefs.h. */
3429 _ACEOF
3430 cat confdefs.h >>conftest.$ac_ext
3431 cat >>conftest.$ac_ext <<_ACEOF
3432 /* end confdefs.h. */
3433
3434 /* Override any gcc2 internal prototype to avoid an error. */
3435 #ifdef __cplusplus
3436 extern "C"
3437 #endif
3438 /* We use char because int might match the return type of a gcc2
3439 builtin and then its argument prototype would still apply. */
3440 char opendir ();
3441 int
3442 main ()
3443 {
3444 opendir ();
3445 ;
3446 return 0;
3447 }
3448 _ACEOF
3449 rm -f conftest.$ac_objext conftest$ac_exeext
3450 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3451 (eval $ac_link) 2>conftest.er1
3452 ac_status=$?
3453 grep -v '^ *+' conftest.er1 >conftest.err
3454 rm -f conftest.er1
3455 cat conftest.err >&5
3456 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3457 (exit $ac_status); } &&
3458 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3459 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3460 (eval $ac_try) 2>&5
3461 ac_status=$?
3462 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3463 (exit $ac_status); }; } &&
3464 { ac_try='test -s conftest$ac_exeext'
3465 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3466 (eval $ac_try) 2>&5
3467 ac_status=$?
3468 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3469 (exit $ac_status); }; }; then
3470 ac_cv_search_opendir="-l$ac_lib"
3471 break
3472 else
3473 echo "$as_me: failed program was:" >&5
3474 sed 's/^/| /' conftest.$ac_ext >&5
3475
3476 fi
3477 rm -f conftest.err conftest.$ac_objext \
3478 conftest$ac_exeext conftest.$ac_ext
3479 done
3480 fi
3481 LIBS=$ac_func_search_save_LIBS
3482 fi
3483 echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
3484 echo "${ECHO_T}$ac_cv_search_opendir" >&6
3485 if test "$ac_cv_search_opendir" != no; then
3486 test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS"
3487
3488 fi
3489
3490 else
3491 echo "$as_me:$LINENO: checking for library containing opendir" >&5
3492 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6
3493 if test "${ac_cv_search_opendir+set}" = set; then
3494 echo $ECHO_N "(cached) $ECHO_C" >&6
3495 else
3496 ac_func_search_save_LIBS=$LIBS
3497 ac_cv_search_opendir=no
3498 cat >conftest.$ac_ext <<_ACEOF
3499 /* confdefs.h. */
3500 _ACEOF
3501 cat confdefs.h >>conftest.$ac_ext
3502 cat >>conftest.$ac_ext <<_ACEOF
3503 /* end confdefs.h. */
3504
3505 /* Override any gcc2 internal prototype to avoid an error. */
3506 #ifdef __cplusplus
3507 extern "C"
3508 #endif
3509 /* We use char because int might match the return type of a gcc2
3510 builtin and then its argument prototype would still apply. */
3511 char opendir ();
3512 int
3513 main ()
3514 {
3515 opendir ();
3516 ;
3517 return 0;
3518 }
3519 _ACEOF
3520 rm -f conftest.$ac_objext conftest$ac_exeext
3521 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3522 (eval $ac_link) 2>conftest.er1
3523 ac_status=$?
3524 grep -v '^ *+' conftest.er1 >conftest.err
3525 rm -f conftest.er1
3526 cat conftest.err >&5
3527 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3528 (exit $ac_status); } &&
3529 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3530 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3531 (eval $ac_try) 2>&5
3532 ac_status=$?
3533 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3534 (exit $ac_status); }; } &&
3535 { ac_try='test -s conftest$ac_exeext'
3536 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3537 (eval $ac_try) 2>&5
3538 ac_status=$?
3539 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3540 (exit $ac_status); }; }; then
3541 ac_cv_search_opendir="none required"
3542 else
3543 echo "$as_me: failed program was:" >&5
3544 sed 's/^/| /' conftest.$ac_ext >&5
3545
3546 fi
3547 rm -f conftest.err conftest.$ac_objext \
3548 conftest$ac_exeext conftest.$ac_ext
3549 if test "$ac_cv_search_opendir" = no; then
3550 for ac_lib in x; do
3551 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
3552 cat >conftest.$ac_ext <<_ACEOF
3553 /* confdefs.h. */
3554 _ACEOF
3555 cat confdefs.h >>conftest.$ac_ext
3556 cat >>conftest.$ac_ext <<_ACEOF
3557 /* end confdefs.h. */
3558
3559 /* Override any gcc2 internal prototype to avoid an error. */
3560 #ifdef __cplusplus
3561 extern "C"
3562 #endif
3563 /* We use char because int might match the return type of a gcc2
3564 builtin and then its argument prototype would still apply. */
3565 char opendir ();
3566 int
3567 main ()
3568 {
3569 opendir ();
3570 ;
3571 return 0;
3572 }
3573 _ACEOF
3574 rm -f conftest.$ac_objext conftest$ac_exeext
3575 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3576 (eval $ac_link) 2>conftest.er1
3577 ac_status=$?
3578 grep -v '^ *+' conftest.er1 >conftest.err
3579 rm -f conftest.er1
3580 cat conftest.err >&5
3581 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3582 (exit $ac_status); } &&
3583 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3584 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3585 (eval $ac_try) 2>&5
3586 ac_status=$?
3587 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3588 (exit $ac_status); }; } &&
3589 { ac_try='test -s conftest$ac_exeext'
3590 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3591 (eval $ac_try) 2>&5
3592 ac_status=$?
3593 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3594 (exit $ac_status); }; }; then
3595 ac_cv_search_opendir="-l$ac_lib"
3596 break
3597 else
3598 echo "$as_me: failed program was:" >&5
3599 sed 's/^/| /' conftest.$ac_ext >&5
3600
3601 fi
3602 rm -f conftest.err conftest.$ac_objext \
3603 conftest$ac_exeext conftest.$ac_ext
3604 done
3605 fi
3606 LIBS=$ac_func_search_save_LIBS
3607 fi
3608 echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
3609 echo "${ECHO_T}$ac_cv_search_opendir" >&6
3610 if test "$ac_cv_search_opendir" != no; then
3611 test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS"
3612
3613 fi
3614
3615 fi
3616
3617 ac_ext=c
3618 ac_cpp='$CPP $CPPFLAGS'
3619 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3620 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3621 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3622 echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
3623 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
3624 # On Suns, sometimes $CPP names a directory.
3625 if test -n "$CPP" && test -d "$CPP"; then
3626 CPP=
3627 fi
3628 if test -z "$CPP"; then
3629 if test "${ac_cv_prog_CPP+set}" = set; then
3630 echo $ECHO_N "(cached) $ECHO_C" >&6
3631 else
3632 # Double quotes because CPP needs to be expanded
3633 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
3634 do
3635 ac_preproc_ok=false
3636 for ac_c_preproc_warn_flag in '' yes
3637 do
3638 # Use a header file that comes with gcc, so configuring glibc
3639 # with a fresh cross-compiler works.
3640 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
3641 # <limits.h> exists even on freestanding compilers.
3642 # On the NeXT, cc -E runs the code through the compiler's parser,
3643 # not just through cpp. "Syntax error" is here to catch this case.
3644 cat >conftest.$ac_ext <<_ACEOF
3645 /* confdefs.h. */
3646 _ACEOF
3647 cat confdefs.h >>conftest.$ac_ext
3648 cat >>conftest.$ac_ext <<_ACEOF
3649 /* end confdefs.h. */
3650 #ifdef __STDC__
3651 # include <limits.h>
3652 #else
3653 # include <assert.h>
3654 #endif
3655 Syntax error
3656 _ACEOF
3657 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
3658 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
3659 ac_status=$?
3660 grep -v '^ *+' conftest.er1 >conftest.err
3661 rm -f conftest.er1
3662 cat conftest.err >&5
3663 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3664 (exit $ac_status); } >/dev/null; then
3665 if test -s conftest.err; then
3666 ac_cpp_err=$ac_c_preproc_warn_flag
3667 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
3668 else
3669 ac_cpp_err=
3670 fi
3671 else
3672 ac_cpp_err=yes
3673 fi
3674 if test -z "$ac_cpp_err"; then
3675 :
3676 else
3677 echo "$as_me: failed program was:" >&5
3678 sed 's/^/| /' conftest.$ac_ext >&5
3679
3680 # Broken: fails on valid input.
3681 continue
3682 fi
3683 rm -f conftest.err conftest.$ac_ext
3684
3685 # OK, works on sane cases. Now check whether non-existent headers
3686 # can be detected and how.
3687 cat >conftest.$ac_ext <<_ACEOF
3688 /* confdefs.h. */
3689 _ACEOF
3690 cat confdefs.h >>conftest.$ac_ext
3691 cat >>conftest.$ac_ext <<_ACEOF
3692 /* end confdefs.h. */
3693 #include <ac_nonexistent.h>
3694 _ACEOF
3695 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
3696 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
3697 ac_status=$?
3698 grep -v '^ *+' conftest.er1 >conftest.err
3699 rm -f conftest.er1
3700 cat conftest.err >&5
3701 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3702 (exit $ac_status); } >/dev/null; then
3703 if test -s conftest.err; then
3704 ac_cpp_err=$ac_c_preproc_warn_flag
3705 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
3706 else
3707 ac_cpp_err=
3708 fi
3709 else
3710 ac_cpp_err=yes
3711 fi
3712 if test -z "$ac_cpp_err"; then
3713 # Broken: success on invalid input.
3714 continue
3715 else
3716 echo "$as_me: failed program was:" >&5
3717 sed 's/^/| /' conftest.$ac_ext >&5
3718
3719 # Passes both tests.
3720 ac_preproc_ok=:
3721 break
3722 fi
3723 rm -f conftest.err conftest.$ac_ext
3724
3725 done
3726 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
3727 rm -f conftest.err conftest.$ac_ext
3728 if $ac_preproc_ok; then
3729 break
3730 fi
3731
3732 done
3733 ac_cv_prog_CPP=$CPP
3734
3735 fi
3736 CPP=$ac_cv_prog_CPP
3737 else
3738 ac_cv_prog_CPP=$CPP
3739 fi
3740 echo "$as_me:$LINENO: result: $CPP" >&5
3741 echo "${ECHO_T}$CPP" >&6
3742 ac_preproc_ok=false
3743 for ac_c_preproc_warn_flag in '' yes
3744 do
3745 # Use a header file that comes with gcc, so configuring glibc
3746 # with a fresh cross-compiler works.
3747 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
3748 # <limits.h> exists even on freestanding compilers.
3749 # On the NeXT, cc -E runs the code through the compiler's parser,
3750 # not just through cpp. "Syntax error" is here to catch this case.
3751 cat >conftest.$ac_ext <<_ACEOF
3752 /* confdefs.h. */
3753 _ACEOF
3754 cat confdefs.h >>conftest.$ac_ext
3755 cat >>conftest.$ac_ext <<_ACEOF
3756 /* end confdefs.h. */
3757 #ifdef __STDC__
3758 # include <limits.h>
3759 #else
3760 # include <assert.h>
3761 #endif
3762 Syntax error
3763 _ACEOF
3764 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
3765 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
3766 ac_status=$?
3767 grep -v '^ *+' conftest.er1 >conftest.err
3768 rm -f conftest.er1
3769 cat conftest.err >&5
3770 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3771 (exit $ac_status); } >/dev/null; then
3772 if test -s conftest.err; then
3773 ac_cpp_err=$ac_c_preproc_warn_flag
3774 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
3775 else
3776 ac_cpp_err=
3777 fi
3778 else
3779 ac_cpp_err=yes
3780 fi
3781 if test -z "$ac_cpp_err"; then
3782 :
3783 else
3784 echo "$as_me: failed program was:" >&5
3785 sed 's/^/| /' conftest.$ac_ext >&5
3786
3787 # Broken: fails on valid input.
3788 continue
3789 fi
3790 rm -f conftest.err conftest.$ac_ext
3791
3792 # OK, works on sane cases. Now check whether non-existent headers
3793 # can be detected and how.
3794 cat >conftest.$ac_ext <<_ACEOF
3795 /* confdefs.h. */
3796 _ACEOF
3797 cat confdefs.h >>conftest.$ac_ext
3798 cat >>conftest.$ac_ext <<_ACEOF
3799 /* end confdefs.h. */
3800 #include <ac_nonexistent.h>
3801 _ACEOF
3802 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
3803 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
3804 ac_status=$?
3805 grep -v '^ *+' conftest.er1 >conftest.err
3806 rm -f conftest.er1
3807 cat conftest.err >&5
3808 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3809 (exit $ac_status); } >/dev/null; then
3810 if test -s conftest.err; then
3811 ac_cpp_err=$ac_c_preproc_warn_flag
3812 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
3813 else
3814 ac_cpp_err=
3815 fi
3816 else
3817 ac_cpp_err=yes
3818 fi
3819 if test -z "$ac_cpp_err"; then
3820 # Broken: success on invalid input.
3821 continue
3822 else
3823 echo "$as_me: failed program was:" >&5
3824 sed 's/^/| /' conftest.$ac_ext >&5
3825
3826 # Passes both tests.
3827 ac_preproc_ok=:
3828 break
3829 fi
3830 rm -f conftest.err conftest.$ac_ext
3831
3832 done
3833 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
3834 rm -f conftest.err conftest.$ac_ext
3835 if $ac_preproc_ok; then
3836 :
3837 else
3838 { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
3839 See \`config.log' for more details." >&5
3840 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
3841 See \`config.log' for more details." >&2;}
3842 { (exit 1); exit 1; }; }
3843 fi
3844
3845 ac_ext=c
3846 ac_cpp='$CPP $CPPFLAGS'
3847 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3848 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3849 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3850
3851
3852 echo "$as_me:$LINENO: checking for egrep" >&5
3853 echo $ECHO_N "checking for egrep... $ECHO_C" >&6
3854 if test "${ac_cv_prog_egrep+set}" = set; then
3855 echo $ECHO_N "(cached) $ECHO_C" >&6
3856 else
3857 if echo a | (grep -E '(a|b)') >/dev/null 2>&1
3858 then ac_cv_prog_egrep='grep -E'
3859 else ac_cv_prog_egrep='egrep'
3860 fi
3861 fi
3862 echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
3863 echo "${ECHO_T}$ac_cv_prog_egrep" >&6
3864 EGREP=$ac_cv_prog_egrep
3865
3866
3867 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
3868 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
3869 if test "${ac_cv_header_stdc+set}" = set; then
3870 echo $ECHO_N "(cached) $ECHO_C" >&6
3871 else
3872 cat >conftest.$ac_ext <<_ACEOF
3873 /* confdefs.h. */
3874 _ACEOF
3875 cat confdefs.h >>conftest.$ac_ext
3876 cat >>conftest.$ac_ext <<_ACEOF
3877 /* end confdefs.h. */
3878 #include <stdlib.h>
3879 #include <stdarg.h>
3880 #include <string.h>
3881 #include <float.h>
3882
3883 int
3884 main ()
3885 {
3886
3887 ;
3888 return 0;
3889 }
3890 _ACEOF
3891 rm -f conftest.$ac_objext
3892 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
3893 (eval $ac_compile) 2>conftest.er1
3894 ac_status=$?
3895 grep -v '^ *+' conftest.er1 >conftest.err
3896 rm -f conftest.er1
3897 cat conftest.err >&5
3898 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3899 (exit $ac_status); } &&
3900 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
3901 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3902 (eval $ac_try) 2>&5
3903 ac_status=$?
3904 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3905 (exit $ac_status); }; } &&
3906 { ac_try='test -s conftest.$ac_objext'
3907 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3908 (eval $ac_try) 2>&5
3909 ac_status=$?
3910 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3911 (exit $ac_status); }; }; then
3912 ac_cv_header_stdc=yes
3913 else
3914 echo "$as_me: failed program was:" >&5
3915 sed 's/^/| /' conftest.$ac_ext >&5
3916
3917 ac_cv_header_stdc=no
3918 fi
3919 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
3920
3921 if test $ac_cv_header_stdc = yes; then
3922 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
3923 cat >conftest.$ac_ext <<_ACEOF
3924 /* confdefs.h. */
3925 _ACEOF
3926 cat confdefs.h >>conftest.$ac_ext
3927 cat >>conftest.$ac_ext <<_ACEOF
3928 /* end confdefs.h. */
3929 #include <string.h>
3930
3931 _ACEOF
3932 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
3933 $EGREP "memchr" >/dev/null 2>&1; then
3934 :
3935 else
3936 ac_cv_header_stdc=no
3937 fi
3938 rm -f conftest*
3939
3940 fi
3941
3942 if test $ac_cv_header_stdc = yes; then
3943 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
3944 cat >conftest.$ac_ext <<_ACEOF
3945 /* confdefs.h. */
3946 _ACEOF
3947 cat confdefs.h >>conftest.$ac_ext
3948 cat >>conftest.$ac_ext <<_ACEOF
3949 /* end confdefs.h. */
3950 #include <stdlib.h>
3951
3952 _ACEOF
3953 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
3954 $EGREP "free" >/dev/null 2>&1; then
3955 :
3956 else
3957 ac_cv_header_stdc=no
3958 fi
3959 rm -f conftest*
3960
3961 fi
3962
3963 if test $ac_cv_header_stdc = yes; then
3964 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
3965 if test "$cross_compiling" = yes; then
3966 :
3967 else
3968 cat >conftest.$ac_ext <<_ACEOF
3969 /* confdefs.h. */
3970 _ACEOF
3971 cat confdefs.h >>conftest.$ac_ext
3972 cat >>conftest.$ac_ext <<_ACEOF
3973 /* end confdefs.h. */
3974 #include <ctype.h>
3975 #if ((' ' & 0x0FF) == 0x020)
3976 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
3977 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
3978 #else
3979 # define ISLOWER(c) \
3980 (('a' <= (c) && (c) <= 'i') \
3981 || ('j' <= (c) && (c) <= 'r') \
3982 || ('s' <= (c) && (c) <= 'z'))
3983 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
3984 #endif
3985
3986 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
3987 int
3988 main ()
3989 {
3990 int i;
3991 for (i = 0; i < 256; i++)
3992 if (XOR (islower (i), ISLOWER (i))
3993 || toupper (i) != TOUPPER (i))
3994 exit(2);
3995 exit (0);
3996 }
3997 _ACEOF
3998 rm -f conftest$ac_exeext
3999 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
4000 (eval $ac_link) 2>&5
4001 ac_status=$?
4002 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4003 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
4004 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4005 (eval $ac_try) 2>&5
4006 ac_status=$?
4007 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4008 (exit $ac_status); }; }; then
4009 :
4010 else
4011 echo "$as_me: program exited with status $ac_status" >&5
4012 echo "$as_me: failed program was:" >&5
4013 sed 's/^/| /' conftest.$ac_ext >&5
4014
4015 ( exit $ac_status )
4016 ac_cv_header_stdc=no
4017 fi
4018 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
4019 fi
4020 fi
4021 fi
4022 echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
4023 echo "${ECHO_T}$ac_cv_header_stdc" >&6
4024 if test $ac_cv_header_stdc = yes; then
4025
4026 cat >>confdefs.h <<\_ACEOF
4027 #define STDC_HEADERS 1
4028 _ACEOF
4029
4030 fi
4031
4032 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
4043 inttypes.h stdint.h unistd.h
4044 do
4045 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
4046 echo "$as_me:$LINENO: checking for $ac_header" >&5
4047 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
4048 if eval "test \"\${$as_ac_Header+set}\" = set"; then
4049 echo $ECHO_N "(cached) $ECHO_C" >&6
4050 else
4051 cat >conftest.$ac_ext <<_ACEOF
4052 /* confdefs.h. */
4053 _ACEOF
4054 cat confdefs.h >>conftest.$ac_ext
4055 cat >>conftest.$ac_ext <<_ACEOF
4056 /* end confdefs.h. */
4057 $ac_includes_default
4058
4059 #include <$ac_header>
4060 _ACEOF
4061 rm -f conftest.$ac_objext
4062 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4063 (eval $ac_compile) 2>conftest.er1
4064 ac_status=$?
4065 grep -v '^ *+' conftest.er1 >conftest.err
4066 rm -f conftest.er1
4067 cat conftest.err >&5
4068 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4069 (exit $ac_status); } &&
4070 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4071 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4072 (eval $ac_try) 2>&5
4073 ac_status=$?
4074 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4075 (exit $ac_status); }; } &&
4076 { ac_try='test -s conftest.$ac_objext'
4077 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4078 (eval $ac_try) 2>&5
4079 ac_status=$?
4080 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4081 (exit $ac_status); }; }; then
4082 eval "$as_ac_Header=yes"
4083 else
4084 echo "$as_me: failed program was:" >&5
4085 sed 's/^/| /' conftest.$ac_ext >&5
4086
4087 eval "$as_ac_Header=no"
4088 fi
4089 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4090 fi
4091 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
4092 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
4093 if test `eval echo '${'$as_ac_Header'}'` = yes; then
4094 cat >>confdefs.h <<_ACEOF
4095 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
4096 _ACEOF
4097
4098 fi
4099
4100 done
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113 for ac_header in arpa/inet.h fcntl.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h syslog.h unistd.h iso/limits_iso.h
4114 do
4115 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
4116 if eval "test \"\${$as_ac_Header+set}\" = set"; then
4117 echo "$as_me:$LINENO: checking for $ac_header" >&5
4118 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
4119 if eval "test \"\${$as_ac_Header+set}\" = set"; then
4120 echo $ECHO_N "(cached) $ECHO_C" >&6
4121 fi
4122 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
4123 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
4124 else
4125 # Is the header compilable?
4126 echo "$as_me:$LINENO: checking $ac_header usability" >&5
4127 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
4128 cat >conftest.$ac_ext <<_ACEOF
4129 /* confdefs.h. */
4130 _ACEOF
4131 cat confdefs.h >>conftest.$ac_ext
4132 cat >>conftest.$ac_ext <<_ACEOF
4133 /* end confdefs.h. */
4134 $ac_includes_default
4135 #include <$ac_header>
4136 _ACEOF
4137 rm -f conftest.$ac_objext
4138 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4139 (eval $ac_compile) 2>conftest.er1
4140 ac_status=$?
4141 grep -v '^ *+' conftest.er1 >conftest.err
4142 rm -f conftest.er1
4143 cat conftest.err >&5
4144 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4145 (exit $ac_status); } &&
4146 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4147 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4148 (eval $ac_try) 2>&5
4149 ac_status=$?
4150 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4151 (exit $ac_status); }; } &&
4152 { ac_try='test -s conftest.$ac_objext'
4153 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4154 (eval $ac_try) 2>&5
4155 ac_status=$?
4156 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4157 (exit $ac_status); }; }; then
4158 ac_header_compiler=yes
4159 else
4160 echo "$as_me: failed program was:" >&5
4161 sed 's/^/| /' conftest.$ac_ext >&5
4162
4163 ac_header_compiler=no
4164 fi
4165 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4166 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
4167 echo "${ECHO_T}$ac_header_compiler" >&6
4168
4169 # Is the header present?
4170 echo "$as_me:$LINENO: checking $ac_header presence" >&5
4171 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
4172 cat >conftest.$ac_ext <<_ACEOF
4173 /* confdefs.h. */
4174 _ACEOF
4175 cat confdefs.h >>conftest.$ac_ext
4176 cat >>conftest.$ac_ext <<_ACEOF
4177 /* end confdefs.h. */
4178 #include <$ac_header>
4179 _ACEOF
4180 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
4181 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
4182 ac_status=$?
4183 grep -v '^ *+' conftest.er1 >conftest.err
4184 rm -f conftest.er1
4185 cat conftest.err >&5
4186 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4187 (exit $ac_status); } >/dev/null; then
4188 if test -s conftest.err; then
4189 ac_cpp_err=$ac_c_preproc_warn_flag
4190 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
4191 else
4192 ac_cpp_err=
4193 fi
4194 else
4195 ac_cpp_err=yes
4196 fi
4197 if test -z "$ac_cpp_err"; then
4198 ac_header_preproc=yes
4199 else
4200 echo "$as_me: failed program was:" >&5
4201 sed 's/^/| /' conftest.$ac_ext >&5
4202
4203 ac_header_preproc=no
4204 fi
4205 rm -f conftest.err conftest.$ac_ext
4206 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
4207 echo "${ECHO_T}$ac_header_preproc" >&6
4208
4209 # So? What about this header?
4210 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
4211 yes:no: )
4212 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
4213 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
4214 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
4215 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
4216 ac_header_preproc=yes
4217 ;;
4218 no:yes:* )
4219 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
4220 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
4221 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
4222 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
4223 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
4224 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
4225 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
4226 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
4227 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
4228 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
4229 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
4230 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
4231 (
4232 cat <<\_ASBOX
4233 ## ----------------------------- ##
4234 ## Report this to haag@switch.ch ##
4235 ## ----------------------------- ##
4236 _ASBOX
4237 ) |
4238 sed "s/^/$as_me: WARNING: /" >&2
4239 ;;
4240 esac
4241 echo "$as_me:$LINENO: checking for $ac_header" >&5
4242 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
4243 if eval "test \"\${$as_ac_Header+set}\" = set"; then
4244 echo $ECHO_N "(cached) $ECHO_C" >&6
4245 else
4246 eval "$as_ac_Header=\$ac_header_preproc"
4247 fi
4248 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
4249 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
4250
4251 fi
4252 if test `eval echo '${'$as_ac_Header'}'` = yes; then
4253 cat >>confdefs.h <<_ACEOF
4254 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
4255 _ACEOF
4256
4257 fi
4258
4259 done
4260
4261
4262 # Checks for typedefs, structures, and compiler characteristics.
4263 echo "$as_me:$LINENO: checking for void *" >&5
4264 echo $ECHO_N "checking for void *... $ECHO_C" >&6
4265 if test "${ac_cv_type_void_p+set}" = set; then
4266 echo $ECHO_N "(cached) $ECHO_C" >&6
4267 else
4268 cat >conftest.$ac_ext <<_ACEOF
4269 /* confdefs.h. */
4270 _ACEOF
4271 cat confdefs.h >>conftest.$ac_ext
4272 cat >>conftest.$ac_ext <<_ACEOF
4273 /* end confdefs.h. */
4274 $ac_includes_default
4275 int
4276 main ()
4277 {
4278 if ((void * *) 0)
4279 return 0;
4280 if (sizeof (void *))
4281 return 0;
4282 ;
4283 return 0;
4284 }
4285 _ACEOF
4286 rm -f conftest.$ac_objext
4287 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4288 (eval $ac_compile) 2>conftest.er1
4289 ac_status=$?
4290 grep -v '^ *+' conftest.er1 >conftest.err
4291 rm -f conftest.er1
4292 cat conftest.err >&5
4293 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4294 (exit $ac_status); } &&
4295 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4296 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4297 (eval $ac_try) 2>&5
4298 ac_status=$?
4299 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4300 (exit $ac_status); }; } &&
4301 { ac_try='test -s conftest.$ac_objext'
4302 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4303 (eval $ac_try) 2>&5
4304 ac_status=$?
4305 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4306 (exit $ac_status); }; }; then
4307 ac_cv_type_void_p=yes
4308 else
4309 echo "$as_me: failed program was:" >&5
4310 sed 's/^/| /' conftest.$ac_ext >&5
4311
4312 ac_cv_type_void_p=no
4313 fi
4314 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4315 fi
4316 echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5
4317 echo "${ECHO_T}$ac_cv_type_void_p" >&6
4318
4319 echo "$as_me:$LINENO: checking size of void *" >&5
4320 echo $ECHO_N "checking size of void *... $ECHO_C" >&6
4321 if test "${ac_cv_sizeof_void_p+set}" = set; then
4322 echo $ECHO_N "(cached) $ECHO_C" >&6
4323 else
4324 if test "$ac_cv_type_void_p" = yes; then
4325 # The cast to unsigned long works around a bug in the HP C Compiler
4326 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
4327 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
4328 # This bug is HP SR number 8606223364.
4329 if test "$cross_compiling" = yes; then
4330 # Depending upon the size, compute the lo and hi bounds.
4331 cat >conftest.$ac_ext <<_ACEOF
4332 /* confdefs.h. */
4333 _ACEOF
4334 cat confdefs.h >>conftest.$ac_ext
4335 cat >>conftest.$ac_ext <<_ACEOF
4336 /* end confdefs.h. */
4337 $ac_includes_default
4338 int
4339 main ()
4340 {
4341 static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= 0)];
4342 test_array [0] = 0
4343
4344 ;
4345 return 0;
4346 }
4347 _ACEOF
4348 rm -f conftest.$ac_objext
4349 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4350 (eval $ac_compile) 2>conftest.er1
4351 ac_status=$?
4352 grep -v '^ *+' conftest.er1 >conftest.err
4353 rm -f conftest.er1
4354 cat conftest.err >&5
4355 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4356 (exit $ac_status); } &&
4357 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4358 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4359 (eval $ac_try) 2>&5
4360 ac_status=$?
4361 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4362 (exit $ac_status); }; } &&
4363 { ac_try='test -s conftest.$ac_objext'
4364 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4365 (eval $ac_try) 2>&5
4366 ac_status=$?
4367 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4368 (exit $ac_status); }; }; then
4369 ac_lo=0 ac_mid=0
4370 while :; do
4371 cat >conftest.$ac_ext <<_ACEOF
4372 /* confdefs.h. */
4373 _ACEOF
4374 cat confdefs.h >>conftest.$ac_ext
4375 cat >>conftest.$ac_ext <<_ACEOF
4376 /* end confdefs.h. */
4377 $ac_includes_default
4378 int
4379 main ()
4380 {
4381 static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)];
4382 test_array [0] = 0
4383
4384 ;
4385 return 0;
4386 }
4387 _ACEOF
4388 rm -f conftest.$ac_objext
4389 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4390 (eval $ac_compile) 2>conftest.er1
4391 ac_status=$?
4392 grep -v '^ *+' conftest.er1 >conftest.err
4393 rm -f conftest.er1
4394 cat conftest.err >&5
4395 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4396 (exit $ac_status); } &&
4397 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4398 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4399 (eval $ac_try) 2>&5
4400 ac_status=$?
4401 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4402 (exit $ac_status); }; } &&
4403 { ac_try='test -s conftest.$ac_objext'
4404 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4405 (eval $ac_try) 2>&5
4406 ac_status=$?
4407 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4408 (exit $ac_status); }; }; then
4409 ac_hi=$ac_mid; break
4410 else
4411 echo "$as_me: failed program was:" >&5
4412 sed 's/^/| /' conftest.$ac_ext >&5
4413
4414 ac_lo=`expr $ac_mid + 1`
4415 if test $ac_lo -le $ac_mid; then
4416 ac_lo= ac_hi=
4417 break
4418 fi
4419 ac_mid=`expr 2 '*' $ac_mid + 1`
4420 fi
4421 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4422 done
4423 else
4424 echo "$as_me: failed program was:" >&5
4425 sed 's/^/| /' conftest.$ac_ext >&5
4426
4427 cat >conftest.$ac_ext <<_ACEOF
4428 /* confdefs.h. */
4429 _ACEOF
4430 cat confdefs.h >>conftest.$ac_ext
4431 cat >>conftest.$ac_ext <<_ACEOF
4432 /* end confdefs.h. */
4433 $ac_includes_default
4434 int
4435 main ()
4436 {
4437 static int test_array [1 - 2 * !(((long) (sizeof (void *))) < 0)];
4438 test_array [0] = 0
4439
4440 ;
4441 return 0;
4442 }
4443 _ACEOF
4444 rm -f conftest.$ac_objext
4445 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4446 (eval $ac_compile) 2>conftest.er1
4447 ac_status=$?
4448 grep -v '^ *+' conftest.er1 >conftest.err
4449 rm -f conftest.er1
4450 cat conftest.err >&5
4451 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4452 (exit $ac_status); } &&
4453 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4454 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4455 (eval $ac_try) 2>&5
4456 ac_status=$?
4457 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4458 (exit $ac_status); }; } &&
4459 { ac_try='test -s conftest.$ac_objext'
4460 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4461 (eval $ac_try) 2>&5
4462 ac_status=$?
4463 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4464 (exit $ac_status); }; }; then
4465 ac_hi=-1 ac_mid=-1
4466 while :; do
4467 cat >conftest.$ac_ext <<_ACEOF
4468 /* confdefs.h. */
4469 _ACEOF
4470 cat confdefs.h >>conftest.$ac_ext
4471 cat >>conftest.$ac_ext <<_ACEOF
4472 /* end confdefs.h. */
4473 $ac_includes_default
4474 int
4475 main ()
4476 {
4477 static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= $ac_mid)];
4478 test_array [0] = 0
4479
4480 ;
4481 return 0;
4482 }
4483 _ACEOF
4484 rm -f conftest.$ac_objext
4485 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4486 (eval $ac_compile) 2>conftest.er1
4487 ac_status=$?
4488 grep -v '^ *+' conftest.er1 >conftest.err
4489 rm -f conftest.er1
4490 cat conftest.err >&5
4491 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4492 (exit $ac_status); } &&
4493 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4494 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4495 (eval $ac_try) 2>&5
4496 ac_status=$?
4497 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4498 (exit $ac_status); }; } &&
4499 { ac_try='test -s conftest.$ac_objext'
4500 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4501 (eval $ac_try) 2>&5
4502 ac_status=$?
4503 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4504 (exit $ac_status); }; }; then
4505 ac_lo=$ac_mid; break
4506 else
4507 echo "$as_me: failed program was:" >&5
4508 sed 's/^/| /' conftest.$ac_ext >&5
4509
4510 ac_hi=`expr '(' $ac_mid ')' - 1`
4511 if test $ac_mid -le $ac_hi; then
4512 ac_lo= ac_hi=
4513 break
4514 fi
4515 ac_mid=`expr 2 '*' $ac_mid`
4516 fi
4517 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4518 done
4519 else
4520 echo "$as_me: failed program was:" >&5
4521 sed 's/^/| /' conftest.$ac_ext >&5
4522
4523 ac_lo= ac_hi=
4524 fi
4525 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4526 fi
4527 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4528 # Binary search between lo and hi bounds.
4529 while test "x$ac_lo" != "x$ac_hi"; do
4530 ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
4531 cat >conftest.$ac_ext <<_ACEOF
4532 /* confdefs.h. */
4533 _ACEOF
4534 cat confdefs.h >>conftest.$ac_ext
4535 cat >>conftest.$ac_ext <<_ACEOF
4536 /* end confdefs.h. */
4537 $ac_includes_default
4538 int
4539 main ()
4540 {
4541 static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)];
4542 test_array [0] = 0
4543
4544 ;
4545 return 0;
4546 }
4547 _ACEOF
4548 rm -f conftest.$ac_objext
4549 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4550 (eval $ac_compile) 2>conftest.er1
4551 ac_status=$?
4552 grep -v '^ *+' conftest.er1 >conftest.err
4553 rm -f conftest.er1
4554 cat conftest.err >&5
4555 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4556 (exit $ac_status); } &&
4557 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4558 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4559 (eval $ac_try) 2>&5
4560 ac_status=$?
4561 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4562 (exit $ac_status); }; } &&
4563 { ac_try='test -s conftest.$ac_objext'
4564 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4565 (eval $ac_try) 2>&5
4566 ac_status=$?
4567 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4568 (exit $ac_status); }; }; then
4569 ac_hi=$ac_mid
4570 else
4571 echo "$as_me: failed program was:" >&5
4572 sed 's/^/| /' conftest.$ac_ext >&5
4573
4574 ac_lo=`expr '(' $ac_mid ')' + 1`
4575 fi
4576 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4577 done
4578 case $ac_lo in
4579 ?*) ac_cv_sizeof_void_p=$ac_lo;;
4580 '') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77
4581 See \`config.log' for more details." >&5
4582 echo "$as_me: error: cannot compute sizeof (void *), 77
4583 See \`config.log' for more details." >&2;}
4584 { (exit 1); exit 1; }; } ;;
4585 esac
4586 else
4587 if test "$cross_compiling" = yes; then
4588 { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
4589 echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
4590 { (exit 1); exit 1; }; }
4591 else
4592 cat >conftest.$ac_ext <<_ACEOF
4593 /* confdefs.h. */
4594 _ACEOF
4595 cat confdefs.h >>conftest.$ac_ext
4596 cat >>conftest.$ac_ext <<_ACEOF
4597 /* end confdefs.h. */
4598 $ac_includes_default
4599 long longval () { return (long) (sizeof (void *)); }
4600 unsigned long ulongval () { return (long) (sizeof (void *)); }
4601 #include <stdio.h>
4602 #include <stdlib.h>
4603 int
4604 main ()
4605 {
4606
4607 FILE *f = fopen ("conftest.val", "w");
4608 if (! f)
4609 exit (1);
4610 if (((long) (sizeof (void *))) < 0)
4611 {
4612 long i = longval ();
4613 if (i != ((long) (sizeof (void *))))
4614 exit (1);
4615 fprintf (f, "%ld\n", i);
4616 }
4617 else
4618 {
4619 unsigned long i = ulongval ();
4620 if (i != ((long) (sizeof (void *))))
4621 exit (1);
4622 fprintf (f, "%lu\n", i);
4623 }
4624 exit (ferror (f) || fclose (f) != 0);
4625
4626 ;
4627 return 0;
4628 }
4629 _ACEOF
4630 rm -f conftest$ac_exeext
4631 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
4632 (eval $ac_link) 2>&5
4633 ac_status=$?
4634 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4635 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
4636 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4637 (eval $ac_try) 2>&5
4638 ac_status=$?
4639 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4640 (exit $ac_status); }; }; then
4641 ac_cv_sizeof_void_p=`cat conftest.val`
4642 else
4643 echo "$as_me: program exited with status $ac_status" >&5
4644 echo "$as_me: failed program was:" >&5
4645 sed 's/^/| /' conftest.$ac_ext >&5
4646
4647 ( exit $ac_status )
4648 { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77
4649 See \`config.log' for more details." >&5
4650 echo "$as_me: error: cannot compute sizeof (void *), 77
4651 See \`config.log' for more details." >&2;}
4652 { (exit 1); exit 1; }; }
4653 fi
4654 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
4655 fi
4656 fi
4657 rm -f conftest.val
4658 else
4659 ac_cv_sizeof_void_p=0
4660 fi
4661 fi
4662 echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5
4663 echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6
4664 cat >>confdefs.h <<_ACEOF
4665 #define SIZEOF_VOID_P $ac_cv_sizeof_void_p
4666 _ACEOF
4667
4668
4669
4670 echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
4671 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
4672 if test "${ac_cv_c_const+set}" = set; then
4673 echo $ECHO_N "(cached) $ECHO_C" >&6
4674 else
4675 cat >conftest.$ac_ext <<_ACEOF
4676 /* confdefs.h. */
4677 _ACEOF
4678 cat confdefs.h >>conftest.$ac_ext
4679 cat >>conftest.$ac_ext <<_ACEOF
4680 /* end confdefs.h. */
4681
4682 int
4683 main ()
4684 {
4685 /* FIXME: Include the comments suggested by Paul. */
4686 #ifndef __cplusplus
4687 /* Ultrix mips cc rejects this. */
4688 typedef int charset[2];
4689 const charset x;
4690 /* SunOS 4.1.1 cc rejects this. */
4691 char const *const *ccp;
4692 char **p;
4693 /* NEC SVR4.0.2 mips cc rejects this. */
4694 struct point {int x, y;};
4695 static struct point const zero = {0,0};
4696 /* AIX XL C 1.02.0.0 rejects this.
4697 It does not let you subtract one const X* pointer from another in
4698 an arm of an if-expression whose if-part is not a constant
4699 expression */
4700 const char *g = "string";
4701 ccp = &g + (g ? g-g : 0);
4702 /* HPUX 7.0 cc rejects these. */
4703 ++ccp;
4704 p = (char**) ccp;
4705 ccp = (char const *const *) p;
4706 { /* SCO 3.2v4 cc rejects this. */
4707 char *t;
4708 char const *s = 0 ? (char *) 0 : (char const *) 0;
4709
4710 *t++ = 0;
4711 }
4712 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
4713 int x[] = {25, 17};
4714 const int *foo = &x[0];
4715 ++foo;
4716 }
4717 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
4718 typedef const int *iptr;
4719 iptr p = 0;
4720 ++p;
4721 }
4722 { /* AIX XL C 1.02.0.0 rejects this saying
4723 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
4724 struct s { int j; const int *ap[3]; };
4725 struct s *b; b->j = 5;
4726 }
4727 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
4728 const int foo = 10;
4729 }
4730 #endif
4731
4732 ;
4733 return 0;
4734 }
4735 _ACEOF
4736 rm -f conftest.$ac_objext
4737 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4738 (eval $ac_compile) 2>conftest.er1
4739 ac_status=$?
4740 grep -v '^ *+' conftest.er1 >conftest.err
4741 rm -f conftest.er1
4742 cat conftest.err >&5
4743 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4744 (exit $ac_status); } &&
4745 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4746 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4747 (eval $ac_try) 2>&5
4748 ac_status=$?
4749 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4750 (exit $ac_status); }; } &&
4751 { ac_try='test -s conftest.$ac_objext'
4752 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4753 (eval $ac_try) 2>&5
4754 ac_status=$?
4755 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4756 (exit $ac_status); }; }; then
4757 ac_cv_c_const=yes
4758 else
4759 echo "$as_me: failed program was:" >&5
4760 sed 's/^/| /' conftest.$ac_ext >&5
4761
4762 ac_cv_c_const=no
4763 fi
4764 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4765 fi
4766 echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
4767 echo "${ECHO_T}$ac_cv_c_const" >&6
4768 if test $ac_cv_c_const = no; then
4769
4770 cat >>confdefs.h <<\_ACEOF
4771 #define const
4772 _ACEOF
4773
4774 fi
4775
4776 echo "$as_me:$LINENO: checking for inline" >&5
4777 echo $ECHO_N "checking for inline... $ECHO_C" >&6
4778 if test "${ac_cv_c_inline+set}" = set; then
4779 echo $ECHO_N "(cached) $ECHO_C" >&6
4780 else
4781 ac_cv_c_inline=no
4782 for ac_kw in inline __inline__ __inline; do
4783 cat >conftest.$ac_ext <<_ACEOF
4784 /* confdefs.h. */
4785 _ACEOF
4786 cat confdefs.h >>conftest.$ac_ext
4787 cat >>conftest.$ac_ext <<_ACEOF
4788 /* end confdefs.h. */
4789 #ifndef __cplusplus
4790 typedef int foo_t;
4791 static $ac_kw foo_t static_foo () {return 0; }
4792 $ac_kw foo_t foo () {return 0; }
4793 #endif
4794
4795 _ACEOF
4796 rm -f conftest.$ac_objext
4797 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4798 (eval $ac_compile) 2>conftest.er1
4799 ac_status=$?
4800 grep -v '^ *+' conftest.er1 >conftest.err
4801 rm -f conftest.er1
4802 cat conftest.err >&5
4803 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4804 (exit $ac_status); } &&
4805 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4806 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4807 (eval $ac_try) 2>&5
4808 ac_status=$?
4809 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4810 (exit $ac_status); }; } &&
4811 { ac_try='test -s conftest.$ac_objext'
4812 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4813 (eval $ac_try) 2>&5
4814 ac_status=$?
4815 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4816 (exit $ac_status); }; }; then
4817 ac_cv_c_inline=$ac_kw; break
4818 else
4819 echo "$as_me: failed program was:" >&5
4820 sed 's/^/| /' conftest.$ac_ext >&5
4821
4822 fi
4823 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4824 done
4825
4826 fi
4827 echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
4828 echo "${ECHO_T}$ac_cv_c_inline" >&6
4829
4830
4831 case $ac_cv_c_inline in
4832 inline | yes) ;;
4833 *)
4834 case $ac_cv_c_inline in
4835 no) ac_val=;;
4836 *) ac_val=$ac_cv_c_inline;;
4837 esac
4838 cat >>confdefs.h <<_ACEOF
4839 #ifndef __cplusplus
4840 #define inline $ac_val
4841 #endif
4842 _ACEOF
4843 ;;
4844 esac
4845
4846 echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
4847 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
4848 if test "${ac_cv_c_bigendian+set}" = set; then
4849 echo $ECHO_N "(cached) $ECHO_C" >&6
4850 else
4851 # See if sys/param.h defines the BYTE_ORDER macro.
4852 cat >conftest.$ac_ext <<_ACEOF
4853 /* confdefs.h. */
4854 _ACEOF
4855 cat confdefs.h >>conftest.$ac_ext
4856 cat >>conftest.$ac_ext <<_ACEOF
4857 /* end confdefs.h. */
4858 #include <sys/types.h>
4859 #include <sys/param.h>
4860
4861 int
4862 main ()
4863 {
4864 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
4865 bogus endian macros
4866 #endif
4867
4868 ;
4869 return 0;
4870 }
4871 _ACEOF
4872 rm -f conftest.$ac_objext
4873 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4874 (eval $ac_compile) 2>conftest.er1
4875 ac_status=$?
4876 grep -v '^ *+' conftest.er1 >conftest.err
4877 rm -f conftest.er1
4878 cat conftest.err >&5
4879 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4880 (exit $ac_status); } &&
4881 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4882 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4883 (eval $ac_try) 2>&5
4884 ac_status=$?
4885 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4886 (exit $ac_status); }; } &&
4887 { ac_try='test -s conftest.$ac_objext'
4888 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4889 (eval $ac_try) 2>&5
4890 ac_status=$?
4891 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4892 (exit $ac_status); }; }; then
4893 # It does; now see whether it defined to BIG_ENDIAN or not.
4894 cat >conftest.$ac_ext <<_ACEOF
4895 /* confdefs.h. */
4896 _ACEOF
4897 cat confdefs.h >>conftest.$ac_ext
4898 cat >>conftest.$ac_ext <<_ACEOF
4899 /* end confdefs.h. */
4900 #include <sys/types.h>
4901 #include <sys/param.h>
4902
4903 int
4904 main ()
4905 {
4906 #if BYTE_ORDER != BIG_ENDIAN
4907 not big endian
4908 #endif
4909
4910 ;
4911 return 0;
4912 }
4913 _ACEOF
4914 rm -f conftest.$ac_objext
4915 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4916 (eval $ac_compile) 2>conftest.er1
4917 ac_status=$?
4918 grep -v '^ *+' conftest.er1 >conftest.err
4919 rm -f conftest.er1
4920 cat conftest.err >&5
4921 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4922 (exit $ac_status); } &&
4923 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4924 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4925 (eval $ac_try) 2>&5
4926 ac_status=$?
4927 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4928 (exit $ac_status); }; } &&
4929 { ac_try='test -s conftest.$ac_objext'
4930 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4931 (eval $ac_try) 2>&5
4932 ac_status=$?
4933 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4934 (exit $ac_status); }; }; then
4935 ac_cv_c_bigendian=yes
4936 else
4937 echo "$as_me: failed program was:" >&5
4938 sed 's/^/| /' conftest.$ac_ext >&5
4939
4940 ac_cv_c_bigendian=no
4941 fi
4942 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
4943 else
4944 echo "$as_me: failed program was:" >&5
4945 sed 's/^/| /' conftest.$ac_ext >&5
4946
4947 # It does not; compile a test program.
4948 if test "$cross_compiling" = yes; then
4949 # try to guess the endianness by grepping values into an object file
4950 ac_cv_c_bigendian=unknown
4951 cat >conftest.$ac_ext <<_ACEOF
4952 /* confdefs.h. */
4953 _ACEOF
4954 cat confdefs.h >>conftest.$ac_ext
4955 cat >>conftest.$ac_ext <<_ACEOF
4956 /* end confdefs.h. */
4957 short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
4958 short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
4959 void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
4960 short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
4961 short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
4962 void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
4963 int
4964 main ()
4965 {
4966 _ascii (); _ebcdic ();
4967 ;
4968 return 0;
4969 }
4970 _ACEOF
4971 rm -f conftest.$ac_objext
4972 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
4973 (eval $ac_compile) 2>conftest.er1
4974 ac_status=$?
4975 grep -v '^ *+' conftest.er1 >conftest.err
4976 rm -f conftest.er1
4977 cat conftest.err >&5
4978 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4979 (exit $ac_status); } &&
4980 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
4981 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4982 (eval $ac_try) 2>&5
4983 ac_status=$?
4984 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4985 (exit $ac_status); }; } &&
4986 { ac_try='test -s conftest.$ac_objext'
4987 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
4988 (eval $ac_try) 2>&5
4989 ac_status=$?
4990 echo "$as_me:$LINENO: \$? = $ac_status" >&5
4991 (exit $ac_status); }; }; then
4992 if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
4993 ac_cv_c_bigendian=yes
4994 fi
4995 if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
4996 if test "$ac_cv_c_bigendian" = unknown; then
4997 ac_cv_c_bigendian=no
4998 else
4999 # finding both strings is unlikely to happen, but who knows?
5000 ac_cv_c_bigendian=unknown
5001 fi
5002 fi
5003 else
5004 echo "$as_me: failed program was:" >&5
5005 sed 's/^/| /' conftest.$ac_ext >&5
5006
5007 fi
5008 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5009 else
5010 cat >conftest.$ac_ext <<_ACEOF
5011 /* confdefs.h. */
5012 _ACEOF
5013 cat confdefs.h >>conftest.$ac_ext
5014 cat >>conftest.$ac_ext <<_ACEOF
5015 /* end confdefs.h. */
5016 int
5017 main ()
5018 {
5019 /* Are we little or big endian? From Harbison&Steele. */
5020 union
5021 {
5022 long l;
5023 char c[sizeof (long)];
5024 } u;
5025 u.l = 1;
5026 exit (u.c[sizeof (long) - 1] == 1);
5027 }
5028 _ACEOF
5029 rm -f conftest$ac_exeext
5030 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5031 (eval $ac_link) 2>&5
5032 ac_status=$?
5033 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5034 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
5035 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5036 (eval $ac_try) 2>&5
5037 ac_status=$?
5038 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5039 (exit $ac_status); }; }; then
5040 ac_cv_c_bigendian=no
5041 else
5042 echo "$as_me: program exited with status $ac_status" >&5
5043 echo "$as_me: failed program was:" >&5
5044 sed 's/^/| /' conftest.$ac_ext >&5
5045
5046 ( exit $ac_status )
5047 ac_cv_c_bigendian=yes
5048 fi
5049 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
5050 fi
5051 fi
5052 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5053 fi
5054 echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
5055 echo "${ECHO_T}$ac_cv_c_bigendian" >&6
5056 case $ac_cv_c_bigendian in
5057 yes)
5058
5059 cat >>confdefs.h <<\_ACEOF
5060 #define WORDS_BIGENDIAN 1
5061 _ACEOF
5062 ;;
5063 no)
5064 ;;
5065 *)
5066 { { echo "$as_me:$LINENO: error: unknown endianness
5067 presetting ac_cv_c_bigendian=no (or yes) will help" >&5
5068 echo "$as_me: error: unknown endianness
5069 presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
5070 { (exit 1); exit 1; }; } ;;
5071 esac
5072
5073 echo "$as_me:$LINENO: checking for pid_t" >&5
5074 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
5075 if test "${ac_cv_type_pid_t+set}" = set; then
5076 echo $ECHO_N "(cached) $ECHO_C" >&6
5077 else
5078 cat >conftest.$ac_ext <<_ACEOF
5079 /* confdefs.h. */
5080 _ACEOF
5081 cat confdefs.h >>conftest.$ac_ext
5082 cat >>conftest.$ac_ext <<_ACEOF
5083 /* end confdefs.h. */
5084 $ac_includes_default
5085 int
5086 main ()
5087 {
5088 if ((pid_t *) 0)
5089 return 0;
5090 if (sizeof (pid_t))
5091 return 0;
5092 ;
5093 return 0;
5094 }
5095 _ACEOF
5096 rm -f conftest.$ac_objext
5097 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5098 (eval $ac_compile) 2>conftest.er1
5099 ac_status=$?
5100 grep -v '^ *+' conftest.er1 >conftest.err
5101 rm -f conftest.er1
5102 cat conftest.err >&5
5103 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5104 (exit $ac_status); } &&
5105 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5106 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5107 (eval $ac_try) 2>&5
5108 ac_status=$?
5109 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5110 (exit $ac_status); }; } &&
5111 { ac_try='test -s conftest.$ac_objext'
5112 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5113 (eval $ac_try) 2>&5
5114 ac_status=$?
5115 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5116 (exit $ac_status); }; }; then
5117 ac_cv_type_pid_t=yes
5118 else
5119 echo "$as_me: failed program was:" >&5
5120 sed 's/^/| /' conftest.$ac_ext >&5
5121
5122 ac_cv_type_pid_t=no
5123 fi
5124 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5125 fi
5126 echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
5127 echo "${ECHO_T}$ac_cv_type_pid_t" >&6
5128 if test $ac_cv_type_pid_t = yes; then
5129 :
5130 else
5131
5132 cat >>confdefs.h <<_ACEOF
5133 #define pid_t int
5134 _ACEOF
5135
5136 fi
5137
5138 echo "$as_me:$LINENO: checking for size_t" >&5
5139 echo $ECHO_N "checking for size_t... $ECHO_C" >&6
5140 if test "${ac_cv_type_size_t+set}" = set; then
5141 echo $ECHO_N "(cached) $ECHO_C" >&6
5142 else
5143 cat >conftest.$ac_ext <<_ACEOF
5144 /* confdefs.h. */
5145 _ACEOF
5146 cat confdefs.h >>conftest.$ac_ext
5147 cat >>conftest.$ac_ext <<_ACEOF
5148 /* end confdefs.h. */
5149 $ac_includes_default
5150 int
5151 main ()
5152 {
5153 if ((size_t *) 0)
5154 return 0;
5155 if (sizeof (size_t))
5156 return 0;
5157 ;
5158 return 0;
5159 }
5160 _ACEOF
5161 rm -f conftest.$ac_objext
5162 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5163 (eval $ac_compile) 2>conftest.er1
5164 ac_status=$?
5165 grep -v '^ *+' conftest.er1 >conftest.err
5166 rm -f conftest.er1
5167 cat conftest.err >&5
5168 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5169 (exit $ac_status); } &&
5170 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5171 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5172 (eval $ac_try) 2>&5
5173 ac_status=$?
5174 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5175 (exit $ac_status); }; } &&
5176 { ac_try='test -s conftest.$ac_objext'
5177 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5178 (eval $ac_try) 2>&5
5179 ac_status=$?
5180 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5181 (exit $ac_status); }; }; then
5182 ac_cv_type_size_t=yes
5183 else
5184 echo "$as_me: failed program was:" >&5
5185 sed 's/^/| /' conftest.$ac_ext >&5
5186
5187 ac_cv_type_size_t=no
5188 fi
5189 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5190 fi
5191 echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
5192 echo "${ECHO_T}$ac_cv_type_size_t" >&6
5193 if test $ac_cv_type_size_t = yes; then
5194 :
5195 else
5196
5197 cat >>confdefs.h <<_ACEOF
5198 #define size_t unsigned
5199 _ACEOF
5200
5201 fi
5202
5203 echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
5204 echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6
5205 if test "${ac_cv_struct_tm+set}" = set; then
5206 echo $ECHO_N "(cached) $ECHO_C" >&6
5207 else
5208 cat >conftest.$ac_ext <<_ACEOF
5209 /* confdefs.h. */
5210 _ACEOF
5211 cat confdefs.h >>conftest.$ac_ext
5212 cat >>conftest.$ac_ext <<_ACEOF
5213 /* end confdefs.h. */
5214 #include <sys/types.h>
5215 #include <time.h>
5216
5217 int
5218 main ()
5219 {
5220 struct tm *tp; tp->tm_sec;
5221 ;
5222 return 0;
5223 }
5224 _ACEOF
5225 rm -f conftest.$ac_objext
5226 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5227 (eval $ac_compile) 2>conftest.er1
5228 ac_status=$?
5229 grep -v '^ *+' conftest.er1 >conftest.err
5230 rm -f conftest.er1
5231 cat conftest.err >&5
5232 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5233 (exit $ac_status); } &&
5234 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5235 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5236 (eval $ac_try) 2>&5
5237 ac_status=$?
5238 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5239 (exit $ac_status); }; } &&
5240 { ac_try='test -s conftest.$ac_objext'
5241 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5242 (eval $ac_try) 2>&5
5243 ac_status=$?
5244 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5245 (exit $ac_status); }; }; then
5246 ac_cv_struct_tm=time.h
5247 else
5248 echo "$as_me: failed program was:" >&5
5249 sed 's/^/| /' conftest.$ac_ext >&5
5250
5251 ac_cv_struct_tm=sys/time.h
5252 fi
5253 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5254 fi
5255 echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
5256 echo "${ECHO_T}$ac_cv_struct_tm" >&6
5257 if test $ac_cv_struct_tm = sys/time.h; then
5258
5259 cat >>confdefs.h <<\_ACEOF
5260 #define TM_IN_SYS_TIME 1
5261 _ACEOF
5262
5263 fi
5264
5265 echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
5266 echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6
5267 if test "${ac_cv_header_stdbool_h+set}" = set; then
5268 echo $ECHO_N "(cached) $ECHO_C" >&6
5269 else
5270 cat >conftest.$ac_ext <<_ACEOF
5271 /* confdefs.h. */
5272 _ACEOF
5273 cat confdefs.h >>conftest.$ac_ext
5274 cat >>conftest.$ac_ext <<_ACEOF
5275 /* end confdefs.h. */
5276
5277 #include <stdbool.h>
5278 #ifndef bool
5279 # error bool is not defined
5280 #endif
5281 #ifndef false
5282 # error false is not defined
5283 #endif
5284 #if false
5285 # error false is not 0
5286 #endif
5287 #ifndef true
5288 # error true is not defined
5289 #endif
5290 #if true != 1
5291 # error true is not 1
5292 #endif
5293 #ifndef __bool_true_false_are_defined
5294 # error __bool_true_false_are_defined is not defined
5295 #endif
5296
5297 struct s { _Bool s: 1; _Bool t; } s;
5298
5299 char a[true == 1 ? 1 : -1];
5300 char b[false == 0 ? 1 : -1];
5301 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
5302 char d[(bool) -0.5 == true ? 1 : -1];
5303 bool e = &s;
5304 char f[(_Bool) -0.0 == false ? 1 : -1];
5305 char g[true];
5306 char h[sizeof (_Bool)];
5307 char i[sizeof s.t];
5308
5309 int
5310 main ()
5311 {
5312 return !a + !b + !c + !d + !e + !f + !g + !h + !i;
5313 ;
5314 return 0;
5315 }
5316 _ACEOF
5317 rm -f conftest.$ac_objext
5318 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5319 (eval $ac_compile) 2>conftest.er1
5320 ac_status=$?
5321 grep -v '^ *+' conftest.er1 >conftest.err
5322 rm -f conftest.er1
5323 cat conftest.err >&5
5324 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5325 (exit $ac_status); } &&
5326 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5327 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5328 (eval $ac_try) 2>&5
5329 ac_status=$?
5330 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5331 (exit $ac_status); }; } &&
5332 { ac_try='test -s conftest.$ac_objext'
5333 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5334 (eval $ac_try) 2>&5
5335 ac_status=$?
5336 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5337 (exit $ac_status); }; }; then
5338 ac_cv_header_stdbool_h=yes
5339 else
5340 echo "$as_me: failed program was:" >&5
5341 sed 's/^/| /' conftest.$ac_ext >&5
5342
5343 ac_cv_header_stdbool_h=no
5344 fi
5345 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5346 fi
5347 echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
5348 echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6
5349 echo "$as_me:$LINENO: checking for _Bool" >&5
5350 echo $ECHO_N "checking for _Bool... $ECHO_C" >&6
5351 if test "${ac_cv_type__Bool+set}" = set; then
5352 echo $ECHO_N "(cached) $ECHO_C" >&6
5353 else
5354 cat >conftest.$ac_ext <<_ACEOF
5355 /* confdefs.h. */
5356 _ACEOF
5357 cat confdefs.h >>conftest.$ac_ext
5358 cat >>conftest.$ac_ext <<_ACEOF
5359 /* end confdefs.h. */
5360 $ac_includes_default
5361 int
5362 main ()
5363 {
5364 if ((_Bool *) 0)
5365 return 0;
5366 if (sizeof (_Bool))
5367 return 0;
5368 ;
5369 return 0;
5370 }
5371 _ACEOF
5372 rm -f conftest.$ac_objext
5373 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5374 (eval $ac_compile) 2>conftest.er1
5375 ac_status=$?
5376 grep -v '^ *+' conftest.er1 >conftest.err
5377 rm -f conftest.er1
5378 cat conftest.err >&5
5379 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5380 (exit $ac_status); } &&
5381 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5382 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5383 (eval $ac_try) 2>&5
5384 ac_status=$?
5385 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5386 (exit $ac_status); }; } &&
5387 { ac_try='test -s conftest.$ac_objext'
5388 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5389 (eval $ac_try) 2>&5
5390 ac_status=$?
5391 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5392 (exit $ac_status); }; }; then
5393 ac_cv_type__Bool=yes
5394 else
5395 echo "$as_me: failed program was:" >&5
5396 sed 's/^/| /' conftest.$ac_ext >&5
5397
5398 ac_cv_type__Bool=no
5399 fi
5400 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5401 fi
5402 echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
5403 echo "${ECHO_T}$ac_cv_type__Bool" >&6
5404 if test $ac_cv_type__Bool = yes; then
5405
5406 cat >>confdefs.h <<_ACEOF
5407 #define HAVE__BOOL 1
5408 _ACEOF
5409
5410
5411 fi
5412
5413 if test $ac_cv_header_stdbool_h = yes; then
5414
5415 cat >>confdefs.h <<\_ACEOF
5416 #define HAVE_STDBOOL_H 1
5417 _ACEOF
5418
5419 fi
5420
5421
5422 # Checks for library functions.
5423 echo "$as_me:$LINENO: checking whether closedir returns void" >&5
5424 echo $ECHO_N "checking whether closedir returns void... $ECHO_C" >&6
5425 if test "${ac_cv_func_closedir_void+set}" = set; then
5426 echo $ECHO_N "(cached) $ECHO_C" >&6
5427 else
5428 if test "$cross_compiling" = yes; then
5429 ac_cv_func_closedir_void=yes
5430 else
5431 cat >conftest.$ac_ext <<_ACEOF
5432 /* confdefs.h. */
5433 _ACEOF
5434 cat confdefs.h >>conftest.$ac_ext
5435 cat >>conftest.$ac_ext <<_ACEOF
5436 /* end confdefs.h. */
5437 $ac_includes_default
5438 #include <$ac_header_dirent>
5439 #ifndef __cplusplus
5440 int closedir ();
5441 #endif
5442
5443 int
5444 main ()
5445 {
5446 exit (closedir (opendir (".")) != 0);
5447 ;
5448 return 0;
5449 }
5450 _ACEOF
5451 rm -f conftest$ac_exeext
5452 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5453 (eval $ac_link) 2>&5
5454 ac_status=$?
5455 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5456 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
5457 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5458 (eval $ac_try) 2>&5
5459 ac_status=$?
5460 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5461 (exit $ac_status); }; }; then
5462 ac_cv_func_closedir_void=no
5463 else
5464 echo "$as_me: program exited with status $ac_status" >&5
5465 echo "$as_me: failed program was:" >&5
5466 sed 's/^/| /' conftest.$ac_ext >&5
5467
5468 ( exit $ac_status )
5469 ac_cv_func_closedir_void=yes
5470 fi
5471 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
5472 fi
5473 fi
5474 echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5
5475 echo "${ECHO_T}$ac_cv_func_closedir_void" >&6
5476 if test $ac_cv_func_closedir_void = yes; then
5477
5478 cat >>confdefs.h <<\_ACEOF
5479 #define CLOSEDIR_VOID 1
5480 _ACEOF
5481
5482 fi
5483
5484
5485
5486 for ac_header in unistd.h vfork.h
5487 do
5488 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
5489 if eval "test \"\${$as_ac_Header+set}\" = set"; then
5490 echo "$as_me:$LINENO: checking for $ac_header" >&5
5491 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
5492 if eval "test \"\${$as_ac_Header+set}\" = set"; then
5493 echo $ECHO_N "(cached) $ECHO_C" >&6
5494 fi
5495 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
5496 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
5497 else
5498 # Is the header compilable?
5499 echo "$as_me:$LINENO: checking $ac_header usability" >&5
5500 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
5501 cat >conftest.$ac_ext <<_ACEOF
5502 /* confdefs.h. */
5503 _ACEOF
5504 cat confdefs.h >>conftest.$ac_ext
5505 cat >>conftest.$ac_ext <<_ACEOF
5506 /* end confdefs.h. */
5507 $ac_includes_default
5508 #include <$ac_header>
5509 _ACEOF
5510 rm -f conftest.$ac_objext
5511 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5512 (eval $ac_compile) 2>conftest.er1
5513 ac_status=$?
5514 grep -v '^ *+' conftest.er1 >conftest.err
5515 rm -f conftest.er1
5516 cat conftest.err >&5
5517 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5518 (exit $ac_status); } &&
5519 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5520 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5521 (eval $ac_try) 2>&5
5522 ac_status=$?
5523 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5524 (exit $ac_status); }; } &&
5525 { ac_try='test -s conftest.$ac_objext'
5526 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5527 (eval $ac_try) 2>&5
5528 ac_status=$?
5529 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5530 (exit $ac_status); }; }; then
5531 ac_header_compiler=yes
5532 else
5533 echo "$as_me: failed program was:" >&5
5534 sed 's/^/| /' conftest.$ac_ext >&5
5535
5536 ac_header_compiler=no
5537 fi
5538 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
5539 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
5540 echo "${ECHO_T}$ac_header_compiler" >&6
5541
5542 # Is the header present?
5543 echo "$as_me:$LINENO: checking $ac_header presence" >&5
5544 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
5545 cat >conftest.$ac_ext <<_ACEOF
5546 /* confdefs.h. */
5547 _ACEOF
5548 cat confdefs.h >>conftest.$ac_ext
5549 cat >>conftest.$ac_ext <<_ACEOF
5550 /* end confdefs.h. */
5551 #include <$ac_header>
5552 _ACEOF
5553 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
5554 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
5555 ac_status=$?
5556 grep -v '^ *+' conftest.er1 >conftest.err
5557 rm -f conftest.er1
5558 cat conftest.err >&5
5559 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5560 (exit $ac_status); } >/dev/null; then
5561 if test -s conftest.err; then
5562 ac_cpp_err=$ac_c_preproc_warn_flag
5563 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
5564 else
5565 ac_cpp_err=
5566 fi
5567 else
5568 ac_cpp_err=yes
5569 fi
5570 if test -z "$ac_cpp_err"; then
5571 ac_header_preproc=yes
5572 else
5573 echo "$as_me: failed program was:" >&5
5574 sed 's/^/| /' conftest.$ac_ext >&5
5575
5576 ac_header_preproc=no
5577 fi
5578 rm -f conftest.err conftest.$ac_ext
5579 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
5580 echo "${ECHO_T}$ac_header_preproc" >&6
5581
5582 # So? What about this header?
5583 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
5584 yes:no: )
5585 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
5586 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
5587 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
5588 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
5589 ac_header_preproc=yes
5590 ;;
5591 no:yes:* )
5592 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
5593 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
5594 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
5595 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
5596 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
5597 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
5598 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
5599 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
5600 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
5601 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
5602 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
5603 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
5604 (
5605 cat <<\_ASBOX
5606 ## ----------------------------- ##
5607 ## Report this to haag@switch.ch ##
5608 ## ----------------------------- ##
5609 _ASBOX
5610 ) |
5611 sed "s/^/$as_me: WARNING: /" >&2
5612 ;;
5613 esac
5614 echo "$as_me:$LINENO: checking for $ac_header" >&5
5615 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
5616 if eval "test \"\${$as_ac_Header+set}\" = set"; then
5617 echo $ECHO_N "(cached) $ECHO_C" >&6
5618 else
5619 eval "$as_ac_Header=\$ac_header_preproc"
5620 fi
5621 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
5622 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
5623
5624 fi
5625 if test `eval echo '${'$as_ac_Header'}'` = yes; then
5626 cat >>confdefs.h <<_ACEOF
5627 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
5628 _ACEOF
5629
5630 fi
5631
5632 done
5633
5634
5635
5636 for ac_func in fork vfork
5637 do
5638 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
5639 echo "$as_me:$LINENO: checking for $ac_func" >&5
5640 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
5641 if eval "test \"\${$as_ac_var+set}\" = set"; then
5642 echo $ECHO_N "(cached) $ECHO_C" >&6
5643 else
5644 cat >conftest.$ac_ext <<_ACEOF
5645 /* confdefs.h. */
5646 _ACEOF
5647 cat confdefs.h >>conftest.$ac_ext
5648 cat >>conftest.$ac_ext <<_ACEOF
5649 /* end confdefs.h. */
5650 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
5651 For example, HP-UX 11i <limits.h> declares gettimeofday. */
5652 #define $ac_func innocuous_$ac_func
5653
5654 /* System header to define __stub macros and hopefully few prototypes,
5655 which can conflict with char $ac_func (); below.
5656 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
5657 <limits.h> exists even on freestanding compilers. */
5658
5659 #ifdef __STDC__
5660 # include <limits.h>
5661 #else
5662 # include <assert.h>
5663 #endif
5664
5665 #undef $ac_func
5666
5667 /* Override any gcc2 internal prototype to avoid an error. */
5668 #ifdef __cplusplus
5669 extern "C"
5670 {
5671 #endif
5672 /* We use char because int might match the return type of a gcc2
5673 builtin and then its argument prototype would still apply. */
5674 char $ac_func ();
5675 /* The GNU C library defines this for functions which it implements
5676 to always fail with ENOSYS. Some functions are actually named
5677 something starting with __ and the normal name is an alias. */
5678 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
5679 choke me
5680 #else
5681 char (*f) () = $ac_func;
5682 #endif
5683 #ifdef __cplusplus
5684 }
5685 #endif
5686
5687 int
5688 main ()
5689 {
5690 return f != $ac_func;
5691 ;
5692 return 0;
5693 }
5694 _ACEOF
5695 rm -f conftest.$ac_objext conftest$ac_exeext
5696 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5697 (eval $ac_link) 2>conftest.er1
5698 ac_status=$?
5699 grep -v '^ *+' conftest.er1 >conftest.err
5700 rm -f conftest.er1
5701 cat conftest.err >&5
5702 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5703 (exit $ac_status); } &&
5704 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
5705 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5706 (eval $ac_try) 2>&5
5707 ac_status=$?
5708 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5709 (exit $ac_status); }; } &&
5710 { ac_try='test -s conftest$ac_exeext'
5711 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5712 (eval $ac_try) 2>&5
5713 ac_status=$?
5714 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5715 (exit $ac_status); }; }; then
5716 eval "$as_ac_var=yes"
5717 else
5718 echo "$as_me: failed program was:" >&5
5719 sed 's/^/| /' conftest.$ac_ext >&5
5720
5721 eval "$as_ac_var=no"
5722 fi
5723 rm -f conftest.err conftest.$ac_objext \
5724 conftest$ac_exeext conftest.$ac_ext
5725 fi
5726 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
5727 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
5728 if test `eval echo '${'$as_ac_var'}'` = yes; then
5729 cat >>confdefs.h <<_ACEOF
5730 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
5731 _ACEOF
5732
5733 fi
5734 done
5735
5736 if test "x$ac_cv_func_fork" = xyes; then
5737 echo "$as_me:$LINENO: checking for working fork" >&5
5738 echo $ECHO_N "checking for working fork... $ECHO_C" >&6
5739 if test "${ac_cv_func_fork_works+set}" = set; then
5740 echo $ECHO_N "(cached) $ECHO_C" >&6
5741 else
5742 if test "$cross_compiling" = yes; then
5743 ac_cv_func_fork_works=cross
5744 else
5745 cat >conftest.$ac_ext <<_ACEOF
5746 /* By Ruediger Kuhlmann. */
5747 #include <sys/types.h>
5748 #if HAVE_UNISTD_H
5749 # include <unistd.h>
5750 #endif
5751 /* Some systems only have a dummy stub for fork() */
5752 int main ()
5753 {
5754 if (fork() < 0)
5755 exit (1);
5756 exit (0);
5757 }
5758 _ACEOF
5759 rm -f conftest$ac_exeext
5760 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5761 (eval $ac_link) 2>&5
5762 ac_status=$?
5763 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5764 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
5765 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5766 (eval $ac_try) 2>&5
5767 ac_status=$?
5768 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5769 (exit $ac_status); }; }; then
5770 ac_cv_func_fork_works=yes
5771 else
5772 echo "$as_me: program exited with status $ac_status" >&5
5773 echo "$as_me: failed program was:" >&5
5774 sed 's/^/| /' conftest.$ac_ext >&5
5775
5776 ( exit $ac_status )
5777 ac_cv_func_fork_works=no
5778 fi
5779 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
5780 fi
5781 fi
5782 echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5
5783 echo "${ECHO_T}$ac_cv_func_fork_works" >&6
5784
5785 else
5786 ac_cv_func_fork_works=$ac_cv_func_fork
5787 fi
5788 if test "x$ac_cv_func_fork_works" = xcross; then
5789 case $host in
5790 *-*-amigaos* | *-*-msdosdjgpp*)
5791 # Override, as these systems have only a dummy fork() stub
5792 ac_cv_func_fork_works=no
5793 ;;
5794 *)
5795 ac_cv_func_fork_works=yes
5796 ;;
5797 esac
5798 { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5
5799 echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;}
5800 fi
5801 ac_cv_func_vfork_works=$ac_cv_func_vfork
5802 if test "x$ac_cv_func_vfork" = xyes; then
5803 echo "$as_me:$LINENO: checking for working vfork" >&5
5804 echo $ECHO_N "checking for working vfork... $ECHO_C" >&6
5805 if test "${ac_cv_func_vfork_works+set}" = set; then
5806 echo $ECHO_N "(cached) $ECHO_C" >&6
5807 else
5808 if test "$cross_compiling" = yes; then
5809 ac_cv_func_vfork_works=cross
5810 else
5811 cat >conftest.$ac_ext <<_ACEOF
5812 /* confdefs.h. */
5813 _ACEOF
5814 cat confdefs.h >>conftest.$ac_ext
5815 cat >>conftest.$ac_ext <<_ACEOF
5816 /* end confdefs.h. */
5817 /* Thanks to Paul Eggert for this test. */
5818 #include <stdio.h>
5819 #include <stdlib.h>
5820 #include <sys/types.h>
5821 #include <sys/stat.h>
5822 #include <sys/wait.h>
5823 #if HAVE_UNISTD_H
5824 # include <unistd.h>
5825 #endif
5826 #if HAVE_VFORK_H
5827 # include <vfork.h>
5828 #endif
5829 /* On some sparc systems, changes by the child to local and incoming
5830 argument registers are propagated back to the parent. The compiler
5831 is told about this with #include <vfork.h>, but some compilers
5832 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
5833 static variable whose address is put into a register that is
5834 clobbered by the vfork. */
5835 static void
5836 #ifdef __cplusplus
5837 sparc_address_test (int arg)
5838 # else
5839 sparc_address_test (arg) int arg;
5840 #endif
5841 {
5842 static pid_t child;
5843 if (!child) {
5844 child = vfork ();
5845 if (child < 0) {
5846 perror ("vfork");
5847 _exit(2);
5848 }
5849 if (!child) {
5850 arg = getpid();
5851 write(-1, "", 0);
5852 _exit (arg);
5853 }
5854 }
5855 }
5856
5857 int
5858 main ()
5859 {
5860 pid_t parent = getpid ();
5861 pid_t child;
5862
5863 sparc_address_test (0);
5864
5865 child = vfork ();
5866
5867 if (child == 0) {
5868 /* Here is another test for sparc vfork register problems. This
5869 test uses lots of local variables, at least as many local
5870 variables as main has allocated so far including compiler
5871 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
5872 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
5873 reuse the register of parent for one of the local variables,
5874 since it will think that parent can't possibly be used any more
5875 in this routine. Assigning to the local variable will thus
5876 munge parent in the parent process. */
5877 pid_t
5878 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
5879 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
5880 /* Convince the compiler that p..p7 are live; otherwise, it might
5881 use the same hardware register for all 8 local variables. */
5882 if (p != p1 || p != p2 || p != p3 || p != p4
5883 || p != p5 || p != p6 || p != p7)
5884 _exit(1);
5885
5886 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
5887 from child file descriptors. If the child closes a descriptor
5888 before it execs or exits, this munges the parent's descriptor
5889 as well. Test for this by closing stdout in the child. */
5890 _exit(close(fileno(stdout)) != 0);
5891 } else {
5892 int status;
5893 struct stat st;
5894
5895 while (wait(&status) != child)
5896 ;
5897 exit(
5898 /* Was there some problem with vforking? */
5899 child < 0
5900
5901 /* Did the child fail? (This shouldn't happen.) */
5902 || status
5903
5904 /* Did the vfork/compiler bug occur? */
5905 || parent != getpid()
5906
5907 /* Did the file descriptor bug occur? */
5908 || fstat(fileno(stdout), &st) != 0
5909 );
5910 }
5911 }
5912 _ACEOF
5913 rm -f conftest$ac_exeext
5914 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5915 (eval $ac_link) 2>&5
5916 ac_status=$?
5917 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5918 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
5919 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
5920 (eval $ac_try) 2>&5
5921 ac_status=$?
5922 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5923 (exit $ac_status); }; }; then
5924 ac_cv_func_vfork_works=yes
5925 else
5926 echo "$as_me: program exited with status $ac_status" >&5
5927 echo "$as_me: failed program was:" >&5
5928 sed 's/^/| /' conftest.$ac_ext >&5
5929
5930 ( exit $ac_status )
5931 ac_cv_func_vfork_works=no
5932 fi
5933 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
5934 fi
5935 fi
5936 echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5
5937 echo "${ECHO_T}$ac_cv_func_vfork_works" >&6
5938
5939 fi;
5940 if test "x$ac_cv_func_fork_works" = xcross; then
5941 ac_cv_func_vfork_works=$ac_cv_func_vfork
5942 { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5
5943 echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;}
5944 fi
5945
5946 if test "x$ac_cv_func_vfork_works" = xyes; then
5947
5948 cat >>confdefs.h <<\_ACEOF
5949 #define HAVE_WORKING_VFORK 1
5950 _ACEOF
5951
5952 else
5953
5954 cat >>confdefs.h <<\_ACEOF
5955 #define vfork fork
5956 _ACEOF
5957
5958 fi
5959 if test "x$ac_cv_func_fork_works" = xyes; then
5960
5961 cat >>confdefs.h <<\_ACEOF
5962 #define HAVE_WORKING_FORK 1
5963 _ACEOF
5964
5965 fi
5966
5967
5968 for ac_header in stdlib.h
5969 do
5970 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
5971 if eval "test \"\${$as_ac_Header+set}\" = set"; then
5972 echo "$as_me:$LINENO: checking for $ac_header" >&5
5973 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
5974 if eval "test \"\${$as_ac_Header+set}\" = set"; then
5975 echo $ECHO_N "(cached) $ECHO_C" >&6
5976 fi
5977 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
5978 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
5979 else
5980 # Is the header compilable?
5981 echo "$as_me:$LINENO: checking $ac_header usability" >&5
5982 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
5983 cat >conftest.$ac_ext <<_ACEOF
5984 /* confdefs.h. */
5985 _ACEOF
5986 cat confdefs.h >>conftest.$ac_ext
5987 cat >>conftest.$ac_ext <<_ACEOF
5988 /* end confdefs.h. */
5989 $ac_includes_default
5990 #include <$ac_header>
5991 _ACEOF
5992 rm -f conftest.$ac_objext
5993 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5994 (eval $ac_compile) 2>conftest.er1
5995 ac_status=$?
5996 grep -v '^ *+' conftest.er1 >conftest.err
5997 rm -f conftest.er1
5998 cat conftest.err >&5
5999 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6000 (exit $ac_status); } &&
6001 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
6002 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6003 (eval $ac_try) 2>&5
6004 ac_status=$?
6005 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6006 (exit $ac_status); }; } &&
6007 { ac_try='test -s conftest.$ac_objext'
6008 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6009 (eval $ac_try) 2>&5
6010 ac_status=$?
6011 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6012 (exit $ac_status); }; }; then
6013 ac_header_compiler=yes
6014 else
6015 echo "$as_me: failed program was:" >&5
6016 sed 's/^/| /' conftest.$ac_ext >&5
6017
6018 ac_header_compiler=no
6019 fi
6020 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
6021 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
6022 echo "${ECHO_T}$ac_header_compiler" >&6
6023
6024 # Is the header present?
6025 echo "$as_me:$LINENO: checking $ac_header presence" >&5
6026 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
6027 cat >conftest.$ac_ext <<_ACEOF
6028 /* confdefs.h. */
6029 _ACEOF
6030 cat confdefs.h >>conftest.$ac_ext
6031 cat >>conftest.$ac_ext <<_ACEOF
6032 /* end confdefs.h. */
6033 #include <$ac_header>
6034 _ACEOF
6035 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
6036 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
6037 ac_status=$?
6038 grep -v '^ *+' conftest.er1 >conftest.err
6039 rm -f conftest.er1
6040 cat conftest.err >&5
6041 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6042 (exit $ac_status); } >/dev/null; then
6043 if test -s conftest.err; then
6044 ac_cpp_err=$ac_c_preproc_warn_flag
6045 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
6046 else
6047 ac_cpp_err=
6048 fi
6049 else
6050 ac_cpp_err=yes
6051 fi
6052 if test -z "$ac_cpp_err"; then
6053 ac_header_preproc=yes
6054 else
6055 echo "$as_me: failed program was:" >&5
6056 sed 's/^/| /' conftest.$ac_ext >&5
6057
6058 ac_header_preproc=no
6059 fi
6060 rm -f conftest.err conftest.$ac_ext
6061 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
6062 echo "${ECHO_T}$ac_header_preproc" >&6
6063
6064 # So? What about this header?
6065 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
6066 yes:no: )
6067 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
6068 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
6069 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
6070 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
6071 ac_header_preproc=yes
6072 ;;
6073 no:yes:* )
6074 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
6075 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
6076 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
6077 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
6078 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
6079 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
6080 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
6081 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
6082 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
6083 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
6084 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
6085 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
6086 (
6087 cat <<\_ASBOX
6088 ## ----------------------------- ##
6089 ## Report this to haag@switch.ch ##
6090 ## ----------------------------- ##
6091 _ASBOX
6092 ) |
6093 sed "s/^/$as_me: WARNING: /" >&2
6094 ;;
6095 esac
6096 echo "$as_me:$LINENO: checking for $ac_header" >&5
6097 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
6098 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6099 echo $ECHO_N "(cached) $ECHO_C" >&6
6100 else
6101 eval "$as_ac_Header=\$ac_header_preproc"
6102 fi
6103 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
6104 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
6105
6106 fi
6107 if test `eval echo '${'$as_ac_Header'}'` = yes; then
6108 cat >>confdefs.h <<_ACEOF
6109 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
6110 _ACEOF
6111
6112 fi
6113
6114 done
6115
6116 echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5
6117 echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6
6118 if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then
6119 echo $ECHO_N "(cached) $ECHO_C" >&6
6120 else
6121 if test "$cross_compiling" = yes; then
6122 ac_cv_func_malloc_0_nonnull=no
6123 else
6124 cat >conftest.$ac_ext <<_ACEOF
6125 /* confdefs.h. */
6126 _ACEOF
6127 cat confdefs.h >>conftest.$ac_ext
6128 cat >>conftest.$ac_ext <<_ACEOF
6129 /* end confdefs.h. */
6130 #if STDC_HEADERS || HAVE_STDLIB_H
6131 # include <stdlib.h>
6132 #else
6133 char *malloc ();
6134 #endif
6135
6136 int
6137 main ()
6138 {
6139 exit (malloc (0) ? 0 : 1);
6140 ;
6141 return 0;
6142 }
6143 _ACEOF
6144 rm -f conftest$ac_exeext
6145 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6146 (eval $ac_link) 2>&5
6147 ac_status=$?
6148 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6149 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
6150 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6151 (eval $ac_try) 2>&5
6152 ac_status=$?
6153 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6154 (exit $ac_status); }; }; then
6155 ac_cv_func_malloc_0_nonnull=yes
6156 else
6157 echo "$as_me: program exited with status $ac_status" >&5
6158 echo "$as_me: failed program was:" >&5
6159 sed 's/^/| /' conftest.$ac_ext >&5
6160
6161 ( exit $ac_status )
6162 ac_cv_func_malloc_0_nonnull=no
6163 fi
6164 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
6165 fi
6166 fi
6167 echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5
6168 echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6
6169 if test $ac_cv_func_malloc_0_nonnull = yes; then
6170
6171 cat >>confdefs.h <<\_ACEOF
6172 #define HAVE_MALLOC 1
6173 _ACEOF
6174
6175 else
6176 cat >>confdefs.h <<\_ACEOF
6177 #define HAVE_MALLOC 0
6178 _ACEOF
6179
6180 case $LIBOBJS in
6181 "malloc.$ac_objext" | \
6182 *" malloc.$ac_objext" | \
6183 "malloc.$ac_objext "* | \
6184 *" malloc.$ac_objext "* ) ;;
6185 *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;;
6186 esac
6187
6188
6189 cat >>confdefs.h <<\_ACEOF
6190 #define malloc rpl_malloc
6191 _ACEOF
6192
6193 fi
6194
6195
6196
6197 echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
6198 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
6199 if test "${ac_cv_header_time+set}" = set; then
6200 echo $ECHO_N "(cached) $ECHO_C" >&6
6201 else
6202 cat >conftest.$ac_ext <<_ACEOF
6203 /* confdefs.h. */
6204 _ACEOF
6205 cat confdefs.h >>conftest.$ac_ext
6206 cat >>conftest.$ac_ext <<_ACEOF
6207 /* end confdefs.h. */
6208 #include <sys/types.h>
6209 #include <sys/time.h>
6210 #include <time.h>
6211
6212 int
6213 main ()
6214 {
6215 if ((struct tm *) 0)
6216 return 0;
6217 ;
6218 return 0;
6219 }
6220 _ACEOF
6221 rm -f conftest.$ac_objext
6222 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
6223 (eval $ac_compile) 2>conftest.er1
6224 ac_status=$?
6225 grep -v '^ *+' conftest.er1 >conftest.err
6226 rm -f conftest.er1
6227 cat conftest.err >&5
6228 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6229 (exit $ac_status); } &&
6230 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
6231 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6232 (eval $ac_try) 2>&5
6233 ac_status=$?
6234 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6235 (exit $ac_status); }; } &&
6236 { ac_try='test -s conftest.$ac_objext'
6237 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6238 (eval $ac_try) 2>&5
6239 ac_status=$?
6240 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6241 (exit $ac_status); }; }; then
6242 ac_cv_header_time=yes
6243 else
6244 echo "$as_me: failed program was:" >&5
6245 sed 's/^/| /' conftest.$ac_ext >&5
6246
6247 ac_cv_header_time=no
6248 fi
6249 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
6250 fi
6251 echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
6252 echo "${ECHO_T}$ac_cv_header_time" >&6
6253 if test $ac_cv_header_time = yes; then
6254
6255 cat >>confdefs.h <<\_ACEOF
6256 #define TIME_WITH_SYS_TIME 1
6257 _ACEOF
6258
6259 fi
6260
6261
6262
6263
6264 for ac_header in stdlib.h sys/time.h unistd.h
6265 do
6266 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
6267 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6268 echo "$as_me:$LINENO: checking for $ac_header" >&5
6269 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
6270 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6271 echo $ECHO_N "(cached) $ECHO_C" >&6
6272 fi
6273 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
6274 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
6275 else
6276 # Is the header compilable?
6277 echo "$as_me:$LINENO: checking $ac_header usability" >&5
6278 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
6279 cat >conftest.$ac_ext <<_ACEOF
6280 /* confdefs.h. */
6281 _ACEOF
6282 cat confdefs.h >>conftest.$ac_ext
6283 cat >>conftest.$ac_ext <<_ACEOF
6284 /* end confdefs.h. */
6285 $ac_includes_default
6286 #include <$ac_header>
6287 _ACEOF
6288 rm -f conftest.$ac_objext
6289 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
6290 (eval $ac_compile) 2>conftest.er1
6291 ac_status=$?
6292 grep -v '^ *+' conftest.er1 >conftest.err
6293 rm -f conftest.er1
6294 cat conftest.err >&5
6295 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6296 (exit $ac_status); } &&
6297 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
6298 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6299 (eval $ac_try) 2>&5
6300 ac_status=$?
6301 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6302 (exit $ac_status); }; } &&
6303 { ac_try='test -s conftest.$ac_objext'
6304 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6305 (eval $ac_try) 2>&5
6306 ac_status=$?
6307 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6308 (exit $ac_status); }; }; then
6309 ac_header_compiler=yes
6310 else
6311 echo "$as_me: failed program was:" >&5
6312 sed 's/^/| /' conftest.$ac_ext >&5
6313
6314 ac_header_compiler=no
6315 fi
6316 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
6317 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
6318 echo "${ECHO_T}$ac_header_compiler" >&6
6319
6320 # Is the header present?
6321 echo "$as_me:$LINENO: checking $ac_header presence" >&5
6322 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
6323 cat >conftest.$ac_ext <<_ACEOF
6324 /* confdefs.h. */
6325 _ACEOF
6326 cat confdefs.h >>conftest.$ac_ext
6327 cat >>conftest.$ac_ext <<_ACEOF
6328 /* end confdefs.h. */
6329 #include <$ac_header>
6330 _ACEOF
6331 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
6332 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
6333 ac_status=$?
6334 grep -v '^ *+' conftest.er1 >conftest.err
6335 rm -f conftest.er1
6336 cat conftest.err >&5
6337 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6338 (exit $ac_status); } >/dev/null; then
6339 if test -s conftest.err; then
6340 ac_cpp_err=$ac_c_preproc_warn_flag
6341 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
6342 else
6343 ac_cpp_err=
6344 fi
6345 else
6346 ac_cpp_err=yes
6347 fi
6348 if test -z "$ac_cpp_err"; then
6349 ac_header_preproc=yes
6350 else
6351 echo "$as_me: failed program was:" >&5
6352 sed 's/^/| /' conftest.$ac_ext >&5
6353
6354 ac_header_preproc=no
6355 fi
6356 rm -f conftest.err conftest.$ac_ext
6357 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
6358 echo "${ECHO_T}$ac_header_preproc" >&6
6359
6360 # So? What about this header?
6361 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
6362 yes:no: )
6363 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
6364 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
6365 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
6366 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
6367 ac_header_preproc=yes
6368 ;;
6369 no:yes:* )
6370 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
6371 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
6372 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
6373 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
6374 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
6375 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
6376 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
6377 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
6378 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
6379 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
6380 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
6381 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
6382 (
6383 cat <<\_ASBOX
6384 ## ----------------------------- ##
6385 ## Report this to haag@switch.ch ##
6386 ## ----------------------------- ##
6387 _ASBOX
6388 ) |
6389 sed "s/^/$as_me: WARNING: /" >&2
6390 ;;
6391 esac
6392 echo "$as_me:$LINENO: checking for $ac_header" >&5
6393 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
6394 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6395 echo $ECHO_N "(cached) $ECHO_C" >&6
6396 else
6397 eval "$as_ac_Header=\$ac_header_preproc"
6398 fi
6399 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
6400 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
6401
6402 fi
6403 if test `eval echo '${'$as_ac_Header'}'` = yes; then
6404 cat >>confdefs.h <<_ACEOF
6405 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
6406 _ACEOF
6407
6408 fi
6409
6410 done
6411
6412
6413 for ac_func in alarm
6414 do
6415 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
6416 echo "$as_me:$LINENO: checking for $ac_func" >&5
6417 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
6418 if eval "test \"\${$as_ac_var+set}\" = set"; then
6419 echo $ECHO_N "(cached) $ECHO_C" >&6
6420 else
6421 cat >conftest.$ac_ext <<_ACEOF
6422 /* confdefs.h. */
6423 _ACEOF
6424 cat confdefs.h >>conftest.$ac_ext
6425 cat >>conftest.$ac_ext <<_ACEOF
6426 /* end confdefs.h. */
6427 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
6428 For example, HP-UX 11i <limits.h> declares gettimeofday. */
6429 #define $ac_func innocuous_$ac_func
6430
6431 /* System header to define __stub macros and hopefully few prototypes,
6432 which can conflict with char $ac_func (); below.
6433 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
6434 <limits.h> exists even on freestanding compilers. */
6435
6436 #ifdef __STDC__
6437 # include <limits.h>
6438 #else
6439 # include <assert.h>
6440 #endif
6441
6442 #undef $ac_func
6443
6444 /* Override any gcc2 internal prototype to avoid an error. */
6445 #ifdef __cplusplus
6446 extern "C"
6447 {
6448 #endif
6449 /* We use char because int might match the return type of a gcc2
6450 builtin and then its argument prototype would still apply. */
6451 char $ac_func ();
6452 /* The GNU C library defines this for functions which it implements
6453 to always fail with ENOSYS. Some functions are actually named
6454 something starting with __ and the normal name is an alias. */
6455 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
6456 choke me
6457 #else
6458 char (*f) () = $ac_func;
6459 #endif
6460 #ifdef __cplusplus
6461 }
6462 #endif
6463
6464 int
6465 main ()
6466 {
6467 return f != $ac_func;
6468 ;
6469 return 0;
6470 }
6471 _ACEOF
6472 rm -f conftest.$ac_objext conftest$ac_exeext
6473 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6474 (eval $ac_link) 2>conftest.er1
6475 ac_status=$?
6476 grep -v '^ *+' conftest.er1 >conftest.err
6477 rm -f conftest.er1
6478 cat conftest.err >&5
6479 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6480 (exit $ac_status); } &&
6481 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
6482 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6483 (eval $ac_try) 2>&5
6484 ac_status=$?
6485 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6486 (exit $ac_status); }; } &&
6487 { ac_try='test -s conftest$ac_exeext'
6488 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6489 (eval $ac_try) 2>&5
6490 ac_status=$?
6491 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6492 (exit $ac_status); }; }; then
6493 eval "$as_ac_var=yes"
6494 else
6495 echo "$as_me: failed program was:" >&5
6496 sed 's/^/| /' conftest.$ac_ext >&5
6497
6498 eval "$as_ac_var=no"
6499 fi
6500 rm -f conftest.err conftest.$ac_objext \
6501 conftest$ac_exeext conftest.$ac_ext
6502 fi
6503 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
6504 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
6505 if test `eval echo '${'$as_ac_var'}'` = yes; then
6506 cat >>confdefs.h <<_ACEOF
6507 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
6508 _ACEOF
6509
6510 fi
6511 done
6512
6513 echo "$as_me:$LINENO: checking for working mktime" >&5
6514 echo $ECHO_N "checking for working mktime... $ECHO_C" >&6
6515 if test "${ac_cv_func_working_mktime+set}" = set; then
6516 echo $ECHO_N "(cached) $ECHO_C" >&6
6517 else
6518 if test "$cross_compiling" = yes; then
6519 ac_cv_func_working_mktime=no
6520 else
6521 cat >conftest.$ac_ext <<_ACEOF
6522 /* confdefs.h. */
6523 _ACEOF
6524 cat confdefs.h >>conftest.$ac_ext
6525 cat >>conftest.$ac_ext <<_ACEOF
6526 /* end confdefs.h. */
6527 /* Test program from Paul Eggert and Tony Leneis. */
6528 #if TIME_WITH_SYS_TIME
6529 # include <sys/time.h>
6530 # include <time.h>
6531 #else
6532 # if HAVE_SYS_TIME_H
6533 # include <sys/time.h>
6534 # else
6535 # include <time.h>
6536 # endif
6537 #endif
6538
6539 #if HAVE_STDLIB_H
6540 # include <stdlib.h>
6541 #endif
6542
6543 #if HAVE_UNISTD_H
6544 # include <unistd.h>
6545 #endif
6546
6547 #if !HAVE_ALARM
6548 # define alarm(X) /* empty */
6549 #endif
6550
6551 /* Work around redefinition to rpl_putenv by other config tests. */
6552 #undef putenv
6553
6554 static time_t time_t_max;
6555 static time_t time_t_min;
6556
6557 /* Values we'll use to set the TZ environment variable. */
6558 static char *tz_strings[] = {
6559 (char *) 0, "TZ=GMT0", "TZ=JST-9",
6560 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
6561 };
6562 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
6563
6564 /* Fail if mktime fails to convert a date in the spring-forward gap.
6565 Based on a problem report from Andreas Jaeger. */
6566 static void
6567 spring_forward_gap ()
6568 {
6569 /* glibc (up to about 1998-10-07) failed this test. */
6570 struct tm tm;
6571
6572 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
6573 instead of "TZ=America/Vancouver" in order to detect the bug even
6574 on systems that don't support the Olson extension, or don't have the
6575 full zoneinfo tables installed. */
6576 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
6577
6578 tm.tm_year = 98;
6579 tm.tm_mon = 3;
6580 tm.tm_mday = 5;
6581 tm.tm_hour = 2;
6582 tm.tm_min = 0;
6583 tm.tm_sec = 0;
6584 tm.tm_isdst = -1;
6585 if (mktime (&tm) == (time_t)-1)
6586 exit (1);
6587 }
6588
6589 static void
6590 mktime_test1 (now)
6591 time_t now;
6592 {
6593 struct tm *lt;
6594 if ((lt = localtime (&now)) && mktime (lt) != now)
6595 exit (1);
6596 }
6597
6598 static void
6599 mktime_test (now)
6600 time_t now;
6601 {
6602 mktime_test1 (now);
6603 mktime_test1 ((time_t) (time_t_max - now));
6604 mktime_test1 ((time_t) (time_t_min + now));
6605 }
6606
6607 static void
6608 irix_6_4_bug ()
6609 {
6610 /* Based on code from Ariel Faigon. */
6611 struct tm tm;
6612 tm.tm_year = 96;
6613 tm.tm_mon = 3;
6614 tm.tm_mday = 0;
6615 tm.tm_hour = 0;
6616 tm.tm_min = 0;
6617 tm.tm_sec = 0;
6618 tm.tm_isdst = -1;
6619 mktime (&tm);
6620 if (tm.tm_mon != 2 || tm.tm_mday != 31)
6621 exit (1);
6622 }
6623
6624 static void
6625 bigtime_test (j)
6626 int j;
6627 {
6628 struct tm tm;
6629 time_t now;
6630 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
6631 now = mktime (&tm);
6632 if (now != (time_t) -1)
6633 {
6634 struct tm *lt = localtime (&now);
6635 if (! (lt
6636 && lt->tm_year == tm.tm_year
6637 && lt->tm_mon == tm.tm_mon
6638 && lt->tm_mday == tm.tm_mday
6639 && lt->tm_hour == tm.tm_hour
6640 && lt->tm_min == tm.tm_min
6641 && lt->tm_sec == tm.tm_sec
6642 && lt->tm_yday == tm.tm_yday
6643 && lt->tm_wday == tm.tm_wday
6644 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
6645 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
6646 exit (1);
6647 }
6648 }
6649
6650 int
6651 main ()
6652 {
6653 time_t t, delta;
6654 int i, j;
6655
6656 /* This test makes some buggy mktime implementations loop.
6657 Give up after 60 seconds; a mktime slower than that
6658 isn't worth using anyway. */
6659 alarm (60);
6660
6661 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
6662 continue;
6663 time_t_max--;
6664 if ((time_t) -1 < 0)
6665 for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
6666 continue;
6667 delta = time_t_max / 997; /* a suitable prime number */
6668 for (i = 0; i < N_STRINGS; i++)
6669 {
6670 if (tz_strings[i])
6671 putenv (tz_strings[i]);
6672
6673 for (t = 0; t <= time_t_max - delta; t += delta)
6674 mktime_test (t);
6675 mktime_test ((time_t) 1);
6676 mktime_test ((time_t) (60 * 60));
6677 mktime_test ((time_t) (60 * 60 * 24));
6678
6679 for (j = 1; 0 < j; j *= 2)
6680 bigtime_test (j);
6681 bigtime_test (j - 1);
6682 }
6683 irix_6_4_bug ();
6684 spring_forward_gap ();
6685 exit (0);
6686 }
6687 _ACEOF
6688 rm -f conftest$ac_exeext
6689 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6690 (eval $ac_link) 2>&5
6691 ac_status=$?
6692 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6693 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
6694 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6695 (eval $ac_try) 2>&5
6696 ac_status=$?
6697 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6698 (exit $ac_status); }; }; then
6699 ac_cv_func_working_mktime=yes
6700 else
6701 echo "$as_me: program exited with status $ac_status" >&5
6702 echo "$as_me: failed program was:" >&5
6703 sed 's/^/| /' conftest.$ac_ext >&5
6704
6705 ( exit $ac_status )
6706 ac_cv_func_working_mktime=no
6707 fi
6708 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
6709 fi
6710 fi
6711 echo "$as_me:$LINENO: result: $ac_cv_func_working_mktime" >&5
6712 echo "${ECHO_T}$ac_cv_func_working_mktime" >&6
6713 if test $ac_cv_func_working_mktime = no; then
6714 case $LIBOBJS in
6715 "mktime.$ac_objext" | \
6716 *" mktime.$ac_objext" | \
6717 "mktime.$ac_objext "* | \
6718 *" mktime.$ac_objext "* ) ;;
6719 *) LIBOBJS="$LIBOBJS mktime.$ac_objext" ;;
6720 esac
6721
6722 fi
6723
6724
6725 for ac_header in stdlib.h
6726 do
6727 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
6728 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6729 echo "$as_me:$LINENO: checking for $ac_header" >&5
6730 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
6731 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6732 echo $ECHO_N "(cached) $ECHO_C" >&6
6733 fi
6734 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
6735 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
6736 else
6737 # Is the header compilable?
6738 echo "$as_me:$LINENO: checking $ac_header usability" >&5
6739 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
6740 cat >conftest.$ac_ext <<_ACEOF
6741 /* confdefs.h. */
6742 _ACEOF
6743 cat confdefs.h >>conftest.$ac_ext
6744 cat >>conftest.$ac_ext <<_ACEOF
6745 /* end confdefs.h. */
6746 $ac_includes_default
6747 #include <$ac_header>
6748 _ACEOF
6749 rm -f conftest.$ac_objext
6750 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
6751 (eval $ac_compile) 2>conftest.er1
6752 ac_status=$?
6753 grep -v '^ *+' conftest.er1 >conftest.err
6754 rm -f conftest.er1
6755 cat conftest.err >&5
6756 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6757 (exit $ac_status); } &&
6758 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
6759 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6760 (eval $ac_try) 2>&5
6761 ac_status=$?
6762 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6763 (exit $ac_status); }; } &&
6764 { ac_try='test -s conftest.$ac_objext'
6765 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6766 (eval $ac_try) 2>&5
6767 ac_status=$?
6768 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6769 (exit $ac_status); }; }; then
6770 ac_header_compiler=yes
6771 else
6772 echo "$as_me: failed program was:" >&5
6773 sed 's/^/| /' conftest.$ac_ext >&5
6774
6775 ac_header_compiler=no
6776 fi
6777 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
6778 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
6779 echo "${ECHO_T}$ac_header_compiler" >&6
6780
6781 # Is the header present?
6782 echo "$as_me:$LINENO: checking $ac_header presence" >&5
6783 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
6784 cat >conftest.$ac_ext <<_ACEOF
6785 /* confdefs.h. */
6786 _ACEOF
6787 cat confdefs.h >>conftest.$ac_ext
6788 cat >>conftest.$ac_ext <<_ACEOF
6789 /* end confdefs.h. */
6790 #include <$ac_header>
6791 _ACEOF
6792 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
6793 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
6794 ac_status=$?
6795 grep -v '^ *+' conftest.er1 >conftest.err
6796 rm -f conftest.er1
6797 cat conftest.err >&5
6798 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6799 (exit $ac_status); } >/dev/null; then
6800 if test -s conftest.err; then
6801 ac_cpp_err=$ac_c_preproc_warn_flag
6802 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
6803 else
6804 ac_cpp_err=
6805 fi
6806 else
6807 ac_cpp_err=yes
6808 fi
6809 if test -z "$ac_cpp_err"; then
6810 ac_header_preproc=yes
6811 else
6812 echo "$as_me: failed program was:" >&5
6813 sed 's/^/| /' conftest.$ac_ext >&5
6814
6815 ac_header_preproc=no
6816 fi
6817 rm -f conftest.err conftest.$ac_ext
6818 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
6819 echo "${ECHO_T}$ac_header_preproc" >&6
6820
6821 # So? What about this header?
6822 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
6823 yes:no: )
6824 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
6825 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
6826 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
6827 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
6828 ac_header_preproc=yes
6829 ;;
6830 no:yes:* )
6831 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
6832 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
6833 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
6834 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
6835 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
6836 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
6837 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
6838 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
6839 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
6840 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
6841 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
6842 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
6843 (
6844 cat <<\_ASBOX
6845 ## ----------------------------- ##
6846 ## Report this to haag@switch.ch ##
6847 ## ----------------------------- ##
6848 _ASBOX
6849 ) |
6850 sed "s/^/$as_me: WARNING: /" >&2
6851 ;;
6852 esac
6853 echo "$as_me:$LINENO: checking for $ac_header" >&5
6854 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
6855 if eval "test \"\${$as_ac_Header+set}\" = set"; then
6856 echo $ECHO_N "(cached) $ECHO_C" >&6
6857 else
6858 eval "$as_ac_Header=\$ac_header_preproc"
6859 fi
6860 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
6861 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
6862
6863 fi
6864 if test `eval echo '${'$as_ac_Header'}'` = yes; then
6865 cat >>confdefs.h <<_ACEOF
6866 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
6867 _ACEOF
6868
6869 fi
6870
6871 done
6872
6873 echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5
6874 echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6
6875 if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then
6876 echo $ECHO_N "(cached) $ECHO_C" >&6
6877 else
6878 if test "$cross_compiling" = yes; then
6879 ac_cv_func_realloc_0_nonnull=no
6880 else
6881 cat >conftest.$ac_ext <<_ACEOF
6882 /* confdefs.h. */
6883 _ACEOF
6884 cat confdefs.h >>conftest.$ac_ext
6885 cat >>conftest.$ac_ext <<_ACEOF
6886 /* end confdefs.h. */
6887 #if STDC_HEADERS || HAVE_STDLIB_H
6888 # include <stdlib.h>
6889 #else
6890 char *realloc ();
6891 #endif
6892
6893 int
6894 main ()
6895 {
6896 exit (realloc (0, 0) ? 0 : 1);
6897 ;
6898 return 0;
6899 }
6900 _ACEOF
6901 rm -f conftest$ac_exeext
6902 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6903 (eval $ac_link) 2>&5
6904 ac_status=$?
6905 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6906 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
6907 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6908 (eval $ac_try) 2>&5
6909 ac_status=$?
6910 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6911 (exit $ac_status); }; }; then
6912 ac_cv_func_realloc_0_nonnull=yes
6913 else
6914 echo "$as_me: program exited with status $ac_status" >&5
6915 echo "$as_me: failed program was:" >&5
6916 sed 's/^/| /' conftest.$ac_ext >&5
6917
6918 ( exit $ac_status )
6919 ac_cv_func_realloc_0_nonnull=no
6920 fi
6921 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
6922 fi
6923 fi
6924 echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5
6925 echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6
6926 if test $ac_cv_func_realloc_0_nonnull = yes; then
6927
6928 cat >>confdefs.h <<\_ACEOF
6929 #define HAVE_REALLOC 1
6930 _ACEOF
6931
6932 else
6933 cat >>confdefs.h <<\_ACEOF
6934 #define HAVE_REALLOC 0
6935 _ACEOF
6936
6937 case $LIBOBJS in
6938 "realloc.$ac_objext" | \
6939 *" realloc.$ac_objext" | \
6940 "realloc.$ac_objext "* | \
6941 *" realloc.$ac_objext "* ) ;;
6942 *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;;
6943 esac
6944
6945
6946 cat >>confdefs.h <<\_ACEOF
6947 #define realloc rpl_realloc
6948 _ACEOF
6949
6950 fi
6951
6952
6953
6954 echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5
6955 echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6
6956 if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then
6957 echo $ECHO_N "(cached) $ECHO_C" >&6
6958 else
6959 rm -f conftest.sym conftest.file
6960 echo >conftest.file
6961 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
6962 if test "$cross_compiling" = yes; then
6963 ac_cv_func_lstat_dereferences_slashed_symlink=no
6964 else
6965 cat >conftest.$ac_ext <<_ACEOF
6966 /* confdefs.h. */
6967 _ACEOF
6968 cat confdefs.h >>conftest.$ac_ext
6969 cat >>conftest.$ac_ext <<_ACEOF
6970 /* end confdefs.h. */
6971 $ac_includes_default
6972 int
6973 main ()
6974 {
6975 struct stat sbuf;
6976 /* Linux will dereference the symlink and fail.
6977 That is better in the sense that it means we will not
6978 have to compile and use the lstat wrapper. */
6979 exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);
6980 ;
6981 return 0;
6982 }
6983 _ACEOF
6984 rm -f conftest$ac_exeext
6985 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
6986 (eval $ac_link) 2>&5
6987 ac_status=$?
6988 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6989 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
6990 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
6991 (eval $ac_try) 2>&5
6992 ac_status=$?
6993 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6994 (exit $ac_status); }; }; then
6995 ac_cv_func_lstat_dereferences_slashed_symlink=yes
6996 else
6997 echo "$as_me: program exited with status $ac_status" >&5
6998 echo "$as_me: failed program was:" >&5
6999 sed 's/^/| /' conftest.$ac_ext >&5
7000
7001 ( exit $ac_status )
7002 ac_cv_func_lstat_dereferences_slashed_symlink=no
7003 fi
7004 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
7005 fi
7006 else
7007 # If the `ln -s' command failed, then we probably don't even
7008 # have an lstat function.
7009 ac_cv_func_lstat_dereferences_slashed_symlink=no
7010 fi
7011 rm -f conftest.sym conftest.file
7012
7013 fi
7014 echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5
7015 echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6
7016
7017 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
7018
7019 cat >>confdefs.h <<_ACEOF
7020 #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
7021 _ACEOF
7022
7023
7024 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
7025 case $LIBOBJS in
7026 "lstat.$ac_objext" | \
7027 *" lstat.$ac_objext" | \
7028 "lstat.$ac_objext "* | \
7029 *" lstat.$ac_objext "* ) ;;
7030 *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;;
7031 esac
7032
7033 fi
7034
7035 echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5
7036 echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6
7037 if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then
7038 echo $ECHO_N "(cached) $ECHO_C" >&6
7039 else
7040 if test "$cross_compiling" = yes; then
7041 ac_cv_func_stat_empty_string_bug=yes
7042 else
7043 cat >conftest.$ac_ext <<_ACEOF
7044 /* confdefs.h. */
7045 _ACEOF
7046 cat confdefs.h >>conftest.$ac_ext
7047 cat >>conftest.$ac_ext <<_ACEOF
7048 /* end confdefs.h. */
7049 $ac_includes_default
7050 int
7051 main ()
7052 {
7053 struct stat sbuf;
7054 exit (stat ("", &sbuf) ? 1 : 0);
7055 ;
7056 return 0;
7057 }
7058 _ACEOF
7059 rm -f conftest$ac_exeext
7060 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
7061 (eval $ac_link) 2>&5
7062 ac_status=$?
7063 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7064 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
7065 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7066 (eval $ac_try) 2>&5
7067 ac_status=$?
7068 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7069 (exit $ac_status); }; }; then
7070 ac_cv_func_stat_empty_string_bug=yes
7071 else
7072 echo "$as_me: program exited with status $ac_status" >&5
7073 echo "$as_me: failed program was:" >&5
7074 sed 's/^/| /' conftest.$ac_ext >&5
7075
7076 ( exit $ac_status )
7077 ac_cv_func_stat_empty_string_bug=no
7078 fi
7079 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
7080 fi
7081 fi
7082 echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5
7083 echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6
7084 if test $ac_cv_func_stat_empty_string_bug = yes; then
7085 case $LIBOBJS in
7086 "stat.$ac_objext" | \
7087 *" stat.$ac_objext" | \
7088 "stat.$ac_objext "* | \
7089 *" stat.$ac_objext "* ) ;;
7090 *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;;
7091 esac
7092
7093
7094 cat >>confdefs.h <<_ACEOF
7095 #define HAVE_STAT_EMPTY_STRING_BUG 1
7096 _ACEOF
7097
7098 fi
7099
7100
7101 for ac_func in strftime
7102 do
7103 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
7104 echo "$as_me:$LINENO: checking for $ac_func" >&5
7105 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
7106 if eval "test \"\${$as_ac_var+set}\" = set"; then
7107 echo $ECHO_N "(cached) $ECHO_C" >&6
7108 else
7109 cat >conftest.$ac_ext <<_ACEOF
7110 /* confdefs.h. */
7111 _ACEOF
7112 cat confdefs.h >>conftest.$ac_ext
7113 cat >>conftest.$ac_ext <<_ACEOF
7114 /* end confdefs.h. */
7115 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
7116 For example, HP-UX 11i <limits.h> declares gettimeofday. */
7117 #define $ac_func innocuous_$ac_func
7118
7119 /* System header to define __stub macros and hopefully few prototypes,
7120 which can conflict with char $ac_func (); below.
7121 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
7122 <limits.h> exists even on freestanding compilers. */
7123
7124 #ifdef __STDC__
7125 # include <limits.h>
7126 #else
7127 # include <assert.h>
7128 #endif
7129
7130 #undef $ac_func
7131
7132 /* Override any gcc2 internal prototype to avoid an error. */
7133 #ifdef __cplusplus
7134 extern "C"
7135 {
7136 #endif
7137 /* We use char because int might match the return type of a gcc2
7138 builtin and then its argument prototype would still apply. */
7139 char $ac_func ();
7140 /* The GNU C library defines this for functions which it implements
7141 to always fail with ENOSYS. Some functions are actually named
7142 something starting with __ and the normal name is an alias. */
7143 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
7144 choke me
7145 #else
7146 char (*f) () = $ac_func;
7147 #endif
7148 #ifdef __cplusplus
7149 }
7150 #endif
7151
7152 int
7153 main ()
7154 {
7155 return f != $ac_func;
7156 ;
7157 return 0;
7158 }
7159 _ACEOF
7160 rm -f conftest.$ac_objext conftest$ac_exeext
7161 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
7162 (eval $ac_link) 2>conftest.er1
7163 ac_status=$?
7164 grep -v '^ *+' conftest.er1 >conftest.err
7165 rm -f conftest.er1
7166 cat conftest.err >&5
7167 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7168 (exit $ac_status); } &&
7169 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
7170 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7171 (eval $ac_try) 2>&5
7172 ac_status=$?
7173 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7174 (exit $ac_status); }; } &&
7175 { ac_try='test -s conftest$ac_exeext'
7176 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7177 (eval $ac_try) 2>&5
7178 ac_status=$?
7179 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7180 (exit $ac_status); }; }; then
7181 eval "$as_ac_var=yes"
7182 else
7183 echo "$as_me: failed program was:" >&5
7184 sed 's/^/| /' conftest.$ac_ext >&5
7185
7186 eval "$as_ac_var=no"
7187 fi
7188 rm -f conftest.err conftest.$ac_objext \
7189 conftest$ac_exeext conftest.$ac_ext
7190 fi
7191 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
7192 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
7193 if test `eval echo '${'$as_ac_var'}'` = yes; then
7194 cat >>confdefs.h <<_ACEOF
7195 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
7196 _ACEOF
7197
7198 else
7199 # strftime is in -lintl on SCO UNIX.
7200 echo "$as_me:$LINENO: checking for strftime in -lintl" >&5
7201 echo $ECHO_N "checking for strftime in -lintl... $ECHO_C" >&6
7202 if test "${ac_cv_lib_intl_strftime+set}" = set; then
7203 echo $ECHO_N "(cached) $ECHO_C" >&6
7204 else
7205 ac_check_lib_save_LIBS=$LIBS
7206 LIBS="-lintl $LIBS"
7207 cat >conftest.$ac_ext <<_ACEOF
7208 /* confdefs.h. */
7209 _ACEOF
7210 cat confdefs.h >>conftest.$ac_ext
7211 cat >>conftest.$ac_ext <<_ACEOF
7212 /* end confdefs.h. */
7213
7214 /* Override any gcc2 internal prototype to avoid an error. */
7215 #ifdef __cplusplus
7216 extern "C"
7217 #endif
7218 /* We use char because int might match the return type of a gcc2
7219 builtin and then its argument prototype would still apply. */
7220 char strftime ();
7221 int
7222 main ()
7223 {
7224 strftime ();
7225 ;
7226 return 0;
7227 }
7228 _ACEOF
7229 rm -f conftest.$ac_objext conftest$ac_exeext
7230 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
7231 (eval $ac_link) 2>conftest.er1
7232 ac_status=$?
7233 grep -v '^ *+' conftest.er1 >conftest.err
7234 rm -f conftest.er1
7235 cat conftest.err >&5
7236 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7237 (exit $ac_status); } &&
7238 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
7239 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7240 (eval $ac_try) 2>&5
7241 ac_status=$?
7242 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7243 (exit $ac_status); }; } &&
7244 { ac_try='test -s conftest$ac_exeext'
7245 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7246 (eval $ac_try) 2>&5
7247 ac_status=$?
7248 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7249 (exit $ac_status); }; }; then
7250 ac_cv_lib_intl_strftime=yes
7251 else
7252 echo "$as_me: failed program was:" >&5
7253 sed 's/^/| /' conftest.$ac_ext >&5
7254
7255 ac_cv_lib_intl_strftime=no
7256 fi
7257 rm -f conftest.err conftest.$ac_objext \
7258 conftest$ac_exeext conftest.$ac_ext
7259 LIBS=$ac_check_lib_save_LIBS
7260 fi
7261 echo "$as_me:$LINENO: result: $ac_cv_lib_intl_strftime" >&5
7262 echo "${ECHO_T}$ac_cv_lib_intl_strftime" >&6
7263 if test $ac_cv_lib_intl_strftime = yes; then
7264 cat >>confdefs.h <<\_ACEOF
7265 #define HAVE_STRFTIME 1
7266 _ACEOF
7267
7268 LIBS="-lintl $LIBS"
7269 fi
7270
7271 fi
7272 done
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282 for ac_func in inet_ntoa socket strchr strdup strerror strrchr strstr scandir
7283 do
7284 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
7285 echo "$as_me:$LINENO: checking for $ac_func" >&5
7286 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
7287 if eval "test \"\${$as_ac_var+set}\" = set"; then
7288 echo $ECHO_N "(cached) $ECHO_C" >&6
7289 else
7290 cat >conftest.$ac_ext <<_ACEOF
7291 /* confdefs.h. */
7292 _ACEOF
7293 cat confdefs.h >>conftest.$ac_ext
7294 cat >>conftest.$ac_ext <<_ACEOF
7295 /* end confdefs.h. */
7296 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
7297 For example, HP-UX 11i <limits.h> declares gettimeofday. */
7298 #define $ac_func innocuous_$ac_func
7299
7300 /* System header to define __stub macros and hopefully few prototypes,
7301 which can conflict with char $ac_func (); below.
7302 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
7303 <limits.h> exists even on freestanding compilers. */
7304
7305 #ifdef __STDC__
7306 # include <limits.h>
7307 #else
7308 # include <assert.h>
7309 #endif
7310
7311 #undef $ac_func
7312
7313 /* Override any gcc2 internal prototype to avoid an error. */
7314 #ifdef __cplusplus
7315 extern "C"
7316 {
7317 #endif
7318 /* We use char because int might match the return type of a gcc2
7319 builtin and then its argument prototype would still apply. */
7320 char $ac_func ();
7321 /* The GNU C library defines this for functions which it implements
7322 to always fail with ENOSYS. Some functions are actually named
7323 something starting with __ and the normal name is an alias. */
7324 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
7325 choke me
7326 #else
7327 char (*f) () = $ac_func;
7328 #endif
7329 #ifdef __cplusplus
7330 }
7331 #endif
7332
7333 int
7334 main ()
7335 {
7336 return f != $ac_func;
7337 ;
7338 return 0;
7339 }
7340 _ACEOF
7341 rm -f conftest.$ac_objext conftest$ac_exeext
7342 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
7343 (eval $ac_link) 2>conftest.er1
7344 ac_status=$?
7345 grep -v '^ *+' conftest.er1 >conftest.err
7346 rm -f conftest.er1
7347 cat conftest.err >&5
7348 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7349 (exit $ac_status); } &&
7350 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
7351 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7352 (eval $ac_try) 2>&5
7353 ac_status=$?
7354 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7355 (exit $ac_status); }; } &&
7356 { ac_try='test -s conftest$ac_exeext'
7357 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7358 (eval $ac_try) 2>&5
7359 ac_status=$?
7360 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7361 (exit $ac_status); }; }; then
7362 eval "$as_ac_var=yes"
7363 else
7364 echo "$as_me: failed program was:" >&5
7365 sed 's/^/| /' conftest.$ac_ext >&5
7366
7367 eval "$as_ac_var=no"
7368 fi
7369 rm -f conftest.err conftest.$ac_objext \
7370 conftest$ac_exeext conftest.$ac_ext
7371 fi
7372 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
7373 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
7374 if test `eval echo '${'$as_ac_var'}'` = yes; then
7375 cat >>confdefs.h <<_ACEOF
7376 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
7377 _ACEOF
7378
7379 fi
7380 done
7381
7382
7383
7384
7385 ac_config_files="$ac_config_files Makefile"
7386
7387 cat >confcache <<\_ACEOF
7388 # This file is a shell script that caches the results of configure
7389 # tests run on this system so they can be shared between configure
7390 # scripts and configure runs, see configure's option --config-cache.
7391 # It is not useful on other systems. If it contains results you don't
7392 # want to keep, you may remove or edit it.
7393 #
7394 # config.status only pays attention to the cache file if you give it
7395 # the --recheck option to rerun configure.
7396 #
7397 # `ac_cv_env_foo' variables (set or unset) will be overridden when
7398 # loading this file, other *unset* `ac_cv_foo' will be assigned the
7399 # following values.
7400
7401 _ACEOF
7402
7403 # The following way of writing the cache mishandles newlines in values,
7404 # but we know of no workaround that is simple, portable, and efficient.
7405 # So, don't put newlines in cache variables' values.
7406 # Ultrix sh set writes to stderr and can't be redirected directly,
7407 # and sets the high bit in the cache file unless we assign to the vars.
7408 {
7409 (set) 2>&1 |
7410 case `(ac_space=' '; set | grep ac_space) 2>&1` in
7411 *ac_space=\ *)
7412 # `set' does not quote correctly, so add quotes (double-quote
7413 # substitution turns \\\\ into \\, and sed turns \\ into \).
7414 sed -n \
7415 "s/'/'\\\\''/g;
7416 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
7417 ;;
7418 *)
7419 # `set' quotes correctly as required by POSIX, so do not add quotes.
7420 sed -n \
7421 "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
7422 ;;
7423 esac;
7424 } |
7425 sed '
7426 t clear
7427 : clear
7428 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
7429 t end
7430 /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
7431 : end' >>confcache
7432 if diff $cache_file confcache >/dev/null 2>&1; then :; else
7433 if test -w $cache_file; then
7434 test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
7435 cat confcache >$cache_file
7436 else
7437 echo "not updating unwritable cache $cache_file"
7438 fi
7439 fi
7440 rm -f confcache
7441
7442 test "x$prefix" = xNONE && prefix=$ac_default_prefix
7443 # Let make expand exec_prefix.
7444 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
7445
7446 # VPATH may cause trouble with some makes, so we remove $(srcdir),
7447 # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
7448 # trailing colons and then remove the whole line if VPATH becomes empty
7449 # (actually we leave an empty line to preserve line numbers).
7450 if test "x$srcdir" = x.; then
7451 ac_vpsub='/^[ ]*VPATH[ ]*=/{
7452 s/:*\$(srcdir):*/:/;
7453 s/:*\${srcdir}:*/:/;
7454 s/:*@srcdir@:*/:/;
7455 s/^\([^=]*=[ ]*\):*/\1/;
7456 s/:*$//;
7457 s/^[^=]*=[ ]*$//;
7458 }'
7459 fi
7460
7461 DEFS=-DHAVE_CONFIG_H
7462
7463 ac_libobjs=
7464 ac_ltlibobjs=
7465 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
7466 # 1. Remove the extension, and $U if already installed.
7467 ac_i=`echo "$ac_i" |
7468 sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
7469 # 2. Add them.
7470 ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
7471 ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
7472 done
7473 LIBOBJS=$ac_libobjs
7474
7475 LTLIBOBJS=$ac_ltlibobjs
7476
7477
7478
7479 : ${CONFIG_STATUS=./config.status}
7480 ac_clean_files_save=$ac_clean_files
7481 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
7482 { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
7483 echo "$as_me: creating $CONFIG_STATUS" >&6;}
7484 cat >$CONFIG_STATUS <<_ACEOF
7485 #! $SHELL
7486 # Generated by $as_me.
7487 # Run this file to recreate the current configuration.
7488 # Compiler output produced by configure, useful for debugging
7489 # configure, is in config.log if it exists.
7490
7491 debug=false
7492 ac_cs_recheck=false
7493 ac_cs_silent=false
7494 SHELL=\${CONFIG_SHELL-$SHELL}
7495 _ACEOF
7496
7497 cat >>$CONFIG_STATUS <<\_ACEOF
7498 ## --------------------- ##
7499 ## M4sh Initialization. ##
7500 ## --------------------- ##
7501
7502 # Be Bourne compatible
7503 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
7504 emulate sh
7505 NULLCMD=:
7506 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
7507 # is contrary to our usage. Disable this feature.
7508 alias -g '${1+"$@"}'='"$@"'
7509 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
7510 set -o posix
7511 fi
7512 DUALCASE=1; export DUALCASE # for MKS sh
7513
7514 # Support unset when possible.
7515 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
7516 as_unset=unset
7517 else
7518 as_unset=false
7519 fi
7520
7521
7522 # Work around bugs in pre-3.0 UWIN ksh.
7523 $as_unset ENV MAIL MAILPATH
7524 PS1='$ '
7525 PS2='> '
7526 PS4='+ '
7527
7528 # NLS nuisances.
7529 for as_var in \
7530 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
7531 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
7532 LC_TELEPHONE LC_TIME
7533 do
7534 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
7535 eval $as_var=C; export $as_var
7536 else
7537 $as_unset $as_var
7538 fi
7539 done
7540
7541 # Required to use basename.
7542 if expr a : '\(a\)' >/dev/null 2>&1; then
7543 as_expr=expr
7544 else
7545 as_expr=false
7546 fi
7547
7548 if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
7549 as_basename=basename
7550 else
7551 as_basename=false
7552 fi
7553
7554
7555 # Name of the executable.
7556 as_me=`$as_basename "$0" ||
7557 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
7558 X"$0" : 'X\(//\)$' \| \
7559 X"$0" : 'X\(/\)$' \| \
7560 . : '\(.\)' 2>/dev/null ||
7561 echo X/"$0" |
7562 sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
7563 /^X\/\(\/\/\)$/{ s//\1/; q; }
7564 /^X\/\(\/\).*/{ s//\1/; q; }
7565 s/.*/./; q'`
7566
7567
7568 # PATH needs CR, and LINENO needs CR and PATH.
7569 # Avoid depending upon Character Ranges.
7570 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
7571 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
7572 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
7573 as_cr_digits='0123456789'
7574 as_cr_alnum=$as_cr_Letters$as_cr_digits
7575
7576 # The user is always right.
7577 if test "${PATH_SEPARATOR+set}" != set; then
7578 echo "#! /bin/sh" >conf$$.sh
7579 echo "exit 0" >>conf$$.sh
7580 chmod +x conf$$.sh
7581 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
7582 PATH_SEPARATOR=';'
7583 else
7584 PATH_SEPARATOR=:
7585 fi
7586 rm -f conf$$.sh
7587 fi
7588
7589
7590 as_lineno_1=$LINENO
7591 as_lineno_2=$LINENO
7592 as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
7593 test "x$as_lineno_1" != "x$as_lineno_2" &&
7594 test "x$as_lineno_3" = "x$as_lineno_2" || {
7595 # Find who we are. Look in the path if we contain no path at all
7596 # relative or not.
7597 case $0 in
7598 *[\\/]* ) as_myself=$0 ;;
7599 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7600 for as_dir in $PATH
7601 do
7602 IFS=$as_save_IFS
7603 test -z "$as_dir" && as_dir=.
7604 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
7605 done
7606
7607 ;;
7608 esac
7609 # We did not find ourselves, most probably we were run as `sh COMMAND'
7610 # in which case we are not to be found in the path.
7611 if test "x$as_myself" = x; then
7612 as_myself=$0
7613 fi
7614 if test ! -f "$as_myself"; then
7615 { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
7616 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
7617 { (exit 1); exit 1; }; }
7618 fi
7619 case $CONFIG_SHELL in
7620 '')
7621 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7622 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
7623 do
7624 IFS=$as_save_IFS
7625 test -z "$as_dir" && as_dir=.
7626 for as_base in sh bash ksh sh5; do
7627 case $as_dir in
7628 /*)
7629 if ("$as_dir/$as_base" -c '
7630 as_lineno_1=$LINENO
7631 as_lineno_2=$LINENO
7632 as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
7633 test "x$as_lineno_1" != "x$as_lineno_2" &&
7634 test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
7635 $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
7636 $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
7637 CONFIG_SHELL=$as_dir/$as_base
7638 export CONFIG_SHELL
7639 exec "$CONFIG_SHELL" "$0" ${1+"$@"}
7640 fi;;
7641 esac
7642 done
7643 done
7644 ;;
7645 esac
7646
7647 # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
7648 # uniformly replaced by the line number. The first 'sed' inserts a
7649 # line-number line before each line; the second 'sed' does the real
7650 # work. The second script uses 'N' to pair each line-number line
7651 # with the numbered line, and appends trailing '-' during
7652 # substitution so that $LINENO is not a special case at line end.
7653 # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
7654 # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
7655 sed '=' <$as_myself |
7656 sed '
7657 N
7658 s,$,-,
7659 : loop
7660 s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
7661 t loop
7662 s,-$,,
7663 s,^['$as_cr_digits']*\n,,
7664 ' >$as_me.lineno &&
7665 chmod +x $as_me.lineno ||
7666 { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
7667 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
7668 { (exit 1); exit 1; }; }
7669
7670 # Don't try to exec as it changes $[0], causing all sort of problems
7671 # (the dirname of $[0] is not the place where we might find the
7672 # original and so on. Autoconf is especially sensible to this).
7673 . ./$as_me.lineno
7674 # Exit status is that of the last command.
7675 exit
7676 }
7677
7678
7679 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
7680 *c*,-n*) ECHO_N= ECHO_C='
7681 ' ECHO_T=' ' ;;
7682 *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
7683 *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
7684 esac
7685
7686 if expr a : '\(a\)' >/dev/null 2>&1; then
7687 as_expr=expr
7688 else
7689 as_expr=false
7690 fi
7691
7692 rm -f conf$$ conf$$.exe conf$$.file
7693 echo >conf$$.file
7694 if ln -s conf$$.file conf$$ 2>/dev/null; then
7695 # We could just check for DJGPP; but this test a) works b) is more generic
7696 # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
7697 if test -f conf$$.exe; then
7698 # Don't use ln at all; we don't have any links
7699 as_ln_s='cp -p'
7700 else
7701 as_ln_s='ln -s'
7702 fi
7703 elif ln conf$$.file conf$$ 2>/dev/null; then
7704 as_ln_s=ln
7705 else
7706 as_ln_s='cp -p'
7707 fi
7708 rm -f conf$$ conf$$.exe conf$$.file
7709
7710 if mkdir -p . 2>/dev/null; then
7711 as_mkdir_p=:
7712 else
7713 test -d ./-p && rmdir ./-p
7714 as_mkdir_p=false
7715 fi
7716
7717 as_executable_p="test -f"
7718
7719 # Sed expression to map a string onto a valid CPP name.
7720 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
7721
7722 # Sed expression to map a string onto a valid variable name.
7723 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
7724
7725
7726 # IFS
7727 # We need space, tab and new line, in precisely that order.
7728 as_nl='
7729 '
7730 IFS=" $as_nl"
7731
7732 # CDPATH.
7733 $as_unset CDPATH
7734
7735 exec 6>&1
7736
7737 # Open the log real soon, to keep \$[0] and so on meaningful, and to
7738 # report actual input values of CONFIG_FILES etc. instead of their
7739 # values after options handling. Logging --version etc. is OK.
7740 exec 5>>config.log
7741 {
7742 echo
7743 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
7744 ## Running $as_me. ##
7745 _ASBOX
7746 } >&5
7747 cat >&5 <<_CSEOF
7748
7749 This file was extended by nfdump $as_me 1.4, which was
7750 generated by GNU Autoconf 2.59. Invocation command line was
7751
7752 CONFIG_FILES = $CONFIG_FILES
7753 CONFIG_HEADERS = $CONFIG_HEADERS
7754 CONFIG_LINKS = $CONFIG_LINKS
7755 CONFIG_COMMANDS = $CONFIG_COMMANDS
7756 $ $0 $@
7757
7758 _CSEOF
7759 echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
7760 echo >&5
7761 _ACEOF
7762
7763 # Files that config.status was made for.
7764 if test -n "$ac_config_files"; then
7765 echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
7766 fi
7767
7768 if test -n "$ac_config_headers"; then
7769 echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
7770 fi
7771
7772 if test -n "$ac_config_links"; then
7773 echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
7774 fi
7775
7776 if test -n "$ac_config_commands"; then
7777 echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
7778 fi
7779
7780 cat >>$CONFIG_STATUS <<\_ACEOF
7781
7782 ac_cs_usage="\
7783 \`$as_me' instantiates files from templates according to the
7784 current configuration.
7785
7786 Usage: $0 [OPTIONS] [FILE]...
7787
7788 -h, --help print this help, then exit
7789 -V, --version print version number, then exit
7790 -q, --quiet do not print progress messages
7791 -d, --debug don't remove temporary files
7792 --recheck update $as_me by reconfiguring in the same conditions
7793 --file=FILE[:TEMPLATE]
7794 instantiate the configuration file FILE
7795 --header=FILE[:TEMPLATE]
7796 instantiate the configuration header FILE
7797
7798 Configuration files:
7799 $config_files
7800
7801 Configuration headers:
7802 $config_headers
7803
7804 Report bugs to <bug-autoconf@gnu.org>."
7805 _ACEOF
7806
7807 cat >>$CONFIG_STATUS <<_ACEOF
7808 ac_cs_version="\\
7809 nfdump config.status 1.4
7810 configured by $0, generated by GNU Autoconf 2.59,
7811 with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
7812
7813 Copyright (C) 2003 Free Software Foundation, Inc.
7814 This config.status script is free software; the Free Software Foundation
7815 gives unlimited permission to copy, distribute and modify it."
7816 srcdir=$srcdir
7817 INSTALL="$INSTALL"
7818 _ACEOF
7819
7820 cat >>$CONFIG_STATUS <<\_ACEOF
7821 # If no file are specified by the user, then we need to provide default
7822 # value. By we need to know if files were specified by the user.
7823 ac_need_defaults=:
7824 while test $# != 0
7825 do
7826 case $1 in
7827 --*=*)
7828 ac_option=`expr "x$1" : 'x\([^=]*\)='`
7829 ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
7830 ac_shift=:
7831 ;;
7832 -*)
7833 ac_option=$1
7834 ac_optarg=$2
7835 ac_shift=shift
7836 ;;
7837 *) # This is not an option, so the user has probably given explicit
7838 # arguments.
7839 ac_option=$1
7840 ac_need_defaults=false;;
7841 esac
7842
7843 case $ac_option in
7844 # Handling of the options.
7845 _ACEOF
7846 cat >>$CONFIG_STATUS <<\_ACEOF
7847 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
7848 ac_cs_recheck=: ;;
7849 --version | --vers* | -V )
7850 echo "$ac_cs_version"; exit 0 ;;
7851 --he | --h)
7852 # Conflict between --help and --header
7853 { { echo "$as_me:$LINENO: error: ambiguous option: $1
7854 Try \`$0 --help' for more information." >&5
7855 echo "$as_me: error: ambiguous option: $1
7856 Try \`$0 --help' for more information." >&2;}
7857 { (exit 1); exit 1; }; };;
7858 --help | --hel | -h )
7859 echo "$ac_cs_usage"; exit 0 ;;
7860 --debug | --d* | -d )
7861 debug=: ;;
7862 --file | --fil | --fi | --f )
7863 $ac_shift
7864 CONFIG_FILES="$CONFIG_FILES $ac_optarg"
7865 ac_need_defaults=false;;
7866 --header | --heade | --head | --hea )
7867 $ac_shift
7868 CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
7869 ac_need_defaults=false;;
7870 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
7871 | -silent | --silent | --silen | --sile | --sil | --si | --s)
7872 ac_cs_silent=: ;;
7873
7874 # This is an error.
7875 -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
7876 Try \`$0 --help' for more information." >&5
7877 echo "$as_me: error: unrecognized option: $1
7878 Try \`$0 --help' for more information." >&2;}
7879 { (exit 1); exit 1; }; } ;;
7880
7881 *) ac_config_targets="$ac_config_targets $1" ;;
7882
7883 esac
7884 shift
7885 done
7886
7887 ac_configure_extra_args=
7888
7889 if $ac_cs_silent; then
7890 exec 6>/dev/null
7891 ac_configure_extra_args="$ac_configure_extra_args --silent"
7892 fi
7893
7894 _ACEOF
7895 cat >>$CONFIG_STATUS <<_ACEOF
7896 if \$ac_cs_recheck; then
7897 echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
7898 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
7899 fi
7900
7901 _ACEOF
7902
7903
7904
7905
7906
7907 cat >>$CONFIG_STATUS <<\_ACEOF
7908 for ac_config_target in $ac_config_targets
7909 do
7910 case "$ac_config_target" in
7911 # Handling of arguments.
7912 "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
7913 "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
7914 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
7915 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
7916 { (exit 1); exit 1; }; };;
7917 esac
7918 done
7919
7920 # If the user did not use the arguments to specify the items to instantiate,
7921 # then the envvar interface is used. Set only those that are not.
7922 # We use the long form for the default assignment because of an extremely
7923 # bizarre bug on SunOS 4.1.3.
7924 if $ac_need_defaults; then
7925 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
7926 test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
7927 fi
7928
7929 # Have a temporary directory for convenience. Make it in the build tree
7930 # simply because there is no reason to put it here, and in addition,
7931 # creating and moving files from /tmp can sometimes cause problems.
7932 # Create a temporary directory, and hook for its removal unless debugging.
7933 $debug ||
7934 {
7935 trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
7936 trap '{ (exit 1); exit 1; }' 1 2 13 15
7937 }
7938
7939 # Create a (secure) tmp directory for tmp files.
7940
7941 {
7942 tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
7943 test -n "$tmp" && test -d "$tmp"
7944 } ||
7945 {
7946 tmp=./confstat$$-$RANDOM
7947 (umask 077 && mkdir $tmp)
7948 } ||
7949 {
7950 echo "$me: cannot create a temporary directory in ." >&2
7951 { (exit 1); exit 1; }
7952 }
7953
7954 _ACEOF
7955
7956 cat >>$CONFIG_STATUS <<_ACEOF
7957
7958 #
7959 # CONFIG_FILES section.
7960 #
7961
7962 # No need to generate the scripts if there are no CONFIG_FILES.
7963 # This happens for instance when ./config.status config.h
7964 if test -n "\$CONFIG_FILES"; then
7965 # Protect against being on the right side of a sed subst in config.status.
7966 sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
7967 s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
7968 s,@SHELL@,$SHELL,;t t
7969 s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
7970 s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
7971 s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
7972 s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
7973 s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
7974 s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
7975 s,@exec_prefix@,$exec_prefix,;t t
7976 s,@prefix@,$prefix,;t t
7977 s,@program_transform_name@,$program_transform_name,;t t
7978 s,@bindir@,$bindir,;t t
7979 s,@sbindir@,$sbindir,;t t
7980 s,@libexecdir@,$libexecdir,;t t
7981 s,@datadir@,$datadir,;t t
7982 s,@sysconfdir@,$sysconfdir,;t t
7983 s,@sharedstatedir@,$sharedstatedir,;t t
7984 s,@localstatedir@,$localstatedir,;t t
7985 s,@libdir@,$libdir,;t t
7986 s,@includedir@,$includedir,;t t
7987 s,@oldincludedir@,$oldincludedir,;t t
7988 s,@infodir@,$infodir,;t t
7989 s,@mandir@,$mandir,;t t
7990 s,@build_alias@,$build_alias,;t t
7991 s,@host_alias@,$host_alias,;t t
7992 s,@target_alias@,$target_alias,;t t
7993 s,@DEFS@,$DEFS,;t t
7994 s,@ECHO_C@,$ECHO_C,;t t
7995 s,@ECHO_N@,$ECHO_N,;t t
7996 s,@ECHO_T@,$ECHO_T,;t t
7997 s,@LIBS@,$LIBS,;t t
7998 s,@CC@,$CC,;t t
7999 s,@CFLAGS@,$CFLAGS,;t t
8000 s,@LDFLAGS@,$LDFLAGS,;t t
8001 s,@CPPFLAGS@,$CPPFLAGS,;t t
8002 s,@ac_ct_CC@,$ac_ct_CC,;t t
8003 s,@EXEEXT@,$EXEEXT,;t t
8004 s,@OBJEXT@,$OBJEXT,;t t
8005 s,@YACC@,$YACC,;t t
8006 s,@LEX@,$LEX,;t t
8007 s,@LEXLIB@,$LEXLIB,;t t
8008 s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t
8009 s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
8010 s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
8011 s,@INSTALL_DATA@,$INSTALL_DATA,;t t
8012 s,@opt_objects@,$opt_objects,;t t
8013 s,@FT_INCLUDES@,$FT_INCLUDES,;t t
8014 s,@FT_LDFLAGS@,$FT_LDFLAGS,;t t
8015 s,@LFLAGS@,$LFLAGS,;t t
8016 s,@CPP@,$CPP,;t t
8017 s,@EGREP@,$EGREP,;t t
8018 s,@LIBOBJS@,$LIBOBJS,;t t
8019 s,@HA_HAVE_SCANDIR@,$HA_HAVE_SCANDIR,;t t
8020 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
8021 CEOF
8022
8023 _ACEOF
8024
8025 cat >>$CONFIG_STATUS <<\_ACEOF
8026 # Split the substitutions into bite-sized pieces for seds with
8027 # small command number limits, like on Digital OSF/1 and HP-UX.
8028 ac_max_sed_lines=48
8029 ac_sed_frag=1 # Number of current file.
8030 ac_beg=1 # First line for current file.
8031 ac_end=$ac_max_sed_lines # Line after last line for current file.
8032 ac_more_lines=:
8033 ac_sed_cmds=
8034 while $ac_more_lines; do
8035 if test $ac_beg -gt 1; then
8036 sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
8037 else
8038 sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
8039 fi
8040 if test ! -s $tmp/subs.frag; then
8041 ac_more_lines=false
8042 else
8043 # The purpose of the label and of the branching condition is to
8044 # speed up the sed processing (if there are no `@' at all, there
8045 # is no need to browse any of the substitutions).
8046 # These are the two extra sed commands mentioned above.
8047 (echo ':t
8048 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
8049 if test -z "$ac_sed_cmds"; then
8050 ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
8051 else
8052 ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
8053 fi
8054 ac_sed_frag=`expr $ac_sed_frag + 1`
8055 ac_beg=$ac_end
8056 ac_end=`expr $ac_end + $ac_max_sed_lines`
8057 fi
8058 done
8059 if test -z "$ac_sed_cmds"; then
8060 ac_sed_cmds=cat
8061 fi
8062 fi # test -n "$CONFIG_FILES"
8063
8064 _ACEOF
8065 cat >>$CONFIG_STATUS <<\_ACEOF
8066 for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
8067 # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
8068 case $ac_file in
8069 - | *:- | *:-:* ) # input from stdin
8070 cat >$tmp/stdin
8071 ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
8072 ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
8073 *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
8074 ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
8075 * ) ac_file_in=$ac_file.in ;;
8076 esac
8077
8078 # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
8079 ac_dir=`(dirname "$ac_file") 2>/dev/null ||
8080 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
8081 X"$ac_file" : 'X\(//\)[^/]' \| \
8082 X"$ac_file" : 'X\(//\)$' \| \
8083 X"$ac_file" : 'X\(/\)' \| \
8084 . : '\(.\)' 2>/dev/null ||
8085 echo X"$ac_file" |
8086 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
8087 /^X\(\/\/\)[^/].*/{ s//\1/; q; }
8088 /^X\(\/\/\)$/{ s//\1/; q; }
8089 /^X\(\/\).*/{ s//\1/; q; }
8090 s/.*/./; q'`
8091 { if $as_mkdir_p; then
8092 mkdir -p "$ac_dir"
8093 else
8094 as_dir="$ac_dir"
8095 as_dirs=
8096 while test ! -d "$as_dir"; do
8097 as_dirs="$as_dir $as_dirs"
8098 as_dir=`(dirname "$as_dir") 2>/dev/null ||
8099 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
8100 X"$as_dir" : 'X\(//\)[^/]' \| \
8101 X"$as_dir" : 'X\(//\)$' \| \
8102 X"$as_dir" : 'X\(/\)' \| \
8103 . : '\(.\)' 2>/dev/null ||
8104 echo X"$as_dir" |
8105 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
8106 /^X\(\/\/\)[^/].*/{ s//\1/; q; }
8107 /^X\(\/\/\)$/{ s//\1/; q; }
8108 /^X\(\/\).*/{ s//\1/; q; }
8109 s/.*/./; q'`
8110 done
8111 test ! -n "$as_dirs" || mkdir $as_dirs
8112 fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
8113 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
8114 { (exit 1); exit 1; }; }; }
8115
8116 ac_builddir=.
8117
8118 if test "$ac_dir" != .; then
8119 ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
8120 # A "../" for each directory in $ac_dir_suffix.
8121 ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
8122 else
8123 ac_dir_suffix= ac_top_builddir=
8124 fi
8125
8126 case $srcdir in
8127 .) # No --srcdir option. We are building in place.
8128 ac_srcdir=.
8129 if test -z "$ac_top_builddir"; then
8130 ac_top_srcdir=.
8131 else
8132 ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
8133 fi ;;
8134 [\\/]* | ?:[\\/]* ) # Absolute path.
8135 ac_srcdir=$srcdir$ac_dir_suffix;
8136 ac_top_srcdir=$srcdir ;;
8137 *) # Relative path.
8138 ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
8139 ac_top_srcdir=$ac_top_builddir$srcdir ;;
8140 esac
8141
8142 # Do not use `cd foo && pwd` to compute absolute paths, because
8143 # the directories may not exist.
8144 case `pwd` in
8145 .) ac_abs_builddir="$ac_dir";;
8146 *)
8147 case "$ac_dir" in
8148 .) ac_abs_builddir=`pwd`;;
8149 [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
8150 *) ac_abs_builddir=`pwd`/"$ac_dir";;
8151 esac;;
8152 esac
8153 case $ac_abs_builddir in
8154 .) ac_abs_top_builddir=${ac_top_builddir}.;;
8155 *)
8156 case ${ac_top_builddir}. in
8157 .) ac_abs_top_builddir=$ac_abs_builddir;;
8158 [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
8159 *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
8160 esac;;
8161 esac
8162 case $ac_abs_builddir in
8163 .) ac_abs_srcdir=$ac_srcdir;;
8164 *)
8165 case $ac_srcdir in
8166 .) ac_abs_srcdir=$ac_abs_builddir;;
8167 [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
8168 *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
8169 esac;;
8170 esac
8171 case $ac_abs_builddir in
8172 .) ac_abs_top_srcdir=$ac_top_srcdir;;
8173 *)
8174 case $ac_top_srcdir in
8175 .) ac_abs_top_srcdir=$ac_abs_builddir;;
8176 [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
8177 *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
8178 esac;;
8179 esac
8180
8181
8182 case $INSTALL in
8183 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
8184 *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
8185 esac
8186
8187 # Let's still pretend it is `configure' which instantiates (i.e., don't
8188 # use $as_me), people would be surprised to read:
8189 # /* config.h. Generated by config.status. */
8190 if test x"$ac_file" = x-; then
8191 configure_input=
8192 else
8193 configure_input="$ac_file. "
8194 fi
8195 configure_input=$configure_input"Generated from `echo $ac_file_in |
8196 sed 's,.*/,,'` by configure."
8197
8198 # First look for the input files in the build tree, otherwise in the
8199 # src tree.
8200 ac_file_inputs=`IFS=:
8201 for f in $ac_file_in; do
8202 case $f in
8203 -) echo $tmp/stdin ;;
8204 [\\/$]*)
8205 # Absolute (can't be DOS-style, as IFS=:)
8206 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
8207 echo "$as_me: error: cannot find input file: $f" >&2;}
8208 { (exit 1); exit 1; }; }
8209 echo "$f";;
8210 *) # Relative
8211 if test -f "$f"; then
8212 # Build tree
8213 echo "$f"
8214 elif test -f "$srcdir/$f"; then
8215 # Source tree
8216 echo "$srcdir/$f"
8217 else
8218 # /dev/null tree
8219 { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
8220 echo "$as_me: error: cannot find input file: $f" >&2;}
8221 { (exit 1); exit 1; }; }
8222 fi;;
8223 esac
8224 done` || { (exit 1); exit 1; }
8225
8226 if test x"$ac_file" != x-; then
8227 { echo "$as_me:$LINENO: creating $ac_file" >&5
8228 echo "$as_me: creating $ac_file" >&6;}
8229 rm -f "$ac_file"
8230 fi
8231 _ACEOF
8232 cat >>$CONFIG_STATUS <<_ACEOF
8233 sed "$ac_vpsub
8234 $extrasub
8235 _ACEOF
8236 cat >>$CONFIG_STATUS <<\_ACEOF
8237 :t
8238 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
8239 s,@configure_input@,$configure_input,;t t
8240 s,@srcdir@,$ac_srcdir,;t t
8241 s,@abs_srcdir@,$ac_abs_srcdir,;t t
8242 s,@top_srcdir@,$ac_top_srcdir,;t t
8243 s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
8244 s,@builddir@,$ac_builddir,;t t
8245 s,@abs_builddir@,$ac_abs_builddir,;t t
8246 s,@top_builddir@,$ac_top_builddir,;t t
8247 s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
8248 s,@INSTALL@,$ac_INSTALL,;t t
8249 " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
8250 rm -f $tmp/stdin
8251 if test x"$ac_file" != x-; then
8252 mv $tmp/out $ac_file
8253 else
8254 cat $tmp/out
8255 rm -f $tmp/out
8256 fi
8257
8258 done
8259 _ACEOF
8260 cat >>$CONFIG_STATUS <<\_ACEOF
8261
8262 #
8263 # CONFIG_HEADER section.
8264 #
8265
8266 # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
8267 # NAME is the cpp macro being defined and VALUE is the value it is being given.
8268 #
8269 # ac_d sets the value in "#define NAME VALUE" lines.
8270 ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
8271 ac_dB='[ ].*$,\1#\2'
8272 ac_dC=' '
8273 ac_dD=',;t'
8274 # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
8275 ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
8276 ac_uB='$,\1#\2define\3'
8277 ac_uC=' '
8278 ac_uD=',;t'
8279
8280 for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
8281 # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
8282 case $ac_file in
8283 - | *:- | *:-:* ) # input from stdin
8284 cat >$tmp/stdin
8285 ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
8286 ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
8287 *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
8288 ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
8289 * ) ac_file_in=$ac_file.in ;;
8290 esac
8291
8292 test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
8293 echo "$as_me: creating $ac_file" >&6;}
8294
8295 # First look for the input files in the build tree, otherwise in the
8296 # src tree.
8297 ac_file_inputs=`IFS=:
8298 for f in $ac_file_in; do
8299 case $f in
8300 -) echo $tmp/stdin ;;
8301 [\\/$]*)
8302 # Absolute (can't be DOS-style, as IFS=:)
8303 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
8304 echo "$as_me: error: cannot find input file: $f" >&2;}
8305 { (exit 1); exit 1; }; }
8306 # Do quote $f, to prevent DOS paths from being IFS'd.
8307 echo "$f";;
8308 *) # Relative
8309 if test -f "$f"; then
8310 # Build tree
8311 echo "$f"
8312 elif test -f "$srcdir/$f"; then
8313 # Source tree
8314 echo "$srcdir/$f"
8315 else
8316 # /dev/null tree
8317 { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
8318 echo "$as_me: error: cannot find input file: $f" >&2;}
8319 { (exit 1); exit 1; }; }
8320 fi;;
8321 esac
8322 done` || { (exit 1); exit 1; }
8323 # Remove the trailing spaces.
8324 sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
8325
8326 _ACEOF
8327
8328 # Transform confdefs.h into two sed scripts, `conftest.defines' and
8329 # `conftest.undefs', that substitutes the proper values into
8330 # config.h.in to produce config.h. The first handles `#define'
8331 # templates, and the second `#undef' templates.
8332 # And first: Protect against being on the right side of a sed subst in
8333 # config.status. Protect against being in an unquoted here document
8334 # in config.status.
8335 rm -f conftest.defines conftest.undefs
8336 # Using a here document instead of a string reduces the quoting nightmare.
8337 # Putting comments in sed scripts is not portable.
8338 #
8339 # `end' is used to avoid that the second main sed command (meant for
8340 # 0-ary CPP macros) applies to n-ary macro definitions.
8341 # See the Autoconf documentation for `clear'.
8342 cat >confdef2sed.sed <<\_ACEOF
8343 s/[\\&,]/\\&/g
8344 s,[\\$`],\\&,g
8345 t clear
8346 : clear
8347 s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
8348 t end
8349 s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
8350 : end
8351 _ACEOF
8352 # If some macros were called several times there might be several times
8353 # the same #defines, which is useless. Nevertheless, we may not want to
8354 # sort them, since we want the *last* AC-DEFINE to be honored.
8355 uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
8356 sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
8357 rm -f confdef2sed.sed
8358
8359 # This sed command replaces #undef with comments. This is necessary, for
8360 # example, in the case of _POSIX_SOURCE, which is predefined and required
8361 # on some systems where configure will not decide to define it.
8362 cat >>conftest.undefs <<\_ACEOF
8363 s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
8364 _ACEOF
8365
8366 # Break up conftest.defines because some shells have a limit on the size
8367 # of here documents, and old seds have small limits too (100 cmds).
8368 echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
8369 echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
8370 echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
8371 echo ' :' >>$CONFIG_STATUS
8372 rm -f conftest.tail
8373 while grep . conftest.defines >/dev/null
8374 do
8375 # Write a limited-size here document to $tmp/defines.sed.
8376 echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
8377 # Speed up: don't consider the non `#define' lines.
8378 echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
8379 # Work around the forget-to-reset-the-flag bug.
8380 echo 't clr' >>$CONFIG_STATUS
8381 echo ': clr' >>$CONFIG_STATUS
8382 sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
8383 echo 'CEOF
8384 sed -f $tmp/defines.sed $tmp/in >$tmp/out
8385 rm -f $tmp/in
8386 mv $tmp/out $tmp/in
8387 ' >>$CONFIG_STATUS
8388 sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
8389 rm -f conftest.defines
8390 mv conftest.tail conftest.defines
8391 done
8392 rm -f conftest.defines
8393 echo ' fi # grep' >>$CONFIG_STATUS
8394 echo >>$CONFIG_STATUS
8395
8396 # Break up conftest.undefs because some shells have a limit on the size
8397 # of here documents, and old seds have small limits too (100 cmds).
8398 echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
8399 rm -f conftest.tail
8400 while grep . conftest.undefs >/dev/null
8401 do
8402 # Write a limited-size here document to $tmp/undefs.sed.
8403 echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
8404 # Speed up: don't consider the non `#undef'
8405 echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
8406 # Work around the forget-to-reset-the-flag bug.
8407 echo 't clr' >>$CONFIG_STATUS
8408 echo ': clr' >>$CONFIG_STATUS
8409 sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
8410 echo 'CEOF
8411 sed -f $tmp/undefs.sed $tmp/in >$tmp/out
8412 rm -f $tmp/in
8413 mv $tmp/out $tmp/in
8414 ' >>$CONFIG_STATUS
8415 sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
8416 rm -f conftest.undefs
8417 mv conftest.tail conftest.undefs
8418 done
8419 rm -f conftest.undefs
8420
8421 cat >>$CONFIG_STATUS <<\_ACEOF
8422 # Let's still pretend it is `configure' which instantiates (i.e., don't
8423 # use $as_me), people would be surprised to read:
8424 # /* config.h. Generated by config.status. */
8425 if test x"$ac_file" = x-; then
8426 echo "/* Generated by configure. */" >$tmp/config.h
8427 else
8428 echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
8429 fi
8430 cat $tmp/in >>$tmp/config.h
8431 rm -f $tmp/in
8432 if test x"$ac_file" != x-; then
8433 if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
8434 { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
8435 echo "$as_me: $ac_file is unchanged" >&6;}
8436 else
8437 ac_dir=`(dirname "$ac_file") 2>/dev/null ||
8438 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
8439 X"$ac_file" : 'X\(//\)[^/]' \| \
8440 X"$ac_file" : 'X\(//\)$' \| \
8441 X"$ac_file" : 'X\(/\)' \| \
8442 . : '\(.\)' 2>/dev/null ||
8443 echo X"$ac_file" |
8444 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
8445 /^X\(\/\/\)[^/].*/{ s//\1/; q; }
8446 /^X\(\/\/\)$/{ s//\1/; q; }
8447 /^X\(\/\).*/{ s//\1/; q; }
8448 s/.*/./; q'`
8449 { if $as_mkdir_p; then
8450 mkdir -p "$ac_dir"
8451 else
8452 as_dir="$ac_dir"
8453 as_dirs=
8454 while test ! -d "$as_dir"; do
8455 as_dirs="$as_dir $as_dirs"
8456 as_dir=`(dirname "$as_dir") 2>/dev/null ||
8457 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
8458 X"$as_dir" : 'X\(//\)[^/]' \| \
8459 X"$as_dir" : 'X\(//\)$' \| \
8460 X"$as_dir" : 'X\(/\)' \| \
8461 . : '\(.\)' 2>/dev/null ||
8462 echo X"$as_dir" |
8463 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
8464 /^X\(\/\/\)[^/].*/{ s//\1/; q; }
8465 /^X\(\/\/\)$/{ s//\1/; q; }
8466 /^X\(\/\).*/{ s//\1/; q; }
8467 s/.*/./; q'`
8468 done
8469 test ! -n "$as_dirs" || mkdir $as_dirs
8470 fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
8471 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
8472 { (exit 1); exit 1; }; }; }
8473
8474 rm -f $ac_file
8475 mv $tmp/config.h $ac_file
8476 fi
8477 else
8478 cat $tmp/config.h
8479 rm -f $tmp/config.h
8480 fi
8481 done
8482 _ACEOF
8483
8484 cat >>$CONFIG_STATUS <<\_ACEOF
8485
8486 { (exit 0); exit 0; }
8487 _ACEOF
8488 chmod +x $CONFIG_STATUS
8489 ac_clean_files=$ac_clean_files_save
8490
8491
8492 # configure is writing to config.log, and then calls config.status.
8493 # config.status does its own redirection, appending to config.log.
8494 # Unfortunately, on DOS this fails, as config.log is still kept open
8495 # by configure, so config.status won't be able to write to it; its
8496 # output is simply discarded. So we exec the FD to /dev/null,
8497 # effectively closing config.log, so it can be properly (re)opened and
8498 # appended to by config.status. When coming back to configure, we
8499 # need to make the FD available again.
8500 if test "$no_create" != yes; then
8501 ac_cs_success=:
8502 ac_config_status_args=
8503 test "$silent" = yes &&
8504 ac_config_status_args="$ac_config_status_args --quiet"
8505 exec 5>/dev/null
8506 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
8507 exec 5>>config.log
8508 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
8509 # would make configure fail if this is the last instruction.
8510 $ac_cs_success || { (exit 1); exit 1; }
8511 fi
8512
8513
8514 echo ""
8515 echo "* Many thanks for using nfdump tools"
8516 echo "* You may want to subscribe to the nfdump-discuss and/or"
8517 echo "* nfsen-discuss mailing list:"
8518 echo "* http://lists.sourceforge.net/lists/listinfo/nfdump-discuss"
8519 echo "* http://lists.sourceforge.net/lists/listinfo/nfsen-discuss"
8520 echo "* Please send bug reports back to me: peter.haag@switch.ch"
8521 echo "* or to one of the lists."
8522
0 .TH ft2nfdump 1 2005-08-19 "" ""
1 .SH NAME
2 ft2nfdump \- flow-tools data converter program
3 .SH SYNOPSIS
4 .HP 5
5 .B ft2nfdump [options]
6 .SH DESCRIPTION
7 .B ft2nfdump
8 is the flow-tools converter program to read, convert and store netflow
9 data, created with the flow-tools package. It works either as a pipe filter
10 or reads flow-tools data format directly from file and exports nfdump data format
11 at stdout.
12
13 .SH OPTIONS
14 .TP 3
15 .B -r <flow-tools-file>
16 Read flow-tools formated netflow data from file \fIflow-tools-file.
17 Default: Read from stdin.
18 .TP 3
19 .B -E
20 Print raw netflow records to stdout. This option is for debugging purpose
21 only, to see any incoming netflow data. Compatible to option -E in nfcapd.
22 .TP 3
23 .B -V
24 Print ft2nfdump version and exit.
25 .TP 3
26 .B -h
27 Print help text on stdout with all options and exit.
28 .SH "RETURN VALUE"
29 Returns
30 .PD 0
31 .RS 4
32 0 No error. \fn
33 .P
34 255 Conversion failed.
35 .RE
36 .PD
37 .SH "EXAMPLES"
38 .B flow-cat ft-v05.2001-05-01.* | ft2nfdump | nfdump -w nfcap.20010501
39 Convert files into nfdump format.
40 .P
41 .B ft2nfdump -r ft-v05.2001-05-01 | nfdump -w nfcap.20010501
42 Convert files into nfdump format.
43 .P
44 .SH NOTES
45 .P
46 .SH "SEE ALSO"
47 nfcapd(1), nfdump(1), nfprofile(1), nfreplay(1)
48 .SH BUGS
0 /*
1 * Copyright (c) 2001 Mark Fullmer and The Ohio State University
2 * All rights reserved.
3
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Flow-Tools related code taken from flow-tools-0.67 cretated by Mark Fullmer
32 *
33 * $Author: peter $
34 *
35 * $Id: ft2nfdump.c 53 2005-11-17 07:45:34Z peter $
36 *
37 * $LastChangedRevision: 53 $
38 *
39 *
40 */
41
42 #include <ftlib.h>
43
44 #include <sys/time.h>
45 #include <sys/types.h>
46 #include <sys/uio.h>
47 #include <netinet/in.h>
48 #include <unistd.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <time.h>
52 #include <fcntl.h>
53
54 #include <string.h>
55 #include <errno.h>
56 #include "ftbuild.h"
57
58 #include <sys/stat.h>
59
60 #include "config.h"
61
62 #ifdef HAVE_STDINT_H
63 #include <stdint.h>
64 #endif
65
66 #include "version.h"
67 #include "nf_common.h"
68
69 /* Global defines */
70 #define MAXRECORDS 30
71
72 /* Global consts */
73 static int const BUFFSIZE = sizeof(flow_header_t) + MAXRECORDS * sizeof(flow_record_t);
74 static char const *vers_id = "$Id: ft2nfdump.c 53 2005-11-17 07:45:34Z peter $";
75
76 /* prototypes */
77 void usage(char *name);
78
79 int flows2nfdump(struct ftio *ftio, int extended);
80
81 void usage(char *name) {
82 printf("usage %s [options] \n"
83 "-h\t\tthis text you see right here.\n"
84 "-E\t\tDump records in ASCII extended format to stdout.\n"
85 "-V\t\tPrint version and exit.\n"
86 "-r\t\tread input from file\n"
87 "Convert flow-tools format to nfdump format:\n"
88 "ft2nfdump -r <flow-tools-data-file> | nfdump -w <nfdump-file>\n"
89 , name);
90
91 } // End of usage
92
93 int flows2nfdump(struct ftio *ftio, int extended) {
94 struct fttime ftt;
95 struct fts3rec_offsets fo;
96 struct ftver ftv;
97 flow_header_t *nf_header;
98 flow_record_t *record_buff, *nf_record;
99 char *rec, *string;
100 uint32_t when, unix_secs, unix_nsecs, sysUpTime;
101 int rec_count;
102 void *flow_buff;
103
104 /* setup memory buffer */
105 flow_buff = malloc(BUFFSIZE);
106 if ( !flow_buff ) {
107 fterr_errx(1, "Buffer allocation error: %s.", strerror(errno));
108 }
109 nf_header = (flow_header_t *)flow_buff;
110 record_buff = (flow_record_t *)(flow_buff + sizeof(flow_header_t));
111 rec_count = 0;
112
113 /* Init defaults in header */
114 nf_header->version = 5;
115 nf_header->count = MAXRECORDS;
116 nf_header->flow_sequence = 1;
117 nf_header->engine_type = 0;
118 nf_header->engine_id = 0;
119 nf_header->layout_version = 1;
120
121 if (ftio_check_xfield(ftio, FT_XFIELD_DPKTS |
122 FT_XFIELD_DOCTETS | FT_XFIELD_FIRST | FT_XFIELD_LAST | FT_XFIELD_INPUT |
123 FT_XFIELD_OUTPUT | FT_XFIELD_SRCADDR | FT_XFIELD_DSTADDR |
124 FT_XFIELD_SRCPORT | FT_XFIELD_DSTPORT | FT_XFIELD_SRC_AS | FT_XFIELD_DST_AS |
125 FT_XFIELD_UNIX_SECS | FT_XFIELD_UNIX_NSECS | FT_XFIELD_SYSUPTIME |
126 FT_XFIELD_TOS | FT_XFIELD_TCP_FLAGS | FT_XFIELD_PROT)) {
127 fterr_warnx("Flow record missing required field for format.");
128 return -1;
129 }
130
131 ftio_get_ver(ftio, &ftv);
132 fts3rec_compute_offsets(&fo, &ftv);
133
134 while ((rec = ftio_read(ftio))) {
135 nf_record = &record_buff[rec_count];
136
137 nf_record->pad = 0;
138 nf_record->nexthop = 0;
139
140 nf_record->dOctets = *((u_int32*)(rec+fo.dOctets));
141 nf_record->dPkts = *((u_int32*)(rec+fo.dPkts));
142
143 unix_secs = *((u_int32*)(rec+fo.unix_secs));
144 unix_nsecs = *((u_int32*)(rec+fo.unix_nsecs));
145 sysUpTime = *((u_int32*)(rec+fo.sysUpTime));
146
147 when = *((u_int32*)(rec+fo.First));
148 ftt = ftltime(sysUpTime, unix_secs, unix_nsecs, when);
149 nf_record->First = ftt.secs;
150 nf_record->msec_first = ftt.msecs;
151
152 when = *((u_int32*)(rec+fo.Last));
153 ftt = ftltime(sysUpTime, unix_secs, unix_nsecs, when);
154 nf_record->Last = ftt.secs;
155 nf_record->msec_last = ftt.msecs;
156
157 nf_record->srcaddr = *((u_int32*)(rec+fo.srcaddr));
158 nf_record->dstaddr = *((u_int32*)(rec+fo.dstaddr));
159 nf_record->input = *((u_int16*)(rec+fo.input));
160 nf_record->output = *((u_int16*)(rec+fo.output));
161 nf_record->srcport = *((u_int16*)(rec+fo.srcport));
162 nf_record->dstport = *((u_int16*)(rec+fo.dstport));
163 nf_record->prot = *((u_int8*)(rec+fo.prot));
164 nf_record->tcp_flags = *((u_int8*)(rec+fo.tcp_flags));
165 nf_record->tos = *((u_int8*)(rec+fo.tos));
166 nf_record->src_as = *((u_int16*)(rec+fo.src_as));
167 nf_record->dst_as = *((u_int16*)(rec+fo.dst_as));
168
169 rec_count++;
170 if ( rec_count == MAXRECORDS ) {
171 rec_count = 0;
172 if ( !extended ) {
173 nf_header->flow_sequence += MAXRECORDS;
174 nf_header->SysUptime = *((u_int32*)(rec+fo.sysUpTime));
175 nf_header->unix_secs = *((u_int32*)(rec+fo.unix_secs));
176 nf_header->unix_nsecs = *((u_int32*)(rec+fo.unix_nsecs));
177 write(STDOUT_FILENO, flow_buff, BUFFSIZE);
178 }
179 }
180
181 if ( extended ) {
182 flow_record_raw(nf_record, 0, 0, 0, &string, 0);
183 printf("%s\n", string);
184 }
185
186
187 } /* while */
188
189 // write the last records in buffer
190 if ( !extended && rec_count ) {
191 nf_header->count = rec_count;
192 nf_header->flow_sequence += rec_count;
193 write(STDOUT_FILENO, flow_buff, sizeof(flow_header_t) + rec_count * sizeof(flow_record_t));
194 }
195 free(flow_buff);
196
197 return 0;
198
199 } // End of flows2nfdump
200
201 int main(int argc, char **argv) {
202 struct ftio ftio;
203 struct stat statbuf;
204 int i, extended, ret, fd;
205 char *ftfile;
206
207 /* init fterr */
208 fterr_setid(argv[0]);
209
210 extended = 0;
211 ftfile = NULL;
212
213 while ((i = getopt(argc, argv, "EVhr:?")) != -1)
214 switch (i) {
215 case 'h': /* help */
216 case '?':
217 usage(argv[0]);
218 exit (0);
219 break;
220
221 case 'V':
222 printf("%s: Version: %s %s\n%s\n",argv[0], nfdump_version, nfdump_date, vers_id);
223 exit(0);
224 break;
225
226 case 'E':
227 extended = 1;
228 break;
229
230 case 'r':
231 ftfile = optarg;
232 if ( (stat(ftfile, &statbuf) < 0 ) || !(statbuf.st_mode & S_IFREG) ) {
233 fprintf(stderr, "No such file: '%s'\n", ftfile);
234 exit(255);
235 }
236 break;
237
238 default:
239 usage(argv[0]);
240 exit (1);
241 break;
242
243 } /* switch */
244
245 if (argc - optind)
246 fterr_errx(1, "Extra arguments starting with %s.", argv[optind]);
247
248 if ( ftfile ) {
249 fd = open(ftfile, O_RDONLY, 0);
250 if ( fd < 0 ) {
251 fprintf(stderr, "Can't open file '%s': %s.", ftfile, strerror(errno));
252 exit(255);
253 }
254 } else {
255 fd = 0;
256 }
257
258 /* read from fd */
259 if (ftio_init(&ftio, fd, FT_IO_FLAG_READ) < 0)
260 fterr_errx(1, "ftio_init(): failed");
261
262 ret = flows2nfdump(&ftio, extended);
263
264 return ret;
265
266 } // End of main
267
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: grammar.y 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 *
37 *
38 */
39
40 %{
41
42 #include <stdio.h>
43 #include <sys/types.h>
44 #include <string.h>
45 #include <stdlib.h>
46
47 #include "config.h"
48
49 #ifdef HAVE_STDINT_H
50 #include <stdint.h>
51 #endif
52
53 #include "nfdump.h"
54 #include "nftree.h"
55
56 /*
57 * function prototypes
58 */
59 static void yyerror(char *msg);
60
61 static uint32_t stoipaddr(char *s, uint32_t *ipaddr);
62
63 enum { SOURCE = 1, DESTINATION, SOURCE_AND_DESTINATION, SOURCE_OR_DESTINATION };
64
65 /* var defs */
66 extern int lineno;
67 extern char *yytext;
68 extern uint32_t StartNode;
69 extern uint16_t Extended;
70 extern int (*FilterEngine)(uint32_t *);
71
72 %}
73
74 %union {
75 uint32_t value;
76 char *s;
77 FilterParam_t param;
78 }
79
80 %token ANY IP IF NEXT TCP UDP ICMP GRE ESP AH RSVP PROTO TOS FLAGS HOST NET PORT IN OUT SRC DST EQ LT GT
81 %token NUMBER QUADDOT ALPHA_FLAGS PORTNUM ICMPTYPE AS PACKETS BYTES PPS BPS BPP DURATION
82 %token NOT END
83 %type <value> expr NUMBER PORTNUM NETNUM ICMPTYPE
84 %type <s> QUADDOT ALPHA_FLAGS
85 %type <param> dqual inout term comp scale
86
87 %left '+' OR
88 %left '*' AND
89 %left NEGATE
90
91 %%
92 prog: /* empty */
93 | expr {
94 StartNode = $1;
95 }
96 ;
97
98 term: ANY { /* this is an unconditionally true expression, as a filter applies in any case */
99 $$.self = NewBlock(OffsetProto, 0, 0, CMP_EQ, FUNC_NONE ); }
100
101 | ICMP { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(1 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
102
103 | TCP { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(6 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
104
105 | UDP { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(17 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
106
107 | RSVP { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(46 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
108
109 | GRE { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(47 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
110
111 | ESP { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(50 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
112
113 | AH { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)(51 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
114
115 | PROTO NUMBER { $$.self = NewBlock(OffsetProto, MaskProto, (uint32_t)($2 << ShiftProto) & MaskProto, CMP_EQ, FUNC_NONE); }
116 | PACKETS comp NUMBER scale {
117 $$.self = NewBlock(OffsetPackets, MaskSize, (uint32_t)$3 * $4.scale, $2.comp, FUNC_NONE);
118 }
119
120 | BYTES comp NUMBER scale {
121 $$.self = NewBlock(OffsetBytes, MaskSize, (uint32_t)$3 * $4.scale , $2.comp, FUNC_NONE);
122 }
123
124 | PPS comp NUMBER scale {
125 $$.self = NewBlock(0, AnyMask, (uint32_t)$3 * $4.scale , $2.comp, FUNC_PPS);
126 }
127
128 | BPS comp NUMBER scale {
129 $$.self = NewBlock(0, AnyMask, (uint32_t)$3 * $4.scale , $2.comp, FUNC_BPS);
130 }
131
132 | BPP comp NUMBER scale {
133 $$.self = NewBlock(0, AnyMask, (uint32_t)$3 * $4.scale , $2.comp, FUNC_BPP);
134 }
135
136 | DURATION comp NUMBER {
137 $$.self = NewBlock(0, AnyMask, (uint32_t)$3, $2.comp, FUNC_DURATION);
138 }
139
140 | TOS comp NUMBER {
141 if ( $3 > 255 ) {
142 yyerror("TOS must be 0..255");
143 YYABORT;
144 }
145 $$.self = NewBlock(OffsetTos, MaskTos, (uint32_t)($3 << ShiftTos) & MaskTos, $2.comp, FUNC_NONE);
146
147 }
148
149 | FLAGS comp NUMBER { if ( $3 > 63 ) {
150 yyerror("Flags must be 0..63");
151 YYABORT;
152 }
153 $$.self = NewBlock(OffsetFlags, MaskFlags, (uint32_t)($3 << ShiftFlags) & MaskFlags, $2.comp, FUNC_NONE);
154 }
155
156 | FLAGS ALPHA_FLAGS {
157 int fl = 0;
158 if ( strlen($2) > 7 ) {
159 yyerror("Too many flags");
160 YYABORT;
161 }
162
163 if ( strchr($2, 'F') ) fl |= 1;
164 if ( strchr($2, 'S') ) fl |= 2;
165 if ( strchr($2, 'R') ) fl |= 4;
166 if ( strchr($2, 'P') ) fl |= 8;
167 if ( strchr($2, 'A') ) fl |= 16;
168 if ( strchr($2, 'U') ) fl |= 32;
169 if ( strchr($2, 'X') ) fl = 63;
170
171 $$.self = NewBlock(OffsetFlags, (uint32_t)(fl << ShiftFlags) & MaskFlags, (uint32_t)(fl << ShiftFlags) & MaskFlags, CMP_EQ, FUNC_NONE);
172 }
173
174 | dqual HOST QUADDOT { if ( !stoipaddr($3, &$$.ip) )
175 YYABORT;
176 $$.direction = $1.direction;
177 if ( $$.direction == SOURCE ) {
178 $$.self = NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE );
179 } else if ( $$.direction == DESTINATION) {
180 $$.self = NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE );
181 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
182 $$.self = Connect_OR(
183 NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE ),
184 NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE )
185 );
186 } else if ( $$.direction == SOURCE_AND_DESTINATION ) {
187 $$.self = Connect_AND(
188 NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE ),
189 NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE )
190 );
191 } else {
192 /* should never happen */
193 yyerror("Internal parser error");
194 YYABORT;
195 }
196 }
197
198 | dqual IP QUADDOT { if ( !stoipaddr($3, &$$.ip) )
199 YYABORT;
200
201 $$.direction = $1.direction;
202 if ( $$.direction == SOURCE ) {
203 $$.self = NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE );
204 } else if ( $$.direction == DESTINATION) {
205 $$.self = NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE );
206 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
207 $$.self = Connect_OR(
208 NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE ),
209 NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE )
210 );
211 } else if ( $$.direction == SOURCE_AND_DESTINATION ) {
212 $$.self = Connect_AND(
213 NewBlock(OffsetSrcIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE ),
214 NewBlock(OffsetDstIP, MaskIP, $$.ip, CMP_EQ, FUNC_NONE )
215 );
216 } else {
217 /* should never happen */
218 yyerror("Internal parser error");
219 YYABORT;
220 }
221
222 }
223
224 | NEXT QUADDOT { if ( !stoipaddr($2, &$$.ip) )
225 YYABORT;
226
227 $$.self = NewBlock(OffsetNext, MaskIP, $$.ip, CMP_EQ, FUNC_NONE );
228
229 }
230
231 | dqual PORT comp NUMBER { $$.direction = $1.direction;
232 if ( $4 > 65535 ) {
233 yyerror("Port outside of range 0..65535");
234 YYABORT;
235 }
236
237 if ( $$.direction == SOURCE ) {
238 $$.self = NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE );
239 } else if ( $$.direction == DESTINATION) {
240 $$.self = NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE );
241 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
242 $$.self = Connect_OR(
243 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE ),
244 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE )
245 );
246 } else if ( $$.direction == SOURCE_AND_DESTINATION ) {
247 $$.self = Connect_AND(
248 NewBlock(OffsetPort, MaskSrcPort, ($4 << ShiftSrcPort) & MaskSrcPort, $3.comp, FUNC_NONE ),
249 NewBlock(OffsetPort, MaskDstPort, ($4 << ShiftDstPort) & MaskDstPort, $3.comp, FUNC_NONE )
250 );
251 } else {
252 /* should never happen */
253 yyerror("Internal parser error");
254 YYABORT;
255 }
256 }
257
258 | dqual AS NUMBER { $$.direction = $1.direction;
259 if ( $3 > 65535 || $3 < 1 ) {
260 yyerror("AS number outside of range 1..65535");
261 YYABORT;
262 }
263
264 if ( $$.direction == SOURCE ) {
265 $$.self = NewBlock(OffsetAS, MaskSrcAS, ($3 << ShiftSrcAS) & MaskSrcAS, CMP_EQ, FUNC_NONE );
266 } else if ( $$.direction == DESTINATION) {
267 $$.self = NewBlock(OffsetAS, MaskDstAS, ($3 << ShiftDstAS) & MaskDstAS, CMP_EQ, FUNC_NONE);
268 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
269 $$.self = Connect_OR(
270 NewBlock(OffsetAS, MaskSrcAS, ($3 << ShiftSrcAS) & MaskSrcAS, CMP_EQ, FUNC_NONE ),
271 NewBlock(OffsetAS, MaskDstAS, ($3 << ShiftDstAS) & MaskDstAS, CMP_EQ, FUNC_NONE)
272 );
273 } else if ( $$.direction == SOURCE_AND_DESTINATION ) {
274 $$.self = Connect_AND(
275 NewBlock(OffsetPort, MaskSrcAS, ($3 << ShiftSrcAS) & MaskSrcAS, CMP_EQ, FUNC_NONE ),
276 NewBlock(OffsetPort, MaskDstAS, ($3 << ShiftDstAS) & MaskDstAS, CMP_EQ, FUNC_NONE)
277 );
278 } else {
279 /* should never happen */
280 yyerror("Internal parser error");
281 YYABORT;
282 }
283 }
284
285 | dqual NET QUADDOT NETNUM { if ( !stoipaddr($3, &$$.ip) )
286 YYABORT;
287 $$.direction = $1.direction;
288 if ( $$.direction == SOURCE ) {
289 $$.self = NewBlock(OffsetSrcIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE);
290 } else if ( $$.direction == DESTINATION) {
291 $$.self = NewBlock(OffsetDstIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE);
292 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
293 $$.self = Connect_OR(
294 NewBlock(OffsetSrcIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE),
295 NewBlock(OffsetDstIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE)
296 );
297 } else if ( $$.direction == SOURCE_AND_DESTINATION ) {
298 $$.self = Connect_AND(
299 NewBlock(OffsetSrcIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE),
300 NewBlock(OffsetDstIP, $4, $$.ip & $4, CMP_EQ, FUNC_NONE)
301 );
302 } else {
303 /* should never happen */
304 yyerror("Internal parser error");
305 YYABORT;
306 }
307
308 }
309
310 | inout IF NUMBER {
311 if ( $3 > 65535 ) {
312 yyerror("Input interface number must be 0..65535");
313 YYABORT;
314 }
315 if ( $$.direction == SOURCE ) {
316 $$.self = NewBlock(OffsetInOut, MaskInput, (uint32_t)($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE);
317 } else if ( $$.direction == DESTINATION) {
318 $$.self = NewBlock(OffsetInOut, MaskOutput, (uint32_t)($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE);
319 } else if ( $$.direction == SOURCE_OR_DESTINATION ) {
320 $$.self = Connect_OR(
321 NewBlock(OffsetInOut, MaskInput, (uint32_t)($3 << ShiftInput) & MaskInput, CMP_EQ, FUNC_NONE),
322 NewBlock(OffsetInOut, MaskOutput, (uint32_t)($3 << ShiftOutput) & MaskOutput, CMP_EQ, FUNC_NONE)
323 );
324 } else {
325 /* should never happen */
326 yyerror("Internal parser error");
327 YYABORT;
328 }
329 }
330
331 | ICMP ICMPTYPE { $$.proto = 1;
332
333 }
334 ;
335
336 NETNUM: QUADDOT { if ( !stoipaddr($1, &$$) )
337 YYABORT;
338 }
339 | '/' NUMBER { if ( $2 > 32 || $2 < 1 ) {
340 yyerror("Mask bits outside of range 1..32");
341 YYABORT;
342 }
343 $$ = 0xffffffff << ( 32 - $2 );
344 /* $$ = !( 1 << ( $2 -1 ) ); */
345
346 }
347 ;
348
349 /* scaling qualifiers */
350 scale: { $$.scale = 1; }
351 | 'k' { $$.scale = 1024; }
352 | 'm' { $$.scale = 1024*1024; }
353 | 'g' { $$.scale = 1024*1024*1024; }
354 ;
355
356 /* comparator qualifiers */
357 comp: { $$.comp = CMP_EQ; }
358 | EQ { $$.comp = CMP_EQ; }
359 | LT { $$.comp = CMP_LT; }
360 | GT { $$.comp = CMP_GT; }
361 ;
362
363 /* 'direction' qualifiers */
364 dqual: { $$.direction = SOURCE_OR_DESTINATION; }
365 | SRC { $$.direction = SOURCE; }
366 | DST { $$.direction = DESTINATION; }
367 | SRC OR DST { $$.direction = SOURCE_OR_DESTINATION; }
368 | DST OR SRC { $$.direction = SOURCE_OR_DESTINATION; }
369 | SRC AND DST { $$.direction = SOURCE_AND_DESTINATION; }
370 | DST AND SRC { $$.direction = SOURCE_AND_DESTINATION; }
371 ;
372
373 inout: { $$.direction = SOURCE_OR_DESTINATION; }
374 | IN { $$.direction = SOURCE; }
375 | OUT { $$.direction = DESTINATION; }
376 ;
377
378 expr: term { $$ = $1.self; }
379 | expr OR expr { $$ = Connect_OR($1, $3); }
380 | expr AND expr { $$ = Connect_AND($1, $3); }
381 | NOT expr %prec NEGATE { $$ = Invert($2); }
382 | '(' expr ')' { $$ = $2; }
383 ;
384
385 %%
386
387 static void yyerror(char *msg) {
388 fprintf(stderr,"line %d: %s at '%s'\n", lineno, msg, yytext);
389 } /* End of yyerror */
390
391 uint32_t stoipaddr(char *s, uint32_t *ipaddr) {
392 uint n, i;
393 char *p, *q;
394
395 *ipaddr = 0;
396 p = s;
397 for ( i=0; i < 4; i++ ) {
398 if ( p ) {
399 if ((q = strchr(p,'.')) != NULL ) {
400 *q = 0;
401 }
402 n = atoi(p);
403 if ( n < 0 || n > 255 ) {
404 yyerror("Bad IP address");
405 return 0;
406 }
407 if ( q )
408 p = q + 1;
409 else
410 p = NULL;
411 } else {
412 n = 0;
413 }
414 *ipaddr = ( *ipaddr << 8 ) | n;
415 }
416 return 1;
417
418 } /* End of stoipaddr */
419
420
0 #!/bin/sh
1 #
2 # install - install a program, script, or datafile
3 # This comes from X11R5 (mit/util/scripts/install.sh).
4 #
5 # Copyright 1991 by the Massachusetts Institute of Technology
6 #
7 # Permission to use, copy, modify, distribute, and sell this software and its
8 # documentation for any purpose is hereby granted without fee, provided that
9 # the above copyright notice appear in all copies and that both that
10 # copyright notice and this permission notice appear in supporting
11 # documentation, and that the name of M.I.T. not be used in advertising or
12 # publicity pertaining to distribution of the software without specific,
13 # written prior permission. M.I.T. makes no representations about the
14 # suitability of this software for any purpose. It is provided "as is"
15 # without express or implied warranty.
16 #
17 # Calling this script install-sh is preferred over install.sh, to prevent
18 # `make' implicit rules from creating a file called install from it
19 # when there is no Makefile.
20 #
21 # This script is compatible with the BSD install script, but was written
22 # from scratch. It can only install one file at a time, a restriction
23 # shared with many OS's install programs.
24
25
26 # set DOITPROG to echo to test this script
27
28 # Don't use :- since 4.3BSD and earlier shells don't like it.
29 doit="${DOITPROG-}"
30
31
32 # put in absolute paths if you don't have them in your path; or use env. vars.
33
34 mvprog="${MVPROG-mv}"
35 cpprog="${CPPROG-cp}"
36 chmodprog="${CHMODPROG-chmod}"
37 chownprog="${CHOWNPROG-chown}"
38 chgrpprog="${CHGRPPROG-chgrp}"
39 stripprog="${STRIPPROG-strip}"
40 rmprog="${RMPROG-rm}"
41 mkdirprog="${MKDIRPROG-mkdir}"
42
43 transformbasename=""
44 transform_arg=""
45 instcmd="$mvprog"
46 chmodcmd="$chmodprog 0755"
47 chowncmd=""
48 chgrpcmd=""
49 stripcmd=""
50 rmcmd="$rmprog -f"
51 mvcmd="$mvprog"
52 src=""
53 dst=""
54 dir_arg=""
55
56 while [ x"$1" != x ]; do
57 case $1 in
58 -c) instcmd="$cpprog"
59 shift
60 continue;;
61
62 -d) dir_arg=true
63 shift
64 continue;;
65
66 -m) chmodcmd="$chmodprog $2"
67 shift
68 shift
69 continue;;
70
71 -o) chowncmd="$chownprog $2"
72 shift
73 shift
74 continue;;
75
76 -g) chgrpcmd="$chgrpprog $2"
77 shift
78 shift
79 continue;;
80
81 -s) stripcmd="$stripprog"
82 shift
83 continue;;
84
85 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
86 shift
87 continue;;
88
89 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
90 shift
91 continue;;
92
93 *) if [ x"$src" = x ]
94 then
95 src=$1
96 else
97 # this colon is to work around a 386BSD /bin/sh bug
98 :
99 dst=$1
100 fi
101 shift
102 continue;;
103 esac
104 done
105
106 if [ x"$src" = x ]
107 then
108 echo "install: no input file specified"
109 exit 1
110 else
111 true
112 fi
113
114 if [ x"$dir_arg" != x ]; then
115 dst=$src
116 src=""
117
118 if [ -d $dst ]; then
119 instcmd=:
120 chmodcmd=""
121 else
122 instcmd=mkdir
123 fi
124 else
125
126 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
127 # might cause directories to be created, which would be especially bad
128 # if $src (and thus $dsttmp) contains '*'.
129
130 if [ -f $src -o -d $src ]
131 then
132 true
133 else
134 echo "install: $src does not exist"
135 exit 1
136 fi
137
138 if [ x"$dst" = x ]
139 then
140 echo "install: no destination specified"
141 exit 1
142 else
143 true
144 fi
145
146 # If destination is a directory, append the input filename; if your system
147 # does not like double slashes in filenames, you may need to add some logic
148
149 if [ -d $dst ]
150 then
151 dst="$dst"/`basename $src`
152 else
153 true
154 fi
155 fi
156
157 ## this sed command emulates the dirname command
158 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
159
160 # Make sure that the destination directory exists.
161 # this part is taken from Noah Friedman's mkinstalldirs script
162
163 # Skip lots of stat calls in the usual case.
164 if [ ! -d "$dstdir" ]; then
165 defaultIFS='
166 '
167 IFS="${IFS-${defaultIFS}}"
168
169 oIFS="${IFS}"
170 # Some sh's can't handle IFS=/ for some reason.
171 IFS='%'
172 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
173 IFS="${oIFS}"
174
175 pathcomp=''
176
177 while [ $# -ne 0 ] ; do
178 pathcomp="${pathcomp}${1}"
179 shift
180
181 if [ ! -d "${pathcomp}" ] ;
182 then
183 $mkdirprog "${pathcomp}"
184 else
185 true
186 fi
187
188 pathcomp="${pathcomp}/"
189 done
190 fi
191
192 if [ x"$dir_arg" != x ]
193 then
194 $doit $instcmd $dst &&
195
196 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
197 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
198 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
199 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
200 else
201
202 # If we're going to rename the final executable, determine the name now.
203
204 if [ x"$transformarg" = x ]
205 then
206 dstfile=`basename $dst`
207 else
208 dstfile=`basename $dst $transformbasename |
209 sed $transformarg`$transformbasename
210 fi
211
212 # don't allow the sed command to completely eliminate the filename
213
214 if [ x"$dstfile" = x ]
215 then
216 dstfile=`basename $dst`
217 else
218 true
219 fi
220
221 # Make a temp file name in the proper directory.
222
223 dsttmp=$dstdir/#inst.$$#
224
225 # Move or copy the file name to the temp name
226
227 $doit $instcmd $src $dsttmp &&
228
229 trap "rm -f ${dsttmp}" 0 &&
230
231 # and set any options; do chmod last to preserve setuid bits
232
233 # If any of these fail, we abort the whole thing. If we want to
234 # ignore errors from any of these, just make sure not to ignore
235 # errors from the above "$doit $instcmd $src $dsttmp" command.
236
237 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
238 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
239 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
240 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
241
242 # Now rename the file to the real destination.
243
244 $doit $rmcmd -f $dstdir/$dstfile &&
245 $doit $mvcmd $dsttmp $dstdir/$dstfile
246
247 fi &&
248
249
250 exit 0
0 /*
1 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of SWITCH nor the names of its contributors may be
13 * used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Author: peter $
29 *
30 * $Id: launch.c 34 2005-08-22 12:01:31Z peter $
31 *
32 * $LastChangedRevision: 34 $
33 *
34 *
35 */
36
37 #include <signal.h>
38 #include <sys/types.h>
39 #include <sys/time.h>
40 #include <sys/resource.h>
41 #include <sys/wait.h>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <syslog.h>
46 #include <stdarg.h>
47 #include <errno.h>
48 #include <unistd.h>
49
50 #include "launch.h"
51
52 static int done, launch, child_exit;
53
54 static void SignalHandler(int signal);
55
56 static char *cmd_expand(srecord_t *InfoRecord, char *datadir, char *process);
57
58 static void cmd_parse(char *buf, char **args);
59
60 static void cmd_execute(char **args);
61
62 #define MAXARGS 256
63 #define MAXCMDLEN 4096
64
65 static void SignalHandler(int signal) {
66
67 switch (signal) {
68 case SIGTERM:
69 // in case the process will not terminate, we
70 // kill the process directly after the 2nd TERM signal
71 if ( done > 1 )
72 exit(234);
73 done++;
74 break;
75 case SIGHUP:
76 launch = 1;
77 break;
78 case SIGCHLD:
79 child_exit = 1;
80 break;
81 }
82
83 } /* End of IntHandler */
84
85 /*
86 * Expand % placeholders in command string
87 * expand the memory needed in the command string and replace placeholders
88 * prevent endless expansion
89 */
90 static char *cmd_expand(srecord_t *InfoRecord, char *datadir, char *process) {
91 char *q, *s, tmp[16];
92 int i;
93
94 q = strdup(process);
95 if ( !q ) {
96 perror("Process cmdline");
97 return NULL;
98 }
99 i = 0;
100
101 while ( q[i] ) {
102 if ( (q[i] == '%') && q[i+1] ) {
103 // replace the %x var
104 switch ( q[i+1] ) {
105 case 'd' :
106 s = datadir;
107 break;
108 case 'f' :
109 s = InfoRecord->fname;
110 break;
111 case 't' :
112 s = InfoRecord->tstring;
113 break;
114 case 'u' :
115 #if defined __OpenBSD__ || defined __FreeBSD__
116 snprintf(tmp, 16, "%i", InfoRecord->tstamp);
117 #else
118 snprintf(tmp, 16, "%li", InfoRecord->tstamp);
119 #endif
120 tmp[15] = 0;
121 s = tmp;
122 break;
123 case 'i' :
124 s = InfoRecord->ident;
125 break;
126 default:
127 syslog(LOG_ERR, "Unknown format token '%%%c'\n", q[i+1]);
128 s = NULL;
129 }
130 if ( s ) {
131 q = realloc(q, strlen(q) + strlen(s));
132 if ( !q ) {
133 perror("Process cmdline");
134 return NULL;
135 }
136 // be a bit paranoid and prevent endless expansion
137 if ( strlen(q) > MAXCMDLEN ) {
138 // this is fishy
139 syslog(LOG_ERR, "Error: cmdline too long!\n");
140 return NULL;
141 }
142 memmove(&q[i] + strlen(s), &q[i+2], strlen(&q[i+2]) + 1); // include trailing '0' in memmove
143 memcpy(&q[i], s, strlen(s));
144 }
145 }
146 i++;
147 }
148
149 return q;
150
151 } // End of cmd_expand
152
153 /*
154 * split the command in buf into individual arguments.
155 */
156 static void cmd_parse(char *buf, char **args) {
157 int i, argnum;
158
159 i = argnum = 0;
160 while ( (i < MAXCMDLEN) && (buf[i] != 0) ) {
161
162 /*
163 * Strip whitespace. Use nulls, so
164 * that the previous argument is terminated
165 * automatically.
166 */
167 while ( (i < MAXCMDLEN) && ((buf[i] == ' ') || (buf[i] == '\t')))
168 buf[i++] = 0;
169
170 /*
171 * Save the argument.
172 */
173 if ( argnum < MAXARGS )
174 args[argnum++] = &(buf[i]);
175
176 /*
177 * Skip over the argument.
178 */
179 while ( (i < MAXCMDLEN) && ((buf[i] != 0) && (buf[i] != ' ') && (buf[i] != '\t')))
180 i++;
181 }
182
183 if ( argnum < MAXARGS )
184 args[argnum] = NULL;
185
186 if ( (i >= MAXCMDLEN) || (argnum >= MAXARGS) ) {
187 // for safety reason, disable the command
188 args[0] = NULL;
189 syslog(LOG_ERR, "Launcher: Unable to parse command: '%s'", buf);
190 }
191
192 } // End of cmd_parse
193
194 /*
195 * cmd_execute
196 * spawn a child process and execute the program.
197 */
198 static void cmd_execute(char **args) {
199 int pid;
200
201 // Get a child process.
202 if ((pid = fork()) < 0) {
203 syslog(LOG_ERR, "Can't fork: %s", strerror(errno));
204 return;
205 }
206
207 if (pid == 0) { // we are the child
208 execvp(*args, args);
209 syslog(LOG_ERR, "Can't execvp: %s: %s", args[0], strerror(errno));
210 exit(1);
211 }
212
213 // we are the parent
214 /* empty */
215
216 } // End of cmd_execute
217
218 void launcher (char *commbuff, char *datadir, char *process) {
219 struct sigaction act;
220 char *cmd, *s;
221 char *args[MAXARGS];
222 int i, pid, stat;
223 srecord_t *InfoRecord, TestRecord;
224
225 InfoRecord = (srecord_t *)commbuff;
226
227 syslog(LOG_INFO, "Launcher: Startup.");
228 done = launch = child_exit = 0;
229
230 // check for valid command expansion
231 strncpy(TestRecord.fname, "test", FNAME_SIZE-1);
232 TestRecord.fname[FNAME_SIZE-1] = 0;
233 strncpy(TestRecord.tstring, "200407110845", 15);
234 TestRecord.tstring[15] = 0;
235 TestRecord.tstamp = 1;
236 cmd = cmd_expand(&TestRecord, datadir, process);
237 if ( cmd == NULL ) {
238 syslog(LOG_ERR, "Launcher: Unable to expand command: '%s'", process);
239 exit(255);
240 }
241
242 cmd_parse(cmd, args);
243 i = 0;
244 s = args[i];
245
246 /* Signal handling */
247 memset((void *)&act,0,sizeof(struct sigaction));
248 act.sa_handler = SignalHandler;
249 sigemptyset(&act.sa_mask);
250 act.sa_flags = 0;
251 sigaction(SIGCHLD, &act, NULL); // child process terminated
252 sigaction(SIGTERM, &act, NULL); // we are done
253 sigaction(SIGINT, &act, NULL); // we are done
254 sigaction(SIGHUP, &act, NULL); // run command
255
256 while ( !done ) {
257 // sleep until we get signaled
258 select(0, NULL, NULL, NULL, NULL);
259 syslog(LOG_DEBUG, "Launcher: Wakeup");
260 if ( launch ) { // SIGHUP
261 launch = 0;
262
263 // Expand % placeholders
264 cmd = cmd_expand(InfoRecord, datadir, process);
265 if ( cmd == NULL ) {
266 syslog(LOG_ERR, "Launcher: Unable to expand command: '%s'", process);
267 continue;
268 }
269 // printf("Launcher: run command: '%s'\n", cmd);
270 syslog(LOG_DEBUG, "Launcher: run command: '%s'", cmd);
271
272 // prepare args array
273 cmd_parse(cmd, args);
274 if ( args[0] )
275 cmd_execute(args);
276 // else cmd_parse already reported the error
277 }
278 if ( child_exit ) {
279 while ( (pid = waitpid (-1, &stat, 0)) > 0 ) {
280 syslog(LOG_DEBUG, "Launcher: child %i terminated: %i", pid, stat);
281 }
282 child_exit = 0;
283 }
284 }
285
286 waitpid (-1, &stat, 0);
287
288 // we are done
289 syslog(LOG_INFO, "Launcher: Terminating.");
290
291 } // End of launcher
0 /*
1 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of SWITCH nor the names of its contributors may be
13 * used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Author: peter $
29 *
30 * $Id: launch.h 13 2004-12-01 09:19:11Z peter $
31 *
32 * $LastChangedRevision: 13 $
33 *
34 *
35 */
36
37 #define FNAME_SIZE 64
38 #define IDENT_SIZE 32
39
40 typedef struct srecord_s {
41 char fname[FNAME_SIZE]; // file name
42 char ident[IDENT_SIZE]; // -I ident string
43 char tstring[16]; // actually 12 needed e.g. 200411011230
44 time_t tstamp; // UNIX time stamp
45 } srecord_t;
46
47 void launcher (char *commbuff, char *datadir, char *process);
48
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: netflow_v5.h 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 */
37
38 #define NETFLOW_V5_HEADER_LENGTH 24
39 #define NETFLOW_V5_RECORD_LENGTH 48
40 #define NETFLOW_V5_MAX_RECORDS 30
41
42 typedef struct netflow_v5_header {
43 uint16_t version;
44 uint16_t count;
45 uint32_t SysUptime;
46 uint32_t unix_secs;
47 uint32_t unix_nsecs;
48 uint32_t flow_sequence;
49 uint8_t engine_type;
50 uint8_t engine_id;
51 uint16_t reserved;
52 } netflow_v5_header_t;
53
54 typedef struct netflow_v5_record {
55 uint32_t srcaddr;
56 uint32_t dstaddr;
57 uint32_t nexthop;
58 uint16_t input;
59 uint16_t output;
60 uint32_t dPkts;
61 uint32_t dOctets;
62 uint32_t First;
63 uint32_t Last;
64 uint16_t srcport;
65 uint16_t dstport;
66 uint8_t pad1;
67 uint8_t tcp_flags;
68 uint8_t prot;
69 uint8_t tos;
70 uint16_t src_as;
71 uint16_t dst_as;
72 uint8_t src_mask;
73 uint8_t dst_mask;
74 uint16_t pad2;
75 } netflow_v5_record_t;
76
77 /* prototypes */
78
79 void netflow_v5_header_to_string(void *header, char **s);
80
81 void netflow_v5_record_to_block(void *record, char **s);
82
83 void netflow_v5_record_to_line(void *record, char **s);
84
85 void netflow_v5_record_to_line_long(void *record, char **s);
86
87 void netflow_v5_record_to_pipe(void *record, char ** s);
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: netflow_v7.h 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 */
37
38 #define NETFLOW_V7_HEADER_LENGTH 24
39 #define NETFLOW_V7_RECORD_LENGTH 52
40 #define NETFLOW_V7_MAX_RECORDS 28
41
42 typedef struct netflow_v7_header {
43 uint16_t version;
44 uint16_t count;
45 uint32_t SysUptime;
46 uint32_t unix_secs;
47 uint32_t unix_nsecs;
48 uint32_t flow_sequence;
49 uint32_t reserved;
50 } netflow_v7_header_t;
51
52 typedef struct netflow_v7_record {
53 uint32_t srcaddr;
54 uint32_t dstaddr;
55 uint32_t nexthop;
56 uint16_t input;
57 uint16_t output;
58 uint32_t dPkts;
59 uint32_t dOctets;
60 uint32_t First;
61 uint32_t Last;
62 uint16_t srcport;
63 uint16_t dstport;
64 uint8_t flags;
65 uint8_t tcp_flags;
66 uint8_t prot;
67 uint8_t tos;
68 uint16_t src_as;
69 uint16_t dst_as;
70 uint8_t src_mask;
71 uint8_t dst_mask;
72 uint16_t pad;
73 uint32_t router_sc;
74 } netflow_v7_record_t;
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nf_common.c 53 2005-11-17 07:45:34Z peter $
33 *
34 * $LastChangedRevision: 53 $
35 *
36 */
37
38 #include <stdio.h>
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #include <time.h>
44 #include <string.h>
45 #include <stdlib.h>
46
47 #include "config.h"
48
49 #ifdef HAVE_STDINT_H
50 #include <stdint.h>
51 #endif
52
53 #include "nf_common.h"
54 #include "panonymizer.h"
55
56 /* locals */
57 #define STRINGSIZE 1024
58
59 static char string[STRINGSIZE];
60
61 static const double _1KB = 1024.0;
62 static const double _1MB = 1024.0 * 1024.0;
63 static const double _1GB = 1024.0 * 1024.0 * 1024.0;
64 static const double _1TB = 1024.0 * 1024.0 * 1024.0 * 1024.0;
65
66 extern int byte_mode, packet_mode;
67 enum { NONE, LESS, MORE };
68
69 #ifdef __SUNPRO_C
70 extern
71 #endif
72 inline int TimeMsec_CMP(time_t t1, uint16_t offset1, time_t t2, uint16_t offset2 ) {
73
74 if ( t1 > t2 )
75 return 1;
76 if ( t2 > t1 )
77 return 2;
78 // else t1 == t2 - offset is now relevant
79 if ( offset1 > offset2 )
80 return 1;
81 if ( offset2 > offset1 )
82 return 2;
83 else
84 // both times are the same
85 return 0;
86 } // End of TimeMsec_CMP
87
88 void flow_header_raw(void *header, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
89 /* Allocates and fills a string with a verbose representation of
90 the header pased as argument.
91 Result: 0 on success, !=0 on error
92 */
93 char * t;
94 flow_header_t *h = (flow_header_t *)header;
95 time_t now;
96
97 now = h->unix_secs;
98 t = ctime(&now);
99 t[strlen(t)-1] = 0;
100
101 snprintf(string,STRINGSIZE-1 ,""
102 "Flow Header: binary version %2u\n"
103 " count = %10u\n"
104 " SysUptime = %10u\n"
105 " unix_secs = %10d [%s]\n"
106 " unix_nsecs = %10d\n"
107 " flow_sequence = %11u\n"
108 " engine_type = %2d\n"
109 " engine_id = %2d\n",
110 h->layout_version,
111 h->count,
112 h->SysUptime,h->unix_secs,t,h->unix_nsecs,
113 h->flow_sequence,h->engine_type,h->engine_id);
114 *s = string;
115
116 } // End of flow_header_raw
117
118
119 void flow_record_raw(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
120 struct in_addr a,d,n;
121 char as[16], ds[16], ns[16], datestr1[64], datestr2[64];
122 char * str;
123 time_t when;
124 struct tm *ts;
125 flow_record_t *r = (flow_record_t *)record;
126
127 if ( anon ) {
128 if ( r->srcaddr )
129 r->srcaddr = anonymize(r->srcaddr);
130 if ( r->dstaddr )
131 r->dstaddr = anonymize(r->dstaddr);
132
133 r->nexthop = anonymize(r->nexthop);
134 }
135 a.s_addr = htonl(r->srcaddr);
136 d.s_addr = htonl(r->dstaddr);
137 n.s_addr = htonl(r->nexthop);
138 str = inet_ntoa(a);
139 strncpy(as, inet_ntoa(a), 15);
140 str = inet_ntoa(d);
141 strncpy(ds, str, 15);
142 str = inet_ntoa(n);
143 strncpy(ns, str, 15);
144 as[15] = 0;
145 ds[15] = 0;
146 ns[15] = 0;
147
148 when = r->First;
149 ts = localtime(&when);
150 strftime(datestr1, 63, "%Y-%m-%d %H:%M:%S", ts);
151
152 when = r->Last;
153 ts = localtime(&when);
154 strftime(datestr2, 63, "%Y-%m-%d %H:%M:%S", ts);
155
156 snprintf(string, STRINGSIZE-1, "\n"
157 "Flow Record: \n"
158 " addr = %15s\n"
159 " dstaddr = %15s\n"
160 " nexthop = %15s\n"
161 " input = %5u\n"
162 " output = %5u\n"
163 " dPkts = %10llu\n"
164 " dOctets = %10llu\n"
165 " First = %10u [%s]\n"
166 " Last = %10u [%s]\n"
167 " port = %5u\n"
168 " dstport = %5u\n"
169 " tcp_flags = %3u\n"
170 " prot = %3u\n"
171 " tos = %3u\n"
172 " src_as = %5u\n"
173 " dst_as = %5u\n"
174 " msec_first = %5u\n"
175 " msec_last = %5u"
176 ,
177 as, ds, ns,
178 r->input, r->output, pkts, bytes, r->First, datestr1,
179 r->Last, datestr2, r->srcport, r->dstport, r->tcp_flags, r->prot, r->tos,
180 r->src_as, r->dst_as, r->msec_first, r->msec_last );
181
182 string[STRINGSIZE-1] = 0;
183
184 *s = string;
185
186 } // End of flow_record_raw
187
188 void flow_record_to_line(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
189 double duration;
190 time_t tt;
191 struct in_addr a,d;
192 char as[16], ds[16], bytes_str[32], packets_str[32];
193 char *str;
194 char *prot;
195 char prot_long[16], datestr[64];
196 struct tm *ts;
197 flow_record_t *r = (flow_record_t *)record;
198
199 if ( anon ) {
200 if ( r->srcaddr )
201 r->srcaddr = anonymize(r->srcaddr);
202 if ( r->dstaddr )
203 r->dstaddr = anonymize(r->dstaddr);
204 }
205
206 a.s_addr = htonl(r->srcaddr);
207 d.s_addr = htonl(r->dstaddr);
208 str = inet_ntoa(a);
209 strncpy(as, inet_ntoa(a), 15);
210 str = inet_ntoa(d);
211 strncpy(ds, str, 15);
212 as[15] = 0;
213 ds[15] = 0;
214
215 duration = r->Last - r->First;
216 duration += ((double)r->msec_last - (double)r->msec_first) / 1000.0;
217
218 tt = r->First;
219 ts = localtime(&tt);
220 strftime(datestr, 63, "%Y-%m-%d %H:%M:%S", ts);
221
222 switch (r->prot) {
223 case 1:
224 prot = "ICMP";
225 break;
226 case 6:
227 prot = "TCP ";
228 break;
229 case 17:
230 prot = "UDP ";
231 break;
232 case 41:
233 prot = "IPv6";
234 break;
235 case 46:
236 prot = "RSVP";
237 break;
238 case 47:
239 prot = "GRE ";
240 break;
241 case 50:
242 prot = "ESP "; // Encap Security Payload
243 break;
244 case 51:
245 prot = "AH "; // Authentication Header
246 break;
247 case 58:
248 prot = "ICM6";
249 break;
250 case 89:
251 prot = "OSPF";
252 break;
253 case 94:
254 prot = "IPIP";
255 break;
256 case 103:
257 prot = "PIM ";
258 break;
259 default:
260 snprintf(prot_long,15,"%4d",r->prot);
261 prot = prot_long;
262 }
263
264 format_number(bytes, bytes_str);
265 format_number(pkts, packets_str);
266
267 snprintf(string, STRINGSIZE-1 ,"%s.%03u %8.3f %s %15s:%-5i -> %15s:%-5i %8s %8s %5llu",
268 datestr, r->msec_first, duration, prot, as, r->srcport, ds, r->dstport, packets_str, bytes_str, numflows);
269 string[STRINGSIZE-1] = 0;
270
271 *s = string;
272
273 } // End of flow_record_to_line
274
275
276 void flow_record_to_line_long(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
277 double duration;
278 time_t tt;
279 struct in_addr a,d;
280 char as[16], ds[16], TCP_flags[7], bytes_str[32], packets_str[32];
281 char *str;
282 char *prot;
283 char prot_long[16], datestr[64];
284 struct tm * ts;
285 flow_record_t *r = (flow_record_t *)record;
286
287 if ( anon ) {
288 if ( r->srcaddr )
289 r->srcaddr = anonymize(r->srcaddr);
290 if ( r->dstaddr )
291 r->dstaddr = anonymize(r->dstaddr);
292 }
293 a.s_addr = htonl(r->srcaddr);
294 d.s_addr = htonl(r->dstaddr);
295 str = inet_ntoa(a);
296 strncpy(as, inet_ntoa(a), 15);
297 str = inet_ntoa(d);
298 strncpy(ds, str, 15);
299 as[15] = 0;
300 ds[15] = 0;
301
302 duration = r->Last - r->First;
303 duration += ((double)r->msec_last - (double)r->msec_first) / 1000.0;
304
305 tt = r->First;
306 ts = localtime(&tt);
307 strftime(datestr, 63, "%Y-%m-%d %H:%M:%S", ts);
308
309 switch (r->prot) {
310 case 1:
311 prot = "ICMP";
312 break;
313 case 6:
314 prot = "TCP ";
315 break;
316 case 17:
317 prot = "UDP ";
318 break;
319 case 41:
320 prot = "IPv6";
321 break;
322 case 46:
323 prot = "RSVP";
324 break;
325 case 47:
326 prot = "GRE ";
327 break;
328 case 50:
329 prot = "ESP "; // Encap Security Payload
330 break;
331 case 51:
332 prot = "AH "; // Authentication Header
333 break;
334 case 58:
335 prot = "ICM6";
336 break;
337 case 94:
338 prot = "IPIP";
339 break;
340 case 89:
341 prot = "OSPF";
342 break;
343 case 103:
344 prot = "PIM ";
345 break;
346 default:
347 snprintf(prot_long,15,"%4d",r->prot);
348 prot = prot_long;
349 }
350
351 format_number(bytes, bytes_str);
352 format_number(pkts, packets_str);
353
354 TCP_flags[0] = r->tcp_flags & 32 ? 'U' : '.';
355 TCP_flags[1] = r->tcp_flags & 16 ? 'A' : '.';
356 TCP_flags[2] = r->tcp_flags & 8 ? 'P' : '.';
357 TCP_flags[3] = r->tcp_flags & 4 ? 'R' : '.';
358 TCP_flags[4] = r->tcp_flags & 2 ? 'S' : '.';
359 TCP_flags[5] = r->tcp_flags & 1 ? 'F' : '.';
360 TCP_flags[6] = '\0';
361
362 snprintf(string, STRINGSIZE-1 ,"%s.%03u %8.3f %s %15s:%-5i -> %15s:%-5i %s %3i %8s %8s %5llu",
363 datestr, r->msec_first, duration, prot, as, r->srcport, ds, r->dstport, TCP_flags, r->tos, packets_str,
364 bytes_str, numflows);
365 string[STRINGSIZE-1] = 0;
366
367 *s = string;
368
369 } // End of flow_record_to_line_long
370
371 void flow_record_to_line_extended(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
372 uint32_t Bpp;
373 uint64_t pps, bps;
374 double duration;
375 time_t tt;
376 struct in_addr a,d;
377 char as[16], ds[16], TCP_flags[7], bytes_str[32], packets_str[32], pps_str[32], bps_str[32];
378 char *str;
379 char *prot;
380 char prot_long[16], datestr[64];
381 struct tm *ts;
382 flow_record_t *r = (flow_record_t *)record;
383
384
385 if ( anon ) {
386 if ( r->srcaddr )
387 r->srcaddr = anonymize(r->srcaddr);
388 if ( r->dstaddr )
389 r->dstaddr = anonymize(r->dstaddr);
390 }
391 a.s_addr = htonl(r->srcaddr);
392 d.s_addr = htonl(r->dstaddr);
393 str = inet_ntoa(a);
394 strncpy(as, inet_ntoa(a), 15);
395 str = inet_ntoa(d);
396 strncpy(ds, str, 15);
397 as[15] = 0;
398 ds[15] = 0;
399
400 duration = r->Last - r->First;
401 duration += ((double)r->msec_last - (double)r->msec_first) / 1000.0;
402
403 tt = r->First;
404 ts = localtime(&tt);
405 strftime(datestr, 63, "%Y-%m-%d %H:%M:%S", ts);
406
407 switch (r->prot) {
408 case 1:
409 prot = "ICMP";
410 break;
411 case 6:
412 prot = "TCP ";
413 break;
414 case 17:
415 prot = "UDP ";
416 break;
417 case 41:
418 prot = "IPv6";
419 break;
420 case 46:
421 prot = "RSVP";
422 break;
423 case 47:
424 prot = "GRE ";
425 break;
426 case 50:
427 prot = "ESP "; // Encap Security Payload
428 break;
429 case 51:
430 prot = "AH "; // Authentication Header
431 break;
432 case 58:
433 prot = "ICM6";
434 break;
435 case 94:
436 prot = "IPIP";
437 break;
438 case 89:
439 prot = "OSPF";
440 break;
441 case 103:
442 prot = "PIM ";
443 break;
444 default:
445 snprintf(prot_long,15,"%4d",r->prot);
446 prot = prot_long;
447 }
448
449 TCP_flags[0] = r->tcp_flags & 32 ? 'U' : '.';
450 TCP_flags[1] = r->tcp_flags & 16 ? 'A' : '.';
451 TCP_flags[2] = r->tcp_flags & 8 ? 'P' : '.';
452 TCP_flags[3] = r->tcp_flags & 4 ? 'R' : '.';
453 TCP_flags[4] = r->tcp_flags & 2 ? 'S' : '.';
454 TCP_flags[5] = r->tcp_flags & 1 ? 'F' : '.';
455 TCP_flags[6] = '\0';
456
457 if ( duration ) {
458 pps = pkts / duration; // packets per second
459 bps = ( bytes << 3 ) / duration; // bits per second. ( >> 3 ) -> * 8 to convert octets into bits
460 } else {
461 pps = bps = 0;
462 }
463 Bpp = bytes / pkts; // Bytes per Packet
464 format_number(bytes, bytes_str);
465 format_number(pkts, packets_str);
466 format_number(pps, pps_str);
467 format_number(bps, bps_str);
468 format_number(bps, bps_str);
469
470 snprintf(string, STRINGSIZE-1 ,"%s.%03u %8.3f %s %15s:%-5i -> %15s:%-5i %s %3i %8s %8s %8s %8s %6u %5llu",
471 datestr, r->msec_first, duration, prot, as, r->srcport, ds, r->dstport, TCP_flags, r->tos, packets_str,
472 bytes_str, pps_str, bps_str, Bpp, numflows);
473 string[STRINGSIZE-1] = 0;
474
475 *s = string;
476
477 } // End of flow_record_line_extended
478
479 void flow_record_to_pipe(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon) {
480 flow_record_t *r = (flow_record_t *)record;
481
482 if ( anon ) {
483 if ( r->srcaddr )
484 r->srcaddr = anonymize(r->srcaddr);
485 if ( r->dstaddr )
486 r->dstaddr = anonymize(r->dstaddr);
487 }
488 snprintf(string, STRINGSIZE-1 ,"%u|%u|%u|%u|%u|%u|%u|%u|%u|%u|%u|%llu|%llu",
489 r->First, r->msec_first ,r->Last, r->msec_last, r->prot, r->srcaddr, r->srcport, r->dstaddr, r->dstport,
490 r->tcp_flags, r->tos, pkts, bytes);
491
492 string[STRINGSIZE-1] = 0;
493
494 *s = string;
495
496 } // End of flow_record_pipe
497
498 #ifdef __SUNPRO_C
499 extern
500 #endif
501 inline void format_number(uint64_t num, char *s) {
502 double f = num;
503
504 if ( f >= _1TB ) {
505 snprintf(s, 31, "%5.1f T", f / _1TB );
506 } else if ( f >= _1GB ) {
507 snprintf(s, 31, "%5.1f G", f / _1GB );
508 } else if ( f >= _1MB ) {
509 snprintf(s, 31, "%5.1f M", f / _1MB );
510 /*
511 } else if ( f >= _1KB ) {
512 snprintf(s, 31, "%5.1f K", f / _1KB );
513 */
514 } else {
515 snprintf(s, 31, "%4.0f", f );
516 }
517
518 } // End of format_number
519
0 /*
1 * nfcapd : Reads netflow data from socket and saves the
2 * data into a file. The file gets automatically rotated
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: nf_common.h 53 2005-11-17 07:45:34Z peter $
34 *
35 * $LastChangedRevision: 53 $
36 *
37 *
38 */
39
40 #include "config.h"
41
42 typedef void (*printer_t)(void *, uint64_t, uint64_t, uint64_t, char **, int);
43
44 #if ( SIZEOF_VOID_P == 8 )
45 typedef uint64_t pointer_addr_t;
46 #else
47 typedef uint32_t pointer_addr_t;
48 #endif
49
50 typedef struct msec_time_s {
51 time_t sec;
52 uint16_t msec;
53 } msec_time_tt;
54
55 /*
56 * binary file layout:
57 * mostly compatible with v5 format
58 * flow_header is identical to the v5 header
59 * flow_record has some changes, to speed up flow processing
60 * and overcome the ugly netflow time format ...
61 */
62
63 #define FLOW_HEADER_LENGTH sizeof(flow_header_t)
64 #define FLOW_RECORD_LENGTH sizeof(flow_record_t)
65
66
67 /* max records in binary files */
68 #define MAX_RECORDS 30
69
70 typedef struct flow_header {
71 uint16_t version;
72 uint16_t count;
73 uint32_t SysUptime;
74 uint32_t unix_secs;
75 uint32_t unix_nsecs;
76 uint32_t flow_sequence;
77 uint8_t engine_type;
78 uint8_t engine_id;
79 uint16_t layout_version; /* binary layout version */
80 } flow_header_t;
81
82 typedef struct flow_record {
83 uint32_t srcaddr;
84 uint32_t dstaddr;
85 uint32_t nexthop;
86 uint16_t input;
87 uint16_t output;
88 uint32_t dPkts;
89 uint32_t dOctets;
90 uint32_t First; /* First seen timestamp in UNIX time format. msec offset at end of record */
91 uint32_t Last; /* Last seen timestamp in UNIX time format. msec offset at end of record */
92 uint16_t srcport;
93 uint16_t dstport;
94 uint8_t pad;
95 uint8_t tcp_flags;
96 uint8_t prot;
97 uint8_t tos;
98 uint16_t src_as;
99 uint16_t dst_as;
100 uint16_t msec_first; /* msec offset from First */
101 uint16_t msec_last; /* msec offset from Last */
102 } flow_record_t;
103
104 /* prototypes */
105
106 void flow_header_raw(void *header, uint64_t numflows, uint64_t pkts, uint64_t bytes, char **s, int anon);
107
108 void flow_record_raw(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char **s, int anon);
109
110 void flow_record_to_line(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char **s, int anon);
111
112 void flow_record_to_line_long(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char **s, int anon);
113
114 void flow_record_to_line_extended(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon);
115
116 void flow_record_to_pipe(void *record, uint64_t numflows, uint64_t pkts, uint64_t bytes, char ** s, int anon);
117
118 #ifdef __SUNPRO_C
119 extern
120 #endif
121 inline int TimeMsec_CMP(time_t t1, uint16_t offset1, time_t t2, uint16_t offset2 );
122
123 #ifdef __SUNPRO_C
124 extern
125 #endif
126 inline void format_number(uint64_t num, char *s);
0 .TH nfcapd 1 2005-08-19 "" ""
1 .SH NAME
2 nfcapd \- netflow capture daemon
3 .SH SYNOPSIS
4 .HP 5
5 .B nfcapd [options]
6 .SH DESCRIPTION
7 .B nfcapd
8 is the netflow capture daemon of the nfdump tools. It reads netflow
9 data from the network and stores it into files. The output file
10 is automatically rotated and renamed every n minutes - typically
11 5 min - according the timestamp YYYYMMddhhmm of the interval e.g.
12 nfcapd.200407110845 contains the data from July 11th 2004 08:45 onward.
13 Additionally a file named nfcapd.200407110845.stat is created which
14 contains an ASCII readable statistical summary of the data. At the
15 end of every interval you may run any external programm, for example
16 nfprofile, which allows you to process the data.
17 .P
18 Netflow version v5 and v7 are transparently supported.
19
20 .SH OPTIONS
21 .TP 3
22 .B -p \fIportnum
23 Specifies the port number to listen. Default port is 9995
24 .TP 3
25 .B -b \fIIPaddr
26 Specifies the IP address to bind for listening. Default is any
27 available IPv4 interface.
28 .TP 3
29 .B -l \fIdirectory
30 Specifies the directory to store the output files. Default is /var/tmp
31 .TP 3
32 .B -t \fIinterval
33 Specifies the time interval in seconds to rotate files. The default value
34 is 300s ( 5min ).
35 .TP 3
36 .B -w
37 Align file rotation with next n minute ( specified by -t ) interval.
38 Example: If interval is 5 min, sync at 0,5,10... wall clock minutes
39 Default: no alignment.
40 .TP 3
41 .B -x \fIcmd
42 Run command \fIcmd\fR at the end of every interval, when a new file
43 becomes available. The following command expansion is available:
44 .PD 0
45 .RS 4
46 %f Replaced by the file name e.g nfcapd.200407110845.
47 .P
48 %d Replaced by the directory where the file is located.
49 .P
50 %t Replaced by the time ISO format e.g. 200407110845.
51 .P
52 %u Replaced by the UNIX time format.
53 .P
54 %i Replaced ident string given by -I
55 .RE
56 .PD
57 .TP 3
58 .B -P \fIpidfile
59 Specify name of pidfile. Default is no pidfile.
60 .TP 3
61 .B -D
62 Daemon mode: fork to background and detach from terminal.
63 Nfcapd terminates on signal TERM, INT and HUP.
64 .TP 3
65 .B -I \fIIdentString
66 Specifies an ident string, which describes the source e.g. the
67 name of the router. This string is put into the stat file to identify
68 the source. Default is 'none'.
69 .TP 3
70 .B -B \fIbufflen
71 Specifies the socket input buffer length in bytes. For high volume traffic
72 ( near GB traffic ) it is recommended to set this value as high as possible
73 ( typically > 100k ), otherwise you risk to lose packets. The default
74 is OS ( and kernel ) dependent.
75 .TP 3
76 .B -E
77 Print netflow records in nfdump raw format to stdout. This option is for
78 debugging purpose only, to see how incoming netflow data is processed and stored.
79 .TP 3
80 .B -V
81 Print nfcapd version and exit.
82 .TP 3
83 .B -h
84 Print help text to stdout with all options and exit.
85 .SH "RETURN VALUE"
86 Returns 0 on success, or 255 if initialization failed.
87 .SH "LOGGING"
88 nfcapd logs to syslog with SYSLOG_FACILITY LOG_DAEMON
89 For normal operation level 'warning' should be fine.
90 More information is reported at level 'info' and 'debug'.
91 .P
92 A small statistic about the collected flows, as well as errors
93 are reported at the end of every interval to syslog with level 'info'.
94 .SH "EXAMPLES"
95 nfcapd -w -D -l /netflow/spool/router1 -p 23456 -B 128000 -I router1 -x '/path/nfprofile -p /to/profile/dir -s router1 -r %d/%f' -P /var/run/nfcapd/nfcapd.router1
96 .SH NOTES
97 Setting the socket buffer size is system dependent. When starting up,
98 nfcapd returns the number of bytes the buffer was actually set. This
99 is done by reading back the buffer size and may differ from what you
100 requested.
101 .P
102 Nfdump tools version 1.4 support netflow v5 and v7 transparently.
103 .SH "SEE ALSO"
104 nfdump(1), nfprofile(1), nfreplay(1)
105 .SH BUGS
106 I only found the second last bug. Please report the last one back to me.
0 /*
1 * nfcapd : Reads netflow data from socket and saves the
2 * data into a file. The file gets automatically rotated
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: nfcapd.c 53 2005-11-17 07:45:34Z peter $
34 *
35 * $LastChangedRevision: 53 $
36 *
37 *
38 */
39
40 /*
41 * Because NetFlow export uses UDP to send export datagrams, it is possible
42 * for datagrams to be lost. To determine whether flow export information has
43 * been lost, Version 5, Version 7, and Version 8 headers contain a flow
44 * sequence number. The sequence number is equal to the sequence number of the
45 * previous datagram plus the number of flows in the previous datagram. After
46 * receiving a new datagram, the receiving application can subtract the expected
47 * sequence number from the sequence number in the header to derive the number
48 * of missed flows.
49
50 */
51
52 #include <stdio.h>
53 #include <stdlib.h>
54 #include <string.h>
55 #include <errno.h>
56 #include <sys/types.h>
57 #include <sys/socket.h>
58 #include <pwd.h>
59 #include <grp.h>
60 #include <unistd.h>
61 #include <sys/wait.h>
62 #include <sys/stat.h>
63 #include <netinet/in.h>
64 #include <arpa/inet.h>
65 #include <time.h>
66 #include <fcntl.h>
67 #include <signal.h>
68 #include <syslog.h>
69 #include <sys/mman.h>
70
71 #include "config.h"
72
73 #ifdef HAVE_STDINT_H
74 #include <stdint.h>
75 #endif
76
77 #include "version.h"
78 #include "nf_common.h"
79 #include "launch.h"
80 #include "netflow_v5.h"
81 #include "netflow_v7.h"
82
83 #define DEFAULTCISCOPORT 9995
84 #define TIME_WINDOW 300 // The Default Time Window is 5min
85 #define OVERDUE_TIME 20 // Rename File latest, after end of time window
86 #define DEFAULT_DIR "/var/tmp"
87
88 #define BUFFSIZE 655350
89 #define NF_DUMPFILE "nfcapd.current"
90
91 #define delta(a,b) ( (a)>(b) ? (a)-(b) : (b)-(a) )
92
93 #define SYSLOG_FACILITY LOG_DAEMON
94
95 /* Global Variables */
96 uint32_t byte_limit, packet_limit; // needed for linking purpose only
97 int byte_mode, packet_mode;
98 caddr_t shmem;
99
100 /*
101 * local static vars used by interrupt routine
102 */
103 static int done, launcher_alive, rename_trigger, launcher_pid, verbose = 0;
104 static char Ident[32];
105
106 static char const *rcsid = "$Id: nfcapd.c 53 2005-11-17 07:45:34Z peter $";
107
108 /* Function Prototypes */
109 static void IntHandler(int signal);
110
111 static void usage(char *name);
112
113 static void SetPriv(char *userid, char *groupid );
114
115 static int Setup_Socket(char *IPAddr, int portnum, int sockbuflen );
116
117 static void kill_launcher(int pid);
118
119 void kill_launcher(int pid) {
120 int stat;
121
122 if ( pid == 0 )
123 return;
124
125 if ( launcher_alive ) {
126 kill(pid, SIGTERM);
127 waitpid (pid, &stat, 0);
128 syslog(LOG_INFO, "laucher terminated: %i", stat);
129 } else {
130 waitpid (pid, &stat, 0);
131 syslog(LOG_ERR, "Can't terminate laucher: process already did: %i", stat);
132 }
133
134 } // End of kill_launcher
135
136
137 static void run(int socket, unsigned int bufflen, time_t twin, time_t t_begin, int report_seq);
138
139 /* Functions */
140 static void usage(char *name) {
141 printf("usage %s [options] \n"
142 "-h\t\tthis text you see right here\n"
143 "-u userid\tChange user to userid\n"
144 "-g groupid\tChange group to groupid\n"
145 "-w\t\tSync file rotation with next 5min (default) interval\n"
146 "-t interval\tset the interval to rotate nfcapd files\n"
147 "-b ipaddr\tbind socket to IP addr\n"
148 "-p portnum\tlisten on port portnum\n"
149 "-l logdir \tset the output directory. (default /var/tmp) \n"
150 "-I Ident\tset the ident string for stat file. (default 'none')\n"
151 "-P pidfile\tset the PID file\n"
152 "-r\t\tReport missing flows to syslog\n"
153 "-x process\tlauch process after a new file becomes available\n"
154 "-B bufflen\tSet socket buffer to bufflen bytes\n"
155 "-D\t\tFork to background\n"
156 "-E\t\tPrint extended format of netflow data. for debugging purpose only.\n"
157 "-V\t\tPrint version and exit.\n"
158 , name);
159 } /* usage */
160
161 static void IntHandler(int signal) {
162
163 switch (signal) {
164 case SIGALRM:
165 rename_trigger = 1;
166 break;
167 case SIGHUP:
168 case SIGINT:
169 case SIGTERM:
170 done = 1;
171 break;
172 case SIGCHLD:
173 launcher_alive = 0;
174 break;
175 default:
176 // ignore everything we don't know
177 break;
178 }
179
180 } /* End of IntHandler */
181
182 static void SetPriv(char *userid, char *groupid ) {
183 struct passwd *pw_entry;
184 struct group *gr_entry;
185 uid_t myuid, newuid, newgid;
186 int err;
187
188 if ( userid == 0 && groupid == 0 )
189 return;
190
191 newuid = newgid = 0;
192 myuid = getuid();
193 if ( myuid != 0 ) {
194 syslog(LOG_ERR, "Only root wants to change uid/gid");
195 fprintf(stderr, "ERROR: Only root wants to change uid/gid\n");
196 exit(255);
197 }
198
199 if ( userid ) {
200 pw_entry = getpwnam(userid);
201 newuid = pw_entry ? pw_entry->pw_uid : atol(userid);
202
203 if ( newuid == 0 ) {
204 fprintf (stderr,"Invalid user '%s'\n", userid);
205 exit(255);
206 }
207 }
208
209 if ( groupid ) {
210 gr_entry = getgrnam(groupid);
211 newgid = gr_entry ? gr_entry->gr_gid : atol(groupid);
212
213 if ( newgid == 0 ) {
214 fprintf (stderr,"Invalid group '%s'\n", groupid);
215 exit(255);
216 }
217
218 err = setgid(newgid);
219 if ( err ) {
220 syslog(LOG_ERR, "Can't set group id %u for group '%s': %s", newgid, groupid, strerror(errno));
221 fprintf (stderr,"Can't set group id %u for group '%s': %s\n", newgid, groupid, strerror(errno));
222 exit(255);
223 }
224
225 }
226
227 if ( newuid ) {
228 err = setuid(newuid);
229 if ( err ) {
230 syslog(LOG_ERR, "Can't set user id %u for user '%s': %s", newuid, userid, strerror(errno));
231 fprintf (stderr,"Can't set user id %u for user '%s': %s\n", newuid, userid, strerror(errno));
232 exit(255);
233 }
234 }
235
236 } // End of SetPriv
237
238 static int Setup_Socket(char *IPAddr, int portnum, int sockbuflen ) {
239 struct sockaddr_in server;
240 int s, p;
241 socklen_t optlen;
242
243
244 if ( !portnum )
245 portnum = DEFAULTCISCOPORT;
246
247 s = socket (AF_INET, SOCK_DGRAM, 0);
248 if ( s < 0 ) {
249 fprintf(stderr, "Can't open socket: %s\n", strerror(errno));
250 syslog(LOG_ERR, "Can't open socket: %s", strerror(errno));
251 return -1;
252 }
253
254 memset ((char *) &server, 0, sizeof (server));
255
256 server.sin_addr.s_addr = IPAddr ? inet_addr(IPAddr) : INADDR_ANY;
257 server.sin_family = AF_INET;
258 server.sin_port = htons(portnum);
259
260 if ( (bind (s, (struct sockaddr *)&server, sizeof(server))) < 0 ) {
261 fprintf(stderr, "bind to %s:%i failed: %s\n", inet_ntoa(server.sin_addr), portnum, strerror(errno));
262 syslog(LOG_ERR, "bind to %s:%i failed: %s", inet_ntoa(server.sin_addr), portnum, strerror(errno));
263 close(s);
264 return -1;
265 }
266
267 if ( sockbuflen ) {
268 optlen = sizeof(p);
269 getsockopt(s,SOL_SOCKET,SO_RCVBUF,&p,&optlen);
270 syslog(LOG_INFO,"Standard setsockopt, SO_RCVBUF is %i Requested length is %i bytes",p, sockbuflen);
271 if ((setsockopt(s, SOL_SOCKET, SO_RCVBUF, &sockbuflen, sizeof(sockbuflen)) != 0) ) {
272 fprintf (stderr, "setsockopt(SO_RCVBUF,%d): %s\n", sockbuflen, strerror (errno));
273 syslog (LOG_ERR, "setsockopt(SO_RCVBUF,%d): %s", sockbuflen, strerror (errno));
274 close(s);
275 return -1;
276 } else {
277 getsockopt(s,SOL_SOCKET,SO_RCVBUF,&p,&optlen);
278 syslog(LOG_INFO,"System set setsockopt, SO_RCVBUF to %d bytes", p);
279 }
280 }
281
282 return s;
283
284 } /* End of Setup_Socket */
285
286
287 static void run(int socket, unsigned int bufflen, time_t twin, time_t t_begin, int report_seq) {
288 size_t writesize;
289 ssize_t cnt;
290 netflow_v5_header_t *nf_header_in; // v5/v7 common header
291 netflow_v5_record_t *v5_record;
292 flow_header_t *nf_header_out; // file flow header
293 flow_record_t *nf_record_out; // file flow record
294 time_t t_start, t_now;
295 uint32_t buffsize;
296 uint64_t numflows, numbytes, numpackets;
297 uint64_t numflows_tcp, numflows_udp, numflows_icmp, numflows_other;
298 uint64_t numbytes_tcp, numbytes_udp, numbytes_icmp, numbytes_other;
299 uint64_t numpackets_tcp, numpackets_udp, numpackets_icmp, numpackets_other;
300 uint64_t start_time, end_time, boot_time, first_seen, last_seen;
301 uint32_t First, Last, sequence_failure, bad_packets;
302 int64_t last_sequence, sequence, distance, last_count;
303 struct tm *now;
304 void *in_buff, *out_buff, *p, *q;
305 int i, err, nffd, header_length, record_length, first;
306 char *string, tmpstring[64];
307 srecord_t *commbuff;
308
309 if ( !bufflen || bufflen < BUFFSIZE )
310 bufflen = BUFFSIZE;
311
312 in_buff = malloc(bufflen);
313 out_buff = malloc(bufflen);
314 if ( !in_buff || !out_buff ) {
315 syslog(LOG_ERR, "Buffer allocation error: %s", strerror(errno));
316 return;
317 }
318
319 // init vars
320 commbuff = (srecord_t *)shmem;
321
322 p = in_buff;
323 q = out_buff;
324 cnt = 0;
325 nf_header_in = NULL;
326 nf_header_out = NULL;
327 v5_record = NULL;
328 nf_record_out = NULL;
329 header_length = NETFLOW_V5_HEADER_LENGTH; // v5 and v7 have same length
330
331 nffd = open(NF_DUMPFILE, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
332 if ( nffd == -1 ) {
333 syslog(LOG_ERR, "Can't open file: '%s': %s", NF_DUMPFILE, strerror(errno));
334 return;
335 }
336
337 bad_packets = 0;
338
339 // init sequence check vars
340 last_sequence = 0;
341 sequence = 0;
342 distance = 0;
343 last_count = 0;
344 sequence_failure = 0;
345 first = 1;
346
347 first_seen = (uint64_t)0xffffffffffffLL;
348 last_seen = 0;
349 t_start = t_begin;
350 numflows = numbytes = numpackets = buffsize = 0;
351 numflows_tcp = numflows_udp = numflows_icmp = numflows_other = 0;
352 numbytes_tcp = numbytes_udp = numbytes_icmp = numbytes_other = 0;
353 numpackets_tcp = numpackets_udp = numpackets_icmp = numpackets_other = 0;
354
355 rename_trigger = 0;
356 alarm(t_start + twin + OVERDUE_TIME - time(NULL));
357 // convert all v7 records to v5 records while processing them
358 // this ignores the router_sc field in v7
359 while ( !done ) {
360 /* check for too little data */
361 if ( buffsize > 0 && buffsize < header_length ) {
362 syslog(LOG_WARNING, "Data length error: too little data for netflow v5 header: %i", buffsize);
363 buffsize = 0;
364 p = in_buff;
365 q = out_buff;
366 bad_packets++;
367 continue;
368 }
369 /* read next bunch of data into beginn of input buffer */
370 if ( buffsize == 0 ) {
371 cnt = recv (socket, in_buff, bufflen , 0);
372 buffsize = cnt > 0 ? cnt : 0;
373 p = in_buff;
374 q = out_buff;
375 /* check for too little data */
376 if ( buffsize > 0 && buffsize < header_length ) {
377 syslog(LOG_WARNING, "Data length error: too little data for netflow header: %i", buffsize);
378 buffsize = 0;
379 p = in_buff;
380 q = out_buff;
381 bad_packets++;
382 continue;
383 }
384 }
385 /* paranoia check */
386 if ( ( (pointer_addr_t)p - (pointer_addr_t)in_buff ) > bufflen ) {
387 /* should never happen, but catch it anyway */
388 syslog(LOG_ERR, "Buffer space error");
389 buffsize = 0;
390 p = in_buff;
391 q = out_buff;
392 continue;
393 }
394
395 /* File renaming */
396 t_now = time(NULL);
397 if ( ((t_now - t_start) >= twin) || done ) {
398 alarm(0);
399 now = localtime(&t_start);
400 snprintf(tmpstring, 64, "nfcapd.%i%02i%02i%02i%02i",
401 now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min);
402 close(nffd);
403 err = rename(NF_DUMPFILE, tmpstring);
404 if ( err ) {
405 syslog(LOG_ERR, "Can't rename dump file: %s", strerror(errno));
406 continue;
407 }
408 if ( launcher_pid ) {
409 strncpy(commbuff->fname, tmpstring, FNAME_SIZE);
410 commbuff->fname[FNAME_SIZE-1] = 0;
411 snprintf(commbuff->tstring, 16, "%i%02i%02i%02i%02i",
412 now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min);
413 commbuff->tstring[15] = 0;
414 commbuff->tstamp = t_start;
415 }
416 snprintf(tmpstring, 64, "nfcapd.%i%02i%02i%02i%02i.stat",
417 now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min);
418 nffd = open(tmpstring, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
419 if ( nffd == -1 ) {
420 syslog(LOG_ERR, "Can't open stat file: %s", strerror(errno));
421 return;
422 }
423
424 /* Statfile */
425 #if defined __OpenBSD__ || defined __FreeBSD__
426 snprintf(tmpstring, 64, "Time: %i\n", t_start);
427 #else
428 snprintf(tmpstring, 64, "Time: %li\n", t_start);
429 #endif
430 write(nffd, tmpstring, strlen(tmpstring));
431 // t_start = t_now - ( t_now % twin);
432 t_start += twin;
433 alarm(t_start + twin + OVERDUE_TIME - t_now);
434
435 snprintf(tmpstring, 64, "Ident: %s\n", Ident);
436 write(nffd, tmpstring, strlen(tmpstring));
437 snprintf(tmpstring, 64, "Flows: %llu\n", numflows);
438 write(nffd, tmpstring, strlen(tmpstring));
439 snprintf(tmpstring, 64, "Flows_tcp: %llu\n", numflows_tcp);
440 write(nffd, tmpstring, strlen(tmpstring));
441 snprintf(tmpstring, 64, "Flows_udp: %llu\n", numflows_udp);
442 write(nffd, tmpstring, strlen(tmpstring));
443 snprintf(tmpstring, 64, "Flows_icmp: %llu\n", numflows_icmp);
444 write(nffd, tmpstring, strlen(tmpstring));
445 snprintf(tmpstring, 64, "Flows_other: %llu\n", numflows_other);
446 write(nffd, tmpstring, strlen(tmpstring));
447 snprintf(tmpstring, 64, "Packets: %llu\n", numpackets);
448 write(nffd, tmpstring, strlen(tmpstring));
449 snprintf(tmpstring, 64, "Packets_tcp: %llu\n", numpackets_tcp);
450 write(nffd, tmpstring, strlen(tmpstring));
451 snprintf(tmpstring, 64, "Packets_udp: %llu\n", numpackets_udp);
452 write(nffd, tmpstring, strlen(tmpstring));
453 snprintf(tmpstring, 64, "Packets_icmp: %llu\n", numpackets_icmp);
454 write(nffd, tmpstring, strlen(tmpstring));
455 snprintf(tmpstring, 64, "Packets_other: %llu\n", numpackets_other);
456 write(nffd, tmpstring, strlen(tmpstring));
457 snprintf(tmpstring, 64, "Bytes: %llu\n", numbytes);
458 write(nffd, tmpstring, strlen(tmpstring));
459 snprintf(tmpstring, 64, "Bytes_tcp: %llu\n", numbytes_tcp);
460 write(nffd, tmpstring, strlen(tmpstring));
461 snprintf(tmpstring, 64, "Bytes_udp: %llu\n", numbytes_udp);
462 write(nffd, tmpstring, strlen(tmpstring));
463 snprintf(tmpstring, 64, "Bytes_icmp: %llu\n", numbytes_icmp);
464 write(nffd, tmpstring, strlen(tmpstring));
465 snprintf(tmpstring, 64, "Bytes_other: %llu\n", numbytes_other);
466 write(nffd, tmpstring, strlen(tmpstring));
467 snprintf(tmpstring, 64, "First: %llu\n", first_seen/1000LL);
468 write(nffd, tmpstring, strlen(tmpstring));
469 snprintf(tmpstring, 64, "Last: %llu\n", last_seen/1000LL);
470 write(nffd, tmpstring, strlen(tmpstring));
471 close(nffd);
472 syslog(LOG_INFO,"Ident: '%s' Flows: %llu, Packets: %llu, Bytes: %llu, Sequence Errors: %u, Bad Packets: %u",
473 Ident, numflows, numpackets, numbytes, sequence_failure, bad_packets);
474 if ( launcher_pid ) {
475 if ( launcher_alive ) {
476 syslog(LOG_DEBUG, "Signal launcher");
477 kill(launcher_pid, SIGHUP);
478 } else {
479 syslog(LOG_ERR, "ERROR: Launcher did unexpectedly!");
480 }
481 }
482 numflows = numbytes = numpackets = 0;
483 sequence_failure = bad_packets = 0;
484 numflows_tcp = numflows_udp = numflows_icmp = numflows_other = 0;
485 numbytes_tcp = numbytes_udp = numbytes_icmp = numbytes_other = 0;
486 numpackets_tcp = numpackets_udp = numpackets_icmp = numpackets_other = 0;
487 first_seen = 0xffffffffffffLL;
488 last_seen = 0;
489
490 nffd = open(NF_DUMPFILE, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
491 if ( nffd == -1 ) {
492 syslog(LOG_ERR, "Can't open dump file: %s", strerror(errno));
493 return;
494 }
495 }
496
497 /* check for error condition or done */
498 if ( cnt < 0 ) {
499 if ( rename_trigger ) {
500 rename_trigger = 0;
501 continue;
502 }
503 if ( done )
504 break;
505 else {
506 syslog(LOG_ERR, "Data receive error while expecting header data: %s", strerror(errno));
507 p = in_buff;
508 q = out_buff;
509 bad_packets++;
510 continue;
511 }
512 }
513
514 /* Process header */
515 nf_header_in = (netflow_v5_header_t *)p;
516 nf_header_out = (flow_header_t *)q;
517
518 nf_header_out->version = ntohs(nf_header_in->version);
519 nf_header_out->count = ntohs(nf_header_in->count);
520 nf_header_out->SysUptime = ntohl(nf_header_in->SysUptime);
521 nf_header_out->unix_secs = ntohl(nf_header_in->unix_secs);
522 nf_header_out->unix_nsecs = ntohl(nf_header_in->unix_nsecs);
523 nf_header_out->flow_sequence = ntohl(nf_header_in->flow_sequence);
524 nf_header_out->layout_version = 1;
525
526 // check version and set appropriate params
527 switch (nf_header_out->version) {
528 case 5:
529 record_length = NETFLOW_V5_RECORD_LENGTH;
530 if ( nf_header_out->count == 0 || nf_header_out->count > NETFLOW_V5_MAX_RECORDS ) {
531 syslog(LOG_ERR,"Error netflow header: Unexpected number of records in v5 header: %i.", nf_header_out->count);
532 buffsize = 0;
533 p = in_buff;
534 q = out_buff;
535 bad_packets++;
536 continue;
537 }
538 break;
539 case 7:
540 record_length = NETFLOW_V7_RECORD_LENGTH;
541 if ( nf_header_out->count == 0 || nf_header_out->count > NETFLOW_V7_MAX_RECORDS ) {
542 syslog(LOG_ERR,"Error netflow header: Unexpected number of records in v7 header: %i.", nf_header_out->count);
543 buffsize = 0;
544 p = in_buff;
545 q = out_buff;
546 bad_packets++;
547 continue;
548 }
549 nf_header_out->version = 5;
550 break;
551 default:
552 // force data error, when reading data from socket
553 record_length = 0;
554 syslog(LOG_ERR,"Error netflow header: Unexpected netflow version %i, found.", nf_header_out->version);
555 buffsize = 0;
556 p = in_buff;
557 q = out_buff;
558 bad_packets++;
559 continue;
560 break;
561 }
562
563 if ( first ) {
564 last_sequence = nf_header_out->flow_sequence;
565 sequence = last_sequence;
566 first = 0;
567 } else {
568 last_sequence = sequence;
569 sequence = nf_header_out->flow_sequence;
570 distance = sequence - last_sequence;
571 // handle overflow
572 if (distance < 0) {
573 distance = 0xffffffff + distance +1;
574 }
575 if (distance != last_count) {
576 sequence_failure++;
577 if ( report_seq )
578 syslog(LOG_ERR,"Flow sequence mismatch. Missing: %lli flows", delta(last_count,distance));
579 }
580 }
581 last_count = nf_header_out->count;
582
583 if ( verbose ) {
584 flow_header_raw(nf_header_out, 0, 0, 0, &string, 0);
585 printf("%s", string);
586 }
587
588 /* advance buffer */
589 p = (void *)((pointer_addr_t)p + header_length);
590 q = (void *)((pointer_addr_t)q + header_length);
591 buffsize -= header_length;
592
593 /* calculate boot time in msec */
594 boot_time = ((uint64_t)(nf_header_out->unix_secs)*1000 +
595 ((uint64_t)(nf_header_out->unix_nsecs) / 1000000) ) - (uint64_t)(nf_header_out->SysUptime);
596
597 /* records associated with the header */
598 for (i = 0; i < nf_header_out->count; i++) {
599 /* make sure enough data is available in the buffer */
600 if ( buffsize > 0 && buffsize < record_length ) {
601 syslog(LOG_WARNING, "Data length error: too little data for netflow record!");
602 buffsize = 0;
603 p = in_buff;
604 q = out_buff;
605 break;
606 }
607 if ( buffsize == 0 ) {
608 /* read next bunch of data - append to end of data already read */
609 cnt = recv (socket, p, (pointer_addr_t)bufflen - ((pointer_addr_t)p - (pointer_addr_t)in_buff), 0);
610 buffsize = cnt;
611 if ( cnt < 0 ) {
612 if ( done ) {
613 break;
614 } else {
615 syslog(LOG_ERR, "Data receive error while expecting record data: %s", strerror(errno));
616 break;
617 }
618 }
619 /* make sure enough data is available in the buffer */
620 if ( buffsize > 0 && ((buffsize < record_length) || (record_length == 0)) ) {
621 syslog(LOG_WARNING, "Data length error: too little data for v5 record: %i", buffsize);
622 buffsize = 0;
623 p = in_buff;
624 q = out_buff;
625 break;
626 }
627 }
628 if ( ( (pointer_addr_t)p - (pointer_addr_t)in_buff ) > bufflen ) {
629 /* should never happen, but catch it anyway */
630 syslog(LOG_ERR, "Buffer space error");
631 buffsize = 0;
632 p = in_buff;
633 q = out_buff;
634 break;
635 }
636 if ( buffsize < record_length ) {
637 syslog(LOG_WARNING, "Data read error: Too little data for v5 record");
638 buffsize = 0;
639 p = in_buff;
640 q = out_buff;
641 break;
642 }
643
644 // process record
645 // whatever netflow version it is ( v5 or v7 allowed here ) both
646 // version have the same common fields below
647 // fields other than those assigned below or ignored, and not
648 // not relevant for nfdump
649 v5_record = (netflow_v5_record_t *)p;
650 nf_record_out = (flow_record_t *)q;
651 nf_record_out->srcaddr = ntohl(v5_record->srcaddr);
652 nf_record_out->dstaddr = ntohl(v5_record->dstaddr);
653 nf_record_out->nexthop = ntohl(v5_record->nexthop);
654 nf_record_out->input = ntohs(v5_record->input);
655 nf_record_out->output = ntohs(v5_record->output);
656 nf_record_out->dPkts = ntohl(v5_record->dPkts);
657 nf_record_out->dOctets = ntohl(v5_record->dOctets);
658 First = ntohl(v5_record->First);
659 Last = ntohl(v5_record->Last);
660 nf_record_out->srcport = ntohs(v5_record->srcport);
661 nf_record_out->dstport = ntohs(v5_record->dstport);
662 nf_record_out->pad = 0;
663 nf_record_out->tcp_flags = v5_record->tcp_flags;
664 nf_record_out->prot = v5_record->prot;
665 nf_record_out->tos = v5_record->tos;
666 nf_record_out->src_as = ntohs(v5_record->src_as);
667 nf_record_out->dst_as = ntohs(v5_record->dst_as);
668
669 switch (nf_record_out->prot) {
670 case 1:
671 numflows_icmp++;
672 numpackets_icmp += nf_record_out->dPkts;
673 numbytes_icmp += nf_record_out->dOctets;
674 break;
675 case 6:
676 numflows_tcp++;
677 numpackets_tcp += nf_record_out->dPkts;
678 numbytes_tcp += nf_record_out->dOctets;
679 break;
680 case 17:
681 numflows_udp++;
682 numpackets_udp += nf_record_out->dPkts;
683 numbytes_udp += nf_record_out->dOctets;
684 break;
685 default:
686 numflows_other++;
687 numpackets_other += nf_record_out->dPkts;
688 numbytes_other += nf_record_out->dOctets;
689 }
690 numflows++;
691 numpackets += nf_record_out->dPkts;
692 numbytes += nf_record_out->dOctets;
693
694 p = (void *)((pointer_addr_t)p + record_length);
695 q = (void *)((pointer_addr_t)q + NETFLOW_V5_RECORD_LENGTH);
696 buffsize -= record_length;
697
698 /* start time in msecs */
699 start_time = (uint64_t)First + boot_time;
700
701 if ( First > Last )
702 /* Last in msec, in case of msec overflow, between start and end */
703 end_time = 0x100000000LL + Last + boot_time;
704 else
705 end_time = (uint64_t)Last + boot_time;
706
707 nf_record_out->First = start_time/1000;
708 nf_record_out->msec_first = start_time - nf_record_out->First*1000;
709
710 nf_record_out->Last = end_time/1000;
711 nf_record_out->msec_last = end_time - nf_record_out->Last*1000;
712
713 if ( start_time < first_seen )
714 first_seen = start_time;
715 if ( end_time > last_seen )
716 last_seen = end_time;
717
718 if ( verbose ) {
719 flow_record_raw(nf_record_out, 1, (uint64_t)nf_record_out->dPkts, (uint64_t)nf_record_out->dOctets, &string, 0);
720 printf("%s\n", string);
721 }
722 }
723 if ( i != nf_header_out->count ) {
724 syslog(LOG_WARNING, "Expected %i records, but found only %i", nf_header_out->count, i);
725 nf_header_out->count = i;
726 }
727 writesize = header_length + nf_header_out->count * NETFLOW_V5_RECORD_LENGTH;
728 if ( write(nffd, (void *)nf_header_out, writesize) <= 0 ) {
729 syslog(LOG_ERR, "Failed to write records to disk: '%s'" , strerror(errno));
730 }
731 }
732 free(in_buff);
733 free(out_buff);
734 close(nffd);
735
736 } /* End of run */
737
738 int main(int argc, char **argv) {
739
740 char *bindaddr, *pidfile, *filter, *datadir, pidstr[32], *lauch_process;
741 char *userid, *groupid, *checkptr;
742 struct stat fstat;
743 srecord_t *commbuff;
744 struct sigaction act;
745 int bufflen;
746 time_t twin, t_start, t_tmp;
747 int portnum, sock, pidf, fd, err, synctime, daemonize, report_sequence;
748 char c;
749 pid_t pid;
750
751 portnum = verbose = synctime = daemonize = 0;
752 bufflen = 0;
753 launcher_pid = 0;
754 launcher_alive = 0;
755 report_sequence = 0;
756 bindaddr = NULL;
757 pidfile = NULL;
758 filter = NULL;
759 lauch_process = NULL;
760 userid = groupid = NULL;
761 twin = TIME_WINDOW;
762 datadir = DEFAULT_DIR;
763 strncpy(Ident, "none", IDENT_SIZE);
764 while ((c = getopt(argc, argv, "whEVI:DB:b:l:p:P:t:x:ru:g:")) != EOF) {
765 switch (c) {
766 case 'h':
767 usage(argv[0]);
768 exit(0);
769 break;
770 case 'u':
771 userid = optarg;
772 break;
773 case 'g':
774 groupid = optarg;
775 break;
776 case 'E':
777 verbose = 1;
778 break;
779 case 'V':
780 printf("%s: Version: %s %s\n%s\n",argv[0], nfdump_version, nfdump_date, rcsid);
781 exit(0);
782 break;
783 case 'D':
784 daemonize = 1;
785 break;
786 case 'I':
787 strncpy(Ident, optarg, IDENT_SIZE);
788 Ident[IDENT_SIZE - 1] = 0;
789 if ( strchr(Ident, ' ') ) {
790 fprintf(stderr,"Ident must not contain spaces\n");
791 exit(255);
792 }
793 break;
794 case 'w':
795 synctime = 1;
796 break;
797 case 'B':
798 bufflen = strtol(optarg, &checkptr, 10);
799 if ( (checkptr != NULL && *checkptr == 0) && bufflen > 0 )
800 break;
801 fprintf(stderr,"Argument error for -B\n");
802 exit(255);
803 case 'b':
804 bindaddr = optarg;
805 break;
806 case 'p':
807 portnum = strtol(optarg, &checkptr, 10);
808 if ( (checkptr != NULL && *checkptr == 0) && portnum > 0 )
809 break;
810 fprintf(stderr,"Argument error for -p\n");
811 exit(255);
812 break;
813 case 'P':
814 pidfile = optarg;
815 break;
816 case 'r':
817 report_sequence = 1;
818 break;
819 case 'l':
820 datadir = optarg;
821 err = stat(datadir, &fstat);
822 if ( !(fstat.st_mode & S_IFDIR) ) {
823 fprintf(stderr, "No such directory: %s\n", datadir);
824 break;
825 }
826 break;
827 case 't':
828 twin = atoi(optarg);
829 if ( twin <= 0 ) {
830 fprintf(stderr, "ERROR: time frame <= 0\n");
831 exit(255);
832 }
833 if (twin < 60) {
834 fprintf(stderr, "WARNING, Very small time frame - < 60s!\n");
835 }
836 break;
837 case 'x':
838 lauch_process = optarg;
839 break;
840 default:
841 usage(argv[0]);
842 exit(255);
843 }
844 }
845
846 openlog(argv[0] , LOG_CONS|LOG_PID, SYSLOG_FACILITY);
847
848 SetPriv(userid, groupid);
849
850 if ( pidfile ) {
851 pidf = open(pidfile, O_CREAT|O_RDWR, 0644);
852 if ( pidf == -1 ) {
853 syslog(LOG_ERR, "Error opening pid file '%s': %s", pidfile, strerror(errno));
854 fprintf(stderr,"Terminated due to errors.\n");
855 exit(255);
856 }
857 pid = getpid();
858 snprintf(pidstr,31,"%i\n", pid);
859 write(pidf, pidstr, strlen(pidstr));
860 close(pidf);
861 }
862
863 if ( lauch_process ) {
864 // for efficiency reason, the process collecting the data
865 // and the process launching processes, when a new file becomes
866 // available are separated. Communication is done using signals
867 // as well as shared memory
868 // prepare shared memory
869 shmem = mmap(0, sizeof(srecord_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
870 if ( shmem == (caddr_t)-1 ) {
871 perror("mmap error");
872 exit(255);
873 }
874
875 commbuff = (srecord_t *)shmem;
876 strncpy(commbuff->ident, Ident, IDENT_SIZE );
877 commbuff->ident[IDENT_SIZE - 1] = 0;
878
879 if ((launcher_pid = fork()) == -1) {
880 syslog(LOG_ERR, "Can't fork: %s", strerror(errno));
881 perror("Can't fork()");
882 } else if ( launcher_pid == 0 ) { // child
883
884 // close stdin, stdout and stderr
885 close(0);
886 close(1);
887 close(2);
888 fd = open("/dev/null",O_RDWR); /* open stdin */
889 dup(fd); /* stdout */
890 dup(fd); /* stdout */
891
892 launcher((char *)shmem, datadir, lauch_process);
893 exit(0);
894 } else {
895 launcher_alive = 1;
896 syslog(LOG_DEBUG, "Launcher forked");
897 }
898 // parent continues
899 }
900
901 if (argc - optind > 1) {
902 usage(argv[0]);
903 kill_launcher(launcher_pid);
904 exit(255);
905 } else {
906 /* user specified a pcap filter */
907 filter = argv[optind];
908 }
909
910 sock = Setup_Socket(bindaddr, portnum, bufflen );
911 if ( sock == -1 ) {
912 kill_launcher(launcher_pid);
913 fprintf(stderr,"Terminated due to errors.\n");
914 exit(255);
915 }
916
917 if ( synctime ) {
918 t_tmp = time(NULL);
919 t_start = t_tmp - ( t_tmp % twin);
920 } else
921 t_start = time(NULL);
922
923 if ( daemonize ) {
924 verbose = 0;
925 if ((pid = fork()) < 0 ) {
926 perror("Can't fork()");
927 } else if (pid) {
928 if (pidfile) {
929 pidf = open(pidfile, O_CREAT|O_RDWR, 0644);
930 if ( pidf == -1 ) {
931 syslog(LOG_ERR, "Error opening pid file: '%s' %s", pidfile, strerror(errno));
932 perror("Error opening pid file:");
933 kill_launcher(launcher_pid);
934 exit(255);
935 }
936 snprintf(pidstr,31,"%i\n", pid);
937 write(pidf, pidstr, strlen(pidstr));
938 close(pidf);
939 }
940 exit (0); /* parent */
941 } // else -> child continues
942
943 if (setsid() < 0) {
944 syslog(LOG_ERR, "Can't create new session: '%s'", strerror(errno));
945 exit(255);
946 }
947 // close stdin, stdout and stderr
948 close(0);
949 close(1);
950 close(2);
951 fd = open("/dev/null",O_RDWR); /* open stdin */
952 dup(fd); /* stdout */
953 dup(fd); /* stdout */
954 }
955
956 if ( chdir(datadir)) {
957 syslog(LOG_ERR, "Error can't chdir to '%s': %s", datadir, strerror(errno));
958 kill_launcher(launcher_pid);
959 exit(255);
960 }
961 done = 0;
962
963 /* Signal handling */
964 memset((void *)&act,0,sizeof(struct sigaction));
965 act.sa_handler = IntHandler;
966 sigemptyset(&act.sa_mask);
967 act.sa_flags = 0;
968 sigaction(SIGTERM, &act, NULL);
969 sigaction(SIGINT, &act, NULL);
970 sigaction(SIGHUP, &act, NULL);
971 sigaction(SIGALRM, &act, NULL);
972 sigaction(SIGCHLD, &act, NULL);
973
974 syslog(LOG_INFO, "Startup.");
975 run(sock, bufflen, twin, t_start, report_sequence);
976 close(sock);
977 syslog(LOG_INFO, "Terminating nfcapd.");
978
979 if ( pidfile )
980 unlink(pidfile);
981
982 closelog();
983 kill_launcher(launcher_pid);
984 exit(0);
985
986 } /* End of main */
0 #!/usr/bin/perl
1 #
2 # Sample script to clean old data.
3 # Run this script each hour to cleanup old files to make room for
4 # new data. When max_size_spool is reached the oldest files are
5 # deleted down to high_water.
6 #
7 # Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
8 # All rights reserved.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions are met:
12 #
13 # * Redistributions of source code must retain the above copyright notice,
14 # this list of conditions and the following disclaimer.
15 # * Redistributions in binary form must reproduce the above copyright notice,
16 # this list of conditions and the following disclaimer in the documentation
17 # and/or other materials provided with the distribution.
18 # * Neither the name of SWITCH nor the names of its contributors may be
19 # used to endorse or promote products derived from this software without
20 # specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 #
34 # $Author: peter $
35 #
36 # $Id: nfclean.pl 15 2004-12-20 12:43:36Z peter $
37 #
38 # $LastChangedRevision: 15 $
39
40 use strict;
41
42 # Configuration
43 # Define all the netflow sources you have
44 my @flow_sources = ( 'router1', 'router2', 'router3', 'router4' );
45
46 #
47 # Linux does not support spool devices larger than 1TB. If you still want
48 # your spool device larger than 1TB you need to split it into two different
49 # drives of equally size. New data is stored in flow_base_dir, and shifted
50 # into carry_base_dir when max_size_spool is reached.
51 # If you do not have two spool devices set carry_base_dir to 'undef'
52 # At least set flow_base_dir to your spool directory
53 my $flow_base_dir = '/netflow0/nfsen/spool';
54 my $carry_base_dir = undef;
55
56 # To which size may flow_base_dir and carry_base_dir grow
57 my $max_size_spool = 0.95 * 1024 * 1024 * 1024 * 1024; # 0.95TB
58
59 my $high_water = 0.9; # when we delete files, we delete down to max_size * high_water
60
61 # End of configuration
62
63 my ($date_extension);
64 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
65 $mon++;
66 $date_extension = $year += 1900;
67 $date_extension .= $mon < 10 ? "0$mon" : "$mon";
68 $date_extension .= $mday < 10 ? "0$mday" : "$mday";
69 $date_extension .= $hour < 10 ? "0$hour" : "$hour";
70 $date_extension .= $min < 10 ? "0$min" : "$min";
71
72 sub CleanDir {
73 my $flow_base_dir = shift;
74 my $carry_base_dir = shift;
75 my $max_size = shift;
76
77 if ( defined $carry_base_dir ) {
78 CleanDir($carry_base_dir, undef, $max_size);
79 }
80
81 my $ksize = $max_size / 1024;
82 print "Clean Dir $flow_base_dir up to $ksize k\n";
83 #
84 # Get a list of all argus files in all directories
85 my @AllFiles;
86 foreach my $flow ( @flow_sources ) {
87 opendir(DIR, "$flow_base_dir/$flow" ) || die "can't opendir '$flow_base_dir/$flow' : $!";
88 push @AllFiles, map{ "$flow_base_dir/$flow/" . $_} grep { /^nf[\w]*\.\d+$/ && -f "$flow_base_dir/$flow/$_" } readdir(DIR);
89 closedir DIR;
90 }
91
92 if ( scalar(@AllFiles) == 0 ) {
93 warn "No files to process\n";
94 return;
95 }
96
97 #
98 # Create a hash with key = filename and value = filesize
99 my %File_Sizes = map { $_ => (stat($_))[7] } @AllFiles;
100
101 #
102 # calculate total size of all files
103 my $total_size = 0;
104 foreach my $file ( keys %File_Sizes ) {
105 # print "$file: $File_Sizes{$file}\n";
106 $total_size += $File_Sizes{$file};
107 }
108 $ksize = $total_size / 1024;
109 print "Total Size: $ksize k\n";
110
111 #
112 # check if we are within max_size
113 if ( $total_size > $max_size ) {
114 print "Total size $total_size > $max_size. Cleaning up ...\n";
115 # hmm .. we need to delete some files
116 # we do this by sorting all files accoring their mtime
117 # and delete until we have max_size * high_water
118 my %mtime_stamp = map { $_ => (stat($_))[9] } @AllFiles;
119 my @sorted_mtime = sort { $mtime_stamp{$a} <=> $mtime_stamp{$b} } keys %mtime_stamp;
120 my $max_allowed = $max_size * $high_water;
121 my $file;
122 do {
123 my $what;
124 my ( $base, $source, $filename, $command );
125 $file = shift @sorted_mtime;
126 if ( defined $carry_base_dir ) {
127 $what = 'Moving';
128 ( $source, $filename ) = $file =~ m#.+/(\w+)/([^/]+)$#;
129 $command = "/bin/mv $file $carry_base_dir/$source/$filename";
130 system("$command");
131 $command = "/bin/mv ${file}.stat $carry_base_dir/$source/${filename}.stat";
132 system("$command");
133 } else {
134 $what = 'Unlinking';
135 unlink $file;
136 unlink "$file.stat" if -f "$file.stat";
137 }
138 if ( -f "$file.stat" ) {
139 print "$what $file and stat file. size: $File_Sizes{$file} New total: $total_size\n";
140 } else {
141 print "$what $file size: $File_Sizes{$file} New total: $total_size\n";
142 }
143 $total_size -= $File_Sizes{$file};
144 } while $total_size > $max_allowed;
145 }
146
147 } # End of CleanDir
148
149 #
150 # Main starts here
151 #
152
153 # Expire old data
154 &CleanDir($flow_base_dir, $carry_base_dir, $max_size_spool);
155
0 .TH nfdump 1 2005-08-19 "" ""
1 .SH NAME
2 nfdump \- netflow display and analyze program
3 .SH SYNOPSIS
4 .HP 5
5 .B nfdump [options] [filter]
6 .SH DESCRIPTION
7 .B nfdump
8 is the netflow display and analyzing program of the nfdump tool set.
9 It reads the netflow data from files stored by nfcapd and processes
10 the flows according the options given. The filter syntax is comparable
11 to tcpdump and extended for netflow data. Nfdump can also display many
12 different top N flow and flow element statistics.
13
14 .SH OPTIONS
15 .TP 3
16 .B -r \fIinputfile
17 Read input data from \fIinputfile\fR. Default is read from stdin.
18 .TP 3
19 .B -R \fIexpr
20 Read input from a sequence of concatenated files. The \fIexpr\fR
21 may be one of:
22 .PD 0
23 .RS 4
24 /any/\fIdir\fR Read all files in directory \fIdir\fR.
25 .P
26 /dir/\fIfile\fR Read all files beginning with \fIfile\fR.
27 .P
28 /dir/\fIfile1:file2\fR Read all files from \fIfile1\fR to \fIfile2\fR.
29 .RE
30 .PD
31 .TP 3
32 .B -M \fIexpr
33 Read input from multiple directories. The \fIexpr\fR looks like:
34 \fI/any/path/to/dir1:dir2:dir3\fR etc. and will be expanded to the
35 directories: \fI/any/path/to/dir1\fR, \fI/any/path/to/dir2\fR and
36 \fI/any/path/to/dir3\fR Any number of colon separated directories may
37 be given. The files to read are specified by -r or -R and are expected
38 to exist in all the given directories. The options -r and -R must
39 not contain any directory part when used in conjunction with -M.
40 .TP 3
41 .B -m
42 Sort the netflow records according the date first seen. This option is
43 usually only useful in conjunction with -M, when netflow records are
44 read from different sources, which are not necessarily sorted.
45 .TP 3
46 .B -w \fIoutputfile
47 If specified writes binary netflow records to \fIoutputfile\fR ready
48 to be processed again with nfdump. The default output is ASCII on
49 stdout.
50 .TP 3
51 .B -f \fIfilterfile
52 Reads the filter syntax from \fIfilterfile\fR. Note: Any filter specified
53 directly on the command line takes precedence over -f.
54 .TP 3
55 .B -t \fItimewin
56 Process only flows, which fall in the time window \fItimewin\fR, where
57 \fItimewin\fR is YYYY/MM/dd.hh:mm:ss[-YYYY/MM/dd.hh:mm:ss]. Any parts of
58 the time spec may be omitted e.g YYYY/MM/dd expands to
59 YYYY/MM/dd.00:00:00-YYYY/MM/dd.23:59:59 and processes all flow from a
60 given day. The time window may also be specified as +/- n. In this case
61 it is relative to the beginning or end of all flows. +10 means the first
62 10 seconds of all flows, -10 means the last 10 seconds of all flows.
63 .TP 3
64 .B -c \fInum
65 Limit number of records to process to the first \fInum\fR flows.
66 .TP 3
67 .B -a
68 Aggregate netflow data. Aggregation is done at connection level.
69 .TP 3
70 .B -A \fIfields
71 Aggregate netflow data using the specified fields, where fields is a ','
72 separated list out of \fIsrcip dstip srcport dstport\fR. The default is using
73 all fields: \fIsrcip,dstip,srcport,dstport\fR. Only flows of the same protocol
74 are aggregated.
75 .TP 3
76 .B -S
77 Compatibility option with pre 1.4 nfdump. Is equal to \fI-s record/packets/bytes\fR.
78 .TP 3
79 .B -s \fIstatistic[/orderby]
80 Generate the Top N flow or flow element statistic. \fIstatistic\fR can be:
81 .PD 0
82 .RS 5
83 record Statistic about aggregated netflow records.
84 .P
85 srcip Statistic about source IP addresses
86 .P
87 dstip Statistic about destination IP addresses
88 .P
89 ip Statistic about any (source or destination) IP addresses
90 .P
91 srcport Statistic about source ports
92 .P
93 dstport Statistic about destination ports
94 .P
95 port Statistic about any (source or destination) ports
96 .P
97 srcas Statistic about source AS numbers
98 .P
99 dstas Statistic about destination AS numbers
100 .P
101 as Statistic about any (source or destination) AS numbers
102 .P
103 .RE
104 .RS 3
105 .P
106 \fIorderby\fR is optional and specifies the order by which the statistics is
107 ordered and can be \fIflows\fR, \fIpackets\fR, \fIbytes\fR, \fIpps\fR, \fIbps\fR
108 or \fIbpp\fR. You may specify more than one \fIorderby\fR which results in the
109 same statistic but ordered differently. If no \fIorderby\fR is given, statistics
110 are ordered by \fIflows\fR.
111 You can specify as many -s flow element statistics on the command line for the
112 same run.
113 .P
114 Example: -s srcip -s ip/flows -s dstport/pps/packets/bytes -s record/bytes
115 .RE
116 .PD
117 .TP 3
118 .B -O \fIorderby
119 Specifies the default \fIorderby\fR for flow element statistics -s, which
120 applies when no \fIorderby\fR is given at -s. \fIorderby\fR can be \fIflows\fR,
121 \fIpackets\fR, \fIbytes\fR, \fIpps\fR, \fIbps\fR or \fIbpp\fR. Defaults to \fIflows\fR.
122 .TP 3
123 .B -l \fI[+/-]packet_num
124 Limit statistics output to those records above or below the \fIpacket_num\fR
125 limit. \fIpacket_num\fR accepts positive or negative numbers followed by 'K'
126 , 'M' or 'G' 10E3, 10E6 or 10E9 flows respectively. See also note at -L
127 .TP 3
128 .B -L \fI[+/-]byte_num
129 Limit statistics output to those records above or below the \fIbyte_num\fR
130 limit. \fIbyte_num\fR accepts positive or negative numbers followed by 'K'
131 , 'M' or 'G' 10E3, 10E6 or 10E9 bytes respectively. \fINote:\fR These limits only
132 apply to the statistics and aggregated outputs generated with -a -s or -S.
133 To filter netflow records by packets and bytes, use the filter syntax 'packets'
134 and 'bytes' described below.
135 .TP 3
136 .B -n \fInum
137 Define the number for the Top N statistics. Defaults to 10. If 0 is specified
138 the number is unlimited.
139 .TP 3
140 .B -o \fIformat
141 Selects the output format to print flows or flow statistics (-S). The following
142 formats are available:
143 .PD 0
144 .RS 5
145 raw Print each flow on multiple lines.
146 .P
147 line Print each flow on one line. Default format.
148 .P
149 long Print each flow on one line with more details
150 .P
151 extended Print each flow on one line with even more details.
152 .P
153 pipe Machine readable format: Print all fields '|' separated.
154 .RE
155 .RS 3
156 See \fIoutput formats\fR below for more information
157 .RE
158 .PD
159 .TP 3
160 .B -K \fIkey
161 Anonymize all IP addresses using the CryptoPAn (Cryptography-based
162 Prefix-preserving Anonymization) module. The key is used to
163 initialize the Rijndael cipher. \fIkey\fR is either a 32 character
164 string, or a 64 hex digit string starting with 0x. Anonymizing takes
165 place \fIafter\fR applying the flow filter, but before printing the flow
166 or writing the flow to a file.
167 .P
168 .RS 3
169 See http://www.cc.gatech.edu/computing/Telecomm/cryptopan/ for
170 more information about CryptoPAn.
171 .RE
172 .TP 3
173 .B -Z
174 Check filter syntax and exit. Sets the return value accordingly.
175 .TP 3
176 .B -X
177 Compiles the filer syntax and dumps the filter engine table to stdout.
178 This is for debugging purpose only.
179 .TP 3
180 .B -V
181 Print nfdump version and exit.
182 .TP 3
183 .B -h
184 Print help text on stdout with all options and exit.
185 .SH "RETURN VALUE"
186 Returns
187 .PD 0
188 .RS 4
189 0 No error. \fn
190 .P
191 255 Initialization failed.
192 .P
193 254 Error in filter syntax.
194 .P
195 250 Internal error.
196 .RE
197 .PD
198 .SH "OUTPUT FORMATS"
199 The output format \fBraw\fR prints each flow record on multiple lines, including
200 all information available in the record. This is the most detailed view on a
201 flow. Use this output format, if you are interested in the details of flows, not
202 printed in the other output formats.
203 .P
204 The output format \fBline\fR is the default output format when no format is specified.
205 It prints the flow record each on a single line and limits the information to the
206 connection details as well as number of packets, bytes and flows.
207 .P
208 The output format \fBlong\fR is identical to the format \fBline\fR, and includes
209 additional information such as TCP flags and Type of Service.
210 .P
211 The output format \fBextended\fR is identical to the format \fBlong\fR, and includes
212 additional computed information such as \fBpps\fR, \fBbps\fR and \fBbpp\fR.
213 .P
214 \fIFields:\fR
215 .P
216 .RS 3
217 \fBDate flow start:\fR Start time flow first seen. ISO 8601 format
218 including milliseconds.
219 .P
220 \fBDuration:\fR Duration of the flow in seconds and milliseconds.
221 If flows are aggregated, \fIduration\fR is the time span over the
222 entire period of time from first seen to last seen.
223 .P
224 \fBProto:\fR Protocol used in the connection.
225 .P
226 \fBSrc IP Addr:Port:\fR Source IP address and source port.
227 .P
228 \fBDst IP Addr:Port:\fR Destination IP address and destination port.
229 .P
230 \fBFlags:\fR TCP flags ORed of the connection.
231 .P
232 \fBTos:\fR Type of service.
233 .P
234 \fBPackets:\fR The number of packets in this flow. If flows are
235 aggregated, the packets are summed up.
236 .P
237 \fBBytes:\fR The number of bytes in this flow. If flows are aggregated,
238 the bytes are summed up.
239 .P
240 \fBpps:\fR The calculated packets per second: number of packets / duration.
241 If flows are aggregated this results in the average pps during this period of time.
242 .P
243 \fBbps:\fR The calculated bits per second: 8 * number of bytes / duration. If flows
244 are aggregated this results in the average bps during this period of time.
245 .P
246 \fBBpp:\fR The calculated bytes per packet: number of bytes / number of packets. If flows
247 are aggregated this results in the average bpp during this period of time.
248 .P
249 \fBFlows:\fR Number of flows. If flows are listed only, this number is always 1. If flows
250 are aggregated, this shows the number of aggregated flows to one record.
251 .P
252 Numbers larger than 1048576 (1024*1024), are scaled to 4 digits and one decimal digit including the
253 scaling factor \fBM\fR, \fBG\fR or \fBT\fR for cleaner output, e.g. \fB923.4 M\fR
254 .PE
255 .SH "FILTER
256 "
257 The filter syntax is similar to the well known pcap library used by tcpdump.
258 The filter can be either specified on the command line after all options or
259 in a separate file. It can span several lines. Anything after a '#' is treated as a
260 comment and ignored to the end of the line. There is virtually no limit in
261 the length of the filter expression. All keywords are case independent.
262 .P Syntax
263 Any filter consists of one or more expressions \fIexpr\fR. Any number of \fIexpr\fR
264 can be linked together:
265 .P
266 expr \fBand\fR expr, expr \fBor\fR expr, \fBnot\fR expr and \fB(\fR expr \fB)\fR.
267 .P
268 \fIExpr\fR can be one of the following filter primitives:
269 .TP 4
270 .I protocol
271 \fBTCP, UDP, ICMP, GRE, ESP, AH, RSVP\fR or \fBPROTO\fR \fInum\fR where \fInum\fR is the protocol
272 number.
273 .TP 4
274 .I IP address
275 .PD 0
276 .RS 4
277 \fB[SourceDestination]\fR \fBIP\fR \fIa.b.c.d\fR or
278 .P
279 \fB[SourceDestination]\fR \fBHOST\fR \fIa.b.c.d\fR with \fIa.b.c.d\fR as any valid IP address.
280 \fISourceDestination\fR may be omitted.
281 .RE
282 .PD
283 .TP 4
284 .I SourceDestination
285 defines the IP address to be selected and can be \fBSRC\fR
286 \fBDST\fR or any combination of \fBSRC and|or DST\fR. Omitting \fISourceDestination\fR is
287 equivalent to \fBSRC or DST\fR.
288 .TP 4
289 .I network
290 \fI[SourceDestination]\fR \fBNET\fR \fIa.b.c.d\fR \fIm.n.r.s\fR
291 .PD 0
292 .RS 4
293 \fI[SourceDestination]\fR \fBNET\fR \fIa.b.c.d\fR / \fInum\fR with \fIa.b.c.d\fR
294 as network number, \fIm.n.r.s\fR as netmask or \fInum\fR as maskbits respectively.
295 The network may be given as \fIa.b\fR, \fIa.b.c\fR, where a B or C-class equivalent netmask
296 is assumed.
297 .RE
298 .PD
299 .TP 4
300 .I Port
301 \fI[SourceDestination]\fR \fBPORT\fR \fI[comp]\fR \fInum\fR with \fInum\fR as a valid port number.
302 If \fIcomp\fR is omitted, '=' is assumed.
303 .TP 4
304 .I Interface
305 \fI[inout]\fR \fBIF\fR \fInum\fR with \fInum\fR as an interface number.
306 .TP 4
307 .I inout
308 defines the interface to be selected and can be \fBIN\fR or
309 \fBOUT\fR.
310 .TP 4
311 .I Flags
312 \fBflags\fR \fItcpflags\fR with \fItcpflags\fR as a combination of:
313 .PD 0
314 .RS 4
315 A ACK.
316 .P
317 S SYN.
318 .P
319 F FIN.
320 .P
321 R Reset.
322 .P
323 P Push.
324 .P
325 U Urgent.
326 .P
327 X All flags on.
328 .RE
329 .PD
330 The ordering of the flags is not relevant. Flags not mentioned are treated as don't care.
331 In order to get those flows with only the SYN flag set, use the syntax '\fBflags S and not
332 flags AFRPU\R '.
333 .TP 4
334 .I TOS
335 Type of service: \fBtos\fR \fIvalue\fR with \fIvalue\fR 0..255.
336 .TP 4
337 .I Packets
338 \fBpackets\fR \fI[comp]\fR \fInum\fR \fI[scale]\fR to specify the packet count in the netflow record.
339 .TP 4
340 .I Bytes
341 \fBbytes\fR \fI[comp]\fR \fInum\fR \fI[scale]\fR to specify the byte count in the netflow record.
342 .TP 4
343 .I Packets per second: Calculated value.
344 \fBpps\fR \fI[comp]\fR \fInum\fR \fI[scale]\fR to specify the pps of the flow.
345 .TP 4
346 .I Duration: Calculated value
347 \fBduration\fR \fI[comp]\fR \fInum\fR to specify the duration in milliseconds of the flow.
348 .TP 4
349 .I Bits per second: Calculated value.
350 \fBbps\fR \fI[comp]\fR \fInum\fR \fI[scale]\fR to specify the bps of the flow.
351 .TP 4
352 .I Bytes per packet: Calculated value.
353 \fBbpp\fR \fI[comp]\fR \fInum\fR \fI[scale]\fR to specify the bpp of the flow.
354 .TP 4
355 .I AS
356 \fI[SourceDestination]\fR \fBAS\fR \fInum\fR with \fInum\fR as a valid AS number.
357 .TP 4
358 \fIscale\fR scaling factor. Maybe \fIk\fR \fIm\fR \fIg\fR. Factor is 1024
359 .TP 4
360 \fIcomp\fR The following comparators are supported:
361 .B =, ==, >, <, EQ, LT, GT .
362 If \fIcomp\fR is omitted, '=' is assumed.
363 .SH "EXAMPLES"
364 .B nfdump -r /and/dir/nfcapd.200407110845 -c 100 'tcp and ( src ip 172.16.17.18 or dst ip 172.16.17.19 )'
365 Dumps the first 100 netflow records which match the given filter:
366 .P
367 .B nfdump -R /and/dir/nfcapd.200407110845:nfcapd.200407110945 'host 192.168.1.2'
368 Dumps all netflow records of host 192.168.1.2 from July 11 08:45 - 09:45
369 .P
370 .B nfdump -M /to/and/dir1:dir2 -R nfcapd.200407110845:nfcapd.200407110945 -S -n 20
371 Generates the Top 20 statistics from 08:45 to 09:45 from 3 sources
372 .P
373 .B nfdump -r /and/dir/nfcapd.200407110845 -S -n 20 -o extended
374 Generates the Top 20 statistics, extended output format
375 .P
376 .B nfdump -r /and/dir/nfcapd.200407110845 -S -n 20 'in if 5 and bps > 10k'
377 Generates the Top 20 statistics from flows coming from interface 5
378 .P
379 .B cat file1 file2 file3 | nfdump 'tcp and ( src port > 1024 and dst port 80 )
380 nfdump reads from stdin and dumps all port 80 connections to any web server.
381 .SH NOTES
382 Generating the statistics for data files of a few hundred MB is no problem. However
383 be careful if you want to create statistics of several GB of data. This may consume a lot
384 of memory and can take a while. Also, anonymizing IP addresses is time consuming and uses
385 a lot of CPU power, which reduces the number of flows per second. Therefore anonymizing
386 takes place only, when flow records are printed or written to files. Any internal flow
387 processing takes place using the original IP addresses.
388 .SH "SEE ALSO"
389 nfcapd(1), nfprofile(1), nfreplay(1)
390 .SH BUGS
391 There is still the famous last bug. Please report them - all the last bugs - back to me.
392
0 /*
1 * nfdump : Reads netflow data from files, saved by nfcapd
2 * Data can be view, filtered and saved to
3 * files.
4 *
5 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * * Neither the name of SWITCH nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Author: peter $
33 *
34 * $Id: nfdump.c 53 2005-11-17 07:45:34Z peter $
35 *
36 * $LastChangedRevision: 53 $
37 *
38 *
39 */
40
41 #include <stdio.h>
42 #include <unistd.h>
43 #include <stdlib.h>
44 #include <errno.h>
45 #include <time.h>
46 #include <string.h>
47 #include <ctype.h>
48 #include <sys/types.h>
49 #include <sys/stat.h>
50 #include <fcntl.h>
51
52 #include "config.h"
53
54 #ifdef HAVE_STDINT_H
55 #include <stdint.h>
56 #endif
57
58
59 #include "netflow_v5.h"
60 #include "nf_common.h"
61 #include "nftree.h"
62 #include "nfprof.h"
63 #include "nfdump.h"
64 #include "nfstat.h"
65 #include "version.h"
66 #include "util.h"
67 #include "panonymizer.h"
68
69 /* hash parameters */
70 #define HashBits 20
71 #define NumPrealloc 128000
72
73
74 /* Global Variables */
75 FilterEngine_data_t *Engine;
76 uint32_t byte_limit, packet_limit;
77 int byte_mode, packet_mode;
78
79 /* Local Variables */
80 static char const *rcsid = "$Id: nfdump.c 53 2005-11-17 07:45:34Z peter $";
81 static uint64_t total_bytes;
82 static uint32_t total_flows;
83
84 // Header Legends
85 #define HEADER_LINE "Date flow start Duration Proto Src IP Addr:Port Dst IP Addr:Port Packets Bytes Flows"
86 // 2004-07-11 10:31:50.110 120.010 TCP 172.16.8.66:8024 -> 172.16.12.18:25 5000 953.7 M 1
87
88
89 #define HEADER_LINE_LONG "Date flow start Duration Proto Src IP Addr:Port Dst IP Addr:Port Flags Tos Packets Bytes Flows"
90 // 2004-07-11 10:31:50.110 120.010 TCP 172.16.8.66:8024 -> 172.16.12.18:25 UAPRSF 0 5000 953.7 M 1
91
92
93 #define HEADER_LINE_EXTENDED "Date flow start Duration Proto Src IP Addr:Port Dst IP Addr:Port Flags Tos Packets Bytes pps bps Bpp Flows"
94 // 2004-07-11 10:31:50.110 120.010 TCP 172.16.8.66:8024 -> 172.16.12.18:25 UAPRSF 0 5000 953.7 M 41 1041579 200000 1
95
96
97 // Assign print functions for all output options -o
98 // Teminated with a NULL record
99 struct printmap_s {
100 char *printmode; // name of mode
101 int sorted; // does it make sense to sort the output in this mode?
102 printer_t func; // name of the function, which prints the record
103 char *HeaderLine; // Header line for each output format, if needed. NULL otherwise
104 } printmap[] = {
105 { "raw", 0, flow_record_raw, NULL },
106 { "line", 1, flow_record_to_line, HEADER_LINE },
107 { "long", 1, flow_record_to_line_long, HEADER_LINE_LONG },
108 { "extended", 1, flow_record_to_line_extended, HEADER_LINE_EXTENDED },
109 { "pipe", 0, flow_record_to_pipe, NULL },
110 { NULL, 0, NULL, NULL }
111 };
112
113 #define DefaultMode "line"
114
115 // compare at most 16 chars
116 #define MAXMODELEN 16
117
118 // all records should be version 5
119 #define FLOW_VERSION 5
120
121 /* Function Prototypes */
122 static void usage(char *name);
123
124 static int ParseAggregateMask( char *arg, uint32_t *AggregateMasks );
125
126 static int ParseCryptoPAnKey ( char *s, char *key );
127
128 static uint32_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows,
129 printer_t print_header, printer_t print_record, time_t twin_start, time_t twin_end,
130 uint64_t limitflows, uint32_t *AggregateMasks, int anon);
131
132 /* Functions */
133 static void usage(char *name) {
134 printf("usage %s [options] [\"filter\"]\n"
135 "-h\t\tthis text you see right here\n"
136 "-V\t\tPrint version and exit.\n"
137 "-a\t\tAggregate netflow data.\n"
138 "-A <expr>\tWhat to aggregate: ',' sep list of 'srcip dstip srcport dstport'\n"
139 "-r\t\tread input from file\n"
140 "-w\t\twrite output to file\n"
141 "-f\t\tread netflow filter from file\n"
142 "-n\t\tDefine number of top N. \n"
143 "-c\t\tLimit number of records to display\n"
144 "-S\t\tGenerate netflow statistics info.\n"
145 "-s\t\tGenerate SRC IP statistics.\n"
146 "-s <expr>\tGenerate statistics for <expr>: srcip, dstip, ip.\n"
147 "-l <expr>\tSet limit on packets for line and packed output format.\n"
148 "-K <key>\tAnonymize IP addressses using CryptoPAn with key <key>.\n"
149 "\t\tkey: 32 character string or 64 digit hex string starting with 0x.\n"
150 "-L <expr>\tSet limit on bytes for line and packed output format.\n"
151 "-M <expr>\tRead input from multiple directories.\n"
152 "\t\t/dir/dir1:dir2:dir3 Read the same files from '/dir/dir1' '/dir/dir2' and '/dir/dir3'.\n"
153 "\t\treqquests either -r filename or -R firstfile:lastfile without pathnames\n"
154 "-m\t\tPrint netflow data date sorted. Only useful with -M\n"
155 "-R <expr>\tRead input from sequence of files.\n"
156 "\t\t/any/dir Read all files in that directory.\n"
157 "\t\t/dir/file Read all files beginning with 'file'.\n"
158 "\t\t/dir/file1:file2: Read all files from 'file1' to file2.\n"
159 "-o <mode>\tUse <mode> to print out netflow records:\n"
160 "\t\t raw Raw record dump.\n"
161 "\t\t line Standard output line format.\n"
162 "\t\t long Standard output line format with additional fields.\n"
163 "\t\t extended Even more information.\n"
164 "\t\t pipe '|' separated, machine parseable output format.\n"
165 "-X\t\tDump Filtertable and exit (debug option).\n"
166 "-Z\t\tCheck filter syntax and exit.\n"
167 "-t <time>\ttime window for filtering packets\n"
168 "\t\tyyyy/MM/dd.hh:mm:ss[-yyyy/MM/dd.hh:mm:ss]\n", name);
169 } /* usage */
170
171 static int ParseAggregateMask( char *arg, uint32_t *AggregateMasks ) {
172 char *p;
173
174 p = strtok(arg, ",");
175 while ( p ) {
176 if ( strcasecmp(p, "srcip" ) == 0 ) {
177 AggregateMasks[0] = 0xffffffff;
178 } else if ( strcasecmp(p, "dstip" ) == 0 ) {
179 AggregateMasks[1] = 0xffffffff;
180 } else if ( strcasecmp(p, "srcport" ) == 0 ) {
181 AggregateMasks[2] = 0xffffffff;
182 } else if ( strcasecmp(p, "dstport" ) == 0 ) {
183 AggregateMasks[3] = 0xffffffff;
184 } else {
185 fprintf(stderr, "Unknown aggregate field: '%s'\n", p);
186 return 0;
187 }
188 p = strtok(NULL, ",");
189 }
190 return 1;
191 } /* End of ParseAggregateMask */
192
193 static int ParseCryptoPAnKey ( char *s, char *key ) {
194 int i, j;
195 char numstr[3];
196
197 if ( strlen(s) == 32 ) {
198 // Key is a string
199 strncpy(key, s, 32);
200 return 1;
201 }
202
203 tolower(s[1]);
204 numstr[2] = 0;
205 if ( strlen(s) == 66 && s[0] == '0' && s[1] == 'x' ) {
206 j = 2;
207 for ( i=0; i<32; i++ ) {
208 if ( !isxdigit(s[j]) || !isxdigit(s[j+1]) )
209 return 0;
210 numstr[0] = s[j++];
211 numstr[1] = s[j++];
212 key[i] = strtol(numstr, NULL, 16);
213 }
214 return 1;
215 }
216
217 // It's an invalid key
218 return 0;
219
220 } // End of ParseCryptoPAnKey
221
222 uint32_t process_data(char *wfile, int element_stat, int flow_stat, int sort_flows,
223 printer_t print_header, printer_t print_record, time_t twin_start, time_t twin_end,
224 uint64_t limitflows, uint32_t *AggregateMasks, int anon) {
225 flow_header_t flow_header;
226 flow_record_t *flow_record, *record_buffer;
227 uint16_t cnt;
228 uint32_t NumRecords;
229 time_t win_start, win_end, first_seen, last_seen;
230 uint64_t numflows, numbytes, numpackets;
231 int i, rfd, wfd, nffd, done, ret, request_size, *ftrue, do_stat, has_aggregate_mask, old_format;
232 uint64_t numflows_tcp, numflows_udp, numflows_icmp, numflows_other;
233 uint64_t numbytes_tcp, numbytes_udp, numbytes_icmp, numbytes_other;
234 uint64_t numpackets_tcp, numpackets_udp, numpackets_icmp, numpackets_other;
235 char *string, sfile[255], tmpstring[64];
236
237 if ( wfile && ( strcmp(wfile, "-") != 0 )) { // if we write a new file
238 // write a new stat file
239 snprintf(sfile, 254, "%s.stat", wfile);
240 sfile[254] = 0;
241 } else {
242 sfile[0] = 0; // no new stat file
243 }
244
245 // print flows later, when all records are processed and sorted
246 if ( sort_flows ) {
247 print_record = NULL;
248 limitflows = 0;
249 }
250
251 // time window of all processed flows
252 win_start = 0x7fffffff;
253 win_end = 0;
254 SetSeenTwin(0, 0);
255
256 // time window of all matched flows
257 first_seen = 0x7fffffff;
258 last_seen = 0;
259
260 numflows = numbytes = numpackets = 0;
261 numflows_tcp = numflows_udp = numflows_icmp = numflows_other = 0;
262 numbytes_tcp = numbytes_udp = numbytes_icmp = numbytes_other = 0;
263 numpackets_tcp = numpackets_udp = numpackets_icmp = numpackets_other = 0;
264
265 do_stat = element_stat || flow_stat;
266
267 // check for a special aggregate mask
268 has_aggregate_mask = 0;
269 for ( i=0; i<4; i++ )
270 if ( AggregateMasks[i] )
271 has_aggregate_mask = 1;
272
273 // Get the first file handle
274 rfd = GetNextFile(0, twin_start, twin_end);
275 if ( rfd < 0 ) {
276 if ( errno )
277 perror("Can't open input file for reading");
278 return numflows;
279 }
280
281 if ( wfile ) {
282 wfd = strcmp(wfile, "-") == 0 ? STDOUT_FILENO :
283 open(wfile, O_CREAT | O_RDWR | O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
284 if ( wfd < 0 ) {
285 perror("Can't open output file for writing");
286 if ( rfd )
287 close(rfd);
288 return numflows;
289 }
290 } else
291 wfd = 0;
292
293 // allocate buffer suitable for netflow version
294 record_buffer = (flow_record_t *) calloc(BuffNumRecords , FLOW_RECORD_LENGTH);
295
296 ftrue = (int *) calloc(BuffNumRecords , sizeof(int));
297 if ( !record_buffer || !ftrue ) {
298 perror("Memory allocation error");
299 close(rfd);
300 if (wfd )
301 close(wfd);
302 return numflows;
303 }
304
305 done = 0;
306 while ( !done ) {
307 ret = read(rfd, &flow_header, FLOW_HEADER_LENGTH);
308 if ( ret == 0 ) {
309 rfd = GetNextFile(rfd, twin_start, twin_end);
310 if ( rfd < 0 ) {
311 if ( errno )
312 perror("Can't open input file for reading");
313 done = 1;
314 }
315 continue;
316 } else if ( ret == -1 ) {
317 perror("Error reading data");
318 close(rfd);
319 if ( wfd )
320 close(wfd);
321 return numflows;
322 }
323 total_bytes += ret;
324 if ( flow_header.version != FLOW_VERSION ) {
325 fprintf(stdout, "Not a netflow v%i header\n", FLOW_VERSION);
326 close(rfd);
327 if ( wfd )
328 close(wfd);
329 return numflows;
330 }
331 if ( flow_header.count > MAX_RECORDS ) {
332 fprintf(stderr, "Too many records %u ( > MAX_RECORDS )\n", flow_header.count);
333 break;
334 }
335
336 NumRecords = flow_header.count;
337 old_format = flow_header.layout_version != 1;
338
339 request_size = NumRecords * FLOW_RECORD_LENGTH;
340 ret = read(rfd, record_buffer, request_size);
341 if ( ret == 0 ) {
342 done = 1;
343 break;
344 } else if ( ret == -1 ) {
345 perror("Error reading data");
346 close(rfd);
347 if ( wfd )
348 close(wfd);
349 return numflows;
350 }
351 if ( request_size != ret ) {
352 fprintf(stderr, "Short read for netflow records: Expected %i, got %i bytes!\n",request_size, ret );
353 break;
354 }
355 total_bytes += ret;
356
357 // cnt is the number of blocks, which survived the filter
358 // ftrue is an array of flags of the filter result
359 cnt = 0;
360 flow_record = record_buffer;
361 for ( i=0; i < NumRecords; i++ ) {
362 total_flows++;
363
364 /* may be removed when old format died out */
365 if ( old_format ) {
366 flow_record->msec_first = 0;
367 flow_record->msec_last = 0;
368 }
369
370 // Time based filter
371 // if no time filter is given, the result is always true
372 ftrue[i] = twin_start && (flow_record->First < twin_start || flow_record->Last > twin_end) ? 0 : 1;
373 ftrue[i] &= limitflows ? numflows < limitflows : 1;
374 Engine->nfrecord = (uint32_t *)flow_record;
375
376 // filter netflow record with user supplied filter
377 if ( ftrue[i] )
378 ftrue[i] = (*Engine->FilterEngine)(Engine);
379
380 if ( ftrue[i] ) {
381 // Update statistics
382 switch (flow_record->prot) {
383 case 1:
384 numflows_icmp++;
385 numpackets_icmp += flow_record->dPkts;
386 numbytes_icmp += flow_record->dOctets;
387 break;
388 case 6:
389 numflows_tcp++;
390 numpackets_tcp += flow_record->dPkts;
391 numbytes_tcp += flow_record->dOctets;
392 break;
393 case 17:
394 numflows_udp++;
395 numpackets_udp += flow_record->dPkts;
396 numbytes_udp += flow_record->dOctets;
397 break;
398 default:
399 numflows_other++;
400 numpackets_other += flow_record->dPkts;
401 numbytes_other += flow_record->dOctets;
402 }
403 numflows++;
404 numpackets += flow_record->dPkts;
405 numbytes += flow_record->dOctets;
406 cnt++;
407
408 if ( flow_record->First < first_seen )
409 first_seen = flow_record->First;
410 if ( flow_record->Last > last_seen )
411 last_seen = flow_record->Last;
412
413 }
414 if ( flow_record->First < win_start )
415 win_start = flow_record->First;
416 if ( flow_record->Last > win_end )
417 win_end = flow_record->Last;
418
419 // increment pointer by number of bytes for netflow record
420 flow_record = (flow_record_t *)((pointer_addr_t)flow_record + (pointer_addr_t)FLOW_RECORD_LENGTH);
421
422 } // for all records
423
424 // check if we are done, due to -c option
425 if ( limitflows )
426 done = numflows >= limitflows;
427
428 // if no records are left after filtering, continue the read loop
429 if ( cnt == 0 )
430 continue;
431
432 // Else we can process the header and any filtered records
433
434 // set new count in v5 header
435 flow_header.count = cnt;
436
437 // write binary output if requested
438 if ( wfd ) {
439 ret = write(wfd, &flow_header, FLOW_HEADER_LENGTH);
440 if ( ret < 0 ) {
441 perror("Error writing data");
442 close(rfd);
443 if ( wfd )
444 close(wfd);
445 return numflows;
446 }
447
448 flow_record = record_buffer;
449 for ( i=0; i < NumRecords; i++ ) {
450 if ( ftrue[i] ) {
451 if ( anon ) {
452 flow_record->srcaddr = anonymize(flow_record->srcaddr);
453 flow_record->dstaddr = anonymize(flow_record->dstaddr);
454 }
455 ret = write(wfd, flow_record, FLOW_RECORD_LENGTH);
456 if ( ret < 0 ) {
457 perror("Error writing data");
458 close(rfd);
459 return numflows;
460 }
461 }
462 // increment pointer by number of bytes for netflow record
463 flow_record = (flow_record_t *)((pointer_addr_t)flow_record + (pointer_addr_t)FLOW_RECORD_LENGTH);
464 }
465
466 } else if ( do_stat ) {
467 // Add records to netflow statistic hash
468 flow_record = record_buffer;
469 for ( i=0; i< NumRecords; i++ ) {
470 if ( ftrue[i] ) {
471 if ( has_aggregate_mask ) {
472 flow_record->srcaddr &= AggregateMasks[0];
473 flow_record->dstaddr &= AggregateMasks[1];
474 flow_record->srcport &= AggregateMasks[2];
475 flow_record->dstport &= AggregateMasks[3];
476 }
477 AddStat(&flow_header, flow_record, flow_stat, element_stat);
478 }
479 // increment pointer by number of bytes for netflow record
480 flow_record = (flow_record_t *)((pointer_addr_t)flow_record + (pointer_addr_t)FLOW_RECORD_LENGTH);
481 }
482
483 } else {
484 // We print out the records somehow
485
486 if ( print_header ) {
487 print_header(&flow_header, 0, 0, 0, &string, anon);
488 printf("%s", string);
489 }
490
491 flow_record = record_buffer;
492 for ( i=0; i< NumRecords; i++ ) {
493 if ( ftrue[i] ) {
494
495 // if we need tp print out this record
496 if ( print_record ) {
497 print_record(flow_record, 1, (uint64_t)flow_record->dPkts, (uint64_t)flow_record->dOctets, &string, anon);
498 if ( string ) {
499 if ( limitflows ) {
500 if ( (numflows <= limitflows) )
501 printf("%s\n", string);
502 } else
503 printf("%s\n", string);
504 }
505 }
506
507 // if we need to sort the flows first -> insert into hash table
508 // they get
509 if ( sort_flows )
510 InsertFlow(flow_record);
511 }
512
513 // increment pointer by number of bytes for netflow record
514 flow_record = (flow_record_t *)((pointer_addr_t)flow_record + (pointer_addr_t)FLOW_RECORD_LENGTH);
515 }
516 }
517
518 } // while
519
520 if ( wfd )
521 close(wfd);
522
523 /* Statfile */
524 if ( sfile[0] != 0 ) {
525 nffd = open(sfile, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
526 if ( nffd == -1 ) {
527 perror("Can't open stat file: ");
528 return numflows;
529 }
530
531 tmpstring[63] = 0;
532 snprintf(tmpstring, 63, "Time: %u\n", GetStatTime());
533 write(nffd, tmpstring, strlen(tmpstring));
534 snprintf(tmpstring, 63, "Ident: %s\n", GetIdent());
535 write(nffd, tmpstring, strlen(tmpstring));
536 snprintf(tmpstring, 63, "Flows: %llu\n", numflows);
537 write(nffd, tmpstring, strlen(tmpstring));
538 snprintf(tmpstring, 63, "Flows_tcp: %llu\n", numflows_tcp);
539 write(nffd, tmpstring, strlen(tmpstring));
540 snprintf(tmpstring, 63, "Flows_udp: %llu\n", numflows_udp);
541 write(nffd, tmpstring, strlen(tmpstring));
542 snprintf(tmpstring, 63, "Flows_icmp: %llu\n", numflows_icmp);
543 write(nffd, tmpstring, strlen(tmpstring));
544 snprintf(tmpstring, 63, "Flows_other: %llu\n", numflows_other);
545 write(nffd, tmpstring, strlen(tmpstring));
546 snprintf(tmpstring, 63, "Packets: %llu\n", numpackets);
547 write(nffd, tmpstring, strlen(tmpstring));
548 snprintf(tmpstring, 63, "Packets_tcp: %llu\n", numpackets_tcp);
549 write(nffd, tmpstring, strlen(tmpstring));
550 snprintf(tmpstring, 63, "Packets_udp: %llu\n", numpackets_udp);
551 write(nffd, tmpstring, strlen(tmpstring));
552 snprintf(tmpstring, 63, "Packets_icmp: %llu\n", numpackets_icmp);
553 write(nffd, tmpstring, strlen(tmpstring));
554 snprintf(tmpstring, 63, "Packets_other: %llu\n", numpackets_other);
555 write(nffd, tmpstring, strlen(tmpstring));
556 snprintf(tmpstring, 63, "Bytes: %llu\n", numbytes);
557 write(nffd, tmpstring, strlen(tmpstring));
558 snprintf(tmpstring, 63, "Bytes_tcp: %llu\n", numbytes_tcp);
559 write(nffd, tmpstring, strlen(tmpstring));
560 snprintf(tmpstring, 63, "Bytes_udp: %llu\n", numbytes_udp);
561 write(nffd, tmpstring, strlen(tmpstring));
562 snprintf(tmpstring, 63, "Bytes_icmp: %llu\n", numbytes_icmp);
563 write(nffd, tmpstring, strlen(tmpstring));
564 snprintf(tmpstring, 63, "Bytes_other: %llu\n", numbytes_other);
565 write(nffd, tmpstring, strlen(tmpstring));
566 #if defined __OpenBSD__ || defined __FreeBSD__
567 snprintf(tmpstring, 63, "First: %u\n", first_seen);
568 write(nffd, tmpstring, strlen(tmpstring));
569 snprintf(tmpstring, 63, "Last: %u\n", last_seen);
570 #else
571 snprintf(tmpstring, 63, "First: %lu\n", first_seen);
572 write(nffd, tmpstring, strlen(tmpstring));
573 snprintf(tmpstring, 63, "Last: %lu\n", last_seen);
574 #endif
575 write(nffd, tmpstring, strlen(tmpstring));
576
577 close(nffd);
578 }
579
580 free((void *)record_buffer);
581 free((void *)ftrue);
582 SetSeenTwin(win_start, win_end);
583
584 return numflows;
585
586 } // End of process_data
587
588
589 int main( int argc, char **argv ) {
590 struct stat stat_buff;
591 printer_t print_header, print_record;
592 nfprof_t profile_data;
593 char c, *rfile, *Rfile, *Mdirs, *wfile, *ffile, *filter, *tstring, *stat_type;
594 char *byte_limit_string, *packet_limit_string, *print_mode, *record_header;
595 char *order_by, CryptoPAnKey[32];
596 int ffd, ret, element_stat, fdump;
597 int i, flow_stat, topN, aggregate, syntax_only, date_sorted, do_anonymize;
598 time_t t_start, t_end;
599 uint32_t limitflows, matched_flows, AggregateMasks[4];
600
601 rfile = Rfile = Mdirs = wfile = ffile = filter = tstring = stat_type = NULL;
602 byte_limit_string = packet_limit_string = NULL;
603 fdump = aggregate = 0;
604 t_start = t_end = 0;
605 syntax_only = 0;
606 topN = 10;
607 flow_stat = 0;
608 element_stat = 0;
609 limitflows = 0;
610 matched_flows = 0;
611 date_sorted = 0;
612 total_bytes = 0;
613 total_flows = 0;
614 do_anonymize = 0;
615
616 print_mode = NULL;
617 print_header = NULL;
618 print_record = NULL;
619 record_header = "";
620
621 SetStat_DefaultOrder("flows");
622
623 for ( i=0; i<4; AggregateMasks[i++] = 0 ) ;
624
625 while ((c = getopt(argc, argv, "aA:c:Ss:hn:f:r:w:K:M:mO:R:XZt:Vv:l:L:o:")) != EOF) {
626 switch (c) {
627 case 'h':
628 usage(argv[0]);
629 exit(0);
630 break;
631 case 'a':
632 aggregate = 1;
633 break;
634 case 'A':
635 if ( !ParseAggregateMask(optarg, AggregateMasks) ) {
636 fprintf(stderr, "Option -A requires a ',' separated list out of 'srcip dstip srcport dstport'\n");
637 exit(255);
638 }
639 break;
640 case 'X':
641 fdump = 1;
642 break;
643 case 'Z':
644 syntax_only = 1;
645 break;
646 case 'c':
647 limitflows = atoi(optarg);
648 if ( !limitflows ) {
649 fprintf(stderr, "Option -c needs a number > 0\n");
650 exit(255);
651 }
652 break;
653 case 's':
654 stat_type = optarg;
655 if ( !SetStat(stat_type, &element_stat, &flow_stat) ) {
656 fprintf(stderr, "Stat '%s' unknown!\n", stat_type);
657 exit(255);
658 }
659 break;
660 case 'V':
661 printf("%s: Version: %s %s\n%s\n",argv[0], nfdump_version, nfdump_date, rcsid);
662 exit(0);
663 break;
664 case 'l':
665 packet_limit_string = optarg;
666 break;
667 case 'K':
668 if ( !ParseCryptoPAnKey(optarg, CryptoPAnKey) ) {
669 fprintf(stderr, "Invalid key '%s' for CryptoPAn!\n", optarg);
670 exit(255);
671 }
672 do_anonymize = 1;
673 break;
674 case 'L':
675 byte_limit_string = optarg;
676 break;
677 case 'f':
678 ffile = optarg;
679 break;
680 case 't':
681 tstring = optarg;
682 break;
683 case 'r':
684 rfile = optarg;
685 if ( strcmp(rfile, "-") == 0 )
686 rfile = NULL;
687 break;
688 case 'm':
689 date_sorted = 1;
690 break;
691 case 'M':
692 Mdirs = optarg;
693 break;
694 case 'o': // output mode
695 print_mode = optarg;
696 break;
697 case 'O': // stat order by
698 order_by = optarg;
699 if ( !SetStat_DefaultOrder(order_by) ) {
700 fprintf(stderr, "Order '%s' unknown!\n", order_by);
701 exit(255);
702 }
703 break;
704 case 'R':
705 Rfile = optarg;
706 break;
707 case 'v':
708 fprintf(stderr, "Option no longer supported.\n");
709 break;
710 case 'w':
711 wfile = optarg;
712 break;
713 case 'n':
714 topN = atoi(optarg);
715 if ( topN < 0 ) {
716 fprintf(stderr, "TopnN number %i out of range\n", topN);
717 exit(255);
718 }
719 break;
720 case 'S': // Compatibility with pre 1.4 -S option
721 if ( !SetStat("record/packets/bytes", &element_stat, &flow_stat) ) {
722 // Should never happen
723 fprintf(stderr, "Software Error!\n");
724 exit(255);
725 }
726 break;
727 default:
728 usage(argv[0]);
729 exit(0);
730 }
731 }
732 if (argc - optind > 1) {
733 usage(argv[0]);
734 exit(255);
735 } else {
736 /* user specified a pcap filter */
737 filter = argv[optind];
738 }
739
740 if ( rfile && Rfile ) {
741 fprintf(stderr, "-r and -R are mutually exclusive. Plase specify either -r or -R\n");
742 exit(255);
743 }
744 if ( Mdirs && !(rfile || Rfile) ) {
745 fprintf(stderr, "-M needs either -r or -R to specify the file or file list. Add '-R .' for all files in the directories.\n");
746 exit(255);
747 }
748
749
750 // handle print mode
751 if ( !print_mode )
752 print_mode = DefaultMode;
753
754 i = 0;
755 while ( printmap[i].printmode ) {
756 if ( strncasecmp(print_mode, printmap[i].printmode, MAXMODELEN) == 0 ) {
757 print_record = printmap[i].func;
758 record_header = printmap[i].HeaderLine;
759 if ( date_sorted && ( printmap[i].sorted == 0 ) ) {
760 date_sorted = 0;
761 fprintf(stderr, "Option -m does not make sense with output mode '%s'\n", print_mode);
762 }
763 break;
764 }
765 i++;
766 }
767
768 if ( !print_record ) {
769 fprintf(stderr, "Unknown output mode '%s'\n", print_mode);
770 exit(255);
771 }
772
773 // this is the only case, where headers are printed.
774 if ( strncasecmp(print_mode, "raw", 16) == 0 )
775 print_header = flow_header_raw;
776
777 if ( aggregate && (flow_stat || element_stat) ) {
778 aggregate = 0;
779 fprintf(stderr, "Command line switch -s or -S overwrites -a\n");
780 }
781
782 if ( !filter && ffile ) {
783 if ( stat(ffile, &stat_buff) ) {
784 fprintf(stderr, "Can't stat filter file '%s': %s\n", ffile, strerror(errno));
785 exit(255);
786 }
787 filter = (char *)malloc(stat_buff.st_size+1);
788 if ( !filter ) {
789 perror("Memory allocation error");
790 exit(255);
791 }
792 ffd = open(ffile, O_RDONLY);
793 if ( ffd < 0 ) {
794 fprintf(stderr, "Can't open filter file '%s': %s\n", ffile, strerror(errno));
795 exit(255);
796 }
797 ret = read(ffd, (void *)filter, stat_buff.st_size);
798 if ( ret < 0 ) {
799 perror("Error reading filter file");
800 close(ffd);
801 exit(255);
802 }
803 total_bytes += ret;
804 filter[stat_buff.st_size] = 0;
805 close(ffd);
806 }
807
808 // if no filter is given, set the default ip filter which passes through every flow
809 if ( !filter )
810 filter = "any";
811
812 Engine = CompileFilter(filter);
813 if ( !Engine )
814 exit(254);
815
816 if ( fdump ) {
817 printf("StartNode: %i Engine: %s\n", Engine->StartNode, Engine->Extended ? "Extended" : "Fast");
818 DumpList(Engine);
819 exit(0);
820 }
821
822 if ( syntax_only )
823 exit(0);
824
825 if ((aggregate || flow_stat) && ( topN > 1000) ) {
826 printf("Topn N > 1000 only allowed for IP statistics");
827 exit(255);
828 }
829
830
831 if ((aggregate || flow_stat || date_sorted) && !Init_FlowTable(HashBits, NumPrealloc) )
832 exit(250);
833
834 if (element_stat && !Init_StatTable(HashBits, NumPrealloc) )
835 exit(250);
836
837 SetLimits(element_stat || aggregate || flow_stat, packet_limit_string, byte_limit_string);
838
839 SetupInputFileSequence(Mdirs, rfile, Rfile);
840
841 if ( tstring ) {
842 if ( !ScanTimeFrame(tstring, &t_start, &t_end) )
843 exit(255);
844 }
845
846
847 if ( !(flow_stat || element_stat || wfile ) && record_header )
848 printf("%s\n", record_header);
849
850 if (do_anonymize)
851 PAnonymizer_Init((uint8_t *)CryptoPAnKey);
852
853 nfprof_start(&profile_data);
854 matched_flows = process_data(wfile, element_stat, aggregate || flow_stat, date_sorted,
855 print_header, print_record, t_start, t_end,
856 limitflows, AggregateMasks, do_anonymize);
857 nfprof_end(&profile_data, total_flows);
858
859 if (aggregate) {
860 ReportAggregated(print_record, limitflows, date_sorted, do_anonymize);
861 Dispose_Tables(1, 0); // Free the FlowTable
862 }
863
864 if (flow_stat || element_stat) {
865 ReportStat(record_header, print_record, topN, flow_stat, element_stat, do_anonymize);
866 Dispose_Tables(flow_stat, element_stat);
867 }
868
869 if ( date_sorted && !(aggregate || flow_stat || element_stat) ) {
870 PrintSortedFlows(print_record, limitflows, do_anonymize);
871 Dispose_Tables(1, 0); // Free the FlowTable
872 }
873
874 if ( !wfile ) {
875 if (do_anonymize)
876 printf("IP addresses anonymized\n");
877 printf("Time window: %s\n", TimeString());
878 printf("Flows analysed: %u matched: %u, Bytes read: %llu\n", total_flows, matched_flows, total_bytes);
879 nfprof_print(&profile_data, stdout);
880 }
881 return 0;
882 }
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nfdump.h 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 */
37
38 #define BuffNumRecords 1024
39
40 /*
41 * Defines for offsets into netflow record
42 */
43
44 #include "config.h"
45
46 #define AnyMask (uint32_t)0xffffffff
47
48 #ifdef WORDS_BIGENDIAN
49
50 #define OffsetSrcIP 0
51 #define OffsetDstIP 1
52 #define OffsetNext 2
53 #define MaskIP (uint32_t)0xffffffff
54
55 #define OffsetInOut 3
56 #define MaskInput (uint32_t)0xffff0000
57 #define MaskOutput (uint32_t)0x0000ffff
58 #define ShiftInput 16
59 #define ShiftOutput 0
60
61 #define OffsetPackets 4
62 #define OffsetBytes 5
63 #define MaskSize (uint32_t)0xffffffff
64
65 #define OffsetPort 8
66 #define MaskDstPort (uint32_t)0x0000ffff
67 #define MaskSrcPort (uint32_t)0xffff0000
68 #define ShiftDstPort 0
69 #define ShiftSrcPort 16
70
71 #define OffsetTos 9
72 #define MaskTos (uint32_t)0x000000ff
73 #define ShiftTos 0
74
75 #define OffsetProto 9
76 #define MaskProto (uint32_t)0x0000ff00
77 #define ShiftProto 8
78
79 #define OffsetFlags 9
80 #define MaskFlags (uint32_t)0x00ff0000
81 #define ShiftFlags 16
82
83 #define OffsetAS 10
84 #define MaskDstAS (uint32_t)0x0000ffff
85 #define MaskSrcAS (uint32_t)0xffff0000
86 #define ShiftSrcAS 16
87 #define ShiftDstAS 0
88
89 #else
90
91 #define OffsetSrcIP 0
92 #define OffsetDstIP 1
93 #define OffsetNext 2
94 #define MaskIP (uint32_t)0xffffffff
95
96 #define OffsetInOut 3
97 #define MaskInput (uint32_t)0x0000ffff
98 #define MaskOutput (uint32_t)0xffff0000
99 #define ShiftInput 0
100 #define ShiftOutput 16
101
102 #define OffsetPackets 4
103 #define OffsetBytes 5
104 #define MaskSize (uint32_t)0xffffffff
105
106 #define OffsetTos 9
107 #define MaskTos (uint32_t)0xff000000
108 #define ShiftTos 24
109
110 #define OffsetProto 9
111 #define MaskProto (uint32_t)0x00ff0000
112 #define ShiftProto 16
113
114 #define OffsetFlags 9
115 #define MaskFlags (uint32_t)0x0000ff00
116 #define ShiftFlags 8
117
118 #define OffsetPort 8
119 #define MaskDstPort (uint32_t)0xffff0000
120 #define MaskSrcPort (uint32_t)0x0000ffff
121 #define ShiftSrcPort 0
122 #define ShiftDstPort 16
123
124 #define OffsetAS 10
125 #define MaskDstAS (uint32_t)0xffff0000
126 #define MaskSrcAS (uint32_t)0x0000ffff
127 #define ShiftSrcAS 0
128 #define ShiftDstAS 16
129
130 #endif
131
132 typedef struct FilterParam {
133 uint32_t scale;
134 uint16_t comp;
135 uint16_t direction;
136 uint16_t proto;
137 uint32_t data;
138 uint32_t ip;
139 uint32_t netmask;
140 uint32_t netbits;
141 uint32_t self;
142 } FilterParam_t;
143
144
145 /* parser/scanner prototypes */
146 int yyparse(void);
147
148 int yylex(void);
149
150 void lex_cleanup(void);
151
152 void lex_init(char *buf);
153
0 Date flow start Duration Proto Src IP Addr:Port Dst IP Addr:Port Flags Tos Packets Bytes pps bps Bpp Flows
1 2004-07-11 10:30:00.010 10.010 TCP 172.16.1.66:1024 -> 172.16.19.18:25 ...... 0 101 101 10 80 1 1
2 2004-07-11 10:30:10.110 20.010 TCP 172.16.1.66:1024 -> 172.16.19.18:25 ...... 0 101 101 5 40 1 1
3 2004-07-11 10:30:20.210 30.010 TCP 172.16.1.66:1024 -> 172.16.19.18:25 ...... 0 101 101 3 26 1 1
4 2004-07-11 10:30:30.310 40.010 UDP 172.16.2.66:2024 -> 172.16.18.18:25 .....F 1 1001 1001 25 200 1 1
5 2004-07-11 10:30:40.410 50.010 AH 172.16.3.66:3024 -> 172.16.17.18:25 ....S. 2 10001 10001 199 1599 1 1
6 2004-07-11 10:30:50.510 60.010 TCP 172.16.4.66:4024 -> 172.16.16.18:25 ...R.. 3 100001 100001 1666 13331 1 1
7 2004-07-11 10:31:00.610 70.010 TCP 172.16.5.66:5024 -> 172.16.15.18:25 ..P... 4 1000001 1000001 14283 114269 1 1
8 2004-07-11 10:31:10.710 80.010 TCP 172.16.5.66:5024 -> 172.16.15.18:25 .....F 4 9.5 M 1001 124984 100 0 1
9 2004-07-11 10:31:20.810 90.010 TCP 172.16.6.66:6024 -> 172.16.14.18:25 .A.... 5 500 9.5 M 5 888790 20000 1
10 2004-07-11 10:31:30.910 100.010 TCP 172.16.6.66:6024 -> 172.16.14.18:25 .A.... 5 500 9.5 M 4 799920 20000 1
11 2004-07-11 10:31:40.010 110.010 TCP 172.16.7.66:7024 -> 172.16.13.18:25 U..... 255 5000 95.4 M 45 6.9 M 20000 1
12 2004-07-11 10:31:50.110 120.010 TCP 172.16.8.66:8024 -> 172.16.12.18:25 UAPRSF 0 5000 953.7 M 41 63.6 M 200000 1
13 2004-07-11 10:32:00.210 130.010 ICMP 172.16.2.66:0 -> 172.16.18.18:8 ...... 0 50000 50000 384 3076 1 1
14 2004-07-11 10:32:10.310 140.010 TCP 172.160.160.166:10024 -> 172.160.160.180:25000 ...... 0 500000 500000 3571 28569 1 1
15 Time window: Jul 11 2004 10:30:00 - Jul 11 2004 10:34:30
16 Flows analysed: 14 matched: 14, Bytes read: 696
0
1 /*
2 * nfgen : Test Programm
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: nfgen.c 34 2005-08-22 12:01:31Z peter $
34 *
35 * $LastChangedRevision: 34 $
36 *
37 */
38
39 #include <stdio.h>
40 #include <unistd.h>
41 #include <stdlib.h>
42 #include <errno.h>
43 #include <time.h>
44 #include <string.h>
45 #include <sys/types.h>
46 #include <sys/stat.h>
47 #include <fcntl.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
51
52 #include "config.h"
53
54 #ifdef HAVE_STDINT_H
55 #include <stdint.h>
56 #endif
57
58
59 #include "netflow_v5.h"
60 #include "netflow_v7.h"
61 #include "nf_common.h"
62
63 static time_t when = 1089534600;
64 uint32_t offset = 10;
65 uint32_t msecs = 10;
66
67
68 void SendHeader (int numrecords) {
69 flow_header_t nf_header;
70
71 nf_header.version = 5;
72 nf_header.count = numrecords;
73 nf_header.SysUptime = when;
74 nf_header.unix_secs = 0;
75 nf_header.unix_nsecs = 0;
76 nf_header.flow_sequence = 0;
77 nf_header.layout_version = 1;
78
79 write(1, &nf_header, FLOW_HEADER_LENGTH);
80
81 } // End of SendHeader
82
83 void GenRecord(flow_record_t *nf_record, char *src_ip, char *dst_ip, int src_port, int dst_port,
84 int proto, int tcp_flags, int tos, int packets, int bytes, int src_as, int dst_as) {
85
86 nf_record->srcaddr = ntohl(inet_addr(src_ip));
87 nf_record->dstaddr = ntohl(inet_addr(dst_ip));
88 nf_record->nexthop = 0;
89 nf_record->input = 0;
90 nf_record->output = 255;
91 nf_record->dPkts = packets;
92 nf_record->dOctets = bytes;
93 nf_record->First = when;
94 nf_record->Last = when + offset;
95 nf_record->srcport = src_port;
96 nf_record->dstport = dst_port;
97 nf_record->pad = 0;
98 nf_record->tcp_flags = tcp_flags;
99 nf_record->prot = proto;
100 nf_record->tos = tos;
101 nf_record->src_as = src_as;
102 nf_record->dst_as = dst_as;
103 nf_record->msec_first = msecs;
104 nf_record->msec_last = msecs + 10;
105 offset += 10;
106 when += 10;
107
108 msecs += 100;
109 if ( msecs > 1000 )
110 msecs = msecs - 1000;
111
112
113 } // End of GenRecord
114
115 int main( int argc, char **argv ) {
116 char c;
117 flow_record_t flow_record[128];
118
119 while ((c = getopt(argc, argv, "h")) != EOF) {
120 switch(c) {
121 case 'h':
122 break;
123 default:
124 fprintf(stderr, "ERROR: Unsupported option: '%c'\n", c);
125 exit(255);
126 }
127 }
128
129 SendHeader(14);
130 // src_ip dst_ip, src_port, dst_port, proto, tcp_flags, tos, packets, bytes, src_as, dst_as
131 GenRecord(&flow_record[0], "172.16.1.66", "172.16.19.18", 1024, 25, 6, 0, 0, 101, 101, 775, 8404);
132 GenRecord(&flow_record[1], "172.16.1.66", "172.16.19.18", 1024, 25, 6, 0, 0, 101, 101, 775, 8404);
133 GenRecord(&flow_record[2], "172.16.1.66", "172.16.19.18", 1024, 25, 6, 0, 0, 101, 101, 775, 8404);
134 GenRecord(&flow_record[3], "172.16.2.66", "172.16.18.18", 2024, 25, 17, 1, 1, 1001, 1001, 775, 8404);
135 GenRecord(&flow_record[4], "172.16.3.66", "172.16.17.18", 3024, 25, 51, 2, 2, 10001, 10001, 775, 8404);
136 GenRecord(&flow_record[5], "172.16.4.66", "172.16.16.18", 4024, 25, 6, 4, 3, 100001, 100001, 775, 8404);
137 GenRecord(&flow_record[6], "172.16.5.66", "172.16.15.18", 5024, 25, 6, 8, 4, 1000001, 1000001, 775, 8404);
138 GenRecord(&flow_record[7], "172.16.5.66", "172.16.15.18", 5024, 25, 6, 1, 4, 10000010, 1001, 775, 8404);
139 GenRecord(&flow_record[8], "172.16.6.66", "172.16.14.18", 6024, 25, 6, 16, 5, 500, 10000001, 775, 8404);
140 GenRecord(&flow_record[9], "172.16.6.66", "172.16.14.18", 6024, 25, 6, 16, 5, 500, 10000001, 775, 8404);
141 GenRecord(&flow_record[10], "172.16.7.66", "172.16.13.18", 7024, 25, 6, 32, 255, 5000, 100000001, 775, 8404);
142 GenRecord(&flow_record[11], "172.16.8.66", "172.16.12.18", 8024, 25, 6, 63, 0, 5000, 1000000001, 775, 8404);
143 GenRecord(&flow_record[12], "172.16.2.66", "172.16.18.18", 0, 8, 1, 0, 0, 50000, 50000, 775, 8404);
144 GenRecord(&flow_record[13], "172.160.160.166", "172.160.160.180", 10024, 25000, 6, 0, 0, 500000, 500000, 775, 8404);
145 write(1, &flow_record[0], 14 * FLOW_RECORD_LENGTH);
146
147 return 0;
148 }
149
0 /*
1 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of SWITCH nor the names of its contributors may be
13 * used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Author: peter $
29 *
30 * $Id: nfprof.c 53 2005-11-17 07:45:34Z peter $
31 *
32 * $LastChangedRevision: 53 $
33 *
34 */
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <sys/types.h>
39 #include <strings.h>
40
41 #include "config.h"
42
43 #ifdef HAVE_STDINT_H
44 #include <stdint.h>
45 #endif
46
47 #include <sys/time.h>
48 #include <sys/resource.h>
49 #include "nfprof.h"
50
51 /*
52 * Initialize profiling.
53 *
54 */
55 int nfprof_start(nfprof_t *profile_data) {
56
57 bzero (profile_data, sizeof(nfprof_t));
58 return gettimeofday(&profile_data->tstart, (struct timezone*)NULL) == 0 ? 1 : 0;
59
60 } // End of nfprof_start
61
62 /*
63 * Finish profiling.
64 *
65 */
66 int nfprof_end(nfprof_t *profile_data, uint64_t numflows) {
67 int ret;
68
69 if ((ret = gettimeofday(&profile_data->tend, (struct timezone*)NULL)) == -1)
70 return 1;
71
72 if ((ret = getrusage(RUSAGE_SELF, &profile_data->used)) == -1)
73 return 1;
74
75 profile_data->numflows = numflows;
76
77 return 0;
78
79 } // End of nfprof_end
80
81 /*
82 * Dump nfprof contents to std
83 *
84 */
85 void nfprof_print(nfprof_t *profile_data, FILE *std) {
86 u_long usec, sec;
87 double fps;
88
89 usec = profile_data->used.ru_utime.tv_usec + profile_data->used.ru_stime.tv_usec;
90 sec = profile_data->used.ru_utime.tv_sec + profile_data->used.ru_stime.tv_sec;
91
92 if (usec > 1000000)
93 usec -= 1000000, ++sec;
94
95 fps = (double)profile_data->numflows / ((double)sec + ((double)usec/1000000));
96
97 fprintf(std, "Sys: %lu.%-3.3lus flows/second: %-10.1f ", sec, usec/1000, fps);
98
99 if (profile_data->tend.tv_usec < profile_data->tstart.tv_usec)
100 profile_data->tend.tv_usec += 1000000, --profile_data->tend.tv_sec;
101
102 usec = profile_data->tend.tv_usec - profile_data->tstart.tv_usec;
103 sec = profile_data->tend.tv_sec - profile_data->tstart.tv_sec;
104 fps = (double)profile_data->numflows / ((double)sec + ((double)usec/1000000));
105
106 fprintf(std, "Wall: %lu.%-3.3lus flows/second: %-10.1f\n", sec, usec/1000, fps);
107 /*
108 fprintf(std, "\n");
109 fprintf(std, "integral max resident set size: %u\n", profile_data->used.ru_maxrss);
110 fprintf(std, "integral shared text memory size: %u\n", profile_data->used.ru_ixrss);
111 fprintf(std, "integral unshared data size: %u\n", profile_data->used.ru_idrss);
112 fprintf(std, "integral unshared stack size: %u\n", profile_data->used.ru_isrss);
113 fprintf(std, "page reclaims: %u\n", profile_data->used.ru_minflt);
114 fprintf(std, "page faults: %u\n", profile_data->used.ru_majflt);
115 fprintf(std, "swaps: %u\n", profile_data->used.ru_nswap);
116 fprintf(std, "block input operations: %u\n", profile_data->used.ru_inblock);
117 fprintf(std, "block output operations: %u\n", profile_data->used.ru_oublock);
118 */
119
120 } // End of nfprof_print
121
0 /*
1 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of SWITCH nor the names of its contributors may be
13 * used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Author: peter $
29 *
30 * $Id: nfprof.h 53 2005-11-17 07:45:34Z peter $
31 *
32 * $LastChangedRevision: 53 $
33 *
34 */
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <sys/types.h>
39 #include <string.h>
40
41 #include "config.h"
42
43 #ifdef HAVE_STDINT_H
44 #include <stdint.h>
45 #endif
46
47 #include <sys/time.h>
48 #include <sys/resource.h>
49
50 typedef struct nfprof_s {
51 struct timeval tstart; /* start time */
52 struct timeval tend; /* end time */
53 struct rusage used; /* system resources used */
54 uint64_t numflows; /* total # of flows processed */
55 } nfprof_t;
56
57 int nfprof_start(nfprof_t *profile_data);
58
59 int nfprof_end(nfprof_t *profile_data, uint64_t numflows);
60
61 void nfprof_print(nfprof_t *profile_data, FILE *std);
62
0 .TH nfprofile 1 2004-06-30 "" ""
1 .SH NAME
2 nfprofile \- netflow profiler
3 .SH SYNOPSIS
4 .HP 5
5 .B nfprofile [options]
6 .SH DESCRIPTION
7 .B nfprofile
8 is the netflow profiler program of the nfdump tool set.
9 It reads the netflow data from the files stored by nfcapd and creates
10 the corresponding output files for every profile available in the
11 profile base directory. The filter syntax is equivalent to nfdump.
12 See the nfdump(1) man page for a detailed description of the filter
13 syntax.
14
15 .SH OPTIONS
16 .TP 3
17 .B -r \fIinput file
18 Read input data from \fIinput file\fR. Required option. The name of the
19 output file is the same as the name as \fIinput file\fR and stored in the
20 appropriate profile directory.
21 .TP 3
22 .B -t \fItimewin
23 Process only flows, which fall in the time window \fItimewin\fR, where
24 \fItimewin\fR is YYYY/MM/dd.hh:mm:ss[-YYYY/MM/dd.hh:mm:ss]. Any parts of
25 the time spec may be omitted e.g YYYY/MM/dd expands to
26 YYYY/MM/dd.00:00:00-YYYY/MM/dd.23:59:59 and processes all flow from a
27 given day.
28 .TP 3
29 .B -f \fIfilter
30 Name of the filter file. This file is stored in the \fIprofile directory\fR
31 for each profile. The default name is filter.txt. If no filter file
32 is found, this profile is not processed.
33 .TP 3
34 .B -p \fIprofile base directory
35 Defines the base directory, where all he profiles are stored. This is a
36 required parameter. Each directory in the \fIprofile base directory\fR is
37 considered to be a profile, and therefore a \fIprofile directory\fR.
38 Directory names starting with a '.' are ignored.
39 .TP 3
40 .B -s \fIprofile subdirectory
41 Defines the \fIprofile subdirectory.
42 Each \fIprofile directory\fR may have several \fIprofile subdirectories\fR
43 according to the number of netflow sources. The filtered output files are
44 stored in this subdirectory: \fIprofile base directory/profile subdirectory.
45 .TP 3
46 .B -Z
47 Check the filter syntax of all profiles and exit. Sets the return value
48 accordingly.
49 .TP 3
50 .B -V
51 Print nfdump version and exit.
52 .TP 3
53 .B -h
54 Print help text on stdout with all options and exit.
55 .SH "RETURN VALUE"
56 Returns
57 .PD 0
58 .RS 4
59 0 No error. \fn
60 .P
61 255 Initialization failed.
62 .P
63 254 Error in filter syntax.
64 .P
65 250 Internal error.
66 .RE
67 .PD
68 .SH NOTES
69 .P
70 .SH "SEE ALSO"
71 nfcapd(1), nfdump(1), nfreplay(1)
72 .SH BUGS
73
0 /*
1 * nfprofile : Reads netflow data from files, saved by nfcapd
2 * Data can be view, filtered and saved to
3 * files.
4 *
5 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * * Neither the name of SWITCH nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Author: peter $
33 *
34 * $Id: nfprofile.c 34 2005-08-22 12:01:31Z peter $
35 *
36 * $LastChangedRevision: 34 $
37 *
38 */
39
40 #include <stdio.h>
41 #include <unistd.h>
42 #include <stdlib.h>
43 #include <errno.h>
44 #include <time.h>
45 #include <string.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <fcntl.h>
49
50 #include "config.h"
51
52 #ifdef HAVE_STDINT_H
53 #include <stdint.h>
54 #endif
55
56
57 #include "version.h"
58 #include "nf_common.h"
59 #include "nftree.h"
60 #include "nfdump.h"
61 #include "nfstat.h"
62 #include "util.h"
63 #include "profile.h"
64
65 /* hash parameters */
66 #define HashBits 20
67 #define NumPrealloc 128000
68
69 /* Global Variables */
70 uint32_t byte_limit, packet_limit;
71 int byte_mode, packet_mode;
72
73 /* Local Variables */
74 static char const *rcsid = "$Id: nfprofile.c 34 2005-08-22 12:01:31Z peter $";
75
76 #define NETFLOW_VERSION 5
77
78 /* Function Prototypes */
79 static void usage(char *name);
80
81 static void process_data(profileinfo_t *profiles, unsigned int num_profiles, time_t twin_start, time_t twin_end);
82
83
84 /* Functions */
85 static void usage(char *name) {
86 printf("usage %s [options] \n"
87 "-h\t\tthis text you see right here\n"
88 "-V\t\tPrint version and exit.\n"
89 "-r\t\tread input from file\n"
90 "-f\t\tfilename with filter syntaxfile\n"
91 "-p\t\tprofile dir.\n"
92 "-s\t\tprofile subdir.\n"
93 "-Z\t\tCheck filter syntax and exit.\n"
94 "-q\t\tSuppress profile working info\n"
95 "-t <time>\ttime window for filtering packets\n"
96 "\t\tyyyy/MM/dd.hh:mm:ss[-yyyy/MM/dd.hh:mm:ss]\n", name);
97 } /* usage */
98
99 static void process_data(profileinfo_t *profiles, unsigned int num_profiles, time_t twin_start, time_t twin_end) {
100 flow_header_t flow_header;
101 flow_record_t *flow_record, *record_buffer;
102 FilterEngine_data_t *engine;
103 uint32_t NumRecords;
104 int i, j, rfd, done, ret ;
105 short *ftrue;
106
107 rfd = GetNextFile(0, twin_start, twin_end);
108 if ( rfd < 0 ) {
109 if ( errno )
110 perror("Can't open file for reading");
111 return;
112 }
113
114 // allocate buffer suitable for netflow version
115 record_buffer = (flow_record_t *) calloc(BuffNumRecords , FLOW_RECORD_LENGTH);
116 ftrue = (short *) malloc(BuffNumRecords * sizeof(short));
117 if ( !record_buffer || !ftrue ) {
118 perror("Memory allocation error");
119 close(rfd);
120 return;
121 }
122
123 SetSeenTwin(0, 0);
124 for ( j=0; j < num_profiles; j++ ) {
125 profiles[j].first_seen = 0x7fffffff;
126 profiles[j].last_seen = 0;
127 }
128
129 done = 0;
130 while ( !done ) {
131 ret = read(rfd, &flow_header, FLOW_HEADER_LENGTH);
132 if ( ret == 0 ) {
133 done = 1;
134 if ( rfd ) // unless stdin
135 close(rfd);
136 break;
137 } else if ( ret == -1 ) {
138 perror("Error reading data");
139 close(rfd);
140 return;
141 }
142 if ( flow_header.version != NETFLOW_VERSION ) {
143 fprintf(stdout, "Not a netflow v5 header\n");
144 close(rfd);
145 return;
146 }
147 if ( flow_header.count > BuffNumRecords ) {
148 fprintf(stderr, "Too many records %u ( > BuffNumRecords )\n", flow_header.count);
149 break;
150 }
151
152 NumRecords = flow_header.count;
153
154 ret = read(rfd, record_buffer, NumRecords * FLOW_RECORD_LENGTH);
155 if ( ret == 0 ) {
156 done = 1;
157 break;
158 } else if ( ret == -1 ) {
159 perror("Error reading data");
160 close(rfd);
161 return;
162 }
163
164 for ( j=0; j < num_profiles; j++ ) {
165 // cnt is the number of blocks, which survived the filter
166 // ftrue is an array of flags of the filter result
167
168 // preset profile specific vars
169 // set flow_record to the beginn of all records
170 flow_record = record_buffer;
171 profiles[j].cnt = 0;
172 engine = profiles[j].engine;
173 for ( i=0; i < NumRecords; i++ ) {
174 // Time filter
175 // if no time filter is given, the result is always true
176 ftrue[i] = twin_start && (flow_record->First < twin_start || flow_record->Last > twin_end) ? 0 : 1;
177
178 // netflow record filter
179 if ( ftrue[i] ) {
180 engine->nfrecord = (uint32_t *)flow_record;
181 ftrue[i] = (*engine->FilterEngine)(engine);
182 }
183
184 if ( ftrue[i] ) {
185 switch (flow_record->prot) {
186 case 1:
187 profiles[j].numflows_icmp++;
188 profiles[j].numpackets_icmp += flow_record->dPkts;
189 profiles[j].numbytes_icmp += flow_record->dOctets;
190 break;
191 case 6:
192 profiles[j].numflows_tcp++;
193 profiles[j].numpackets_tcp += flow_record->dPkts;
194 profiles[j].numbytes_tcp += flow_record->dOctets;
195 break;
196 case 17:
197 profiles[j].numflows_udp++;
198 profiles[j].numpackets_udp += flow_record->dPkts;
199 profiles[j].numbytes_udp += flow_record->dOctets;
200 break;
201 default:
202 profiles[j].numflows_other++;
203 profiles[j].numpackets_other += flow_record->dPkts;
204 profiles[j].numbytes_other += flow_record->dOctets;
205 }
206 profiles[j].numflows++;
207 profiles[j].numpackets += flow_record->dPkts;
208 profiles[j].numbytes += flow_record->dOctets;
209 profiles[j].cnt++;
210
211 if ( flow_record->First < profiles[j].first_seen )
212 profiles[j].first_seen = flow_record->First;
213 if ( flow_record->Last > profiles[j].last_seen )
214 profiles[j].last_seen = flow_record->Last;
215 }
216 // increment pointer by number of bytes for netflow record
217 flow_record = (void *)((pointer_addr_t)flow_record + FLOW_RECORD_LENGTH);
218 }
219
220 // set new count in header
221 flow_header.count = profiles[j].cnt;
222
223 // dump header and records only, if any block is left
224 if ( profiles[j].cnt ) {
225 /* write to file */
226 ret = write(profiles[j].wfd, &flow_header, FLOW_HEADER_LENGTH);
227 if ( ret < 0 ) {
228 perror("Error writing data");
229 continue;
230 }
231 flow_record = record_buffer;
232 for ( i=0; i < NumRecords; i++ ) {
233 if ( ftrue[i] ) {
234 ret = write(profiles[j].wfd, flow_record, FLOW_RECORD_LENGTH);
235 if ( ret < 0 ) {
236 perror("Error writing data");
237 continue;
238 }
239 }
240 // increment pointer by number of bytes for netflow record
241 flow_record = (void *)((pointer_addr_t)flow_record + FLOW_RECORD_LENGTH);
242 }
243 } // if cnt
244 } // for j all profiles
245 } // while read file
246
247 free((void *)record_buffer);
248
249 } // End of process_data
250
251
252 int main( int argc, char **argv ) {
253 unsigned int num_profiles, quiet;
254 struct stat stat_buf;
255 char c, *rfile, *ffile, *filename, *p, *tstring, *profiledir, *subdir;
256 int syntax_only;
257 time_t t_start, t_end;
258
259 tstring = NULL;
260 profiledir = subdir = NULL;
261 t_start = t_end = 0;
262 syntax_only = 0;
263 quiet = 0;
264
265 // default file names
266 ffile = "filter.txt";
267 rfile = "nfcapd";
268 while ((c = getopt(argc, argv, "p:s:hf:r:Zt:Vq")) != EOF) {
269 switch (c) {
270 case 'h':
271 usage(argv[0]);
272 exit(0);
273 break;
274 case 'Z':
275 syntax_only = 1;
276 break;
277 case 'p':
278 profiledir = optarg;
279 break;
280 case 's':
281 subdir = optarg;
282 break;
283 case 'V':
284 printf("%s: Version: %s %s\n%s\n",argv[0], nfdump_version, nfdump_date, rcsid);
285 exit(0);
286 break;
287 case 'f':
288 ffile = optarg;
289 break;
290 case 't':
291 tstring = optarg;
292 break;
293 case 'r':
294 rfile = optarg;
295 break;
296 case 'q':
297 quiet = 1;
298 break;
299 default:
300 usage(argv[0]);
301 exit(0);
302 }
303 }
304
305
306 if ( !profiledir ) {
307 fprintf(stderr, "Profile directory required!\n");
308 exit(255);
309 }
310
311 SetLimits(0,NULL, NULL);
312
313 if ( stat(profiledir, &stat_buf) || !S_ISDIR(stat_buf.st_mode) ) {
314 fprintf(stderr, "'%s' not a directory\n", profiledir);
315 exit(255);
316 }
317
318 p = strrchr(rfile, '/');
319 filename = p == NULL ? rfile : ++p;
320
321 if ( strlen(filename) == 0 ) {
322 fprintf(stderr, "Filename error");
323 exit(254);
324 }
325
326 num_profiles = InitProfiles(profiledir, subdir, ffile, filename, syntax_only, quiet);
327 if ( !num_profiles )
328 exit(254);
329
330 if ( syntax_only )
331 exit(0);
332
333 SetupInputFileSequence(NULL,rfile, NULL);
334
335 if ( tstring ) {
336 if ( !ScanTimeFrame(tstring, &t_start, &t_end) )
337 exit(255);
338 }
339
340 process_data(GetProfiles(), num_profiles, t_start, t_end);
341
342 CloseProfiles();
343
344 return 0;
345 }
0 .TH nfreplay 1 2005-08-19 "" ""
1 .SH NAME
2 nfreplay \- netflow replay program
3 .SH SYNOPSIS
4 .HP 5
5 .B replay [options] [filter]
6 .SH DESCRIPTION
7 .B nfreplay
8 is the netflow replay program of the nfdump tool set.
9 It reads the netflow data from the files stored by nfcapd. The filter
10 syntax is equivalent to nfdump. If a filter is supplied, only the
11 matching flows are sent. See the nfdump(1) man page for a detailed
12 description of the filter syntax. All records are sent as netflow version 5.
13
14 .SH OPTIONS
15 .TP 3
16 .B -i \fIIP address
17 Send all flows to this IP address. Default is localhost 127.0.0.1
18 .TP 3
19 .B -p \fIport
20 Send all fows to this port on the remote side. Default is 9995.
21 .TP 3
22 .B -d \fIusec
23 Delay each record bei \fIusec\fR mirco seconds, to avoid overrun on the remote
24 side. Default is 10.
25 .TP 3
26 .B -b \fIbuffersize
27 Set send buffer size in bytes. Usefull for large data to transfer. Default is
28 system dependent.
29 .TP 3
30 .B -r \fIinputfile
31 Read input data from \fIinputfile\fR. Default is read from stdin.
32 .TP 3
33 .B -t \fItimewin
34 Send only flows, which fall in the time window \fItimewin\fR, where
35 \fItimewin\fR is YYYY/MM/dd.hh:mm:ss[-YYYY/MM/dd.hh:mm:ss]. Any parts of
36 the time spec may be omitted e.g YYYY/MM/dd expands to
37 YYYY/MM/dd.00:00:00-YYYY/MM/dd.23:59:59 and sends all flow from a
38 given day.
39 .TP 3
40 .B -c \fInum
41 Limit number of records to send to the first \fInum\fR flows.
42 .TP 3
43 .B -V
44 Print nfreplay version and exit.
45 .TP 3
46 .B -h
47 Print help text on stdout with all options and exit.
48 .SH "RETURN VALUE"
49 Returns
50 .PD 0
51 .RS 4
52 0 No error. \fn
53 .P
54 255 Initialization failed.
55 .P
56 254 Error in filter syntax.
57 .P
58 250 Internal error.
59 .RE
60 .PD
61 .SH NOTES
62 .P
63 .SH "SEE ALSO"
64 nfcapd(1), nfdump(1), nfprofile(1)
65 .SH BUGS
66
0 /*
1 * nfreplay : Reads netflow data from files saved by nfcapd
2 * and sends them to another host.
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: nfreplay.c 42 2005-08-24 12:32:39Z peter $
34 *
35 * $LastChangedRevision: 42 $
36 *
37 */
38
39 #include <stdio.h>
40 #include <unistd.h>
41 #include <stdlib.h>
42 #include <errno.h>
43 #include <time.h>
44 #include <string.h>
45 #include <sys/types.h>
46 #include <sys/stat.h>
47 #include <fcntl.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
51
52 #include "config.h"
53
54 #ifdef HAVE_STDINT_H
55 #include <stdint.h>
56 #endif
57
58
59 #include "netflow_v5.h"
60 #include "version.h"
61 #include "nf_common.h"
62 #include "nftree.h"
63 #include "nfdump.h"
64 #include "util.h"
65 #include "grammar.h"
66
67 #define BuffNumRecords 1024
68
69 // all records should be version 5
70 #define NETFLOW_VERSION 5
71
72 /* Externals */
73 extern int yydebug;
74
75 /* Global Variables */
76 FilterEngine_data_t *Engine;
77 int byte_mode, packet_mode;
78 uint32_t byte_limit, packet_limit; // needed for linking purpose only
79
80 /* Local Variables */
81 static char const *rcsid = "$Id: nfreplay.c 42 2005-08-24 12:32:39Z peter $";
82
83 /* Function Prototypes */
84 static void usage(char *name);
85
86 static int create_send_socket(unsigned int wmem_size);
87
88 static void send_data(char *rfile, int socket, char *send_ip, int send_port, char *filter,
89 time_t twin_start, time_t twin_end, uint32_t count, unsigned int delay);
90
91
92 /* Functions */
93 static void usage(char *name) {
94 printf("usage %s [options] [\"filter\"]\n"
95 "-h\t\tthis text you see right here\n"
96 "-V\t\tPrint version and exit.\n"
97 "-i <ip>\t\tTarget IP address default: 127.0.0.1\n"
98 "-p <port>\tTarget port default 9995\n"
99 "-d <usec>\tDelay in usec between packets. default 10\n"
100 "-c <cnt>\tPacket count. default send all packets\n"
101 "-b <bsize>\tSend buffer size.\n"
102 "-r <input>\tread from file. default: stdin\n"
103 "-f <filter>\tfilter syntaxfile\n"
104 "-t <time>\ttime window for sendiing packets\n"
105 "\t\tyyyy/MM/dd.hh:mm:ss[-yyyy/MM/dd.hh:mm:ss]\n"
106 , name);
107 } /* usage */
108
109 static int create_send_socket(unsigned int wmem_size) {
110 int send_socket;
111 unsigned int wmem_actual;
112 socklen_t optlen;
113
114 // create socket
115 send_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
116 if (send_socket == -1) {
117 perror("Opening output socket failed");
118 return 0;
119 }
120
121 // Set socket write buffer. Need to be root!
122 if ( wmem_size > 0 ) {
123 if ( geteuid() == 0 ) {
124 setsockopt(send_socket, SOL_SOCKET, SO_SNDBUF, &wmem_size, sizeof(wmem_size));
125
126 // check what was set (e.g. linux 2.4.20 sets twice of what was requested)
127 getsockopt(send_socket, SOL_SOCKET, SO_SNDBUF, &wmem_actual, &optlen);
128
129 if (wmem_size != wmem_actual) {
130 printf("Warning: Socket write buffer size requested: %u set: %u\n",
131 wmem_size, wmem_actual);
132 }
133 } else {
134 printf("Warning: Socket buffer size can only be changed by root!\n");
135 }
136 }
137
138
139 return send_socket;
140
141 } // End of create_send_socket
142
143 static void send_data(char *rfile, int socket, char *send_ip, int send_port, char *filter,
144 time_t twin_start, time_t twin_end, uint32_t count, unsigned int delay) {
145 netflow_v5_header_t *nf_header;
146 netflow_v5_record_t *nf_record, *record_buffer;
147 flow_record_t *flow_record;
148 void *sendptr, *sendbuff;
149 struct sockaddr_in send_to;
150 int i, rfd, done, ret, *ftrue, old_format;
151 uint32_t NumRecords, numflows, cnt, flow_sequence;
152 uint64_t boot_time;
153
154 // address descriptor
155 send_to.sin_family = AF_INET;
156 send_to.sin_port = htons(send_port);
157 // if ( inet_aton(send_ip, &(send_to.sin_addr)) == 0 ) {
158 if ((send_to.sin_addr.s_addr = inet_addr(send_ip)) == -1) {
159 perror("Invalid target IP address ");
160 return;
161 }
162
163 rfd = GetNextFile(0, twin_start, twin_end);
164 if ( rfd < 0 ) {
165 if ( errno )
166 perror("Can't open file for reading");
167 return;
168 }
169
170 // prepare read and send buffer
171 record_buffer = (netflow_v5_record_t *) calloc(BuffNumRecords , NETFLOW_V5_RECORD_LENGTH);
172 sendbuff = calloc(BuffNumRecords , NETFLOW_V5_RECORD_LENGTH) + NETFLOW_V5_HEADER_LENGTH;
173 ftrue = (int *) calloc(BuffNumRecords , sizeof(int));
174 if ( !record_buffer || !sendbuff || !ftrue ) {
175 perror("Memory allocation error");
176 close(rfd);
177 return;
178 }
179
180 numflows = 0;
181 done = 0;
182 flow_sequence = 0;
183 nf_header = (netflow_v5_header_t *)sendbuff;
184
185 while ( !done ) {
186 ret = read(rfd, nf_header, NETFLOW_V5_HEADER_LENGTH);
187 if ( ret == 0 ) {
188 done = 1;
189 break;
190 } else if ( ret == -1 ) {
191 perror("Error reading data");
192 close(rfd);
193 return;
194 }
195 if ( nf_header->version != NETFLOW_VERSION ) {
196 fprintf(stdout, "Not a netflow v5 header\n");
197 close(rfd);
198 return;
199 }
200 if ( nf_header->count > BuffNumRecords ) {
201 fprintf(stderr, "Too many records %u ( > BuffNumRecords )\n", nf_header->count);
202 break;
203 }
204
205 NumRecords = nf_header->count;
206 old_format = nf_header->reserved != 1;
207
208 ret = read(rfd, record_buffer, NumRecords * NETFLOW_V5_RECORD_LENGTH);
209 if ( ret == 0 ) {
210 done = 1;
211 break;
212 } else if ( ret == -1 ) {
213 perror("Error reading data");
214 close(rfd);
215 return;
216 }
217
218 // cnt is the number of blocks, which survived the filter
219 // ftrue is an array of flags of the filter result
220 cnt = 0;
221 for ( i=0; i < NumRecords && numflows < count; i++ ) {
222 nf_record = &(record_buffer[i]);
223 // if no filter is given, the result is always true
224 ftrue[i] = twin_start ? nf_record->First >= twin_start && nf_record->Last <= twin_end : 1;
225 Engine->nfrecord = (uint32_t *)nf_record;
226
227 if ( filter && ftrue[i] )
228 ftrue[i] = (*Engine->FilterEngine)(Engine);
229
230 if ( ftrue[i] ) {
231 cnt++;
232 numflows++;
233 }
234 }
235
236 // set new count in v5 header
237 nf_header->count = cnt;
238
239 // dump header and records only, if any block is left
240 if ( cnt ) {
241 sendptr = (void *)((pointer_addr_t)sendbuff + NETFLOW_V5_HEADER_LENGTH);
242 boot_time = ((uint64_t)(nf_header->unix_secs)*1000 +
243 ((uint64_t)(nf_header->unix_nsecs) / 1000000) ) - (uint64_t)(nf_header->SysUptime);
244
245 nf_header->version = htons(nf_header->version);
246 nf_header->count = htons(nf_header->count);
247 nf_header->SysUptime = htonl(nf_header->SysUptime);
248 nf_header->unix_secs = htonl(nf_header->unix_secs);
249 nf_header->unix_nsecs = htonl(nf_header->unix_nsecs);
250 nf_header->flow_sequence = flow_sequence;
251 flow_sequence += cnt;
252
253 for ( i=0; i < NumRecords; i++ ) {
254 nf_record = &(record_buffer[i]);
255 if ( ftrue[i] ) {
256 /* the use of the flow_record cast is a bit ugly, but needs to be rewritten anyway when v9 comes */
257 flow_record = (flow_record_t *)nf_record;
258
259 /* may be removed when old format died out */
260 if ( old_format ) {
261 flow_record->msec_first = 0;
262 flow_record->msec_last = 0;
263 }
264
265 nf_record->First = (uint32_t)(1000LL * (uint64_t)flow_record->First + flow_record->msec_first - boot_time);
266 nf_record->Last = (uint32_t)(1000LL * (uint64_t)flow_record->Last + flow_record->msec_last - boot_time);
267
268 nf_record->srcaddr = htonl(nf_record->srcaddr);
269 nf_record->dstaddr = htonl(nf_record->dstaddr);
270 nf_record->nexthop = htonl(nf_record->nexthop);
271 nf_record->input = htons(nf_record->input);
272 nf_record->output = htons(nf_record->output);
273 nf_record->dPkts = htonl(nf_record->dPkts);
274 nf_record->dOctets = htonl(nf_record->dOctets);
275 nf_record->First = htonl(nf_record->First);
276 nf_record->Last = htonl(nf_record->Last);
277 nf_record->srcport = htons(nf_record->srcport);
278 nf_record->dstport = htons(nf_record->dstport);
279 nf_record->src_as = htons(nf_record->src_as);
280 nf_record->dst_as = htons(nf_record->dst_as);
281 nf_record->src_mask = 0;
282 nf_record->dst_mask = 0;
283 nf_record->pad2 = 0;
284
285 memcpy(sendptr, nf_record, NETFLOW_V5_RECORD_LENGTH);
286 sendptr = (void *)((pointer_addr_t)sendptr + NETFLOW_V5_RECORD_LENGTH);
287 }
288 // increment pointer by number of bytes for netflow record
289 nf_record = (void *)((pointer_addr_t)nf_record + NETFLOW_V5_RECORD_LENGTH);
290
291 }
292
293 ret = sendto(socket, (void *)sendbuff, cnt * NETFLOW_V5_RECORD_LENGTH + NETFLOW_V5_HEADER_LENGTH, 0,
294 (struct sockaddr *)&send_to, sizeof(send_to));
295
296 if ( ret < 0 ) {
297 perror("Error writing data");
298 close(rfd);
299 return;
300 }
301
302 if ( delay ) {
303 // sleep as specified
304 usleep(delay);
305 }
306
307 if ( numflows >= count )
308 done = 1;
309
310 } // if cnt
311 } // while
312
313 } // End of send_data
314
315
316 int main( int argc, char **argv ) {
317 struct stat stat_buff;
318 char c, *rfile, *ffile, *filter, *tstring;
319 char *send_ip;
320 int send_port, ffd, ret, sockfd;
321 unsigned int delay, count, sockbuff;
322 time_t t_start, t_end;
323
324 rfile = ffile = filter = tstring = NULL;
325 t_start = t_end = 0;
326 send_ip = "127.0.0.1";
327 send_port = 9995;
328 delay = 10;
329 count = 0xFFFFFFFF;
330 sockbuff = 0;
331 while ((c = getopt(argc, argv, "hi:p:d:c:b:r:f:t:V")) != EOF) {
332 switch (c) {
333 case 'h':
334 usage(argv[0]);
335 exit(0);
336 break;
337 case 'V':
338 printf("%s: Version: %s %s\n%s\n",argv[0], nfdump_version, nfdump_date, rcsid);
339 exit(0);
340 break;
341 case 'i':
342 send_ip = optarg;
343 break;
344 case 'p':
345 send_port = atoi(optarg);
346 if ( send_port <= 0 || send_port > 65535 ) {
347 fprintf(stderr, "Send port out of range\n");
348 exit(255);
349 }
350 break;
351 case 'd':
352 delay = atoi(optarg);
353 break;
354 case 'c':
355 count = atoi(optarg);
356 break;
357 case 'b':
358 sockbuff = atoi(optarg);
359 break;
360 case 'f':
361 ffile = optarg;
362 break;
363 case 't':
364 tstring = optarg;
365 break;
366 case 'r':
367 rfile = optarg;
368 break;
369 default:
370 usage(argv[0]);
371 exit(0);
372 }
373 }
374 if (argc - optind > 1) {
375 usage(argv[0]);
376 exit(255);
377 } else {
378 /* user specified a pcap filter */
379 filter = argv[optind];
380 }
381
382 if ( !filter && ffile ) {
383 if ( stat(ffile, &stat_buff) ) {
384 perror("Can't stat file");
385 exit(255);
386 }
387 filter = (char *)malloc(stat_buff.st_size);
388 if ( !filter ) {
389 perror("Memory error");
390 exit(255);
391 }
392 ffd = open(ffile, O_RDONLY);
393 if ( ffd < 0 ) {
394 perror("Can't open file");
395 exit(255);
396 }
397 ret = read(ffd, (void *)filter, stat_buff.st_size);
398 if ( ret < 0 ) {
399 perror("Error reading file");
400 close(ffd);
401 exit(255);
402 }
403 close(ffd);
404 }
405
406 if ( !filter )
407 filter = "any";
408
409 Engine = CompileFilter(filter);
410 if ( !Engine )
411 exit(254);
412
413 sockfd = create_send_socket(sockbuff);
414 if ( sockfd <= 0 ) {
415 exit(255);
416 }
417
418
419 SetupInputFileSequence(NULL,rfile, NULL);
420
421 if ( tstring ) {
422 if ( !ScanTimeFrame(tstring, &t_start, &t_end) )
423 exit(255);
424 }
425
426 send_data(rfile, sockfd, send_ip, send_port, filter, t_start, t_end, count, delay);
427
428 return 0;
429 }
0 /* This file is part of the nfdump project.
1 *
2 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of SWITCH nor the names of its contributors may be
14 * used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Author: peter $
30 *
31 * $Id: nfstat.c 53 2005-11-17 07:45:34Z peter $
32 *
33 * $LastChangedRevision: 53 $
34 *
35 */
36
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <errno.h>
40 #include <sys/types.h>
41 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
44 #include <time.h>
45 #include <string.h>
46
47 #include "config.h"
48
49 #ifdef HAVE_STDINT_H
50 #include <stdint.h>
51 #endif
52
53 #include "nfdump.h"
54 #include "netflow_v5.h"
55 #include "nf_common.h"
56 #include "util.h"
57 #include "panonymizer.h"
58 #include "nfstat.h"
59
60 struct flow_element_s {
61 uint32_t offset; // set in the netflow record block
62 uint32_t mask; // mask for value in 32bit word
63 uint32_t shift; // number of bits to shift right to get final value
64 };
65
66 struct StatParameter_s {
67 char *statname; // name of -s option
68 char *HeaderInfo; // How to name the field in the output header line
69 struct flow_element_s element[2]; // what element(s) in flow record is used for statistics.
70 // need 2 elements to be able to get src/dst stats in one stat record
71 uint8_t num_elem; // number of elements used. 1 ord 2
72 uint8_t ipconv; // is an IP address: Convert number to readable IP Addr
73 } StatParameters[] ={
74 // flow record stst
75 { "record", "", { {0,0, 0}, {0,0,0} }, 1, 0},
76
77 // 9 possible flow element stats
78 { "srcip", "Src IP Addr", { {OffsetSrcIP, MaskIP, 0}, {0,0,0} }, 1, 1},
79 { "dstip", "Dst IP Addr", { {OffsetDstIP, MaskIP, 0}, {0,0,0} }, 1, 1},
80 { "ip", " IP Addr", { {OffsetSrcIP, MaskIP, 0}, {OffsetDstIP, MaskIP, 0} }, 2, 1},
81 { "srcport", " Src Port", { {OffsetPort, MaskSrcPort, ShiftSrcPort}, {0,0,0} }, 1, 0},
82 { "dstport", " Dst Port", { {OffsetPort, MaskDstPort, ShiftDstPort}, {0,0,0} }, 1, 0},
83 { "port", " Port", { {OffsetPort, MaskSrcPort, ShiftSrcPort}, {OffsetPort, MaskDstPort, ShiftDstPort} }, 2, 0},
84 { "srcas", " Src AS", { {OffsetAS, MaskSrcAS, ShiftSrcAS}, {0,0,0} }, 1, 0},
85 { "dstas", " Dst AS", { {OffsetAS, MaskDstAS, ShiftDstAS}, {0,0,0} }, 1, 0},
86 { "as", " AS", { {OffsetAS, MaskSrcAS, ShiftSrcAS}, {OffsetAS, MaskDstAS, ShiftDstAS} }, 2, 0},
87
88 { NULL, NULL, { {0,0, 0}, {0,0,0} }, 1, 0}
89 };
90
91 static const uint32_t NumOrders = 6; // Number of Stats in enum StatTypes
92 enum StatTypes { FLOWS = 0, PACKETS, BYTES, PPS, BPS, BPP };
93
94 struct StatRequest_s {
95 int16_t StatType; // value out of enum StatTypes
96 uint16_t order_bits; // bits 0: flows 1: packets 2: bytes 3: pps 4: bps, 5 bpp
97 } StatRequest[9]; // 9 = number of possible flow element stats
98
99 uint32_t flow_stat_order;
100 /*
101 * pps, bps and bpp are not directly available in the flow/stat record
102 * therefore we need a function to calculate these values
103 */
104 typedef uint32_t (*order_proc_t)(CommonRecord_t *);
105
106 /* order functions */
107 static inline uint32_t pps_function(CommonRecord_t *record);
108
109 static inline uint32_t bps_function(CommonRecord_t *record);
110
111 static inline uint32_t bpp_function(CommonRecord_t *record);
112
113 struct order_mode_s {
114 char *string; // Stat name
115 int val; // order bit set results in this value
116 order_proc_t function; // Function to call if value not directly available in record
117 } order_mode[] = {
118 { "flows", 1, NULL},
119 { "packets", 2, NULL},
120 { "bytes", 4, NULL},
121 { "pps", 8, pps_function},
122 { "bps", 16, bps_function},
123 { "bpp", 32, bpp_function},
124 { NULL, 0, NULL}
125 };
126
127
128 extern uint32_t byte_limit, packet_limit;
129 extern int byte_mode, packet_mode;
130 enum { NONE, LESS, MORE };
131
132 #define MaxMemBlocks 256
133
134 /* function prototypes */
135 static int ParseStatString(char *str, int16_t *StatType, uint16_t *order_bits, int *flow_record_stat);
136
137 static inline FlowTableRecord_t *hash_lookup_FlowTable(uint32_t *index_cache, uint8_t proto,
138 uint32_t addr, uint32_t dstaddr, uint16_t port, uint16_t dstport);
139
140 static inline FlowTableRecord_t *hash_insert_FlowTable(uint32_t index_cache,
141 uint32_t addr, uint32_t dstaddr, uint16_t port, uint16_t dstport);
142
143 static inline StatRecord_t *stat_hash_lookup(uint32_t addr, int hash_num);
144
145 static inline StatRecord_t *stat_hash_insert(uint32_t addr, int hash_num);
146
147 static void Expand_FlowTable_Blocks(void);
148
149 static void Expand_StatTable_Blocks(int hash_num);
150
151 static inline void MapRecord(flow_record_t *flow_record, void *record);
152
153 static void PrintStatLine(StatRecord_t *StatData, int ipconv, int anon);
154
155 static void Create_topN_FlowStat(SortElement_t **topN_lists, int order, int topN, uint32_t *count );
156
157 // static SortElement_t *Make_TopN_packets(int topN, uint32_t *count);
158
159 // static SortElement_t *Make_TopN_bytes(int topN, uint32_t *count);
160
161 static SortElement_t *StatTopN(int topN, uint32_t *count, int hash_num, int order );
162
163 static inline void RankValue(FlowTableRecord_t *r, uint64_t val, int topN, SortElement_t *topN_list);
164
165 static void heapSort(SortElement_t *SortElement, uint32_t array_size, int topN);
166
167 static void siftDown(SortElement_t *SortElement, uint32_t root, uint32_t bottom);
168
169 /* locals */
170 #ifndef __SUNPRO_C
171 static
172 #endif
173 hash_FlowTable FlowTable;
174
175 #ifndef __SUNPRO_C
176 static
177 #endif
178 hash_StatTable *StatTable;
179
180 static int NumStats = 0, DefaultOrder;
181
182 #define mix(a,b,c) { \
183 a -= b; a -= c; a ^= (c>>13); \
184 b -= c; b -= a; b ^= (a<<8); \
185 c -= a; c -= b; c ^= (b>>13); \
186 a -= b; a -= c; a ^= (c>>12); \
187 b -= c; b -= a; b ^= (a<<16); \
188 c -= a; c -= b; c ^= (b>>5); \
189 a -= b; a -= c; a ^= (c>>3); \
190 b -= c; b -= a; b ^= (a<<10); \
191 c -= a; c -= b; c ^= (b>>15); \
192 }
193
194 /* Functions */
195
196 static uint32_t pps_function(CommonRecord_t *record) {
197 uint64_t duration;
198
199 /* duration in msec */
200 duration = 1000*(record->last - record->first) + record->msec_last - record->msec_first;
201 if ( duration == 0 )
202 return 0;
203 else
204 return ( 1000LL * (uint64_t)record->counter[PACKETS] ) / duration;
205
206 } // End of pps_function
207
208 static uint32_t bps_function(CommonRecord_t *record) {
209 uint64_t duration;
210
211 duration = 1000*(record->last - record->first) + record->msec_last - record->msec_first;
212 if ( duration == 0 )
213 return 0;
214 else
215 return ( 8000LL * (uint64_t)record->counter[BYTES] ) / duration; /* 8 bits per Octet - x 1000 for msec */
216
217 } // End of bps_function
218
219 static uint32_t bpp_function(CommonRecord_t *record) {
220
221 return record->counter[BYTES] / record->counter[PACKETS];
222
223 } // End of bpp_function
224
225 int Init_FlowTable(uint16_t NumBits, uint32_t Prealloc) {
226 uint32_t maxindex;
227
228 if ( NumBits == 0 || NumBits > 31 ) {
229 fprintf(stderr, "Numbits outside 1..31\n");
230 exit(255);
231 }
232 maxindex = (1 << NumBits);
233 FlowTable.IndexMask = maxindex -1;
234 FlowTable.NumBits = NumBits;
235 FlowTable.Prealloc = Prealloc;
236 FlowTable.bucket = (FlowTableRecord_t **)calloc(maxindex, sizeof(FlowTableRecord_t *));
237 FlowTable.bucketcache = (FlowTableRecord_t **)calloc(maxindex, sizeof(FlowTableRecord_t *));
238 if ( !FlowTable.bucket ) {
239 perror("Can't allocate memory");
240 return 0;
241 }
242 FlowTable.memblock = (FlowTableRecord_t **)calloc(MaxMemBlocks, sizeof(FlowTableRecord_t *));
243 if ( !FlowTable.memblock ) {
244 perror("Can't allocate memory");
245 return 0;
246 }
247 FlowTable.memblock[0] = (FlowTableRecord_t *)calloc(Prealloc, sizeof(FlowTableRecord_t));
248
249 FlowTable.NumBlocks = 1;
250 FlowTable.MaxBlocks = MaxMemBlocks;
251 FlowTable.NextBlock = 0;
252 FlowTable.NextElem = 0;
253
254 if ( !flow_stat_order )
255 flow_stat_order = DefaultOrder;
256
257 return 1;
258
259 } // End of Init_FlowTable
260
261 int Init_StatTable(uint16_t NumBits, uint32_t Prealloc) {
262 uint32_t maxindex;
263 int hash_num;
264
265 if ( NumBits == 0 || NumBits > 31 ) {
266 fprintf(stderr, "Numbits outside 1..31\n");
267 exit(255);
268 }
269
270 maxindex = (1 << NumBits);
271
272 StatTable = (hash_StatTable *)calloc(NumStats, sizeof(hash_StatTable));
273 if ( !StatTable ) {
274 perror("Init_StatTable memory error");
275 return 0;
276 }
277
278 for ( hash_num=0; hash_num<NumStats; hash_num++ ) {
279 StatTable[hash_num].IndexMask = maxindex -1;
280 StatTable[hash_num].NumBits = NumBits;
281 StatTable[hash_num].Prealloc = Prealloc;
282 StatTable[hash_num].bucket = (StatRecord_t **)calloc(maxindex, sizeof(StatRecord_t *));
283 StatTable[hash_num].bucketcache = (StatRecord_t **)calloc(maxindex, sizeof(StatRecord_t *));
284 if ( !StatTable[hash_num].bucket || !StatTable[hash_num].bucketcache ) {
285 perror("Init_StatTable memory error");
286 return 0;
287 }
288 StatTable[hash_num].memblock = (StatRecord_t **)calloc(MaxMemBlocks, sizeof(StatRecord_t *));
289 if ( !StatTable[hash_num].memblock ) {
290 perror("Init_StatTable Memory error");
291 return 0;
292 }
293 StatTable[hash_num].memblock[0] = (StatRecord_t *)calloc(Prealloc, sizeof(StatRecord_t));
294 if ( !StatTable[hash_num].memblock[0] ) {
295 perror("Init_StatTable Memory error");
296 return 0;
297 }
298
299 StatTable[hash_num].NumBlocks = 1;
300 StatTable[hash_num].MaxBlocks = MaxMemBlocks;
301 StatTable[hash_num].NextBlock = 0;
302 StatTable[hash_num].NextElem = 0;
303
304 if ( StatRequest[hash_num].order_bits == 0 ) {
305 StatRequest[hash_num].order_bits = DefaultOrder;
306 }
307 }
308
309 return 1;
310
311 } // End of Init_StatTable
312
313 void Dispose_Tables(int flow_stat, int element_stat) {
314 unsigned int i, hash_num;
315
316 if ( flow_stat ) {
317 free((void *)FlowTable.bucket);
318 free((void *)FlowTable.bucketcache);
319 for ( i=0; i<FlowTable.NumBlocks; i++ )
320 free((void *)FlowTable.memblock[i]);
321 free((void *)FlowTable.memblock);
322 }
323
324 if ( element_stat ) {
325 for ( hash_num=0; hash_num<NumStats; hash_num++ ) {
326 free((void *)StatTable[hash_num].bucket);
327 for ( i=0; i<StatTable[hash_num].NumBlocks; i++ )
328 free((void *)StatTable[hash_num].memblock[i]);
329 free((void *)StatTable[hash_num].memblock);
330 }
331 }
332
333 } // End of Dispose_Tables
334
335 int SetStat(char *str, int *element_stat, int *flow_stat) {
336 int flow_record_stat = 0;
337 int16_t StatType = 0;
338 uint16_t order_bits = 0;
339
340 if ( ParseStatString(str, &StatType, &order_bits, &flow_record_stat) ) {
341 if ( flow_record_stat ) {
342 flow_stat_order = order_bits;
343 *flow_stat = 1;
344 } else {
345 StatRequest[NumStats].StatType = StatType;
346 StatRequest[NumStats].order_bits = order_bits;
347 NumStats++;
348 *element_stat = 1;
349 }
350 return 1;
351 } else {
352 return 0;
353 }
354
355 } // End of SetStat
356
357 static int ParseStatString(char *str, int16_t *StatType, uint16_t *order_bits, int *flow_record_stat) {
358 char *s, *q, *r;
359 int i=0;
360
361 if ( NumStats >= 9 )
362 return 0;
363
364 s = strdup(str);
365 q = strchr(s, '/');
366 if ( q )
367 *q = 0;
368
369 i = 0;
370 // check for a valid stat name
371 while ( StatParameters[i].statname ) {
372 if ( strncasecmp(s, StatParameters[i].statname ,16) == 0 ) {
373 // set flag if it's the flow record stat request
374 *flow_record_stat = strncasecmp(s, "record", 16) == 0;
375 break;
376 }
377 i++;
378 }
379
380 // if so - initialize type and order_bits
381 if ( StatParameters[i].statname ) {
382 *StatType = i;
383 *order_bits = 0;
384 } else {
385 return 0;
386 }
387
388 // no order is given - default order applies;
389 if ( !q ) {
390 return 1;
391 }
392
393 // check if one or more orders are given
394 r = ++q;
395 while ( r ) {
396 q = strchr(r, '/');
397 if ( q )
398 *q = 0;
399 i = 0;
400 while ( order_mode[i].string ) {
401 if ( strcasecmp(order_mode[i].string, r ) == 0 )
402 break;
403 i++;
404 }
405 if ( order_mode[i].string ) {
406 *order_bits |= order_mode[i].val;
407 } else
408 return 0;
409
410 if ( !q ) {
411 return 1;
412 }
413
414 r = ++q;
415 }
416
417 return 0;
418
419 } // End of ParseStatString
420
421 int SetStat_DefaultOrder(char *order) {
422 int order_index;
423
424 order_index = 0;
425 while ( order_mode[order_index].string ) {
426 if ( strcasecmp(order_mode[order_index].string, order ) == 0 )
427 break;
428 order_index++;
429 }
430 if ( !order_mode[order_index].string )
431 return 0;
432
433 DefaultOrder = order_mode[order_index].val;
434 return 1;
435
436 } // End of SetStat_DefaultOrder
437
438 static inline FlowTableRecord_t *hash_lookup_FlowTable(uint32_t *index_cache, uint8_t proto,
439 uint32_t addr, uint32_t dstaddr, uint16_t port, uint16_t dstport ) {
440 uint32_t index, a1, a2;
441 FlowTableRecord_t *record;
442
443 index = port ^ dstport;
444 a1 = addr; a2 = dstaddr;
445 mix(a1, a2, index);
446
447 index = (index ^ ( index >> ( 32 - FlowTable.NumBits ))) & FlowTable.IndexMask;
448 *index_cache = index;
449
450 if ( FlowTable.bucket[index] == NULL )
451 return NULL;
452
453 record = FlowTable.bucket[index];
454 while ( record ) {
455 if ( ( record->ip1 == addr && record->ip2 == dstaddr &&
456 record->port1 == port && record->port2 == dstport &&
457 record->proto == proto ) )
458 return record;
459 record = record->next;
460 }
461 return NULL;
462
463 } // End of hash_lookup_FlowTable
464
465 static inline StatRecord_t *stat_hash_lookup(uint32_t addr, int hash_num) {
466 uint32_t index;
467 StatRecord_t *record;
468
469 index = addr & StatTable[hash_num].IndexMask;
470 if ( StatTable[hash_num].bucket[index] == NULL )
471 return NULL;
472
473 record = StatTable[hash_num].bucket[index];
474 while ( record && ( record->stat_key != addr ) ) {
475 record = record->next;
476 }
477 return record;
478
479 } // End of stat_hash_lookup
480
481 static void Expand_FlowTable_Blocks(void) {
482
483 if ( FlowTable.NumBlocks >= FlowTable.MaxBlocks ) {
484 FlowTable.MaxBlocks += MaxMemBlocks;
485 FlowTable.memblock = (FlowTableRecord_t **)realloc(FlowTable.memblock,
486 FlowTable.MaxBlocks * sizeof(FlowTableRecord_t *));
487 if ( !FlowTable.memblock ) {
488 perror("Expand_FlowTable_Blocks Memory error");
489 exit(250);
490 }
491 }
492 FlowTable.memblock[FlowTable.NumBlocks] =
493 (FlowTableRecord_t *)calloc(FlowTable.Prealloc, sizeof(FlowTableRecord_t));
494
495 if ( !FlowTable.memblock[FlowTable.NumBlocks] ) {
496 perror("Expand_FlowTable_Blocks Memory error");
497 exit(250);
498 }
499 FlowTable.NextBlock = FlowTable.NumBlocks++;
500 FlowTable.NextElem = 0;
501
502 } // End of Expand_FlowTable_Blocks
503
504 static void Expand_StatTable_Blocks(int hash_num) {
505
506 if ( StatTable[hash_num].NumBlocks >= StatTable[hash_num].MaxBlocks ) {
507 StatTable[hash_num].MaxBlocks += MaxMemBlocks;
508 StatTable[hash_num].memblock = (StatRecord_t **)realloc(StatTable[hash_num].memblock,
509 StatTable[hash_num].MaxBlocks * sizeof(StatRecord_t *));
510 if ( !StatTable[hash_num].memblock ) {
511 perror("Expand_StatTable_Blocks Memory error");
512 exit(250);
513 }
514 }
515 StatTable[hash_num].memblock[StatTable[hash_num].NumBlocks] =
516 (StatRecord_t *)calloc(StatTable[hash_num].Prealloc, sizeof(StatRecord_t));
517
518 if ( !StatTable[hash_num].memblock[StatTable[hash_num].NumBlocks] ) {
519 perror("Expand_StatTable_Blocks Memory error");
520 exit(250);
521 }
522 StatTable[hash_num].NextBlock = StatTable[hash_num].NumBlocks++;
523 StatTable[hash_num].NextElem = 0;
524
525 } // End of Expand_StatTable_Blocks
526
527 inline static FlowTableRecord_t *hash_insert_FlowTable(uint32_t index_cache,
528 uint32_t addr, uint32_t dstaddr, uint16_t port, uint16_t dstport) {
529 FlowTableRecord_t *record;
530
531 if ( FlowTable.NextElem >= FlowTable.Prealloc )
532 Expand_FlowTable_Blocks();
533
534 record = &(FlowTable.memblock[FlowTable.NextBlock][FlowTable.NextElem]);
535 FlowTable.NextElem++;
536 record->next = NULL;
537 record->ip1 = addr;
538 record->ip2 = dstaddr;
539 record->port1 = port;
540 record->port2 = dstport;
541
542 if ( FlowTable.bucket[index_cache] == NULL )
543 FlowTable.bucket[index_cache] = record;
544 else
545 FlowTable.bucketcache[index_cache]->next = record;
546 FlowTable.bucketcache[index_cache] = record;
547
548 return record;
549
550 } // End of hash_insert_FlowTable
551
552 void InsertFlow(flow_record_t *flow_record) {
553 FlowTableRecord_t *record;
554
555 if ( FlowTable.NextElem >= FlowTable.Prealloc )
556 Expand_FlowTable_Blocks();
557
558 record = &(FlowTable.memblock[FlowTable.NextBlock][FlowTable.NextElem]);
559 FlowTable.NextElem++;
560
561 record->next = NULL;
562 record->ip1 = flow_record->srcaddr;
563 record->ip2 = flow_record->dstaddr;
564 record->port1 = flow_record->srcport;
565 record->port2 = flow_record->dstport;
566 record->counter[BYTES] = flow_record->dOctets;
567 record->counter[PACKETS] = flow_record->dPkts;
568 record->first = flow_record->First;
569 record->msec_first = flow_record->msec_first;
570 record->last = flow_record->Last;
571 record->msec_last = flow_record->msec_last;
572 record->proto = flow_record->prot;
573 record->tcp_flags = flow_record->tcp_flags;
574 record->tos = flow_record->tos;
575 record->counter[FLOWS] = 1;
576
577 } // End of InsertFlow
578
579
580 inline static StatRecord_t *stat_hash_insert(uint32_t addr, int hash_num) {
581 uint32_t index;
582 StatRecord_t *record;
583
584 if ( StatTable[hash_num].NextElem >= StatTable[hash_num].Prealloc )
585 Expand_StatTable_Blocks(hash_num);
586
587 record = &(StatTable[hash_num].memblock[StatTable[hash_num].NextBlock][StatTable[hash_num].NextElem]);
588 StatTable[hash_num].NextElem++;
589 record->next = NULL;
590 record->stat_key = addr;
591
592 index = addr & StatTable[hash_num].IndexMask;
593 if ( StatTable[hash_num].bucket[index] == NULL )
594 StatTable[hash_num].bucket[index] = record;
595 else
596 StatTable[hash_num].bucketcache[index]->next = record;
597 StatTable[hash_num].bucketcache[index] = record;
598
599 return record;
600
601 } // End of stat_hash_insert
602
603 int AddStat(flow_header_t *flow_header, flow_record_t *flow_record, int flow_stat, int element_stat ) {
604 FlowTableRecord_t *FlowTableRecord;
605 StatRecord_t *stat_record;
606 uint32_t index_cache, value;
607 int j, i;
608
609 if ( flow_stat ) {
610 // Update netflow statistics
611 FlowTableRecord = hash_lookup_FlowTable(&index_cache, flow_record->prot,
612 flow_record->srcaddr, flow_record->dstaddr, flow_record->srcport, flow_record->dstport);
613 if ( FlowTableRecord ) {
614 FlowTableRecord->counter[BYTES] += flow_record->dOctets;
615 FlowTableRecord->counter[PACKETS] += flow_record->dPkts;
616
617 if ( TimeMsec_CMP(flow_record->First, flow_record->msec_first, FlowTableRecord->first, FlowTableRecord->msec_first) == 2) {
618 FlowTableRecord->first = flow_record->First;
619 FlowTableRecord->msec_first = flow_record->msec_first;
620 }
621 if ( TimeMsec_CMP(flow_record->Last, flow_record->msec_last, FlowTableRecord->last, FlowTableRecord->msec_last) == 1) {
622 FlowTableRecord->last = flow_record->Last;
623 FlowTableRecord->msec_last = flow_record->msec_last;
624 }
625
626 FlowTableRecord->counter[FLOWS]++;
627
628 } else {
629 FlowTableRecord = hash_insert_FlowTable(index_cache,
630 flow_record->srcaddr, flow_record->dstaddr, flow_record->srcport, flow_record->dstport);
631 if ( !FlowTableRecord )
632 return -1;
633
634 FlowTableRecord->counter[BYTES] = flow_record->dOctets;
635 FlowTableRecord->counter[PACKETS] = flow_record->dPkts;
636 FlowTableRecord->first = flow_record->First;
637 FlowTableRecord->msec_first = flow_record->msec_first;
638 FlowTableRecord->last = flow_record->Last;
639 FlowTableRecord->msec_last = flow_record->msec_last;
640 FlowTableRecord->tos = flow_record->tos;
641 FlowTableRecord->tcp_flags = flow_record->tcp_flags;
642 FlowTableRecord->proto = flow_record->prot;
643 FlowTableRecord->counter[FLOWS] = 1;
644 }
645 }
646
647 // Update element statistics
648 if ( element_stat ) {
649 // for every requested -s stat do
650 for ( j=0; j<NumStats; j++ ) {
651 int stat = StatRequest[j].StatType;
652 // for the number of elements in this stat type
653 for ( i=0; i<StatParameters[stat].num_elem; i++ ) {
654 uint32_t offset = StatParameters[stat].element[i].offset;
655 uint32_t mask = StatParameters[stat].element[i].mask;
656 uint32_t shift = StatParameters[stat].element[i].shift;
657
658 value = ((uint32_t *)flow_record)[offset] & mask;
659 value = value >> shift;
660 stat_record = stat_hash_lookup(value, j);
661 if ( stat_record ) {
662 stat_record->counter[BYTES] += flow_record->dOctets;
663 stat_record->counter[PACKETS] += flow_record->dPkts;
664
665 if ( TimeMsec_CMP(flow_record->First, flow_record->msec_first, stat_record->first, stat_record->msec_first) == 2) {
666 stat_record->first = flow_record->First;
667 stat_record->msec_first = flow_record->msec_first;
668 }
669 if ( TimeMsec_CMP(flow_record->Last, flow_record->msec_last, stat_record->last, stat_record->msec_last) == 1) {
670 stat_record->last = flow_record->Last;
671 stat_record->msec_last = flow_record->msec_last;
672 }
673 stat_record->counter[FLOWS]++;
674
675 } else {
676 stat_record = stat_hash_insert(value, j);
677 if ( !stat_record )
678 return -1;
679
680 stat_record->counter[BYTES] = flow_record->dOctets;
681 stat_record->counter[PACKETS] = flow_record->dPkts;
682 stat_record->first = flow_record->First;
683 stat_record->msec_first = flow_record->msec_first;
684 stat_record->last = flow_record->Last;
685 stat_record->msec_last = flow_record->msec_last;
686 stat_record->counter[FLOWS] = 1;
687 }
688 } // for the number of elements in this stat type
689 } // for every requested -s stat
690 } // Update element statistics
691
692 return 0;
693
694 } // End of AddStat
695
696 static inline void MapRecord(flow_record_t *flow_record, void *record) {
697 /* This function is needed to normalize the data the feed a flow_record_t for printing */
698
699 flow_record->srcaddr = ((FlowTableRecord_t *)record)->ip1;
700 flow_record->dstaddr = ((FlowTableRecord_t *)record)->ip2;
701 flow_record->srcport = ((FlowTableRecord_t *)record)->port1;
702 flow_record->dstport = ((FlowTableRecord_t *)record)->port2;
703 flow_record->dOctets = ((FlowTableRecord_t *)record)->counter[BYTES];
704 flow_record->dPkts = ((FlowTableRecord_t *)record)->counter[PACKETS];
705
706 flow_record->First = ((FlowTableRecord_t *)record)->first;
707 flow_record->msec_first = ((FlowTableRecord_t *)record)->msec_first;
708 flow_record->Last = ((FlowTableRecord_t *)record)->last;
709 flow_record->msec_last = ((FlowTableRecord_t *)record)->msec_last;
710
711 flow_record->prot = ((FlowTableRecord_t *)record)->proto;
712 flow_record->tcp_flags = ((FlowTableRecord_t *)record)->tcp_flags;
713 flow_record->tos = ((FlowTableRecord_t *)record)->tos;
714
715 } // End of MapRecord
716
717 static void PrintStatLine(StatRecord_t *StatData, int ipconv, int anon) {
718 char *str, valstr[32], datestr[64], flows_str[32], byte_str[32], packets_str[32], pps_str[32], bps_str[32];
719 double duration;
720 uint32_t pps, bps, bpp;
721 time_t First;
722 struct tm *tbuff;
723 struct in_addr a;
724
725 if ( ipconv ) {
726 a.s_addr = htonl(StatData->stat_key);
727 if ( anon ) {
728 a.s_addr = anonymize(a.s_addr);
729 }
730 str = inet_ntoa(a);
731 strncpy(valstr, str, 15);
732 valstr[15] = 0;
733 } else {
734 snprintf(valstr, 15, "%u", StatData->stat_key);
735 valstr[31] = 0;
736 }
737
738 format_number(StatData->counter[FLOWS], flows_str);
739 format_number(StatData->counter[PACKETS], packets_str);
740 format_number(StatData->counter[BYTES], byte_str);
741
742 duration = StatData->last - StatData->first;
743 duration += ((double)StatData->msec_last - (double)StatData->msec_first) / 1000.0;
744
745 if ( duration != 0 ) {
746 pps = (uint32_t)((double)StatData->counter[PACKETS] / duration);
747 bps = (uint32_t)((double)(8 * StatData->counter[BYTES]) / duration);
748 } else {
749 pps = bps = 0;
750 }
751 bpp = StatData->counter[BYTES] / StatData->counter[PACKETS];
752 format_number(pps, pps_str);
753 format_number(bps, bps_str);
754
755 First = StatData->first;
756 tbuff = localtime(&First);
757 if ( !tbuff ) {
758 perror("Error time convert");
759 exit(250);
760 }
761 strftime(datestr, 63, "%Y-%m-%d %H:%M:%S", tbuff);
762
763 printf("%s.%03u %8.3f %15s %8s %8s %8s %8s %8s %5u\n", datestr, StatData->msec_first, duration,
764 valstr, flows_str, packets_str, byte_str, pps_str, bps_str, bpp );
765
766 } // End of PrintStatLine
767
768 void ReportAggregated(printer_t print_record, uint32_t limitflows, int date_sorted, int anon) {
769 FlowTableRecord_t *r;
770 flow_record_t flow_record;
771 SortElement_t *SortList;
772 uint32_t i, j, tmp;
773 uint32_t maxindex, c;
774 char *string;
775
776 c = 0;
777 maxindex = ( FlowTable.NextBlock * FlowTable.Prealloc ) + FlowTable.NextElem;
778 if ( date_sorted ) {
779 // Sort according the date
780 SortList = (SortElement_t *)calloc(maxindex+1, sizeof(SortElement_t));
781
782 if ( !SortList ) {
783 perror("Can't allocate Top N lists: \n");
784 return;
785 }
786
787 // preset SortList table - still unsorted
788 for ( i=0; i <= FlowTable.IndexMask; i++ ) {
789 r = FlowTable.bucket[i];
790 // foreach elem in this bucket
791 while ( r ) {
792 // we want to sort only those flows which pass the packet or byte limits
793 if ( byte_limit ) {
794 if (( byte_mode == LESS && r->counter[BYTES] >= byte_limit ) ||
795 ( byte_mode == MORE && r->counter[BYTES] <= byte_limit ) ) {
796 r = r->next;
797 continue;
798 }
799 }
800 if ( packet_limit ) {
801 if (( packet_mode == LESS && r->counter[PACKETS] >= packet_limit ) ||
802 ( packet_mode == MORE && r->counter[PACKETS] <= packet_limit ) ) {
803 r = r->next;
804 continue;
805 }
806 }
807
808 SortList[c].count = 1000LL * r->first + r->msec_first; // sort according the date
809 SortList[c].record = (void *)r;
810 r = r->next;
811 c++;
812 }
813 }
814
815 SortList[maxindex].count = 0;
816 // heapSort(SortList, maxindex, 0);
817 if ( c >= 2 )
818 heapSort(SortList, c, 0);
819
820 if ( limitflows && limitflows < maxindex )
821 maxindex = limitflows;
822 for ( i = 0; i < maxindex; i++ ) {
823
824 flow_record.srcaddr = ((FlowTableRecord_t *)(SortList[i].record))->ip1;
825 flow_record.dstaddr = ((FlowTableRecord_t *)(SortList[i].record))->ip2;
826 flow_record.srcport = ((FlowTableRecord_t *)(SortList[i].record))->port1;
827 flow_record.dstport = ((FlowTableRecord_t *)(SortList[i].record))->port2;
828 flow_record.dOctets = ((FlowTableRecord_t *)(SortList[i].record))->counter[BYTES];
829 flow_record.dPkts = ((FlowTableRecord_t *)(SortList[i].record))->counter[PACKETS];
830
831 flow_record.First = ((FlowTableRecord_t *)(SortList[i].record))->first;
832 flow_record.msec_first = ((FlowTableRecord_t *)(SortList[i].record))->msec_first;
833 flow_record.Last = ((FlowTableRecord_t *)(SortList[i].record))->last;
834 flow_record.msec_last = ((FlowTableRecord_t *)(SortList[i].record))->msec_last;
835
836 flow_record.prot = ((FlowTableRecord_t *)(SortList[i].record))->proto;
837 flow_record.tcp_flags = ((FlowTableRecord_t *)(SortList[i].record))->tcp_flags;
838 flow_record.tos = ((FlowTableRecord_t *)(SortList[i].record))->tos;
839
840 print_record((void *)&flow_record, ((FlowTableRecord_t *)(SortList[i].record))->counter[FLOWS],
841 ((FlowTableRecord_t *)(SortList[i].record))->counter[PACKETS],
842 ((FlowTableRecord_t *)(SortList[i].record))->counter[BYTES],
843 &string, anon);
844 printf("%s\n", string);
845
846 }
847
848 } else {
849 // print them as they came
850 c = 0;
851 for ( i=0; i < FlowTable.NumBlocks; i++ ) {
852 tmp = i * FlowTable.Prealloc;
853 for ( j=0; j < FlowTable.Prealloc; j++ ) {
854 r = &(FlowTable.memblock[i][j]);
855 if ( (tmp + j) < maxindex ) {
856 if ( limitflows && c >= limitflows )
857 return;
858
859 // we want to print only those flows which pass the packet or byte limits
860 if ( byte_limit ) {
861 if (( byte_mode == LESS && r->counter[BYTES] >= byte_limit ) ||
862 ( byte_mode == MORE && r->counter[BYTES] <= byte_limit ) ) {
863 continue;
864 }
865 }
866 if ( packet_limit ) {
867 if (( packet_mode == LESS && r->counter[PACKETS] >= packet_limit ) ||
868 ( packet_mode == MORE && r->counter[PACKETS] <= packet_limit ) ) {
869 continue;
870 }
871 }
872
873 flow_record.srcaddr = r->ip1;
874 flow_record.dstaddr = r->ip2;
875 flow_record.srcport = r->port1;
876 flow_record.dstport = r->port2;
877 flow_record.dOctets = r->counter[BYTES];
878 flow_record.dPkts = r->counter[PACKETS];
879 flow_record.First = r->first;
880 flow_record.msec_first = r->msec_first;
881 flow_record.Last = r->last;
882 flow_record.msec_last = r->msec_last;
883 flow_record.prot = r->proto;
884 flow_record.tcp_flags = r->tcp_flags;
885 flow_record.tos = r->tos;
886
887 print_record((void *)&flow_record, r->counter[FLOWS], r->counter[PACKETS], r->counter[BYTES], &string, anon);
888 printf("%s\n", string);
889
890 c++;
891 }
892 }
893 }
894 }
895
896 } // End of ReportAggregated
897
898 void ReportStat(char *record_header, printer_t print_record, int topN, int flow_stat, int element_stat, int anon) {
899 SortElement_t *topN_flow_list[NumOrders];
900 SortElement_t *topN_element_list;
901 flow_record_t flow_record;
902 uint32_t numflows, maxindex;
903 int32_t i, j, hash_num, order_index, order_bit;
904 char *string;
905
906
907 if ( flow_stat ) {
908 for ( i=0; i<NumOrders; i++ ) {
909 topN_flow_list[i] = (SortElement_t *)calloc(topN, sizeof(SortElement_t));
910 if ( !topN_flow_list[i] ) {
911 perror("Can't allocate TopN listarray: \n");
912 return;
913 }
914 }
915
916 Create_topN_FlowStat(topN_flow_list, flow_stat_order , topN, &numflows);
917 printf("Aggregated flows %u\n", numflows);
918
919
920 for ( order_index=0; order_index<NumOrders; order_index++ ) {
921 order_bit = 1 << order_index;
922 if ( flow_stat_order & order_bit ) {
923 printf("Top %i flows ordered by %s:\n", topN, order_mode[order_index].string);
924 if ( record_header )
925 printf("%s\n", record_header);
926 for ( i=topN-1; i>=0; i--) {
927 if ( !topN_flow_list[order_index][i].count )
928 break;
929
930 MapRecord(&flow_record, topN_flow_list[order_index][i].record);
931
932 print_record((void *)&flow_record,
933 ((FlowTableRecord_t *)(topN_flow_list[order_index][i].record))->counter[FLOWS],
934 ((FlowTableRecord_t *)(topN_flow_list[order_index][i].record))->counter[PACKETS],
935 ((FlowTableRecord_t *)(topN_flow_list[order_index][i].record))->counter[BYTES],
936 &string, anon);
937 printf("%s\n", string);
938
939 }
940 printf("\n");
941 }
942 }
943
944 /*
945 printf("Top %i flows packet count:\n", topN);
946 if ( record_header )
947 printf("%s\n", record_header);
948
949 for ( i=topN-1; i>=0; i--) {
950 if ( !topN_flow_list[PACKETS][i].count )
951 break;
952
953 MapRecord(&flow_record, topN_flow_list[PACKETS][i].record);
954
955 print_record((void *)&flow_record, ((FlowTableRecord_t *)(topN_flow_list[PACKETS][i].record))->counter[FLOWS], &string, anon);
956 printf("%s\n", string);
957
958 }
959
960 printf("\nTop %i flows byte count:\n", topN);
961 if ( record_header )
962 printf("%s\n", record_header);
963
964 for ( i=topN-1; i>=0; i--) {
965 if ( !topN_flow_list[BYTES][i].count )
966 break;
967
968 MapRecord(&flow_record, topN_flow_list[BYTES][i].record);
969
970 print_record((void *)&flow_record, ((FlowTableRecord_t *)(topN_flow_list[BYTES][i].record))->counter[FLOWS], &string, anon);
971 printf("%s\n", string);
972
973 }
974 printf("\n");
975 */
976 }
977 if ( element_stat ) {
978 // for every requested -s stat do
979 for ( hash_num=0; hash_num<NumStats; hash_num++ ) {
980 int stat = StatRequest[hash_num].StatType;
981 int order = StatRequest[hash_num].order_bits;
982 int ipconv = StatParameters[stat].ipconv;
983
984 for ( order_index=0; order_index<NumOrders; order_index++ ) {
985 order_bit = 1 << order_index;
986 if ( order & order_bit ) {
987 topN_element_list = StatTopN(topN, &numflows, hash_num, order_index);
988 printf("Top %i %s ordered by %s:\n", topN, StatParameters[stat].HeaderInfo, order_mode[order_index].string);
989 // 2005-07-26 20:08:59.197 1553.730 ss 65255 203435 52.2 M 130 281636 268
990 printf("Date first seen Duration %s Flows Packets Bytes pps bps bpp\n",
991 StatParameters[stat].HeaderInfo);
992
993 maxindex = ( StatTable[hash_num].NextBlock * StatTable[hash_num].Prealloc ) + StatTable[hash_num].NextElem;
994 j = numflows - topN;
995 j = j < 0 ? 0 : j;
996 if ( topN == 0 )
997 j = 0;
998
999 for ( i=numflows-1; i>=j ; i--) {
1000 if ( !topN_element_list[i].count )
1001 break;
1002 PrintStatLine((StatRecord_t *)topN_element_list[i].record, ipconv, anon);
1003 }
1004 free((void *)topN_element_list);
1005 printf("\n");
1006 }
1007 } // for every requested order
1008 } // for every requested -s stat do
1009 }
1010
1011 } // End of ReportStat
1012
1013 /*
1014 * Generate the top N lists for packets and bytes in one run
1015 */
1016 static void Create_topN_FlowStat(SortElement_t **topN_lists, int order, int topN, uint32_t *count ) {
1017 FlowTableRecord_t *r;
1018 unsigned int i;
1019 int order_bit, order_index;
1020 uint64_t c, value;
1021
1022 c = 0;
1023 // Iterate through all buckets
1024 for ( i=0; i <= FlowTable.IndexMask; i++ ) {
1025 r = FlowTable.bucket[i];
1026 // foreach elem in this bucket
1027 while ( r ) {
1028
1029 // we want to sort only those flows which pass the packet or byte limits
1030 if ( byte_limit ) {
1031 if (( byte_mode == LESS && r->counter[BYTES] >= byte_limit ) ||
1032 ( byte_mode == MORE && r->counter[BYTES] <= byte_limit ) ) {
1033 r = r->next;
1034 continue;
1035 }
1036 }
1037 if ( packet_limit ) {
1038 if (( packet_mode == LESS && r->counter[PACKETS] >= packet_limit ) ||
1039 ( packet_mode == MORE && r->counter[PACKETS] <= packet_limit ) ) {
1040 r = r->next;
1041 continue;
1042 }
1043 }
1044
1045 c++;
1046 for ( order_index=0; order_index<NumOrders; order_index++ ) {
1047 order_bit = 1 << order_index;
1048 if ( order & order_bit ) {
1049 if ( order_mode[order_index].function )
1050 value = order_mode[order_index].function((CommonRecord_t *)r);
1051 else
1052 value = r->counter[order_index];
1053 RankValue(r, value, topN, topN_lists[order_index]);
1054 }
1055 }
1056
1057 // next elem in bucket
1058 r = r->next;
1059 } // foreach element
1060 }
1061 *count = c;
1062
1063 } // End of Create_topN_FlowStat
1064
1065 void PrintSortedFlows(printer_t print_record, uint32_t limitflows, int anon) {
1066 FlowTableRecord_t *r;
1067 SortElement_t *SortList;
1068 flow_record_t flow_record;
1069 unsigned int i, j, tmp;
1070 uint32_t maxindex, c;
1071 char *string;
1072
1073 maxindex = ( FlowTable.NextBlock * FlowTable.Prealloc ) + FlowTable.NextElem;
1074 SortList = (SortElement_t *)calloc(maxindex+1, sizeof(SortElement_t));
1075
1076 if ( !SortList ) {
1077 perror("Can't allocate Top N lists: \n");
1078 return;
1079 }
1080
1081 // preset SortList table - still unsorted
1082 c = 0;
1083 for ( i=0; i < FlowTable.NumBlocks; i++ ) {
1084 tmp = i * FlowTable.Prealloc;
1085 for ( j=0; j < FlowTable.Prealloc; j++ ) {
1086 r = &(FlowTable.memblock[i][j]);
1087 if ( (tmp + j) < maxindex ) {
1088 SortList[c].count = 1000LL * r->first + r->msec_first; // sort according the date
1089 SortList[c].record = (void *)r;
1090 c++;
1091 }
1092 }
1093 }
1094
1095 SortList[maxindex].count = 0;
1096 heapSort(SortList, maxindex, 0);
1097
1098 if ( limitflows && limitflows < maxindex )
1099 maxindex = limitflows;
1100 for ( i=0; i<maxindex; i++ ) {
1101 r = SortList[i].record;
1102
1103 flow_record.srcaddr = r->ip1;
1104 flow_record.dstaddr = r->ip2;
1105 flow_record.srcport = r->port1;
1106 flow_record.dstport = r->port2;
1107 flow_record.dOctets = r->counter[BYTES];
1108 flow_record.dPkts = r->counter[PACKETS];
1109 flow_record.First = r->first;
1110 flow_record.msec_first = r->msec_first;
1111 flow_record.Last = r->last;
1112 flow_record.msec_last = r->msec_last;
1113 flow_record.prot = r->proto;
1114 flow_record.tcp_flags = r->tcp_flags;
1115 flow_record.tos = r->tos;
1116
1117 print_record((void *)&flow_record, 1, r->counter[PACKETS], r->counter[BYTES], &string, anon);
1118
1119 if ( string )
1120 printf("%s\n", string);
1121 }
1122
1123 free(SortList);
1124
1125 } // End of PrintSortedFlows
1126
1127 /*
1128 * Some different implementation of statistics
1129 *
1130 static SortElement_t *Make_TopN_packets(int topN, uint32_t *count) {
1131 FlowTableRecord_t *r;
1132 SortElement_t *topN_SortList;
1133 unsigned int i;
1134 uint32_t maxindex, c;
1135
1136 maxindex = ( FlowTable.NextBlock * FlowTable.Prealloc ) + FlowTable.NextElem;
1137 topN_SortList = (SortElement_t *)calloc(maxindex+1, sizeof(SortElement_t));
1138
1139 if ( !topN_SortList ) {
1140 perror("Can't allocate Top N lists: \n");
1141 return NULL;
1142 }
1143
1144 // preset topN_SortList table - still unsorted
1145 c = 0;
1146 // Iterate through all buckets
1147 for ( i=0; i <= FlowTable.IndexMask; i++ ) {
1148 r = FlowTable.bucket[i];
1149 // foreach elem in this bucket
1150 while ( r ) {
1151 // next elem in bucket
1152 topN_SortList[c].count = r->pkts;
1153 topN_SortList[c].record = (void *)r;
1154 r = r->next;
1155 c++;
1156 }
1157 }
1158 *count = c;
1159
1160 topN_SortList[maxindex].count = 0;
1161 heapSort(topN_SortList, maxindex, topN);
1162 return topN_SortList;
1163
1164 } // End of Make_TopN_packets
1165
1166 static SortElement_t *Make_TopN_bytes(int topN, uint32_t *count) {
1167 SortElement_t *topN_bytes_list;
1168 FlowTableRecord_t *r;
1169 unsigned int i;
1170 uint32_t maxindex, c;
1171
1172 maxindex = ( FlowTable.NextBlock * FlowTable.Prealloc ) + FlowTable.NextElem;
1173 topN_bytes_list = (SortElement_t *)calloc(maxindex+1, sizeof(SortElement_t));
1174
1175 if ( !topN_bytes_list ) {
1176 perror("Can't allocate Top N lists: \n");
1177 return NULL;
1178 }
1179
1180 // preset topN_SortList table - still unsorted
1181 c = 0;
1182 // Iterate through all buckets
1183 for ( i=0; i <= FlowTable.IndexMask; i++ ) {
1184 r = FlowTable.bucket[i];
1185 // foreach elem in this bucket
1186 while ( r ) {
1187 // next elem in bucket
1188 topN_bytes_list[c].count = r->pkts;
1189 topN_bytes_list[c].record = (void *)r;
1190 r = r->next;
1191 c++;
1192 }
1193 }
1194 *count = c;
1195
1196 topN_bytes_list[maxindex].count = 0;
1197 heapSort(topN_bytes_list, maxindex, topN);
1198 return topN_bytes_list;
1199
1200 } // End of Make_TopN_bytes
1201
1202 */
1203
1204 static SortElement_t *StatTopN(int topN, uint32_t *count, int hash_num, int order ) {
1205 SortElement_t *topN_list;
1206 StatRecord_t *r;
1207 unsigned int i;
1208 uint32_t c, maxindex;
1209
1210 maxindex = ( StatTable[hash_num].NextBlock * StatTable[hash_num].Prealloc ) + StatTable[hash_num].NextElem;
1211 topN_list = (SortElement_t *)calloc(maxindex+1, sizeof(SortElement_t)); // +1 for heapsort bug
1212
1213 if ( !topN_list ) {
1214 perror("Can't allocate Top N lists: \n");
1215 return NULL;
1216 }
1217
1218 // preset topN_list table - still unsorted
1219 c = 0;
1220 // Iterate through all buckets
1221 for ( i=0; i <= StatTable[hash_num].IndexMask; i++ ) {
1222 r = StatTable[hash_num].bucket[i];
1223 // foreach elem in this bucket
1224 while ( r ) {
1225 // next elem in bucket
1226
1227 // we want to sort only those flows which pass the packet or byte limits
1228 if ( byte_limit ) {
1229 if (( byte_mode == LESS && r->counter[BYTES] >= byte_limit ) ||
1230 ( byte_mode == MORE && r->counter[BYTES] <= byte_limit ) ) {
1231 r = r->next;
1232 continue;
1233 }
1234 }
1235 if ( packet_limit ) {
1236 if (( packet_mode == LESS && r->counter[PACKETS] >= packet_limit ) ||
1237 ( packet_mode == MORE && r->counter[PACKETS] <= packet_limit ) ) {
1238 r = r->next;
1239 continue;
1240 }
1241 }
1242
1243 if ( order_mode[order].function )
1244 topN_list[c].count = order_mode[order].function((CommonRecord_t *)r);
1245 else
1246 topN_list[c].count = r->counter[order];
1247
1248 topN_list[c].record = (void *)r;
1249 r = r->next;
1250 c++;
1251 } // foreach element
1252 }
1253 *count = c;
1254 // printf ("Sort %u flows\n", c);
1255
1256 topN_list[maxindex].count = 0;
1257
1258 // Sorting makes only sense, when 2 or more flows are left
1259 if ( c >= 2 )
1260 heapSort(topN_list, c, topN > c ? c : topN);
1261
1262 /*
1263 for ( i = 0; i < maxindex; i++ )
1264 printf("%i, %llu %llu\n", i, topN_list[i].count, topN_list[i].record);
1265 */
1266 return topN_list;
1267
1268 } // End of StatTopN
1269
1270
1271 static inline void RankValue(FlowTableRecord_t *r, uint64_t val, int topN, SortElement_t *topN_list) {
1272 FlowTableRecord_t *r1, *r2;
1273 uint64_t c1, c2;
1274 int j;
1275
1276 if ( val > (topN_list)[0].count ) {
1277 /* element value is bigger than smallest value in topN */
1278 c1 = val;
1279 r1 = r;
1280 for (j=topN-1; j>=0; j-- ) {
1281 if ( c1 > topN_list[j].count ) {
1282 c2 = topN_list[j].count;
1283 r2 = topN_list[j].record;
1284 topN_list[j].count = c1;
1285 topN_list[j].record = r1;
1286 c1 = c2; r1 = r2;
1287 }
1288 }
1289 }
1290
1291 } // End of RankValue
1292
1293 static void heapSort(SortElement_t *SortElement, uint32_t array_size, int topN) {
1294 int32_t i;
1295 uint32_t top_count;
1296 SortElement_t temp;
1297
1298 for (i = (array_size >> 1)-1; i >= 0; i--)
1299 siftDown(SortElement, i, array_size);
1300
1301 top_count = 1;
1302 for (i = array_size-1; i >= 1; i--) {
1303 temp = SortElement[0];
1304 SortElement[0] = SortElement[i];
1305 SortElement[i] = temp;
1306 siftDown(SortElement, 0, i-1);
1307 /*
1308 * if we need to know only the first top N skip
1309 * the sorting of the rest. For topN == 0 -> all gets sorted
1310 * as top_count is never 0
1311 */
1312 if ( top_count == topN ) {
1313 return;
1314 }
1315 top_count++;
1316 }
1317
1318 } // End of heapSort
1319
1320 static void siftDown(SortElement_t *SortElement, uint32_t root, uint32_t bottom) {
1321 uint32_t maxChild;
1322 SortElement_t temp;
1323 int done;
1324
1325 done = 0;
1326 while (((root << 1) <= bottom) && (!done)) {
1327 if ((root << 1) == bottom)
1328 maxChild = root << 1;
1329 else if (SortElement[root << 1].count > SortElement[(root << 1) + 1].count)
1330 maxChild = root << 1;
1331 else
1332 maxChild = (root << 1) + 1;
1333
1334 if (SortElement[root].count < SortElement[maxChild].count) {
1335 temp = SortElement[root];
1336 SortElement[root] = SortElement[maxChild];
1337 SortElement[maxChild] = temp;
1338 root = maxChild;
1339 } else
1340 done = 1;
1341 }
1342 } // End of siftDown
1343
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nfstat.h 47 2005-08-25 12:58:27Z peter $
33 *
34 * $LastChangedRevision: 47 $
35 *
36 */
37
38 /* Definitions */
39
40 /*
41 * Common type for FlowTableRecord_t and StatRecord_t
42 * Needed for some common functions
43 * No variable is ever generated of this type. It's just needed for type coercing
44 * Maybe some day I will rewrite that ... to make it easier
45 */
46 typedef struct CommonRecord_s {
47 // record chain - points to next record
48 struct CommonRecord_s *next;
49 // flow counter parameters for FLOWS, PACKETS and BYTES
50 uint64_t counter[3];
51 uint32_t first;
52 uint32_t last;
53 uint16_t msec_first;
54 uint16_t msec_last;
55 } CommonRecord_t;
56
57 /*
58 * Flow Table
59 * In order to aggregate flows or to generate any flow statistics, the flows passed the filter
60 * are stored into an internal hash table.
61 */
62
63 /* Element of the Flow Table */
64 typedef struct FlowTableRecord {
65 // record chain - points to next record with same hash in case of a hash collision
66 struct FlowTableRecord *next;
67 // flow counter parameters for FLOWS, PACKETS and BYTES
68 uint64_t counter[3];
69 uint32_t first;
70 uint32_t last;
71 uint16_t msec_first;
72 uint16_t msec_last;
73
74 // more flow parameters
75 uint8_t pad1;
76 uint8_t tcp_flags;
77 uint8_t proto;
78 uint8_t tos;
79
80 // elements used for hash generation
81 uint32_t ip1;
82 uint32_t ip2;
83 uint16_t port1;
84 uint16_t port2;
85 } FlowTableRecord_t;
86
87 typedef struct hash_FlowTable {
88 /* hash table data */
89 uint16_t NumBits; /* width of the hash table */
90 uint32_t IndexMask; /* Mask which corresponds to NumBits */
91 FlowTableRecord_t **bucket; /* Hash entry point: points to elements in the flow block */
92 FlowTableRecord_t **bucketcache; /* in case of index collisions, this array points to the last element with that index */
93
94 /* memory management */
95 /* memory blocks - containing the flow blocks */
96 FlowTableRecord_t **memblock; /* array holding all NumBlocks allocated flow blocks */
97 uint32_t MaxBlocks; /* Size of memblock array */
98 /* flow blocks - containing the flows */
99 uint32_t NumBlocks; /* number of allocated flow blocks in memblock array */
100 uint32_t Prealloc; /* Number of flow records in each flow block */
101 uint32_t NextBlock; /* This flow block contains the next free slot for a flow recorrd */
102 uint32_t NextElem; /* This element in the current flow block is the next free slot */
103 } hash_FlowTable;
104
105 /*
106 * Stat Table
107 * In order to generate any flow element statistics, the flows passed the filter
108 * are stored into an internal hash table.
109 */
110
111 typedef struct StatRecord {
112 // record chain
113 struct StatRecord *next;
114 // flow parameters
115 uint64_t counter[3];
116 uint32_t first;
117 uint32_t last;
118 uint16_t msec_first;
119 uint16_t msec_last;
120 // key
121 uint32_t stat_key;
122 } StatRecord_t;
123
124 typedef struct hash_StatTable {
125 /* hash table data */
126 uint16_t NumBits; /* width of the hash table */
127 uint32_t IndexMask; /* Mask which corresponds to NumBits */
128 StatRecord_t **bucket; /* Hash entry point: points to elements in the stat block */
129 StatRecord_t **bucketcache; /* in case of index collisions, this array points to the last element with that index */
130
131 /* memory management */
132 /* memory blocks - containing the stat records */
133 StatRecord_t **memblock; /* array holding all NumBlocks allocated stat blocks */
134 uint32_t MaxBlocks; /* Size of memblock array */
135 /* stat blocks - containing the stat records */
136 uint32_t NumBlocks; /* number of allocated stat blocks in memblock array */
137 uint32_t Prealloc; /* Number of stat records in each stat block */
138 uint32_t NextBlock; /* This stat block contains the next free slot for a stat recorrd */
139 uint32_t NextElem; /* This element in the current stat block is the next free slot */
140 } hash_StatTable;
141
142 typedef struct SortElement {
143 void *record;
144 uint64_t count;
145 } SortElement_t;
146
147
148 /* Function prototypes */
149 int Init_FlowTable(uint16_t NumBits, uint32_t Prealloc);
150
151 int Init_StatTable(uint16_t NumBits, uint32_t Prealloc);
152
153 void Dispose_Tables(int flow_stat, int ip_stat);
154
155 int SetStat(char *str, int *element_stat, int *flow_stat);
156
157 int SetStat_DefaultOrder(char *order);
158
159 void InsertFlow(flow_record_t *flow_record);
160
161 int AddStat(flow_header_t *flow_header, flow_record_t *flow_record, int flow_stat, int element_stat);
162
163 void ReportAggregated(printer_t print_record, uint32_t limitflows, int date_sorted, int anon);
164
165 void ReportStat(char *record_header, printer_t print_record, int topN, int flow_stat, int ip_stat, int anon);
166
167 void PrintSortedFlows(printer_t print_record, uint32_t limitflows, int anon);
168
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nftree.c 48 2005-08-26 08:23:31Z peter $
33 *
34 * $LastChangedRevision: 48 $
35 *
36 */
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <sys/types.h>
41 #include <string.h>
42
43 #include "config.h"
44
45 #ifdef HAVE_STDINT_H
46 #include <stdint.h>
47 #endif
48
49 #include "nfdump.h"
50 #include "nf_common.h"
51 #include "nftree.h"
52 #include "grammar.h"
53 /*
54 * netflow filter engine
55 *
56 */
57
58 #define MAXBLOCKS 1024
59
60 static FilterBlock_t *FilterTree;
61 static uint32_t memblocks;
62
63 static uint32_t NumBlocks = 1; /* index 0 reserved */
64
65 static void UpdateList(uint32_t a, uint32_t b);
66
67 /* flow processing functions */
68 static inline uint32_t pps_function(uint32_t *data);
69 static inline uint32_t bps_function(uint32_t *data);
70 static inline uint32_t bpp_function(uint32_t *data);
71 static inline uint32_t duration_function(uint32_t *data);
72
73 /*
74 * flow processing function table:
75 * order of entries must correspond with filter functions enum in nftree.h
76 */
77 static struct flow_procs_map_s {
78 char *name;
79 flow_proc_t function;
80 } flow_procs_map[] = {
81 {"none", NULL},
82 {"pps", pps_function},
83 {"bps", bps_function},
84 {"bpp", bpp_function},
85 {"duration", duration_function},
86 {NULL, NULL}
87 };
88
89 uint32_t StartNode;
90 uint16_t Extended;
91
92 void InitTree(void) {
93 memblocks = 1;
94 FilterTree = (FilterBlock_t *)malloc(MAXBLOCKS * sizeof(FilterBlock_t));
95 if ( !FilterTree ) {
96 perror("Memory error: ");
97 exit(255);
98 }
99 ClearFilter();
100 } // End of InitTree
101
102 /*
103 * Clear Filter
104 */
105 void ClearFilter(void) {
106
107 NumBlocks = 1;
108 Extended = 0;
109 memset((void *)FilterTree, 0, MAXBLOCKS * sizeof(FilterBlock_t));
110
111 } /* End of ClearFilter */
112
113 FilterEngine_data_t *CompileFilter(char *FilterSyntax) {
114 FilterEngine_data_t *engine;
115 int ret;
116
117 if ( !FilterSyntax )
118 return NULL;
119
120 InitTree();
121 lex_init(FilterSyntax);
122 ret = yyparse();
123 lex_cleanup();
124 if ( ret != 0 ) {
125 return NULL;
126 }
127 engine = malloc(sizeof(FilterEngine_data_t));
128 if ( !engine ) {
129 perror("Memory error: ");
130 exit(255);
131 }
132 engine->nfrecord = NULL;
133 engine->StartNode = StartNode;
134 engine->Extended = Extended;
135 engine->filter = FilterTree;
136 if ( Extended )
137 engine->FilterEngine = RunExtendedFilter;
138 else
139 engine->FilterEngine = RunFilter;
140
141 return engine;
142
143 } // End of GetTree
144
145 /*
146 * For testing purpose only
147 */
148 int nblocks(void) {
149 return NumBlocks - 1;
150 } /* End of nblocks */
151
152 /*
153 * Returns next free slot in blocklist
154 */
155 uint32_t NewBlock(uint32_t offset, uint32_t mask, uint32_t value, uint16_t comp, uint32_t function) {
156 uint32_t n = NumBlocks;
157
158 if ( n >= ( memblocks * MAXBLOCKS ) ) {
159 memblocks++;
160 FilterTree = realloc(FilterTree, memblocks * MAXBLOCKS * sizeof(FilterBlock_t));
161 if ( !FilterTree ) {
162 perror("Memory error: ");
163 exit(255);
164 }
165 }
166
167 FilterTree[n].offset = offset;
168 FilterTree[n].mask = mask;
169 FilterTree[n].value = value;
170 FilterTree[n].invert = 0;
171 FilterTree[n].comp = comp;
172 FilterTree[n].function = flow_procs_map[function].function;
173 FilterTree[n].fname = flow_procs_map[function].name;
174 if ( comp > 0 || function > 0 )
175 Extended = 1;
176
177 FilterTree[n].numblocks = 1;
178 FilterTree[n].blocklist = (uint32_t *)malloc(sizeof(uint32_t));
179 FilterTree[n].superblock = n;
180 FilterTree[n].blocklist[0] = n;
181 NumBlocks++;
182 return n;
183
184 } /* End of NewBlock */
185
186 /*
187 * Connects the two blocks b1 and b2 ( AND ) and returns index of superblock
188 */
189 uint32_t Connect_AND(uint32_t b1, uint32_t b2) {
190
191 uint32_t a, b, i, j;
192
193 if ( FilterTree[b1].numblocks <= FilterTree[b2].numblocks ) {
194 a = b1;
195 b = b2;
196 } else {
197 a = b2;
198 b = b1;
199 }
200 /* a points to block with less children and becomes the superblock
201 * connect b to a
202 */
203 for ( i=0; i < FilterTree[a].numblocks; i++ ) {
204 j = FilterTree[a].blocklist[i];
205 if ( FilterTree[j].invert ) {
206 if ( FilterTree[j].OnFalse == 0 ) {
207 FilterTree[j].OnFalse = b;
208 }
209 } else {
210 if ( FilterTree[j].OnTrue == 0 ) {
211 FilterTree[j].OnTrue = b;
212 }
213 }
214 }
215 UpdateList(a,b);
216 return a;
217
218 } /* End of Connect_AND */
219
220 /*
221 * Connects the two blocks b1 and b2 ( OR ) and returns index of superblock
222 */
223 uint32_t Connect_OR(uint32_t b1, uint32_t b2) {
224
225 uint32_t a, b, i, j;
226
227 if ( FilterTree[b1].numblocks <= FilterTree[b2].numblocks ) {
228 a = b1;
229 b = b2;
230 } else {
231 a = b2;
232 b = b1;
233 }
234 /* a points to block with less children and becomes the superblock
235 * connect b to a
236 */
237 for ( i=0; i < FilterTree[a].numblocks; i++ ) {
238 j = FilterTree[a].blocklist[i];
239 if ( FilterTree[j].invert ) {
240 if ( FilterTree[j].OnTrue == 0 ) {
241 FilterTree[j].OnTrue = b;
242 }
243 } else {
244 if ( FilterTree[j].OnFalse == 0 ) {
245 FilterTree[j].OnFalse = b;
246 }
247 }
248 }
249 UpdateList(a,b);
250 return a;
251
252 } /* End of Connect_OR */
253
254 /*
255 * Inverts OnTrue and OnFalse
256 */
257 uint32_t Invert(uint32_t a) {
258 uint32_t i, j;
259
260 for ( i=0; i< FilterTree[a].numblocks; i++ ) {
261 j = FilterTree[a].blocklist[i];
262 FilterTree[j].invert = FilterTree[j].invert ? 0 : 1 ;
263 }
264 return a;
265
266 } /* End of Invert */
267
268 /*
269 * Update supernode infos:
270 * node 'b' was connected to 'a'. update node 'a' supernode data
271 */
272 static void UpdateList(uint32_t a, uint32_t b) {
273 size_t s;
274 uint32_t i,j;
275
276 /* numblocks contains the number of blocks in the superblock */
277 s = FilterTree[a].numblocks + FilterTree[b].numblocks;
278 FilterTree[a].blocklist = (uint32_t *)realloc(FilterTree[a].blocklist, s * sizeof(uint32_t));
279 if ( !FilterTree[a].blocklist ) {
280 perror("Memory error: ");
281 exit(250);
282 }
283
284 /* connect list of node 'b' after list of node 'a' */
285 j = FilterTree[a].numblocks;
286 for ( i=0; i< FilterTree[b].numblocks; i++ ) {
287 FilterTree[a].blocklist[j+i] = FilterTree[b].blocklist[i];
288 }
289 FilterTree[a].numblocks = s;
290
291 /* set superblock info of all children to new superblock */
292 for ( i=0; i< FilterTree[a].numblocks; i++ ) {
293 j = FilterTree[a].blocklist[i];
294 FilterTree[j].superblock = a;
295 }
296
297 /* cleanup old node 'b' */
298 FilterTree[b].numblocks = 0;
299 if ( FilterTree[b].blocklist )
300 free(FilterTree[b].blocklist);
301
302 } /* End of UpdateList */
303
304 /*
305 * Dump Filterlist
306 */
307 void DumpList(FilterEngine_data_t *args) {
308 uint32_t i, j;
309
310 for (i=1; i<NumBlocks; i++ ) {
311 if ( args->filter[i].invert )
312 printf("Index: %u, Offset: %u, Mask: %x, Value: %x, Superblock: %u, Numblocks: %u, !OnTrue: %u, !OnFalse: %u Comp: %u Function: %s\n",
313 i, args->filter[i].offset, args->filter[i].mask, args->filter[i].value, args->filter[i].superblock,
314 args->filter[i].numblocks, args->filter[i].OnTrue, args->filter[i].OnFalse, args->filter[i].comp, args->filter[i].fname);
315 else
316 printf("Index: %u, Offset: %u, Mask: %x, Value: %x, Superblock: %u, Numblocks: %u, OnTrue: %u, OnFalse: %u Comp: %u Function: %s\n",
317 i, args->filter[i].offset, args->filter[i].mask, args->filter[i].value, args->filter[i].superblock,
318 args->filter[i].numblocks, args->filter[i].OnTrue, args->filter[i].OnFalse, args->filter[i].comp, args->filter[i].fname);
319 printf("\tBlocks: ");
320 for ( j=0; j<args->filter[i].numblocks; j++ )
321 printf("%i ", args->filter[i].blocklist[j]);
322 printf("\n");
323 }
324 printf("NumBlocks: %i\n", NumBlocks - 1);
325
326 } /* End of DumpList */
327
328 /* fast filter engine */
329 int RunFilter(FilterEngine_data_t *args) {
330 uint32_t index, offset;
331 int evaluate, invert;
332
333 index = args->StartNode;
334 evaluate = 0;
335 invert = 0;
336 while ( index ) {
337 offset = args->filter[index].offset;
338 invert = args->filter[index].invert;
339 evaluate = ( args->nfrecord[offset] & args->filter[index].mask ) == args->filter[index].value;
340 index = evaluate ? args->filter[index].OnTrue : args->filter[index].OnFalse;
341 }
342 return invert ? !evaluate : evaluate;
343
344 } /* End of RunFilter */
345
346 /* extended filter engine */
347 int RunExtendedFilter(FilterEngine_data_t *args) {
348 uint32_t index, offset, value;
349 int evaluate, invert;
350
351 index = args->StartNode;
352 evaluate = 0;
353 invert = 0;
354 while ( index ) {
355 offset = args->filter[index].offset;
356 invert = args->filter[index].invert;
357
358 if (args->filter[index].function == NULL)
359 value = args->nfrecord[offset] & args->filter[index].mask;
360 else
361 value = args->filter[index].function(args->nfrecord);
362
363 if ( args->filter[index].comp == CMP_EQ )
364 evaluate = value == args->filter[index].value;
365 else if ( args->filter[index].comp == CMP_GT )
366 evaluate = value > args->filter[index].value;
367 else if ( args->filter[index].comp == CMP_LT )
368 evaluate = value < args->filter[index].value;
369
370 index = evaluate ? args->filter[index].OnTrue : args->filter[index].OnFalse;
371 }
372 return invert ? !evaluate : evaluate;
373
374 } /* End of RunExtendedFilter */
375
376 /* record processing functions */
377
378 static inline uint32_t duration_function(uint32_t *data) {
379 flow_record_t *record;
380 uint64_t duration;
381
382 record = (flow_record_t *)data;
383 /* duration in msec */
384 duration = 1000*(record->Last - record->First) + record->msec_last - record->msec_first;
385
386 return (uint32_t)duration;
387
388 } // End of duration_function
389
390 static inline uint32_t pps_function(uint32_t *data) {
391 flow_record_t *record;
392 uint64_t duration;
393
394 record = (flow_record_t *)data;
395 /* duration in msec */
396 duration = 1000*(record->Last - record->First) + record->msec_last - record->msec_first;
397 if ( duration == 0 )
398 return 0;
399 else
400 return ( 1000LL * (uint64_t)record->dPkts ) / duration;
401
402 } // End of pps_function
403
404 static inline uint32_t bps_function(uint32_t *data) {
405 flow_record_t *record;
406 uint64_t duration;
407
408 record = (flow_record_t *)data;
409 /* duration in msec */
410 duration = 1000*(record->Last - record->First) + record->msec_last - record->msec_first;
411 if ( duration == 0 )
412 return 0;
413 else
414 return ( 8000LL * (uint64_t)record->dOctets ) / duration; /* 8 bits per Octet - x 1000 for msec */
415
416 } // End of bps_function
417
418 static inline uint32_t bpp_function(uint32_t *data) {
419 flow_record_t *record;
420
421 record = (flow_record_t *)data;
422 return record->dPkts ? record->dOctets / record->dPkts : 0;
423
424 } // End of bpp_function
425
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nftree.h 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 */
37
38
39 /*
40 * type definitions for nf tree
41 */
42
43 typedef uint32_t (*flow_proc_t)(uint32_t *);
44
45 typedef struct FilterBlock {
46 /* Filter specific data */
47 uint32_t offset;
48 uint32_t mask;
49 uint32_t value;
50
51 /* Internal block info for tree setup */
52 uint32_t superblock; /* Index of superblock */
53 uint32_t *blocklist; /* index array of blocks, belonging to
54 this superblock */
55 uint32_t numblocks; /* number of blocks in blocklist */
56 uint32_t OnTrue, OnFalse; /* Jump Index for tree */
57 int16_t invert; /* Invert result of test */
58 uint16_t comp; /* comperator */
59 flow_proc_t function; /* function for flow processing */
60 char *fname; /* ascii function name */
61 } FilterBlock_t;
62
63 typedef struct FilterEngine_data_s {
64 FilterBlock_t *filter;
65 uint32_t StartNode;
66 uint16_t Extended;
67 uint32_t *nfrecord;
68 int (*FilterEngine)(struct FilterEngine_data_s *);
69 } FilterEngine_data_t;
70
71 /*
72 * Definitions
73 */
74 enum { CMP_EQ = 0, CMP_GT, CMP_LT };
75
76 /*
77 * filter functions:
78 * For some filter functions, netflow records need to be processed first in order to filter them
79 * This involves all data not directly available in the netflow record, such as packets per second etc.
80 * Filter speed is a bit slower due to extra netflow processsing
81 * The sequence of the enum values must correspond with the entries in the flow_procs array
82 */
83
84 enum { FUNC_NONE = 0, /* no function - just plain filtering - just to be complete here */
85 FUNC_PPS, /* function code for pps ( packet per second ) filter function */
86 FUNC_BPS, /* function code for bps ( bits per second ) filter function */
87 FUNC_BPP, /* function code for bpp ( bytes per packet ) filter function */
88 FUNC_DURATION /* function code for duration ( in miliseconds ) filter function */
89 };
90
91 /*
92 * Filter Engine Functions
93 */
94 int RunFilter(FilterEngine_data_t *args);
95 int RunExtendedFilter(FilterEngine_data_t *args);
96 /*
97 * For testing purpose only
98 */
99 int nblocks(void);
100
101 /*
102 * Initialize globals
103 */
104 void InitTree(void);
105
106 /*
107 * Returns the current Filter Tree
108 */
109 FilterEngine_data_t *CompileFilter(char *FilterSyntax);
110
111 /*
112 * Clear Filter
113 */
114 void ClearFilter(void);
115
116 /*
117 * Returns next free slot in blocklist
118 */
119 uint32_t NewBlock(uint32_t offset, uint32_t mask, uint32_t value, uint16_t comp, uint32_t function);
120
121 /*
122 * Connects the to blocks b1 and b2 ( AND ) and returns index of superblock
123 */
124 uint32_t Connect_AND(uint32_t b1, uint32_t b2);
125
126 /*
127 * Connects the to blocks b1 and b2 ( OR ) and returns index of superblock
128 */
129 uint32_t Connect_OR(uint32_t b1, uint32_t b2);
130
131 /*
132 * Inverts OnTrue and OnFalse
133 */
134 uint32_t Invert(uint32_t a );
135
136 /*
137 * Dump Filterlist
138 */
139 void DumpList(FilterEngine_data_t *args);
140
141 /*
142 * Prints info while filer is running
143 */
144 int RunDebugFilter(uint32_t *block);
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: nftree_check.c 51 2005-08-26 10:58:13Z peter $
33 *
34 * $LastChangedRevision: 51 $
35 *
36 */
37
38 #include <stdio.h>
39 #include <sys/types.h>
40 #include <string.h>
41 #include <stdlib.h>
42
43 #include "config.h"
44
45 #ifdef HAVE_STDINT_H
46 #include <stdint.h>
47 #endif
48
49 #include "nfdump.h"
50 #include "nftree.h"
51 #include "nf_common.h"
52
53 /* Global Variables */
54 FilterEngine_data_t *Engine;
55 uint32_t byte_limit, packet_limit;
56 int byte_mode, packet_mode, failed;
57
58 #define TCP 6
59 #define UDP 17
60
61 int check(char *filter, struct flow_record *flow_record, int expect);
62
63 int check(char *filter, struct flow_record *flow_record, int expect) {
64 int ret;
65
66 Engine = CompileFilter(filter);
67 if ( !Engine ) {
68 exit(254);
69 }
70
71 Engine->nfrecord = (uint32_t *)flow_record;
72 ret = (*Engine->FilterEngine)(Engine);
73 if ( ret == expect ) {
74 printf("Success: Startnode: %i Numblocks: %i Extended: %i Filter: '%s'\n", Engine->StartNode, nblocks(), Engine->Extended, filter);
75 } else {
76 printf("**** FAILED **** Startnode: %i Numblocks: %i Extended: %i Filter: '%s'\n", Engine->StartNode, nblocks(), Engine->Extended, filter);
77 DumpList(Engine);
78 printf("Expected: %i, Found: %i\n", expect, ret);
79 failed = 1;
80 }
81 return (ret == expect);
82 }
83
84 int main(int argc, char **argv) {
85 struct flow_record flow_record;
86 uint32_t *blocks;
87 time_t now;
88 int ret;
89
90 failed = 0;
91 memset((void *)&flow_record, 0, FLOW_RECORD_LENGTH);
92 blocks = (uint32_t *)&flow_record;
93
94 printf("Src AS Offset: %u\n", (unsigned int)((pointer_addr_t)&flow_record.src_as - (pointer_addr_t)&blocks[10]));
95 printf("Dst AS Offset: %u\n", (unsigned int)((pointer_addr_t)&flow_record.dst_as - (pointer_addr_t)&blocks[10]));
96 printf("Src Port Offset: %u\n", (unsigned int)((pointer_addr_t)&flow_record.srcport - (pointer_addr_t)&blocks[8]));
97 printf("Dst Port Offset: %u\n", (unsigned int)((pointer_addr_t)&flow_record.dstport - (pointer_addr_t)&blocks[8]));
98 printf("Protocol Offset: %u\n", (unsigned int)((pointer_addr_t)&flow_record.prot - (pointer_addr_t)&blocks[9]));
99
100 #if defined __OpenBSD__ || defined __FreeBSD__
101 printf("Pointer Size : %u\n", sizeof(blocks));
102 printf("Time_t Size : %u\n", sizeof(now));
103 printf("int Size : %u\n", sizeof(int));
104 printf("long Size : %u\n", sizeof(long));
105 if ( FLOW_HEADER_LENGTH != 24 ) {
106 printf("**** FAILED **** Header length reported %u, expected 24\n", FLOW_HEADER_LENGTH);
107 }
108 if ( FLOW_RECORD_LENGTH != 48 ) {
109 printf("**** FAILED **** Record length reported %u, expected 48\n", FLOW_RECORD_LENGTH);
110 }
111 #else
112 printf("Pointer Size : %u\n", sizeof(blocks));
113 printf("Time_t Size : %u\n", sizeof(now));
114 printf("int Size : %u\n", sizeof(int));
115 printf("long Size : %u\n", sizeof(long));
116 if ( FLOW_HEADER_LENGTH != 24 ) {
117 printf("**** FAILED **** Header length reported %u, expected 24\n", FLOW_HEADER_LENGTH);
118 }
119 if ( FLOW_RECORD_LENGTH != 48 ) {
120 printf("**** FAILED **** Record length reported %u, expected 48\n", FLOW_RECORD_LENGTH);
121 }
122 #endif
123
124 flow_record.prot = TCP;
125 ret = check("any", &flow_record, 1);
126 ret = check("not any", &flow_record, 0);
127 ret = check("tcp", &flow_record, 1);
128 ret = check("udp", &flow_record, 0);
129 flow_record.prot = UDP;
130 ret = check("tcp", &flow_record, 0);
131 ret = check("udp", &flow_record, 1);
132 flow_record.prot = 50;
133 ret = check("esp", &flow_record, 1);
134 ret = check("ah", &flow_record, 0);
135 flow_record.prot = 51;
136 ret = check("ah", &flow_record, 1);
137 flow_record.prot = 46;
138 ret = check("rsvp", &flow_record, 1);
139 flow_record.prot = 47;
140 ret = check("gre", &flow_record, 1);
141 ret = check("proto 47", &flow_record, 1);
142 ret = check("proto 42", &flow_record, 0);
143
144 /* 172.32.7.16 => 0xac200710
145 * 10.10.10.11 => 0x0a0a0a0b
146 */
147 flow_record.srcaddr = 0xac200710;
148 flow_record.dstaddr = 0x0a0a0a0b;
149 ret = check("src ip 172.32.7.16", &flow_record, 1);
150 ret = check("src ip 172.32.7.15", &flow_record, 0);
151 ret = check("dst ip 10.10.10.11", &flow_record, 1);
152 ret = check("dst ip 10.10.10.10", &flow_record, 0);
153 ret = check("ip 172.32.7.16", &flow_record, 1);
154 ret = check("ip 10.10.10.11", &flow_record, 1);
155 ret = check("ip 172.32.7.17", &flow_record, 0);
156 ret = check("ip 10.10.10.12", &flow_record, 0);
157 ret = check("not ip 172.32.7.16", &flow_record, 0);
158 ret = check("not ip 172.32.7.17", &flow_record, 1);
159
160 ret = check("src host 172.32.7.16", &flow_record, 1);
161 ret = check("src host 172.32.7.15", &flow_record, 0);
162 ret = check("dst host 10.10.10.11", &flow_record, 1);
163 ret = check("dst host 10.10.10.10", &flow_record, 0);
164 ret = check("host 172.32.7.16", &flow_record, 1);
165 ret = check("host 10.10.10.11", &flow_record, 1);
166 ret = check("host 172.32.7.17", &flow_record, 0);
167 ret = check("host 10.10.10.12", &flow_record, 0);
168 ret = check("not host 172.32.7.16", &flow_record, 0);
169 ret = check("not host 172.32.7.17", &flow_record, 1);
170
171 flow_record.srcport = 63;
172 flow_record.dstport = 255;
173 ret = check("src port 63", &flow_record, 1);
174 ret = check("dst port 255", &flow_record, 1);
175 ret = check("port 63", &flow_record, 1);
176 ret = check("port 255", &flow_record, 1);
177 ret = check("src port 64", &flow_record, 0);
178 ret = check("dst port 258", &flow_record, 0);
179 ret = check("port 64", &flow_record, 0);
180 ret = check("port 258", &flow_record, 0);
181
182 ret = check("src port = 63", &flow_record, 1);
183 ret = check("src port == 63", &flow_record, 1);
184 ret = check("src port eq 63", &flow_record, 1);
185 ret = check("src port > 62", &flow_record, 1);
186 ret = check("src port gt 62", &flow_record, 1);
187 ret = check("src port > 63", &flow_record, 0);
188 ret = check("src port < 64", &flow_record, 1);
189 ret = check("src port lt 64", &flow_record, 1);
190 ret = check("src port < 63", &flow_record, 0);
191
192 ret = check("dst port = 255", &flow_record, 1);
193 ret = check("dst port == 255", &flow_record, 1);
194 ret = check("dst port eq 255", &flow_record, 1);
195 ret = check("dst port > 254", &flow_record, 1);
196 ret = check("dst port gt 254", &flow_record, 1);
197 ret = check("dst port > 255", &flow_record, 0);
198 ret = check("dst port < 256", &flow_record, 1);
199 ret = check("dst port lt 256", &flow_record, 1);
200 ret = check("dst port < 255", &flow_record, 0);
201
202 flow_record.src_as = 123;
203 flow_record.dst_as = 456;
204 ret = check("src as 123", &flow_record, 1);
205 ret = check("dst as 456", &flow_record, 1);
206 ret = check("as 123", &flow_record, 1);
207 ret = check("as 456", &flow_record, 1);
208 ret = check("src as 124", &flow_record, 0);
209 ret = check("dst as 457", &flow_record, 0);
210 ret = check("as 124", &flow_record, 0);
211 ret = check("as 457", &flow_record, 0);
212
213 ret = check("src net 172.32/16", &flow_record, 1);
214 ret = check("src net 172.32.7/24", &flow_record, 1);
215 ret = check("src net 172.32.7/27", &flow_record, 1);
216 ret = check("src net 172.32.7/28", &flow_record, 0);
217 ret = check("src net 172.32.7.0 255.255.255.0", &flow_record, 1);
218 ret = check("src net 172.32.7.0 255.255.255.240", &flow_record, 0);
219
220 ret = check("dst net 10.10/16", &flow_record, 1);
221 ret = check("dst net 10.10.10/24", &flow_record, 1);
222 ret = check("dst net 10.10.10/28", &flow_record, 1);
223 ret = check("dst net 10.10.10/29", &flow_record, 0);
224 ret = check("dst net 10.10.10.0 255.255.255.240", &flow_record, 1);
225 ret = check("dst net 10.10.10.0 255.255.255.248", &flow_record, 0);
226
227 ret = check("net 172.32/16", &flow_record, 1);
228 ret = check("net 172.32.7/24", &flow_record, 1);
229 ret = check("net 172.32.7/27", &flow_record, 1);
230 ret = check("net 172.32.7/28", &flow_record, 0);
231 ret = check("net 172.32.7.0 255.255.255.0", &flow_record, 1);
232 ret = check("net 172.32.7.0 255.255.255.240", &flow_record, 0);
233
234 ret = check("net 10.10/16", &flow_record, 1);
235 ret = check("net 10.10.10/24", &flow_record, 1);
236 ret = check("net 10.10.10/28", &flow_record, 1);
237 ret = check("net 10.10.10/29", &flow_record, 0);
238 ret = check("net 10.10.10.0 255.255.255.240", &flow_record, 1);
239 ret = check("net 10.10.10.0 255.255.255.240", &flow_record, 1);
240 ret = check("net 10.10.10.0 255.255.255.248", &flow_record, 0);
241
242 ret = check("src ip 172.32.7.16 or src ip 172.32.7.15", &flow_record, 1);
243 ret = check("src ip 172.32.7.15 or src ip 172.32.7.16", &flow_record, 1);
244 ret = check("src ip 172.32.7.15 or src ip 172.32.7.14", &flow_record, 0);
245 ret = check("src ip 172.32.7.16 and dst ip 10.10.10.11", &flow_record, 1);
246 ret = check("src ip 172.32.7.15 and dst ip 10.10.10.11", &flow_record, 0);
247 ret = check("src ip 172.32.7.16 and dst ip 10.10.10.12", &flow_record, 0);
248
249 flow_record.tcp_flags = 1;
250 ret = check("flags F", &flow_record, 1);
251 ret = check("flags S", &flow_record, 0);
252 ret = check("flags R", &flow_record, 0);
253 ret = check("flags P", &flow_record, 0);
254 ret = check("flags A", &flow_record, 0);
255 ret = check("flags U", &flow_record, 0);
256 ret = check("flags X", &flow_record, 0);
257
258 flow_record.tcp_flags = 2;
259 ret = check("flags S", &flow_record, 1);
260 flow_record.tcp_flags = 4;
261 ret = check("flags R", &flow_record, 1);
262 flow_record.tcp_flags = 8;
263 ret = check("flags P", &flow_record, 1);
264 flow_record.tcp_flags = 16;
265 ret = check("flags A", &flow_record, 1);
266 flow_record.tcp_flags = 32;
267 ret = check("flags U", &flow_record, 1);
268 flow_record.tcp_flags = 63;
269 ret = check("flags X", &flow_record, 1);
270
271 flow_record.tcp_flags = 3;
272 ret = check("flags SF", &flow_record, 1);
273 ret = check("flags 3", &flow_record, 1);
274 flow_record.tcp_flags = 7;
275 ret = check("flags SF", &flow_record, 1);
276 ret = check("flags R", &flow_record, 1);
277 ret = check("flags P", &flow_record, 0);
278 ret = check("flags A", &flow_record, 0);
279 ret = check("flags = 7 ", &flow_record, 1);
280 ret = check("flags > 7 ", &flow_record, 0);
281 ret = check("flags > 6 ", &flow_record, 1);
282 ret = check("flags < 7 ", &flow_record, 0);
283 ret = check("flags < 8 ", &flow_record, 1);
284
285 flow_record.tos = 5;
286 ret = check("tos 5", &flow_record, 1);
287 ret = check("tos = 5", &flow_record, 1);
288 ret = check("tos > 5", &flow_record, 0);
289 ret = check("tos < 5", &flow_record, 0);
290 ret = check("tos > 4", &flow_record, 1);
291 ret = check("tos < 6", &flow_record, 1);
292
293 ret = check("tos 10", &flow_record, 0);
294
295 flow_record.input = 5;
296 ret = check("in if 5", &flow_record, 1);
297 ret = check("in if 6", &flow_record, 0);
298 ret = check("out if 6", &flow_record, 0);
299 flow_record.output = 6;
300 ret = check("out if 6", &flow_record, 1);
301
302 /*
303 * 172.32.7.17 => 0xac200711
304 */
305 flow_record.nexthop = 0xac200711;
306 ret = check("next 172.32.7.17", &flow_record, 1);
307 ret = check("next 172.32.7.16", &flow_record, 0);
308
309 flow_record.dPkts = 1000;
310 ret = check("packets 1000", &flow_record, 1);
311 ret = check("packets = 1000", &flow_record, 1);
312 ret = check("packets 1010", &flow_record, 0);
313 ret = check("packets < 1010", &flow_record, 1);
314 ret = check("packets > 110", &flow_record, 1);
315
316 flow_record.dOctets = 2000;
317 ret = check("bytes 2000", &flow_record, 1);
318 ret = check("bytes = 2000", &flow_record, 1);
319 ret = check("bytes 2010", &flow_record, 0);
320 ret = check("bytes < 2010", &flow_record, 1);
321 ret = check("bytes > 210", &flow_record, 1);
322
323 flow_record.dOctets = 2048;
324 ret = check("bytes 2k", &flow_record, 1);
325 ret = check("bytes < 2k", &flow_record, 0);
326 ret = check("bytes > 2k", &flow_record, 0);
327 flow_record.dOctets *= 1024;
328 ret = check("bytes 2m", &flow_record, 1);
329 ret = check("bytes < 2m", &flow_record, 0);
330 ret = check("bytes > 2m", &flow_record, 0);
331 flow_record.dOctets *= 1024;
332 ret = check("bytes 2g", &flow_record, 1);
333 ret = check("bytes < 2g", &flow_record, 0);
334 ret = check("bytes > 2g", &flow_record, 0);
335
336 /*
337 * Function tests
338 */
339 flow_record.First = 1089534600; /* 2004-07-11 10:30:00 */
340 flow_record.Last = 1089534600; /* 2004-07-11 10:30:01 */
341 flow_record.msec_first = 10;
342 flow_record.msec_last = 20;
343
344 /* duration 10ms */
345 ret = check("duration == 10", &flow_record, 1);
346 ret = check("duration < 11", &flow_record, 1);
347 ret = check("duration > 9", &flow_record, 1);
348 ret = check("not duration == 10", &flow_record, 0);
349 ret = check("duration > 10", &flow_record, 0);
350 ret = check("duration < 10", &flow_record, 0);
351
352 flow_record.First = 1089534600; /* 2004-07-11 10:30:00 */
353 flow_record.Last = 1089534610; /* 2004-07-11 10:30:01 */
354 flow_record.msec_first = 0;
355 flow_record.msec_last = 0;
356
357 /* duration 10s */
358 flow_record.dPkts = 1000;
359 ret = check("duration == 10000", &flow_record, 1);
360 ret = check("duration < 10001", &flow_record, 1);
361 ret = check("duration > 9999", &flow_record, 1);
362 ret = check("not duration == 10000", &flow_record, 0);
363 ret = check("duration > 10000", &flow_record, 0);
364 ret = check("duration < 10000", &flow_record, 0);
365
366 ret = check("pps == 100", &flow_record, 1);
367 ret = check("pps < 101", &flow_record, 1);
368 ret = check("pps > 99", &flow_record, 1);
369 ret = check("not pps == 100", &flow_record, 0);
370 ret = check("pps > 100", &flow_record, 0);
371 ret = check("pps < 100", &flow_record, 0);
372
373 flow_record.dOctets = 1000;
374 ret = check("bps == 800", &flow_record, 1);
375 ret = check("bps < 801", &flow_record, 1);
376 ret = check("bps > 799", &flow_record, 1);
377 ret = check("not bps == 800", &flow_record, 0);
378 ret = check("bps > 800", &flow_record, 0);
379 ret = check("bps < 800", &flow_record, 0);
380
381 flow_record.dOctets = 20000;
382 ret = check("bps > 1k", &flow_record, 1);
383 ret = check("bps > 15k", &flow_record, 1);
384 ret = check("bps > 16k", &flow_record, 0);
385
386 ret = check("bpp == 20", &flow_record, 1);
387 ret = check("bpp < 21", &flow_record, 1);
388 ret = check("bpp > 19", &flow_record, 1);
389 ret = check("not bpp == 20", &flow_record, 0);
390 ret = check("bpp > 20", &flow_record, 0);
391 ret = check("bpp < 20", &flow_record, 0);
392
393 return failed;
394 }
0 /*
1 * Code adapted from Crypto-PAN 1.0 Code. See original disclaimer below
2 * The sourcecode has been converted from C++ to C and adapted for nfdump
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: panonymizer.c 53 2005-11-17 07:45:34Z peter $
34 *
35 * $LastChangedRevision: 53 $
36 *
37 */
38
39 /* Original disclaimer
40 * Atlanta, Georgia 30332.
41 * All Rights Reserved
42 *
43 * The following Software is posted on the Internet by the Georgia
44 * Tech Research Corporation (GTRC). It was developed by employees
45 * of the Georgia Institute of Technology in the College of Computing.
46 * GTRC hereby grants to the user a non-exclusive, royalty-free
47 * license to utilize such Software for the User's own purposes
48 * pursuant to the following conditions.
49 *
50 *
51 * THE SOFTWARE IS LICENSED ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY
52 * THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM THE SOFTWARE.
53 * GTRC SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM
54 * THE USE OF THE SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION, AND CAN
55 * IN NO WAY PROVIDE COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING
56 * BUT NOT LIMITED TO ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY
57 * FOR TORT, OF FOR ANY ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS,
58 * TRADE SECRETS, OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS
59 * EXPENSE, MACHINE DOWNTIME, OR DAMAGES CAUSED LICENSEE BY ANY DEFICIENCY,
60 * DEFECT OR ERROR IN THE SOFTWARE OR MALFUNCTION THEREOF, NOR ANY
61 * INCIDENTAL OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS
62 * ALL WARRANTIES, BOTH EXPRESS AND IMPLIED RESPECTING THE USE AND
63 * OPERATION OF THE SOFTWARE AND ANY ACCOMPANYING DOCUMENTATION,
64 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65 * PARTICULAR PURPOSE AND ANY IMPLIED WARRANTY ARISING FROM COURSE
66 * OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. GTRC MAKES NO
67 * WARRANTY THAT THE SOFTWARE IS ADEQUATELY OR COMPLETELY DESCRIBED
68 * IN, OR BEHAVES IN ACCORDANCE WITH ANY OF THE ACCOMPANYING
69 * DOCUMENTATION. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL
70 * EVALUATION OF THE SOFTWARE'S USEFULNESS IN USER'S OWN ENVIRONMENT.
71 *
72 *
73 * Package: Crypto-PAn 1.0
74 * File: panonymizer.cpp
75 * Last Update: April 17, 2002
76 * Author: Jinliang Fan
77 *
78 */
79
80 #include <stdio.h>
81 #include <sys/types.h>
82 #include <stdlib.h>
83 #include <string.h>
84
85 #include "config.h"
86
87 #ifdef HAVE_STDINT_H
88 #include <stdint.h>
89 #endif
90
91 #include "panonymizer.h"
92
93 static uint8_t m_key[16]; //128 bit secret key
94 static uint8_t m_pad[16]; //128 bit secret pad
95
96 // Init
97 void PAnonymizer_Init(uint8_t * key) {
98 //initialize the 128-bit secret key.
99 memcpy(m_key, key, 16);
100 //initialize the Rijndael cipher.
101 Rijndael_init(ECB, Encrypt, key, Key16Bytes, NULL);
102 //initialize the 128-bit secret pad. The pad is encrypted before being used for padding.
103 Rijndael_blockEncrypt(key + 16, 128, m_pad);
104 }
105
106 //Anonymization funtion
107 uint32_t anonymize(const uint32_t orig_addr) {
108 uint8_t rin_output[16];
109 uint8_t rin_input[16];
110
111 uint32_t result = 0;
112 uint32_t first4bytes_pad, first4bytes_input;
113 int pos;
114
115 memcpy(rin_input, m_pad, 16);
116 first4bytes_pad = (((uint32_t) m_pad[0]) << 24) + (((uint32_t) m_pad[1]) << 16) +
117 (((uint32_t) m_pad[2]) << 8) + (uint32_t) m_pad[3];
118
119 // For each prefixes with length from 0 to 31, generate a bit using the Rijndael cipher,
120 // which is used as a pseudorandom function here. The bits generated in every rounds
121 // are combineed into a pseudorandom one-time-pad.
122 for (pos = 0; pos <= 31 ; pos++) {
123
124 //Padding: The most significant pos bits are taken from orig_addr. The other 128-pos
125 //bits are taken from m_pad. The variables first4bytes_pad and first4bytes_input are used
126 //to handle the annoying byte order problem.
127 if (pos==0) {
128 first4bytes_input = first4bytes_pad;
129 }
130 else {
131 first4bytes_input = ((orig_addr >> (32-pos)) << (32-pos)) | ((first4bytes_pad<<pos) >> pos);
132 }
133 rin_input[0] = (uint8_t) (first4bytes_input >> 24);
134 rin_input[1] = (uint8_t) ((first4bytes_input << 8) >> 24);
135 rin_input[2] = (uint8_t) ((first4bytes_input << 16) >> 24);
136 rin_input[3] = (uint8_t) ((first4bytes_input << 24) >> 24);
137
138 //Encryption: The Rijndael cipher is used as pseudorandom function. During each
139 //round, only the first bit of rin_output is used.
140 Rijndael_blockEncrypt(rin_input, 128, rin_output);
141
142 //Combination: the bits are combined into a pseudorandom one-time-pad
143 result |= (rin_output[0] >> 7) << (31-pos);
144 }
145 //XOR the orginal address with the pseudorandom one-time-pad
146 return result ^ orig_addr;
147 }
0 /*
1 * Code adapted from Crypto-PAN 1.0 Code. See original disclaimer below
2 * The sourcecode has been converted from C++ to C and adapted for nfdump
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $Author: peter $
32 *
33 * $Id: panonymizer.h 53 2005-11-17 07:45:34Z peter $
34 *
35 * $LastChangedRevision: 53 $
36 *
37 */
38
39 /* Original disclaimer
40 * Atlanta, Georgia 30332.
41 * All Rights Reserved
42 *
43 * The following Software is posted on the Internet by the Georgia
44 * Tech Research Corporation (GTRC). It was developed by employees
45 * of the Georgia Institute of Technology in the College of Computing.
46 * GTRC hereby grants to the user a non-exclusive, royalty-free
47 * license to utilize such Software for the User's own purposes
48 * pursuant to the following conditions.
49 *
50 *
51 * THE SOFTWARE IS LICENSED ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY
52 * THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM THE SOFTWARE.
53 * GTRC SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM
54 * THE USE OF THE SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION, AND CAN
55 * IN NO WAY PROVIDE COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING
56 * BUT NOT LIMITED TO ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY
57 * FOR TORT, OF FOR ANY ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS,
58 * TRADE SECRETS, OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS
59 * EXPENSE, MACHINE DOWNTIME, OR DAMAGES CAUSED LICENSEE BY ANY DEFICIENCY,
60 * DEFECT OR ERROR IN THE SOFTWARE OR MALFUNCTION THEREOF, NOR ANY
61 * INCIDENTAL OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS
62 * ALL WARRANTIES, BOTH EXPRESS AND IMPLIED RESPECTING THE USE AND
63 * OPERATION OF THE SOFTWARE AND ANY ACCOMPANYING DOCUMENTATION,
64 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65 * PARTICULAR PURPOSE AND ANY IMPLIED WARRANTY ARISING FROM COURSE
66 * OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. GTRC MAKES NO
67 * WARRANTY THAT THE SOFTWARE IS ADEQUATELY OR COMPLETELY DESCRIBED
68 * IN, OR BEHAVES IN ACCORDANCE WITH ANY OF THE ACCOMPANYING
69 * DOCUMENTATION. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL
70 * EVALUATION OF THE SOFTWARE'S USEFULNESS IN USER'S OWN ENVIRONMENT.
71 *
72 *
73 * Package: Crypto-PAn 1.0
74 * File: panonymizer.h
75 * Last Update: April 17, 2002
76 * Author: Jinliang Fan
77 *
78 */
79
80 #ifndef _PANONYMIZER_H_
81 #define _PANONYMIZER_H_
82
83 #include "rijndael.h"
84
85 // PAnonymizer_Init need a 256-bit key
86 // The first 128 bits of the key are used as the secret key for rijndael cipher
87 // The second 128 bits of the key are used as the secret pad for padding
88 void PAnonymizer_Init(uint8_t * key);
89
90 uint32_t anonymize( const uint32_t orig_addr);
91
92 #endif //_PANONYMIZER_H_
0 /*
1 * nfprofile : Reads netflow data from files, saved by nfcapd
2 * Data can be view, filtered and saved to
3 * files.
4 *
5 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * * Neither the name of SWITCH nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $Author: peter $
33 *
34 * $Id: profile.c 17 2005-03-04 09:06:48Z peter $
35 *
36 * $LastChangedRevision: 17 $
37 *
38 */
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <sys/types.h>
43 #include <dirent.h>
44 #include <string.h>
45 #include <sys/types.h>
46 #include <sys/stat.h>
47 #include <unistd.h>
48 #include <fcntl.h>
49 #include <errno.h>
50
51 #include "config.h"
52
53 #ifdef HAVE_STDINT_H
54 #include <stdint.h>
55 #endif
56
57 #include "nfdump.h"
58 #include "util.h"
59 #include "nftree.h"
60 #include "profile.h"
61
62 static profileinfo_t *profile;
63 static unsigned int num_profiles;
64
65 static void SetupProfile(char *profiledir, char *profilename, char *subdir, char *filterfile, char *filename, int veryfy_only, int quiet );
66
67 profileinfo_t *GetProfiles(void) {
68 return profile;
69 } // End of GetProfiles
70
71 int InitProfiles(char *profiledir, char *subdir, char *filterfile, char *filename, int veryfy_only, int quiet ) {
72 DIR *PDIR;
73 struct dirent *entry;
74 struct stat stat_buf;
75 char stringbuf[1024];
76
77 profile = NULL;
78 num_profiles = 0;
79 PDIR = opendir(profiledir);
80 if ( !PDIR ) {
81 perror("Can't read profiledir: ");
82 return 0;
83 }
84
85 while ( ( entry = readdir(PDIR)) != NULL ) {
86 snprintf(stringbuf, 1023, "%s/%s", profiledir, entry->d_name);
87 if ( stat(stringbuf, &stat_buf) ) {
88 perror("Can't stat entry: ");
89 continue;
90 }
91 if ( !S_ISDIR(stat_buf.st_mode) )
92 continue;
93
94 // skip all '.' entries -> make .anything invisible to nfprofile
95 if ( entry->d_name[0] == '.' )
96 continue;
97
98 SetupProfile(profiledir, entry->d_name, subdir, filterfile, filename, veryfy_only, quiet);
99 }
100 closedir(PDIR);
101
102 return num_profiles;
103
104 } // End of InitProfiles
105
106 static void SetupProfile(char *profiledir, char *profilename, char *subdir, char *filterfile, char *filename, int veryfy_only, int quiet ) {
107 FilterEngine_data_t *engine;
108 struct stat stat_buf;
109 char *filter;
110 char stringbuf[1024];
111 int ffd, wfd, ret;
112
113 // check if subdir exists if defined
114 if ( subdir ) {
115 snprintf(stringbuf, 1023, "%s/%s/%s", profiledir, profilename, subdir);
116 if ( stat(stringbuf, &stat_buf) ) {
117 if ( !quiet )
118 fprintf(stderr, "Skipping profile '%s'\n", profilename);
119 return;
120 }
121 if ( !S_ISDIR(stat_buf.st_mode) )
122 return;
123 }
124
125
126 // Try to read filter
127 snprintf(stringbuf, 1023, "%s/%s/%s", profiledir, profilename, filterfile);
128 if ( stat(stringbuf, &stat_buf) || !S_ISREG(stat_buf.st_mode) ) {
129 if ( !quiet )
130 fprintf(stderr, "Skipping profile '%s'\n", profilename);
131 return;
132 }
133
134 // stringbuf contains filter file
135 filter = (char *)malloc(stat_buf.st_size+1);
136 if ( !filter ) {
137 perror("Memory error: ");
138 exit(255);
139 }
140 ffd = open(stringbuf, O_RDONLY);
141 if ( ffd < 0 ) {
142 fprintf(stderr, "Error opening file '%s': %s\n",stringbuf, strerror(errno) );
143 perror("Can't open file");
144 return;
145 }
146
147 ret = read(ffd, (void *)filter, stat_buf.st_size);
148 if ( ret < 0 ) {
149 perror("Error reading file");
150 close(ffd);
151 return;
152 }
153 close(ffd);
154 filter[stat_buf.st_size] = 0;
155
156 if ( !quiet )
157 printf("Setup Profile %s\n", profilename);
158 // compile profile filter
159 if ( veryfy_only && !quiet )
160 printf("Check profile '%s': ", profilename);
161
162 engine = CompileFilter(filter);
163 free(filter);
164
165 if ( !engine ) {
166 printf("\n");
167 exit(254);
168 }
169
170 if ( veryfy_only && !quiet ) {
171 printf("Done.\n");
172 return;
173 }
174
175 // prepare output file
176 if ( subdir )
177 snprintf(stringbuf, 1023, "%s/%s/%s/%s", profiledir, profilename, subdir, filename);
178 else
179 snprintf(stringbuf, 1023, "%s/%s/%s", profiledir, profilename, filename);
180
181 wfd = open(stringbuf, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
182
183 if ( wfd < 0 ) {
184 fprintf(stderr, "Error opening file '%s': %s\n",stringbuf, strerror(errno) );
185 perror("Can't open file for writing");
186 return;
187 }
188
189 // collect all profile info
190 num_profiles++;
191 profile = realloc(profile, num_profiles * sizeof(profileinfo_t) );
192 if ( !profile ) {
193 perror("Memory error: ");
194 exit(255);
195 }
196
197 memset(&profile[num_profiles-1], 0, sizeof(profileinfo_t));
198
199 profile[num_profiles-1].engine = engine;
200 profile[num_profiles-1].name = strdup(profilename);
201 profile[num_profiles-1].wfile = strdup(stringbuf);
202 profile[num_profiles-1].wfd = wfd;
203 profile[num_profiles-1].first_seen = 0xffffffff;
204 profile[num_profiles-1].last_seen = 0;
205
206 return;
207
208 } // End of InitProfiles
209
210
211 void CloseProfiles (void) {
212 char sfile[255], tmpstring[64];
213 unsigned int num;
214 int fd;
215
216 for ( num = 0; num < num_profiles; num++ ) {
217
218 close(profile[num].wfd);
219
220 snprintf(sfile, 254, "%s.stat", profile[num].wfile);
221 fd = open(sfile, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
222 if ( fd == -1 ) {
223 perror("Can't open stat file: ");
224 continue;
225 }
226
227 snprintf(tmpstring, 64, "Time: %u\n", GetStatTime());
228 write(fd, tmpstring, strlen(tmpstring));
229 snprintf(tmpstring, 64, "Ident: %s\n", GetIdent());
230 write(fd, tmpstring, strlen(tmpstring));
231 snprintf(tmpstring, 64, "Flows: %llu\n", profile[num].numflows);
232 write(fd, tmpstring, strlen(tmpstring));
233 snprintf(tmpstring, 64, "Flows_tcp: %llu\n", profile[num].numflows_tcp);
234 write(fd, tmpstring, strlen(tmpstring));
235 snprintf(tmpstring, 64, "Flows_udp: %llu\n", profile[num].numflows_udp);
236 write(fd, tmpstring, strlen(tmpstring));
237 snprintf(tmpstring, 64, "Flows_icmp: %llu\n", profile[num].numflows_icmp);
238 write(fd, tmpstring, strlen(tmpstring));
239 snprintf(tmpstring, 64, "Flows_other: %llu\n", profile[num].numflows_other);
240 write(fd, tmpstring, strlen(tmpstring));
241 snprintf(tmpstring, 64, "Packets: %llu\n", profile[num].numpackets);
242 write(fd, tmpstring, strlen(tmpstring));
243 snprintf(tmpstring, 64, "Packets_tcp: %llu\n", profile[num].numpackets_tcp);
244 write(fd, tmpstring, strlen(tmpstring));
245 snprintf(tmpstring, 64, "Packets_udp: %llu\n", profile[num].numpackets_udp);
246 write(fd, tmpstring, strlen(tmpstring));
247 snprintf(tmpstring, 64, "Packets_icmp: %llu\n", profile[num].numpackets_icmp);
248 write(fd, tmpstring, strlen(tmpstring));
249 snprintf(tmpstring, 64, "Packets_other: %llu\n", profile[num].numpackets_other);
250 write(fd, tmpstring, strlen(tmpstring));
251 snprintf(tmpstring, 64, "Bytes: %llu\n", profile[num].numbytes);
252 write(fd, tmpstring, strlen(tmpstring));
253 snprintf(tmpstring, 64, "Bytes_tcp: %llu\n", profile[num].numbytes_tcp);
254 write(fd, tmpstring, strlen(tmpstring));
255 snprintf(tmpstring, 64, "Bytes_udp: %llu\n", profile[num].numbytes_udp);
256 write(fd, tmpstring, strlen(tmpstring));
257 snprintf(tmpstring, 64, "Bytes_icmp: %llu\n", profile[num].numbytes_icmp);
258 write(fd, tmpstring, strlen(tmpstring));
259 snprintf(tmpstring, 64, "Bytes_other: %llu\n", profile[num].numbytes_other);
260 write(fd, tmpstring, strlen(tmpstring));
261 snprintf(tmpstring, 64, "First: %u\n", profile[num].first_seen);
262 write(fd, tmpstring, strlen(tmpstring));
263 snprintf(tmpstring, 64, "Last: %u\n", profile[num].last_seen);
264 write(fd, tmpstring, strlen(tmpstring));
265
266 close(fd);
267 }
268
269 } // End of CloseProfiles
270
0
1 /*
2 * nfprofile : Reads netflow data from files, saved by nfcapd
3 * Data can be view, filtered and saved to
4 * files.
5 *
6 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * * Neither the name of SWITCH nor the names of its contributors may be
18 * used to endorse or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * $Author: peter $
34 *
35 * $Id: profile.h 17 2005-03-04 09:06:48Z peter $
36 *
37 * $LastChangedRevision: 17 $
38 *
39 */
40
41 typedef struct profileinfo_s {
42 FilterEngine_data_t *engine;
43 char *name;
44 char *wfile;
45 uint64_t numflows, numbytes, numpackets;
46 uint32_t first_seen, last_seen;
47 uint64_t numflows_tcp, numflows_udp, numflows_icmp, numflows_other;
48 uint64_t numbytes_tcp, numbytes_udp, numbytes_icmp, numbytes_other;
49 uint64_t numpackets_tcp, numpackets_udp, numpackets_icmp, numpackets_other;
50 uint16_t cnt;
51 int wfd;
52 } profileinfo_t;
53
54 profileinfo_t *GetProfiles(void);
55
56 int InitProfiles(char *profiledir, char *subdir, char *filterfile, char *filename, int veryfy_only, int quiet );
57
58 void CloseProfiles (void);
0 /*
1 * Code adapted from Crypto-PAN 1.0 Code. See original disclaimer below
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Nfdump Author:$
31 *
32 * $Id: rijndael.c 53 2005-11-17 07:45:34Z peter $
33 *
34 * $LastChangedRevision: 53 $
35 *
36 */
37
38 /* Original disclaimer
39 * Atlanta, Georgia 30332.
40 * All Rights Reserved
41 *
42 * The following Software is posted on the Internet by the Georgia
43 * Tech Research Corporation (GTRC). It was developed by employees
44 * of the Georgia Institute of Technology in the College of Computing.
45 * GTRC hereby grants to the user a non-exclusive, royalty-free
46 * license to utilize such Software for the User's own purposes
47 * pursuant to the following conditions.
48 *
49 *
50 * THE SOFTWARE IS LICENSED ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY
51 * THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM THE SOFTWARE.
52 * GTRC SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM
53 * THE USE OF THE SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION, AND CAN
54 * IN NO WAY PROVIDE COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING
55 * BUT NOT LIMITED TO ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY
56 * FOR TORT, OF FOR ANY ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS,
57 * TRADE SECRETS, OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS
58 * EXPENSE, MACHINE DOWNTIME, OR DAMAGES CAUSED LICENSEE BY ANY DEFICIENCY,
59 * DEFECT OR ERROR IN THE SOFTWARE OR MALFUNCTION THEREOF, NOR ANY
60 * INCIDENTAL OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS
61 * ALL WARRANTIES, BOTH EXPRESS AND IMPLIED RESPECTING THE USE AND
62 * OPERATION OF THE SOFTWARE AND ANY ACCOMPANYING DOCUMENTATION,
63 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
64 * PARTICULAR PURPOSE AND ANY IMPLIED WARRANTY ARISING FROM COURSE
65 * OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. GTRC MAKES NO
66 * WARRANTY THAT THE SOFTWARE IS ADEQUATELY OR COMPLETELY DESCRIBED
67 * IN, OR BEHAVES IN ACCORDANCE WITH ANY OF THE ACCOMPANYING
68 * DOCUMENTATION. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL
69 * EVALUATION OF THE SOFTWARE'S USEFULNESS IN USER'S OWN ENVIRONMENT.
70 *
71 *
72 */
73
74 //
75 // File : rijndael.cpp
76 // Creation date : Sun Nov 5 2000 03:22:10 CEST
77 // Author : Szymon Stefanek (stefanek@tin.it)
78 //
79 // Another implementation of the Rijndael cipher.
80 // This is intended to be an easily usable library file.
81 // This code is public domain.
82 // Based on the Vincent Rijmen and K.U.Leuven implementation 2.4.
83 //
84
85 //
86 // Original Copyright notice:
87 //
88 // rijndael-alg-fst.c v2.4 April '2000
89 // rijndael-alg-fst.h
90 // rijndael-api-fst.c
91 // rijndael-api-fst.h
92 //
93 // Optimised ANSI C code
94 //
95 // authors: v1.0: Antoon Bosselaers
96 // v2.0: Vincent Rijmen, K.U.Leuven
97 // v2.3: Paulo Barreto
98 // v2.4: Vincent Rijmen, K.U.Leuven
99 //
100 // This code is placed in the public domain.
101 //
102
103 //
104 // This implementation works on 128 , 192 , 256 bit keys
105 // and on 128 bit blocks
106 //
107
108 #include <stdio.h>
109 #include <stdlib.h>
110 #include <sys/types.h>
111
112 #include "config.h"
113
114 #ifdef HAVE_STDINT_H
115 #include <stdint.h>
116 #endif
117
118 #include <string.h>
119
120
121 #include "rijndael.h"
122
123 static uint8_t S[256]=
124 {
125 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,
126 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192,
127 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21,
128 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117,
129 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132,
130 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207,
131 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168,
132 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210,
133 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115,
134 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219,
135 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121,
136 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8,
137 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138,
138 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158,
139 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223,
140 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22
141 };
142
143
144 static uint8_t T1[256][4]=
145 {
146 {0xc6,0x63,0x63,0xa5}, {0xf8,0x7c,0x7c,0x84}, {0xee,0x77,0x77,0x99}, {0xf6,0x7b,0x7b,0x8d},
147 {0xff,0xf2,0xf2,0x0d}, {0xd6,0x6b,0x6b,0xbd}, {0xde,0x6f,0x6f,0xb1}, {0x91,0xc5,0xc5,0x54},
148 {0x60,0x30,0x30,0x50}, {0x02,0x01,0x01,0x03}, {0xce,0x67,0x67,0xa9}, {0x56,0x2b,0x2b,0x7d},
149 {0xe7,0xfe,0xfe,0x19}, {0xb5,0xd7,0xd7,0x62}, {0x4d,0xab,0xab,0xe6}, {0xec,0x76,0x76,0x9a},
150 {0x8f,0xca,0xca,0x45}, {0x1f,0x82,0x82,0x9d}, {0x89,0xc9,0xc9,0x40}, {0xfa,0x7d,0x7d,0x87},
151 {0xef,0xfa,0xfa,0x15}, {0xb2,0x59,0x59,0xeb}, {0x8e,0x47,0x47,0xc9}, {0xfb,0xf0,0xf0,0x0b},
152 {0x41,0xad,0xad,0xec}, {0xb3,0xd4,0xd4,0x67}, {0x5f,0xa2,0xa2,0xfd}, {0x45,0xaf,0xaf,0xea},
153 {0x23,0x9c,0x9c,0xbf}, {0x53,0xa4,0xa4,0xf7}, {0xe4,0x72,0x72,0x96}, {0x9b,0xc0,0xc0,0x5b},
154 {0x75,0xb7,0xb7,0xc2}, {0xe1,0xfd,0xfd,0x1c}, {0x3d,0x93,0x93,0xae}, {0x4c,0x26,0x26,0x6a},
155 {0x6c,0x36,0x36,0x5a}, {0x7e,0x3f,0x3f,0x41}, {0xf5,0xf7,0xf7,0x02}, {0x83,0xcc,0xcc,0x4f},
156 {0x68,0x34,0x34,0x5c}, {0x51,0xa5,0xa5,0xf4}, {0xd1,0xe5,0xe5,0x34}, {0xf9,0xf1,0xf1,0x08},
157 {0xe2,0x71,0x71,0x93}, {0xab,0xd8,0xd8,0x73}, {0x62,0x31,0x31,0x53}, {0x2a,0x15,0x15,0x3f},
158 {0x08,0x04,0x04,0x0c}, {0x95,0xc7,0xc7,0x52}, {0x46,0x23,0x23,0x65}, {0x9d,0xc3,0xc3,0x5e},
159 {0x30,0x18,0x18,0x28}, {0x37,0x96,0x96,0xa1}, {0x0a,0x05,0x05,0x0f}, {0x2f,0x9a,0x9a,0xb5},
160 {0x0e,0x07,0x07,0x09}, {0x24,0x12,0x12,0x36}, {0x1b,0x80,0x80,0x9b}, {0xdf,0xe2,0xe2,0x3d},
161 {0xcd,0xeb,0xeb,0x26}, {0x4e,0x27,0x27,0x69}, {0x7f,0xb2,0xb2,0xcd}, {0xea,0x75,0x75,0x9f},
162 {0x12,0x09,0x09,0x1b}, {0x1d,0x83,0x83,0x9e}, {0x58,0x2c,0x2c,0x74}, {0x34,0x1a,0x1a,0x2e},
163 {0x36,0x1b,0x1b,0x2d}, {0xdc,0x6e,0x6e,0xb2}, {0xb4,0x5a,0x5a,0xee}, {0x5b,0xa0,0xa0,0xfb},
164 {0xa4,0x52,0x52,0xf6}, {0x76,0x3b,0x3b,0x4d}, {0xb7,0xd6,0xd6,0x61}, {0x7d,0xb3,0xb3,0xce},
165 {0x52,0x29,0x29,0x7b}, {0xdd,0xe3,0xe3,0x3e}, {0x5e,0x2f,0x2f,0x71}, {0x13,0x84,0x84,0x97},
166 {0xa6,0x53,0x53,0xf5}, {0xb9,0xd1,0xd1,0x68}, {0x00,0x00,0x00,0x00}, {0xc1,0xed,0xed,0x2c},
167 {0x40,0x20,0x20,0x60}, {0xe3,0xfc,0xfc,0x1f}, {0x79,0xb1,0xb1,0xc8}, {0xb6,0x5b,0x5b,0xed},
168 {0xd4,0x6a,0x6a,0xbe}, {0x8d,0xcb,0xcb,0x46}, {0x67,0xbe,0xbe,0xd9}, {0x72,0x39,0x39,0x4b},
169 {0x94,0x4a,0x4a,0xde}, {0x98,0x4c,0x4c,0xd4}, {0xb0,0x58,0x58,0xe8}, {0x85,0xcf,0xcf,0x4a},
170 {0xbb,0xd0,0xd0,0x6b}, {0xc5,0xef,0xef,0x2a}, {0x4f,0xaa,0xaa,0xe5}, {0xed,0xfb,0xfb,0x16},
171 {0x86,0x43,0x43,0xc5}, {0x9a,0x4d,0x4d,0xd7}, {0x66,0x33,0x33,0x55}, {0x11,0x85,0x85,0x94},
172 {0x8a,0x45,0x45,0xcf}, {0xe9,0xf9,0xf9,0x10}, {0x04,0x02,0x02,0x06}, {0xfe,0x7f,0x7f,0x81},
173 {0xa0,0x50,0x50,0xf0}, {0x78,0x3c,0x3c,0x44}, {0x25,0x9f,0x9f,0xba}, {0x4b,0xa8,0xa8,0xe3},
174 {0xa2,0x51,0x51,0xf3}, {0x5d,0xa3,0xa3,0xfe}, {0x80,0x40,0x40,0xc0}, {0x05,0x8f,0x8f,0x8a},
175 {0x3f,0x92,0x92,0xad}, {0x21,0x9d,0x9d,0xbc}, {0x70,0x38,0x38,0x48}, {0xf1,0xf5,0xf5,0x04},
176 {0x63,0xbc,0xbc,0xdf}, {0x77,0xb6,0xb6,0xc1}, {0xaf,0xda,0xda,0x75}, {0x42,0x21,0x21,0x63},
177 {0x20,0x10,0x10,0x30}, {0xe5,0xff,0xff,0x1a}, {0xfd,0xf3,0xf3,0x0e}, {0xbf,0xd2,0xd2,0x6d},
178 {0x81,0xcd,0xcd,0x4c}, {0x18,0x0c,0x0c,0x14}, {0x26,0x13,0x13,0x35}, {0xc3,0xec,0xec,0x2f},
179 {0xbe,0x5f,0x5f,0xe1}, {0x35,0x97,0x97,0xa2}, {0x88,0x44,0x44,0xcc}, {0x2e,0x17,0x17,0x39},
180 {0x93,0xc4,0xc4,0x57}, {0x55,0xa7,0xa7,0xf2}, {0xfc,0x7e,0x7e,0x82}, {0x7a,0x3d,0x3d,0x47},
181 {0xc8,0x64,0x64,0xac}, {0xba,0x5d,0x5d,0xe7}, {0x32,0x19,0x19,0x2b}, {0xe6,0x73,0x73,0x95},
182 {0xc0,0x60,0x60,0xa0}, {0x19,0x81,0x81,0x98}, {0x9e,0x4f,0x4f,0xd1}, {0xa3,0xdc,0xdc,0x7f},
183 {0x44,0x22,0x22,0x66}, {0x54,0x2a,0x2a,0x7e}, {0x3b,0x90,0x90,0xab}, {0x0b,0x88,0x88,0x83},
184 {0x8c,0x46,0x46,0xca}, {0xc7,0xee,0xee,0x29}, {0x6b,0xb8,0xb8,0xd3}, {0x28,0x14,0x14,0x3c},
185 {0xa7,0xde,0xde,0x79}, {0xbc,0x5e,0x5e,0xe2}, {0x16,0x0b,0x0b,0x1d}, {0xad,0xdb,0xdb,0x76},
186 {0xdb,0xe0,0xe0,0x3b}, {0x64,0x32,0x32,0x56}, {0x74,0x3a,0x3a,0x4e}, {0x14,0x0a,0x0a,0x1e},
187 {0x92,0x49,0x49,0xdb}, {0x0c,0x06,0x06,0x0a}, {0x48,0x24,0x24,0x6c}, {0xb8,0x5c,0x5c,0xe4},
188 {0x9f,0xc2,0xc2,0x5d}, {0xbd,0xd3,0xd3,0x6e}, {0x43,0xac,0xac,0xef}, {0xc4,0x62,0x62,0xa6},
189 {0x39,0x91,0x91,0xa8}, {0x31,0x95,0x95,0xa4}, {0xd3,0xe4,0xe4,0x37}, {0xf2,0x79,0x79,0x8b},
190 {0xd5,0xe7,0xe7,0x32}, {0x8b,0xc8,0xc8,0x43}, {0x6e,0x37,0x37,0x59}, {0xda,0x6d,0x6d,0xb7},
191 {0x01,0x8d,0x8d,0x8c}, {0xb1,0xd5,0xd5,0x64}, {0x9c,0x4e,0x4e,0xd2}, {0x49,0xa9,0xa9,0xe0},
192 {0xd8,0x6c,0x6c,0xb4}, {0xac,0x56,0x56,0xfa}, {0xf3,0xf4,0xf4,0x07}, {0xcf,0xea,0xea,0x25},
193 {0xca,0x65,0x65,0xaf}, {0xf4,0x7a,0x7a,0x8e}, {0x47,0xae,0xae,0xe9}, {0x10,0x08,0x08,0x18},
194 {0x6f,0xba,0xba,0xd5}, {0xf0,0x78,0x78,0x88}, {0x4a,0x25,0x25,0x6f}, {0x5c,0x2e,0x2e,0x72},
195 {0x38,0x1c,0x1c,0x24}, {0x57,0xa6,0xa6,0xf1}, {0x73,0xb4,0xb4,0xc7}, {0x97,0xc6,0xc6,0x51},
196 {0xcb,0xe8,0xe8,0x23}, {0xa1,0xdd,0xdd,0x7c}, {0xe8,0x74,0x74,0x9c}, {0x3e,0x1f,0x1f,0x21},
197 {0x96,0x4b,0x4b,0xdd}, {0x61,0xbd,0xbd,0xdc}, {0x0d,0x8b,0x8b,0x86}, {0x0f,0x8a,0x8a,0x85},
198 {0xe0,0x70,0x70,0x90}, {0x7c,0x3e,0x3e,0x42}, {0x71,0xb5,0xb5,0xc4}, {0xcc,0x66,0x66,0xaa},
199 {0x90,0x48,0x48,0xd8}, {0x06,0x03,0x03,0x05}, {0xf7,0xf6,0xf6,0x01}, {0x1c,0x0e,0x0e,0x12},
200 {0xc2,0x61,0x61,0xa3}, {0x6a,0x35,0x35,0x5f}, {0xae,0x57,0x57,0xf9}, {0x69,0xb9,0xb9,0xd0},
201 {0x17,0x86,0x86,0x91}, {0x99,0xc1,0xc1,0x58}, {0x3a,0x1d,0x1d,0x27}, {0x27,0x9e,0x9e,0xb9},
202 {0xd9,0xe1,0xe1,0x38}, {0xeb,0xf8,0xf8,0x13}, {0x2b,0x98,0x98,0xb3}, {0x22,0x11,0x11,0x33},
203 {0xd2,0x69,0x69,0xbb}, {0xa9,0xd9,0xd9,0x70}, {0x07,0x8e,0x8e,0x89}, {0x33,0x94,0x94,0xa7},
204 {0x2d,0x9b,0x9b,0xb6}, {0x3c,0x1e,0x1e,0x22}, {0x15,0x87,0x87,0x92}, {0xc9,0xe9,0xe9,0x20},
205 {0x87,0xce,0xce,0x49}, {0xaa,0x55,0x55,0xff}, {0x50,0x28,0x28,0x78}, {0xa5,0xdf,0xdf,0x7a},
206 {0x03,0x8c,0x8c,0x8f}, {0x59,0xa1,0xa1,0xf8}, {0x09,0x89,0x89,0x80}, {0x1a,0x0d,0x0d,0x17},
207 {0x65,0xbf,0xbf,0xda}, {0xd7,0xe6,0xe6,0x31}, {0x84,0x42,0x42,0xc6}, {0xd0,0x68,0x68,0xb8},
208 {0x82,0x41,0x41,0xc3}, {0x29,0x99,0x99,0xb0}, {0x5a,0x2d,0x2d,0x77}, {0x1e,0x0f,0x0f,0x11},
209 {0x7b,0xb0,0xb0,0xcb}, {0xa8,0x54,0x54,0xfc}, {0x6d,0xbb,0xbb,0xd6}, {0x2c,0x16,0x16,0x3a}
210 };
211
212 static uint8_t T2[256][4]=
213 {
214 {0xa5,0xc6,0x63,0x63}, {0x84,0xf8,0x7c,0x7c}, {0x99,0xee,0x77,0x77}, {0x8d,0xf6,0x7b,0x7b},
215 {0x0d,0xff,0xf2,0xf2}, {0xbd,0xd6,0x6b,0x6b}, {0xb1,0xde,0x6f,0x6f}, {0x54,0x91,0xc5,0xc5},
216 {0x50,0x60,0x30,0x30}, {0x03,0x02,0x01,0x01}, {0xa9,0xce,0x67,0x67}, {0x7d,0x56,0x2b,0x2b},
217 {0x19,0xe7,0xfe,0xfe}, {0x62,0xb5,0xd7,0xd7}, {0xe6,0x4d,0xab,0xab}, {0x9a,0xec,0x76,0x76},
218 {0x45,0x8f,0xca,0xca}, {0x9d,0x1f,0x82,0x82}, {0x40,0x89,0xc9,0xc9}, {0x87,0xfa,0x7d,0x7d},
219 {0x15,0xef,0xfa,0xfa}, {0xeb,0xb2,0x59,0x59}, {0xc9,0x8e,0x47,0x47}, {0x0b,0xfb,0xf0,0xf0},
220 {0xec,0x41,0xad,0xad}, {0x67,0xb3,0xd4,0xd4}, {0xfd,0x5f,0xa2,0xa2}, {0xea,0x45,0xaf,0xaf},
221 {0xbf,0x23,0x9c,0x9c}, {0xf7,0x53,0xa4,0xa4}, {0x96,0xe4,0x72,0x72}, {0x5b,0x9b,0xc0,0xc0},
222 {0xc2,0x75,0xb7,0xb7}, {0x1c,0xe1,0xfd,0xfd}, {0xae,0x3d,0x93,0x93}, {0x6a,0x4c,0x26,0x26},
223 {0x5a,0x6c,0x36,0x36}, {0x41,0x7e,0x3f,0x3f}, {0x02,0xf5,0xf7,0xf7}, {0x4f,0x83,0xcc,0xcc},
224 {0x5c,0x68,0x34,0x34}, {0xf4,0x51,0xa5,0xa5}, {0x34,0xd1,0xe5,0xe5}, {0x08,0xf9,0xf1,0xf1},
225 {0x93,0xe2,0x71,0x71}, {0x73,0xab,0xd8,0xd8}, {0x53,0x62,0x31,0x31}, {0x3f,0x2a,0x15,0x15},
226 {0x0c,0x08,0x04,0x04}, {0x52,0x95,0xc7,0xc7}, {0x65,0x46,0x23,0x23}, {0x5e,0x9d,0xc3,0xc3},
227 {0x28,0x30,0x18,0x18}, {0xa1,0x37,0x96,0x96}, {0x0f,0x0a,0x05,0x05}, {0xb5,0x2f,0x9a,0x9a},
228 {0x09,0x0e,0x07,0x07}, {0x36,0x24,0x12,0x12}, {0x9b,0x1b,0x80,0x80}, {0x3d,0xdf,0xe2,0xe2},
229 {0x26,0xcd,0xeb,0xeb}, {0x69,0x4e,0x27,0x27}, {0xcd,0x7f,0xb2,0xb2}, {0x9f,0xea,0x75,0x75},
230 {0x1b,0x12,0x09,0x09}, {0x9e,0x1d,0x83,0x83}, {0x74,0x58,0x2c,0x2c}, {0x2e,0x34,0x1a,0x1a},
231 {0x2d,0x36,0x1b,0x1b}, {0xb2,0xdc,0x6e,0x6e}, {0xee,0xb4,0x5a,0x5a}, {0xfb,0x5b,0xa0,0xa0},
232 {0xf6,0xa4,0x52,0x52}, {0x4d,0x76,0x3b,0x3b}, {0x61,0xb7,0xd6,0xd6}, {0xce,0x7d,0xb3,0xb3},
233 {0x7b,0x52,0x29,0x29}, {0x3e,0xdd,0xe3,0xe3}, {0x71,0x5e,0x2f,0x2f}, {0x97,0x13,0x84,0x84},
234 {0xf5,0xa6,0x53,0x53}, {0x68,0xb9,0xd1,0xd1}, {0x00,0x00,0x00,0x00}, {0x2c,0xc1,0xed,0xed},
235 {0x60,0x40,0x20,0x20}, {0x1f,0xe3,0xfc,0xfc}, {0xc8,0x79,0xb1,0xb1}, {0xed,0xb6,0x5b,0x5b},
236 {0xbe,0xd4,0x6a,0x6a}, {0x46,0x8d,0xcb,0xcb}, {0xd9,0x67,0xbe,0xbe}, {0x4b,0x72,0x39,0x39},
237 {0xde,0x94,0x4a,0x4a}, {0xd4,0x98,0x4c,0x4c}, {0xe8,0xb0,0x58,0x58}, {0x4a,0x85,0xcf,0xcf},
238 {0x6b,0xbb,0xd0,0xd0}, {0x2a,0xc5,0xef,0xef}, {0xe5,0x4f,0xaa,0xaa}, {0x16,0xed,0xfb,0xfb},
239 {0xc5,0x86,0x43,0x43}, {0xd7,0x9a,0x4d,0x4d}, {0x55,0x66,0x33,0x33}, {0x94,0x11,0x85,0x85},
240 {0xcf,0x8a,0x45,0x45}, {0x10,0xe9,0xf9,0xf9}, {0x06,0x04,0x02,0x02}, {0x81,0xfe,0x7f,0x7f},
241 {0xf0,0xa0,0x50,0x50}, {0x44,0x78,0x3c,0x3c}, {0xba,0x25,0x9f,0x9f}, {0xe3,0x4b,0xa8,0xa8},
242 {0xf3,0xa2,0x51,0x51}, {0xfe,0x5d,0xa3,0xa3}, {0xc0,0x80,0x40,0x40}, {0x8a,0x05,0x8f,0x8f},
243 {0xad,0x3f,0x92,0x92}, {0xbc,0x21,0x9d,0x9d}, {0x48,0x70,0x38,0x38}, {0x04,0xf1,0xf5,0xf5},
244 {0xdf,0x63,0xbc,0xbc}, {0xc1,0x77,0xb6,0xb6}, {0x75,0xaf,0xda,0xda}, {0x63,0x42,0x21,0x21},
245 {0x30,0x20,0x10,0x10}, {0x1a,0xe5,0xff,0xff}, {0x0e,0xfd,0xf3,0xf3}, {0x6d,0xbf,0xd2,0xd2},
246 {0x4c,0x81,0xcd,0xcd}, {0x14,0x18,0x0c,0x0c}, {0x35,0x26,0x13,0x13}, {0x2f,0xc3,0xec,0xec},
247 {0xe1,0xbe,0x5f,0x5f}, {0xa2,0x35,0x97,0x97}, {0xcc,0x88,0x44,0x44}, {0x39,0x2e,0x17,0x17},
248 {0x57,0x93,0xc4,0xc4}, {0xf2,0x55,0xa7,0xa7}, {0x82,0xfc,0x7e,0x7e}, {0x47,0x7a,0x3d,0x3d},
249 {0xac,0xc8,0x64,0x64}, {0xe7,0xba,0x5d,0x5d}, {0x2b,0x32,0x19,0x19}, {0x95,0xe6,0x73,0x73},
250 {0xa0,0xc0,0x60,0x60}, {0x98,0x19,0x81,0x81}, {0xd1,0x9e,0x4f,0x4f}, {0x7f,0xa3,0xdc,0xdc},
251 {0x66,0x44,0x22,0x22}, {0x7e,0x54,0x2a,0x2a}, {0xab,0x3b,0x90,0x90}, {0x83,0x0b,0x88,0x88},
252 {0xca,0x8c,0x46,0x46}, {0x29,0xc7,0xee,0xee}, {0xd3,0x6b,0xb8,0xb8}, {0x3c,0x28,0x14,0x14},
253 {0x79,0xa7,0xde,0xde}, {0xe2,0xbc,0x5e,0x5e}, {0x1d,0x16,0x0b,0x0b}, {0x76,0xad,0xdb,0xdb},
254 {0x3b,0xdb,0xe0,0xe0}, {0x56,0x64,0x32,0x32}, {0x4e,0x74,0x3a,0x3a}, {0x1e,0x14,0x0a,0x0a},
255 {0xdb,0x92,0x49,0x49}, {0x0a,0x0c,0x06,0x06}, {0x6c,0x48,0x24,0x24}, {0xe4,0xb8,0x5c,0x5c},
256 {0x5d,0x9f,0xc2,0xc2}, {0x6e,0xbd,0xd3,0xd3}, {0xef,0x43,0xac,0xac}, {0xa6,0xc4,0x62,0x62},
257 {0xa8,0x39,0x91,0x91}, {0xa4,0x31,0x95,0x95}, {0x37,0xd3,0xe4,0xe4}, {0x8b,0xf2,0x79,0x79},
258 {0x32,0xd5,0xe7,0xe7}, {0x43,0x8b,0xc8,0xc8}, {0x59,0x6e,0x37,0x37}, {0xb7,0xda,0x6d,0x6d},
259 {0x8c,0x01,0x8d,0x8d}, {0x64,0xb1,0xd5,0xd5}, {0xd2,0x9c,0x4e,0x4e}, {0xe0,0x49,0xa9,0xa9},
260 {0xb4,0xd8,0x6c,0x6c}, {0xfa,0xac,0x56,0x56}, {0x07,0xf3,0xf4,0xf4}, {0x25,0xcf,0xea,0xea},
261 {0xaf,0xca,0x65,0x65}, {0x8e,0xf4,0x7a,0x7a}, {0xe9,0x47,0xae,0xae}, {0x18,0x10,0x08,0x08},
262 {0xd5,0x6f,0xba,0xba}, {0x88,0xf0,0x78,0x78}, {0x6f,0x4a,0x25,0x25}, {0x72,0x5c,0x2e,0x2e},
263 {0x24,0x38,0x1c,0x1c}, {0xf1,0x57,0xa6,0xa6}, {0xc7,0x73,0xb4,0xb4}, {0x51,0x97,0xc6,0xc6},
264 {0x23,0xcb,0xe8,0xe8}, {0x7c,0xa1,0xdd,0xdd}, {0x9c,0xe8,0x74,0x74}, {0x21,0x3e,0x1f,0x1f},
265 {0xdd,0x96,0x4b,0x4b}, {0xdc,0x61,0xbd,0xbd}, {0x86,0x0d,0x8b,0x8b}, {0x85,0x0f,0x8a,0x8a},
266 {0x90,0xe0,0x70,0x70}, {0x42,0x7c,0x3e,0x3e}, {0xc4,0x71,0xb5,0xb5}, {0xaa,0xcc,0x66,0x66},
267 {0xd8,0x90,0x48,0x48}, {0x05,0x06,0x03,0x03}, {0x01,0xf7,0xf6,0xf6}, {0x12,0x1c,0x0e,0x0e},
268 {0xa3,0xc2,0x61,0x61}, {0x5f,0x6a,0x35,0x35}, {0xf9,0xae,0x57,0x57}, {0xd0,0x69,0xb9,0xb9},
269 {0x91,0x17,0x86,0x86}, {0x58,0x99,0xc1,0xc1}, {0x27,0x3a,0x1d,0x1d}, {0xb9,0x27,0x9e,0x9e},
270 {0x38,0xd9,0xe1,0xe1}, {0x13,0xeb,0xf8,0xf8}, {0xb3,0x2b,0x98,0x98}, {0x33,0x22,0x11,0x11},
271 {0xbb,0xd2,0x69,0x69}, {0x70,0xa9,0xd9,0xd9}, {0x89,0x07,0x8e,0x8e}, {0xa7,0x33,0x94,0x94},
272 {0xb6,0x2d,0x9b,0x9b}, {0x22,0x3c,0x1e,0x1e}, {0x92,0x15,0x87,0x87}, {0x20,0xc9,0xe9,0xe9},
273 {0x49,0x87,0xce,0xce}, {0xff,0xaa,0x55,0x55}, {0x78,0x50,0x28,0x28}, {0x7a,0xa5,0xdf,0xdf},
274 {0x8f,0x03,0x8c,0x8c}, {0xf8,0x59,0xa1,0xa1}, {0x80,0x09,0x89,0x89}, {0x17,0x1a,0x0d,0x0d},
275 {0xda,0x65,0xbf,0xbf}, {0x31,0xd7,0xe6,0xe6}, {0xc6,0x84,0x42,0x42}, {0xb8,0xd0,0x68,0x68},
276 {0xc3,0x82,0x41,0x41}, {0xb0,0x29,0x99,0x99}, {0x77,0x5a,0x2d,0x2d}, {0x11,0x1e,0x0f,0x0f},
277 {0xcb,0x7b,0xb0,0xb0}, {0xfc,0xa8,0x54,0x54}, {0xd6,0x6d,0xbb,0xbb}, {0x3a,0x2c,0x16,0x16}
278 };
279
280 static uint8_t T3[256][4]=
281 {
282 {0x63,0xa5,0xc6,0x63}, {0x7c,0x84,0xf8,0x7c}, {0x77,0x99,0xee,0x77}, {0x7b,0x8d,0xf6,0x7b},
283 {0xf2,0x0d,0xff,0xf2}, {0x6b,0xbd,0xd6,0x6b}, {0x6f,0xb1,0xde,0x6f}, {0xc5,0x54,0x91,0xc5},
284 {0x30,0x50,0x60,0x30}, {0x01,0x03,0x02,0x01}, {0x67,0xa9,0xce,0x67}, {0x2b,0x7d,0x56,0x2b},
285 {0xfe,0x19,0xe7,0xfe}, {0xd7,0x62,0xb5,0xd7}, {0xab,0xe6,0x4d,0xab}, {0x76,0x9a,0xec,0x76},
286 {0xca,0x45,0x8f,0xca}, {0x82,0x9d,0x1f,0x82}, {0xc9,0x40,0x89,0xc9}, {0x7d,0x87,0xfa,0x7d},
287 {0xfa,0x15,0xef,0xfa}, {0x59,0xeb,0xb2,0x59}, {0x47,0xc9,0x8e,0x47}, {0xf0,0x0b,0xfb,0xf0},
288 {0xad,0xec,0x41,0xad}, {0xd4,0x67,0xb3,0xd4}, {0xa2,0xfd,0x5f,0xa2}, {0xaf,0xea,0x45,0xaf},
289 {0x9c,0xbf,0x23,0x9c}, {0xa4,0xf7,0x53,0xa4}, {0x72,0x96,0xe4,0x72}, {0xc0,0x5b,0x9b,0xc0},
290 {0xb7,0xc2,0x75,0xb7}, {0xfd,0x1c,0xe1,0xfd}, {0x93,0xae,0x3d,0x93}, {0x26,0x6a,0x4c,0x26},
291 {0x36,0x5a,0x6c,0x36}, {0x3f,0x41,0x7e,0x3f}, {0xf7,0x02,0xf5,0xf7}, {0xcc,0x4f,0x83,0xcc},
292 {0x34,0x5c,0x68,0x34}, {0xa5,0xf4,0x51,0xa5}, {0xe5,0x34,0xd1,0xe5}, {0xf1,0x08,0xf9,0xf1},
293 {0x71,0x93,0xe2,0x71}, {0xd8,0x73,0xab,0xd8}, {0x31,0x53,0x62,0x31}, {0x15,0x3f,0x2a,0x15},
294 {0x04,0x0c,0x08,0x04}, {0xc7,0x52,0x95,0xc7}, {0x23,0x65,0x46,0x23}, {0xc3,0x5e,0x9d,0xc3},
295 {0x18,0x28,0x30,0x18}, {0x96,0xa1,0x37,0x96}, {0x05,0x0f,0x0a,0x05}, {0x9a,0xb5,0x2f,0x9a},
296 {0x07,0x09,0x0e,0x07}, {0x12,0x36,0x24,0x12}, {0x80,0x9b,0x1b,0x80}, {0xe2,0x3d,0xdf,0xe2},
297 {0xeb,0x26,0xcd,0xeb}, {0x27,0x69,0x4e,0x27}, {0xb2,0xcd,0x7f,0xb2}, {0x75,0x9f,0xea,0x75},
298 {0x09,0x1b,0x12,0x09}, {0x83,0x9e,0x1d,0x83}, {0x2c,0x74,0x58,0x2c}, {0x1a,0x2e,0x34,0x1a},
299 {0x1b,0x2d,0x36,0x1b}, {0x6e,0xb2,0xdc,0x6e}, {0x5a,0xee,0xb4,0x5a}, {0xa0,0xfb,0x5b,0xa0},
300 {0x52,0xf6,0xa4,0x52}, {0x3b,0x4d,0x76,0x3b}, {0xd6,0x61,0xb7,0xd6}, {0xb3,0xce,0x7d,0xb3},
301 {0x29,0x7b,0x52,0x29}, {0xe3,0x3e,0xdd,0xe3}, {0x2f,0x71,0x5e,0x2f}, {0x84,0x97,0x13,0x84},
302 {0x53,0xf5,0xa6,0x53}, {0xd1,0x68,0xb9,0xd1}, {0x00,0x00,0x00,0x00}, {0xed,0x2c,0xc1,0xed},
303 {0x20,0x60,0x40,0x20}, {0xfc,0x1f,0xe3,0xfc}, {0xb1,0xc8,0x79,0xb1}, {0x5b,0xed,0xb6,0x5b},
304 {0x6a,0xbe,0xd4,0x6a}, {0xcb,0x46,0x8d,0xcb}, {0xbe,0xd9,0x67,0xbe}, {0x39,0x4b,0x72,0x39},
305 {0x4a,0xde,0x94,0x4a}, {0x4c,0xd4,0x98,0x4c}, {0x58,0xe8,0xb0,0x58}, {0xcf,0x4a,0x85,0xcf},
306 {0xd0,0x6b,0xbb,0xd0}, {0xef,0x2a,0xc5,0xef}, {0xaa,0xe5,0x4f,0xaa}, {0xfb,0x16,0xed,0xfb},
307 {0x43,0xc5,0x86,0x43}, {0x4d,0xd7,0x9a,0x4d}, {0x33,0x55,0x66,0x33}, {0x85,0x94,0x11,0x85},
308 {0x45,0xcf,0x8a,0x45}, {0xf9,0x10,0xe9,0xf9}, {0x02,0x06,0x04,0x02}, {0x7f,0x81,0xfe,0x7f},
309 {0x50,0xf0,0xa0,0x50}, {0x3c,0x44,0x78,0x3c}, {0x9f,0xba,0x25,0x9f}, {0xa8,0xe3,0x4b,0xa8},
310 {0x51,0xf3,0xa2,0x51}, {0xa3,0xfe,0x5d,0xa3}, {0x40,0xc0,0x80,0x40}, {0x8f,0x8a,0x05,0x8f},
311 {0x92,0xad,0x3f,0x92}, {0x9d,0xbc,0x21,0x9d}, {0x38,0x48,0x70,0x38}, {0xf5,0x04,0xf1,0xf5},
312 {0xbc,0xdf,0x63,0xbc}, {0xb6,0xc1,0x77,0xb6}, {0xda,0x75,0xaf,0xda}, {0x21,0x63,0x42,0x21},
313 {0x10,0x30,0x20,0x10}, {0xff,0x1a,0xe5,0xff}, {0xf3,0x0e,0xfd,0xf3}, {0xd2,0x6d,0xbf,0xd2},
314 {0xcd,0x4c,0x81,0xcd}, {0x0c,0x14,0x18,0x0c}, {0x13,0x35,0x26,0x13}, {0xec,0x2f,0xc3,0xec},
315 {0x5f,0xe1,0xbe,0x5f}, {0x97,0xa2,0x35,0x97}, {0x44,0xcc,0x88,0x44}, {0x17,0x39,0x2e,0x17},
316 {0xc4,0x57,0x93,0xc4}, {0xa7,0xf2,0x55,0xa7}, {0x7e,0x82,0xfc,0x7e}, {0x3d,0x47,0x7a,0x3d},
317 {0x64,0xac,0xc8,0x64}, {0x5d,0xe7,0xba,0x5d}, {0x19,0x2b,0x32,0x19}, {0x73,0x95,0xe6,0x73},
318 {0x60,0xa0,0xc0,0x60}, {0x81,0x98,0x19,0x81}, {0x4f,0xd1,0x9e,0x4f}, {0xdc,0x7f,0xa3,0xdc},
319 {0x22,0x66,0x44,0x22}, {0x2a,0x7e,0x54,0x2a}, {0x90,0xab,0x3b,0x90}, {0x88,0x83,0x0b,0x88},
320 {0x46,0xca,0x8c,0x46}, {0xee,0x29,0xc7,0xee}, {0xb8,0xd3,0x6b,0xb8}, {0x14,0x3c,0x28,0x14},
321 {0xde,0x79,0xa7,0xde}, {0x5e,0xe2,0xbc,0x5e}, {0x0b,0x1d,0x16,0x0b}, {0xdb,0x76,0xad,0xdb},
322 {0xe0,0x3b,0xdb,0xe0}, {0x32,0x56,0x64,0x32}, {0x3a,0x4e,0x74,0x3a}, {0x0a,0x1e,0x14,0x0a},
323 {0x49,0xdb,0x92,0x49}, {0x06,0x0a,0x0c,0x06}, {0x24,0x6c,0x48,0x24}, {0x5c,0xe4,0xb8,0x5c},
324 {0xc2,0x5d,0x9f,0xc2}, {0xd3,0x6e,0xbd,0xd3}, {0xac,0xef,0x43,0xac}, {0x62,0xa6,0xc4,0x62},
325 {0x91,0xa8,0x39,0x91}, {0x95,0xa4,0x31,0x95}, {0xe4,0x37,0xd3,0xe4}, {0x79,0x8b,0xf2,0x79},
326 {0xe7,0x32,0xd5,0xe7}, {0xc8,0x43,0x8b,0xc8}, {0x37,0x59,0x6e,0x37}, {0x6d,0xb7,0xda,0x6d},
327 {0x8d,0x8c,0x01,0x8d}, {0xd5,0x64,0xb1,0xd5}, {0x4e,0xd2,0x9c,0x4e}, {0xa9,0xe0,0x49,0xa9},
328 {0x6c,0xb4,0xd8,0x6c}, {0x56,0xfa,0xac,0x56}, {0xf4,0x07,0xf3,0xf4}, {0xea,0x25,0xcf,0xea},
329 {0x65,0xaf,0xca,0x65}, {0x7a,0x8e,0xf4,0x7a}, {0xae,0xe9,0x47,0xae}, {0x08,0x18,0x10,0x08},
330 {0xba,0xd5,0x6f,0xba}, {0x78,0x88,0xf0,0x78}, {0x25,0x6f,0x4a,0x25}, {0x2e,0x72,0x5c,0x2e},
331 {0x1c,0x24,0x38,0x1c}, {0xa6,0xf1,0x57,0xa6}, {0xb4,0xc7,0x73,0xb4}, {0xc6,0x51,0x97,0xc6},
332 {0xe8,0x23,0xcb,0xe8}, {0xdd,0x7c,0xa1,0xdd}, {0x74,0x9c,0xe8,0x74}, {0x1f,0x21,0x3e,0x1f},
333 {0x4b,0xdd,0x96,0x4b}, {0xbd,0xdc,0x61,0xbd}, {0x8b,0x86,0x0d,0x8b}, {0x8a,0x85,0x0f,0x8a},
334 {0x70,0x90,0xe0,0x70}, {0x3e,0x42,0x7c,0x3e}, {0xb5,0xc4,0x71,0xb5}, {0x66,0xaa,0xcc,0x66},
335 {0x48,0xd8,0x90,0x48}, {0x03,0x05,0x06,0x03}, {0xf6,0x01,0xf7,0xf6}, {0x0e,0x12,0x1c,0x0e},
336 {0x61,0xa3,0xc2,0x61}, {0x35,0x5f,0x6a,0x35}, {0x57,0xf9,0xae,0x57}, {0xb9,0xd0,0x69,0xb9},
337 {0x86,0x91,0x17,0x86}, {0xc1,0x58,0x99,0xc1}, {0x1d,0x27,0x3a,0x1d}, {0x9e,0xb9,0x27,0x9e},
338 {0xe1,0x38,0xd9,0xe1}, {0xf8,0x13,0xeb,0xf8}, {0x98,0xb3,0x2b,0x98}, {0x11,0x33,0x22,0x11},
339 {0x69,0xbb,0xd2,0x69}, {0xd9,0x70,0xa9,0xd9}, {0x8e,0x89,0x07,0x8e}, {0x94,0xa7,0x33,0x94},
340 {0x9b,0xb6,0x2d,0x9b}, {0x1e,0x22,0x3c,0x1e}, {0x87,0x92,0x15,0x87}, {0xe9,0x20,0xc9,0xe9},
341 {0xce,0x49,0x87,0xce}, {0x55,0xff,0xaa,0x55}, {0x28,0x78,0x50,0x28}, {0xdf,0x7a,0xa5,0xdf},
342 {0x8c,0x8f,0x03,0x8c}, {0xa1,0xf8,0x59,0xa1}, {0x89,0x80,0x09,0x89}, {0x0d,0x17,0x1a,0x0d},
343 {0xbf,0xda,0x65,0xbf}, {0xe6,0x31,0xd7,0xe6}, {0x42,0xc6,0x84,0x42}, {0x68,0xb8,0xd0,0x68},
344 {0x41,0xc3,0x82,0x41}, {0x99,0xb0,0x29,0x99}, {0x2d,0x77,0x5a,0x2d}, {0x0f,0x11,0x1e,0x0f},
345 {0xb0,0xcb,0x7b,0xb0}, {0x54,0xfc,0xa8,0x54}, {0xbb,0xd6,0x6d,0xbb}, {0x16,0x3a,0x2c,0x16}
346 };
347
348 static uint8_t T4[256][4]=
349 {
350 {0x63,0x63,0xa5,0xc6}, {0x7c,0x7c,0x84,0xf8}, {0x77,0x77,0x99,0xee}, {0x7b,0x7b,0x8d,0xf6},
351 {0xf2,0xf2,0x0d,0xff}, {0x6b,0x6b,0xbd,0xd6}, {0x6f,0x6f,0xb1,0xde}, {0xc5,0xc5,0x54,0x91},
352 {0x30,0x30,0x50,0x60}, {0x01,0x01,0x03,0x02}, {0x67,0x67,0xa9,0xce}, {0x2b,0x2b,0x7d,0x56},
353 {0xfe,0xfe,0x19,0xe7}, {0xd7,0xd7,0x62,0xb5}, {0xab,0xab,0xe6,0x4d}, {0x76,0x76,0x9a,0xec},
354 {0xca,0xca,0x45,0x8f}, {0x82,0x82,0x9d,0x1f}, {0xc9,0xc9,0x40,0x89}, {0x7d,0x7d,0x87,0xfa},
355 {0xfa,0xfa,0x15,0xef}, {0x59,0x59,0xeb,0xb2}, {0x47,0x47,0xc9,0x8e}, {0xf0,0xf0,0x0b,0xfb},
356 {0xad,0xad,0xec,0x41}, {0xd4,0xd4,0x67,0xb3}, {0xa2,0xa2,0xfd,0x5f}, {0xaf,0xaf,0xea,0x45},
357 {0x9c,0x9c,0xbf,0x23}, {0xa4,0xa4,0xf7,0x53}, {0x72,0x72,0x96,0xe4}, {0xc0,0xc0,0x5b,0x9b},
358 {0xb7,0xb7,0xc2,0x75}, {0xfd,0xfd,0x1c,0xe1}, {0x93,0x93,0xae,0x3d}, {0x26,0x26,0x6a,0x4c},
359 {0x36,0x36,0x5a,0x6c}, {0x3f,0x3f,0x41,0x7e}, {0xf7,0xf7,0x02,0xf5}, {0xcc,0xcc,0x4f,0x83},
360 {0x34,0x34,0x5c,0x68}, {0xa5,0xa5,0xf4,0x51}, {0xe5,0xe5,0x34,0xd1}, {0xf1,0xf1,0x08,0xf9},
361 {0x71,0x71,0x93,0xe2}, {0xd8,0xd8,0x73,0xab}, {0x31,0x31,0x53,0x62}, {0x15,0x15,0x3f,0x2a},
362 {0x04,0x04,0x0c,0x08}, {0xc7,0xc7,0x52,0x95}, {0x23,0x23,0x65,0x46}, {0xc3,0xc3,0x5e,0x9d},
363 {0x18,0x18,0x28,0x30}, {0x96,0x96,0xa1,0x37}, {0x05,0x05,0x0f,0x0a}, {0x9a,0x9a,0xb5,0x2f},
364 {0x07,0x07,0x09,0x0e}, {0x12,0x12,0x36,0x24}, {0x80,0x80,0x9b,0x1b}, {0xe2,0xe2,0x3d,0xdf},
365 {0xeb,0xeb,0x26,0xcd}, {0x27,0x27,0x69,0x4e}, {0xb2,0xb2,0xcd,0x7f}, {0x75,0x75,0x9f,0xea},
366 {0x09,0x09,0x1b,0x12}, {0x83,0x83,0x9e,0x1d}, {0x2c,0x2c,0x74,0x58}, {0x1a,0x1a,0x2e,0x34},
367 {0x1b,0x1b,0x2d,0x36}, {0x6e,0x6e,0xb2,0xdc}, {0x5a,0x5a,0xee,0xb4}, {0xa0,0xa0,0xfb,0x5b},
368 {0x52,0x52,0xf6,0xa4}, {0x3b,0x3b,0x4d,0x76}, {0xd6,0xd6,0x61,0xb7}, {0xb3,0xb3,0xce,0x7d},
369 {0x29,0x29,0x7b,0x52}, {0xe3,0xe3,0x3e,0xdd}, {0x2f,0x2f,0x71,0x5e}, {0x84,0x84,0x97,0x13},
370 {0x53,0x53,0xf5,0xa6}, {0xd1,0xd1,0x68,0xb9}, {0x00,0x00,0x00,0x00}, {0xed,0xed,0x2c,0xc1},
371 {0x20,0x20,0x60,0x40}, {0xfc,0xfc,0x1f,0xe3}, {0xb1,0xb1,0xc8,0x79}, {0x5b,0x5b,0xed,0xb6},
372 {0x6a,0x6a,0xbe,0xd4}, {0xcb,0xcb,0x46,0x8d}, {0xbe,0xbe,0xd9,0x67}, {0x39,0x39,0x4b,0x72},
373 {0x4a,0x4a,0xde,0x94}, {0x4c,0x4c,0xd4,0x98}, {0x58,0x58,0xe8,0xb0}, {0xcf,0xcf,0x4a,0x85},
374 {0xd0,0xd0,0x6b,0xbb}, {0xef,0xef,0x2a,0xc5}, {0xaa,0xaa,0xe5,0x4f}, {0xfb,0xfb,0x16,0xed},
375 {0x43,0x43,0xc5,0x86}, {0x4d,0x4d,0xd7,0x9a}, {0x33,0x33,0x55,0x66}, {0x85,0x85,0x94,0x11},
376 {0x45,0x45,0xcf,0x8a}, {0xf9,0xf9,0x10,0xe9}, {0x02,0x02,0x06,0x04}, {0x7f,0x7f,0x81,0xfe},
377 {0x50,0x50,0xf0,0xa0}, {0x3c,0x3c,0x44,0x78}, {0x9f,0x9f,0xba,0x25}, {0xa8,0xa8,0xe3,0x4b},
378 {0x51,0x51,0xf3,0xa2}, {0xa3,0xa3,0xfe,0x5d}, {0x40,0x40,0xc0,0x80}, {0x8f,0x8f,0x8a,0x05},
379 {0x92,0x92,0xad,0x3f}, {0x9d,0x9d,0xbc,0x21}, {0x38,0x38,0x48,0x70}, {0xf5,0xf5,0x04,0xf1},
380 {0xbc,0xbc,0xdf,0x63}, {0xb6,0xb6,0xc1,0x77}, {0xda,0xda,0x75,0xaf}, {0x21,0x21,0x63,0x42},
381 {0x10,0x10,0x30,0x20}, {0xff,0xff,0x1a,0xe5}, {0xf3,0xf3,0x0e,0xfd}, {0xd2,0xd2,0x6d,0xbf},
382 {0xcd,0xcd,0x4c,0x81}, {0x0c,0x0c,0x14,0x18}, {0x13,0x13,0x35,0x26}, {0xec,0xec,0x2f,0xc3},
383 {0x5f,0x5f,0xe1,0xbe}, {0x97,0x97,0xa2,0x35}, {0x44,0x44,0xcc,0x88}, {0x17,0x17,0x39,0x2e},
384 {0xc4,0xc4,0x57,0x93}, {0xa7,0xa7,0xf2,0x55}, {0x7e,0x7e,0x82,0xfc}, {0x3d,0x3d,0x47,0x7a},
385 {0x64,0x64,0xac,0xc8}, {0x5d,0x5d,0xe7,0xba}, {0x19,0x19,0x2b,0x32}, {0x73,0x73,0x95,0xe6},
386 {0x60,0x60,0xa0,0xc0}, {0x81,0x81,0x98,0x19}, {0x4f,0x4f,0xd1,0x9e}, {0xdc,0xdc,0x7f,0xa3},
387 {0x22,0x22,0x66,0x44}, {0x2a,0x2a,0x7e,0x54}, {0x90,0x90,0xab,0x3b}, {0x88,0x88,0x83,0x0b},
388 {0x46,0x46,0xca,0x8c}, {0xee,0xee,0x29,0xc7}, {0xb8,0xb8,0xd3,0x6b}, {0x14,0x14,0x3c,0x28},
389 {0xde,0xde,0x79,0xa7}, {0x5e,0x5e,0xe2,0xbc}, {0x0b,0x0b,0x1d,0x16}, {0xdb,0xdb,0x76,0xad},
390 {0xe0,0xe0,0x3b,0xdb}, {0x32,0x32,0x56,0x64}, {0x3a,0x3a,0x4e,0x74}, {0x0a,0x0a,0x1e,0x14},
391 {0x49,0x49,0xdb,0x92}, {0x06,0x06,0x0a,0x0c}, {0x24,0x24,0x6c,0x48}, {0x5c,0x5c,0xe4,0xb8},
392 {0xc2,0xc2,0x5d,0x9f}, {0xd3,0xd3,0x6e,0xbd}, {0xac,0xac,0xef,0x43}, {0x62,0x62,0xa6,0xc4},
393 {0x91,0x91,0xa8,0x39}, {0x95,0x95,0xa4,0x31}, {0xe4,0xe4,0x37,0xd3}, {0x79,0x79,0x8b,0xf2},
394 {0xe7,0xe7,0x32,0xd5}, {0xc8,0xc8,0x43,0x8b}, {0x37,0x37,0x59,0x6e}, {0x6d,0x6d,0xb7,0xda},
395 {0x8d,0x8d,0x8c,0x01}, {0xd5,0xd5,0x64,0xb1}, {0x4e,0x4e,0xd2,0x9c}, {0xa9,0xa9,0xe0,0x49},
396 {0x6c,0x6c,0xb4,0xd8}, {0x56,0x56,0xfa,0xac}, {0xf4,0xf4,0x07,0xf3}, {0xea,0xea,0x25,0xcf},
397 {0x65,0x65,0xaf,0xca}, {0x7a,0x7a,0x8e,0xf4}, {0xae,0xae,0xe9,0x47}, {0x08,0x08,0x18,0x10},
398 {0xba,0xba,0xd5,0x6f}, {0x78,0x78,0x88,0xf0}, {0x25,0x25,0x6f,0x4a}, {0x2e,0x2e,0x72,0x5c},
399 {0x1c,0x1c,0x24,0x38}, {0xa6,0xa6,0xf1,0x57}, {0xb4,0xb4,0xc7,0x73}, {0xc6,0xc6,0x51,0x97},
400 {0xe8,0xe8,0x23,0xcb}, {0xdd,0xdd,0x7c,0xa1}, {0x74,0x74,0x9c,0xe8}, {0x1f,0x1f,0x21,0x3e},
401 {0x4b,0x4b,0xdd,0x96}, {0xbd,0xbd,0xdc,0x61}, {0x8b,0x8b,0x86,0x0d}, {0x8a,0x8a,0x85,0x0f},
402 {0x70,0x70,0x90,0xe0}, {0x3e,0x3e,0x42,0x7c}, {0xb5,0xb5,0xc4,0x71}, {0x66,0x66,0xaa,0xcc},
403 {0x48,0x48,0xd8,0x90}, {0x03,0x03,0x05,0x06}, {0xf6,0xf6,0x01,0xf7}, {0x0e,0x0e,0x12,0x1c},
404 {0x61,0x61,0xa3,0xc2}, {0x35,0x35,0x5f,0x6a}, {0x57,0x57,0xf9,0xae}, {0xb9,0xb9,0xd0,0x69},
405 {0x86,0x86,0x91,0x17}, {0xc1,0xc1,0x58,0x99}, {0x1d,0x1d,0x27,0x3a}, {0x9e,0x9e,0xb9,0x27},
406 {0xe1,0xe1,0x38,0xd9}, {0xf8,0xf8,0x13,0xeb}, {0x98,0x98,0xb3,0x2b}, {0x11,0x11,0x33,0x22},
407 {0x69,0x69,0xbb,0xd2}, {0xd9,0xd9,0x70,0xa9}, {0x8e,0x8e,0x89,0x07}, {0x94,0x94,0xa7,0x33},
408 {0x9b,0x9b,0xb6,0x2d}, {0x1e,0x1e,0x22,0x3c}, {0x87,0x87,0x92,0x15}, {0xe9,0xe9,0x20,0xc9},
409 {0xce,0xce,0x49,0x87}, {0x55,0x55,0xff,0xaa}, {0x28,0x28,0x78,0x50}, {0xdf,0xdf,0x7a,0xa5},
410 {0x8c,0x8c,0x8f,0x03}, {0xa1,0xa1,0xf8,0x59}, {0x89,0x89,0x80,0x09}, {0x0d,0x0d,0x17,0x1a},
411 {0xbf,0xbf,0xda,0x65}, {0xe6,0xe6,0x31,0xd7}, {0x42,0x42,0xc6,0x84}, {0x68,0x68,0xb8,0xd0},
412 {0x41,0x41,0xc3,0x82}, {0x99,0x99,0xb0,0x29}, {0x2d,0x2d,0x77,0x5a}, {0x0f,0x0f,0x11,0x1e},
413 {0xb0,0xb0,0xcb,0x7b}, {0x54,0x54,0xfc,0xa8}, {0xbb,0xbb,0xd6,0x6d}, {0x16,0x16,0x3a,0x2c}
414 };
415
416 static uint8_t T5[256][4]=
417 {
418 {0x51,0xf4,0xa7,0x50}, {0x7e,0x41,0x65,0x53}, {0x1a,0x17,0xa4,0xc3}, {0x3a,0x27,0x5e,0x96},
419 {0x3b,0xab,0x6b,0xcb}, {0x1f,0x9d,0x45,0xf1}, {0xac,0xfa,0x58,0xab}, {0x4b,0xe3,0x03,0x93},
420 {0x20,0x30,0xfa,0x55}, {0xad,0x76,0x6d,0xf6}, {0x88,0xcc,0x76,0x91}, {0xf5,0x02,0x4c,0x25},
421 {0x4f,0xe5,0xd7,0xfc}, {0xc5,0x2a,0xcb,0xd7}, {0x26,0x35,0x44,0x80}, {0xb5,0x62,0xa3,0x8f},
422 {0xde,0xb1,0x5a,0x49}, {0x25,0xba,0x1b,0x67}, {0x45,0xea,0x0e,0x98}, {0x5d,0xfe,0xc0,0xe1},
423 {0xc3,0x2f,0x75,0x02}, {0x81,0x4c,0xf0,0x12}, {0x8d,0x46,0x97,0xa3}, {0x6b,0xd3,0xf9,0xc6},
424 {0x03,0x8f,0x5f,0xe7}, {0x15,0x92,0x9c,0x95}, {0xbf,0x6d,0x7a,0xeb}, {0x95,0x52,0x59,0xda},
425 {0xd4,0xbe,0x83,0x2d}, {0x58,0x74,0x21,0xd3}, {0x49,0xe0,0x69,0x29}, {0x8e,0xc9,0xc8,0x44},
426 {0x75,0xc2,0x89,0x6a}, {0xf4,0x8e,0x79,0x78}, {0x99,0x58,0x3e,0x6b}, {0x27,0xb9,0x71,0xdd},
427 {0xbe,0xe1,0x4f,0xb6}, {0xf0,0x88,0xad,0x17}, {0xc9,0x20,0xac,0x66}, {0x7d,0xce,0x3a,0xb4},
428 {0x63,0xdf,0x4a,0x18}, {0xe5,0x1a,0x31,0x82}, {0x97,0x51,0x33,0x60}, {0x62,0x53,0x7f,0x45},
429 {0xb1,0x64,0x77,0xe0}, {0xbb,0x6b,0xae,0x84}, {0xfe,0x81,0xa0,0x1c}, {0xf9,0x08,0x2b,0x94},
430 {0x70,0x48,0x68,0x58}, {0x8f,0x45,0xfd,0x19}, {0x94,0xde,0x6c,0x87}, {0x52,0x7b,0xf8,0xb7},
431 {0xab,0x73,0xd3,0x23}, {0x72,0x4b,0x02,0xe2}, {0xe3,0x1f,0x8f,0x57}, {0x66,0x55,0xab,0x2a},
432 {0xb2,0xeb,0x28,0x07}, {0x2f,0xb5,0xc2,0x03}, {0x86,0xc5,0x7b,0x9a}, {0xd3,0x37,0x08,0xa5},
433 {0x30,0x28,0x87,0xf2}, {0x23,0xbf,0xa5,0xb2}, {0x02,0x03,0x6a,0xba}, {0xed,0x16,0x82,0x5c},
434 {0x8a,0xcf,0x1c,0x2b}, {0xa7,0x79,0xb4,0x92}, {0xf3,0x07,0xf2,0xf0}, {0x4e,0x69,0xe2,0xa1},
435 {0x65,0xda,0xf4,0xcd}, {0x06,0x05,0xbe,0xd5}, {0xd1,0x34,0x62,0x1f}, {0xc4,0xa6,0xfe,0x8a},
436 {0x34,0x2e,0x53,0x9d}, {0xa2,0xf3,0x55,0xa0}, {0x05,0x8a,0xe1,0x32}, {0xa4,0xf6,0xeb,0x75},
437 {0x0b,0x83,0xec,0x39}, {0x40,0x60,0xef,0xaa}, {0x5e,0x71,0x9f,0x06}, {0xbd,0x6e,0x10,0x51},
438 {0x3e,0x21,0x8a,0xf9}, {0x96,0xdd,0x06,0x3d}, {0xdd,0x3e,0x05,0xae}, {0x4d,0xe6,0xbd,0x46},
439 {0x91,0x54,0x8d,0xb5}, {0x71,0xc4,0x5d,0x05}, {0x04,0x06,0xd4,0x6f}, {0x60,0x50,0x15,0xff},
440 {0x19,0x98,0xfb,0x24}, {0xd6,0xbd,0xe9,0x97}, {0x89,0x40,0x43,0xcc}, {0x67,0xd9,0x9e,0x77},
441 {0xb0,0xe8,0x42,0xbd}, {0x07,0x89,0x8b,0x88}, {0xe7,0x19,0x5b,0x38}, {0x79,0xc8,0xee,0xdb},
442 {0xa1,0x7c,0x0a,0x47}, {0x7c,0x42,0x0f,0xe9}, {0xf8,0x84,0x1e,0xc9}, {0x00,0x00,0x00,0x00},
443 {0x09,0x80,0x86,0x83}, {0x32,0x2b,0xed,0x48}, {0x1e,0x11,0x70,0xac}, {0x6c,0x5a,0x72,0x4e},
444 {0xfd,0x0e,0xff,0xfb}, {0x0f,0x85,0x38,0x56}, {0x3d,0xae,0xd5,0x1e}, {0x36,0x2d,0x39,0x27},
445 {0x0a,0x0f,0xd9,0x64}, {0x68,0x5c,0xa6,0x21}, {0x9b,0x5b,0x54,0xd1}, {0x24,0x36,0x2e,0x3a},
446 {0x0c,0x0a,0x67,0xb1}, {0x93,0x57,0xe7,0x0f}, {0xb4,0xee,0x96,0xd2}, {0x1b,0x9b,0x91,0x9e},
447 {0x80,0xc0,0xc5,0x4f}, {0x61,0xdc,0x20,0xa2}, {0x5a,0x77,0x4b,0x69}, {0x1c,0x12,0x1a,0x16},
448 {0xe2,0x93,0xba,0x0a}, {0xc0,0xa0,0x2a,0xe5}, {0x3c,0x22,0xe0,0x43}, {0x12,0x1b,0x17,0x1d},
449 {0x0e,0x09,0x0d,0x0b}, {0xf2,0x8b,0xc7,0xad}, {0x2d,0xb6,0xa8,0xb9}, {0x14,0x1e,0xa9,0xc8},
450 {0x57,0xf1,0x19,0x85}, {0xaf,0x75,0x07,0x4c}, {0xee,0x99,0xdd,0xbb}, {0xa3,0x7f,0x60,0xfd},
451 {0xf7,0x01,0x26,0x9f}, {0x5c,0x72,0xf5,0xbc}, {0x44,0x66,0x3b,0xc5}, {0x5b,0xfb,0x7e,0x34},
452 {0x8b,0x43,0x29,0x76}, {0xcb,0x23,0xc6,0xdc}, {0xb6,0xed,0xfc,0x68}, {0xb8,0xe4,0xf1,0x63},
453 {0xd7,0x31,0xdc,0xca}, {0x42,0x63,0x85,0x10}, {0x13,0x97,0x22,0x40}, {0x84,0xc6,0x11,0x20},
454 {0x85,0x4a,0x24,0x7d}, {0xd2,0xbb,0x3d,0xf8}, {0xae,0xf9,0x32,0x11}, {0xc7,0x29,0xa1,0x6d},
455 {0x1d,0x9e,0x2f,0x4b}, {0xdc,0xb2,0x30,0xf3}, {0x0d,0x86,0x52,0xec}, {0x77,0xc1,0xe3,0xd0},
456 {0x2b,0xb3,0x16,0x6c}, {0xa9,0x70,0xb9,0x99}, {0x11,0x94,0x48,0xfa}, {0x47,0xe9,0x64,0x22},
457 {0xa8,0xfc,0x8c,0xc4}, {0xa0,0xf0,0x3f,0x1a}, {0x56,0x7d,0x2c,0xd8}, {0x22,0x33,0x90,0xef},
458 {0x87,0x49,0x4e,0xc7}, {0xd9,0x38,0xd1,0xc1}, {0x8c,0xca,0xa2,0xfe}, {0x98,0xd4,0x0b,0x36},
459 {0xa6,0xf5,0x81,0xcf}, {0xa5,0x7a,0xde,0x28}, {0xda,0xb7,0x8e,0x26}, {0x3f,0xad,0xbf,0xa4},
460 {0x2c,0x3a,0x9d,0xe4}, {0x50,0x78,0x92,0x0d}, {0x6a,0x5f,0xcc,0x9b}, {0x54,0x7e,0x46,0x62},
461 {0xf6,0x8d,0x13,0xc2}, {0x90,0xd8,0xb8,0xe8}, {0x2e,0x39,0xf7,0x5e}, {0x82,0xc3,0xaf,0xf5},
462 {0x9f,0x5d,0x80,0xbe}, {0x69,0xd0,0x93,0x7c}, {0x6f,0xd5,0x2d,0xa9}, {0xcf,0x25,0x12,0xb3},
463 {0xc8,0xac,0x99,0x3b}, {0x10,0x18,0x7d,0xa7}, {0xe8,0x9c,0x63,0x6e}, {0xdb,0x3b,0xbb,0x7b},
464 {0xcd,0x26,0x78,0x09}, {0x6e,0x59,0x18,0xf4}, {0xec,0x9a,0xb7,0x01}, {0x83,0x4f,0x9a,0xa8},
465 {0xe6,0x95,0x6e,0x65}, {0xaa,0xff,0xe6,0x7e}, {0x21,0xbc,0xcf,0x08}, {0xef,0x15,0xe8,0xe6},
466 {0xba,0xe7,0x9b,0xd9}, {0x4a,0x6f,0x36,0xce}, {0xea,0x9f,0x09,0xd4}, {0x29,0xb0,0x7c,0xd6},
467 {0x31,0xa4,0xb2,0xaf}, {0x2a,0x3f,0x23,0x31}, {0xc6,0xa5,0x94,0x30}, {0x35,0xa2,0x66,0xc0},
468 {0x74,0x4e,0xbc,0x37}, {0xfc,0x82,0xca,0xa6}, {0xe0,0x90,0xd0,0xb0}, {0x33,0xa7,0xd8,0x15},
469 {0xf1,0x04,0x98,0x4a}, {0x41,0xec,0xda,0xf7}, {0x7f,0xcd,0x50,0x0e}, {0x17,0x91,0xf6,0x2f},
470 {0x76,0x4d,0xd6,0x8d}, {0x43,0xef,0xb0,0x4d}, {0xcc,0xaa,0x4d,0x54}, {0xe4,0x96,0x04,0xdf},
471 {0x9e,0xd1,0xb5,0xe3}, {0x4c,0x6a,0x88,0x1b}, {0xc1,0x2c,0x1f,0xb8}, {0x46,0x65,0x51,0x7f},
472 {0x9d,0x5e,0xea,0x04}, {0x01,0x8c,0x35,0x5d}, {0xfa,0x87,0x74,0x73}, {0xfb,0x0b,0x41,0x2e},
473 {0xb3,0x67,0x1d,0x5a}, {0x92,0xdb,0xd2,0x52}, {0xe9,0x10,0x56,0x33}, {0x6d,0xd6,0x47,0x13},
474 {0x9a,0xd7,0x61,0x8c}, {0x37,0xa1,0x0c,0x7a}, {0x59,0xf8,0x14,0x8e}, {0xeb,0x13,0x3c,0x89},
475 {0xce,0xa9,0x27,0xee}, {0xb7,0x61,0xc9,0x35}, {0xe1,0x1c,0xe5,0xed}, {0x7a,0x47,0xb1,0x3c},
476 {0x9c,0xd2,0xdf,0x59}, {0x55,0xf2,0x73,0x3f}, {0x18,0x14,0xce,0x79}, {0x73,0xc7,0x37,0xbf},
477 {0x53,0xf7,0xcd,0xea}, {0x5f,0xfd,0xaa,0x5b}, {0xdf,0x3d,0x6f,0x14}, {0x78,0x44,0xdb,0x86},
478 {0xca,0xaf,0xf3,0x81}, {0xb9,0x68,0xc4,0x3e}, {0x38,0x24,0x34,0x2c}, {0xc2,0xa3,0x40,0x5f},
479 {0x16,0x1d,0xc3,0x72}, {0xbc,0xe2,0x25,0x0c}, {0x28,0x3c,0x49,0x8b}, {0xff,0x0d,0x95,0x41},
480 {0x39,0xa8,0x01,0x71}, {0x08,0x0c,0xb3,0xde}, {0xd8,0xb4,0xe4,0x9c}, {0x64,0x56,0xc1,0x90},
481 {0x7b,0xcb,0x84,0x61}, {0xd5,0x32,0xb6,0x70}, {0x48,0x6c,0x5c,0x74}, {0xd0,0xb8,0x57,0x42}
482 };
483
484 static uint8_t T6[256][4]=
485 {
486 {0x50,0x51,0xf4,0xa7}, {0x53,0x7e,0x41,0x65}, {0xc3,0x1a,0x17,0xa4}, {0x96,0x3a,0x27,0x5e},
487 {0xcb,0x3b,0xab,0x6b}, {0xf1,0x1f,0x9d,0x45}, {0xab,0xac,0xfa,0x58}, {0x93,0x4b,0xe3,0x03},
488 {0x55,0x20,0x30,0xfa}, {0xf6,0xad,0x76,0x6d}, {0x91,0x88,0xcc,0x76}, {0x25,0xf5,0x02,0x4c},
489 {0xfc,0x4f,0xe5,0xd7}, {0xd7,0xc5,0x2a,0xcb}, {0x80,0x26,0x35,0x44}, {0x8f,0xb5,0x62,0xa3},
490 {0x49,0xde,0xb1,0x5a}, {0x67,0x25,0xba,0x1b}, {0x98,0x45,0xea,0x0e}, {0xe1,0x5d,0xfe,0xc0},
491 {0x02,0xc3,0x2f,0x75}, {0x12,0x81,0x4c,0xf0}, {0xa3,0x8d,0x46,0x97}, {0xc6,0x6b,0xd3,0xf9},
492 {0xe7,0x03,0x8f,0x5f}, {0x95,0x15,0x92,0x9c}, {0xeb,0xbf,0x6d,0x7a}, {0xda,0x95,0x52,0x59},
493 {0x2d,0xd4,0xbe,0x83}, {0xd3,0x58,0x74,0x21}, {0x29,0x49,0xe0,0x69}, {0x44,0x8e,0xc9,0xc8},
494 {0x6a,0x75,0xc2,0x89}, {0x78,0xf4,0x8e,0x79}, {0x6b,0x99,0x58,0x3e}, {0xdd,0x27,0xb9,0x71},
495 {0xb6,0xbe,0xe1,0x4f}, {0x17,0xf0,0x88,0xad}, {0x66,0xc9,0x20,0xac}, {0xb4,0x7d,0xce,0x3a},
496 {0x18,0x63,0xdf,0x4a}, {0x82,0xe5,0x1a,0x31}, {0x60,0x97,0x51,0x33}, {0x45,0x62,0x53,0x7f},
497 {0xe0,0xb1,0x64,0x77}, {0x84,0xbb,0x6b,0xae}, {0x1c,0xfe,0x81,0xa0}, {0x94,0xf9,0x08,0x2b},
498 {0x58,0x70,0x48,0x68}, {0x19,0x8f,0x45,0xfd}, {0x87,0x94,0xde,0x6c}, {0xb7,0x52,0x7b,0xf8},
499 {0x23,0xab,0x73,0xd3}, {0xe2,0x72,0x4b,0x02}, {0x57,0xe3,0x1f,0x8f}, {0x2a,0x66,0x55,0xab},
500 {0x07,0xb2,0xeb,0x28}, {0x03,0x2f,0xb5,0xc2}, {0x9a,0x86,0xc5,0x7b}, {0xa5,0xd3,0x37,0x08},
501 {0xf2,0x30,0x28,0x87}, {0xb2,0x23,0xbf,0xa5}, {0xba,0x02,0x03,0x6a}, {0x5c,0xed,0x16,0x82},
502 {0x2b,0x8a,0xcf,0x1c}, {0x92,0xa7,0x79,0xb4}, {0xf0,0xf3,0x07,0xf2}, {0xa1,0x4e,0x69,0xe2},
503 {0xcd,0x65,0xda,0xf4}, {0xd5,0x06,0x05,0xbe}, {0x1f,0xd1,0x34,0x62}, {0x8a,0xc4,0xa6,0xfe},
504 {0x9d,0x34,0x2e,0x53}, {0xa0,0xa2,0xf3,0x55}, {0x32,0x05,0x8a,0xe1}, {0x75,0xa4,0xf6,0xeb},
505 {0x39,0x0b,0x83,0xec}, {0xaa,0x40,0x60,0xef}, {0x06,0x5e,0x71,0x9f}, {0x51,0xbd,0x6e,0x10},
506 {0xf9,0x3e,0x21,0x8a}, {0x3d,0x96,0xdd,0x06}, {0xae,0xdd,0x3e,0x05}, {0x46,0x4d,0xe6,0xbd},
507 {0xb5,0x91,0x54,0x8d}, {0x05,0x71,0xc4,0x5d}, {0x6f,0x04,0x06,0xd4}, {0xff,0x60,0x50,0x15},
508 {0x24,0x19,0x98,0xfb}, {0x97,0xd6,0xbd,0xe9}, {0xcc,0x89,0x40,0x43}, {0x77,0x67,0xd9,0x9e},
509 {0xbd,0xb0,0xe8,0x42}, {0x88,0x07,0x89,0x8b}, {0x38,0xe7,0x19,0x5b}, {0xdb,0x79,0xc8,0xee},
510 {0x47,0xa1,0x7c,0x0a}, {0xe9,0x7c,0x42,0x0f}, {0xc9,0xf8,0x84,0x1e}, {0x00,0x00,0x00,0x00},
511 {0x83,0x09,0x80,0x86}, {0x48,0x32,0x2b,0xed}, {0xac,0x1e,0x11,0x70}, {0x4e,0x6c,0x5a,0x72},
512 {0xfb,0xfd,0x0e,0xff}, {0x56,0x0f,0x85,0x38}, {0x1e,0x3d,0xae,0xd5}, {0x27,0x36,0x2d,0x39},
513 {0x64,0x0a,0x0f,0xd9}, {0x21,0x68,0x5c,0xa6}, {0xd1,0x9b,0x5b,0x54}, {0x3a,0x24,0x36,0x2e},
514 {0xb1,0x0c,0x0a,0x67}, {0x0f,0x93,0x57,0xe7}, {0xd2,0xb4,0xee,0x96}, {0x9e,0x1b,0x9b,0x91},
515 {0x4f,0x80,0xc0,0xc5}, {0xa2,0x61,0xdc,0x20}, {0x69,0x5a,0x77,0x4b}, {0x16,0x1c,0x12,0x1a},
516 {0x0a,0xe2,0x93,0xba}, {0xe5,0xc0,0xa0,0x2a}, {0x43,0x3c,0x22,0xe0}, {0x1d,0x12,0x1b,0x17},
517 {0x0b,0x0e,0x09,0x0d}, {0xad,0xf2,0x8b,0xc7}, {0xb9,0x2d,0xb6,0xa8}, {0xc8,0x14,0x1e,0xa9},
518 {0x85,0x57,0xf1,0x19}, {0x4c,0xaf,0x75,0x07}, {0xbb,0xee,0x99,0xdd}, {0xfd,0xa3,0x7f,0x60},
519 {0x9f,0xf7,0x01,0x26}, {0xbc,0x5c,0x72,0xf5}, {0xc5,0x44,0x66,0x3b}, {0x34,0x5b,0xfb,0x7e},
520 {0x76,0x8b,0x43,0x29}, {0xdc,0xcb,0x23,0xc6}, {0x68,0xb6,0xed,0xfc}, {0x63,0xb8,0xe4,0xf1},
521 {0xca,0xd7,0x31,0xdc}, {0x10,0x42,0x63,0x85}, {0x40,0x13,0x97,0x22}, {0x20,0x84,0xc6,0x11},
522 {0x7d,0x85,0x4a,0x24}, {0xf8,0xd2,0xbb,0x3d}, {0x11,0xae,0xf9,0x32}, {0x6d,0xc7,0x29,0xa1},
523 {0x4b,0x1d,0x9e,0x2f}, {0xf3,0xdc,0xb2,0x30}, {0xec,0x0d,0x86,0x52}, {0xd0,0x77,0xc1,0xe3},
524 {0x6c,0x2b,0xb3,0x16}, {0x99,0xa9,0x70,0xb9}, {0xfa,0x11,0x94,0x48}, {0x22,0x47,0xe9,0x64},
525 {0xc4,0xa8,0xfc,0x8c}, {0x1a,0xa0,0xf0,0x3f}, {0xd8,0x56,0x7d,0x2c}, {0xef,0x22,0x33,0x90},
526 {0xc7,0x87,0x49,0x4e}, {0xc1,0xd9,0x38,0xd1}, {0xfe,0x8c,0xca,0xa2}, {0x36,0x98,0xd4,0x0b},
527 {0xcf,0xa6,0xf5,0x81}, {0x28,0xa5,0x7a,0xde}, {0x26,0xda,0xb7,0x8e}, {0xa4,0x3f,0xad,0xbf},
528 {0xe4,0x2c,0x3a,0x9d}, {0x0d,0x50,0x78,0x92}, {0x9b,0x6a,0x5f,0xcc}, {0x62,0x54,0x7e,0x46},
529 {0xc2,0xf6,0x8d,0x13}, {0xe8,0x90,0xd8,0xb8}, {0x5e,0x2e,0x39,0xf7}, {0xf5,0x82,0xc3,0xaf},
530 {0xbe,0x9f,0x5d,0x80}, {0x7c,0x69,0xd0,0x93}, {0xa9,0x6f,0xd5,0x2d}, {0xb3,0xcf,0x25,0x12},
531 {0x3b,0xc8,0xac,0x99}, {0xa7,0x10,0x18,0x7d}, {0x6e,0xe8,0x9c,0x63}, {0x7b,0xdb,0x3b,0xbb},
532 {0x09,0xcd,0x26,0x78}, {0xf4,0x6e,0x59,0x18}, {0x01,0xec,0x9a,0xb7}, {0xa8,0x83,0x4f,0x9a},
533 {0x65,0xe6,0x95,0x6e}, {0x7e,0xaa,0xff,0xe6}, {0x08,0x21,0xbc,0xcf}, {0xe6,0xef,0x15,0xe8},
534 {0xd9,0xba,0xe7,0x9b}, {0xce,0x4a,0x6f,0x36}, {0xd4,0xea,0x9f,0x09}, {0xd6,0x29,0xb0,0x7c},
535 {0xaf,0x31,0xa4,0xb2}, {0x31,0x2a,0x3f,0x23}, {0x30,0xc6,0xa5,0x94}, {0xc0,0x35,0xa2,0x66},
536 {0x37,0x74,0x4e,0xbc}, {0xa6,0xfc,0x82,0xca}, {0xb0,0xe0,0x90,0xd0}, {0x15,0x33,0xa7,0xd8},
537 {0x4a,0xf1,0x04,0x98}, {0xf7,0x41,0xec,0xda}, {0x0e,0x7f,0xcd,0x50}, {0x2f,0x17,0x91,0xf6},
538 {0x8d,0x76,0x4d,0xd6}, {0x4d,0x43,0xef,0xb0}, {0x54,0xcc,0xaa,0x4d}, {0xdf,0xe4,0x96,0x04},
539 {0xe3,0x9e,0xd1,0xb5}, {0x1b,0x4c,0x6a,0x88}, {0xb8,0xc1,0x2c,0x1f}, {0x7f,0x46,0x65,0x51},
540 {0x04,0x9d,0x5e,0xea}, {0x5d,0x01,0x8c,0x35}, {0x73,0xfa,0x87,0x74}, {0x2e,0xfb,0x0b,0x41},
541 {0x5a,0xb3,0x67,0x1d}, {0x52,0x92,0xdb,0xd2}, {0x33,0xe9,0x10,0x56}, {0x13,0x6d,0xd6,0x47},
542 {0x8c,0x9a,0xd7,0x61}, {0x7a,0x37,0xa1,0x0c}, {0x8e,0x59,0xf8,0x14}, {0x89,0xeb,0x13,0x3c},
543 {0xee,0xce,0xa9,0x27}, {0x35,0xb7,0x61,0xc9}, {0xed,0xe1,0x1c,0xe5}, {0x3c,0x7a,0x47,0xb1},
544 {0x59,0x9c,0xd2,0xdf}, {0x3f,0x55,0xf2,0x73}, {0x79,0x18,0x14,0xce}, {0xbf,0x73,0xc7,0x37},
545 {0xea,0x53,0xf7,0xcd}, {0x5b,0x5f,0xfd,0xaa}, {0x14,0xdf,0x3d,0x6f}, {0x86,0x78,0x44,0xdb},
546 {0x81,0xca,0xaf,0xf3}, {0x3e,0xb9,0x68,0xc4}, {0x2c,0x38,0x24,0x34}, {0x5f,0xc2,0xa3,0x40},
547 {0x72,0x16,0x1d,0xc3}, {0x0c,0xbc,0xe2,0x25}, {0x8b,0x28,0x3c,0x49}, {0x41,0xff,0x0d,0x95},
548 {0x71,0x39,0xa8,0x01}, {0xde,0x08,0x0c,0xb3}, {0x9c,0xd8,0xb4,0xe4}, {0x90,0x64,0x56,0xc1},
549 {0x61,0x7b,0xcb,0x84}, {0x70,0xd5,0x32,0xb6}, {0x74,0x48,0x6c,0x5c}, {0x42,0xd0,0xb8,0x57}
550 };
551
552 static uint8_t T7[256][4]=
553 {
554 {0xa7,0x50,0x51,0xf4}, {0x65,0x53,0x7e,0x41}, {0xa4,0xc3,0x1a,0x17}, {0x5e,0x96,0x3a,0x27},
555 {0x6b,0xcb,0x3b,0xab}, {0x45,0xf1,0x1f,0x9d}, {0x58,0xab,0xac,0xfa}, {0x03,0x93,0x4b,0xe3},
556 {0xfa,0x55,0x20,0x30}, {0x6d,0xf6,0xad,0x76}, {0x76,0x91,0x88,0xcc}, {0x4c,0x25,0xf5,0x02},
557 {0xd7,0xfc,0x4f,0xe5}, {0xcb,0xd7,0xc5,0x2a}, {0x44,0x80,0x26,0x35}, {0xa3,0x8f,0xb5,0x62},
558 {0x5a,0x49,0xde,0xb1}, {0x1b,0x67,0x25,0xba}, {0x0e,0x98,0x45,0xea}, {0xc0,0xe1,0x5d,0xfe},
559 {0x75,0x02,0xc3,0x2f}, {0xf0,0x12,0x81,0x4c}, {0x97,0xa3,0x8d,0x46}, {0xf9,0xc6,0x6b,0xd3},
560 {0x5f,0xe7,0x03,0x8f}, {0x9c,0x95,0x15,0x92}, {0x7a,0xeb,0xbf,0x6d}, {0x59,0xda,0x95,0x52},
561 {0x83,0x2d,0xd4,0xbe}, {0x21,0xd3,0x58,0x74}, {0x69,0x29,0x49,0xe0}, {0xc8,0x44,0x8e,0xc9},
562 {0x89,0x6a,0x75,0xc2}, {0x79,0x78,0xf4,0x8e}, {0x3e,0x6b,0x99,0x58}, {0x71,0xdd,0x27,0xb9},
563 {0x4f,0xb6,0xbe,0xe1}, {0xad,0x17,0xf0,0x88}, {0xac,0x66,0xc9,0x20}, {0x3a,0xb4,0x7d,0xce},
564 {0x4a,0x18,0x63,0xdf}, {0x31,0x82,0xe5,0x1a}, {0x33,0x60,0x97,0x51}, {0x7f,0x45,0x62,0x53},
565 {0x77,0xe0,0xb1,0x64}, {0xae,0x84,0xbb,0x6b}, {0xa0,0x1c,0xfe,0x81}, {0x2b,0x94,0xf9,0x08},
566 {0x68,0x58,0x70,0x48}, {0xfd,0x19,0x8f,0x45}, {0x6c,0x87,0x94,0xde}, {0xf8,0xb7,0x52,0x7b},
567 {0xd3,0x23,0xab,0x73}, {0x02,0xe2,0x72,0x4b}, {0x8f,0x57,0xe3,0x1f}, {0xab,0x2a,0x66,0x55},
568 {0x28,0x07,0xb2,0xeb}, {0xc2,0x03,0x2f,0xb5}, {0x7b,0x9a,0x86,0xc5}, {0x08,0xa5,0xd3,0x37},
569 {0x87,0xf2,0x30,0x28}, {0xa5,0xb2,0x23,0xbf}, {0x6a,0xba,0x02,0x03}, {0x82,0x5c,0xed,0x16},
570 {0x1c,0x2b,0x8a,0xcf}, {0xb4,0x92,0xa7,0x79}, {0xf2,0xf0,0xf3,0x07}, {0xe2,0xa1,0x4e,0x69},
571 {0xf4,0xcd,0x65,0xda}, {0xbe,0xd5,0x06,0x05}, {0x62,0x1f,0xd1,0x34}, {0xfe,0x8a,0xc4,0xa6},
572 {0x53,0x9d,0x34,0x2e}, {0x55,0xa0,0xa2,0xf3}, {0xe1,0x32,0x05,0x8a}, {0xeb,0x75,0xa4,0xf6},
573 {0xec,0x39,0x0b,0x83}, {0xef,0xaa,0x40,0x60}, {0x9f,0x06,0x5e,0x71}, {0x10,0x51,0xbd,0x6e},
574 {0x8a,0xf9,0x3e,0x21}, {0x06,0x3d,0x96,0xdd}, {0x05,0xae,0xdd,0x3e}, {0xbd,0x46,0x4d,0xe6},
575 {0x8d,0xb5,0x91,0x54}, {0x5d,0x05,0x71,0xc4}, {0xd4,0x6f,0x04,0x06}, {0x15,0xff,0x60,0x50},
576 {0xfb,0x24,0x19,0x98}, {0xe9,0x97,0xd6,0xbd}, {0x43,0xcc,0x89,0x40}, {0x9e,0x77,0x67,0xd9},
577 {0x42,0xbd,0xb0,0xe8}, {0x8b,0x88,0x07,0x89}, {0x5b,0x38,0xe7,0x19}, {0xee,0xdb,0x79,0xc8},
578 {0x0a,0x47,0xa1,0x7c}, {0x0f,0xe9,0x7c,0x42}, {0x1e,0xc9,0xf8,0x84}, {0x00,0x00,0x00,0x00},
579 {0x86,0x83,0x09,0x80}, {0xed,0x48,0x32,0x2b}, {0x70,0xac,0x1e,0x11}, {0x72,0x4e,0x6c,0x5a},
580 {0xff,0xfb,0xfd,0x0e}, {0x38,0x56,0x0f,0x85}, {0xd5,0x1e,0x3d,0xae}, {0x39,0x27,0x36,0x2d},
581 {0xd9,0x64,0x0a,0x0f}, {0xa6,0x21,0x68,0x5c}, {0x54,0xd1,0x9b,0x5b}, {0x2e,0x3a,0x24,0x36},
582 {0x67,0xb1,0x0c,0x0a}, {0xe7,0x0f,0x93,0x57}, {0x96,0xd2,0xb4,0xee}, {0x91,0x9e,0x1b,0x9b},
583 {0xc5,0x4f,0x80,0xc0}, {0x20,0xa2,0x61,0xdc}, {0x4b,0x69,0x5a,0x77}, {0x1a,0x16,0x1c,0x12},
584 {0xba,0x0a,0xe2,0x93}, {0x2a,0xe5,0xc0,0xa0}, {0xe0,0x43,0x3c,0x22}, {0x17,0x1d,0x12,0x1b},
585 {0x0d,0x0b,0x0e,0x09}, {0xc7,0xad,0xf2,0x8b}, {0xa8,0xb9,0x2d,0xb6}, {0xa9,0xc8,0x14,0x1e},
586 {0x19,0x85,0x57,0xf1}, {0x07,0x4c,0xaf,0x75}, {0xdd,0xbb,0xee,0x99}, {0x60,0xfd,0xa3,0x7f},
587 {0x26,0x9f,0xf7,0x01}, {0xf5,0xbc,0x5c,0x72}, {0x3b,0xc5,0x44,0x66}, {0x7e,0x34,0x5b,0xfb},
588 {0x29,0x76,0x8b,0x43}, {0xc6,0xdc,0xcb,0x23}, {0xfc,0x68,0xb6,0xed}, {0xf1,0x63,0xb8,0xe4},
589 {0xdc,0xca,0xd7,0x31}, {0x85,0x10,0x42,0x63}, {0x22,0x40,0x13,0x97}, {0x11,0x20,0x84,0xc6},
590 {0x24,0x7d,0x85,0x4a}, {0x3d,0xf8,0xd2,0xbb}, {0x32,0x11,0xae,0xf9}, {0xa1,0x6d,0xc7,0x29},
591 {0x2f,0x4b,0x1d,0x9e}, {0x30,0xf3,0xdc,0xb2}, {0x52,0xec,0x0d,0x86}, {0xe3,0xd0,0x77,0xc1},
592 {0x16,0x6c,0x2b,0xb3}, {0xb9,0x99,0xa9,0x70}, {0x48,0xfa,0x11,0x94}, {0x64,0x22,0x47,0xe9},
593 {0x8c,0xc4,0xa8,0xfc}, {0x3f,0x1a,0xa0,0xf0}, {0x2c,0xd8,0x56,0x7d}, {0x90,0xef,0x22,0x33},
594 {0x4e,0xc7,0x87,0x49}, {0xd1,0xc1,0xd9,0x38}, {0xa2,0xfe,0x8c,0xca}, {0x0b,0x36,0x98,0xd4},
595 {0x81,0xcf,0xa6,0xf5}, {0xde,0x28,0xa5,0x7a}, {0x8e,0x26,0xda,0xb7}, {0xbf,0xa4,0x3f,0xad},
596 {0x9d,0xe4,0x2c,0x3a}, {0x92,0x0d,0x50,0x78}, {0xcc,0x9b,0x6a,0x5f}, {0x46,0x62,0x54,0x7e},
597 {0x13,0xc2,0xf6,0x8d}, {0xb8,0xe8,0x90,0xd8}, {0xf7,0x5e,0x2e,0x39}, {0xaf,0xf5,0x82,0xc3},
598 {0x80,0xbe,0x9f,0x5d}, {0x93,0x7c,0x69,0xd0}, {0x2d,0xa9,0x6f,0xd5}, {0x12,0xb3,0xcf,0x25},
599 {0x99,0x3b,0xc8,0xac}, {0x7d,0xa7,0x10,0x18}, {0x63,0x6e,0xe8,0x9c}, {0xbb,0x7b,0xdb,0x3b},
600 {0x78,0x09,0xcd,0x26}, {0x18,0xf4,0x6e,0x59}, {0xb7,0x01,0xec,0x9a}, {0x9a,0xa8,0x83,0x4f},
601 {0x6e,0x65,0xe6,0x95}, {0xe6,0x7e,0xaa,0xff}, {0xcf,0x08,0x21,0xbc}, {0xe8,0xe6,0xef,0x15},
602 {0x9b,0xd9,0xba,0xe7}, {0x36,0xce,0x4a,0x6f}, {0x09,0xd4,0xea,0x9f}, {0x7c,0xd6,0x29,0xb0},
603 {0xb2,0xaf,0x31,0xa4}, {0x23,0x31,0x2a,0x3f}, {0x94,0x30,0xc6,0xa5}, {0x66,0xc0,0x35,0xa2},
604 {0xbc,0x37,0x74,0x4e}, {0xca,0xa6,0xfc,0x82}, {0xd0,0xb0,0xe0,0x90}, {0xd8,0x15,0x33,0xa7},
605 {0x98,0x4a,0xf1,0x04}, {0xda,0xf7,0x41,0xec}, {0x50,0x0e,0x7f,0xcd}, {0xf6,0x2f,0x17,0x91},
606 {0xd6,0x8d,0x76,0x4d}, {0xb0,0x4d,0x43,0xef}, {0x4d,0x54,0xcc,0xaa}, {0x04,0xdf,0xe4,0x96},
607 {0xb5,0xe3,0x9e,0xd1}, {0x88,0x1b,0x4c,0x6a}, {0x1f,0xb8,0xc1,0x2c}, {0x51,0x7f,0x46,0x65},
608 {0xea,0x04,0x9d,0x5e}, {0x35,0x5d,0x01,0x8c}, {0x74,0x73,0xfa,0x87}, {0x41,0x2e,0xfb,0x0b},
609 {0x1d,0x5a,0xb3,0x67}, {0xd2,0x52,0x92,0xdb}, {0x56,0x33,0xe9,0x10}, {0x47,0x13,0x6d,0xd6},
610 {0x61,0x8c,0x9a,0xd7}, {0x0c,0x7a,0x37,0xa1}, {0x14,0x8e,0x59,0xf8}, {0x3c,0x89,0xeb,0x13},
611 {0x27,0xee,0xce,0xa9}, {0xc9,0x35,0xb7,0x61}, {0xe5,0xed,0xe1,0x1c}, {0xb1,0x3c,0x7a,0x47},
612 {0xdf,0x59,0x9c,0xd2}, {0x73,0x3f,0x55,0xf2}, {0xce,0x79,0x18,0x14}, {0x37,0xbf,0x73,0xc7},
613 {0xcd,0xea,0x53,0xf7}, {0xaa,0x5b,0x5f,0xfd}, {0x6f,0x14,0xdf,0x3d}, {0xdb,0x86,0x78,0x44},
614 {0xf3,0x81,0xca,0xaf}, {0xc4,0x3e,0xb9,0x68}, {0x34,0x2c,0x38,0x24}, {0x40,0x5f,0xc2,0xa3},
615 {0xc3,0x72,0x16,0x1d}, {0x25,0x0c,0xbc,0xe2}, {0x49,0x8b,0x28,0x3c}, {0x95,0x41,0xff,0x0d},
616 {0x01,0x71,0x39,0xa8}, {0xb3,0xde,0x08,0x0c}, {0xe4,0x9c,0xd8,0xb4}, {0xc1,0x90,0x64,0x56},
617 {0x84,0x61,0x7b,0xcb}, {0xb6,0x70,0xd5,0x32}, {0x5c,0x74,0x48,0x6c}, {0x57,0x42,0xd0,0xb8}
618 };
619
620 static uint8_t T8[256][4]=
621 {
622 {0xf4,0xa7,0x50,0x51}, {0x41,0x65,0x53,0x7e}, {0x17,0xa4,0xc3,0x1a}, {0x27,0x5e,0x96,0x3a},
623 {0xab,0x6b,0xcb,0x3b}, {0x9d,0x45,0xf1,0x1f}, {0xfa,0x58,0xab,0xac}, {0xe3,0x03,0x93,0x4b},
624 {0x30,0xfa,0x55,0x20}, {0x76,0x6d,0xf6,0xad}, {0xcc,0x76,0x91,0x88}, {0x02,0x4c,0x25,0xf5},
625 {0xe5,0xd7,0xfc,0x4f}, {0x2a,0xcb,0xd7,0xc5}, {0x35,0x44,0x80,0x26}, {0x62,0xa3,0x8f,0xb5},
626 {0xb1,0x5a,0x49,0xde}, {0xba,0x1b,0x67,0x25}, {0xea,0x0e,0x98,0x45}, {0xfe,0xc0,0xe1,0x5d},
627 {0x2f,0x75,0x02,0xc3}, {0x4c,0xf0,0x12,0x81}, {0x46,0x97,0xa3,0x8d}, {0xd3,0xf9,0xc6,0x6b},
628 {0x8f,0x5f,0xe7,0x03}, {0x92,0x9c,0x95,0x15}, {0x6d,0x7a,0xeb,0xbf}, {0x52,0x59,0xda,0x95},
629 {0xbe,0x83,0x2d,0xd4}, {0x74,0x21,0xd3,0x58}, {0xe0,0x69,0x29,0x49}, {0xc9,0xc8,0x44,0x8e},
630 {0xc2,0x89,0x6a,0x75}, {0x8e,0x79,0x78,0xf4}, {0x58,0x3e,0x6b,0x99}, {0xb9,0x71,0xdd,0x27},
631 {0xe1,0x4f,0xb6,0xbe}, {0x88,0xad,0x17,0xf0}, {0x20,0xac,0x66,0xc9}, {0xce,0x3a,0xb4,0x7d},
632 {0xdf,0x4a,0x18,0x63}, {0x1a,0x31,0x82,0xe5}, {0x51,0x33,0x60,0x97}, {0x53,0x7f,0x45,0x62},
633 {0x64,0x77,0xe0,0xb1}, {0x6b,0xae,0x84,0xbb}, {0x81,0xa0,0x1c,0xfe}, {0x08,0x2b,0x94,0xf9},
634 {0x48,0x68,0x58,0x70}, {0x45,0xfd,0x19,0x8f}, {0xde,0x6c,0x87,0x94}, {0x7b,0xf8,0xb7,0x52},
635 {0x73,0xd3,0x23,0xab}, {0x4b,0x02,0xe2,0x72}, {0x1f,0x8f,0x57,0xe3}, {0x55,0xab,0x2a,0x66},
636 {0xeb,0x28,0x07,0xb2}, {0xb5,0xc2,0x03,0x2f}, {0xc5,0x7b,0x9a,0x86}, {0x37,0x08,0xa5,0xd3},
637 {0x28,0x87,0xf2,0x30}, {0xbf,0xa5,0xb2,0x23}, {0x03,0x6a,0xba,0x02}, {0x16,0x82,0x5c,0xed},
638 {0xcf,0x1c,0x2b,0x8a}, {0x79,0xb4,0x92,0xa7}, {0x07,0xf2,0xf0,0xf3}, {0x69,0xe2,0xa1,0x4e},
639 {0xda,0xf4,0xcd,0x65}, {0x05,0xbe,0xd5,0x06}, {0x34,0x62,0x1f,0xd1}, {0xa6,0xfe,0x8a,0xc4},
640 {0x2e,0x53,0x9d,0x34}, {0xf3,0x55,0xa0,0xa2}, {0x8a,0xe1,0x32,0x05}, {0xf6,0xeb,0x75,0xa4},
641 {0x83,0xec,0x39,0x0b}, {0x60,0xef,0xaa,0x40}, {0x71,0x9f,0x06,0x5e}, {0x6e,0x10,0x51,0xbd},
642 {0x21,0x8a,0xf9,0x3e}, {0xdd,0x06,0x3d,0x96}, {0x3e,0x05,0xae,0xdd}, {0xe6,0xbd,0x46,0x4d},
643 {0x54,0x8d,0xb5,0x91}, {0xc4,0x5d,0x05,0x71}, {0x06,0xd4,0x6f,0x04}, {0x50,0x15,0xff,0x60},
644 {0x98,0xfb,0x24,0x19}, {0xbd,0xe9,0x97,0xd6}, {0x40,0x43,0xcc,0x89}, {0xd9,0x9e,0x77,0x67},
645 {0xe8,0x42,0xbd,0xb0}, {0x89,0x8b,0x88,0x07}, {0x19,0x5b,0x38,0xe7}, {0xc8,0xee,0xdb,0x79},
646 {0x7c,0x0a,0x47,0xa1}, {0x42,0x0f,0xe9,0x7c}, {0x84,0x1e,0xc9,0xf8}, {0x00,0x00,0x00,0x00},
647 {0x80,0x86,0x83,0x09}, {0x2b,0xed,0x48,0x32}, {0x11,0x70,0xac,0x1e}, {0x5a,0x72,0x4e,0x6c},
648 {0x0e,0xff,0xfb,0xfd}, {0x85,0x38,0x56,0x0f}, {0xae,0xd5,0x1e,0x3d}, {0x2d,0x39,0x27,0x36},
649 {0x0f,0xd9,0x64,0x0a}, {0x5c,0xa6,0x21,0x68}, {0x5b,0x54,0xd1,0x9b}, {0x36,0x2e,0x3a,0x24},
650 {0x0a,0x67,0xb1,0x0c}, {0x57,0xe7,0x0f,0x93}, {0xee,0x96,0xd2,0xb4}, {0x9b,0x91,0x9e,0x1b},
651 {0xc0,0xc5,0x4f,0x80}, {0xdc,0x20,0xa2,0x61}, {0x77,0x4b,0x69,0x5a}, {0x12,0x1a,0x16,0x1c},
652 {0x93,0xba,0x0a,0xe2}, {0xa0,0x2a,0xe5,0xc0}, {0x22,0xe0,0x43,0x3c}, {0x1b,0x17,0x1d,0x12},
653 {0x09,0x0d,0x0b,0x0e}, {0x8b,0xc7,0xad,0xf2}, {0xb6,0xa8,0xb9,0x2d}, {0x1e,0xa9,0xc8,0x14},
654 {0xf1,0x19,0x85,0x57}, {0x75,0x07,0x4c,0xaf}, {0x99,0xdd,0xbb,0xee}, {0x7f,0x60,0xfd,0xa3},
655 {0x01,0x26,0x9f,0xf7}, {0x72,0xf5,0xbc,0x5c}, {0x66,0x3b,0xc5,0x44}, {0xfb,0x7e,0x34,0x5b},
656 {0x43,0x29,0x76,0x8b}, {0x23,0xc6,0xdc,0xcb}, {0xed,0xfc,0x68,0xb6}, {0xe4,0xf1,0x63,0xb8},
657 {0x31,0xdc,0xca,0xd7}, {0x63,0x85,0x10,0x42}, {0x97,0x22,0x40,0x13}, {0xc6,0x11,0x20,0x84},
658 {0x4a,0x24,0x7d,0x85}, {0xbb,0x3d,0xf8,0xd2}, {0xf9,0x32,0x11,0xae}, {0x29,0xa1,0x6d,0xc7},
659 {0x9e,0x2f,0x4b,0x1d}, {0xb2,0x30,0xf3,0xdc}, {0x86,0x52,0xec,0x0d}, {0xc1,0xe3,0xd0,0x77},
660 {0xb3,0x16,0x6c,0x2b}, {0x70,0xb9,0x99,0xa9}, {0x94,0x48,0xfa,0x11}, {0xe9,0x64,0x22,0x47},
661 {0xfc,0x8c,0xc4,0xa8}, {0xf0,0x3f,0x1a,0xa0}, {0x7d,0x2c,0xd8,0x56}, {0x33,0x90,0xef,0x22},
662 {0x49,0x4e,0xc7,0x87}, {0x38,0xd1,0xc1,0xd9}, {0xca,0xa2,0xfe,0x8c}, {0xd4,0x0b,0x36,0x98},
663 {0xf5,0x81,0xcf,0xa6}, {0x7a,0xde,0x28,0xa5}, {0xb7,0x8e,0x26,0xda}, {0xad,0xbf,0xa4,0x3f},
664 {0x3a,0x9d,0xe4,0x2c}, {0x78,0x92,0x0d,0x50}, {0x5f,0xcc,0x9b,0x6a}, {0x7e,0x46,0x62,0x54},
665 {0x8d,0x13,0xc2,0xf6}, {0xd8,0xb8,0xe8,0x90}, {0x39,0xf7,0x5e,0x2e}, {0xc3,0xaf,0xf5,0x82},
666 {0x5d,0x80,0xbe,0x9f}, {0xd0,0x93,0x7c,0x69}, {0xd5,0x2d,0xa9,0x6f}, {0x25,0x12,0xb3,0xcf},
667 {0xac,0x99,0x3b,0xc8}, {0x18,0x7d,0xa7,0x10}, {0x9c,0x63,0x6e,0xe8}, {0x3b,0xbb,0x7b,0xdb},
668 {0x26,0x78,0x09,0xcd}, {0x59,0x18,0xf4,0x6e}, {0x9a,0xb7,0x01,0xec}, {0x4f,0x9a,0xa8,0x83},
669 {0x95,0x6e,0x65,0xe6}, {0xff,0xe6,0x7e,0xaa}, {0xbc,0xcf,0x08,0x21}, {0x15,0xe8,0xe6,0xef},
670 {0xe7,0x9b,0xd9,0xba}, {0x6f,0x36,0xce,0x4a}, {0x9f,0x09,0xd4,0xea}, {0xb0,0x7c,0xd6,0x29},
671 {0xa4,0xb2,0xaf,0x31}, {0x3f,0x23,0x31,0x2a}, {0xa5,0x94,0x30,0xc6}, {0xa2,0x66,0xc0,0x35},
672 {0x4e,0xbc,0x37,0x74}, {0x82,0xca,0xa6,0xfc}, {0x90,0xd0,0xb0,0xe0}, {0xa7,0xd8,0x15,0x33},
673 {0x04,0x98,0x4a,0xf1}, {0xec,0xda,0xf7,0x41}, {0xcd,0x50,0x0e,0x7f}, {0x91,0xf6,0x2f,0x17},
674 {0x4d,0xd6,0x8d,0x76}, {0xef,0xb0,0x4d,0x43}, {0xaa,0x4d,0x54,0xcc}, {0x96,0x04,0xdf,0xe4},
675 {0xd1,0xb5,0xe3,0x9e}, {0x6a,0x88,0x1b,0x4c}, {0x2c,0x1f,0xb8,0xc1}, {0x65,0x51,0x7f,0x46},
676 {0x5e,0xea,0x04,0x9d}, {0x8c,0x35,0x5d,0x01}, {0x87,0x74,0x73,0xfa}, {0x0b,0x41,0x2e,0xfb},
677 {0x67,0x1d,0x5a,0xb3}, {0xdb,0xd2,0x52,0x92}, {0x10,0x56,0x33,0xe9}, {0xd6,0x47,0x13,0x6d},
678 {0xd7,0x61,0x8c,0x9a}, {0xa1,0x0c,0x7a,0x37}, {0xf8,0x14,0x8e,0x59}, {0x13,0x3c,0x89,0xeb},
679 {0xa9,0x27,0xee,0xce}, {0x61,0xc9,0x35,0xb7}, {0x1c,0xe5,0xed,0xe1}, {0x47,0xb1,0x3c,0x7a},
680 {0xd2,0xdf,0x59,0x9c}, {0xf2,0x73,0x3f,0x55}, {0x14,0xce,0x79,0x18}, {0xc7,0x37,0xbf,0x73},
681 {0xf7,0xcd,0xea,0x53}, {0xfd,0xaa,0x5b,0x5f}, {0x3d,0x6f,0x14,0xdf}, {0x44,0xdb,0x86,0x78},
682 {0xaf,0xf3,0x81,0xca}, {0x68,0xc4,0x3e,0xb9}, {0x24,0x34,0x2c,0x38}, {0xa3,0x40,0x5f,0xc2},
683 {0x1d,0xc3,0x72,0x16}, {0xe2,0x25,0x0c,0xbc}, {0x3c,0x49,0x8b,0x28}, {0x0d,0x95,0x41,0xff},
684 {0xa8,0x01,0x71,0x39}, {0x0c,0xb3,0xde,0x08}, {0xb4,0xe4,0x9c,0xd8}, {0x56,0xc1,0x90,0x64},
685 {0xcb,0x84,0x61,0x7b}, {0x32,0xb6,0x70,0xd5}, {0x6c,0x5c,0x74,0x48}, {0xb8,0x57,0x42,0xd0}
686 };
687
688 static uint8_t S5[256]=
689 {
690 0x52,0x09,0x6a,0xd5,
691 0x30,0x36,0xa5,0x38,
692 0xbf,0x40,0xa3,0x9e,
693 0x81,0xf3,0xd7,0xfb,
694 0x7c,0xe3,0x39,0x82,
695 0x9b,0x2f,0xff,0x87,
696 0x34,0x8e,0x43,0x44,
697 0xc4,0xde,0xe9,0xcb,
698 0x54,0x7b,0x94,0x32,
699 0xa6,0xc2,0x23,0x3d,
700 0xee,0x4c,0x95,0x0b,
701 0x42,0xfa,0xc3,0x4e,
702 0x08,0x2e,0xa1,0x66,
703 0x28,0xd9,0x24,0xb2,
704 0x76,0x5b,0xa2,0x49,
705 0x6d,0x8b,0xd1,0x25,
706 0x72,0xf8,0xf6,0x64,
707 0x86,0x68,0x98,0x16,
708 0xd4,0xa4,0x5c,0xcc,
709 0x5d,0x65,0xb6,0x92,
710 0x6c,0x70,0x48,0x50,
711 0xfd,0xed,0xb9,0xda,
712 0x5e,0x15,0x46,0x57,
713 0xa7,0x8d,0x9d,0x84,
714 0x90,0xd8,0xab,0x00,
715 0x8c,0xbc,0xd3,0x0a,
716 0xf7,0xe4,0x58,0x05,
717 0xb8,0xb3,0x45,0x06,
718 0xd0,0x2c,0x1e,0x8f,
719 0xca,0x3f,0x0f,0x02,
720 0xc1,0xaf,0xbd,0x03,
721 0x01,0x13,0x8a,0x6b,
722 0x3a,0x91,0x11,0x41,
723 0x4f,0x67,0xdc,0xea,
724 0x97,0xf2,0xcf,0xce,
725 0xf0,0xb4,0xe6,0x73,
726 0x96,0xac,0x74,0x22,
727 0xe7,0xad,0x35,0x85,
728 0xe2,0xf9,0x37,0xe8,
729 0x1c,0x75,0xdf,0x6e,
730 0x47,0xf1,0x1a,0x71,
731 0x1d,0x29,0xc5,0x89,
732 0x6f,0xb7,0x62,0x0e,
733 0xaa,0x18,0xbe,0x1b,
734 0xfc,0x56,0x3e,0x4b,
735 0xc6,0xd2,0x79,0x20,
736 0x9a,0xdb,0xc0,0xfe,
737 0x78,0xcd,0x5a,0xf4,
738 0x1f,0xdd,0xa8,0x33,
739 0x88,0x07,0xc7,0x31,
740 0xb1,0x12,0x10,0x59,
741 0x27,0x80,0xec,0x5f,
742 0x60,0x51,0x7f,0xa9,
743 0x19,0xb5,0x4a,0x0d,
744 0x2d,0xe5,0x7a,0x9f,
745 0x93,0xc9,0x9c,0xef,
746 0xa0,0xe0,0x3b,0x4d,
747 0xae,0x2a,0xf5,0xb0,
748 0xc8,0xeb,0xbb,0x3c,
749 0x83,0x53,0x99,0x61,
750 0x17,0x2b,0x04,0x7e,
751 0xba,0x77,0xd6,0x26,
752 0xe1,0x69,0x14,0x63,
753 0x55,0x21,0x0c,0x7d
754 };
755
756 static uint8_t U1[256][4]=
757 {
758 {0x00,0x00,0x00,0x00}, {0x0e,0x09,0x0d,0x0b}, {0x1c,0x12,0x1a,0x16}, {0x12,0x1b,0x17,0x1d},
759 {0x38,0x24,0x34,0x2c}, {0x36,0x2d,0x39,0x27}, {0x24,0x36,0x2e,0x3a}, {0x2a,0x3f,0x23,0x31},
760 {0x70,0x48,0x68,0x58}, {0x7e,0x41,0x65,0x53}, {0x6c,0x5a,0x72,0x4e}, {0x62,0x53,0x7f,0x45},
761 {0x48,0x6c,0x5c,0x74}, {0x46,0x65,0x51,0x7f}, {0x54,0x7e,0x46,0x62}, {0x5a,0x77,0x4b,0x69},
762 {0xe0,0x90,0xd0,0xb0}, {0xee,0x99,0xdd,0xbb}, {0xfc,0x82,0xca,0xa6}, {0xf2,0x8b,0xc7,0xad},
763 {0xd8,0xb4,0xe4,0x9c}, {0xd6,0xbd,0xe9,0x97}, {0xc4,0xa6,0xfe,0x8a}, {0xca,0xaf,0xf3,0x81},
764 {0x90,0xd8,0xb8,0xe8}, {0x9e,0xd1,0xb5,0xe3}, {0x8c,0xca,0xa2,0xfe}, {0x82,0xc3,0xaf,0xf5},
765 {0xa8,0xfc,0x8c,0xc4}, {0xa6,0xf5,0x81,0xcf}, {0xb4,0xee,0x96,0xd2}, {0xba,0xe7,0x9b,0xd9},
766 {0xdb,0x3b,0xbb,0x7b}, {0xd5,0x32,0xb6,0x70}, {0xc7,0x29,0xa1,0x6d}, {0xc9,0x20,0xac,0x66},
767 {0xe3,0x1f,0x8f,0x57}, {0xed,0x16,0x82,0x5c}, {0xff,0x0d,0x95,0x41}, {0xf1,0x04,0x98,0x4a},
768 {0xab,0x73,0xd3,0x23}, {0xa5,0x7a,0xde,0x28}, {0xb7,0x61,0xc9,0x35}, {0xb9,0x68,0xc4,0x3e},
769 {0x93,0x57,0xe7,0x0f}, {0x9d,0x5e,0xea,0x04}, {0x8f,0x45,0xfd,0x19}, {0x81,0x4c,0xf0,0x12},
770 {0x3b,0xab,0x6b,0xcb}, {0x35,0xa2,0x66,0xc0}, {0x27,0xb9,0x71,0xdd}, {0x29,0xb0,0x7c,0xd6},
771 {0x03,0x8f,0x5f,0xe7}, {0x0d,0x86,0x52,0xec}, {0x1f,0x9d,0x45,0xf1}, {0x11,0x94,0x48,0xfa},
772 {0x4b,0xe3,0x03,0x93}, {0x45,0xea,0x0e,0x98}, {0x57,0xf1,0x19,0x85}, {0x59,0xf8,0x14,0x8e},
773 {0x73,0xc7,0x37,0xbf}, {0x7d,0xce,0x3a,0xb4}, {0x6f,0xd5,0x2d,0xa9}, {0x61,0xdc,0x20,0xa2},
774 {0xad,0x76,0x6d,0xf6}, {0xa3,0x7f,0x60,0xfd}, {0xb1,0x64,0x77,0xe0}, {0xbf,0x6d,0x7a,0xeb},
775 {0x95,0x52,0x59,0xda}, {0x9b,0x5b,0x54,0xd1}, {0x89,0x40,0x43,0xcc}, {0x87,0x49,0x4e,0xc7},
776 {0xdd,0x3e,0x05,0xae}, {0xd3,0x37,0x08,0xa5}, {0xc1,0x2c,0x1f,0xb8}, {0xcf,0x25,0x12,0xb3},
777 {0xe5,0x1a,0x31,0x82}, {0xeb,0x13,0x3c,0x89}, {0xf9,0x08,0x2b,0x94}, {0xf7,0x01,0x26,0x9f},
778 {0x4d,0xe6,0xbd,0x46}, {0x43,0xef,0xb0,0x4d}, {0x51,0xf4,0xa7,0x50}, {0x5f,0xfd,0xaa,0x5b},
779 {0x75,0xc2,0x89,0x6a}, {0x7b,0xcb,0x84,0x61}, {0x69,0xd0,0x93,0x7c}, {0x67,0xd9,0x9e,0x77},
780 {0x3d,0xae,0xd5,0x1e}, {0x33,0xa7,0xd8,0x15}, {0x21,0xbc,0xcf,0x08}, {0x2f,0xb5,0xc2,0x03},
781 {0x05,0x8a,0xe1,0x32}, {0x0b,0x83,0xec,0x39}, {0x19,0x98,0xfb,0x24}, {0x17,0x91,0xf6,0x2f},
782 {0x76,0x4d,0xd6,0x8d}, {0x78,0x44,0xdb,0x86}, {0x6a,0x5f,0xcc,0x9b}, {0x64,0x56,0xc1,0x90},
783 {0x4e,0x69,0xe2,0xa1}, {0x40,0x60,0xef,0xaa}, {0x52,0x7b,0xf8,0xb7}, {0x5c,0x72,0xf5,0xbc},
784 {0x06,0x05,0xbe,0xd5}, {0x08,0x0c,0xb3,0xde}, {0x1a,0x17,0xa4,0xc3}, {0x14,0x1e,0xa9,0xc8},
785 {0x3e,0x21,0x8a,0xf9}, {0x30,0x28,0x87,0xf2}, {0x22,0x33,0x90,0xef}, {0x2c,0x3a,0x9d,0xe4},
786 {0x96,0xdd,0x06,0x3d}, {0x98,0xd4,0x0b,0x36}, {0x8a,0xcf,0x1c,0x2b}, {0x84,0xc6,0x11,0x20},
787 {0xae,0xf9,0x32,0x11}, {0xa0,0xf0,0x3f,0x1a}, {0xb2,0xeb,0x28,0x07}, {0xbc,0xe2,0x25,0x0c},
788 {0xe6,0x95,0x6e,0x65}, {0xe8,0x9c,0x63,0x6e}, {0xfa,0x87,0x74,0x73}, {0xf4,0x8e,0x79,0x78},
789 {0xde,0xb1,0x5a,0x49}, {0xd0,0xb8,0x57,0x42}, {0xc2,0xa3,0x40,0x5f}, {0xcc,0xaa,0x4d,0x54},
790 {0x41,0xec,0xda,0xf7}, {0x4f,0xe5,0xd7,0xfc}, {0x5d,0xfe,0xc0,0xe1}, {0x53,0xf7,0xcd,0xea},
791 {0x79,0xc8,0xee,0xdb}, {0x77,0xc1,0xe3,0xd0}, {0x65,0xda,0xf4,0xcd}, {0x6b,0xd3,0xf9,0xc6},
792 {0x31,0xa4,0xb2,0xaf}, {0x3f,0xad,0xbf,0xa4}, {0x2d,0xb6,0xa8,0xb9}, {0x23,0xbf,0xa5,0xb2},
793 {0x09,0x80,0x86,0x83}, {0x07,0x89,0x8b,0x88}, {0x15,0x92,0x9c,0x95}, {0x1b,0x9b,0x91,0x9e},
794 {0xa1,0x7c,0x0a,0x47}, {0xaf,0x75,0x07,0x4c}, {0xbd,0x6e,0x10,0x51}, {0xb3,0x67,0x1d,0x5a},
795 {0x99,0x58,0x3e,0x6b}, {0x97,0x51,0x33,0x60}, {0x85,0x4a,0x24,0x7d}, {0x8b,0x43,0x29,0x76},
796 {0xd1,0x34,0x62,0x1f}, {0xdf,0x3d,0x6f,0x14}, {0xcd,0x26,0x78,0x09}, {0xc3,0x2f,0x75,0x02},
797 {0xe9,0x10,0x56,0x33}, {0xe7,0x19,0x5b,0x38}, {0xf5,0x02,0x4c,0x25}, {0xfb,0x0b,0x41,0x2e},
798 {0x9a,0xd7,0x61,0x8c}, {0x94,0xde,0x6c,0x87}, {0x86,0xc5,0x7b,0x9a}, {0x88,0xcc,0x76,0x91},
799 {0xa2,0xf3,0x55,0xa0}, {0xac,0xfa,0x58,0xab}, {0xbe,0xe1,0x4f,0xb6}, {0xb0,0xe8,0x42,0xbd},
800 {0xea,0x9f,0x09,0xd4}, {0xe4,0x96,0x04,0xdf}, {0xf6,0x8d,0x13,0xc2}, {0xf8,0x84,0x1e,0xc9},
801 {0xd2,0xbb,0x3d,0xf8}, {0xdc,0xb2,0x30,0xf3}, {0xce,0xa9,0x27,0xee}, {0xc0,0xa0,0x2a,0xe5},
802 {0x7a,0x47,0xb1,0x3c}, {0x74,0x4e,0xbc,0x37}, {0x66,0x55,0xab,0x2a}, {0x68,0x5c,0xa6,0x21},
803 {0x42,0x63,0x85,0x10}, {0x4c,0x6a,0x88,0x1b}, {0x5e,0x71,0x9f,0x06}, {0x50,0x78,0x92,0x0d},
804 {0x0a,0x0f,0xd9,0x64}, {0x04,0x06,0xd4,0x6f}, {0x16,0x1d,0xc3,0x72}, {0x18,0x14,0xce,0x79},
805 {0x32,0x2b,0xed,0x48}, {0x3c,0x22,0xe0,0x43}, {0x2e,0x39,0xf7,0x5e}, {0x20,0x30,0xfa,0x55},
806 {0xec,0x9a,0xb7,0x01}, {0xe2,0x93,0xba,0x0a}, {0xf0,0x88,0xad,0x17}, {0xfe,0x81,0xa0,0x1c},
807 {0xd4,0xbe,0x83,0x2d}, {0xda,0xb7,0x8e,0x26}, {0xc8,0xac,0x99,0x3b}, {0xc6,0xa5,0x94,0x30},
808 {0x9c,0xd2,0xdf,0x59}, {0x92,0xdb,0xd2,0x52}, {0x80,0xc0,0xc5,0x4f}, {0x8e,0xc9,0xc8,0x44},
809 {0xa4,0xf6,0xeb,0x75}, {0xaa,0xff,0xe6,0x7e}, {0xb8,0xe4,0xf1,0x63}, {0xb6,0xed,0xfc,0x68},
810 {0x0c,0x0a,0x67,0xb1}, {0x02,0x03,0x6a,0xba}, {0x10,0x18,0x7d,0xa7}, {0x1e,0x11,0x70,0xac},
811 {0x34,0x2e,0x53,0x9d}, {0x3a,0x27,0x5e,0x96}, {0x28,0x3c,0x49,0x8b}, {0x26,0x35,0x44,0x80},
812 {0x7c,0x42,0x0f,0xe9}, {0x72,0x4b,0x02,0xe2}, {0x60,0x50,0x15,0xff}, {0x6e,0x59,0x18,0xf4},
813 {0x44,0x66,0x3b,0xc5}, {0x4a,0x6f,0x36,0xce}, {0x58,0x74,0x21,0xd3}, {0x56,0x7d,0x2c,0xd8},
814 {0x37,0xa1,0x0c,0x7a}, {0x39,0xa8,0x01,0x71}, {0x2b,0xb3,0x16,0x6c}, {0x25,0xba,0x1b,0x67},
815 {0x0f,0x85,0x38,0x56}, {0x01,0x8c,0x35,0x5d}, {0x13,0x97,0x22,0x40}, {0x1d,0x9e,0x2f,0x4b},
816 {0x47,0xe9,0x64,0x22}, {0x49,0xe0,0x69,0x29}, {0x5b,0xfb,0x7e,0x34}, {0x55,0xf2,0x73,0x3f},
817 {0x7f,0xcd,0x50,0x0e}, {0x71,0xc4,0x5d,0x05}, {0x63,0xdf,0x4a,0x18}, {0x6d,0xd6,0x47,0x13},
818 {0xd7,0x31,0xdc,0xca}, {0xd9,0x38,0xd1,0xc1}, {0xcb,0x23,0xc6,0xdc}, {0xc5,0x2a,0xcb,0xd7},
819 {0xef,0x15,0xe8,0xe6}, {0xe1,0x1c,0xe5,0xed}, {0xf3,0x07,0xf2,0xf0}, {0xfd,0x0e,0xff,0xfb},
820 {0xa7,0x79,0xb4,0x92}, {0xa9,0x70,0xb9,0x99}, {0xbb,0x6b,0xae,0x84}, {0xb5,0x62,0xa3,0x8f},
821 {0x9f,0x5d,0x80,0xbe}, {0x91,0x54,0x8d,0xb5}, {0x83,0x4f,0x9a,0xa8}, {0x8d,0x46,0x97,0xa3}
822 };
823
824 static uint8_t U2[256][4]=
825 {
826 {0x00,0x00,0x00,0x00}, {0x0b,0x0e,0x09,0x0d}, {0x16,0x1c,0x12,0x1a}, {0x1d,0x12,0x1b,0x17},
827 {0x2c,0x38,0x24,0x34}, {0x27,0x36,0x2d,0x39}, {0x3a,0x24,0x36,0x2e}, {0x31,0x2a,0x3f,0x23},
828 {0x58,0x70,0x48,0x68}, {0x53,0x7e,0x41,0x65}, {0x4e,0x6c,0x5a,0x72}, {0x45,0x62,0x53,0x7f},
829 {0x74,0x48,0x6c,0x5c}, {0x7f,0x46,0x65,0x51}, {0x62,0x54,0x7e,0x46}, {0x69,0x5a,0x77,0x4b},
830 {0xb0,0xe0,0x90,0xd0}, {0xbb,0xee,0x99,0xdd}, {0xa6,0xfc,0x82,0xca}, {0xad,0xf2,0x8b,0xc7},
831 {0x9c,0xd8,0xb4,0xe4}, {0x97,0xd6,0xbd,0xe9}, {0x8a,0xc4,0xa6,0xfe}, {0x81,0xca,0xaf,0xf3},
832 {0xe8,0x90,0xd8,0xb8}, {0xe3,0x9e,0xd1,0xb5}, {0xfe,0x8c,0xca,0xa2}, {0xf5,0x82,0xc3,0xaf},
833 {0xc4,0xa8,0xfc,0x8c}, {0xcf,0xa6,0xf5,0x81}, {0xd2,0xb4,0xee,0x96}, {0xd9,0xba,0xe7,0x9b},
834 {0x7b,0xdb,0x3b,0xbb}, {0x70,0xd5,0x32,0xb6}, {0x6d,0xc7,0x29,0xa1}, {0x66,0xc9,0x20,0xac},
835 {0x57,0xe3,0x1f,0x8f}, {0x5c,0xed,0x16,0x82}, {0x41,0xff,0x0d,0x95}, {0x4a,0xf1,0x04,0x98},
836 {0x23,0xab,0x73,0xd3}, {0x28,0xa5,0x7a,0xde}, {0x35,0xb7,0x61,0xc9}, {0x3e,0xb9,0x68,0xc4},
837 {0x0f,0x93,0x57,0xe7}, {0x04,0x9d,0x5e,0xea}, {0x19,0x8f,0x45,0xfd}, {0x12,0x81,0x4c,0xf0},
838 {0xcb,0x3b,0xab,0x6b}, {0xc0,0x35,0xa2,0x66}, {0xdd,0x27,0xb9,0x71}, {0xd6,0x29,0xb0,0x7c},
839 {0xe7,0x03,0x8f,0x5f}, {0xec,0x0d,0x86,0x52}, {0xf1,0x1f,0x9d,0x45}, {0xfa,0x11,0x94,0x48},
840 {0x93,0x4b,0xe3,0x03}, {0x98,0x45,0xea,0x0e}, {0x85,0x57,0xf1,0x19}, {0x8e,0x59,0xf8,0x14},
841 {0xbf,0x73,0xc7,0x37}, {0xb4,0x7d,0xce,0x3a}, {0xa9,0x6f,0xd5,0x2d}, {0xa2,0x61,0xdc,0x20},
842 {0xf6,0xad,0x76,0x6d}, {0xfd,0xa3,0x7f,0x60}, {0xe0,0xb1,0x64,0x77}, {0xeb,0xbf,0x6d,0x7a},
843 {0xda,0x95,0x52,0x59}, {0xd1,0x9b,0x5b,0x54}, {0xcc,0x89,0x40,0x43}, {0xc7,0x87,0x49,0x4e},
844 {0xae,0xdd,0x3e,0x05}, {0xa5,0xd3,0x37,0x08}, {0xb8,0xc1,0x2c,0x1f}, {0xb3,0xcf,0x25,0x12},
845 {0x82,0xe5,0x1a,0x31}, {0x89,0xeb,0x13,0x3c}, {0x94,0xf9,0x08,0x2b}, {0x9f,0xf7,0x01,0x26},
846 {0x46,0x4d,0xe6,0xbd}, {0x4d,0x43,0xef,0xb0}, {0x50,0x51,0xf4,0xa7}, {0x5b,0x5f,0xfd,0xaa},
847 {0x6a,0x75,0xc2,0x89}, {0x61,0x7b,0xcb,0x84}, {0x7c,0x69,0xd0,0x93}, {0x77,0x67,0xd9,0x9e},
848 {0x1e,0x3d,0xae,0xd5}, {0x15,0x33,0xa7,0xd8}, {0x08,0x21,0xbc,0xcf}, {0x03,0x2f,0xb5,0xc2},
849 {0x32,0x05,0x8a,0xe1}, {0x39,0x0b,0x83,0xec}, {0x24,0x19,0x98,0xfb}, {0x2f,0x17,0x91,0xf6},
850 {0x8d,0x76,0x4d,0xd6}, {0x86,0x78,0x44,0xdb}, {0x9b,0x6a,0x5f,0xcc}, {0x90,0x64,0x56,0xc1},
851 {0xa1,0x4e,0x69,0xe2}, {0xaa,0x40,0x60,0xef}, {0xb7,0x52,0x7b,0xf8}, {0xbc,0x5c,0x72,0xf5},
852 {0xd5,0x06,0x05,0xbe}, {0xde,0x08,0x0c,0xb3}, {0xc3,0x1a,0x17,0xa4}, {0xc8,0x14,0x1e,0xa9},
853 {0xf9,0x3e,0x21,0x8a}, {0xf2,0x30,0x28,0x87}, {0xef,0x22,0x33,0x90}, {0xe4,0x2c,0x3a,0x9d},
854 {0x3d,0x96,0xdd,0x06}, {0x36,0x98,0xd4,0x0b}, {0x2b,0x8a,0xcf,0x1c}, {0x20,0x84,0xc6,0x11},
855 {0x11,0xae,0xf9,0x32}, {0x1a,0xa0,0xf0,0x3f}, {0x07,0xb2,0xeb,0x28}, {0x0c,0xbc,0xe2,0x25},
856 {0x65,0xe6,0x95,0x6e}, {0x6e,0xe8,0x9c,0x63}, {0x73,0xfa,0x87,0x74}, {0x78,0xf4,0x8e,0x79},
857 {0x49,0xde,0xb1,0x5a}, {0x42,0xd0,0xb8,0x57}, {0x5f,0xc2,0xa3,0x40}, {0x54,0xcc,0xaa,0x4d},
858 {0xf7,0x41,0xec,0xda}, {0xfc,0x4f,0xe5,0xd7}, {0xe1,0x5d,0xfe,0xc0}, {0xea,0x53,0xf7,0xcd},
859 {0xdb,0x79,0xc8,0xee}, {0xd0,0x77,0xc1,0xe3}, {0xcd,0x65,0xda,0xf4}, {0xc6,0x6b,0xd3,0xf9},
860 {0xaf,0x31,0xa4,0xb2}, {0xa4,0x3f,0xad,0xbf}, {0xb9,0x2d,0xb6,0xa8}, {0xb2,0x23,0xbf,0xa5},
861 {0x83,0x09,0x80,0x86}, {0x88,0x07,0x89,0x8b}, {0x95,0x15,0x92,0x9c}, {0x9e,0x1b,0x9b,0x91},
862 {0x47,0xa1,0x7c,0x0a}, {0x4c,0xaf,0x75,0x07}, {0x51,0xbd,0x6e,0x10}, {0x5a,0xb3,0x67,0x1d},
863 {0x6b,0x99,0x58,0x3e}, {0x60,0x97,0x51,0x33}, {0x7d,0x85,0x4a,0x24}, {0x76,0x8b,0x43,0x29},
864 {0x1f,0xd1,0x34,0x62}, {0x14,0xdf,0x3d,0x6f}, {0x09,0xcd,0x26,0x78}, {0x02,0xc3,0x2f,0x75},
865 {0x33,0xe9,0x10,0x56}, {0x38,0xe7,0x19,0x5b}, {0x25,0xf5,0x02,0x4c}, {0x2e,0xfb,0x0b,0x41},
866 {0x8c,0x9a,0xd7,0x61}, {0x87,0x94,0xde,0x6c}, {0x9a,0x86,0xc5,0x7b}, {0x91,0x88,0xcc,0x76},
867 {0xa0,0xa2,0xf3,0x55}, {0xab,0xac,0xfa,0x58}, {0xb6,0xbe,0xe1,0x4f}, {0xbd,0xb0,0xe8,0x42},
868 {0xd4,0xea,0x9f,0x09}, {0xdf,0xe4,0x96,0x04}, {0xc2,0xf6,0x8d,0x13}, {0xc9,0xf8,0x84,0x1e},
869 {0xf8,0xd2,0xbb,0x3d}, {0xf3,0xdc,0xb2,0x30}, {0xee,0xce,0xa9,0x27}, {0xe5,0xc0,0xa0,0x2a},
870 {0x3c,0x7a,0x47,0xb1}, {0x37,0x74,0x4e,0xbc}, {0x2a,0x66,0x55,0xab}, {0x21,0x68,0x5c,0xa6},
871 {0x10,0x42,0x63,0x85}, {0x1b,0x4c,0x6a,0x88}, {0x06,0x5e,0x71,0x9f}, {0x0d,0x50,0x78,0x92},
872 {0x64,0x0a,0x0f,0xd9}, {0x6f,0x04,0x06,0xd4}, {0x72,0x16,0x1d,0xc3}, {0x79,0x18,0x14,0xce},
873 {0x48,0x32,0x2b,0xed}, {0x43,0x3c,0x22,0xe0}, {0x5e,0x2e,0x39,0xf7}, {0x55,0x20,0x30,0xfa},
874 {0x01,0xec,0x9a,0xb7}, {0x0a,0xe2,0x93,0xba}, {0x17,0xf0,0x88,0xad}, {0x1c,0xfe,0x81,0xa0},
875 {0x2d,0xd4,0xbe,0x83}, {0x26,0xda,0xb7,0x8e}, {0x3b,0xc8,0xac,0x99}, {0x30,0xc6,0xa5,0x94},
876 {0x59,0x9c,0xd2,0xdf}, {0x52,0x92,0xdb,0xd2}, {0x4f,0x80,0xc0,0xc5}, {0x44,0x8e,0xc9,0xc8},
877 {0x75,0xa4,0xf6,0xeb}, {0x7e,0xaa,0xff,0xe6}, {0x63,0xb8,0xe4,0xf1}, {0x68,0xb6,0xed,0xfc},
878 {0xb1,0x0c,0x0a,0x67}, {0xba,0x02,0x03,0x6a}, {0xa7,0x10,0x18,0x7d}, {0xac,0x1e,0x11,0x70},
879 {0x9d,0x34,0x2e,0x53}, {0x96,0x3a,0x27,0x5e}, {0x8b,0x28,0x3c,0x49}, {0x80,0x26,0x35,0x44},
880 {0xe9,0x7c,0x42,0x0f}, {0xe2,0x72,0x4b,0x02}, {0xff,0x60,0x50,0x15}, {0xf4,0x6e,0x59,0x18},
881 {0xc5,0x44,0x66,0x3b}, {0xce,0x4a,0x6f,0x36}, {0xd3,0x58,0x74,0x21}, {0xd8,0x56,0x7d,0x2c},
882 {0x7a,0x37,0xa1,0x0c}, {0x71,0x39,0xa8,0x01}, {0x6c,0x2b,0xb3,0x16}, {0x67,0x25,0xba,0x1b},
883 {0x56,0x0f,0x85,0x38}, {0x5d,0x01,0x8c,0x35}, {0x40,0x13,0x97,0x22}, {0x4b,0x1d,0x9e,0x2f},
884 {0x22,0x47,0xe9,0x64}, {0x29,0x49,0xe0,0x69}, {0x34,0x5b,0xfb,0x7e}, {0x3f,0x55,0xf2,0x73},
885 {0x0e,0x7f,0xcd,0x50}, {0x05,0x71,0xc4,0x5d}, {0x18,0x63,0xdf,0x4a}, {0x13,0x6d,0xd6,0x47},
886 {0xca,0xd7,0x31,0xdc}, {0xc1,0xd9,0x38,0xd1}, {0xdc,0xcb,0x23,0xc6}, {0xd7,0xc5,0x2a,0xcb},
887 {0xe6,0xef,0x15,0xe8}, {0xed,0xe1,0x1c,0xe5}, {0xf0,0xf3,0x07,0xf2}, {0xfb,0xfd,0x0e,0xff},
888 {0x92,0xa7,0x79,0xb4}, {0x99,0xa9,0x70,0xb9}, {0x84,0xbb,0x6b,0xae}, {0x8f,0xb5,0x62,0xa3},
889 {0xbe,0x9f,0x5d,0x80}, {0xb5,0x91,0x54,0x8d}, {0xa8,0x83,0x4f,0x9a}, {0xa3,0x8d,0x46,0x97}
890 };
891
892 static uint8_t U3[256][4]=
893 {
894 {0x00,0x00,0x00,0x00}, {0x0d,0x0b,0x0e,0x09}, {0x1a,0x16,0x1c,0x12}, {0x17,0x1d,0x12,0x1b},
895 {0x34,0x2c,0x38,0x24}, {0x39,0x27,0x36,0x2d}, {0x2e,0x3a,0x24,0x36}, {0x23,0x31,0x2a,0x3f},
896 {0x68,0x58,0x70,0x48}, {0x65,0x53,0x7e,0x41}, {0x72,0x4e,0x6c,0x5a}, {0x7f,0x45,0x62,0x53},
897 {0x5c,0x74,0x48,0x6c}, {0x51,0x7f,0x46,0x65}, {0x46,0x62,0x54,0x7e}, {0x4b,0x69,0x5a,0x77},
898 {0xd0,0xb0,0xe0,0x90}, {0xdd,0xbb,0xee,0x99}, {0xca,0xa6,0xfc,0x82}, {0xc7,0xad,0xf2,0x8b},
899 {0xe4,0x9c,0xd8,0xb4}, {0xe9,0x97,0xd6,0xbd}, {0xfe,0x8a,0xc4,0xa6}, {0xf3,0x81,0xca,0xaf},
900 {0xb8,0xe8,0x90,0xd8}, {0xb5,0xe3,0x9e,0xd1}, {0xa2,0xfe,0x8c,0xca}, {0xaf,0xf5,0x82,0xc3},
901 {0x8c,0xc4,0xa8,0xfc}, {0x81,0xcf,0xa6,0xf5}, {0x96,0xd2,0xb4,0xee}, {0x9b,0xd9,0xba,0xe7},
902 {0xbb,0x7b,0xdb,0x3b}, {0xb6,0x70,0xd5,0x32}, {0xa1,0x6d,0xc7,0x29}, {0xac,0x66,0xc9,0x20},
903 {0x8f,0x57,0xe3,0x1f}, {0x82,0x5c,0xed,0x16}, {0x95,0x41,0xff,0x0d}, {0x98,0x4a,0xf1,0x04},
904 {0xd3,0x23,0xab,0x73}, {0xde,0x28,0xa5,0x7a}, {0xc9,0x35,0xb7,0x61}, {0xc4,0x3e,0xb9,0x68},
905 {0xe7,0x0f,0x93,0x57}, {0xea,0x04,0x9d,0x5e}, {0xfd,0x19,0x8f,0x45}, {0xf0,0x12,0x81,0x4c},
906 {0x6b,0xcb,0x3b,0xab}, {0x66,0xc0,0x35,0xa2}, {0x71,0xdd,0x27,0xb9}, {0x7c,0xd6,0x29,0xb0},
907 {0x5f,0xe7,0x03,0x8f}, {0x52,0xec,0x0d,0x86}, {0x45,0xf1,0x1f,0x9d}, {0x48,0xfa,0x11,0x94},
908 {0x03,0x93,0x4b,0xe3}, {0x0e,0x98,0x45,0xea}, {0x19,0x85,0x57,0xf1}, {0x14,0x8e,0x59,0xf8},
909 {0x37,0xbf,0x73,0xc7}, {0x3a,0xb4,0x7d,0xce}, {0x2d,0xa9,0x6f,0xd5}, {0x20,0xa2,0x61,0xdc},
910 {0x6d,0xf6,0xad,0x76}, {0x60,0xfd,0xa3,0x7f}, {0x77,0xe0,0xb1,0x64}, {0x7a,0xeb,0xbf,0x6d},
911 {0x59,0xda,0x95,0x52}, {0x54,0xd1,0x9b,0x5b}, {0x43,0xcc,0x89,0x40}, {0x4e,0xc7,0x87,0x49},
912 {0x05,0xae,0xdd,0x3e}, {0x08,0xa5,0xd3,0x37}, {0x1f,0xb8,0xc1,0x2c}, {0x12,0xb3,0xcf,0x25},
913 {0x31,0x82,0xe5,0x1a}, {0x3c,0x89,0xeb,0x13}, {0x2b,0x94,0xf9,0x08}, {0x26,0x9f,0xf7,0x01},
914 {0xbd,0x46,0x4d,0xe6}, {0xb0,0x4d,0x43,0xef}, {0xa7,0x50,0x51,0xf4}, {0xaa,0x5b,0x5f,0xfd},
915 {0x89,0x6a,0x75,0xc2}, {0x84,0x61,0x7b,0xcb}, {0x93,0x7c,0x69,0xd0}, {0x9e,0x77,0x67,0xd9},
916 {0xd5,0x1e,0x3d,0xae}, {0xd8,0x15,0x33,0xa7}, {0xcf,0x08,0x21,0xbc}, {0xc2,0x03,0x2f,0xb5},
917 {0xe1,0x32,0x05,0x8a}, {0xec,0x39,0x0b,0x83}, {0xfb,0x24,0x19,0x98}, {0xf6,0x2f,0x17,0x91},
918 {0xd6,0x8d,0x76,0x4d}, {0xdb,0x86,0x78,0x44}, {0xcc,0x9b,0x6a,0x5f}, {0xc1,0x90,0x64,0x56},
919 {0xe2,0xa1,0x4e,0x69}, {0xef,0xaa,0x40,0x60}, {0xf8,0xb7,0x52,0x7b}, {0xf5,0xbc,0x5c,0x72},
920 {0xbe,0xd5,0x06,0x05}, {0xb3,0xde,0x08,0x0c}, {0xa4,0xc3,0x1a,0x17}, {0xa9,0xc8,0x14,0x1e},
921 {0x8a,0xf9,0x3e,0x21}, {0x87,0xf2,0x30,0x28}, {0x90,0xef,0x22,0x33}, {0x9d,0xe4,0x2c,0x3a},
922 {0x06,0x3d,0x96,0xdd}, {0x0b,0x36,0x98,0xd4}, {0x1c,0x2b,0x8a,0xcf}, {0x11,0x20,0x84,0xc6},
923 {0x32,0x11,0xae,0xf9}, {0x3f,0x1a,0xa0,0xf0}, {0x28,0x07,0xb2,0xeb}, {0x25,0x0c,0xbc,0xe2},
924 {0x6e,0x65,0xe6,0x95}, {0x63,0x6e,0xe8,0x9c}, {0x74,0x73,0xfa,0x87}, {0x79,0x78,0xf4,0x8e},
925 {0x5a,0x49,0xde,0xb1}, {0x57,0x42,0xd0,0xb8}, {0x40,0x5f,0xc2,0xa3}, {0x4d,0x54,0xcc,0xaa},
926 {0xda,0xf7,0x41,0xec}, {0xd7,0xfc,0x4f,0xe5}, {0xc0,0xe1,0x5d,0xfe}, {0xcd,0xea,0x53,0xf7},
927 {0xee,0xdb,0x79,0xc8}, {0xe3,0xd0,0x77,0xc1}, {0xf4,0xcd,0x65,0xda}, {0xf9,0xc6,0x6b,0xd3},
928 {0xb2,0xaf,0x31,0xa4}, {0xbf,0xa4,0x3f,0xad}, {0xa8,0xb9,0x2d,0xb6}, {0xa5,0xb2,0x23,0xbf},
929 {0x86,0x83,0x09,0x80}, {0x8b,0x88,0x07,0x89}, {0x9c,0x95,0x15,0x92}, {0x91,0x9e,0x1b,0x9b},
930 {0x0a,0x47,0xa1,0x7c}, {0x07,0x4c,0xaf,0x75}, {0x10,0x51,0xbd,0x6e}, {0x1d,0x5a,0xb3,0x67},
931 {0x3e,0x6b,0x99,0x58}, {0x33,0x60,0x97,0x51}, {0x24,0x7d,0x85,0x4a}, {0x29,0x76,0x8b,0x43},
932 {0x62,0x1f,0xd1,0x34}, {0x6f,0x14,0xdf,0x3d}, {0x78,0x09,0xcd,0x26}, {0x75,0x02,0xc3,0x2f},
933 {0x56,0x33,0xe9,0x10}, {0x5b,0x38,0xe7,0x19}, {0x4c,0x25,0xf5,0x02}, {0x41,0x2e,0xfb,0x0b},
934 {0x61,0x8c,0x9a,0xd7}, {0x6c,0x87,0x94,0xde}, {0x7b,0x9a,0x86,0xc5}, {0x76,0x91,0x88,0xcc},
935 {0x55,0xa0,0xa2,0xf3}, {0x58,0xab,0xac,0xfa}, {0x4f,0xb6,0xbe,0xe1}, {0x42,0xbd,0xb0,0xe8},
936 {0x09,0xd4,0xea,0x9f}, {0x04,0xdf,0xe4,0x96}, {0x13,0xc2,0xf6,0x8d}, {0x1e,0xc9,0xf8,0x84},
937 {0x3d,0xf8,0xd2,0xbb}, {0x30,0xf3,0xdc,0xb2}, {0x27,0xee,0xce,0xa9}, {0x2a,0xe5,0xc0,0xa0},
938 {0xb1,0x3c,0x7a,0x47}, {0xbc,0x37,0x74,0x4e}, {0xab,0x2a,0x66,0x55}, {0xa6,0x21,0x68,0x5c},
939 {0x85,0x10,0x42,0x63}, {0x88,0x1b,0x4c,0x6a}, {0x9f,0x06,0x5e,0x71}, {0x92,0x0d,0x50,0x78},
940 {0xd9,0x64,0x0a,0x0f}, {0xd4,0x6f,0x04,0x06}, {0xc3,0x72,0x16,0x1d}, {0xce,0x79,0x18,0x14},
941 {0xed,0x48,0x32,0x2b}, {0xe0,0x43,0x3c,0x22}, {0xf7,0x5e,0x2e,0x39}, {0xfa,0x55,0x20,0x30},
942 {0xb7,0x01,0xec,0x9a}, {0xba,0x0a,0xe2,0x93}, {0xad,0x17,0xf0,0x88}, {0xa0,0x1c,0xfe,0x81},
943 {0x83,0x2d,0xd4,0xbe}, {0x8e,0x26,0xda,0xb7}, {0x99,0x3b,0xc8,0xac}, {0x94,0x30,0xc6,0xa5},
944 {0xdf,0x59,0x9c,0xd2}, {0xd2,0x52,0x92,0xdb}, {0xc5,0x4f,0x80,0xc0}, {0xc8,0x44,0x8e,0xc9},
945 {0xeb,0x75,0xa4,0xf6}, {0xe6,0x7e,0xaa,0xff}, {0xf1,0x63,0xb8,0xe4}, {0xfc,0x68,0xb6,0xed},
946 {0x67,0xb1,0x0c,0x0a}, {0x6a,0xba,0x02,0x03}, {0x7d,0xa7,0x10,0x18}, {0x70,0xac,0x1e,0x11},
947 {0x53,0x9d,0x34,0x2e}, {0x5e,0x96,0x3a,0x27}, {0x49,0x8b,0x28,0x3c}, {0x44,0x80,0x26,0x35},
948 {0x0f,0xe9,0x7c,0x42}, {0x02,0xe2,0x72,0x4b}, {0x15,0xff,0x60,0x50}, {0x18,0xf4,0x6e,0x59},
949 {0x3b,0xc5,0x44,0x66}, {0x36,0xce,0x4a,0x6f}, {0x21,0xd3,0x58,0x74}, {0x2c,0xd8,0x56,0x7d},
950 {0x0c,0x7a,0x37,0xa1}, {0x01,0x71,0x39,0xa8}, {0x16,0x6c,0x2b,0xb3}, {0x1b,0x67,0x25,0xba},
951 {0x38,0x56,0x0f,0x85}, {0x35,0x5d,0x01,0x8c}, {0x22,0x40,0x13,0x97}, {0x2f,0x4b,0x1d,0x9e},
952 {0x64,0x22,0x47,0xe9}, {0x69,0x29,0x49,0xe0}, {0x7e,0x34,0x5b,0xfb}, {0x73,0x3f,0x55,0xf2},
953 {0x50,0x0e,0x7f,0xcd}, {0x5d,0x05,0x71,0xc4}, {0x4a,0x18,0x63,0xdf}, {0x47,0x13,0x6d,0xd6},
954 {0xdc,0xca,0xd7,0x31}, {0xd1,0xc1,0xd9,0x38}, {0xc6,0xdc,0xcb,0x23}, {0xcb,0xd7,0xc5,0x2a},
955 {0xe8,0xe6,0xef,0x15}, {0xe5,0xed,0xe1,0x1c}, {0xf2,0xf0,0xf3,0x07}, {0xff,0xfb,0xfd,0x0e},
956 {0xb4,0x92,0xa7,0x79}, {0xb9,0x99,0xa9,0x70}, {0xae,0x84,0xbb,0x6b}, {0xa3,0x8f,0xb5,0x62},
957 {0x80,0xbe,0x9f,0x5d}, {0x8d,0xb5,0x91,0x54}, {0x9a,0xa8,0x83,0x4f}, {0x97,0xa3,0x8d,0x46}
958 };
959
960 static uint8_t U4[256][4]=
961 {
962 {0x00,0x00,0x00,0x00}, {0x09,0x0d,0x0b,0x0e}, {0x12,0x1a,0x16,0x1c}, {0x1b,0x17,0x1d,0x12},
963 {0x24,0x34,0x2c,0x38}, {0x2d,0x39,0x27,0x36}, {0x36,0x2e,0x3a,0x24}, {0x3f,0x23,0x31,0x2a},
964 {0x48,0x68,0x58,0x70}, {0x41,0x65,0x53,0x7e}, {0x5a,0x72,0x4e,0x6c}, {0x53,0x7f,0x45,0x62},
965 {0x6c,0x5c,0x74,0x48}, {0x65,0x51,0x7f,0x46}, {0x7e,0x46,0x62,0x54}, {0x77,0x4b,0x69,0x5a},
966 {0x90,0xd0,0xb0,0xe0}, {0x99,0xdd,0xbb,0xee}, {0x82,0xca,0xa6,0xfc}, {0x8b,0xc7,0xad,0xf2},
967 {0xb4,0xe4,0x9c,0xd8}, {0xbd,0xe9,0x97,0xd6}, {0xa6,0xfe,0x8a,0xc4}, {0xaf,0xf3,0x81,0xca},
968 {0xd8,0xb8,0xe8,0x90}, {0xd1,0xb5,0xe3,0x9e}, {0xca,0xa2,0xfe,0x8c}, {0xc3,0xaf,0xf5,0x82},
969 {0xfc,0x8c,0xc4,0xa8}, {0xf5,0x81,0xcf,0xa6}, {0xee,0x96,0xd2,0xb4}, {0xe7,0x9b,0xd9,0xba},
970 {0x3b,0xbb,0x7b,0xdb}, {0x32,0xb6,0x70,0xd5}, {0x29,0xa1,0x6d,0xc7}, {0x20,0xac,0x66,0xc9},
971 {0x1f,0x8f,0x57,0xe3}, {0x16,0x82,0x5c,0xed}, {0x0d,0x95,0x41,0xff}, {0x04,0x98,0x4a,0xf1},
972 {0x73,0xd3,0x23,0xab}, {0x7a,0xde,0x28,0xa5}, {0x61,0xc9,0x35,0xb7}, {0x68,0xc4,0x3e,0xb9},
973 {0x57,0xe7,0x0f,0x93}, {0x5e,0xea,0x04,0x9d}, {0x45,0xfd,0x19,0x8f}, {0x4c,0xf0,0x12,0x81},
974 {0xab,0x6b,0xcb,0x3b}, {0xa2,0x66,0xc0,0x35}, {0xb9,0x71,0xdd,0x27}, {0xb0,0x7c,0xd6,0x29},
975 {0x8f,0x5f,0xe7,0x03}, {0x86,0x52,0xec,0x0d}, {0x9d,0x45,0xf1,0x1f}, {0x94,0x48,0xfa,0x11},
976 {0xe3,0x03,0x93,0x4b}, {0xea,0x0e,0x98,0x45}, {0xf1,0x19,0x85,0x57}, {0xf8,0x14,0x8e,0x59},
977 {0xc7,0x37,0xbf,0x73}, {0xce,0x3a,0xb4,0x7d}, {0xd5,0x2d,0xa9,0x6f}, {0xdc,0x20,0xa2,0x61},
978 {0x76,0x6d,0xf6,0xad}, {0x7f,0x60,0xfd,0xa3}, {0x64,0x77,0xe0,0xb1}, {0x6d,0x7a,0xeb,0xbf},
979 {0x52,0x59,0xda,0x95}, {0x5b,0x54,0xd1,0x9b}, {0x40,0x43,0xcc,0x89}, {0x49,0x4e,0xc7,0x87},
980 {0x3e,0x05,0xae,0xdd}, {0x37,0x08,0xa5,0xd3}, {0x2c,0x1f,0xb8,0xc1}, {0x25,0x12,0xb3,0xcf},
981 {0x1a,0x31,0x82,0xe5}, {0x13,0x3c,0x89,0xeb}, {0x08,0x2b,0x94,0xf9}, {0x01,0x26,0x9f,0xf7},
982 {0xe6,0xbd,0x46,0x4d}, {0xef,0xb0,0x4d,0x43}, {0xf4,0xa7,0x50,0x51}, {0xfd,0xaa,0x5b,0x5f},
983 {0xc2,0x89,0x6a,0x75}, {0xcb,0x84,0x61,0x7b}, {0xd0,0x93,0x7c,0x69}, {0xd9,0x9e,0x77,0x67},
984 {0xae,0xd5,0x1e,0x3d}, {0xa7,0xd8,0x15,0x33}, {0xbc,0xcf,0x08,0x21}, {0xb5,0xc2,0x03,0x2f},
985 {0x8a,0xe1,0x32,0x05}, {0x83,0xec,0x39,0x0b}, {0x98,0xfb,0x24,0x19}, {0x91,0xf6,0x2f,0x17},
986 {0x4d,0xd6,0x8d,0x76}, {0x44,0xdb,0x86,0x78}, {0x5f,0xcc,0x9b,0x6a}, {0x56,0xc1,0x90,0x64},
987 {0x69,0xe2,0xa1,0x4e}, {0x60,0xef,0xaa,0x40}, {0x7b,0xf8,0xb7,0x52}, {0x72,0xf5,0xbc,0x5c},
988 {0x05,0xbe,0xd5,0x06}, {0x0c,0xb3,0xde,0x08}, {0x17,0xa4,0xc3,0x1a}, {0x1e,0xa9,0xc8,0x14},
989 {0x21,0x8a,0xf9,0x3e}, {0x28,0x87,0xf2,0x30}, {0x33,0x90,0xef,0x22}, {0x3a,0x9d,0xe4,0x2c},
990 {0xdd,0x06,0x3d,0x96}, {0xd4,0x0b,0x36,0x98}, {0xcf,0x1c,0x2b,0x8a}, {0xc6,0x11,0x20,0x84},
991 {0xf9,0x32,0x11,0xae}, {0xf0,0x3f,0x1a,0xa0}, {0xeb,0x28,0x07,0xb2}, {0xe2,0x25,0x0c,0xbc},
992 {0x95,0x6e,0x65,0xe6}, {0x9c,0x63,0x6e,0xe8}, {0x87,0x74,0x73,0xfa}, {0x8e,0x79,0x78,0xf4},
993 {0xb1,0x5a,0x49,0xde}, {0xb8,0x57,0x42,0xd0}, {0xa3,0x40,0x5f,0xc2}, {0xaa,0x4d,0x54,0xcc},
994 {0xec,0xda,0xf7,0x41}, {0xe5,0xd7,0xfc,0x4f}, {0xfe,0xc0,0xe1,0x5d}, {0xf7,0xcd,0xea,0x53},
995 {0xc8,0xee,0xdb,0x79}, {0xc1,0xe3,0xd0,0x77}, {0xda,0xf4,0xcd,0x65}, {0xd3,0xf9,0xc6,0x6b},
996 {0xa4,0xb2,0xaf,0x31}, {0xad,0xbf,0xa4,0x3f}, {0xb6,0xa8,0xb9,0x2d}, {0xbf,0xa5,0xb2,0x23},
997 {0x80,0x86,0x83,0x09}, {0x89,0x8b,0x88,0x07}, {0x92,0x9c,0x95,0x15}, {0x9b,0x91,0x9e,0x1b},
998 {0x7c,0x0a,0x47,0xa1}, {0x75,0x07,0x4c,0xaf}, {0x6e,0x10,0x51,0xbd}, {0x67,0x1d,0x5a,0xb3},
999 {0x58,0x3e,0x6b,0x99}, {0x51,0x33,0x60,0x97}, {0x4a,0x24,0x7d,0x85}, {0x43,0x29,0x76,0x8b},
1000 {0x34,0x62,0x1f,0xd1}, {0x3d,0x6f,0x14,0xdf}, {0x26,0x78,0x09,0xcd}, {0x2f,0x75,0x02,0xc3},
1001 {0x10,0x56,0x33,0xe9}, {0x19,0x5b,0x38,0xe7}, {0x02,0x4c,0x25,0xf5}, {0x0b,0x41,0x2e,0xfb},
1002 {0xd7,0x61,0x8c,0x9a}, {0xde,0x6c,0x87,0x94}, {0xc5,0x7b,0x9a,0x86}, {0xcc,0x76,0x91,0x88},
1003 {0xf3,0x55,0xa0,0xa2}, {0xfa,0x58,0xab,0xac}, {0xe1,0x4f,0xb6,0xbe}, {0xe8,0x42,0xbd,0xb0},
1004 {0x9f,0x09,0xd4,0xea}, {0x96,0x04,0xdf,0xe4}, {0x8d,0x13,0xc2,0xf6}, {0x84,0x1e,0xc9,0xf8},
1005 {0xbb,0x3d,0xf8,0xd2}, {0xb2,0x30,0xf3,0xdc}, {0xa9,0x27,0xee,0xce}, {0xa0,0x2a,0xe5,0xc0},
1006 {0x47,0xb1,0x3c,0x7a}, {0x4e,0xbc,0x37,0x74}, {0x55,0xab,0x2a,0x66}, {0x5c,0xa6,0x21,0x68},
1007 {0x63,0x85,0x10,0x42}, {0x6a,0x88,0x1b,0x4c}, {0x71,0x9f,0x06,0x5e}, {0x78,0x92,0x0d,0x50},
1008 {0x0f,0xd9,0x64,0x0a}, {0x06,0xd4,0x6f,0x04}, {0x1d,0xc3,0x72,0x16}, {0x14,0xce,0x79,0x18},
1009 {0x2b,0xed,0x48,0x32}, {0x22,0xe0,0x43,0x3c}, {0x39,0xf7,0x5e,0x2e}, {0x30,0xfa,0x55,0x20},
1010 {0x9a,0xb7,0x01,0xec}, {0x93,0xba,0x0a,0xe2}, {0x88,0xad,0x17,0xf0}, {0x81,0xa0,0x1c,0xfe},
1011 {0xbe,0x83,0x2d,0xd4}, {0xb7,0x8e,0x26,0xda}, {0xac,0x99,0x3b,0xc8}, {0xa5,0x94,0x30,0xc6},
1012 {0xd2,0xdf,0x59,0x9c}, {0xdb,0xd2,0x52,0x92}, {0xc0,0xc5,0x4f,0x80}, {0xc9,0xc8,0x44,0x8e},
1013 {0xf6,0xeb,0x75,0xa4}, {0xff,0xe6,0x7e,0xaa}, {0xe4,0xf1,0x63,0xb8}, {0xed,0xfc,0x68,0xb6},
1014 {0x0a,0x67,0xb1,0x0c}, {0x03,0x6a,0xba,0x02}, {0x18,0x7d,0xa7,0x10}, {0x11,0x70,0xac,0x1e},
1015 {0x2e,0x53,0x9d,0x34}, {0x27,0x5e,0x96,0x3a}, {0x3c,0x49,0x8b,0x28}, {0x35,0x44,0x80,0x26},
1016 {0x42,0x0f,0xe9,0x7c}, {0x4b,0x02,0xe2,0x72}, {0x50,0x15,0xff,0x60}, {0x59,0x18,0xf4,0x6e},
1017 {0x66,0x3b,0xc5,0x44}, {0x6f,0x36,0xce,0x4a}, {0x74,0x21,0xd3,0x58}, {0x7d,0x2c,0xd8,0x56},
1018 {0xa1,0x0c,0x7a,0x37}, {0xa8,0x01,0x71,0x39}, {0xb3,0x16,0x6c,0x2b}, {0xba,0x1b,0x67,0x25},
1019 {0x85,0x38,0x56,0x0f}, {0x8c,0x35,0x5d,0x01}, {0x97,0x22,0x40,0x13}, {0x9e,0x2f,0x4b,0x1d},
1020 {0xe9,0x64,0x22,0x47}, {0xe0,0x69,0x29,0x49}, {0xfb,0x7e,0x34,0x5b}, {0xf2,0x73,0x3f,0x55},
1021 {0xcd,0x50,0x0e,0x7f}, {0xc4,0x5d,0x05,0x71}, {0xdf,0x4a,0x18,0x63}, {0xd6,0x47,0x13,0x6d},
1022 {0x31,0xdc,0xca,0xd7}, {0x38,0xd1,0xc1,0xd9}, {0x23,0xc6,0xdc,0xcb}, {0x2a,0xcb,0xd7,0xc5},
1023 {0x15,0xe8,0xe6,0xef}, {0x1c,0xe5,0xed,0xe1}, {0x07,0xf2,0xf0,0xf3}, {0x0e,0xff,0xfb,0xfd},
1024 {0x79,0xb4,0x92,0xa7}, {0x70,0xb9,0x99,0xa9}, {0x6b,0xae,0x84,0xbb}, {0x62,0xa3,0x8f,0xb5},
1025 {0x5d,0x80,0xbe,0x9f}, {0x54,0x8d,0xb5,0x91}, {0x4f,0x9a,0xa8,0x83}, {0x46,0x97,0xa3,0x8d}
1026 };
1027
1028 static uint32_t rcon[30]=
1029 {
1030 0x01, 0x02, 0x04, 0x08, 0x10, 0x20,
1031 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
1032 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc,
1033 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4,
1034 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
1035 };
1036
1037
1038 // Internal vars
1039 enum State { Valid , Invalid };
1040
1041 static uint8_t m_state = Invalid;
1042 static uint8_t m_mode;
1043 static uint8_t m_direction;
1044 static uint8_t m_initVector[MAX_IV_SIZE];
1045 static uint32_t m_uRounds;
1046 static uint8_t m_expandedKey[_MAX_ROUNDS+1][4][4];
1047
1048 static void keySched(uint8_t key[_MAX_KEY_COLUMNS][4]);
1049
1050 static void keyEncToDec();
1051
1052 static void encrypt(const uint8_t a[16], uint8_t b[16]);
1053
1054 static void decrypt(const uint8_t a[16], uint8_t b[16]);
1055
1056 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1057 // API
1058 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1059
1060 int Rijndael_init(int mode,int dir,const uint8_t * key,int keyLen,uint8_t * initVector)
1061 {
1062 uint32_t i, uKeyLenInBytes;
1063 uint8_t keyMatrix[_MAX_KEY_COLUMNS][4];
1064
1065 // Not initialized yet
1066 m_state = Invalid;
1067
1068 // Check the mode
1069 if((mode != CBC) && (mode != ECB) && (mode != CFB1))return RIJNDAEL_UNSUPPORTED_MODE;
1070 m_mode = mode;
1071
1072 // And the direction
1073 if((dir != Encrypt) && (dir != Decrypt))return RIJNDAEL_UNSUPPORTED_DIRECTION;
1074 m_direction = dir;
1075
1076 // Allow to set an init vector
1077 if(initVector)
1078 {
1079 // specified init vector
1080 for(i = 0;i < MAX_IV_SIZE;i++)
1081 {
1082 m_initVector[i] = initVector[i];
1083 }
1084 } else {
1085 // zero init vector
1086 for(i = 0;i < MAX_IV_SIZE;i++)
1087 {
1088 m_initVector[i] = 0;
1089 }
1090 }
1091
1092
1093 // And check the key length
1094 switch(keyLen)
1095 {
1096 case Key16Bytes:
1097 uKeyLenInBytes = 16;
1098 m_uRounds = 10;
1099 break;
1100 case Key24Bytes:
1101 uKeyLenInBytes = 24;
1102 m_uRounds = 12;
1103 break;
1104 case Key32Bytes:
1105 uKeyLenInBytes = 32;
1106 m_uRounds = 14;
1107 break;
1108 default:
1109 return RIJNDAEL_UNSUPPORTED_KEY_LENGTH;
1110 break;
1111 }
1112 // The number of rounds is calculated as
1113 // m_uRounds = (m_uKeyLenInBits / 32) + 6;
1114
1115 if(!key)return RIJNDAEL_BAD_KEY;
1116
1117
1118 for(i = 0;i < uKeyLenInBytes;i++)keyMatrix[i >> 2][i & 3] = key[i];
1119
1120 keySched(keyMatrix);
1121
1122 if(m_direction == Decrypt)keyEncToDec();
1123
1124 m_state = Valid;
1125
1126 return RIJNDAEL_SUCCESS;
1127 }
1128
1129 int Rijndael_blockEncrypt(const uint8_t *input,int inputLen,uint8_t *outBuffer)
1130 {
1131 int i, k, numBlocks;
1132 uint8_t block[16], iv[4][4];
1133
1134 if(m_state != Valid)return RIJNDAEL_NOT_INITIALIZED;
1135 if(m_direction != Encrypt)return RIJNDAEL_BAD_DIRECTION;
1136
1137 if(input == 0 || inputLen <= 0)return 0;
1138
1139 numBlocks = inputLen/128;
1140
1141 switch(m_mode){
1142 case ECB:
1143 for(i = numBlocks;i > 0;i--)
1144 {
1145 encrypt(input,outBuffer);
1146 input += 16;
1147 outBuffer += 16;
1148 }
1149 break;
1150 case CBC:
1151 ((uint32_t*)block)[0] = ((uint32_t*)m_initVector)[0] ^ ((uint32_t*)input)[0];
1152 ((uint32_t*)block)[1] = ((uint32_t*)m_initVector)[1] ^ ((uint32_t*)input)[1];
1153 ((uint32_t*)block)[2] = ((uint32_t*)m_initVector)[2] ^ ((uint32_t*)input)[2];
1154 ((uint32_t*)block)[3] = ((uint32_t*)m_initVector)[3] ^ ((uint32_t*)input)[3];
1155 encrypt(block,outBuffer);
1156 input += 16;
1157 for(i = numBlocks - 1;i > 0;i--)
1158 {
1159 ((uint32_t*)block)[0] = ((uint32_t*)outBuffer)[0] ^ ((uint32_t*)input)[0];
1160 ((uint32_t*)block)[1] = ((uint32_t*)outBuffer)[1] ^ ((uint32_t*)input)[1];
1161 ((uint32_t*)block)[2] = ((uint32_t*)outBuffer)[2] ^ ((uint32_t*)input)[2];
1162 ((uint32_t*)block)[3] = ((uint32_t*)outBuffer)[3] ^ ((uint32_t*)input)[3];
1163 outBuffer += 16;
1164 encrypt(block,outBuffer);
1165 input += 16;
1166 }
1167 break;
1168 case CFB1:
1169 #if STRICT_ALIGN
1170 memcpy(iv,m_initVector,16);
1171 #else /* !STRICT_ALIGN */
1172 *((uint32_t*)iv[0]) = *((uint32_t*)(m_initVector ));
1173 *((uint32_t*)iv[1]) = *((uint32_t*)(m_initVector + 4));
1174 *((uint32_t*)iv[2]) = *((uint32_t*)(m_initVector + 8));
1175 *((uint32_t*)iv[3]) = *((uint32_t*)(m_initVector +12));
1176 #endif /* ?STRICT_ALIGN */
1177 for(i = numBlocks; i > 0; i--)
1178 {
1179 for(k = 0; k < 128; k++)
1180 {
1181 *((uint32_t*) block ) = *((uint32_t*)iv[0]);
1182 *((uint32_t*)(block+ 4)) = *((uint32_t*)iv[1]);
1183 *((uint32_t*)(block+ 8)) = *((uint32_t*)iv[2]);
1184 *((uint32_t*)(block+12)) = *((uint32_t*)iv[3]);
1185 encrypt(block,block);
1186 outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
1187 iv[0][0] = (iv[0][0] << 1) | (iv[0][1] >> 7);
1188 iv[0][1] = (iv[0][1] << 1) | (iv[0][2] >> 7);
1189 iv[0][2] = (iv[0][2] << 1) | (iv[0][3] >> 7);
1190 iv[0][3] = (iv[0][3] << 1) | (iv[1][0] >> 7);
1191 iv[1][0] = (iv[1][0] << 1) | (iv[1][1] >> 7);
1192 iv[1][1] = (iv[1][1] << 1) | (iv[1][2] >> 7);
1193 iv[1][2] = (iv[1][2] << 1) | (iv[1][3] >> 7);
1194 iv[1][3] = (iv[1][3] << 1) | (iv[2][0] >> 7);
1195 iv[2][0] = (iv[2][0] << 1) | (iv[2][1] >> 7);
1196 iv[2][1] = (iv[2][1] << 1) | (iv[2][2] >> 7);
1197 iv[2][2] = (iv[2][2] << 1) | (iv[2][3] >> 7);
1198 iv[2][3] = (iv[2][3] << 1) | (iv[3][0] >> 7);
1199 iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
1200 iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
1201 iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
1202 iv[3][3] = (iv[3][3] << 1) | ((outBuffer[k/8] >> (7-(k&7))) & 1);
1203 }
1204 }
1205 break;
1206 default:
1207 return -1;
1208 break;
1209 }
1210
1211 return 128 * numBlocks;
1212 }
1213
1214 int Rijndael_padEncrypt(const uint8_t *input, int inputOctets, uint8_t *outBuffer)
1215 {
1216 int i, numBlocks, padLen;
1217 uint8_t block[16], *iv;
1218
1219 if(m_state != Valid)return RIJNDAEL_NOT_INITIALIZED;
1220 if(m_direction != Encrypt)return RIJNDAEL_NOT_INITIALIZED;
1221
1222 if(input == 0 || inputOctets <= 0)return 0;
1223
1224 numBlocks = inputOctets/16;
1225
1226 switch(m_mode)
1227 {
1228 case ECB:
1229 for(i = numBlocks; i > 0; i--)
1230 {
1231 encrypt(input, outBuffer);
1232 input += 16;
1233 outBuffer += 16;
1234 }
1235 padLen = 16 - (inputOctets - 16*numBlocks);
1236 // assert(padLen > 0 && padLen <= 16);
1237 memcpy(block, input, 16 - padLen);
1238 memset(block + 16 - padLen, padLen, padLen);
1239 encrypt(block,outBuffer);
1240 break;
1241 case CBC:
1242 iv = m_initVector;
1243 for(i = numBlocks; i > 0; i--)
1244 {
1245 ((uint32_t*)block)[0] = ((uint32_t*)input)[0] ^ ((uint32_t*)iv)[0];
1246 ((uint32_t*)block)[1] = ((uint32_t*)input)[1] ^ ((uint32_t*)iv)[1];
1247 ((uint32_t*)block)[2] = ((uint32_t*)input)[2] ^ ((uint32_t*)iv)[2];
1248 ((uint32_t*)block)[3] = ((uint32_t*)input)[3] ^ ((uint32_t*)iv)[3];
1249 encrypt(block, outBuffer);
1250 iv = outBuffer;
1251 input += 16;
1252 outBuffer += 16;
1253 }
1254 padLen = 16 - (inputOctets - 16*numBlocks);
1255 // assert(padLen > 0 && padLen <= 16); // DO SOMETHING HERE ?
1256 for (i = 0; i < 16 - padLen; i++) {
1257 block[i] = input[i] ^ iv[i];
1258 }
1259 for (i = 16 - padLen; i < 16; i++) {
1260 block[i] = (uint8_t)padLen ^ iv[i];
1261 }
1262 encrypt(block,outBuffer);
1263 break;
1264 default:
1265 return -1;
1266 break;
1267 }
1268
1269 return 16*(numBlocks + 1);
1270 }
1271
1272 int Rijndael_blockDecrypt(const uint8_t *input, int inputLen, uint8_t *outBuffer)
1273 {
1274 int i, k, numBlocks;
1275 uint8_t block[16], iv[4][4];
1276
1277 if(m_state != Valid)return RIJNDAEL_NOT_INITIALIZED;
1278 if((m_mode != CFB1) && (m_direction == Encrypt))return RIJNDAEL_BAD_DIRECTION;
1279
1280 if (input == 0 || inputLen <= 0)return 0;
1281
1282 numBlocks = inputLen/128;
1283
1284 switch(m_mode)
1285 {
1286 case ECB:
1287 for (i = numBlocks; i > 0; i--)
1288 {
1289 decrypt(input,outBuffer);
1290 input += 16;
1291 outBuffer += 16;
1292 }
1293 break;
1294 case CBC:
1295 #if STRICT_ALIGN
1296 memcpy(iv,m_initVector,16);
1297 #else
1298 *((uint32_t*)iv[0]) = *((uint32_t*)(m_initVector ));
1299 *((uint32_t*)iv[1]) = *((uint32_t*)(m_initVector+ 4));
1300 *((uint32_t*)iv[2]) = *((uint32_t*)(m_initVector+ 8));
1301 *((uint32_t*)iv[3]) = *((uint32_t*)(m_initVector+12));
1302 #endif
1303 for (i = numBlocks; i > 0; i--)
1304 {
1305 decrypt(input, block);
1306 ((uint32_t*)block)[0] ^= *((uint32_t*)iv[0]);
1307 ((uint32_t*)block)[1] ^= *((uint32_t*)iv[1]);
1308 ((uint32_t*)block)[2] ^= *((uint32_t*)iv[2]);
1309 ((uint32_t*)block)[3] ^= *((uint32_t*)iv[3]);
1310 #if STRICT_ALIGN
1311 memcpy(iv, input, 16);
1312 memcpy(outBuf, block, 16);
1313 #else
1314 *((uint32_t*)iv[0]) = ((uint32_t*)input)[0]; ((uint32_t*)outBuffer)[0] = ((uint32_t*)block)[0];
1315 *((uint32_t*)iv[1]) = ((uint32_t*)input)[1]; ((uint32_t*)outBuffer)[1] = ((uint32_t*)block)[1];
1316 *((uint32_t*)iv[2]) = ((uint32_t*)input)[2]; ((uint32_t*)outBuffer)[2] = ((uint32_t*)block)[2];
1317 *((uint32_t*)iv[3]) = ((uint32_t*)input)[3]; ((uint32_t*)outBuffer)[3] = ((uint32_t*)block)[3];
1318 #endif
1319 input += 16;
1320 outBuffer += 16;
1321 }
1322 break;
1323 case CFB1:
1324 #if STRICT_ALIGN
1325 memcpy(iv, m_initVector, 16);
1326 #else
1327 *((uint32_t*)iv[0]) = *((uint32_t*)(m_initVector));
1328 *((uint32_t*)iv[1]) = *((uint32_t*)(m_initVector+ 4));
1329 *((uint32_t*)iv[2]) = *((uint32_t*)(m_initVector+ 8));
1330 *((uint32_t*)iv[3]) = *((uint32_t*)(m_initVector+12));
1331 #endif
1332 for(i = numBlocks; i > 0; i--)
1333 {
1334 for(k = 0; k < 128; k++)
1335 {
1336 *((uint32_t*) block ) = *((uint32_t*)iv[0]);
1337 *((uint32_t*)(block+ 4)) = *((uint32_t*)iv[1]);
1338 *((uint32_t*)(block+ 8)) = *((uint32_t*)iv[2]);
1339 *((uint32_t*)(block+12)) = *((uint32_t*)iv[3]);
1340 encrypt(block, block);
1341 iv[0][0] = (iv[0][0] << 1) | (iv[0][1] >> 7);
1342 iv[0][1] = (iv[0][1] << 1) | (iv[0][2] >> 7);
1343 iv[0][2] = (iv[0][2] << 1) | (iv[0][3] >> 7);
1344 iv[0][3] = (iv[0][3] << 1) | (iv[1][0] >> 7);
1345 iv[1][0] = (iv[1][0] << 1) | (iv[1][1] >> 7);
1346 iv[1][1] = (iv[1][1] << 1) | (iv[1][2] >> 7);
1347 iv[1][2] = (iv[1][2] << 1) | (iv[1][3] >> 7);
1348 iv[1][3] = (iv[1][3] << 1) | (iv[2][0] >> 7);
1349 iv[2][0] = (iv[2][0] << 1) | (iv[2][1] >> 7);
1350 iv[2][1] = (iv[2][1] << 1) | (iv[2][2] >> 7);
1351 iv[2][2] = (iv[2][2] << 1) | (iv[2][3] >> 7);
1352 iv[2][3] = (iv[2][3] << 1) | (iv[3][0] >> 7);
1353 iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
1354 iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
1355 iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
1356 iv[3][3] = (iv[3][3] << 1) | ((input[k/8] >> (7-(k&7))) & 1);
1357 outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
1358 }
1359 }
1360 break;
1361 default:
1362 return -1;
1363 break;
1364 }
1365
1366 return 128*numBlocks;
1367 }
1368
1369 int Rijndael_padDecrypt(const uint8_t *input, int inputOctets, uint8_t *outBuffer)
1370 {
1371 int i, numBlocks, padLen;
1372 uint8_t block[16];
1373 uint32_t iv[4];
1374
1375 if(m_state != Valid)return RIJNDAEL_NOT_INITIALIZED;
1376 if(m_direction != Decrypt)return RIJNDAEL_BAD_DIRECTION;
1377
1378 if(input == 0 || inputOctets <= 0)return 0;
1379
1380 if((inputOctets % 16) != 0)return RIJNDAEL_CORRUPTED_DATA;
1381
1382 numBlocks = inputOctets/16;
1383
1384 switch(m_mode){
1385 case ECB:
1386 for (i = numBlocks - 1; i > 0; i--)
1387 {
1388 decrypt(input, outBuffer);
1389 input += 16;
1390 outBuffer += 16;
1391 }
1392
1393 decrypt(input, block);
1394 padLen = block[15];
1395 if (padLen >= 16)return RIJNDAEL_CORRUPTED_DATA;
1396 for(i = 16 - padLen; i < 16; i++)
1397 {
1398 if(block[i] != padLen)return RIJNDAEL_CORRUPTED_DATA;
1399 }
1400 memcpy(outBuffer, block, 16 - padLen);
1401 break;
1402 case CBC:
1403 memcpy(iv, m_initVector, 16);
1404 /* all blocks but last */
1405 for (i = numBlocks - 1; i > 0; i--)
1406 {
1407 decrypt(input, block);
1408 ((uint32_t*)block)[0] ^= iv[0];
1409 ((uint32_t*)block)[1] ^= iv[1];
1410 ((uint32_t*)block)[2] ^= iv[2];
1411 ((uint32_t*)block)[3] ^= iv[3];
1412 memcpy(iv, input, 16);
1413 memcpy(outBuffer, block, 16);
1414 input += 16;
1415 outBuffer += 16;
1416 }
1417 /* last block */
1418 decrypt(input, block);
1419 ((uint32_t*)block)[0] ^= iv[0];
1420 ((uint32_t*)block)[1] ^= iv[1];
1421 ((uint32_t*)block)[2] ^= iv[2];
1422 ((uint32_t*)block)[3] ^= iv[3];
1423 padLen = block[15];
1424 if(padLen <= 0 || padLen > 16)return RIJNDAEL_CORRUPTED_DATA;
1425 for(i = 16 - padLen; i < 16; i++)
1426 {
1427 if(block[i] != padLen)return RIJNDAEL_CORRUPTED_DATA;
1428 }
1429 memcpy(outBuffer, block, 16 - padLen);
1430 break;
1431
1432 default:
1433 return -1;
1434 break;
1435 }
1436
1437 return 16*numBlocks - padLen;
1438 }
1439
1440 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1441 // ALGORITHM
1442 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1443
1444
1445 void keySched(uint8_t key[_MAX_KEY_COLUMNS][4])
1446 {
1447 int j,rconpointer = 0;
1448 int r = 0;
1449 int t = 0;
1450
1451 // Calculate the necessary round keys
1452 // The number of calculations depends on keyBits and blockBits
1453 int uKeyColumns = m_uRounds - 6;
1454
1455 uint8_t tempKey[_MAX_KEY_COLUMNS][4];
1456
1457 // Copy the input key to the temporary key matrix
1458
1459 for(j = 0;j < uKeyColumns;j++)
1460 {
1461 *((uint32_t*)(tempKey[j])) = *((uint32_t*)(key[j]));
1462 }
1463
1464 // copy values into round key array
1465 for(j = 0;(j < uKeyColumns) && (r <= m_uRounds); )
1466 {
1467 for(;(j < uKeyColumns) && (t < 4); j++, t++)
1468 {
1469 *((uint32_t*)m_expandedKey[r][t]) = *((uint32_t*)tempKey[j]);
1470 }
1471
1472
1473 if(t == 4)
1474 {
1475 r++;
1476 t = 0;
1477 }
1478 }
1479
1480 while(r <= m_uRounds)
1481 {
1482 tempKey[0][0] ^= S[tempKey[uKeyColumns-1][1]];
1483 tempKey[0][1] ^= S[tempKey[uKeyColumns-1][2]];
1484 tempKey[0][2] ^= S[tempKey[uKeyColumns-1][3]];
1485 tempKey[0][3] ^= S[tempKey[uKeyColumns-1][0]];
1486 tempKey[0][0] ^= rcon[rconpointer++];
1487
1488 if (uKeyColumns != 8)
1489 {
1490 for(j = 1; j < uKeyColumns; j++)
1491 {
1492 *((uint32_t*)tempKey[j]) ^= *((uint32_t*)tempKey[j-1]);
1493 }
1494 } else {
1495 for(j = 1; j < uKeyColumns/2; j++)
1496 {
1497 *((uint32_t*)tempKey[j]) ^= *((uint32_t*)tempKey[j-1]);
1498 }
1499 tempKey[uKeyColumns/2][0] ^= S[tempKey[uKeyColumns/2 - 1][0]];
1500 tempKey[uKeyColumns/2][1] ^= S[tempKey[uKeyColumns/2 - 1][1]];
1501 tempKey[uKeyColumns/2][2] ^= S[tempKey[uKeyColumns/2 - 1][2]];
1502 tempKey[uKeyColumns/2][3] ^= S[tempKey[uKeyColumns/2 - 1][3]];
1503 for(j = uKeyColumns/2 + 1; j < uKeyColumns; j++)
1504 {
1505 *((uint32_t*)tempKey[j]) ^= *((uint32_t*)tempKey[j-1]);
1506 }
1507 }
1508 for(j = 0; (j < uKeyColumns) && (r <= m_uRounds); )
1509 {
1510 for(; (j < uKeyColumns) && (t < 4); j++, t++)
1511 {
1512 *((uint32_t*)m_expandedKey[r][t]) = *((uint32_t*)tempKey[j]);
1513 }
1514 if(t == 4)
1515 {
1516 r++;
1517 t = 0;
1518 }
1519 }
1520 }
1521 }
1522
1523 void keyEncToDec()
1524 {
1525 int r;
1526 uint8_t *w;
1527
1528 for(r = 1; r < m_uRounds; r++)
1529 {
1530 w = m_expandedKey[r][0];
1531 *((uint32_t*)w) = *((uint32_t*)U1[w[0]]) ^ *((uint32_t*)U2[w[1]]) ^ *((uint32_t*)U3[w[2]]) ^ *((uint32_t*)U4[w[3]]);
1532 w = m_expandedKey[r][1];
1533 *((uint32_t*)w) = *((uint32_t*)U1[w[0]]) ^ *((uint32_t*)U2[w[1]]) ^ *((uint32_t*)U3[w[2]]) ^ *((uint32_t*)U4[w[3]]);
1534 w = m_expandedKey[r][2];
1535 *((uint32_t*)w) = *((uint32_t*)U1[w[0]]) ^ *((uint32_t*)U2[w[1]]) ^ *((uint32_t*)U3[w[2]]) ^ *((uint32_t*)U4[w[3]]);
1536 w = m_expandedKey[r][3];
1537 *((uint32_t*)w) = *((uint32_t*)U1[w[0]]) ^ *((uint32_t*)U2[w[1]]) ^ *((uint32_t*)U3[w[2]]) ^ *((uint32_t*)U4[w[3]]);
1538 }
1539 }
1540
1541 void encrypt(const uint8_t a[16], uint8_t b[16])
1542 {
1543 int r;
1544 uint8_t temp[4][4];
1545
1546 *((uint32_t*)temp[0]) = *((uint32_t*)(a )) ^ *((uint32_t*)m_expandedKey[0][0]);
1547 *((uint32_t*)temp[1]) = *((uint32_t*)(a+ 4)) ^ *((uint32_t*)m_expandedKey[0][1]);
1548 *((uint32_t*)temp[2]) = *((uint32_t*)(a+ 8)) ^ *((uint32_t*)m_expandedKey[0][2]);
1549 *((uint32_t*)temp[3]) = *((uint32_t*)(a+12)) ^ *((uint32_t*)m_expandedKey[0][3]);
1550 *((uint32_t*)(b )) = *((uint32_t*)T1[temp[0][0]])
1551 ^ *((uint32_t*)T2[temp[1][1]])
1552 ^ *((uint32_t*)T3[temp[2][2]])
1553 ^ *((uint32_t*)T4[temp[3][3]]);
1554 *((uint32_t*)(b + 4)) = *((uint32_t*)T1[temp[1][0]])
1555 ^ *((uint32_t*)T2[temp[2][1]])
1556 ^ *((uint32_t*)T3[temp[3][2]])
1557 ^ *((uint32_t*)T4[temp[0][3]]);
1558 *((uint32_t*)(b + 8)) = *((uint32_t*)T1[temp[2][0]])
1559 ^ *((uint32_t*)T2[temp[3][1]])
1560 ^ *((uint32_t*)T3[temp[0][2]])
1561 ^ *((uint32_t*)T4[temp[1][3]]);
1562 *((uint32_t*)(b +12)) = *((uint32_t*)T1[temp[3][0]])
1563 ^ *((uint32_t*)T2[temp[0][1]])
1564 ^ *((uint32_t*)T3[temp[1][2]])
1565 ^ *((uint32_t*)T4[temp[2][3]]);
1566 for(r = 1; r < m_uRounds-1; r++)
1567 {
1568 *((uint32_t*)temp[0]) = *((uint32_t*)(b )) ^ *((uint32_t*)m_expandedKey[r][0]);
1569 *((uint32_t*)temp[1]) = *((uint32_t*)(b+ 4)) ^ *((uint32_t*)m_expandedKey[r][1]);
1570 *((uint32_t*)temp[2]) = *((uint32_t*)(b+ 8)) ^ *((uint32_t*)m_expandedKey[r][2]);
1571 *((uint32_t*)temp[3]) = *((uint32_t*)(b+12)) ^ *((uint32_t*)m_expandedKey[r][3]);
1572
1573 *((uint32_t*)(b )) = *((uint32_t*)T1[temp[0][0]])
1574 ^ *((uint32_t*)T2[temp[1][1]])
1575 ^ *((uint32_t*)T3[temp[2][2]])
1576 ^ *((uint32_t*)T4[temp[3][3]]);
1577 *((uint32_t*)(b + 4)) = *((uint32_t*)T1[temp[1][0]])
1578 ^ *((uint32_t*)T2[temp[2][1]])
1579 ^ *((uint32_t*)T3[temp[3][2]])
1580 ^ *((uint32_t*)T4[temp[0][3]]);
1581 *((uint32_t*)(b + 8)) = *((uint32_t*)T1[temp[2][0]])
1582 ^ *((uint32_t*)T2[temp[3][1]])
1583 ^ *((uint32_t*)T3[temp[0][2]])
1584 ^ *((uint32_t*)T4[temp[1][3]]);
1585 *((uint32_t*)(b +12)) = *((uint32_t*)T1[temp[3][0]])
1586 ^ *((uint32_t*)T2[temp[0][1]])
1587 ^ *((uint32_t*)T3[temp[1][2]])
1588 ^ *((uint32_t*)T4[temp[2][3]]);
1589 }
1590 *((uint32_t*)temp[0]) = *((uint32_t*)(b )) ^ *((uint32_t*)m_expandedKey[m_uRounds-1][0]);
1591 *((uint32_t*)temp[1]) = *((uint32_t*)(b+ 4)) ^ *((uint32_t*)m_expandedKey[m_uRounds-1][1]);
1592 *((uint32_t*)temp[2]) = *((uint32_t*)(b+ 8)) ^ *((uint32_t*)m_expandedKey[m_uRounds-1][2]);
1593 *((uint32_t*)temp[3]) = *((uint32_t*)(b+12)) ^ *((uint32_t*)m_expandedKey[m_uRounds-1][3]);
1594 b[ 0] = T1[temp[0][0]][1];
1595 b[ 1] = T1[temp[1][1]][1];
1596 b[ 2] = T1[temp[2][2]][1];
1597 b[ 3] = T1[temp[3][3]][1];
1598 b[ 4] = T1[temp[1][0]][1];
1599 b[ 5] = T1[temp[2][1]][1];
1600 b[ 6] = T1[temp[3][2]][1];
1601 b[ 7] = T1[temp[0][3]][1];
1602 b[ 8] = T1[temp[2][0]][1];
1603 b[ 9] = T1[temp[3][1]][1];
1604 b[10] = T1[temp[0][2]][1];
1605 b[11] = T1[temp[1][3]][1];
1606 b[12] = T1[temp[3][0]][1];
1607 b[13] = T1[temp[0][1]][1];
1608 b[14] = T1[temp[1][2]][1];
1609 b[15] = T1[temp[2][3]][1];
1610 *((uint32_t*)(b )) ^= *((uint32_t*)m_expandedKey[m_uRounds][0]);
1611 *((uint32_t*)(b+ 4)) ^= *((uint32_t*)m_expandedKey[m_uRounds][1]);
1612 *((uint32_t*)(b+ 8)) ^= *((uint32_t*)m_expandedKey[m_uRounds][2]);
1613 *((uint32_t*)(b+12)) ^= *((uint32_t*)m_expandedKey[m_uRounds][3]);
1614 }
1615
1616 void decrypt(const uint8_t a[16], uint8_t b[16])
1617 {
1618 int r;
1619 uint8_t temp[4][4];
1620
1621 *((uint32_t*)temp[0]) = *((uint32_t*)(a )) ^ *((uint32_t*)m_expandedKey[m_uRounds][0]);
1622 *((uint32_t*)temp[1]) = *((uint32_t*)(a+ 4)) ^ *((uint32_t*)m_expandedKey[m_uRounds][1]);
1623 *((uint32_t*)temp[2]) = *((uint32_t*)(a+ 8)) ^ *((uint32_t*)m_expandedKey[m_uRounds][2]);
1624 *((uint32_t*)temp[3]) = *((uint32_t*)(a+12)) ^ *((uint32_t*)m_expandedKey[m_uRounds][3]);
1625
1626 *((uint32_t*)(b )) = *((uint32_t*)T5[temp[0][0]])
1627 ^ *((uint32_t*)T6[temp[3][1]])
1628 ^ *((uint32_t*)T7[temp[2][2]])
1629 ^ *((uint32_t*)T8[temp[1][3]]);
1630 *((uint32_t*)(b+ 4)) = *((uint32_t*)T5[temp[1][0]])
1631 ^ *((uint32_t*)T6[temp[0][1]])
1632 ^ *((uint32_t*)T7[temp[3][2]])
1633 ^ *((uint32_t*)T8[temp[2][3]]);
1634 *((uint32_t*)(b+ 8)) = *((uint32_t*)T5[temp[2][0]])
1635 ^ *((uint32_t*)T6[temp[1][1]])
1636 ^ *((uint32_t*)T7[temp[0][2]])
1637 ^ *((uint32_t*)T8[temp[3][3]]);
1638 *((uint32_t*)(b+12)) = *((uint32_t*)T5[temp[3][0]])
1639 ^ *((uint32_t*)T6[temp[2][1]])
1640 ^ *((uint32_t*)T7[temp[1][2]])
1641 ^ *((uint32_t*)T8[temp[0][3]]);
1642 for(r = m_uRounds-1; r > 1; r--)
1643 {
1644 *((uint32_t*)temp[0]) = *((uint32_t*)(b )) ^ *((uint32_t*)m_expandedKey[r][0]);
1645 *((uint32_t*)temp[1]) = *((uint32_t*)(b+ 4)) ^ *((uint32_t*)m_expandedKey[r][1]);
1646 *((uint32_t*)temp[2]) = *((uint32_t*)(b+ 8)) ^ *((uint32_t*)m_expandedKey[r][2]);
1647 *((uint32_t*)temp[3]) = *((uint32_t*)(b+12)) ^ *((uint32_t*)m_expandedKey[r][3]);
1648 *((uint32_t*)(b )) = *((uint32_t*)T5[temp[0][0]])
1649 ^ *((uint32_t*)T6[temp[3][1]])
1650 ^ *((uint32_t*)T7[temp[2][2]])
1651 ^ *((uint32_t*)T8[temp[1][3]]);
1652 *((uint32_t*)(b+ 4)) = *((uint32_t*)T5[temp[1][0]])
1653 ^ *((uint32_t*)T6[temp[0][1]])
1654 ^ *((uint32_t*)T7[temp[3][2]])
1655 ^ *((uint32_t*)T8[temp[2][3]]);
1656 *((uint32_t*)(b+ 8)) = *((uint32_t*)T5[temp[2][0]])
1657 ^ *((uint32_t*)T6[temp[1][1]])
1658 ^ *((uint32_t*)T7[temp[0][2]])
1659 ^ *((uint32_t*)T8[temp[3][3]]);
1660 *((uint32_t*)(b+12)) = *((uint32_t*)T5[temp[3][0]])
1661 ^ *((uint32_t*)T6[temp[2][1]])
1662 ^ *((uint32_t*)T7[temp[1][2]])
1663 ^ *((uint32_t*)T8[temp[0][3]]);
1664 }
1665
1666 *((uint32_t*)temp[0]) = *((uint32_t*)(b )) ^ *((uint32_t*)m_expandedKey[1][0]);
1667 *((uint32_t*)temp[1]) = *((uint32_t*)(b+ 4)) ^ *((uint32_t*)m_expandedKey[1][1]);
1668 *((uint32_t*)temp[2]) = *((uint32_t*)(b+ 8)) ^ *((uint32_t*)m_expandedKey[1][2]);
1669 *((uint32_t*)temp[3]) = *((uint32_t*)(b+12)) ^ *((uint32_t*)m_expandedKey[1][3]);
1670 b[ 0] = S5[temp[0][0]];
1671 b[ 1] = S5[temp[3][1]];
1672 b[ 2] = S5[temp[2][2]];
1673 b[ 3] = S5[temp[1][3]];
1674 b[ 4] = S5[temp[1][0]];
1675 b[ 5] = S5[temp[0][1]];
1676 b[ 6] = S5[temp[3][2]];
1677 b[ 7] = S5[temp[2][3]];
1678 b[ 8] = S5[temp[2][0]];
1679 b[ 9] = S5[temp[1][1]];
1680 b[10] = S5[temp[0][2]];
1681 b[11] = S5[temp[3][3]];
1682 b[12] = S5[temp[3][0]];
1683 b[13] = S5[temp[2][1]];
1684 b[14] = S5[temp[1][2]];
1685 b[15] = S5[temp[0][3]];
1686 *((uint32_t*)(b )) ^= *((uint32_t*)m_expandedKey[0][0]);
1687 *((uint32_t*)(b+ 4)) ^= *((uint32_t*)m_expandedKey[0][1]);
1688 *((uint32_t*)(b+ 8)) ^= *((uint32_t*)m_expandedKey[0][2]);
1689 *((uint32_t*)(b+12)) ^= *((uint32_t*)m_expandedKey[0][3]);
1690 }
0 /*
1 * Code adapted from Crypto-PAN 1.0 Code. See original disclaimer below
2 * The sourcecode has been converted from C++ to C and adapted for nfdump
3 *
4 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of SWITCH nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $NfDump Author:$
32 *
33 * $Id: rijndael.h 53 2005-11-17 07:45:34Z peter $
34 *
35 * $LastChangedRevision: 53 $
36 *
37 */
38
39 /* Original disclaimer
40 * Atlanta, Georgia 30332.
41 * All Rights Reserved
42 *
43 * The following Software is posted on the Internet by the Georgia
44 * Tech Research Corporation (GTRC). It was developed by employees
45 * of the Georgia Institute of Technology in the College of Computing.
46 * GTRC hereby grants to the user a non-exclusive, royalty-free
47 * license to utilize such Software for the User's own purposes
48 * pursuant to the following conditions.
49 *
50 *
51 * THE SOFTWARE IS LICENSED ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY
52 * THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM THE SOFTWARE.
53 * GTRC SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM
54 * THE USE OF THE SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION, AND CAN
55 * IN NO WAY PROVIDE COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING
56 * BUT NOT LIMITED TO ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY
57 * FOR TORT, OF FOR ANY ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS,
58 * TRADE SECRETS, OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS
59 * EXPENSE, MACHINE DOWNTIME, OR DAMAGES CAUSED LICENSEE BY ANY DEFICIENCY,
60 * DEFECT OR ERROR IN THE SOFTWARE OR MALFUNCTION THEREOF, NOR ANY
61 * INCIDENTAL OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS
62 * ALL WARRANTIES, BOTH EXPRESS AND IMPLIED RESPECTING THE USE AND
63 * OPERATION OF THE SOFTWARE AND ANY ACCOMPANYING DOCUMENTATION,
64 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65 * PARTICULAR PURPOSE AND ANY IMPLIED WARRANTY ARISING FROM COURSE
66 * OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. GTRC MAKES NO
67 * WARRANTY THAT THE SOFTWARE IS ADEQUATELY OR COMPLETELY DESCRIBED
68 * IN, OR BEHAVES IN ACCORDANCE WITH ANY OF THE ACCOMPANYING
69 * DOCUMENTATION. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL
70 * EVALUATION OF THE SOFTWARE'S USEFULNESS IN USER'S OWN ENVIRONMENT.
71 *
72 *
73 */
74
75 #ifndef _RIJNDAEL_H_
76 #define _RIJNDAEL_H_
77 //
78 // File : rijndael.h
79 // Creation date : Sun Nov 5 2000 03:21:05 CEST
80 // Author : Szymon Stefanek (stefanek@tin.it)
81 //
82 // Another implementation of the Rijndael cipher.
83 // This is intended to be an easily usable library file.
84 // This code is public domain.
85 // Based on the Vincent Rijmen and K.U.Leuven implementation 2.4.
86 //
87
88 //
89 // Original Copyright notice:
90 //
91 // rijndael-alg-fst.c v2.4 April '2000
92 // rijndael-alg-fst.h
93 // rijndael-api-fst.c
94 // rijndael-api-fst.h
95 //
96 // Optimised ANSI C code
97 //
98 // authors: v1.0: Antoon Bosselaers
99 // v2.0: Vincent Rijmen, K.U.Leuven
100 // v2.3: Paulo Barreto
101 // v2.4: Vincent Rijmen, K.U.Leuven
102 //
103 // This code is placed in the public domain.
104 //
105
106 //
107 // This implementation works on 128 , 192 , 256 bit keys
108 // and on 128 bit blocks
109 //
110
111 //
112 // Example of usage:
113 //
114 // // Input data
115 // unsigned char key[32]; // The key
116 // initializeYour256BitKey(); // Obviously initialized with sth
117 // const unsigned char * plainText = getYourPlainText(); // Your plain text
118 // int plainTextLen = strlen(plainText); // Plain text length
119 //
120 // // Encrypting
121 // Rijndael rin;
122 // unsigned char output[plainTextLen + 16];
123 //
124 // rin.init(Rijndael::CBC,Rijndael::Encrypt,key,Rijndael::Key32Bytes);
125 // // It is a good idea to check the error code
126 // int len = rin.padEncrypt(plainText,len,output);
127 // if(len >= 0)useYourEncryptedText();
128 // else encryptError(len);
129 //
130 // // Decrypting: we can reuse the same object
131 // unsigned char output2[len];
132 // rin.init(Rijndael::CBC,Rijndael::Decrypt,key,Rijndael::Key32Bytes));
133 // len = rin.padDecrypt(output,len,output2);
134 // if(len >= 0)useYourDecryptedText();
135 // else decryptError(len);
136 //
137
138 #define _MAX_KEY_COLUMNS (256/32)
139 #define _MAX_ROUNDS 14
140 #define MAX_IV_SIZE 16
141
142 // Error codes
143 #define RIJNDAEL_SUCCESS 0
144 #define RIJNDAEL_UNSUPPORTED_MODE -1
145 #define RIJNDAEL_UNSUPPORTED_DIRECTION -2
146 #define RIJNDAEL_UNSUPPORTED_KEY_LENGTH -3
147 #define RIJNDAEL_BAD_KEY -4
148 #define RIJNDAEL_NOT_INITIALIZED -5
149 #define RIJNDAEL_BAD_DIRECTION -6
150 #define RIJNDAEL_CORRUPTED_DATA -7
151
152
153 enum Direction { Encrypt , Decrypt };
154 enum Mode { ECB , CBC , CFB1 };
155 enum KeyLength { Key16Bytes , Key24Bytes , Key32Bytes };
156
157 //////////////////////////////////////////////////////////////////////////////////////////
158 // API
159 //////////////////////////////////////////////////////////////////////////////////////////
160
161 // init(): Initializes the crypt session
162 // Returns RIJNDAEL_SUCCESS or an error code
163 // mode : ECB, CBC or CFB1
164 // You have to use the same mode for encrypting and decrypting
165 // dir : Encrypt or Decrypt
166 // A cipher instance works only in one direction
167 // (Well , it could be easily modified to work in both
168 // directions with a single init() call, but it looks
169 // useless to me...anyway , it is a matter of generating
170 // two expanded keys)
171 // key : array of unsigned octets , it can be 16 , 24 or 32 bytes long
172 // this CAN be binary data (it is not expected to be null terminated)
173 // keyLen : Key16Bytes , Key24Bytes or Key32Bytes
174 // initVector: initialization vector, you will usually use 0 here
175 int Rijndael_init(int mode,int dir,const uint8_t * key,int keyLen,uint8_t * initVector);
176 // Encrypts the input array (can be binary data)
177 // The input array length must be a multiple of 16 bytes, the remaining part
178 // is DISCARDED.
179 // so it actually encrypts inputLen / 128 blocks of input and puts it in outBuffer
180 // Input len is in BITS!
181 // outBuffer must be at least inputLen / 8 bytes long.
182 // Returns the encrypted buffer length in BITS or an error code < 0 in case of error
183 int Rijndael_blockEncrypt(const uint8_t *input, int inputLen, uint8_t *outBuffer);
184 // Encrypts the input array (can be binary data)
185 // The input array can be any length , it is automatically padded on a 16 byte boundary.
186 // Input len is in BYTES!
187 // outBuffer must be at least (inputLen + 16) bytes long
188 // Returns the encrypted buffer length in BYTES or an error code < 0 in case of error
189 int Rijndael_padEncrypt(const uint8_t *input, int inputOctets, uint8_t *outBuffer);
190 // Decrypts the input vector
191 // Input len is in BITS!
192 // outBuffer must be at least inputLen / 8 bytes long
193 // Returns the decrypted buffer length in BITS and an error code < 0 in case of error
194 int Rijndael_blockDecrypt(const uint8_t *input, int inputLen, uint8_t *outBuffer);
195 // Decrypts the input vector
196 // Input len is in BYTES!
197 // outBuffer must be at least inputLen bytes long
198 // Returns the decrypted buffer length in BYTES and an error code < 0 in case of error
199 int Rijndael_padDecrypt(const uint8_t *input, int inputOctets, uint8_t *outBuffer);
200 #endif
0 #include<dirent.h>
1 #include<stdlib.h>
2 #include<string.h>
3 #include<sys/types.h>
4
5 /* This function is only required for SunOS, all other supported OS
6 have this function in their system libraries */
7
8 int scandir(const char *dir, struct dirent ***namelist,
9 const int (*select)(struct dirent *),
10 const int (*compar)(const void *, const void *))
11 {
12 DIR *d;
13 struct dirent *entry;
14 register int i=0;
15 size_t entrysize;
16
17 if ((d=opendir(dir)) == NULL)
18 return(-1);
19
20 *namelist=NULL;
21 while ((entry=readdir(d)) != NULL)
22 {
23 if (select == NULL || (select != NULL && (*select)(entry)))
24 {
25 *namelist=(struct dirent **)realloc((void *)(*namelist),
26 (size_t)((i+1)*sizeof(struct dirent *)));
27 if (*namelist == NULL) return(-1);
28 entrysize=sizeof(struct
29 dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1;
30 (*namelist)[i]=(struct dirent *)malloc(entrysize);
31 if ((*namelist)[i] == NULL) return(-1);
32 memcpy((*namelist)[i], entry, entrysize);
33 i++;
34 }
35 }
36 if (closedir(d)) return(-1);
37 if (i == 0) return(-1);
38 if (compar != NULL)
39 qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
40
41 return(i);
42 }
43
44 int alphasort(const void *a, const void *b)
45 {
46 return strcmp ((*(const struct dirent **) a)->d_name, (*(const struct dirent **) b)->d_name);
47 }
0 int scandir(const char *dir, struct dirent ***namelist,
1 const int (*select)(const struct dirent *),
2 const int (*compar)(const void *, const void *));
3
4 int alphasort(const void *a, const void *b);
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: scanner.l 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 *
37 *
38 */
39
40 %{
41
42 #include <sys/types.h>
43 #include <stdlib.h>
44 #include <string.h>
45
46 #include "config.h"
47
48 #ifdef HAVE_STDINT_H
49 #include <stdint.h>
50 #endif
51
52
53 #include "nfdump.h"
54 #include "grammar.h"
55 int lineno = 1;
56
57 #ifdef FLEX_SCANNER
58 #define YY_NO_UNPUT
59 static YY_BUFFER_STATE in_buffer;
60 #else
61 static char *in_buffer;
62
63 #undef getc
64 #define getc(fp) (*in_buffer == 0 ? EOF : *in_buffer++)
65 #endif
66
67 %}
68
69 N [0-9]+
70 H (0X|0x)[0-9A-Fa-f]+
71
72 %%
73
74 ({N}{1,3}\.{N}{1,3})|({N}{1,3}\.{N}{1,3}\.{N}{1,3}) {
75 yylval.s = strdup(yytext);
76 return QUADDOT;
77 }
78 {N}{1,3}\.{N}{1,3}\.{N}{1,3}\.{N}{1,3} {
79 yylval.s = strdup(yytext);
80 return QUADDOT;
81 }
82 any { return ANY; }
83 ip { return IP; }
84 if { return IF; }
85 tcp { return TCP; }
86 udp { return UDP; }
87 gre { return GRE; }
88 esp { return ESP; }
89 ah { return AH; }
90 rsvp { return RSVP; }
91 proto { return PROTO; }
92 flags { return FLAGS; }
93 tos { return TOS; }
94 host { return HOST; }
95 net { return NET; }
96 icmp { return ICMP; }
97 port { return PORT; }
98 as { return AS; }
99 in { return IN; }
100 out { return OUT; }
101 next { return NEXT; }
102 packets { return PACKETS; }
103 bytes { return BYTES; }
104 bpp { return BPP; }
105 bps { return BPS; }
106 pps { return PPS; }
107 duration { return DURATION; }
108 and|"&&" { return AND; }
109 or|"||" { return OR; }
110 not|"!" { return NOT; }
111 "="|"=="|eq { return EQ; }
112 ">"|gt { return GT; }
113 "<"|lt { return LT; }
114 src { return SRC; }
115 dst { return DST; }
116 #.* { ; }
117 [ \t] { ; }
118 [FSRPAUX]+ {
119 yylval.s = strdup(yytext);
120 return ALPHA_FLAGS;
121 }
122 [0-9]+ {
123 yylval.value = atoi(yytext);
124 return NUMBER;
125 }
126 \n { lineno++; }
127 . { return yytext[0]; }
128
129 %%
130
131 void lex_init(char *buf) {
132 #ifdef FLEX_SCANNER
133 in_buffer = yy_scan_string(buf);
134 #else
135 in_buffer = buf;
136 #endif
137 }
138
139 /*
140 * Do any cleanup necessary after parsing.
141 */
142 void lex_cleanup(void) {
143 #ifdef FLEX_SCANNER
144 if (in_buffer != NULL)
145 yy_delete_buffer(in_buffer);
146 in_buffer = NULL;
147 #endif
148 }
149
150 int yywrap(void) {
151 return 1;
152 }
+1010
-0
util.c less more
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: util.c 53 2005-11-17 07:45:34Z peter $
33 *
34 * $LastChangedRevision: 53 $
35 *
36 */
37
38 #include <stdio.h>
39 #include <unistd.h>
40 #include <stdlib.h>
41 #include <time.h>
42 #include <string.h>
43 #include <errno.h>
44 #include <dirent.h>
45 #include <sys/stat.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <fcntl.h>
49 #include <ctype.h>
50
51 #include "config.h"
52
53 #ifdef HAVE_STDINT_H
54 #include <stdint.h>
55 #endif
56
57 #include "util.h"
58
59 #ifndef HAVE_SCANDIR
60 int scandir(const char *dir, struct dirent ***namelist,
61 const int (*select)(struct dirent *),
62 const int (*compar)(const void *, const void *));
63
64 int alphasort(const void *a, const void *b);
65
66 #endif
67
68 /* Global vars */
69 // uint64_t total_bytes = 0;
70
71 extern uint32_t byte_limit, packet_limit;
72 extern int byte_mode, packet_mode;
73
74 enum { NONE, LESS, MORE };
75
76
77 /* Function prototypes */
78 static int check_number(char *s, int len);
79
80 static int ParseTime(char *s, time_t *t_start);
81
82 static int FileFilter(const struct dirent *dir);
83
84 static void ReadNetflowStat(char *sfile);
85
86 static void GetFileList(char *path);
87
88 static void GetDirList(char *dirs);
89
90 static time_t firstseen, lastseen;
91
92 typedef struct StatInfo_s {
93 char Ident[32];
94 uint32_t tstamp;
95 uint64_t flows;
96 uint64_t flows_tcp;
97 uint64_t flows_udp;
98 uint64_t flows_icmp;
99 uint64_t flows_other;
100 uint64_t pkts;
101 uint64_t pkts_tcp;
102 uint64_t pkts_udp;
103 uint64_t pkts_icmp;
104 uint64_t pkts_other;
105 uint64_t bytes;
106 uint64_t bytes_tcp;
107 uint64_t bytes_udp;
108 uint64_t bytes_icmp;
109 uint64_t bytes_other;
110 uint32_t first_seen;
111 uint32_t last_seen;
112 } StatInfo_t;
113
114 static StatInfo_t NetflowStat;
115
116 typedef struct DirList_s {
117 struct DirList_s *next;
118 char *dirname;
119 } DirList_t;
120
121
122 static struct dirent **namelist;
123 static DirList_t *dirlist, *current_dir;
124 static uint32_t numfiles, cnt;
125 static char *first_file, *last_file;
126 static uint32_t twin_first, twin_last;
127
128 /* Functions */
129
130 #ifndef HAVE_SCANDIR
131 #include "scandir.c"
132 #endif
133
134 static int check_number(char *s, int len) {
135 int i;
136 int l = strlen(s);
137
138 for ( i=0; i<l; i++ ) {
139 if ( s[i] < '0' || s[i] > '9' ) {
140 fprintf(stderr, "Time format error at '%s': unexpected character: '%c'.\n", s, s[i]);
141 return 0;
142 }
143 }
144
145 if ( l != len ) {
146 fprintf(stderr, "Time format error: '%s' unexpected.\n", s);
147 return 0;
148 }
149 return 1;
150
151 } // End of check_number
152
153 static int ParseTime(char *s, time_t *t_start ) {
154 struct tm ts;
155 int i;
156 char *p, *q;
157
158
159 /* A time string may look like:
160 * yyyy/MM/dd.hh:mm:ss
161 */
162
163 memset((void *)&ts, 0, sizeof(ts));
164 ts.tm_isdst = -1;
165
166 p = s;
167
168 // parse year
169 q = strchr(p, '/');
170 if ( q ) {
171 *q++ = 0;
172 }
173 if ( !check_number(p,4) )
174 return 0;
175 i = atoi(p);
176 if ( i > 2013 || i < 1970 ) {
177 fprintf(stderr, "Year out of range: '%i'\n", i);
178 *t_start = 0;
179 return 0;
180 }
181 ts.tm_year = i - 1900;
182 if ( !q ) {
183 ts.tm_mday = 1;
184 *t_start = mktime(&ts);
185 return 1;
186 }
187
188 // parse month
189 p = q;
190 q = strchr(p, '/');
191 if ( q )
192 *q++ = 0;
193 if ( !check_number(p,2) )
194 return 0;
195 i = atoi(p);
196 if ( i < 1 || i > 12 ) {
197 fprintf(stderr, "Month out of range: '%i'\n", i);
198 *t_start = 0;
199 return 0;
200 }
201 ts.tm_mon = i - 1;
202 if ( !q ) {
203 ts.tm_mday = 1;
204 *t_start = mktime(&ts);
205 return 1;
206 }
207
208 // Parse day
209 p = q;
210 q = strchr(p, '.');
211 if ( q )
212 *q++ = 0;
213 if ( !check_number(p,2) )
214 return 0;
215 i = atoi(p);
216 if ( i < 1 || i > 31 ) {
217 fprintf(stderr, "Day out of range: '%i'\n", i);
218 *t_start = 0;
219 return 0;
220 }
221 ts.tm_mday = i;
222 if ( !q ) {
223 *t_start = mktime(&ts);
224 return 1;
225 }
226
227 // Parse hour
228 p = q;
229 q = strchr(p, ':');
230 if ( q )
231 *q++ = 0;
232 if ( !check_number(p,2) )
233 return 0;
234 i = atoi(p);
235 if ( i < 0 || i > 23 ) {
236 fprintf(stderr, "Hour out of range: '%i'\n", i);
237 *t_start = 0;
238 return 0;
239 }
240 ts.tm_hour = i;
241 if ( !q ) {
242 *t_start = mktime(&ts);
243 return 1;
244 }
245
246 // Parse minute
247 p = q;
248 q = strchr(p, ':');
249 if ( q )
250 *q++ = 0;
251 if ( !check_number(p,2) )
252 return 0;
253 i = atoi(p);
254 if ( i < 0 || i > 59 ) {
255 fprintf(stderr, "Minute out of range: '%i'\n", i);
256 *t_start = 0;
257 return 0;
258 }
259 ts.tm_min = i;
260 if ( !q ) {
261 *t_start = mktime(&ts);
262 return 1;
263 }
264
265 // Parse second
266 p = q;
267 if ( !check_number(p,2) )
268 return 0;
269 i = atoi(p);
270 if ( i < 0 || i > 59 ) {
271 fprintf(stderr, "Seconds out of range: '%i'\n", i);
272 *t_start = 0;
273 return 0;
274 }
275 ts.tm_sec = i;
276 *t_start = mktime(&ts);
277 return 1;
278
279 } // End of ParseTime
280
281
282 int ScanTimeFrame(char *tstring, time_t *t_start, time_t *t_end) {
283 char *p;
284
285 if ( !tstring ) {
286 fprintf(stderr,"Time Window format error '%s'\n", tstring);
287 return 0;
288 }
289
290 // check for delta time window
291 if ( tstring[0] == '-' || tstring[0] == '+' ) {
292 if ( !twin_first || !twin_last ) {
293 fprintf(stderr,"Time Window error: Check if stat files available\n");
294 return 0;
295 }
296
297 if ( tstring[0] == '-' ) {
298 *t_start = twin_last + atoi(tstring);
299 *t_end = twin_last;
300 return 1;
301 }
302
303 if ( tstring[0] == '+' ) {
304 *t_start = twin_first;
305 *t_end = twin_first + atoi(tstring);
306 return 1;
307 }
308 }
309
310 if ( strlen(tstring) < 4 ) {
311 fprintf(stderr,"Time Window format error '%s'\n", tstring);
312 return 0;
313 }
314 if ( (p = strchr(tstring, '-') ) == NULL ) {
315 ParseTime(tstring, t_start);
316 *t_end = 0xFFFFFFFF;
317 } else {
318 *p++ = 0;
319 ParseTime(tstring, t_start);
320 ParseTime(p, t_end);
321 }
322
323 return *t_start == 0 || *t_end == 0 ? 0 : 1;
324
325 } // End of ScanTimeFrame
326
327 static void ReadNetflowStat(char *sfile){
328 FILE *fd;
329
330 if ( sfile == NULL ) {
331 // printf("No Statfile\n");
332 NetflowStat.Ident[0] = 0;
333 NetflowStat.first_seen = 0;
334 NetflowStat.last_seen = 0;
335 }
336
337 // printf("Statfile %s\n",sfile);
338 fd = fopen(sfile, "r");
339 if ( !fd ) {
340 NetflowStat.Ident[0] = 0;
341 NetflowStat.first_seen = 0;
342 NetflowStat.last_seen = 0;
343 // printf("No such Statfile\n");
344 return;
345 }
346 // printf("Statfile ok\n");
347 fscanf(fd, "Time: %u\n", &NetflowStat.tstamp);
348 fscanf(fd, "Ident: %s\n", NetflowStat.Ident);
349 fscanf(fd, "Flows: %llu\n", &NetflowStat.flows);
350 fscanf(fd, "Flows_tcp: %llu\n", &NetflowStat.flows_tcp);
351 fscanf(fd, "Flows_udp: %llu\n", &NetflowStat.flows_udp);
352 fscanf(fd, "Flows_icmp: %llu\n", &NetflowStat.flows_icmp);
353 fscanf(fd, "Flows_other: %llu\n", &NetflowStat.flows_other);
354 fscanf(fd, "Packets: %llu\n", &NetflowStat.pkts);
355 fscanf(fd, "Packets_tcp: %llu\n", &NetflowStat.pkts_tcp);
356 fscanf(fd, "Packets_udp: %llu\n", &NetflowStat.pkts_udp);
357 fscanf(fd, "Packets_icmp: %llu\n", &NetflowStat.pkts_icmp);
358 fscanf(fd, "Packets_other: %llu\n", &NetflowStat.pkts_other);
359 fscanf(fd, "Bytes: %llu\n", &NetflowStat.bytes);
360 fscanf(fd, "Bytes_tcp: %llu\n", &NetflowStat.bytes_tcp);
361 fscanf(fd, "Bytes_udp: %llu\n", &NetflowStat.bytes_udp);
362 fscanf(fd, "Bytes_icmp: %llu\n", &NetflowStat.bytes_icmp);
363 fscanf(fd, "Bytes_other: %llu\n", &NetflowStat.bytes_other);
364 fscanf(fd, "First: %u\n", &NetflowStat.first_seen);
365 fscanf(fd, "Last: %u\n", &NetflowStat.last_seen);
366 fclose(fd);
367
368 /*
369 printf("Time: %u\n", NetflowStat.tstamp);
370 printf("Ident: %s\n", NetflowStat.Ident);
371 printf("Flows: %llu\n", NetflowStat.flows);
372 printf("Flows_tcp: %llu\n", NetflowStat.flows_tcp);
373 printf("Flows_udp: %llu\n", NetflowStat.flows_udp);
374 printf("Flows_icmp: %llu\n", NetflowStat.flows_icmp);
375 printf("Flows_other: %llu\n", NetflowStat.flows_other);
376 printf("Packets: %llu\n", NetflowStat.pkts);
377 printf("Packets_tcp: %llu\n", NetflowStat.pkts_tcp);
378 printf("Packets_udp: %llu\n", NetflowStat.pkts_udp);
379 printf("Packets_icmp: %llu\n", NetflowStat.pkts_icmp);
380 printf("Packets_other: %llu\n", NetflowStat.pkts_other);
381 printf("Bytes: %llu\n", NetflowStat.bytes);
382 printf("Bytes_tcp: %llu\n", NetflowStat.bytes_tcp);
383 printf("Bytes_udp: %llu\n", NetflowStat.bytes_udp);
384 printf("Bytes_icmp: %llu\n", NetflowStat.bytes_icmp);
385 printf("Bytes_other: %llu\n", NetflowStat.bytes_other);
386 printf("First: %u\n", NetflowStat.first_seen);
387 printf("Last: %u\n", NetflowStat.last_seen);
388 */
389
390 } // End of ReadNetflowStat
391
392 char *GetIdent(void) {
393
394 return strlen(NetflowStat.Ident) > 0 ? NetflowStat.Ident : "none";
395
396 } // End of GetIdent
397
398 uint32_t GetStatTime(void) {
399
400 return NetflowStat.tstamp;
401
402 } // End of GetIdent
403
404 char *TimeString(void){
405 static char datestr[255];
406 char t1[64], t2[64];
407 struct tm *tbuff;
408
409 if ( firstseen ) {
410 tbuff = localtime(&firstseen);
411 if ( !tbuff ) {
412 perror("Error time convert");
413 exit(250);
414 }
415 strftime(t1, 63, "%b %d %Y %T", tbuff);
416
417 tbuff = localtime(&lastseen);
418 if ( !tbuff ) {
419 perror("Error time convert");
420 exit(250);
421 }
422 strftime(t2, 63, "%b %d %Y %T", tbuff);
423
424 snprintf(datestr, 254, "%s - %s", t1, t2);
425 } else {
426 snprintf(datestr, 254, "Time Window unknown");
427 }
428 datestr[254] = 0;
429 return datestr;
430 }
431
432 int CheckTimeWindow(uint32_t t_start, uint32_t t_end) {
433 /*
434 printf("t start %u %s", t_start, ctime(&t_start));
435 printf("t end %u %s", t_end, ctime(&t_end));
436 printf("f start %u %s", NetflowStat.first_seen, ctime(&NetflowStat.first_seen));
437 printf("f end %u %s", NetflowStat.last_seen, ctime(&NetflowStat.last_seen));
438 */
439
440 // if no time window is set, return true
441 if ( t_start == 0 )
442 return 1;
443
444 if ( NetflowStat.first_seen == 0 )
445 return 0;
446
447 if ( t_start >= NetflowStat.first_seen && t_start <= NetflowStat.last_seen )
448 return 1;
449
450 if ( t_end >= NetflowStat.first_seen && t_end <= NetflowStat.last_seen )
451 return 1;
452
453 if ( t_start < NetflowStat.first_seen && t_end > NetflowStat.last_seen )
454 return 1;
455
456
457 return 0;
458
459 } // End of CheckTimeWindow
460
461 void SetSeenTwin(uint32_t first_seen, uint32_t last_seen) {
462 firstseen = first_seen;
463 lastseen = last_seen;
464
465 } /* End of SetSeenTwin */
466
467 // file filter for scandir function
468
469 static int FileFilter(const struct dirent *dir) {
470 struct stat stat_buf;
471 char string[255];
472
473 string[254] = 0;
474 snprintf(string, 254, "%s/%s", dirlist->dirname, dir->d_name);
475 if ( stat(string, &stat_buf) ) {
476 perror("Can't stat entry: ");
477 return 0;
478 }
479
480 // if it's not a file
481 if ( !S_ISREG(stat_buf.st_mode) ) {
482 return 0;
483 }
484 // mask out all stat files
485 if ( strstr(dir->d_name, ".stat") )
486 return 0;
487
488 // mask out tmp file of nfcapd
489 if ( strstr(dir->d_name, "nfcapd.current") )
490 return 0;
491
492 if ( first_file ) {
493 if ( last_file ) {
494 return ( strcmp(dir->d_name, first_file) >= 0 ) && ( strcmp(dir->d_name, last_file) <= 0 );
495 } else {
496 return strcmp(dir->d_name, first_file) >= 0;
497 }
498 } else {
499 if ( last_file ) {
500 return strcmp(dir->d_name, last_file) <= 0;
501 } else {
502 return 1;
503 }
504 }
505
506 } // End of FileFilter
507
508 /*
509 * path my contain:
510 * /path/to/dir/firstfile:lastfile
511 * /path/to/dir/firstfile
512 * /path/to/dir
513 * firstfile:lastfile
514 * firstfile
515 * dir
516 * dirpath is set to the directory containing all the files
517 * first_file and last_file may contain filenames, that limit the file list
518 *
519 */
520 static void GetFileList(char *path) {
521 struct stat stat_buf;
522 char *p, *q, *dirpath, string[512];
523
524
525 // set dirpath to the directory containing all the files
526 // this may also come from the dirlist, if set
527 // Note: Only the first dir in dirlist counts as it is assumed
528 // all the other dirs contain the same files
529 p = strrchr(path, '/');
530 if ( p ) {
531 if ( dirlist ) {
532 // make sure we have no directory path in -R <filelist>
533 // when using multiple directories option -M
534 fprintf(stderr, "File name error: -R <filelist> must not contain a directory name\n");
535 fprintf(stderr, "when using with -M multiple directory option\n");
536 exit(250);
537 } else {
538 *p++ = 0;
539 dirpath = path;
540 }
541 } else {
542 dirpath = dirlist ? dirlist->dirname : ".";
543 p = path;
544 }
545 // dirpath is set
546 // p contains rest of string to analyze:
547 // firstfile:lastfile
548 // firstfile
549 // dir
550
551 first_file = last_file = NULL;
552
553 if ( ( q = strchr(p, ':')) != NULL ) {
554 // we have firstfile:lastfile
555 *q++ = 0;
556 last_file = q;
557 first_file = p;
558 if ( strlen(first_file) == 0 || strlen(last_file) == 0 ) {
559 fprintf(stderr, "Missing file.\n");
560 exit(250);
561 }
562
563 } else {
564 // p is either a directory or a file
565 snprintf(string, 510, "%s/%s", dirpath, p);
566 string[511] = 0;
567 if ( stat(string, &stat_buf) ) {
568 fprintf(stderr, "Can't stat '%s': %s\n", string, strerror(errno));
569 return;
570 }
571
572 // it's a dir
573 if ( S_ISDIR(stat_buf.st_mode) ) {
574 if ( dirlist && (strcmp(path, ".") != 0) ) {
575 fprintf(stderr, "File name error: -R <filelist> must not contain a directory name\n");
576 fprintf(stderr, "when using with -M multiple directory option\n");
577 exit(250);
578 }
579
580 // append dir to dirpath
581 dirpath = strdup(string);
582
583 // it's a file
584 } else if (S_ISREG(stat_buf.st_mode) ) {
585 first_file = p;
586
587 // it's something else
588 } else {
589 fprintf(stderr, "Not a file or directory: '%s'\n", string);
590 exit(250);
591 }
592
593 if ( !dirpath ) {
594 // should never happen, unless out of memory, when strdup is called!
595 fprintf(stderr, "Dirpath NULL\n");
596 exit(250);
597 }
598 }
599
600 // make sure we have at least one entry in the dirlist
601 // so subsequent functions do not have to care any more
602 // if multiple dirs or files or whatever ...
603 if ( !dirlist ) {
604 dirlist = (DirList_t *)malloc(sizeof(DirList_t));
605 if ( !dirlist ) {
606 perror("GetDirList failed!");
607 exit(250);
608 }
609 dirlist->dirname = strdup(dirpath);
610 dirlist->next = NULL;
611 }
612
613 // sanity checks
614 if ( first_file ) {
615 snprintf(string, 254, "%s/%s", dirlist->dirname, first_file);
616 string[254] = '0';
617 if ( stat(string, &stat_buf) ) {
618 fprintf(stderr, "Can't stat file '%s': %s\n", string, strerror(errno));
619 return;
620 }
621 if (!S_ISREG(stat_buf.st_mode) ) {
622 fprintf(stderr, "'%s' is not a file\n", string);
623 return;
624 }
625 }
626 if ( last_file ) {
627 snprintf(string, 254, "%s/%s", dirlist->dirname, last_file);
628 string[254] = '0';
629 if ( stat(string, &stat_buf) ) {
630 fprintf(stderr, "Can't stat file '%s': %s\n", string, strerror(errno));
631 return;
632 }
633 if (!S_ISREG(stat_buf.st_mode) ) {
634 fprintf(stderr, "'%s' is not a file\n", string);
635 return;
636 }
637
638 }
639
640 // scan the directory
641 numfiles = scandir(dirpath, &namelist, FileFilter, alphasort);
642
643 } // End of GetFileList
644
645 /*
646 * Get the list of directories
647 * dirs: user supplied parameter: /any/path/dir1:dir2:dir3:...
648 * dirlist must result in
649 * /any/path/dir1
650 * /any/path/dir2
651 * /any/path/dir3
652 * /any/path is dir prefix, which may be NULL e.g. dir1:dir2:dir3:...
653 * dir1, dir2 etc dirnames
654 */
655 void GetDirList(char *dirs) {
656 struct stat stat_buf;
657 char *p, *q, *dirprefix;
658 char path[1024];
659 DirList_t **list;
660
661 list = &dirlist;
662 q = strchr(dirs, ':');
663 if ( q ) { // we have /path/to/firstdir:dir1:dir2:...
664 *q = 0;
665 p = strrchr(dirs, '/');
666 if ( p ) {
667 *p++ = 0; // p points now to the first name in the dir list
668 dirprefix = dirs;
669 } else { // we have a dirlist in current directory
670 p = dirs; // p points now to the first name in the dir list
671 dirprefix = "."; // current directory
672 }
673 *q = ':'; // restore ':' in dirlist
674
675 while ( p ) { // iterate over all elements in the dir list
676 q = strchr(p, ':');
677 if ( q )
678 *q = 0;
679
680 // p point to a dir name
681 snprintf(path, 1023, "%s/%s", dirprefix, p);
682 path[1023] = 0;
683 if ( stat(dirs, &stat_buf) ) {
684 fprintf(stderr, "Can't stat '%s': %s\n", path, strerror(errno));
685 dirlist = NULL;
686 return;
687 }
688 if ( !S_ISDIR(stat_buf.st_mode) ) {
689 fprintf(stderr, "Not a directory: '%s'\n", path);
690 dirlist = NULL;
691 return;
692 }
693 // save path into dirlist
694 *list = (DirList_t *)malloc(sizeof(DirList_t));
695 if ( !*list ) {
696 perror("GetDirList failed!");
697 exit(250);
698 }
699 (*list)->dirname = strdup(path);
700 (*list)->next = NULL;
701 list = &((*list)->next);
702 p = q ? q + 1 : NULL;
703 }
704
705 } else { // we have only one directory
706 dirlist = NULL;
707 if ( stat(dirs, &stat_buf) ) {
708 fprintf(stderr, "Can't stat '%s': %s\n", dirs, strerror(errno));
709 return;
710 }
711 if ( !S_ISDIR(stat_buf.st_mode) ) {
712 fprintf(stderr, "Not a directory: '%s'\n", dirs);
713 return;
714 }
715 dirlist = (DirList_t *)malloc(sizeof(DirList_t));
716 if ( !dirlist ) {
717 perror("GetDirList failed!");
718 exit(250);
719 }
720 dirlist->dirname = strdup(dirs);
721 dirlist->next = NULL;
722 }
723
724 } // End of GetDirList
725
726 void SetupInputFileSequence(char *multiple_dirs, char *single_file, char *multiple_files) {
727 char string[255];
728 char *p;
729
730 namelist = NULL;
731 twin_first = 0;
732 twin_last = 0xffffffff;
733
734 if ( multiple_dirs )
735 GetDirList(multiple_dirs);
736
737 if ( multiple_files ) {
738 // use multiple files
739 numfiles = 0;
740 GetFileList(multiple_files);
741
742 // get time window spanning all the files
743 if ( numfiles ) {
744 snprintf(string, 254, "%s/%s.stat", dirlist->dirname, namelist[0]->d_name);
745 ReadNetflowStat(string); // read the corresponding stat file
746 twin_first = NetflowStat.first_seen;
747 snprintf(string, 254, "%s/%s.stat", dirlist->dirname, namelist[numfiles-1]->d_name);
748 ReadNetflowStat(string); // read the corresponding stat file
749 twin_last = NetflowStat.last_seen;
750 }
751
752 } else if ( single_file ) {
753 if ( dirlist && strchr(single_file, '/') ) {
754 fprintf(stderr, "File name error: -r <file> must not contain a directory name\n");
755 fprintf(stderr, "when using with -M multiple directory option\n");
756 exit(250);
757 }
758 // printf("Set single %s\n", single_file);
759 // Normalize the lists:
760 // if we have no dirlist, make one with a single entry
761 // and store the directory part in dirlist
762 namelist = ( struct dirent **)malloc(sizeof(struct dirent *));
763 if ( !namelist ) {
764 perror("GetDirList failed!");
765 exit(250);
766 }
767 *namelist = ( struct dirent *)malloc(sizeof(struct dirent ));
768 if ( !*namelist ) {
769 perror("GetDirList failed!");
770 exit(250);
771 }
772
773 /* with best regards from Solaris */
774 if ( sizeof((*namelist)->d_name) < 255 )
775 *namelist = ( struct dirent *)realloc(*namelist, sizeof(struct dirent ) - sizeof((*namelist)->d_name) + 255);
776
777 if ( !*namelist ) {
778 perror("GetDirList failed!");
779 exit(250);
780 }
781
782 if ( !dirlist ) {
783 dirlist = (DirList_t *)malloc(sizeof(DirList_t));
784 if ( !dirlist ) {
785 perror("GetDirList failed!");
786 exit(250);
787 }
788 dirlist->next = NULL;
789
790 p = strrchr(single_file, '/');
791 if ( p ) {
792 *p++ = 0;
793 dirlist->dirname = strdup(single_file);
794 } else {
795 dirlist->dirname = ".";
796 p = single_file;
797 }
798 strncpy(namelist[0]->d_name, p, 255);
799 (namelist[0]->d_name)[255] = 0;
800 } else {
801 strncpy(namelist[0]->d_name, single_file, 255);
802 (namelist[0]->d_name)[255] = 0;
803 }
804 numfiles = 1;
805
806 } else {
807 // use stdin
808 // dirlist == NULL
809 numfiles = 1;
810 }
811
812 // set first directory to current dir
813 cnt = 0;
814 current_dir = dirlist;
815
816 /*
817 for ( current_dir = dirlist; current_dir != NULL; current_dir = current_dir->next ) {
818 fprintf(stderr, "Dirlist: '%s'\n", current_dir->dirname);
819 }
820 fprintf(stderr, "\n");
821 for ( i = 0; i < numfiles; i++ ) {
822 fprintf(stderr, "File: '%s'\n", namelist[i]->d_name);
823 }
824 current_dir = dirlist;
825 */
826
827 } // End of SetupInputFileSequence
828
829 int GetNextFile(int current, time_t twin_start, time_t twin_end) {
830 struct stat stat_buf;
831 char string[255], *fname;
832 int stat_failed;
833
834 // close current file before open the next one
835 // stdin ( current = 0 ) is not closed
836 if ( current )
837 close(current);
838
839 // no or no more files available
840 if ( (numfiles == 0) ) {
841 errno = 0;
842 return -1;
843 }
844
845 if ( dirlist == NULL ) {
846 // use stdin
847 // printf("Return stdin\n");
848 numfiles = 0;
849 return STDIN_FILENO;
850 }
851
852 while ( cnt < numfiles ) {
853 while ( current_dir ) {
854 fname = namelist[cnt]->d_name;
855 snprintf(string, 254, "%s/%s.stat", current_dir->dirname, fname);
856 ReadNetflowStat(string); // read the corresponding stat file
857 if ( CheckTimeWindow(twin_start, twin_end) ) {
858 snprintf(string, 254, "%s/%s", current_dir->dirname, fname);
859 stat_failed = 0;
860 if ( stat(string, &stat_buf) ) {
861 fprintf(stderr, "Can't stat '%s': %s\n", string, strerror(errno));
862 stat_failed = 1;
863 }
864 if (!S_ISREG(stat_buf.st_mode) ) {
865 fprintf(stderr, "'%s' is not a file\n", string);
866 stat_failed = 1;
867 }
868 // total_bytes += stat_buf.st_size;
869 // printf("Return file: %s\n", string);
870 current_dir = current_dir->next;
871 if ( !stat_failed )
872 return open(string, O_RDONLY);
873 }
874 // in the event of missing the stat file in the last directory
875 // of the directory queue current_dir is already NULL
876 current_dir = current_dir ? current_dir->next : NULL;
877 }
878 cnt++;
879 current_dir = dirlist;
880 }
881
882
883 errno = 0;
884 return -1;
885
886 } // End of GetNextFile
887
888 void SetLimits(int stat, char *packet_limit_string, char *byte_limit_string ) {
889 char *s, c;
890 uint32_t len,scale;
891
892 if ( ( stat == 0 ) && ( packet_limit_string || byte_limit_string )) {
893 fprintf(stderr,"Options -l and -L do not make sense for plain packet dumps.\n");
894 fprintf(stderr,"Use -l and -L together with -s -S or -a.\n");
895 fprintf(stderr,"Use netflow filter syntax to limit the number of packets and bytes in netflow records.\n");
896 exit(250);
897 }
898 packet_limit = byte_limit = 0;
899 if ( packet_limit_string ) {
900 switch ( packet_limit_string[0] ) {
901 case '-':
902 packet_mode = LESS;
903 s = &packet_limit_string[1];
904 break;
905 case '+':
906 packet_mode = MORE;
907 s = &packet_limit_string[1];
908 break;
909 default:
910 if ( !isdigit((int)packet_limit_string[0])) {
911 fprintf(stderr,"Can't understand '%s'\n", packet_limit_string);
912 exit(250);
913 }
914 packet_mode = MORE;
915 s = packet_limit_string;
916 }
917 len = strlen(packet_limit_string);
918 c = packet_limit_string[len-1];
919 switch ( c ) {
920 case 'B':
921 case 'b':
922 scale = 1;
923 break;
924 case 'K':
925 case 'k':
926 scale = 1024;
927 break;
928 case 'M':
929 case 'm':
930 scale = 1024 * 1024;
931 break;
932 case 'G':
933 case 'g':
934 scale = 1024 * 1024 * 1024;
935 break;
936 default:
937 scale = 1;
938 if ( isalpha((int)c) ) {
939 fprintf(stderr,"Can't understand '%c' in '%s'\n", c, packet_limit_string);
940 exit(250);
941 }
942 }
943 packet_limit = atol(s) * scale;
944 }
945
946 if ( byte_limit_string ) {
947 switch ( byte_limit_string[0] ) {
948 case '-':
949 byte_mode = LESS;
950 s = &byte_limit_string[1];
951 break;
952 case '+':
953 byte_mode = MORE;
954 s = &byte_limit_string[1];
955 break;
956 default:
957 if ( !isdigit((int)byte_limit_string[0])) {
958 fprintf(stderr,"Can't understand '%s'\n", byte_limit_string);
959 exit(250);
960 }
961 byte_mode = MORE;
962 s = byte_limit_string;
963 }
964 len = strlen(byte_limit_string);
965 c = byte_limit_string[len-1];
966 switch ( c ) {
967 case 'B':
968 case 'b':
969 scale = 1;
970 break;
971 case 'K':
972 case 'k':
973 scale = 1024;
974 break;
975 case 'M':
976 case 'm':
977 scale = 1024 * 1024;
978 break;
979 case 'G':
980 case 'g':
981 scale = 1024 * 1024 * 1024;
982 break;
983 default:
984 if ( isalpha((int)c) ) {
985 fprintf(stderr,"Can't understand '%c' in '%s'\n", c, byte_limit_string);
986 exit(250);
987 }
988 scale = 1;
989 }
990 byte_limit = atol(s) * scale;
991 }
992
993 if ( byte_limit )
994 printf("Byte limit: %c %u bytes\n", byte_mode == LESS ? '<' : '>', byte_limit);
995
996 if ( packet_limit )
997 printf("Packet limit: %c %u packets\n", packet_mode == LESS ? '<' : '>', packet_limit);
998
999
1000 } // End of SetLimits
1001
1002 void UpdateTimeWindow ( time_t *start, time_t *end ) {
1003
1004 if ( NetflowStat.first_seen < *start )
1005 *start = NetflowStat.first_seen;
1006 if ( NetflowStat.last_seen > *end )
1007 *end = NetflowStat.last_seen;
1008
1009 } // End of UpdateTimeWindow
0 /*
1 * This file is part of the nfdump project.
2 *
3 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither the name of SWITCH nor the names of its contributors may be
15 * used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Author: peter $
31 *
32 * $Id: util.h 34 2005-08-22 12:01:31Z peter $
33 *
34 * $LastChangedRevision: 34 $
35 *
36 */
37
38
39 #include <time.h>
40 #include <sys/types.h>
41
42 int ScanTimeFrame(char *tstring, time_t *t_start, time_t *t_end);
43
44 char *GetIdent(void);
45
46 int CheckTimeWindow(uint32_t t_start, uint32_t t_end);
47
48 uint32_t GetStatTime(void);
49
50 char *TimeString(void);
51
52 void SetupInputFileSequence(char *multiple_dirs, char *single_file, char *multiple_files);
53
54 int GetNextFile(int current, time_t twin_start, time_t twin_end);
55
56 void SetSeenTwin(uint32_t first_seen, uint32_t last_seen);
57
58 void SetLimits(int stat, char *packet_limit_string, char *byte_limit_string );
59
60 void UpdateTimeWindow ( time_t *start, time_t *end );
61
62
0 /*
1 * Copyright (c) 2004, SWITCH - Teleinformatikdienste fuer Lehre und Forschung
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * * Neither the name of SWITCH nor the names of its contributors may be
13 * used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Author: peter $
29 *
30 * $Id: version.h 53 2005-11-17 07:45:34Z peter $
31 *
32 * $LastChangedRevision: 53 $
33 *
34 *
35 */
36
37
38 const char *nfdump_version = "1.4.1";
39 const char *nfdump_date = "$LastChangedDate: 2005-11-17 08:45:34 +0100 (Thu, 17 Nov 2005) $";
40