mirror of
https://github.com/adulau/ssldump.git
synced 2025-07-16 10:33:13 +00:00
ssldump_0.9b3.orig.tar.gz Import
This commit is contained in:
commit
ea12dfe6d2
100 changed files with 22293 additions and 0 deletions
60
COPYRIGHT
Normal file
60
COPYRIGHT
Normal file
|
@ -0,0 +1,60 @@
|
|||
SSLDUMP LICENSE
|
||||
Copyright (C) 1999-2001 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE ERIC RESCORLA AND RTFM ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
TCPDUMP LICENSE
|
||||
The manual page for this software is partially excerpted from
|
||||
the tcpdump manual page, which is subject to the following license:
|
||||
Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
|
||||
The Regents of the University of California. All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that: (1) source code distributions
|
||||
retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
distributions including binary code include the above copyright notice and
|
||||
this paragraph in its entirety in the documentation or other materials
|
||||
provided with the distribution, and (3) all advertising materials mentioning
|
||||
features or use of this software display the following acknowledgement:
|
||||
``This product includes software developed by the University of California,
|
||||
Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
the University nor the names of its contributors may be used to endorse
|
||||
or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
20
CREDITS
Normal file
20
CREDITS
Normal file
|
@ -0,0 +1,20 @@
|
|||
ssldump was written by Eric Rescorla <ekr@rtfm.com>
|
||||
|
||||
The Windows port of ssldump was provided by Greg Stark.
|
||||
|
||||
The following people have provided bug fixes, bug reports, or suggestions.
|
||||
Adam Cain
|
||||
Pavel Curtis
|
||||
Chris Jepeway
|
||||
Alexander Fetke
|
||||
Jeffrey Hafey
|
||||
Lutz Jaenicke
|
||||
Dave Jagoda
|
||||
Norbert Klasen
|
||||
Richard Levitte
|
||||
Hugh Mandeville
|
||||
Eric Murray
|
||||
Henrik Nordstrom
|
||||
|
||||
If you think you should be on this list, send me mail at <ekr@rtfm.com>.
|
||||
|
158
ChangeLog
Normal file
158
ChangeLog
Normal file
|
@ -0,0 +1,158 @@
|
|||
Wed Aug 21 10:48:45 2002 EKR <ekr@rtfm.com>
|
||||
* Installed Greg Stark's new Win32 patches.
|
||||
|
||||
* Added updated VLAN support (Jeffrey Hafey)
|
||||
|
||||
Fri Aug 16 16:56:23 2002 EKR <ekr@rtfm.com>
|
||||
* Cleaned up 56-bit ciphersuites in ciphersuites.c
|
||||
|
||||
* Fixed memory errors in packet copying.
|
||||
|
||||
* Fixed bugs in processing of bogus SSLv2 messages.
|
||||
|
||||
* Fixed bugs in TCP packet reassembly code.
|
||||
|
||||
Tue Aug 13 13:03:41 2002 EKR <ekr@rtfm.com>
|
||||
* Fixed EXPORT1024 DES cipher suites
|
||||
|
||||
Mon Aug 12 16:49:51 2002 EKR <ekr@rtfm.com>
|
||||
* Added support for VLAN networks (Jeffrey Hafey)
|
||||
|
||||
* Fixed printing of data with embedded tabs (Pavel Curtis)
|
||||
|
||||
* Added support for non-promiscuous mode (-P flag)
|
||||
(Bruce M Simpson)
|
||||
|
||||
* Fixed potential small overrun in RSA decryption.
|
||||
|
||||
Fri Sep 28 15:54:47 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed install so that we install in /usr/local/sbin
|
||||
with mode 755. Bug report ssldump/22.
|
||||
(Dave Jagoda)
|
||||
|
||||
* Fixed compilation warning about create_null_analyzer
|
||||
Bug report ssldump/23.
|
||||
|
||||
Wed Sep 26 14:49:06 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed SYN & SYN/ACK detection to that it works with ECN.
|
||||
(Henrik Nordstrom)
|
||||
|
||||
* Added /usr/include/pcap to the PCAP search path
|
||||
(Henrik Nordstrom)
|
||||
|
||||
Sat Sep 15 13:41:10 2001 EKR <ekr@rtfm.com>
|
||||
* Fix to ssldecode.c to remove error with empty
|
||||
struct when compiling with VC++ and no OpenSSL
|
||||
(Greg Stark)
|
||||
|
||||
* Change to vcwin32.mak to print out that you're not
|
||||
using OpenSSL (Greg Stark)
|
||||
|
||||
* Automatic version changing courtesy of version-change.pl
|
||||
|
||||
Fri Sep 14 15:22:29 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed bug 4. Delete the MS after decrypting a PMS
|
||||
to force new MS generation in the key generation phase.
|
||||
This makes decryption of renegotiated connections work
|
||||
correctly. This got broken when session resumption
|
||||
was added.
|
||||
|
||||
2001-09-14 Eric Rescorla <ekr@rtfm.com>
|
||||
|
||||
* Imported Greg Stark's Win32 port
|
||||
|
||||
Sun Sep 2 15:53:06 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed the reassembler so it doesn't crash when
|
||||
FIN/RST segments have data.
|
||||
|
||||
* closure/connection freeing now works, thus meaning less
|
||||
memory leakage and less crashing.
|
||||
|
||||
* A bunch of trivial makefile/configure fixes.
|
||||
|
||||
Fri Jul 20 16:40:51 2001 EKR <ekr@rtfm.com>
|
||||
* Removed loading of certificate file. This served
|
||||
no real purpose. Fix for bug 5.
|
||||
|
||||
Fri Jul 20 11:02:09 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed initialization so that the key file is loaded
|
||||
only once.
|
||||
|
||||
Removed default keyfile and password. You now must
|
||||
specify them. You also get an error if you specify
|
||||
a bad password or keyfile.
|
||||
|
||||
Fri Jul 20 10:17:36 2001 EKR <ekr@rtfm.com>
|
||||
* Added support for session resumption.
|
||||
|
||||
Fri Jul 20 10:17:16 2001 EKR <ekr@rtfm.com>
|
||||
* Fixed SEQ_LT problems on Linux and other compilation
|
||||
problems.
|
||||
|
||||
Tue Mar 6 2001 EKR <ekr@rtfm.com>
|
||||
* Removed statically allocated conn array. We can now
|
||||
have an arbitrary number of
|
||||
|
||||
Thu Nov 9 12:14:15 2000 EKR <ekr@rtfm.com>
|
||||
* Cleanups to the man page and cleaned up some cases
|
||||
where printing didn't work quite right.
|
||||
|
||||
Mon Nov 6 10:22:25 2000 EKR <ekr@rtfm.com>
|
||||
* Added the -X flag to force hex-only printing when
|
||||
binary data is displayed as hex dumps.
|
||||
|
||||
Fri Nov 3 09:23:35 2000 EKR <ekr@rtfm.com>
|
||||
* cleaned up the case where multiple handshake messages
|
||||
are in the same SSL record.
|
||||
|
||||
Fri Nov 3 09:14:39 2000 EKR <ekr@rtfm.com>
|
||||
* Modified printing so that when we're printing hex dumps
|
||||
of application data traffic we also print the printable
|
||||
sections of the data itself in a column on the side.
|
||||
|
||||
Thu Nov 2 14:14:21 2000 EKR <ekr@rtfm.com>
|
||||
* Modified cipher suite printing so that the names have
|
||||
SSL_ if we're doing SSLv3 and TLS_ if we're doing TLS.
|
||||
Suggestion by Eric Murray.
|
||||
|
||||
Thu Nov 2 13:07:09 2000 EKR <ekr@rtfm.com>
|
||||
* Fixed an ABW in ssldecode.c that caused crashes
|
||||
on Solaris. Also, fixed a bunch of memory leaks
|
||||
using Purify.
|
||||
|
||||
Thu Nov 2 08:45:42 2000 EKR <ekr@rtfm.com>
|
||||
* Various Portability fixes
|
||||
CC=gcc -> CC=@CC@ in Makefile
|
||||
Removed FLAGS in Makefile (it was a noop)
|
||||
in base/tcpconn.c, changed {} to {0} to appease HPUX's compiler
|
||||
made create_null_analyzer.c static as it should be.
|
||||
Removed the final (bogus) entry in null_vtbl.
|
||||
made sslx__print_serial() static to match its prototype
|
||||
Rearranged library order for better linkage
|
||||
Thanks to Lutze Jainecke for these fixes.
|
||||
|
||||
Thu Nov 2 08:41:10 2000 EKR <ekr@rtfm.com>
|
||||
* Added -r as a synonym for -f. -f will eventually
|
||||
be removed and reused for some other option.
|
||||
This was done for option compatibility with tcpdump
|
||||
and on the theory that someday I might add a -w.
|
||||
|
||||
* Renamed -h to -H and added it to the documentation.
|
||||
-h now triggers usage info.
|
||||
|
||||
Thu Nov 2 08:38:06 2000 EKR <ekr@rtfm.com>
|
||||
* Removed blank lines in the man page. This confuses some
|
||||
man page formatters. (Thanks to Hugh Mandeville for pointing
|
||||
this one out)
|
||||
|
||||
Thu Nov 2 08:37:59 2000 EKR <ekr@rtfm.com>
|
||||
* Wired up -N (it was unwired)
|
||||
|
||||
Thu Nov 2 08:37:47 2000 EKR <ekr@rtfm.com>
|
||||
* Added -D_BSD_SOURCE=1 when you're compiling on Linux.
|
||||
(Allowing it to compile)
|
||||
|
||||
|
||||
|
||||
|
||||
|
9
FILES
Normal file
9
FILES
Normal file
|
@ -0,0 +1,9 @@
|
|||
record-fmt.txt
|
||||
record_analyze.c
|
||||
record_analyze.h
|
||||
targets.mk
|
||||
|
||||
CVS:
|
||||
Entries
|
||||
Repository
|
||||
Root
|
46
INSTALL
Normal file
46
INSTALL
Normal file
|
@ -0,0 +1,46 @@
|
|||
$Id: INSTALL,v 1.5 2001/09/14 22:29:13 ekr Exp $
|
||||
|
||||
If you don't have libpcap, you'll need to get it and install it. You
|
||||
can obtain it from:
|
||||
http://www.tcpdump.org/
|
||||
|
||||
If you want to be able to decrypt SSL traffic or view certificates,
|
||||
get OpenSSL if you don't have it:
|
||||
http://www.openssl.org/
|
||||
|
||||
Once you've built and installed libpcap and OpenSSL, you're ready to
|
||||
build ssldump.
|
||||
|
||||
ssldump uses a GNU autoconf-based configuration to automatically
|
||||
configure the build.
|
||||
|
||||
In the simplest form you can simply do:
|
||||
./configure
|
||||
|
||||
If the configure script can't find libpcap, it will abort. If you've
|
||||
installed it in unobvious place, you may need to give configure a hint
|
||||
using the '--with-pcap' or '--with-pcap-{lib,inc}' switches.
|
||||
|
||||
If the configure script can't find OpenSSL, it will continue without
|
||||
it. If your OpenSSL is in a nonstandard location, you may need to give
|
||||
configure a hint with the '--with-openssl' or
|
||||
'--with-openssl-{lib,include}' switches.
|
||||
|
||||
Once you've done the configure, you can simply run 'make'. Note that
|
||||
on some platforms (HP/UX) you will have to use GNU make (gmake).
|
||||
|
||||
If the make succeeds, run a 'make install' (you will probably need to
|
||||
be root to do this.)
|
||||
|
||||
TESTED PLATFORMS
|
||||
FreeBSD 2.2.8, 3.4
|
||||
HP/UX 10.20
|
||||
Linux (Red Hat, Debian)
|
||||
Solaris 2.x
|
||||
|
||||
If you get ssldump to work on a platform not listed above, please send mail
|
||||
to ssldump@rtfm.com with the platform and any fixes you had to make.
|
||||
|
||||
INSTALLING ON WINDOWS
|
||||
Read the file INSTALL.W32 in this directory for instructions on
|
||||
installing on Windows.
|
114
INSTALL.W32
Normal file
114
INSTALL.W32
Normal file
|
@ -0,0 +1,114 @@
|
|||
Notes
|
||||
|
||||
|
||||
First, make sure you've read the README file.
|
||||
|
||||
Build Environment
|
||||
-----------------
|
||||
|
||||
The build environment is assumed to be Microsoft Visual C++ 6.0 SP4
|
||||
(VC6), although earlier or later versions may work. In particular, the
|
||||
make-like utility used to build this port of ssldump is NMAKE version
|
||||
6.00.x from Microsoft.
|
||||
|
||||
The basis for this port is ssldump version 0.9b3. The win32 directory
|
||||
contains the win32-specific stuff, including the NMAKE makefile
|
||||
vcwin32.mak.
|
||||
|
||||
You need to have your environment variables and PATH correctly setup
|
||||
to properly use the command-line VC6 tools. In the VC6\bin directory
|
||||
is a batch file, VCVARS32.bat, which should set things up
|
||||
correctly. You should run this batch file prior to attempting a build.
|
||||
|
||||
|
||||
|
||||
What you need (besides the ssldump source)
|
||||
------------------------------------------
|
||||
|
||||
You must have downloaded and installed the following from the
|
||||
WinPcap/Windump project:
|
||||
|
||||
1. The Winpcap developer's pack, version 2.3, from
|
||||
http://winpcap.polito.it/install/bin/WPdpack_2_3.zip contains the
|
||||
pcap.h and net/bpf.h files, and the pcap import library. Place these
|
||||
in the win32 directory.
|
||||
|
||||
2. The Winpcap source code distribution, version 2.3, from
|
||||
http://winpcap.polito.it/install/bin/WPcapSrc_2_3.zip. It contains
|
||||
some .h files commonly found on UNIX systems that ssldump
|
||||
expects. Place these in the win32 directory.
|
||||
|
||||
3. The Winpcap auto-installer, version 2.3, from
|
||||
http://winpcap.polito.it/install/bin/WinPcap_2_3_nogui.exe. This is
|
||||
only needed to run ssldump, not needed to build it. It is needed on
|
||||
*any* windows system on which ssldump is run. It installs a device
|
||||
driver and the pcap library DLL.
|
||||
|
||||
4. Possibly the Windump utility from
|
||||
http://windump.polito.it/install/bin/WinDump.exe. This is essentially
|
||||
a Windows port of tcpdump, with an extra -D option. This option
|
||||
enumerates the interface names so that you at least have a clue to
|
||||
what to supply the -i option (see below).
|
||||
|
||||
The win32 directory should look like the following after these files
|
||||
are downloaded and extracted:
|
||||
|
||||
winpcap <directory>
|
||||
WPdpack <directory>
|
||||
Ssldump.html
|
||||
vcwin32.mak
|
||||
|
||||
|
||||
|
||||
OpenSSL Support
|
||||
---------------
|
||||
|
||||
By default, the OpenSSL libraries are not linked into ssldump. If you
|
||||
want to link in the OpenSSL libraries, you'll need to customize the
|
||||
makefile. First, look for the macro OPENSSL and change its value to
|
||||
"yes". Next, look for the macro OPENSSL_DIR and make sure it points to
|
||||
the openssl distribution on your machine. You must build a version(s)
|
||||
of SSL that links to the static C run-time library; these are
|
||||
distinguished by the use of the compiler flag /MT for release
|
||||
versions, and /MTd for debug versions. Then you must set the
|
||||
OPENSSL_RELEASE and OPENSSL_DEBUG macros to point to the directories
|
||||
that contain the libraries for these versions. If you only intend to
|
||||
build one of either the debug or release versions, you only need to
|
||||
define the corresponding OPENSSL_ macro.
|
||||
|
||||
|
||||
|
||||
Building ssldump
|
||||
----------------
|
||||
|
||||
To build, run (from the ssldump root directory):
|
||||
|
||||
nmake /f win32\vcwin32.mak all
|
||||
|
||||
this creates a directory, out32, which contains the object files and
|
||||
the ssldump.exe executable. The build produces a simple command-line
|
||||
ssldump.exe which must be run from a console window (i.e. a DOS
|
||||
box). It builds the release version by default. Set the macro
|
||||
CFG="debug" to build a debug version, e.g. nmake /f vcwin32.mak all
|
||||
CFG="debug".
|
||||
|
||||
win32\ssldump.html contains an HTML version of the ssldump.1
|
||||
manpage. You should read this to learn the options.
|
||||
|
||||
|
||||
|
||||
What are the names of the Interfaces?
|
||||
-------------------------------------
|
||||
|
||||
One tricky aspect is choosing the correct interface name for the -i
|
||||
option of ssldump. AFAIK, there is no standard windows utility that
|
||||
will give you the correct names for the interfaces. For example, on my
|
||||
system they are named PPPMAC (for the PPP adapter) and CBEN5 (for my
|
||||
Ethernet Adapter). I did find these names in the registry under
|
||||
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net\nnnn\NDIS\LogDriverName,
|
||||
but this may be different on other Windows OSes. The Windump utility
|
||||
from the WinPcap folks has an option, -D, to enumerate these interface
|
||||
names. Use the Windump utility or hunt through the registry to find
|
||||
the names of your interfaces. If you don't specify the interface
|
||||
explicitly with the -i option, ssldump will select the 'first'
|
||||
interface and this may be exactly what you want.
|
111
Makefile.in
Normal file
111
Makefile.in
Normal file
|
@ -0,0 +1,111 @@
|
|||
# Copyright (C) 1999-2000 RTFM, Inc.
|
||||
# All Rights Reserved
|
||||
|
||||
# This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
# <ekr\@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
#
|
||||
# This product includes software developed by Eric Rescorla for
|
||||
# RTFM, Inc.
|
||||
|
||||
# 4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
# used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
PLATFORM=freebsd31
|
||||
CC=@CC@
|
||||
|
||||
all: ssldump
|
||||
|
||||
OBJSUFFIX=o
|
||||
LIBSUFFIX=a
|
||||
INSTALL=@INSTALL@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
BINDIR=@sbindir@
|
||||
MANDIR=@mandir@
|
||||
RM=rm -f
|
||||
|
||||
ROOT=./
|
||||
ANALYZE_SRCDIR=$(ROOT)base/
|
||||
COMMONDIR=common/
|
||||
COMMON_LIB_SRCDIR=$(COMMONDIR)lib/
|
||||
ANALYZE_NULL_SRCDIR=$(ROOT)null/
|
||||
ANALYZE_SSL_SRCDIR=$(ROOT)ssl/
|
||||
ANALYZE_RECORD_SRCDIR=$(ROOT)@RECORD_MOD@/
|
||||
include rules.mk
|
||||
|
||||
include $(COMMON_LIB_SRCDIR)/targets.mk
|
||||
include $(ANALYZE_SRCDIR)targets.mk
|
||||
include $(ANALYZE_NULL_SRCDIR)targets.mk
|
||||
include $(ANALYZE_SSL_SRCDIR)targets.mk
|
||||
include $(ANALYZE_RECORD_SRCDIR)targets.mk
|
||||
|
||||
INCLUDES += -I$(COMMONDIR)include/ -I$(ANALYZE_NULL_SRCDIR) -I$(ANALYZE_SSL_SRCDIR)
|
||||
|
||||
|
||||
DEFINES += @DEFINES@
|
||||
INCLUDES += @INCLUDES@
|
||||
LIBS += @LDFLAGS@ @LIBS@
|
||||
|
||||
CFLAGS += @CFLAGS@ @DEFS@
|
||||
|
||||
|
||||
ssldump: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o $@ $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) ssldump
|
||||
|
||||
install:
|
||||
[ -d $(BINDIR) ] || mkdir -p $(BINDIR)
|
||||
$(INSTALL) -m 755 ssldump $(BINDIR)/ssldump
|
||||
[ -d $(MANDIR) ] || mkdir -p $(MANDIR)/man1
|
||||
$(INSTALL) -m 444 ssldump.1 $(MANDIR)/man1/ssldump.1
|
||||
|
||||
dist:
|
||||
perl "./version-check.pl"
|
||||
- name=ssldump-`cat VERSION`; \
|
||||
rm -rf /dist/ship/$$name; \
|
||||
mkdir /dist/ship/$$name; \
|
||||
cp -pR * /dist/ship/$$name; \
|
||||
cd /dist/ship/$$name; \
|
||||
make -f Makefile.in clean; \
|
||||
rm Makefile; \
|
||||
find . -name '*~' -exec rm {} \; -print;\
|
||||
find . -name '*.o' -exec rm {} \; -print;\
|
||||
find . -name '#*#' -exec rm {} \; -print;\
|
||||
find . -name 'CVS' -exec rm -rf {} \; -print;\
|
||||
find . -name '*bak' -exec rm -rf {} \; -print;\
|
||||
find . -name '*.core' -exec rm -rf {} \; -print;\
|
||||
find . -name '*.tr' -exec rm -rf {} \; -print;\
|
||||
find . -name '*.pl' -exec rm -rf {} \; -print;\
|
||||
find . -name '*.pem' -exec rm -rf {} \; -print;\
|
||||
find . -name '*orig' -exec rm -rf {} \; -print;\
|
||||
find . -name '*.rej' -exec rm -rf {} \; -print;\
|
||||
rm -f TODO TAGS; \
|
||||
rm -f config.status config.log config.cache config.h; \
|
||||
rm -f ssl/a.out all; \
|
||||
cd /dist/ship; tar cf - $$name | gzip > $$name.tar.gz
|
||||
|
||||
|
85
README
Normal file
85
README
Normal file
|
@ -0,0 +1,85 @@
|
|||
$Id: README,v 1.9 2002/08/17 01:33:15 ekr Exp $
|
||||
|
||||
SSLDUMP 0.9b3
|
||||
|
||||
ssldump is an SSLv3/TLS network protocol analyzer. It identifies TCP
|
||||
connections on the chosen network interface and attempts to interpret
|
||||
them as SSLv3/TLS traffic. When it identifies SSLv3/TLS traffic, it
|
||||
decodes the records and displays them in a textual form to stdout. If
|
||||
provided with the appropriate keying material, it will also decrypt
|
||||
the connections and display the application data traffic.
|
||||
|
||||
ssldump depends on the libpcap packet capture library. Some systems
|
||||
(e.g. FreeBSD) now have libpcap as part of their standard install. On
|
||||
other systems, you will need to install it. You can obtain the
|
||||
distribution from:
|
||||
http://www.tcpdump.org/
|
||||
|
||||
If linked with OpenSSL, ssldump can display certificates in decoded
|
||||
form and decrypt traffic (provided that it has the appropriate keying
|
||||
material). Again, OpenSSL may be installed on your system. Otherwise
|
||||
you can obtain it from:
|
||||
http://www.openssl.org/
|
||||
|
||||
See the file INSTALL for instructions on building and installing
|
||||
ssldump.
|
||||
|
||||
STABILITY
|
||||
This is a beta release of ssldump. The UNIX portions have received
|
||||
extensive testing and are believed to be quite solid. The Windows
|
||||
port is substantially less stable.
|
||||
|
||||
CHANGES SINCE 0.9b2
|
||||
Security fix: some potential over and underflows
|
||||
Added support for VLANs.
|
||||
Added -P flag to disable promiscuous mode.
|
||||
Fixed bugs in the TCP reassembly code.
|
||||
A lot of bug fixes.
|
||||
|
||||
See the ChangeLog for a more complete list of changes.
|
||||
|
||||
MAILING LIST
|
||||
For support questions and general discussion on ssldump, please
|
||||
subscribe to the ssldump-users mailing list. Subscription is by
|
||||
majordomo. To subscribe, send a message with no subject and a body
|
||||
consisting of the single line:
|
||||
|
||||
subscribe ssldump-users
|
||||
|
||||
to majordomo@rtfm.com. Note, you cannot send messages to the list
|
||||
unless you are subscribed.
|
||||
|
||||
BUG REPORTS
|
||||
Please send bug reports either to the ssldump-users mailing list
|
||||
or to ssldump@rtfm.com.
|
||||
|
||||
INTEROPERABILITY NOTE
|
||||
Previous versions of ssldump automatically looked for the keyfile
|
||||
in 'server.pem' and used the password 'password'. This version
|
||||
removes those defaults. For decryption to work you MUST specify
|
||||
the keyfile (and password if the keyfile is encrypted.)
|
||||
|
||||
NEW VERSIONS
|
||||
Newer versions of ssldump can be found at:
|
||||
http://www.rtfm.com/ssldump/
|
||||
|
||||
|
||||
SSL REFERENCES
|
||||
The SSLv3 specification can be found at:
|
||||
http://home.netscape.com/eng/ssl3/draft302.txt
|
||||
|
||||
The TLS specification is in RFC 2246 and can be found at:
|
||||
http://www.ietf.org/rfc/rfc2246.txt
|
||||
|
||||
SHAMELESS PLUG
|
||||
Extremely detailed coverage of SSL/TLS can be found in
|
||||
|
||||
_SSL_and_TLS:_Designing_and_Building_Secure_Systems_
|
||||
Eric Rescorla
|
||||
Addison-Wesley, 2001
|
||||
ISBN 0-201-61598-3
|
||||
|
||||
_SSL_and_TLS_ makes extensive use of ssldump to demonstrate real-life
|
||||
SSL behavior. If you like ssldump and want to learn about SSL, you
|
||||
might consider buying my book.
|
||||
|
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
0.9b3
|
66
base/common.c
Normal file
66
base/common.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
common.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: common.c,v 1.2 2000/10/17 16:09:57 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 09:59:39 1998
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: common.c,v 1.2 2000/10/17 16:09:57 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
|
||||
int xdump(label,data,len)
|
||||
char *label;
|
||||
UCHAR *data;
|
||||
int len;
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("%s[%d]",label,len);
|
||||
for(i=0;i<len;i++){
|
||||
if((len>8) && !(i%20)) printf("\n");
|
||||
printf("%.2x ",data[i]&255);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
return(0);
|
||||
}
|
60
base/data
Normal file
60
base/data
Normal file
|
@ -0,0 +1,60 @@
|
|||
network.c:126: off=ntohs(p.ip->ip_off);
|
||||
network.c:134: hlen=p.ip->ip_hl * 4;
|
||||
network.c:136: p.len =ntohs(p.ip->ip_len)-hlen;
|
||||
network.c:139: switch(p.ip->ip_p){
|
||||
network.c:159: memcpy(&p->ts,&in->ts,sizeof(struct timeval));
|
||||
network.c:160: if(!(p->base=(UCHAR *)malloc(in->_len)))
|
||||
network.c:162: memcpy(p->base,in->base,p->_len=in->_len);
|
||||
network.c:164: p->data=p->base + (in->data -> in->base);
|
||||
network.c:165: p->len=in->len;
|
||||
network.c:167: p->ip=(struct ip *)(p->base + ((UCHAR *)in->ip - in->base));
|
||||
network.c:168: p->tcp=(struct tcphdr *)(p->base + ((UCHAR *)in->tcp - in->base));
|
||||
network.c:186: FREE(p->base);
|
||||
pcap-snoop.c:2: pcap-snoop.c
|
||||
pcap-snoop.c:40: $Id: pcap-snoop.c,v 1.12 2002/01/21 17:36:51 ekr Exp $
|
||||
pcap-snoop.c:47:static char *RCSSTRING="$Id: pcap-snoop.c,v 1.12 2002/01/21 17:36:51 ekr Exp $";
|
||||
tcppack.c:84: p->tcp=(struct tcphdr *)p->data;
|
||||
tcppack.c:88: if(r=tcp_find_conn(&conn,&direction,&p->ip->ip_src,
|
||||
tcppack.c:89: ntohs(p->tcp->th_sport),&p->ip->ip_dst,ntohs(p->tcp->th_dport))){
|
||||
tcppack.c:96: if((p->tcp->th_flags & (TH_SYN|TH_ACK))!=TH_SYN){
|
||||
tcppack.c:104: conn->i2r.seq=ntohl(p->tcp->th_seq)+1;
|
||||
tcppack.c:114: if((p->tcp->th_flags & (TH_SYN|TH_ACK))!=(TH_SYN|TH_ACK))
|
||||
tcppack.c:116: conn->r2i.seq=ntohl(p->tcp->th_seq)+1;
|
||||
tcppack.c:117: conn->r2i.ack=ntohl(p->tcp->th_ack)+1;
|
||||
tcppack.c:127: conn->i2r.ack=ntohl(p->tcp->th_ack)+1;
|
||||
tcppack.c:148: if(p->tcp->th_flags & TH_SYN)
|
||||
tcppack.c:150: length=p->len - (p->tcp->th_off * 4);
|
||||
tcppack.c:178: if(r=tcp_create_conn(&conn,&p->ip->ip_src,ntohs(p->tcp->th_sport),
|
||||
tcppack.c:179: &p->ip->ip_dst,ntohs(p->tcp->th_dport)))
|
||||
tcppack.c:183: memcpy(&conn->start_time,&p->ts,sizeof(struct timeval));
|
||||
tcppack.c:184: if(r=create_proto_handler(handler,ctx,&conn->analyzer,conn,&p->ts))
|
||||
tcppack.c:197: off=(s)->p->tcp->th_off*4; \
|
||||
tcppack.c:198: if(l>((s)->p->len-off)) ERETURN(R_BAD_DATA);\
|
||||
tcppack.c:199: (s)->data=(s)->p->data + off + (l) ; \
|
||||
tcppack.c:200: (s)->len=(s)->p->len - off + (l); \
|
||||
tcppack.c:227: l=p->len - p->tcp->th_off * 4;
|
||||
tcppack.c:238: seq=ntohl(p->tcp->th_seq);
|
||||
tcppack.c:241: if(p->tcp->th_flags & TH_ACK){
|
||||
tcppack.c:245: acknum=ntohl(p->tcp->th_ack);
|
||||
tcppack.c:250: if(r=timestamp_diff(&p->ts,&conn->start_time,&dt))
|
||||
tcppack.c:268: if(!(p->tcp->th_flags & (TH_RST)) && SEQ_LT(seq,stream->seq))
|
||||
tcppack.c:310: if(_seg.p->tcp->th_flags & (TH_RST)){
|
||||
tcppack.c:311: stream->close=_seg.p->tcp->th_flags & (TH_RST);
|
||||
tcppack.c:319: if(_seg.p->tcp->th_flags & (TH_FIN)){
|
||||
tcppack.c:320: stream->close=_seg.p->tcp->th_flags & (TH_FIN);
|
||||
tcppack.c:325: if(seg->p->tcp->th_flags & (TH_FIN)){
|
||||
tcppack.c:326: stream->close=_seg.p->tcp->th_flags & (TH_FIN);
|
||||
tcppack.c:338: if(seg->p->tcp->th_flags & (TH_FIN) ){
|
||||
tcppack.c:374: lookuphostname(&p->ip->ip_src,&src);
|
||||
tcppack.c:375: lookuphostname(&p->ip->ip_dst,&dst);
|
||||
tcppack.c:379: ntohs(p->tcp->th_sport),
|
||||
tcppack.c:381: ntohs(p->tcp->th_dport));
|
||||
tcppack.c:384: ntohl(p->tcp->th_seq),
|
||||
tcppack.c:385: p->len - p->tcp->th_off *4);
|
||||
tcppack.c:387: if(p->tcp->th_flags & TH_ACK)
|
||||
tcppack.c:388: printf("ACK %ld ",ntohl(p->tcp->th_ack));
|
||||
tcppack.c:390: if(p->tcp->th_flags & TH_FIN)
|
||||
tcppack.c:392: if(p->tcp->th_flags & TH_SYN)
|
||||
tcppack.c:394: if(p->tcp->th_flags & TH_RST)
|
||||
tcppack.c:396: if(p->tcp->th_flags & TH_PUSH)
|
||||
tcppack.c:398: if(p->tcp->th_flags & TH_URG)
|
68
base/debug.c
Normal file
68
base/debug.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
debug.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: debug.c,v 1.2 2000/10/17 16:09:57 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Jan 6 17:08:58 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: debug.c,v 1.2 2000/10/17 16:09:57 ekr Exp $";
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int debug(int class,char *format,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,format);
|
||||
vfprintf(stderr,format,ap);
|
||||
fprintf(stderr,"\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
58
base/debug.h
Normal file
58
base/debug.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
debug.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: debug.h,v 1.2 2000/10/17 16:09:57 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Jan 6 17:13:00 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _debug_h
|
||||
#define _debug_h
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(a) debug a
|
||||
int debug(int class,char *format,...);
|
||||
#else
|
||||
#define DBG(a)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
241
base/network.c
Normal file
241
base/network.c
Normal file
|
@ -0,0 +1,241 @@
|
|||
/**
|
||||
network.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: network.c,v 1.10 2002/09/09 21:02:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 09:52:54 1998
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: network.c,v 1.10 2002/09/09 21:02:58 ekr Exp $";
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <r_common.h>
|
||||
#include "network.h"
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "tcppack.h"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
UINT4 NET_print_flags;
|
||||
|
||||
struct network_handler_ {
|
||||
proto_mod *mod;
|
||||
proto_ctx *ctx;
|
||||
};
|
||||
|
||||
int network_handler_create(mod,handlerp)
|
||||
proto_mod *mod;
|
||||
n_handler **handlerp;
|
||||
{
|
||||
int r,_status;
|
||||
n_handler *handler=0;
|
||||
|
||||
if(!(handler=(n_handler *)malloc(sizeof(n_handler))))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(mod->vtbl->create_ctx){
|
||||
if(r=mod->vtbl->create_ctx(mod->handle,&handler->ctx))
|
||||
ABORT(r);
|
||||
}
|
||||
handler->mod=mod;
|
||||
*handlerp=handler;
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
network_handler_destroy(&handler);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int network_handler_destroy(handlerp)
|
||||
n_handler **handlerp;
|
||||
{
|
||||
if(!handlerp || !*handlerp)
|
||||
return(0);
|
||||
|
||||
free(*handlerp);
|
||||
*handlerp=0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int network_process_packet(handler,timestamp,data,length)
|
||||
n_handler *handler;
|
||||
struct timeval *timestamp;
|
||||
UCHAR *data;
|
||||
int length;
|
||||
{
|
||||
int r;
|
||||
int hlen;
|
||||
packet p;
|
||||
u_short off;
|
||||
|
||||
/*We can pretty much ignore all the options*/
|
||||
memcpy(&p.ts,timestamp,sizeof(struct timeval));
|
||||
p.base=data;
|
||||
p._len=length;
|
||||
p.data=data;
|
||||
p.len=length;
|
||||
p.ip=(struct ip *)data;
|
||||
|
||||
/*Handle, or rather mishandle, fragmentation*/
|
||||
off=ntohs(p.ip->ip_off);
|
||||
|
||||
if((off & 0x1fff) || /*Later fragment*/
|
||||
(off & 0x2000)){ /*More fragments*/
|
||||
/* fprintf(stderr,"Fragmented packet! rejecting\n"); */
|
||||
return(0);
|
||||
}
|
||||
|
||||
hlen=p.ip->ip_hl * 4;
|
||||
p.data += hlen;
|
||||
p.len =ntohs(p.ip->ip_len)-hlen;
|
||||
|
||||
|
||||
switch(p.ip->ip_p){
|
||||
case IPPROTO_TCP:
|
||||
if(r=process_tcp_packet(handler->mod,handler->ctx,&p))
|
||||
ERETURN(r);
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int packet_copy(in,out)
|
||||
packet *in;
|
||||
packet **out;
|
||||
{
|
||||
int _status;
|
||||
|
||||
packet *p=0;
|
||||
|
||||
if(!(p=(packet *)calloc(sizeof(packet),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
memcpy(&p->ts,&in->ts,sizeof(struct timeval));
|
||||
if(!(p->base=(UCHAR *)malloc(in->_len)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
memcpy(p->base,in->base,p->_len=in->_len);
|
||||
|
||||
p->data=p->base + (in->data - in->base);
|
||||
p->len=in->len;
|
||||
|
||||
p->ip=(struct ip *)(p->base + ((UCHAR *)in->ip - in->base));
|
||||
p->tcp=(struct tcphdr *)(p->base + ((UCHAR *)in->tcp - in->base));
|
||||
|
||||
*out=p;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
packet_destroy(p);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int packet_destroy(p)
|
||||
packet *p;
|
||||
{
|
||||
if(!p)
|
||||
return(0);
|
||||
|
||||
FREE(p->base);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int timestamp_diff(t1,t0,diff)
|
||||
struct timeval *t1;
|
||||
struct timeval *t0;
|
||||
struct timeval *diff;
|
||||
{
|
||||
long d;
|
||||
|
||||
if(t0->tv_sec > t1->tv_sec)
|
||||
ERETURN(R_BAD_ARGS);
|
||||
|
||||
/*Easy case*/
|
||||
if(t0->tv_usec <= t1->tv_usec){
|
||||
diff->tv_sec=t1->tv_sec - t0->tv_sec;
|
||||
diff->tv_usec=t1->tv_usec - t0->tv_usec;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*Hard case*/
|
||||
d=t0->tv_usec - t1->tv_usec;
|
||||
if(t1->tv_sec < (t0->tv_sec + 1))
|
||||
ERETURN(R_BAD_ARGS);
|
||||
diff->tv_sec=t1->tv_sec - (t0->tv_sec + 1);
|
||||
diff->tv_usec=1000000 - d;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int lookuphostname(addr,namep)
|
||||
struct in_addr *addr;
|
||||
char **namep;
|
||||
{
|
||||
struct hostent *ne=0;
|
||||
|
||||
if(!(NET_print_flags & NET_PRINT_NO_RESOLVE)){
|
||||
ne=gethostbyaddr((char *)addr,4,AF_INET);
|
||||
}
|
||||
|
||||
if(!ne){
|
||||
*namep=strdup((char *)inet_ntoa(*addr));
|
||||
}
|
||||
else{
|
||||
*namep=strdup(ne->h_name);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
106
base/network.h
Normal file
106
base/network.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
network.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: network.h,v 1.3 2001/09/14 22:29:14 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 09:53:50 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _network_h
|
||||
#define _network_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <r_common.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <r_time.h>
|
||||
#include <r_data.h>
|
||||
|
||||
typedef struct network_handler_ n_handler;
|
||||
typedef struct proto_mod_ proto_mod;
|
||||
typedef struct proto_handler_ proto_handler;
|
||||
typedef struct packet_ packet;
|
||||
|
||||
int network_handler_create PROTO_LIST((proto_mod *mod,
|
||||
n_handler **handlerp));
|
||||
int network_handler_destroy PROTO_LIST((n_handler **handlerp));
|
||||
int network_process_packet PROTO_LIST((n_handler *handler,
|
||||
struct timeval *timestamp,UCHAR *data,int length));
|
||||
int packet_copy PROTO_LIST((packet *in,packet **out));
|
||||
int packet_destroy PROTO_LIST((packet *p));
|
||||
int timestamp_diff PROTO_LIST(( struct timeval *t1,struct timeval *t0,
|
||||
struct timeval *diff));
|
||||
int lookuphostname PROTO_LIST((struct in_addr *addr,char **name));
|
||||
|
||||
struct packet_ {
|
||||
struct timeval ts;
|
||||
UCHAR *base; /*The base of the packet*/
|
||||
int _len;
|
||||
UCHAR *data; /*The data ptr appropriate to this layer*/
|
||||
int len; /*The length of the data segment*/
|
||||
|
||||
/*These just save us the effort of doing casts to the data
|
||||
segments*/
|
||||
struct ip *ip; /*The IP header*/
|
||||
struct tcphdr *tcp; /*The TCP header*/
|
||||
};
|
||||
|
||||
#include "tcpconn.h"
|
||||
#include "proto_mod.h"
|
||||
|
||||
extern UINT4 NET_print_flags;
|
||||
|
||||
#define NET_PRINT_TCP_HDR 1
|
||||
#define NET_PRINT_TYPESET 2
|
||||
#define NET_PRINT_ACKS 4
|
||||
#define NET_PRINT_NO_RESOLVE 8
|
||||
#endif
|
||||
|
365
base/pcap-snoop.c
Normal file
365
base/pcap-snoop.c
Normal file
|
@ -0,0 +1,365 @@
|
|||
/**
|
||||
pcap-snoop.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2001 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: pcap-snoop.c,v 1.14 2002/09/09 21:02:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 10:17:41 1998
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: pcap-snoop.c,v 1.14 2002/09/09 21:02:58 ekr Exp $";
|
||||
|
||||
|
||||
#include <pcap.h>
|
||||
#include <unistd.h>
|
||||
#include <net/bpf.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <bittypes.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include "network.h"
|
||||
#include <r_common.h>
|
||||
#include <r_time.h>
|
||||
#include "null_analyze.h"
|
||||
#include "ssl_analyze.h"
|
||||
#ifdef ENABLE_RECORD
|
||||
#include "record_analyze.h"
|
||||
#endif
|
||||
|
||||
#ifndef ETHERTYPE_8021Q
|
||||
# define ETHERTYPE_8021Q 0x8100
|
||||
#endif
|
||||
|
||||
char *collapse_args PROTO_LIST((int argc,char **argv));
|
||||
static int pcap_if_type=DLT_NULL;
|
||||
int err_exit PROTO_LIST((char *str,int num));
|
||||
int usage PROTO_LIST((void));
|
||||
int print_version PROTO_LIST((void));
|
||||
RETSIGTYPE sig_handler PROTO_LIST((void));
|
||||
void pcap_cb PROTO_LIST((u_char *ptr,struct pcap_pkthdr *hdr,u_char *data));
|
||||
int main PROTO_LIST((int argc,char **argv));
|
||||
|
||||
int err_exit(str,num)
|
||||
char *str;
|
||||
int num;
|
||||
{
|
||||
fprintf(stderr,"ERROR: %s\n",str);
|
||||
exit(num);
|
||||
}
|
||||
|
||||
int usage()
|
||||
{
|
||||
fprintf(stderr,"Usage: ssldump [-r dumpfile] [-i interface] \n");
|
||||
fprintf(stderr," [-k keyfile] [-p password] [-vtaTnsAxVNde]\n");
|
||||
fprintf(stderr," [filter]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int print_version()
|
||||
{
|
||||
printf("ssldump 0.9b3\n");
|
||||
printf("Copyright (C) 1998-2001 RTFM, Inc.\n");
|
||||
printf("All rights reserved.\n");
|
||||
#ifdef OPENSSL
|
||||
printf("Compiled with OpenSSL: decryption enabled\n");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
RETSIGTYPE sig_handler()
|
||||
{
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void pcap_cb(ptr,hdr,data)
|
||||
u_char *ptr;
|
||||
struct pcap_pkthdr *hdr;
|
||||
u_char *data;
|
||||
{
|
||||
n_handler *n;
|
||||
int len;
|
||||
struct ether_header *e_hdr=(struct ether_header *)data;
|
||||
int type;
|
||||
|
||||
n=(n_handler *)ptr;
|
||||
if(hdr->caplen!=hdr->len) err_exit("Length mismatch",-1);
|
||||
|
||||
len=hdr->len;
|
||||
|
||||
switch(pcap_if_type){
|
||||
case DLT_NULL:
|
||||
data+=4;
|
||||
len-=4;
|
||||
break;
|
||||
case DLT_EN10MB:
|
||||
type=ntohs(e_hdr->ether_type);
|
||||
|
||||
data+=sizeof(struct ether_header);
|
||||
len-=sizeof(struct ether_header);
|
||||
|
||||
/* if vlans, push past VLAN header (4 bytes) */
|
||||
if(type==ETHERTYPE_8021Q) {
|
||||
type=ntohs(*(u_int16_t *)(data + 2));
|
||||
|
||||
data+=4;
|
||||
len+=4;
|
||||
}
|
||||
|
||||
if(type!=ETHERTYPE_IP)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
network_process_packet(n,&hdr->ts,data,len);
|
||||
}
|
||||
|
||||
typedef struct module_def_ {
|
||||
char *name;
|
||||
proto_mod *mod;
|
||||
} module_def;
|
||||
|
||||
static module_def modules[]={
|
||||
{"SSL",&ssl_mod},
|
||||
{"NULL",&null_mod},
|
||||
#ifdef ENABLE_RECORD
|
||||
{"RECORD",&record_mod},
|
||||
#endif
|
||||
{0,0}
|
||||
};
|
||||
|
||||
|
||||
int parse_ssl_flag PROTO_LIST((int c));
|
||||
|
||||
int main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
pcap_t *p;
|
||||
int r;
|
||||
n_handler *n;
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport) char *optarg;
|
||||
__declspec(dllimport) int optind;
|
||||
#else
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
#endif
|
||||
char *interface_name=0;
|
||||
char *file=0;
|
||||
char *filter=0;
|
||||
proto_mod *mod=&ssl_mod;
|
||||
bpf_u_int32 localnet,netmask;
|
||||
int c;
|
||||
module_def *m=0;
|
||||
int no_promiscuous=0;
|
||||
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
signal(SIGINT,sig_handler);
|
||||
|
||||
while((c=getopt(argc,argv,"vr:f:S:Ttai:k:p:nsAxXhHVNdqem:P"))!=EOF){
|
||||
switch(c){
|
||||
case 'v':
|
||||
print_version();
|
||||
break;
|
||||
case 'f':
|
||||
fprintf(stderr,"-f option replaced by -r. Use that in the future\n");
|
||||
case 'r':
|
||||
file=strdup(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
ssl_mod.vtbl->parse_flags(optarg);
|
||||
break;
|
||||
case 'y':
|
||||
NET_print_flags|=NET_PRINT_TYPESET;
|
||||
/*Kludge*/
|
||||
SSL_print_flags |= SSL_PRINT_NROFF;
|
||||
break;
|
||||
case 'a':
|
||||
NET_print_flags |= NET_PRINT_ACKS;
|
||||
break;
|
||||
case 'T':
|
||||
NET_print_flags |= NET_PRINT_TCP_HDR;
|
||||
break;
|
||||
case 'i':
|
||||
interface_name=strdup(optarg);
|
||||
break;
|
||||
case 'k':
|
||||
SSL_keyfile=strdup(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
SSL_password=strdup(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
++no_promiscuous;
|
||||
break;
|
||||
case 'n':
|
||||
NET_print_flags |= NET_PRINT_NO_RESOLVE;
|
||||
break;
|
||||
case 'm':
|
||||
for(m=modules;m->name!=0;m++){
|
||||
if(!strcmp(m->name,optarg)){
|
||||
mod=m->mod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!m->name){
|
||||
fprintf(stderr,"Request analysis module %s not found\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
printf("Do 'man ssldump' for documentation\n");
|
||||
exit(1);
|
||||
|
||||
case '?':
|
||||
usage();
|
||||
exit(1);
|
||||
|
||||
/* must be an SSL flag. This is kind of a gross
|
||||
special case */
|
||||
default:
|
||||
parse_ssl_flag(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argv+=optind;
|
||||
argc-=optind;
|
||||
|
||||
if(!file){
|
||||
if(!interface_name){
|
||||
interface_name=pcap_lookupdev(errbuf);
|
||||
if(!interface_name){
|
||||
fprintf(stderr,"PCAP: %s\n",errbuf);
|
||||
err_exit("Aborting",-1);
|
||||
}
|
||||
}
|
||||
if(!(p=pcap_open_live(interface_name,5000,!no_promiscuous,1000,errbuf))){
|
||||
fprintf(stderr,"PCAP: %s\n",errbuf);
|
||||
err_exit("Aborting",-1);
|
||||
}
|
||||
|
||||
if (pcap_lookupnet(interface_name, &localnet, &netmask, errbuf) < 0)
|
||||
verr_exit("PCAP: %s\n",errbuf);
|
||||
|
||||
}
|
||||
else{
|
||||
if(!(p=pcap_open_offline(file,errbuf))){
|
||||
fprintf(stderr,"PCAP: %s\n",errbuf);
|
||||
err_exit("Aborting",-1);
|
||||
}
|
||||
|
||||
netmask=0;
|
||||
localnet=0;
|
||||
}
|
||||
|
||||
if(argc!=0)
|
||||
filter=collapse_args(argc,argv);
|
||||
|
||||
if(filter){
|
||||
struct bpf_program fp;
|
||||
|
||||
if(pcap_compile(p,&fp,filter,0,netmask)<0)
|
||||
verr_exit("PCAP: %s\n",pcap_geterr(p));
|
||||
|
||||
if(pcap_setfilter(p,&fp)<0)
|
||||
verr_exit("PCAP: %s\n",pcap_geterr(p));
|
||||
}
|
||||
|
||||
pcap_if_type=pcap_datalink(p);
|
||||
|
||||
if(NET_print_flags & NET_PRINT_TYPESET)
|
||||
printf("\n.nf\n.ps -2\n");
|
||||
|
||||
if(r=network_handler_create(mod,&n))
|
||||
err_exit("Couldn't create network handler",r);
|
||||
|
||||
pcap_loop(p,-1,pcap_cb,(u_char *)n);
|
||||
|
||||
if(NET_print_flags & NET_PRINT_TYPESET)
|
||||
printf("\n.ps\n.fi\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
char *collapse_args(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i,len=0;
|
||||
char *ret;
|
||||
|
||||
if(!argc)
|
||||
return(0);
|
||||
|
||||
for(i=0;i<argc;i++){
|
||||
len+=strlen(argv[i])+1;
|
||||
}
|
||||
|
||||
if(!(ret=(char *)malloc(len)))
|
||||
err_exit("Out of memory",1);
|
||||
|
||||
len=0;
|
||||
for(i=0;i<argc;i++){
|
||||
strcpy(ret+len,argv[i]);
|
||||
len+=strlen(argv[i]);
|
||||
|
||||
if(i!=(argc-1))
|
||||
ret[len++]=' ';
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
88
base/print_utils.c
Normal file
88
base/print_utils.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
print_utils.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: print_utils.c,v 1.2 2000/10/17 16:09:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Mon Feb 15 17:23:36 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: print_utils.c,v 1.2 2000/10/17 16:09:58 ekr Exp $";
|
||||
int explain(char *format,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,format);
|
||||
|
||||
INDENT;
|
||||
|
||||
vprintf(format,ap);
|
||||
va_end(ap);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int exdump(name,data)
|
||||
char *name;
|
||||
Data *data;
|
||||
{
|
||||
int i,j;
|
||||
char prefix[100];
|
||||
|
||||
INDENT;
|
||||
|
||||
if(name){
|
||||
sprintf(prefix,"%s[%d]=\n",name,data->len);
|
||||
printf("%s",prefix);
|
||||
INDENT_INCR;
|
||||
}
|
||||
for(i=0;i<data->len;i++){
|
||||
if(!i && (data->len>8)) INDENT;
|
||||
if((data->len>8) && i && !(i%12)){
|
||||
printf("\n"); INDENT;
|
||||
}
|
||||
printf("%.2x ",data->data[i]&255);
|
||||
}
|
||||
if(name) INDENT_POP;
|
||||
if(data->len>8 && i%12)
|
||||
printf("\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
56
base/print_utils.h
Normal file
56
base/print_utils.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
print_utils.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: print_utils.h,v 1.2 2000/10/17 16:09:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Mon Feb 15 17:23:56 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _print_utils_h
|
||||
#define _print_utils_h
|
||||
|
||||
int explain PROTO_LIST((char *format,...));
|
||||
int exdump PROTO_LIST((char *name,
|
||||
Data *data));
|
||||
|
||||
|
||||
#endif
|
||||
|
88
base/proto_mod.c
Normal file
88
base/proto_mod.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
proto_mod.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: proto_mod.c,v 1.3 2001/07/20 23:33:14 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Thu Jan 7 22:35:23 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: proto_mod.c,v 1.3 2001/07/20 23:33:14 ekr Exp $";
|
||||
|
||||
#include "network.h"
|
||||
|
||||
int create_proto_handler(mod,ctx,handlerp,conn,first_packet)
|
||||
proto_mod *mod;
|
||||
proto_ctx *ctx;
|
||||
proto_handler **handlerp;
|
||||
tcp_conn *conn;
|
||||
struct timeval *first_packet;
|
||||
{
|
||||
int r,_status;
|
||||
proto_handler *handler=0;
|
||||
|
||||
if(!(handler=(proto_handler *)calloc(sizeof(proto_handler),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
handler->vtbl=mod->vtbl;
|
||||
if(r=mod->vtbl->create(mod->handle,ctx,conn,&handler->obj,
|
||||
&conn->i_addr,conn->i_port,&conn->r_addr,conn->r_port,first_packet))
|
||||
ABORT(r);
|
||||
|
||||
*handlerp=handler;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
destroy_proto_handler(&handler);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int destroy_proto_handler(handlerp)
|
||||
proto_handler **handlerp;
|
||||
{
|
||||
if(!handlerp || !*handlerp)
|
||||
return(0);
|
||||
|
||||
(*handlerp)->vtbl->destroy(&(*handlerp)->obj);
|
||||
free(*handlerp);
|
||||
*handlerp=0;
|
||||
return(0);
|
||||
}
|
86
base/proto_mod.h
Normal file
86
base/proto_mod.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
proto_mod.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: proto_mod.h,v 1.4 2001/11/26 22:28:16 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Thu Dec 24 21:10:05 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _proto_mod_h
|
||||
#define _proto_mod_h
|
||||
|
||||
typedef struct proto_obj_ proto_obj;
|
||||
typedef struct proto_ctx_ proto_ctx;
|
||||
|
||||
#define DIR_I2R 1
|
||||
#define DIR_R2I 2
|
||||
|
||||
struct proto_mod_vtbl_ {
|
||||
int (*parse_flags) PROTO_LIST((char *str));
|
||||
int (*parse_flag) PROTO_LIST((int flag));
|
||||
int (*create_ctx) PROTO_LIST((void *handle,proto_ctx **ctxp));
|
||||
int (*create) PROTO_LIST((void *handle,proto_ctx *ctx,
|
||||
tcp_conn *conn,
|
||||
proto_obj **objp,
|
||||
struct in_addr *i_addr,u_short i_port,
|
||||
struct in_addr *r_addr,u_short r_port,struct timeval *time_base));
|
||||
int (*destroy) PROTO_LIST((proto_obj **objp));
|
||||
int (*data) PROTO_LIST((proto_obj *obj,segment *data,int direction));
|
||||
int (*close) PROTO_LIST((proto_obj *obj,packet *p,int direction));
|
||||
};
|
||||
|
||||
struct proto_mod_ {
|
||||
void *handle;
|
||||
struct proto_mod_vtbl_ *vtbl;
|
||||
};
|
||||
|
||||
struct proto_handler_ {
|
||||
proto_obj *obj;
|
||||
struct proto_mod_vtbl_ *vtbl;
|
||||
};
|
||||
|
||||
int create_proto_handler PROTO_LIST((proto_mod *mod,proto_ctx *ctx,
|
||||
proto_handler **handlerp,
|
||||
tcp_conn *conn,struct timeval *first_packet));
|
||||
int destroy_proto_handler PROTO_LIST((proto_handler **handlerp));
|
||||
|
||||
#endif
|
||||
|
275
base/targets.mk
Normal file
275
base/targets.mk
Normal file
|
@ -0,0 +1,275 @@
|
|||
#
|
||||
# targets.mk
|
||||
#
|
||||
# $Source: /usr/local/CVS/ssldump/base/targets.mk,v $
|
||||
# $Revision: 1.3 $
|
||||
# $Date: 2002/08/17 01:33:16 $
|
||||
# $Name: $
|
||||
# $Disclaimer$
|
||||
#
|
||||
# Copyright (C) 2001, Terisa Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ekr@terisa.com
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE USER-DEFINED MAKE ENVIRONMENT
|
||||
#
|
||||
# These fields are specified by the user. The remainder of
|
||||
# this file is generated from this user-specified information.
|
||||
#
|
||||
# ANALYZE_DEFINES:
|
||||
# cpp defines, with the -D flag preceeding each
|
||||
#
|
||||
# ANALYZE_INCLUDES:
|
||||
# cpp include directories, with the -I flag preceeding each
|
||||
#
|
||||
# ANALYZE_INTERNAL:
|
||||
# headers files which are local to a specific module directory,
|
||||
# and should not be used by other parts of the toolkit or by
|
||||
# the user
|
||||
#
|
||||
# ANALYZE_LIBNAME:
|
||||
# the library associated with this module directory, used in
|
||||
# most cases for debugging purposes
|
||||
#
|
||||
# ANALYZE_LIBPATHS:
|
||||
# link-time directories to search for libraries, with the -L flag
|
||||
# preceeding each
|
||||
#
|
||||
# ANALYZE_LIBRARIES:
|
||||
# link-time libraries, with the -l flag preceeding each
|
||||
#
|
||||
# ANALYZE_LOCALFLAGS:
|
||||
# compile-time flags specific to compiling only the files in
|
||||
# this module directory--this variable should only be set in
|
||||
# extremely exceptional cases
|
||||
#
|
||||
# ANALYZE_MAKEFILES:
|
||||
# the makefiles
|
||||
#
|
||||
# ANALYZE_PREFIX:
|
||||
# defines the module name, which also serves as the
|
||||
# prefix for all the variable names defined in this file
|
||||
#
|
||||
# ANALYZE_PRIVATE:
|
||||
# the private, for-toolkit-use-only API header files
|
||||
#
|
||||
# ANALYZE_PROGRAMS:
|
||||
# programs to build
|
||||
#
|
||||
# ANALYZE_PUBLIC:
|
||||
# the header files that define the public API for the toolkit
|
||||
# and any other 'public' files that should be copied to
|
||||
# the build directory
|
||||
#
|
||||
# ANALYZE_SOURCES:
|
||||
# the source files to compile to object
|
||||
#
|
||||
ANALYZE_DEFINES =
|
||||
ANALYZE_INCLUDES = -I$(ANALYZE_SRCDIR)
|
||||
ANALYZE_INTERNAL =
|
||||
ANALYZE_LIBNAME =
|
||||
ANALYZE_LIBPATHS =
|
||||
ANALYZE_LIBRARIES =
|
||||
ANALYZE_LOCALFLAGS =
|
||||
ANALYZE_MAKEFILES = targets.mk
|
||||
ANALYZE_PREFIX = ANALYZE
|
||||
ANALYZE_PRIVATE = network.h proto_mod.h tcpconn.h tcppack.h
|
||||
ANALYZE_PROGRAMS =
|
||||
ANALYZE_PUBLIC =
|
||||
ANALYZE_SOURCES = network.c pcap-snoop.c proto_mod.c tcpconn.c \
|
||||
tcppack.c
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE AUTOMATICALLY-GENERATED MAKE ENVIRONMENT
|
||||
#
|
||||
# ANALYZE_OBJECTS:
|
||||
# object files to build
|
||||
#
|
||||
# ANALYZE_UNUSED:
|
||||
# obsolete files in the module directory that are not
|
||||
# used during the build process
|
||||
#
|
||||
# ANALYZE_USED:
|
||||
# all files in the module directory that are used
|
||||
# during the build process
|
||||
#
|
||||
ANALYZE_OBJECTS = network.$(OBJSUFFIX) pcap-snoop.$(OBJSUFFIX) \
|
||||
proto_mod.$(OBJSUFFIX) tcpconn.$(OBJSUFFIX) \
|
||||
tcppack.$(OBJSUFFIX)
|
||||
ANALYZE_UNUSED = common.c debug.c debug.h print_utils.c \
|
||||
print_utils.h
|
||||
ANALYZE_USED = $(ANALYZE_INTERNAL:%=$(ANALYZE_SRCDIR)%) \
|
||||
$(ANALYZE_MAKEFILES:%=$(ANALYZE_SRCDIR)%) \
|
||||
$(ANALYZE_PRIVATE:%=$(ANALYZE_SRCDIR)%) \
|
||||
$(ANALYZE_PUBLIC:%=$(ANALYZE_SRCDIR)%) \
|
||||
$(ANALYZE_SOURCES:%=$(ANALYZE_SRCDIR)%)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# NOTES
|
||||
#
|
||||
# The following variables may be used during the build process,
|
||||
# but are not defined in this file. If they are to be set
|
||||
# to something other than the default blank, then they must
|
||||
# be set by the calling make system.
|
||||
#
|
||||
# ANALYZE_SRCDIR:
|
||||
# if the build target directory is different from the
|
||||
# module directory (the source directory), then this
|
||||
# variable contains the relative or full path of
|
||||
# the module directory
|
||||
#
|
||||
# LIBARS:
|
||||
# the library archive files (with fully-specified paths) that
|
||||
# executables built from this module directory depend upon
|
||||
#
|
||||
# LIBPATHS:
|
||||
# the paths to search for library archives (specified with
|
||||
# the -L)
|
||||
#
|
||||
# LIBRARIES:
|
||||
# the libraries to use while building executables from
|
||||
# this module directory (specified with the -l)
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GLOBAL ENVIRONMENT
|
||||
#
|
||||
DEFINES += $(ANALYZE_DEFINES)
|
||||
INCLUDES += $(ANALYZE_INCLUDES)
|
||||
LIBPATHS += $(ANALYZE_LIBPATHS)
|
||||
LIBRARIES += $(ANALYZE_LIBRARIES)
|
||||
OBJECTS += $(ANALYZE_OBJECTS)
|
||||
PUBLIC += $(ANALYZE_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GENERIC DEPENDENCIES
|
||||
#
|
||||
# default:
|
||||
# default dependency, must be the first dependency in this makefile
|
||||
#
|
||||
# all:
|
||||
# build everything in this module directory
|
||||
#
|
||||
# build:
|
||||
# make only the toolkit build files of this module directory
|
||||
#
|
||||
# ci:
|
||||
# perform an RCS check-in of this module directory
|
||||
#
|
||||
# clean:
|
||||
# remove the compiled files
|
||||
#
|
||||
# clean_public:
|
||||
# remove the public header files that have been copied
|
||||
# to a public build directory
|
||||
#
|
||||
# objects:
|
||||
# build the object files (this dependency is used for
|
||||
# building the toolkit library)
|
||||
#
|
||||
# private:
|
||||
# build only the private API header files
|
||||
#
|
||||
# public:
|
||||
# build only the public API header files
|
||||
#
|
||||
default: $(ANALYZE_LIBNAME)
|
||||
default: $(ANALYZE_PROGRAMS)
|
||||
|
||||
all: $(ANALYZE_PUBLIC)
|
||||
all: $(ANALYZE_OBJECTS)
|
||||
all: $(ANALYZE_LIBNAME)
|
||||
all: $(ANALYZE_PROGRAMS)
|
||||
build: $(ANALYZE_PUBLIC)
|
||||
build: $(ANALYZE_OBJECTS)
|
||||
ci: analyze_ci
|
||||
clean: analyze_clean
|
||||
clean_public: analyze_clean_public
|
||||
objects: $(ANALYZE_OBJECTS)
|
||||
private: $(ANALYZE_PRIVATE)
|
||||
public: $(ANALYZE_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# LOCAL UTILITY DEPENDENCIES
|
||||
#
|
||||
# utility dependencies are necessary because of some
|
||||
# make-isms having to do with dependencies
|
||||
#
|
||||
|
||||
analyze_ci:
|
||||
$(CI) $(CIFLAGS) $(ANALYZE_USED)
|
||||
|
||||
analyze_clean:
|
||||
$(RM) $(RMFLAGS) $(ANALYZE_OBJECTS) $(ANALYZE_LIBNAME) $(ANALYZE_PROGRAMS)
|
||||
|
||||
analyze_clean_public:
|
||||
$(RM) $(RMFLAGS) $(ANALYZE_PUBLIC)
|
||||
|
||||
analyze_objects: $(ANALYZE_OBJECTS)
|
||||
|
||||
analyze_programs: $(ANALYZE_PROGRAMS)
|
||||
|
||||
analyze_public: $(ANALYZE_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# BUILD DEPENDENCIES
|
||||
#
|
||||
# build dependencies invoke the rule used to build each
|
||||
# class of file
|
||||
#
|
||||
|
||||
$(ANALYZE_LIBNAME):
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
$(ANALYZE_OBJECTS):
|
||||
$(COMPILE.c) $(ANALYZE_SRCDIR)$(@:%.$(OBJSUFFIX)=%.c) $(DEFINES) $(INCLUDES) $(ANALYZE_LOCALFLAGS)
|
||||
|
||||
$(ANALYZE_PUBLIC):
|
||||
$(CP) $(CPFLAGS) $(ANALYZE_SRCDIR)$@ $@
|
||||
|
||||
$(ANALYZE_PROGRAMS):
|
||||
$(LINK.c) -o $@ $@.$(OBJSUFFIX) $(LDLIBS) $(LIBS) $(LIBRARIES) $(LIBPATHS)
|
||||
#LIBS above is obsolete (use LIBARARIES instead)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# FILE DEPENDENCIES
|
||||
#
|
||||
# file dependencies state, for each file that is built,
|
||||
# which file(s) it depends upon
|
||||
#
|
||||
|
||||
network.$(OBJSUFFIX): $(ANALYZE_SRCDIR)network.h
|
||||
network.$(OBJSUFFIX): $(ANALYZE_SRCDIR)network.c
|
||||
|
||||
pcap-snoop.$(OBJSUFFIX): $(ANALYZE_SRCDIR)pcap-snoop.c
|
||||
|
||||
proto_mod.$(OBJSUFFIX): $(ANALYZE_SRCDIR)proto_mod.h
|
||||
proto_mod.$(OBJSUFFIX): $(ANALYZE_SRCDIR)proto_mod.c
|
||||
|
||||
tcpconn.$(OBJSUFFIX): $(ANALYZE_SRCDIR)tcpconn.h
|
||||
tcpconn.$(OBJSUFFIX): $(ANALYZE_SRCDIR)tcpconn.c
|
||||
|
||||
tcppack.$(OBJSUFFIX): $(ANALYZE_SRCDIR)tcppack.h
|
||||
tcppack.$(OBJSUFFIX): $(ANALYZE_SRCDIR)tcppack.c
|
||||
|
||||
$(ANALYZE_LIBNAME): $(ANALYZE_OBJECTS)
|
203
base/tcpconn.c
Normal file
203
base/tcpconn.c
Normal file
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
tcpconn.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: tcpconn.c,v 1.7 2002/08/17 01:33:16 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 15:13:03 1998
|
||||
*/
|
||||
|
||||
static char *RCSSTRING="$Id: tcpconn.c,v 1.7 2002/08/17 01:33:16 ekr Exp $";
|
||||
|
||||
#include "network.h"
|
||||
#include "tcpconn.h"
|
||||
|
||||
|
||||
typedef struct conn_struct_ {
|
||||
tcp_conn conn;
|
||||
struct conn_struct_ *next;
|
||||
struct conn_struct_ *prev;
|
||||
} conn_struct;
|
||||
|
||||
int conn_number=1;
|
||||
|
||||
static conn_struct *first_conn=0;
|
||||
|
||||
static int zero_conn PROTO_LIST((tcp_conn *conn));
|
||||
|
||||
static int zero_conn(conn)
|
||||
tcp_conn *conn;
|
||||
{
|
||||
memset(conn,0,sizeof(tcp_conn));
|
||||
return(0);
|
||||
}
|
||||
|
||||
int tcp_find_conn(connp,directionp,saddr,sport,daddr,dport)
|
||||
tcp_conn **connp;
|
||||
int *directionp;
|
||||
struct in_addr *saddr;
|
||||
u_short sport;
|
||||
struct in_addr *daddr;
|
||||
u_short dport;
|
||||
{
|
||||
conn_struct *conn;
|
||||
|
||||
for(conn=first_conn;conn;conn=conn->next){
|
||||
|
||||
if(sport == conn->conn.i_port && dport==conn->conn.r_port){
|
||||
if(!memcmp(saddr,&conn->conn.i_addr,sizeof(struct in_addr))
|
||||
&& !memcmp(daddr,&conn->conn.r_addr,sizeof(struct in_addr)))
|
||||
{
|
||||
*directionp=DIR_I2R;
|
||||
*connp=&(conn->conn);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(dport == conn->conn.i_port && sport==conn->conn.r_port){
|
||||
if(!memcmp(saddr,&conn->conn.r_addr,sizeof(struct in_addr))
|
||||
&& !memcmp(daddr,&conn->conn.i_addr,sizeof(struct in_addr)))
|
||||
{
|
||||
*directionp=DIR_R2I;
|
||||
*connp=&(conn->conn);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(R_NOT_FOUND);
|
||||
}
|
||||
|
||||
int tcp_create_conn(connp,i_addr,i_port,r_addr,r_port)
|
||||
tcp_conn **connp;
|
||||
struct in_addr *i_addr;
|
||||
u_short i_port;
|
||||
struct in_addr *r_addr;
|
||||
u_short r_port;
|
||||
{
|
||||
conn_struct *conn=0;
|
||||
|
||||
if(!(conn=(conn_struct *)malloc(sizeof(conn_struct))))
|
||||
return(R_NO_MEMORY);
|
||||
|
||||
conn->prev=0;
|
||||
|
||||
zero_conn(&conn->conn);
|
||||
conn->conn.backptr=conn;
|
||||
conn->conn.conn_number=conn_number++;
|
||||
|
||||
memcpy(&conn->conn.i_addr,i_addr,sizeof(struct in_addr));
|
||||
conn->conn.i_port=i_port;
|
||||
memcpy(&conn->conn.r_addr,r_addr,sizeof(struct in_addr));
|
||||
conn->conn.r_port=r_port;
|
||||
*connp=&(conn->conn);
|
||||
|
||||
/* Insert at the head of the list */
|
||||
conn->next=first_conn;
|
||||
if(first_conn)
|
||||
first_conn->prev=conn;
|
||||
first_conn=conn;
|
||||
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int tcp_destroy_conn(conn)
|
||||
tcp_conn *conn;
|
||||
{
|
||||
conn_struct *c=conn->backptr;
|
||||
|
||||
/* Detach from the list */
|
||||
if(c->next){
|
||||
c->next->prev=c->prev;
|
||||
}
|
||||
if(c->prev){
|
||||
c->prev->next=c->next;
|
||||
}
|
||||
else {
|
||||
first_conn=c->next;
|
||||
}
|
||||
|
||||
destroy_proto_handler(&conn->analyzer);
|
||||
free_tcp_segment_queue(conn->i2r.oo_queue);
|
||||
free_tcp_segment_queue(conn->r2i.oo_queue);
|
||||
zero_conn(conn);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int free_tcp_segment_queue(seg)
|
||||
segment *seg;
|
||||
{
|
||||
segment *tmp;
|
||||
|
||||
while(seg){
|
||||
tmp=seg->next;
|
||||
packet_destroy(seg->p);
|
||||
free(seg);
|
||||
seg=tmp;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int copy_tcp_segment_queue(out,in)
|
||||
segment **out;
|
||||
segment *in;
|
||||
{
|
||||
int r,_status;
|
||||
segment *base=0;
|
||||
|
||||
for(;in;in=in->next){
|
||||
if(!(*out=(segment *)calloc(sizeof(segment),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(!base) base=*out;
|
||||
|
||||
if(r=packet_copy(in->p,&(*out)->p))
|
||||
ABORT(r);
|
||||
out=&(*out)->next; /* Move the pointer we're assigning to */
|
||||
}
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
free_tcp_segment_queue(base);
|
||||
}
|
||||
return(_status);
|
||||
}
|
104
base/tcpconn.h
Normal file
104
base/tcpconn.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
tcpconn.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: tcpconn.h,v 1.4 2001/07/20 23:33:15 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 13:00:52 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _tcpconn_h
|
||||
#define _tcpconn_h
|
||||
|
||||
typedef struct segment_ {
|
||||
u_char *data;
|
||||
u_int len;
|
||||
tcp_seq s_seq;
|
||||
packet *p;
|
||||
struct segment_ *next;
|
||||
} segment;
|
||||
|
||||
typedef struct stream_data_ {
|
||||
tcp_seq seq;
|
||||
tcp_seq ack;
|
||||
short close;
|
||||
segment *oo_queue;
|
||||
} stream_data;
|
||||
|
||||
typedef struct tcp_conn_ {
|
||||
int conn_number;
|
||||
int state;
|
||||
#define TCP_STATE_SYN1 1
|
||||
#define TCP_STATE_SYN2 2
|
||||
#define TCP_STATE_ACK 3
|
||||
#define TCP_STATE_ESTABLISHED 4
|
||||
#define TCP_STATE_FIN1 5
|
||||
#define TCP_STATE_CLOSED 6
|
||||
/*The address which sent the first SYN*/
|
||||
struct in_addr i_addr;
|
||||
u_short i_port;
|
||||
|
||||
/*The address which sent the second SYN*/
|
||||
struct in_addr r_addr;
|
||||
u_short r_port;
|
||||
|
||||
stream_data i2r; /*The stream from initiator to responder*/
|
||||
stream_data r2i; /*The stream from responder to initiator*/
|
||||
|
||||
struct timeval start_time;
|
||||
proto_handler *analyzer; /*The analyzer to call with new data*/
|
||||
struct conn_struct_ *backptr;
|
||||
} tcp_conn;
|
||||
|
||||
int tcp_find_conn PROTO_LIST((tcp_conn **connp,
|
||||
int *directionp,
|
||||
struct in_addr *src_addr, u_short src_port,
|
||||
struct in_addr *dst_addr, u_short dst_port));
|
||||
|
||||
int tcp_create_conn PROTO_LIST((tcp_conn **connp,
|
||||
struct in_addr *initiator_addr, u_short initiator_port,
|
||||
struct in_addr *responder_addr, u_short responder_port));
|
||||
|
||||
int tcp_destroy_conn PROTO_LIST((tcp_conn *conn));
|
||||
int free_tcp_segment_queue PROTO_LIST((segment *seg));
|
||||
int copy_tcp_segment_queue PROTO_LIST((segment **out,segment *in));
|
||||
|
||||
#endif
|
||||
|
446
base/tcppack.c
Normal file
446
base/tcppack.c
Normal file
|
@ -0,0 +1,446 @@
|
|||
/**
|
||||
tcppack.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: tcppack.c,v 1.11 2002/09/09 21:02:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 29 12:43:39 1998
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: tcppack.c,v 1.11 2002/09/09 21:02:58 ekr Exp $";
|
||||
|
||||
#include "network.h"
|
||||
#ifndef _WIN32
|
||||
# include <sys/socket.h>
|
||||
# include <arpa/inet.h>
|
||||
# ifndef LINUX
|
||||
# include <netinet/tcp_seq.h>
|
||||
# else
|
||||
# define SEQ_LT(x,y) ((int)((x)-(y))<0)
|
||||
# endif
|
||||
#else
|
||||
# include <winsock2.h>
|
||||
# define SEQ_LT(x,y) ((int)((x)-(y))<0)
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include "debug.h"
|
||||
#include "tcpconn.h"
|
||||
#include "tcppack.h"
|
||||
|
||||
|
||||
static int process_data_segment PROTO_LIST((tcp_conn *conn,
|
||||
proto_mod *handler,packet *p,stream_data *stream,int direction));
|
||||
static int new_connection PROTO_LIST((proto_mod *handler,proto_ctx *ctx,
|
||||
packet *p,tcp_conn **connp));
|
||||
static int print_tcp_packet PROTO_LIST((packet *p));
|
||||
int STRIM PROTO_LIST((UINT4 _seq,segment *s));
|
||||
|
||||
int process_tcp_packet(handler,ctx,p)
|
||||
proto_mod *handler;
|
||||
proto_ctx *ctx;
|
||||
packet *p;
|
||||
{
|
||||
int r,_status;
|
||||
int direction;
|
||||
stream_data *stream;
|
||||
tcp_conn *conn;
|
||||
|
||||
p->tcp=(struct tcphdr *)p->data;
|
||||
|
||||
print_tcp_packet(p);
|
||||
|
||||
if(r=tcp_find_conn(&conn,&direction,&p->ip->ip_src,
|
||||
ntohs(p->tcp->th_sport),&p->ip->ip_dst,ntohs(p->tcp->th_dport))){
|
||||
if(r!=R_NOT_FOUND)
|
||||
ABORT(r);
|
||||
|
||||
/*Note that we MUST receive the 3-way handshake in the
|
||||
proper order. This shouldn't be a problem, though,
|
||||
except for simultaneous connects*/
|
||||
if((p->tcp->th_flags & (TH_SYN|TH_ACK))!=TH_SYN){
|
||||
DBG((0,"TCP: rejecting packet from unknown connection\n"));
|
||||
return(0);
|
||||
}
|
||||
|
||||
DBG((0,"SYN1\n"));
|
||||
if(r=new_connection(handler,ctx,p,&conn))
|
||||
ABORT(r);
|
||||
conn->i2r.seq=ntohl(p->tcp->th_seq)+1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
stream=direction==DIR_R2I?&conn->r2i:&conn->i2r;
|
||||
|
||||
switch(conn->state){
|
||||
case TCP_STATE_SYN1:
|
||||
if(direction != DIR_R2I)
|
||||
break;
|
||||
if((p->tcp->th_flags & (TH_SYN|TH_ACK))!=(TH_SYN|TH_ACK))
|
||||
break;
|
||||
conn->r2i.seq=ntohl(p->tcp->th_seq)+1;
|
||||
conn->r2i.ack=ntohl(p->tcp->th_ack)+1;
|
||||
conn->state=TCP_STATE_SYN2;
|
||||
DBG((0,"SYN2\n"));
|
||||
break;
|
||||
case TCP_STATE_SYN2:
|
||||
{
|
||||
char *sn=0,*dn=0;
|
||||
if(direction != DIR_I2R)
|
||||
break;
|
||||
DBG((0,"ACK\n"));
|
||||
conn->i2r.ack=ntohl(p->tcp->th_ack)+1;
|
||||
lookuphostname(&conn->i_addr,&sn);
|
||||
lookuphostname(&conn->r_addr,&dn);
|
||||
if(NET_print_flags & NET_PRINT_TYPESET)
|
||||
printf("\\fC");
|
||||
printf("New TCP connection #%d: %s(%d) <-> %s(%d)\n",
|
||||
conn->conn_number,
|
||||
sn,conn->i_port,
|
||||
dn,conn->r_port);
|
||||
if(NET_print_flags & NET_PRINT_TYPESET)
|
||||
printf("\\fR");
|
||||
|
||||
conn->state=TCP_STATE_ESTABLISHED;
|
||||
free(sn);
|
||||
free(dn);
|
||||
}
|
||||
case TCP_STATE_ESTABLISHED:
|
||||
case TCP_STATE_FIN1:
|
||||
{
|
||||
UINT4 length;
|
||||
|
||||
if(p->tcp->th_flags & TH_SYN)
|
||||
break;
|
||||
length=p->len - (p->tcp->th_off * 4);
|
||||
if(r=process_data_segment(conn,handler,p,stream,direction))
|
||||
ABORT(r);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(conn->state==TCP_STATE_CLOSED)
|
||||
tcp_destroy_conn(conn);
|
||||
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
|
||||
return(_status);
|
||||
}
|
||||
|
||||
static int new_connection(handler,ctx,p,connp)
|
||||
proto_mod *handler;
|
||||
proto_ctx *ctx;
|
||||
packet *p;
|
||||
tcp_conn **connp;
|
||||
{
|
||||
int r,_status;
|
||||
tcp_conn *conn=0;
|
||||
|
||||
if(r=tcp_create_conn(&conn,&p->ip->ip_src,ntohs(p->tcp->th_sport),
|
||||
&p->ip->ip_dst,ntohs(p->tcp->th_dport)))
|
||||
ABORT(r);
|
||||
|
||||
conn->state=TCP_STATE_SYN1;
|
||||
memcpy(&conn->start_time,&p->ts,sizeof(struct timeval));
|
||||
if(r=create_proto_handler(handler,ctx,&conn->analyzer,conn,&p->ts))
|
||||
ABORT(r);
|
||||
|
||||
*connp=conn;
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
/*#define STRIM(_seq,s) { \
|
||||
int l;\
|
||||
int off;\
|
||||
l=(s)->s_seq - _seq; \
|
||||
off=(s)->p->tcp->th_off*4; \
|
||||
if(l>((s)->p->len-off)) ERETURN(R_BAD_DATA);\
|
||||
(s)->data=(s)->p->data + off + (l) ; \
|
||||
(s)->len=(s)->p->len - off + (l); \
|
||||
(s)->s_seq += (l); \
|
||||
if((s)->next) { \
|
||||
if((s)->s_seq >= (s)->next->s_seq) {\
|
||||
l=(s)->next->s_seq - (s)->s_seq; \
|
||||
if((s)->len){\
|
||||
(s)->len-=(l+1); \
|
||||
(s)->s_seq-=(l+1);\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
*/
|
||||
|
||||
static int process_data_segment(conn,handler,p,stream,direction)
|
||||
tcp_conn *conn;
|
||||
proto_mod *handler;
|
||||
packet *p;
|
||||
stream_data *stream;
|
||||
int direction;
|
||||
{
|
||||
int r,_status;
|
||||
tcp_seq seq,right_edge;
|
||||
segment _seg;
|
||||
segment *seg,*nseg=0;
|
||||
long l;
|
||||
|
||||
l=p->len - p->tcp->th_off * 4;
|
||||
|
||||
if(stream->close){
|
||||
DBG((0,"Rejecting packet received after FIN"));
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*The idea here is to pass all available segments
|
||||
to the analyzer at once. Since we want to preserve
|
||||
the segment packet data, we pass the data as a linked list of
|
||||
segments*/
|
||||
seq=ntohl(p->tcp->th_seq);
|
||||
|
||||
/*Add ACK processing logic here <TODO>*/
|
||||
if(p->tcp->th_flags & TH_ACK){
|
||||
long acknum,acked;
|
||||
|
||||
|
||||
acknum=ntohl(p->tcp->th_ack);
|
||||
acked=acknum-stream->ack;
|
||||
|
||||
if(acked && !l){
|
||||
/*
|
||||
if(r=timestamp_diff(&p->ts,&conn->start_time,&dt))
|
||||
ERETURN(r);
|
||||
printf("%d%c%4.4d ",dt.tv_sec,'.',dt.tv_usec/100);
|
||||
if(direction == DIR_R2I)
|
||||
printf("S>C ");
|
||||
else
|
||||
printf("C>S ");
|
||||
|
||||
printf("ACK (%d)\n",acked); */
|
||||
}
|
||||
|
||||
stream->ack=acknum;
|
||||
}
|
||||
|
||||
|
||||
DBG((0,"Stream Seq %u ",stream->seq));
|
||||
|
||||
/* Check to see if this packet has been processed already */
|
||||
right_edge=seq + (p->len - (p->tcp->th_off)*4);
|
||||
if(!(p->tcp->th_flags & (TH_RST)) && SEQ_LT(right_edge,stream->seq))
|
||||
return(0);
|
||||
|
||||
if(SEQ_LT(stream->seq,seq)){
|
||||
/* Out of order segment */
|
||||
tcp_seq left_edge;
|
||||
|
||||
for(seg=0;seg;seg=seg?seg->next:stream->oo_queue){
|
||||
if(seg->next->s_seq > seq)
|
||||
break;
|
||||
}
|
||||
|
||||
if(!(nseg=(segment *)calloc(sizeof(segment),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(r=packet_copy(p,&nseg->p))
|
||||
ABORT(r);
|
||||
nseg->s_seq=seq;
|
||||
|
||||
/*Insert this segment into the reassembly queue*/
|
||||
if(seg){
|
||||
nseg->next=seg->next;
|
||||
seg->next=nseg;
|
||||
}
|
||||
else{
|
||||
nseg->next=stream->oo_queue;
|
||||
stream->oo_queue=nseg;
|
||||
}
|
||||
|
||||
left_edge=seg?seg->s_seq:stream->seq;
|
||||
STRIM(left_edge,nseg);
|
||||
}
|
||||
else{
|
||||
/*First segment -- just thread the unallocated data on the
|
||||
list so we can pass to the analyzer*/
|
||||
_seg.next=0;
|
||||
_seg.p=p;
|
||||
_seg.s_seq=seq;
|
||||
|
||||
/*Now split the queue. Assemble as many packets as possible
|
||||
and pass them to the analyzer. But process anything with a
|
||||
RST in it immediately and ignore any data that might be in it
|
||||
*/
|
||||
if(_seg.p->tcp->th_flags & (TH_RST)){
|
||||
stream->close=_seg.p->tcp->th_flags & (TH_RST);
|
||||
seg=&_seg;
|
||||
|
||||
conn->state=TCP_STATE_CLOSED;
|
||||
}
|
||||
else{
|
||||
STRIM(stream->seq,&_seg);
|
||||
|
||||
if(_seg.p->tcp->th_flags & (TH_FIN)){
|
||||
stream->close=_seg.p->tcp->th_flags & (TH_FIN);
|
||||
seg=&_seg;
|
||||
}
|
||||
else {
|
||||
for(seg=&_seg;seg->next;seg=seg->next){
|
||||
if(seg->p->tcp->th_flags & (TH_FIN)){
|
||||
stream->close=_seg.p->tcp->th_flags & (TH_FIN);
|
||||
break;
|
||||
}
|
||||
if(seg->len + seg->s_seq != seg->next->s_seq)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Note that this logic is broken because it doesn't
|
||||
do the CLOSE_WAIT/FIN_WAIT stuff, but it's probably
|
||||
close enough, since this is a higher level protocol analyzer,
|
||||
not a TCP analyzer*/
|
||||
if(seg->p->tcp->th_flags & (TH_FIN) ){
|
||||
if(conn->state == TCP_STATE_ESTABLISHED)
|
||||
conn->state=TCP_STATE_FIN1;
|
||||
else
|
||||
conn->state=TCP_STATE_CLOSED;
|
||||
}
|
||||
|
||||
stream->oo_queue=seg->next;
|
||||
seg->next=0;
|
||||
stream->seq=seg->s_seq + seg->len;
|
||||
|
||||
if(r=conn->analyzer->vtbl->data(conn->analyzer->obj,&_seg,direction))
|
||||
ABORT(r);
|
||||
}
|
||||
|
||||
if(stream->close){
|
||||
if(r=conn->analyzer->vtbl->close(conn->analyzer->obj,p,direction))
|
||||
ABORT(r);
|
||||
}
|
||||
|
||||
free_tcp_segment_queue(_seg.next);
|
||||
}
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
static int print_tcp_packet(p)
|
||||
packet *p;
|
||||
{
|
||||
char *src=0,*dst=0;
|
||||
|
||||
if(!(NET_print_flags & NET_PRINT_TCP_HDR))
|
||||
return(0);
|
||||
|
||||
lookuphostname(&p->ip->ip_src,&src);
|
||||
lookuphostname(&p->ip->ip_dst,&dst);
|
||||
|
||||
printf("TCP: %s(%d) -> %s(%d) ",
|
||||
src,
|
||||
ntohs(p->tcp->th_sport),
|
||||
dst,
|
||||
ntohs(p->tcp->th_dport));
|
||||
|
||||
printf("Seq %u.(%d) ",
|
||||
ntohl(p->tcp->th_seq),
|
||||
p->len - p->tcp->th_off *4);
|
||||
|
||||
if(p->tcp->th_flags & TH_ACK)
|
||||
printf("ACK %u ",ntohl(p->tcp->th_ack));
|
||||
|
||||
if(p->tcp->th_flags & TH_FIN)
|
||||
printf("FIN ");
|
||||
if(p->tcp->th_flags & TH_SYN)
|
||||
printf("SYN ");
|
||||
if(p->tcp->th_flags & TH_RST)
|
||||
printf("RST ");
|
||||
if(p->tcp->th_flags & TH_PUSH)
|
||||
printf("PUSH ");
|
||||
if(p->tcp->th_flags & TH_URG)
|
||||
printf("URG ");
|
||||
|
||||
printf("\n");
|
||||
|
||||
free(src);
|
||||
free(dst);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int STRIM(_seq,s)
|
||||
UINT4 _seq;
|
||||
segment *s;
|
||||
{
|
||||
int l;
|
||||
int off;
|
||||
|
||||
/* Test: this shouldn't damage things at all
|
||||
s->p->data-=4;
|
||||
s->p->len+=4;
|
||||
s->s_seq-=4;
|
||||
*/
|
||||
|
||||
l=_seq - (s)->s_seq; /* number of bytes to trim
|
||||
from the left of s */
|
||||
off=(s)->p->tcp->th_off*4;
|
||||
if(l>((s)->p->len-off)) ERETURN(R_BAD_DATA);
|
||||
|
||||
/* Now remove the leading l bytes */
|
||||
(s)->data=(s)->p->data + off + (l) ;
|
||||
(s)->len=(s)->p->len - (off + l);
|
||||
(s)->s_seq += (l);
|
||||
|
||||
/* Now trim to the right if necessary */
|
||||
if((s)->next) {
|
||||
if((s)->s_seq >= (s)->next->s_seq) {
|
||||
l=(s)->s_seq - (s)->next->s_seq;
|
||||
|
||||
if((s)->len){
|
||||
(s)->len-=(l+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
54
base/tcppack.h
Normal file
54
base/tcppack.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
tcppack.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: tcppack.h,v 1.3 2001/07/20 23:33:15 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Jan 6 15:08:30 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _tcppack_h
|
||||
#define _tcppack_h
|
||||
|
||||
int process_tcp_packet PROTO_LIST((proto_mod *mod,proto_ctx *ctx,
|
||||
packet *p));
|
||||
|
||||
#endif
|
||||
|
5
common/Makefile.in
Normal file
5
common/Makefile.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
OBJECTS=r_assoc.o r_data.o r_errors.o r_list.c r_time.o
|
||||
INCLUDES += ../includes
|
||||
OBJECTS:
|
||||
$(CC) $(CFLAGS) $(@:%.c
|
||||
|
20
common/configure.scan
Normal file
20
common/configure.scan
Normal file
|
@ -0,0 +1,20 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(include/r_assoc.h)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(sys/time.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_HEADER_TIME
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
AC_OUTPUT(make/freebsd31/Makefile make/freebsd22/Makefile make/sunos413/Makefile)
|
106
common/include/.#r_macros.h.1.2
Normal file
106
common/include/.#r_macros.h.1.2
Normal file
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
r_macros.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_macros.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:37:32 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_macros_h
|
||||
#define _r_macros_h
|
||||
|
||||
#if (R_USE_PROTOTYPES==1)
|
||||
#define PROTO_LIST(a) a
|
||||
#else
|
||||
#define PROTO_LIST(a) ()
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __FUNCTION__ "unknown"
|
||||
#endif
|
||||
|
||||
#ifdef R_TRACE_ERRORS
|
||||
#define REPORT_ERROR_(caller,a) fprintf(stderr,"%s: error %d at %s:%d (function %s)\n", \
|
||||
caller,a,__FILE__,__LINE__,__FUNCTION__)
|
||||
#else
|
||||
#define REPORT_ERROR_(caller,a)
|
||||
#endif
|
||||
|
||||
#ifndef ERETURN
|
||||
#define ERETURN(a) do {int _r=a; if(!_r) _r=-1; REPORT_ERROR_("ERETURN",_r); return(_r);} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef ABORT
|
||||
#define ABORT(a) do { int _r=a; if(!_r) _r=-1; REPORT_ERROR_("ABORT",_r); _status=_r; goto abort;} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef FREE
|
||||
#define FREE(a) if(a) free(a)
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)>(b))?(b):(a)
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((b)>(a))?(b):(a)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(a) debug a
|
||||
int debug(int class,char *format,...);
|
||||
#else
|
||||
#define DBG(a)
|
||||
#endif
|
||||
|
||||
#ifndef RMALLOC
|
||||
#define RMALLOC(a) malloc(A)
|
||||
#endif
|
||||
|
||||
#ifndef RCALLOC
|
||||
#define RCALLOC(a) calloc(1,a)
|
||||
#endif
|
||||
|
||||
#ifndef RFREE
|
||||
#define RFREE(a) if(a) free(a)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
83
common/include/r_assoc.h
Normal file
83
common/include/r_assoc.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
r_assoc.h
|
||||
|
||||
Associative array code. This code has the advantage that different
|
||||
elements can have different create and destroy operators. Unfortunately,
|
||||
this can waste space.
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_assoc.h,v 1.3 2001/12/24 06:06:26 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Sun Jan 17 17:57:18 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_assoc_h
|
||||
#define _r_assoc_h
|
||||
|
||||
typedef struct r_assoc_ r_assoc;
|
||||
|
||||
int r_assoc_create PROTO_LIST((r_assoc **assocp));
|
||||
int r_assoc_insert PROTO_LIST((r_assoc *assoc,char *key,int len,
|
||||
void *value,int (*copy)(void **new,void *old),
|
||||
int (*destroy)(void *ptr),int how));
|
||||
#define R_ASSOC_REPLACE 0x1
|
||||
#define R_ASSOC_NEW 0x2
|
||||
|
||||
int r_assoc_fetch PROTO_LIST((r_assoc *assoc,char *key, int len,
|
||||
void **value));
|
||||
int r_assoc_copy PROTO_LIST((r_assoc **new,r_assoc *old));
|
||||
int r_assoc_destroy PROTO_LIST((r_assoc **assocp));
|
||||
|
||||
/*We need iterators, but I haven't written them yet*/
|
||||
typedef struct r_assoc_iterator_ {
|
||||
r_assoc *assoc;
|
||||
int prev_chain;
|
||||
struct r_assoc_el_ *prev;
|
||||
int next_chain;
|
||||
struct r_assoc_el_ *next;
|
||||
} r_assoc_iterator;
|
||||
|
||||
int r_assoc_init_iter PROTO_LIST((r_assoc *assoc,r_assoc_iterator *));
|
||||
int r_assoc_iter PROTO_LIST((r_assoc_iterator *iter,void **key,int *keyl,
|
||||
void **val));
|
||||
int r_assoc_iter_delete PROTO_LIST((r_assoc_iterator *));
|
||||
|
||||
#endif
|
||||
|
26
common/include/r_bitfield.h
Normal file
26
common/include/r_bitfield.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
r_bitfield.h
|
||||
|
||||
Copyright (C) 2001 RTFM, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
ekr@rtfm.com Wed Oct 3 10:43:50 2001
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_bitfield_h
|
||||
#define _r_bitfield_h
|
||||
|
||||
typedef struct r_bitfield_ {
|
||||
UINT4 *data;
|
||||
UINT4 len;
|
||||
UINT4 base;
|
||||
} r_bitfield;
|
||||
|
||||
int r_bitfield_set PROTO_LIST((r_bitfield *,int bit));
|
||||
int r_bitfield_isset PROTO_LIST((r_bitfield *,int bit));
|
||||
int r_bitfield_create PROTO_LIST((r_bitfield **setp,UINT4 size));
|
||||
int r_bitfield_destroy PROTO_LIST((r_bitfield **setp));
|
||||
|
||||
#endif
|
||||
|
66
common/include/r_common.h
Normal file
66
common/include/r_common.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
r_common.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_common.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:40:07 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_common_h
|
||||
#define _r_common_h
|
||||
|
||||
#include "r_defaults.h"
|
||||
#include "r_includes.h"
|
||||
#include "r_types.h"
|
||||
#include "r_macros.h"
|
||||
#include "r_errors.h"
|
||||
#include "r_data.h"
|
||||
|
||||
/*AAH*/
|
||||
int xdump PROTO_LIST((char *label,UCHAR *data,int len));
|
||||
|
||||
/* defines for possibly replaced functions */
|
||||
#ifndef HAVE_STRDUP
|
||||
char *strdup PROTO_LIST((char *in));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
68
common/include/r_data.h
Normal file
68
common/include/r_data.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
r_data.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_data.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Feb 10 14:18:19 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_data_h
|
||||
#define _r_data_h
|
||||
|
||||
typedef struct Data_ {
|
||||
UCHAR *data;
|
||||
int len;
|
||||
} Data;
|
||||
|
||||
int r_data_create PROTO_LIST((Data **dp,UCHAR *d,int l));
|
||||
int r_data_alloc PROTO_LIST((Data **dp, int l));
|
||||
int r_data_make PROTO_LIST((Data *dp, UCHAR *d,int l));
|
||||
int r_data_destroy PROTO_LIST((Data **dp));
|
||||
int r_data_copy PROTO_LIST((Data *dst,Data *src));
|
||||
int r_data_zfree PROTO_LIST((Data *d));
|
||||
int r_data_compare PROTO_LIST((Data *d1,Data *d2));
|
||||
|
||||
#define INIT_DATA(a,b,c) (a).data=b; (a).len=c
|
||||
#define ATTACH_DATA(a,b) (a).data=b; (a).len=sizeof(b)
|
||||
#define ZERO_DATA(a) (a).data=0; (a).len=0
|
||||
|
||||
#endif
|
||||
|
59
common/include/r_defaults.h
Normal file
59
common/include/r_defaults.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
r_defaults.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_defaults.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:39:14 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_defaults_h
|
||||
#define _r_defaults_h
|
||||
|
||||
#ifndef R_USE_PROTOTYPES
|
||||
#define R_USE_PROTOTYPES 1
|
||||
#endif
|
||||
|
||||
|
||||
/*The needs defines don't belong here*/
|
||||
#define R_NEEDS_STDLIB_H
|
||||
|
||||
#endif
|
||||
|
62
common/include/r_errors.h
Normal file
62
common/include/r_errors.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
r_errors.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_errors.h,v 1.3 2002/01/21 17:36:51 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:59:49 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_errors_h
|
||||
#define _r_errors_h
|
||||
|
||||
#define R_NO_MEMORY 1 /*out of memory*/
|
||||
#define R_NOT_FOUND 2 /*Item not found*/
|
||||
#define R_INTERNAL 3 /*Unspecified internal error*/
|
||||
#define R_ALREADY 4 /*Action already done*/
|
||||
#define R_EOD 5 /*end of data*/
|
||||
#define R_BAD_ARGS 6 /*Bad arguments*/
|
||||
#define R_BAD_DATA 7 /*Bad data*/
|
||||
#define R_WOULDBLOCK 8 /*Operation would block */
|
||||
|
||||
int verr_exit PROTO_LIST((char *fmt,...));
|
||||
|
||||
#endif
|
||||
|
61
common/include/r_includes.h
Normal file
61
common/include/r_includes.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
r_includes.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_includes.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 11:38:50 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_includes_h
|
||||
#define _r_includes_h
|
||||
|
||||
#ifdef R_NEEDS_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef R_NEEDS_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#endif
|
||||
|
69
common/include/r_list.h
Normal file
69
common/include/r_list.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
r_list.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_list.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Jan 19 08:36:48 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_list_h
|
||||
#define _r_list_h
|
||||
|
||||
typedef struct r_list_ r_list;
|
||||
|
||||
typedef struct r_list_iterator_ {
|
||||
r_list *list;
|
||||
struct r_list_el_ *ptr;
|
||||
} r_list_iterator;
|
||||
|
||||
int r_list_create PROTO_LIST((r_list **listp));
|
||||
int r_list_destroy PROTO_LIST((r_list **listp));
|
||||
int r_list_copy PROTO_LIST((r_list **out,r_list *in));
|
||||
int r_list_insert PROTO_LIST((r_list *list,void *value,
|
||||
int (*copy)(void **new,void *old),
|
||||
int (*destroy)(void **ptr)));
|
||||
int r_list_append PROTO_LIST((r_list *list,void *value,
|
||||
int (*copy)(void **new,void *old),
|
||||
int (*destroy)(void **ptr)));
|
||||
int r_list_init_iter PROTO_LIST((r_list *list,r_list_iterator *iter));
|
||||
int r_list_iter PROTO_LIST((r_list_iterator *iter,void **val));
|
||||
|
||||
#endif
|
112
common/include/r_macros.h
Normal file
112
common/include/r_macros.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
r_macros.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_macros.h,v 1.4 2001/11/20 17:45:18 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:37:32 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_macros_h
|
||||
#define _r_macros_h
|
||||
|
||||
#if (R_USE_PROTOTYPES==1)
|
||||
#define PROTO_LIST(a) a
|
||||
#else
|
||||
#define PROTO_LIST(a) ()
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __FUNCTION__ "unknown"
|
||||
#endif
|
||||
|
||||
#ifdef R_TRACE_ERRORS
|
||||
#define REPORT_ERROR_(caller,a) fprintf(stderr,"%s: error %d at %s:%d (function %s)\n", \
|
||||
caller,a,__FILE__,__LINE__,__FUNCTION__)
|
||||
#else
|
||||
#define REPORT_ERROR_(caller,a)
|
||||
#endif
|
||||
|
||||
#ifndef ERETURN
|
||||
#define ERETURN(a) do {int _r=a; if(!_r) _r=-1; REPORT_ERROR_("ERETURN",_r); return(_r);} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef ABORT
|
||||
#define ABORT(a) do { int _r=a; if(!_r) _r=-1; REPORT_ERROR_("ABORT",_r); _status=_r; goto abort;} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef FREE
|
||||
#define FREE(a) if(a) free(a)
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)>(b))?(b):(a)
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((b)>(a))?(b):(a)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(a) debug a
|
||||
int debug(int class,char *format,...);
|
||||
#else
|
||||
#define DBG(a)
|
||||
#endif
|
||||
|
||||
#ifndef RMALLOC
|
||||
#define RMALLOC(a) malloc(a)
|
||||
#endif
|
||||
|
||||
#ifndef RCALLOC
|
||||
#define RCALLOC(a) calloc(1,a)
|
||||
#endif
|
||||
|
||||
#ifndef RFREE
|
||||
#define RFREE(a) if(a) free(a)
|
||||
#endif
|
||||
|
||||
#ifndef RREALLOC
|
||||
#define RREALLOC(a,b) realloc(a,b)
|
||||
#endif
|
||||
|
||||
#define UNIMPLEMENTED do { fprintf(stderr,"Function %s unimplemented\n",__FUNCTION__); abort(); } while(0)
|
||||
|
||||
|
||||
#endif
|
69
common/include/r_thread.h
Normal file
69
common/include/r_thread.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
r_thread.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_thread.h,v 1.2 2000/10/17 16:09:59 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Feb 23 14:58:36 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_thread_h
|
||||
#define _r_thread_h
|
||||
|
||||
typedef void *r_thread;
|
||||
typedef void *r_rwlock;
|
||||
|
||||
int r_thread_fork PROTO_LIST((void (*func)(void *),void *arg,
|
||||
r_thread *tid));
|
||||
int r_thread_destroy PROTO_LIST((r_thread tid));
|
||||
int r_thread_yield PROTO_LIST((void));
|
||||
int r_thread_exit PROTO_LIST((void));
|
||||
int r_thread_wait_last PROTO_LIST((void));
|
||||
|
||||
int r_rwlock_create PROTO_LIST((r_rwlock **lockp));
|
||||
int r_rwlock_destroy PROTO_LIST((r_rwlock **lock));
|
||||
int r_rwlock_lock PROTO_LIST((r_rwlock *lock,int action));
|
||||
|
||||
#define R_RWLOCK_UNLOCK 0
|
||||
#define R_RWLOCK_RLOCK 1
|
||||
#define R_RWLOCK_WLOCK 2
|
||||
|
||||
#endif
|
||||
|
75
common/include/r_time.h
Normal file
75
common/include/r_time.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
r_time.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_time.h,v 1.4 2001/12/24 06:06:26 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Thu Mar 4 08:45:41 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_time_h
|
||||
#define _r_time_h
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
#else
|
||||
/* Cribbed from the autoconf doc */
|
||||
# if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
# else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int r_timeval_diff PROTO_LIST((struct timeval *t1,struct timeval *t0,
|
||||
struct timeval *diff));
|
||||
int r_timeval_add PROTO_LIST((struct timeval *t1,struct timeval *t2,
|
||||
struct timeval *sum));
|
||||
|
||||
UINT8 r_timeval2int PROTO_LIST((struct timeval *tv));
|
||||
UINT8 r_gettimeint PROTO_LIST((void));
|
||||
|
||||
#endif
|
||||
|
91
common/include/r_types.h
Normal file
91
common/include/r_types.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
r_types.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_types.h,v 1.3 2002/09/09 21:02:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Dec 22 10:36:02 1998
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_types_h
|
||||
#define _r_types_h
|
||||
|
||||
#ifndef R_DEFINED_UINT4
|
||||
#ifndef SIZEOF_UNSIGNED_INT
|
||||
typedef unsigned int UINT4;
|
||||
#else
|
||||
# if (SIZEOF_UNSIGNED_INT==4)
|
||||
typedef unsigned int UINT4;
|
||||
# elif (SIZEOF_UNSIGNED_SHORT==4)
|
||||
typedef unsigned short UINT4;
|
||||
# elif (SIZEOF_UNSIGNED_LONG==4)
|
||||
typedef unsigned long UINT4;
|
||||
# else
|
||||
# error no type for UINT4
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef R_DEFINED_UINT8
|
||||
#ifndef SIZEOF_UNSIGNED_LONG
|
||||
typedef unsigned long UINT8;
|
||||
#else
|
||||
# if (SIZEOF_UNSIGNED_INT==8)
|
||||
typedef unsigned int UINT8;
|
||||
# elif (SIZEOF_UNSIGNED_SHORT==8)
|
||||
typedef unsigned short UINT8;
|
||||
# elif (SIZEOF_UNSIGNED_LONG==8)
|
||||
typedef unsigned long UINT8;
|
||||
# elif (SIZEOF_UNSIGNED_LONG_LONG==8)
|
||||
typedef unsigned long long UINT8;
|
||||
# elif defined (_WIN32) && defined (_MSC_VER)
|
||||
typedef unsigned __int64 UINT8;
|
||||
# else
|
||||
# error no type for UINT8
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef R_DEFINED_UCHAR
|
||||
typedef unsigned char UCHAR;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
53
common/lib/assoc.h
Normal file
53
common/lib/assoc.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
assoc.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: assoc.h,v 1.2 2000/10/17 16:10:00 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Sun Jan 17 17:56:35 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _assoc_h
|
||||
#define _assoc_h
|
||||
|
||||
typedef struct assoc_ assoc;
|
||||
|
||||
#endif
|
||||
|
91
common/lib/debug.c
Normal file
91
common/lib/debug.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
debug.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: debug.c,v 1.3 2001/12/24 06:06:26 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Jan 6 17:08:58 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: debug.c,v 1.3 2001/12/24 06:06:26 ekr Exp $";
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "r_common.h"
|
||||
#include "debug.h"
|
||||
|
||||
int debug(int class,char *format,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,format);
|
||||
vfprintf(stderr,format,ap);
|
||||
fprintf(stderr,"\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
int xdump(name,data,len)
|
||||
char *name;
|
||||
UCHAR *data;
|
||||
int len;
|
||||
{
|
||||
int i;
|
||||
|
||||
if(name){
|
||||
printf("%s[%d]=\n",name,len);
|
||||
}
|
||||
for(i=0;i<len;i++){
|
||||
|
||||
if((len>8) && i && !(i%12)){
|
||||
printf("\n");
|
||||
}
|
||||
printf("%.2x ",data[i]&255);
|
||||
}
|
||||
if(i%12)
|
||||
printf("\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
61
common/lib/debug.h
Normal file
61
common/lib/debug.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
debug.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: debug.h,v 1.3 2001/12/24 06:06:26 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Wed Jan 6 17:13:00 1999
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _debug_h
|
||||
#define _debug_h
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(a) debug a
|
||||
#else
|
||||
#define DBG(a)
|
||||
#endif
|
||||
|
||||
int debug(int class,char *format,...);
|
||||
int xdump PROTO_LIST((char *name,UCHAR *data,
|
||||
int len));
|
||||
|
||||
#endif
|
||||
|
279
common/lib/local.mk
Normal file
279
common/lib/local.mk
Normal file
|
@ -0,0 +1,279 @@
|
|||
#
|
||||
# local.mk
|
||||
#
|
||||
# $Source: /usr/local/CVS/ssldump/common/lib/local.mk,v $
|
||||
# $Revision: 1.2 $
|
||||
# $Date: 2001/10/04 17:19:47 $
|
||||
# $Name: $
|
||||
# $Disclaimer$
|
||||
#
|
||||
# Copyright (C) 2001, Terisa Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ekr@terisa.com
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE USER-DEFINED MAKE ENVIRONMENT
|
||||
#
|
||||
# These fields are specified by the user. The remainder of
|
||||
# this file is generated from this user-specified information.
|
||||
#
|
||||
# COMMON_LIB_DEFINES:
|
||||
# cpp defines, with the -D flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_INCLUDES:
|
||||
# cpp include directories, with the -I flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_INTERNAL:
|
||||
# headers files which are local to a specific module directory,
|
||||
# and should not be used by other parts of the toolkit or by
|
||||
# the user
|
||||
#
|
||||
# COMMON_LIB_LIBNAME:
|
||||
# the library associated with this module directory, used in
|
||||
# most cases for debugging purposes
|
||||
#
|
||||
# COMMON_LIB_LIBPATHS:
|
||||
# link-time directories to search for libraries, with the -L flag
|
||||
# preceeding each
|
||||
#
|
||||
# COMMON_LIB_LIBRARIES:
|
||||
# link-time libraries, with the -l flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_LOCALFLAGS:
|
||||
# compile-time flags specific to compiling only the files in
|
||||
# this module directory--this variable should only be set in
|
||||
# extremely exceptional cases
|
||||
#
|
||||
# COMMON_LIB_MAKEFILES:
|
||||
# the makefiles
|
||||
#
|
||||
# COMMON_LIB_PREFIX:
|
||||
# defines the module name, which also serves as the
|
||||
# prefix for all the variable names defined in this file
|
||||
#
|
||||
# COMMON_LIB_PRIVATE:
|
||||
# the private, for-toolkit-use-only API header files
|
||||
#
|
||||
# COMMON_LIB_PROGRAMS:
|
||||
# programs to build
|
||||
#
|
||||
# COMMON_LIB_PUBLIC:
|
||||
# the header files that define the public API for the toolkit
|
||||
# and any other 'public' files that should be copied to
|
||||
# the build directory
|
||||
#
|
||||
# COMMON_LIB_SOURCES:
|
||||
# the source files to compile to object
|
||||
#
|
||||
COMMON_LIB_DEFINES =
|
||||
COMMON_LIB_INCLUDES =
|
||||
COMMON_LIB_INTERNAL =
|
||||
COMMON_LIB_LIBNAME =
|
||||
COMMON_LIB_LIBPATHS =
|
||||
COMMON_LIB_LIBRARIES =
|
||||
COMMON_LIB_LOCALFLAGS =
|
||||
COMMON_LIB_MAKEFILES = targets.mk
|
||||
COMMON_LIB_PREFIX = COMMON_LIB
|
||||
COMMON_LIB_PRIVATE =
|
||||
COMMON_LIB_PROGRAMS =
|
||||
COMMON_LIB_PUBLIC =
|
||||
COMMON_LIB_SOURCES = debug.c r_assoc.c r_bitfield.c r_data.c \
|
||||
r_errors.c r_list.c r_replace.c r_time.c
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE AUTOMATICALLY-GENERATED MAKE ENVIRONMENT
|
||||
#
|
||||
# COMMON_LIB_OBJECTS:
|
||||
# object files to build
|
||||
#
|
||||
# COMMON_LIB_UNUSED:
|
||||
# obsolete files in the module directory that are not
|
||||
# used during the build process
|
||||
#
|
||||
# COMMON_LIB_USED:
|
||||
# all files in the module directory that are used
|
||||
# during the build process
|
||||
#
|
||||
COMMON_LIB_OBJECTS = debug.$(OBJSUFFIX) r_assoc.$(OBJSUFFIX) \
|
||||
r_bitfield.$(OBJSUFFIX) r_data.$(OBJSUFFIX) \
|
||||
r_errors.$(OBJSUFFIX) r_list.$(OBJSUFFIX) \
|
||||
r_replace.$(OBJSUFFIX) r_time.$(OBJSUFFIX)
|
||||
COMMON_LIB_UNUSED = assoc.h debug.h local.mk r_assoc_test.c r_data.h
|
||||
COMMON_LIB_USED = $(COMMON_LIB_INTERNAL:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_MAKEFILES:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_PRIVATE:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_PUBLIC:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_SOURCES:%=$(COMMON_LIB_SRCDIR)%)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# NOTES
|
||||
#
|
||||
# The following variables may be used during the build process,
|
||||
# but are not defined in this file. If they are to be set
|
||||
# to something other than the default blank, then they must
|
||||
# be set by the calling make system.
|
||||
#
|
||||
# COMMON_LIB_SRCDIR:
|
||||
# if the build target directory is different from the
|
||||
# module directory (the source directory), then this
|
||||
# variable contains the relative or full path of
|
||||
# the module directory
|
||||
#
|
||||
# LIBARS:
|
||||
# the library archive files (with fully-specified paths) that
|
||||
# executables built from this module directory depend upon
|
||||
#
|
||||
# LIBPATHS:
|
||||
# the paths to search for library archives (specified with
|
||||
# the -L)
|
||||
#
|
||||
# LIBRARIES:
|
||||
# the libraries to use while building executables from
|
||||
# this module directory (specified with the -l)
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GLOBAL ENVIRONMENT
|
||||
#
|
||||
DEFINES += $(COMMON_LIB_DEFINES)
|
||||
INCLUDES += $(COMMON_LIB_INCLUDES)
|
||||
LIBPATHS += $(COMMON_LIB_LIBPATHS)
|
||||
LIBRARIES += $(COMMON_LIB_LIBRARIES)
|
||||
OBJECTS += $(COMMON_LIB_OBJECTS)
|
||||
PUBLIC += $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GENERIC DEPENDENCIES
|
||||
#
|
||||
# default:
|
||||
# default dependency, must be the first dependency in this makefile
|
||||
#
|
||||
# all:
|
||||
# build everything in this module directory
|
||||
#
|
||||
# build:
|
||||
# make only the toolkit build files of this module directory
|
||||
#
|
||||
# ci:
|
||||
# perform an RCS check-in of this module directory
|
||||
#
|
||||
# clean:
|
||||
# remove the compiled files
|
||||
#
|
||||
# clean_public:
|
||||
# remove the public header files that have been copied
|
||||
# to a public build directory
|
||||
#
|
||||
# objects:
|
||||
# build the object files (this dependency is used for
|
||||
# building the toolkit library)
|
||||
#
|
||||
# private:
|
||||
# build only the private API header files
|
||||
#
|
||||
# public:
|
||||
# build only the public API header files
|
||||
#
|
||||
default: $(COMMON_LIB_LIBNAME)
|
||||
default: $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
all: $(COMMON_LIB_PUBLIC)
|
||||
all: $(COMMON_LIB_OBJECTS)
|
||||
all: $(COMMON_LIB_LIBNAME)
|
||||
all: $(COMMON_LIB_PROGRAMS)
|
||||
build: $(COMMON_LIB_PUBLIC)
|
||||
build: $(COMMON_LIB_OBJECTS)
|
||||
ci: common_lib_ci
|
||||
clean: common_lib_clean
|
||||
clean_public: common_lib_clean_public
|
||||
objects: $(COMMON_LIB_OBJECTS)
|
||||
private: $(COMMON_LIB_PRIVATE)
|
||||
public: $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# LOCAL UTILITY DEPENDENCIES
|
||||
#
|
||||
# utility dependencies are necessary because of some
|
||||
# make-isms having to do with dependencies
|
||||
#
|
||||
|
||||
common_lib_ci:
|
||||
$(CI) $(CIFLAGS) $(COMMON_LIB_USED)
|
||||
|
||||
common_lib_clean:
|
||||
$(RM) $(RMFLAGS) $(COMMON_LIB_OBJECTS) $(COMMON_LIB_LIBNAME) $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
common_lib_clean_public:
|
||||
$(RM) $(RMFLAGS) $(COMMON_LIB_PUBLIC)
|
||||
|
||||
common_lib_objects: $(COMMON_LIB_OBJECTS)
|
||||
|
||||
common_lib_programs: $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
common_lib_public: $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# BUILD DEPENDENCIES
|
||||
#
|
||||
# build dependencies invoke the rule used to build each
|
||||
# class of file
|
||||
#
|
||||
|
||||
$(COMMON_LIB_LIBNAME):
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
$(COMMON_LIB_OBJECTS):
|
||||
$(COMPILE.c) $(COMMON_LIB_SRCDIR)$(@:%.$(OBJSUFFIX)=%.c) $(DEFINES) $(INCLUDES) $(COMMON_LIB_LOCALFLAGS)
|
||||
|
||||
$(COMMON_LIB_PUBLIC):
|
||||
$(CP) $(CPFLAGS) $(COMMON_LIB_SRCDIR)$@ $@
|
||||
|
||||
$(COMMON_LIB_PROGRAMS):
|
||||
$(LINK.c) $@.$(OBJSUFFIX) $(LDLIBS) $(LIBS) $(LIBRARIES) $(LIBPATHS)
|
||||
#LIBS above is obsolete (use LIBARARIES instead)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# FILE DEPENDENCIES
|
||||
#
|
||||
# file dependencies state, for each file that is built,
|
||||
# which file(s) it depends upon
|
||||
#
|
||||
|
||||
debug.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)debug.h
|
||||
debug.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)debug.c
|
||||
|
||||
r_assoc.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_assoc.c
|
||||
|
||||
r_bitfield.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_bitfield.c
|
||||
|
||||
r_data.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_data.h
|
||||
r_data.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_data.c
|
||||
|
||||
r_errors.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_errors.c
|
||||
|
||||
r_list.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_list.c
|
||||
|
||||
r_replace.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_replace.c
|
||||
|
||||
r_time.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_time.c
|
||||
|
||||
$(COMMON_LIB_LIBNAME): $(COMMON_LIB_OBJECTS)
|
425
common/lib/r_assoc.c
Normal file
425
common/lib/r_assoc.c
Normal file
|
@ -0,0 +1,425 @@
|
|||
/**
|
||||
r_assoc.c
|
||||
|
||||
This is an associative array implementation, using an open-chained
|
||||
hash bucket technique.
|
||||
|
||||
Note that this implementation permits each data entry to have
|
||||
separate copy constructors and destructors. This currently wastes
|
||||
space, but could be implemented while saving space by using
|
||||
the high order bit of the length value or somesuch.
|
||||
|
||||
The major problem with this code is it's not resizable, though it
|
||||
could be made so.
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_assoc.c,v 1.4 2001/12/24 06:06:26 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Sun Jan 17 17:57:15 1999
|
||||
*/
|
||||
|
||||
static char *RCSSTRING="$Id: r_assoc.c,v 1.4 2001/12/24 06:06:26 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include "r_assoc.h"
|
||||
|
||||
typedef struct r_assoc_el_ {
|
||||
char *key;
|
||||
int key_len;
|
||||
void *data;
|
||||
struct r_assoc_el_ *prev;
|
||||
struct r_assoc_el_ *next;
|
||||
int (*copy) PROTO_LIST((void **new,void *old));
|
||||
int (*destroy) PROTO_LIST((void *ptr));
|
||||
} r_assoc_el;
|
||||
|
||||
struct r_assoc_ {
|
||||
int size;
|
||||
int bits;
|
||||
r_assoc_el **chains;
|
||||
};
|
||||
|
||||
#define DEFAULT_TABLE_BITS 5
|
||||
|
||||
static int destroy_assoc_chain PROTO_LIST((r_assoc_el *chain));
|
||||
static int r_assoc_fetch_bucket PROTO_LIST((r_assoc *assoc,
|
||||
char *key,int len,r_assoc_el **bucketp));
|
||||
UINT4 hash_compute PROTO_LIST((char *key,int len,int size));
|
||||
static int copy_assoc_chain PROTO_LIST((r_assoc_el **newp,
|
||||
r_assoc_el *old));
|
||||
|
||||
int r_assoc_create(assocp)
|
||||
r_assoc **assocp;
|
||||
{
|
||||
r_assoc *assoc=0;
|
||||
int _status;
|
||||
|
||||
if(!(assoc=(r_assoc *)calloc(sizeof(r_assoc),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
assoc->size=(1<<DEFAULT_TABLE_BITS);
|
||||
assoc->bits=DEFAULT_TABLE_BITS;
|
||||
|
||||
if(!(assoc->chains=(r_assoc_el **)calloc(sizeof(r_assoc_el *),
|
||||
assoc->size)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
*assocp=assoc;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
r_assoc_destroy(&assoc);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_assoc_destroy(assocp)
|
||||
r_assoc **assocp;
|
||||
{
|
||||
r_assoc *assoc;
|
||||
int i;
|
||||
|
||||
if(!assocp || !*assocp)
|
||||
return(0);
|
||||
|
||||
assoc=*assocp;
|
||||
for(i=0;i<assoc->size;i++)
|
||||
destroy_assoc_chain(assoc->chains[i]);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int destroy_assoc_chain(chain)
|
||||
r_assoc_el *chain;
|
||||
{
|
||||
r_assoc_el *nxt;
|
||||
|
||||
while(chain){
|
||||
nxt=chain->next;
|
||||
|
||||
if(chain->destroy)
|
||||
chain->destroy(chain->data);
|
||||
|
||||
free(chain->key);
|
||||
|
||||
free(chain);
|
||||
chain=nxt;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int copy_assoc_chain(newp,old)
|
||||
r_assoc_el **newp;
|
||||
r_assoc_el *old;
|
||||
{
|
||||
r_assoc_el *new=0,*ptr,*tmp;
|
||||
int r,_status;
|
||||
|
||||
if(!old) {
|
||||
*newp=0;
|
||||
return(0);
|
||||
}
|
||||
for(;old;old=old->next){
|
||||
if(!(tmp=(r_assoc_el *)calloc(sizeof(r_assoc_el),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
if(!new){
|
||||
new=tmp;
|
||||
ptr=new;
|
||||
}
|
||||
else{
|
||||
ptr->next=tmp;
|
||||
tmp->prev=ptr;
|
||||
ptr=tmp;
|
||||
}
|
||||
|
||||
ptr->destroy=old->destroy;
|
||||
ptr->copy=old->copy;
|
||||
|
||||
if(old->copy){
|
||||
if(r=old->copy(&ptr->data,old->data))
|
||||
ABORT(r);
|
||||
}
|
||||
else
|
||||
ptr->data=old->data;
|
||||
|
||||
if(!(ptr->key=(char *)malloc(old->key_len)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
memcpy(ptr->key,old->key,ptr->key_len=old->key_len);
|
||||
}
|
||||
|
||||
*newp=new;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
destroy_assoc_chain(new);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
static int r_assoc_fetch_bucket(assoc,key,len,bucketp)
|
||||
r_assoc *assoc;
|
||||
char *key;
|
||||
int len;
|
||||
r_assoc_el **bucketp;
|
||||
{
|
||||
UINT4 hash_value;
|
||||
r_assoc_el *bucket;
|
||||
|
||||
hash_value=hash_compute(key,len,assoc->bits);
|
||||
|
||||
for(bucket=assoc->chains[hash_value];bucket;bucket=bucket->next){
|
||||
if(bucket->key_len == len && !memcmp(bucket->key,key,len)){
|
||||
*bucketp=bucket;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
return(R_NOT_FOUND);
|
||||
}
|
||||
|
||||
int r_assoc_fetch(assoc,key,len,datap)
|
||||
r_assoc *assoc;
|
||||
char *key;
|
||||
int len;
|
||||
void **datap;
|
||||
{
|
||||
r_assoc_el *bucket;
|
||||
int r;
|
||||
|
||||
if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){
|
||||
if(r!=R_NOT_FOUND)
|
||||
ERETURN(r);
|
||||
return(r);
|
||||
}
|
||||
|
||||
*datap=bucket->data;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_assoc_insert(assoc,key,len,data,copy,destroy,how)
|
||||
r_assoc *assoc;
|
||||
char *key;
|
||||
int len;
|
||||
void *data;
|
||||
int (*copy) PROTO_LIST((void **new,void *old));
|
||||
int (*destroy) PROTO_LIST((void *ptr));
|
||||
int how;
|
||||
{
|
||||
r_assoc_el *bucket,*new_bucket=0;
|
||||
int r,_status;
|
||||
|
||||
if(r=r_assoc_fetch_bucket(assoc,key,len,&bucket)){
|
||||
/*Note that we compute the hash value twice*/
|
||||
UINT4 hash_value;
|
||||
|
||||
if(r!=R_NOT_FOUND)
|
||||
ABORT(r);
|
||||
hash_value=hash_compute(key,len,assoc->bits);
|
||||
|
||||
if(!(new_bucket=(r_assoc_el *)calloc(sizeof(r_assoc_el),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(!(new_bucket->key=(char *)malloc(len)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
memcpy(new_bucket->key,key,len);
|
||||
new_bucket->key_len=len;
|
||||
|
||||
/*Insert at the list head. Is FIFO a good algorithm?*/
|
||||
if(assoc->chains[hash_value])
|
||||
assoc->chains[hash_value]->prev=new_bucket;
|
||||
new_bucket->next=assoc->chains[hash_value];
|
||||
assoc->chains[hash_value]=new_bucket;
|
||||
bucket=new_bucket;
|
||||
}
|
||||
else{
|
||||
if(!(how&R_ASSOC_REPLACE))
|
||||
ABORT(R_ALREADY);
|
||||
|
||||
if(bucket->destroy)
|
||||
bucket->destroy(bucket->data);
|
||||
}
|
||||
|
||||
bucket->data=data;
|
||||
bucket->copy=copy;
|
||||
bucket->destroy=destroy;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status && new_bucket){
|
||||
free(new_bucket->key);
|
||||
free(new_bucket);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_assoc_copy(newp,old)
|
||||
r_assoc **newp;
|
||||
r_assoc *old;
|
||||
{
|
||||
int r,_status,i;
|
||||
r_assoc *new;
|
||||
|
||||
if(!(new=(r_assoc *)calloc(sizeof(r_assoc),1)))
|
||||
ABORT(r);
|
||||
new->size=old->size;
|
||||
new->bits=old->bits;
|
||||
|
||||
if(!(new->chains=(r_assoc_el **)calloc(sizeof(r_assoc_el),old->size)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
for(i=0;i<new->size;i++){
|
||||
if(r=copy_assoc_chain(new->chains+i,old->chains[i]))
|
||||
ABORT(r);
|
||||
}
|
||||
*newp=new;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
r_assoc_destroy(&new);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_assoc_init_iter(assoc,iter)
|
||||
r_assoc *assoc;
|
||||
r_assoc_iterator *iter;
|
||||
{
|
||||
int i;
|
||||
|
||||
iter->assoc=assoc;
|
||||
iter->prev_chain=-1;
|
||||
iter->prev=0;
|
||||
|
||||
iter->next_chain=assoc->size;
|
||||
iter->next=0;
|
||||
|
||||
for(i=0;i<assoc->size;i++){
|
||||
if(assoc->chains[i]!=0){
|
||||
iter->next_chain=i;
|
||||
iter->next=assoc->chains[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_assoc_iter(iter,key,keyl,val)
|
||||
r_assoc_iterator *iter;
|
||||
void **key;
|
||||
int *keyl;
|
||||
void **val;
|
||||
{
|
||||
int i;
|
||||
r_assoc_el *ret;
|
||||
|
||||
if(!iter->next)
|
||||
return(R_EOD);
|
||||
ret=iter->next;
|
||||
|
||||
*key=ret->key;
|
||||
*keyl=ret->key_len;
|
||||
*val=ret->data;
|
||||
|
||||
/* Now increment */
|
||||
iter->prev_chain=iter->next_chain;
|
||||
iter->prev=iter->next;
|
||||
|
||||
/* More on this chain */
|
||||
if(iter->next->next){
|
||||
iter->next=iter->next->next;
|
||||
}
|
||||
else{
|
||||
iter->next=0;
|
||||
|
||||
/* FInd the next occupied chain*/
|
||||
for(i=iter->next_chain;i<iter->assoc->size;i++){
|
||||
if(iter->assoc->chains[i]){
|
||||
iter->next_chain=i;
|
||||
iter->next=iter->assoc->chains[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Delete the last returned value*/
|
||||
int r_assoc_iter_delete(iter)
|
||||
r_assoc_iterator *iter;
|
||||
{
|
||||
/* First unhook it from the list*/
|
||||
if(!iter->prev->prev){
|
||||
/* First element*/
|
||||
iter->assoc->chains[iter->prev_chain]=iter->prev->next;
|
||||
}
|
||||
else{
|
||||
iter->prev->prev->next=iter->prev->next;
|
||||
}
|
||||
|
||||
if(iter->prev->next){
|
||||
iter->prev->next->prev=iter->prev->prev;
|
||||
}
|
||||
|
||||
iter->prev->destroy(iter->prev->data);
|
||||
free(iter->prev->data);
|
||||
free(iter->prev);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*This is a hack from AMS. Supposedly, it's pretty good for strings, even
|
||||
though it doesn't take into account all the data*/
|
||||
UINT4 hash_compute(key,len,bits)
|
||||
char *key;
|
||||
int len;
|
||||
int bits;
|
||||
{
|
||||
UINT4 h=0;
|
||||
|
||||
h=key[0] +(key[len-1] * len);
|
||||
|
||||
h &= (1<<bits) - 1;
|
||||
|
||||
return(h);
|
||||
}
|
||||
|
137
common/lib/r_assoc_test.c
Normal file
137
common/lib/r_assoc_test.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
r_assoc_test.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_assoc_test.c,v 1.2 2000/10/17 16:10:00 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Sun Jan 17 21:09:22 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_assoc_test.c,v 1.2 2000/10/17 16:10:00 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include <r_assoc.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char test_vector[1024],*v;
|
||||
int rnd,ct,r;
|
||||
r_assoc *assoc,*new_assoc;
|
||||
|
||||
if(r=r_assoc_create(&assoc)){
|
||||
fprintf(stderr,"Couldn't create\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
srand(getpid());
|
||||
|
||||
v=test_vector;
|
||||
for(ct=0;ct<256;ct++){
|
||||
v[0]=ct & 255;
|
||||
v[1]=(ct>>8) & 255;
|
||||
v[2]=(ct>>16) & 255;
|
||||
v[3]=(ct>>24) & 255;
|
||||
|
||||
|
||||
if(r=r_assoc_insert(assoc,v,4,v,0,0,R_ASSOC_REPLACE)){
|
||||
fprintf(stderr,"Couldn't insert %d\n",ct);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
v+=4;
|
||||
}
|
||||
|
||||
fetch_test(assoc);
|
||||
|
||||
if(r=r_assoc_copy(&new_assoc,assoc)){
|
||||
fprintf(stderr,"Couldn't copy\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
r_assoc_destroy(&assoc);
|
||||
|
||||
fetch_test(new_assoc);
|
||||
|
||||
r_assoc_destroy(&new_assoc);
|
||||
|
||||
printf("Tests pass\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int fetch_test(assoc)
|
||||
r_assoc *assoc;
|
||||
{
|
||||
int ct;
|
||||
char vec[4],*v;
|
||||
int r,_status,rnd;
|
||||
|
||||
for(ct=0;ct<65537;ct++){
|
||||
rnd=rand();
|
||||
|
||||
rnd &= 0x3ff;
|
||||
|
||||
vec[0]=rnd & 255;
|
||||
vec[1]=(rnd>>8) & 255;
|
||||
vec[2]=(rnd>>16) & 255;
|
||||
vec[3]=(rnd>>24) & 255;
|
||||
|
||||
if(r=r_assoc_fetch(assoc,vec,4,(void **)&v)){
|
||||
|
||||
if(rnd<256){
|
||||
fprintf(stderr,"Couldn't fetch\n");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else{
|
||||
if(rnd>255){
|
||||
fprintf(stderr,"Spurious fetch\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(memcmp(vec,v,4)){
|
||||
fprintf(stderr,"Fetch error\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
113
common/lib/r_bitfield.c
Normal file
113
common/lib/r_bitfield.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
r_bitfield.c
|
||||
|
||||
Copyright (C) 2001 RTFM, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
ekr@rtfm.com Wed Oct 3 11:15:23 2001
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_bitfield.c,v 1.3 2001/12/24 06:06:26 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include "r_bitfield.h"
|
||||
|
||||
int r_bitfield_create(setp,size)
|
||||
r_bitfield **setp;
|
||||
UINT4 size;
|
||||
{
|
||||
r_bitfield *set=0;
|
||||
int _status;
|
||||
int num_words=size/32+!!(size%32);
|
||||
|
||||
if(!(set=(r_bitfield *)RMALLOC(sizeof(r_bitfield))))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
if(!(set->data=(UINT4 *)RMALLOC(num_words*4)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
memset(set->data,0,4*num_words);
|
||||
|
||||
set->base=0;
|
||||
set->len=num_words;
|
||||
|
||||
*setp=set;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status){
|
||||
r_bitfield_destroy(&set);
|
||||
}
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_bitfield_destroy(setp)
|
||||
r_bitfield **setp;
|
||||
{
|
||||
r_bitfield *set;
|
||||
|
||||
if(!setp || !*setp)
|
||||
return(0);
|
||||
|
||||
set=*setp;
|
||||
|
||||
RFREE(set->data);
|
||||
RFREE(set);
|
||||
|
||||
*setp=0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_bitfield_set(set,bit)
|
||||
r_bitfield *set;
|
||||
int bit;
|
||||
{
|
||||
int word=(bit-set->base)/32;
|
||||
int bbit=(bit-set->base)%32;
|
||||
int _status;
|
||||
|
||||
/* Resize? */
|
||||
if(word>set->len){
|
||||
UINT4 newlen=set->len;
|
||||
UINT4 *tmp;
|
||||
|
||||
while(newlen<word)
|
||||
newlen*=2;
|
||||
|
||||
if(!(tmp=(UINT4 *)RMALLOC(newlen)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
memcpy(tmp,set->data,set->len*4);
|
||||
memset(tmp+set->len*4,0,(newlen-set->len)*4);
|
||||
|
||||
RFREE(set->data);
|
||||
set->data=tmp;
|
||||
}
|
||||
|
||||
set->data[word]|=1<<bbit;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_bitfield_isset(set,bit)
|
||||
r_bitfield *set;
|
||||
int bit;
|
||||
{
|
||||
int word=(bit-set->base)/32;
|
||||
int bbit=(bit-set->base)%32;
|
||||
int _status;
|
||||
|
||||
if(bit<set->base)
|
||||
return(0);
|
||||
|
||||
/* Resize? */
|
||||
if(word>set->len)
|
||||
return(0);
|
||||
|
||||
return(set->data[word]&(1<<bbit));
|
||||
|
||||
_status=0;
|
||||
return(_status);
|
||||
}
|
162
common/lib/r_data.c
Normal file
162
common/lib/r_data.c
Normal file
|
@ -0,0 +1,162 @@
|
|||
/**
|
||||
r_data.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_data.c,v 1.3 2001/07/20 23:33:15 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Aug 17 15:39:50 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_data.c,v 1.3 2001/07/20 23:33:15 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include <r_data.h>
|
||||
|
||||
int r_data_create(dp,d,l)
|
||||
Data **dp;
|
||||
UCHAR *d;
|
||||
int l;
|
||||
{
|
||||
Data *d_=0;
|
||||
int _status;
|
||||
|
||||
if(!(d_=(Data *)calloc(sizeof(Data),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(!(d_->data=(UCHAR *)malloc(l)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
memcpy(d_->data,d,l);
|
||||
d_->len=l;
|
||||
|
||||
*dp=d_;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status)
|
||||
r_data_destroy(&d_);
|
||||
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_data_alloc(dp,l)
|
||||
Data **dp;
|
||||
int l;
|
||||
{
|
||||
Data *d_=0;
|
||||
int _status;
|
||||
|
||||
if(!(d_=(Data *)calloc(sizeof(Data),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
if(!(d_->data=(UCHAR *)calloc(l,1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
d_->len=l;
|
||||
|
||||
*dp=d_;
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status)
|
||||
r_data_destroy(&d_);
|
||||
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_data_make(dp,d,l)
|
||||
Data *dp;
|
||||
UCHAR *d;
|
||||
int l;
|
||||
{
|
||||
if(!(dp->data=(UCHAR *)malloc(l)))
|
||||
ERETURN(R_NO_MEMORY);
|
||||
|
||||
memcpy(dp->data,d,l);
|
||||
dp->len=l;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_data_destroy(dp)
|
||||
Data **dp;
|
||||
{
|
||||
if(!dp || !*dp)
|
||||
return(0);
|
||||
|
||||
if((*dp)->data)
|
||||
free((*dp)->data);
|
||||
|
||||
free(*dp);
|
||||
*dp=0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_data_copy(dst,src)
|
||||
Data *dst;
|
||||
Data *src;
|
||||
{
|
||||
if(!(dst->data=(UCHAR *)malloc(src->len)))
|
||||
ERETURN(R_NO_MEMORY);
|
||||
memcpy(dst->data,src->data,dst->len=src->len);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_data_zfree(d)
|
||||
Data *d;
|
||||
{
|
||||
if(!d)
|
||||
return(0);
|
||||
if(!d->data)
|
||||
return(0);
|
||||
memset(d->data,0,d->len);
|
||||
free(d->data);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_data_compare(d1,d2)
|
||||
Data *d1;
|
||||
Data *d2;
|
||||
{
|
||||
if(d1->len<d2->len)
|
||||
return(-1);
|
||||
if(d2->len<d1->len)
|
||||
return(-1);
|
||||
return(memcmp(d1->data,d2->data,d1->len));
|
||||
}
|
||||
|
52
common/lib/r_data.h
Normal file
52
common/lib/r_data.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
r_data.h
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_data.h,v 1.2 2000/10/17 16:10:00 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Fri Feb 4 08:58:48 2000
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _r_data_h
|
||||
#define _r_data_h
|
||||
|
||||
|
||||
#endif
|
||||
|
61
common/lib/r_errors.c
Normal file
61
common/lib/r_errors.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
r_errors.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_errors.c,v 1.3 2001/12/24 06:06:27 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Feb 16 16:37:05 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_errors.c,v 1.3 2001/12/24 06:06:27 ekr Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "r_common.h"
|
||||
#include "r_errors.h"
|
||||
|
||||
int verr_exit(char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,fmt);
|
||||
vfprintf(stderr,fmt,ap);
|
||||
exit(1);
|
||||
}
|
234
common/lib/r_list.c
Normal file
234
common/lib/r_list.c
Normal file
|
@ -0,0 +1,234 @@
|
|||
/**
|
||||
r_list.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_list.c,v 1.4 2001/12/24 06:06:27 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Tue Jan 19 08:36:39 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_list.c,v 1.4 2001/12/24 06:06:27 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include "r_list.h"
|
||||
|
||||
typedef struct r_list_el_ {
|
||||
void *data;
|
||||
struct r_list_el_ *next;
|
||||
struct r_list_el_ *prev;
|
||||
int (*copy) PROTO_LIST((void **new,void *old));
|
||||
int (*destroy) PROTO_LIST((void **ptr));
|
||||
} r_list_el;
|
||||
|
||||
struct r_list_ {
|
||||
struct r_list_el_ *first;
|
||||
struct r_list_el_ *last;
|
||||
};
|
||||
|
||||
int r_list_create(listp)
|
||||
r_list **listp;
|
||||
{
|
||||
r_list *list=0;
|
||||
int _status;
|
||||
|
||||
if(!(list=(r_list *)calloc(sizeof(r_list),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
list->first=0;
|
||||
list->last=0;
|
||||
*listp=list;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_list_destroy(listp)
|
||||
r_list **listp;
|
||||
{
|
||||
r_list *list;
|
||||
r_list_el *el;
|
||||
|
||||
if(!listp || !*listp)
|
||||
return(0);
|
||||
list=*listp;
|
||||
|
||||
el=list->first;
|
||||
|
||||
while(el){
|
||||
r_list_el *el_t;
|
||||
|
||||
if(el->destroy && el->data)
|
||||
el->destroy(&el->data);
|
||||
el_t=el;
|
||||
el=el->next;
|
||||
free(el_t);
|
||||
}
|
||||
|
||||
free(list);
|
||||
*listp=0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_list_copy(outp,in)
|
||||
r_list**outp;
|
||||
r_list *in;
|
||||
{
|
||||
r_list *out=0;
|
||||
r_list_el *el,*el2,*last=0;
|
||||
int r, _status;
|
||||
|
||||
if(r=r_list_create(&out))
|
||||
ABORT(r);
|
||||
|
||||
for(el=in->first;in;el=el->next){
|
||||
if(!(el2=(r_list_el *)calloc(sizeof(r_list_el),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
if(el->copy && el->data){
|
||||
if(r=el->copy(&el2->data,el->data))
|
||||
ABORT(r);
|
||||
}
|
||||
|
||||
el2->copy=el->copy;
|
||||
el2->destroy=el->destroy;
|
||||
|
||||
if(!(out->first))
|
||||
out->first=el2;
|
||||
|
||||
el2->prev=last;
|
||||
last->next=el2;
|
||||
last=el2;
|
||||
}
|
||||
|
||||
out->last=last;
|
||||
|
||||
*outp=out;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
if(_status)
|
||||
r_list_destroy(&out);
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_list_insert(list,value,copy,destroy)
|
||||
r_list *list;
|
||||
void *value;
|
||||
int (*copy) PROTO_LIST((void **out, void *in));
|
||||
int (*destroy) PROTO_LIST((void **val));
|
||||
{
|
||||
r_list_el *el=0;
|
||||
int _status;
|
||||
|
||||
if(!(el=(r_list_el *)calloc(sizeof(r_list_el),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
el->data=value;
|
||||
el->copy=copy;
|
||||
el->destroy=destroy;
|
||||
|
||||
el->prev=0;
|
||||
el->next=list->first;
|
||||
if(list->first){
|
||||
list->first->prev=el;
|
||||
}
|
||||
list->first=el;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_list_append(list,value,copy,destroy)
|
||||
r_list *list;
|
||||
void *value;
|
||||
int (*copy) PROTO_LIST((void **out, void *in));
|
||||
int (*destroy) PROTO_LIST((void **val));
|
||||
{
|
||||
r_list_el *el=0;
|
||||
int _status;
|
||||
|
||||
if(!(el=(r_list_el *)calloc(sizeof(r_list_el),1)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
el->data=value;
|
||||
el->copy=copy;
|
||||
el->destroy=destroy;
|
||||
|
||||
el->prev=list->last;
|
||||
el->next=0;
|
||||
|
||||
if(list->last) list->last->next=el;
|
||||
else list->first=el;
|
||||
|
||||
list->last=el;
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_list_init_iter(list,iter)
|
||||
r_list *list;
|
||||
r_list_iterator *iter;
|
||||
{
|
||||
iter->list=list;
|
||||
iter->ptr=list->first;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_list_iter(iter,val)
|
||||
r_list_iterator *iter;
|
||||
void **val;
|
||||
{
|
||||
if(!iter->ptr)
|
||||
return(R_EOD);
|
||||
|
||||
*val=iter->ptr->data;
|
||||
iter->ptr=iter->ptr->next;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
67
common/lib/r_replace.c
Normal file
67
common/lib/r_replace.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
r_replace.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_replace.c,v 1.2 2000/10/17 16:10:00 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Sun Oct 1 11:18:49 2000
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_replace.c,v 1.2 2000/10/17 16:10:00 ekr Exp $";
|
||||
|
||||
#include "r_common.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
|
||||
char *strdup(str)
|
||||
char *str;
|
||||
{
|
||||
int len=strlen(str);
|
||||
char *n;
|
||||
|
||||
if(!(n=(char *)malloc(len+1)))
|
||||
return(0);
|
||||
|
||||
memcpy(n,str,len+1);
|
||||
|
||||
return(n);
|
||||
}
|
||||
#endif
|
||||
|
158
common/lib/r_time.c
Normal file
158
common/lib/r_time.c
Normal file
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
r_time.c
|
||||
|
||||
|
||||
Copyright (C) 1999-2000 RTFM, Inc.
|
||||
All Rights Reserved
|
||||
|
||||
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
|
||||
<ekr@rtfm.com> and licensed by RTFM, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed by Eric Rescorla for
|
||||
RTFM, Inc.
|
||||
|
||||
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
|
||||
used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY SUCH DAMAGE.
|
||||
|
||||
$Id: r_time.c,v 1.6 2002/09/09 21:02:58 ekr Exp $
|
||||
|
||||
|
||||
ekr@rtfm.com Thu Mar 4 08:43:46 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: r_time.c,v 1.6 2002/09/09 21:02:58 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include <r_time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tzp)
|
||||
{
|
||||
/* JAN1_1970_OFFSET is the number of 100-nanoseconds ticks
|
||||
between midnight jan 1, 1970 and jan 1, 1601.
|
||||
*/
|
||||
|
||||
const ULARGE_INTEGER JAN1_1970_OFFSET = {0xd53e8000, 0x019db1de};
|
||||
ULARGE_INTEGER currentTimeSinceJan_1_1970;
|
||||
FILETIME currentTime;
|
||||
|
||||
GetSystemTimeAsFileTime( ¤tTime );
|
||||
currentTimeSinceJan_1_1970.LowPart = currentTime.dwLowDateTime;
|
||||
currentTimeSinceJan_1_1970.HighPart = currentTime.dwHighDateTime;
|
||||
currentTimeSinceJan_1_1970.QuadPart -= JAN1_1970_OFFSET.QuadPart;
|
||||
|
||||
/* At this point, currentTimeSinceJan_1_1970 contains the
|
||||
number of 100-nanosecond 'ticks' since midnight, Jan. 1,
|
||||
1970. This is equivalent to 10 * the number of microseconds
|
||||
elapsed since this time. The BSD man pages for gettimeofday()
|
||||
suggest that we should return the whole number of seconds in
|
||||
the tv_sec field, and the fractional number of seconds in units
|
||||
of microseconds in the tv_usec field.
|
||||
|
||||
sec = time / 10000000, usec = (time % 10000000) / 10;
|
||||
*/
|
||||
|
||||
tv->tv_sec = currentTimeSinceJan_1_1970.QuadPart / 10000000;
|
||||
tv->tv_usec = (currentTimeSinceJan_1_1970.QuadPart % 10000000) / 10;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/*Note that t1 must be > t0 */
|
||||
int r_timeval_diff(t1,t0,diff)
|
||||
struct timeval *t1;
|
||||
struct timeval *t0;
|
||||
struct timeval *diff;
|
||||
{
|
||||
long d;
|
||||
|
||||
if(t0->tv_sec > t1->tv_sec)
|
||||
ERETURN(R_BAD_ARGS);
|
||||
|
||||
/*Easy case*/
|
||||
if(t0->tv_usec <= t1->tv_usec){
|
||||
diff->tv_sec=t1->tv_sec - t0->tv_sec;
|
||||
diff->tv_usec=t1->tv_usec - t0->tv_usec;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*Hard case*/
|
||||
d=t0->tv_usec - t1->tv_usec;
|
||||
if(t1->tv_sec < (t0->tv_sec + 1))
|
||||
ERETURN(R_BAD_ARGS);
|
||||
diff->tv_sec=t1->tv_sec - (t0->tv_sec + 1);
|
||||
diff->tv_usec=1000000 - d;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_timeval_add(t1,t2,sum)
|
||||
struct timeval *t1;
|
||||
struct timeval *t2;
|
||||
struct timeval *sum;
|
||||
{
|
||||
long tv_sec,tv_usec,d;
|
||||
|
||||
tv_sec=t1->tv_sec + t2->tv_sec;
|
||||
|
||||
d=t1->tv_usec + t2->tv_usec;
|
||||
if(d>1000000){
|
||||
tv_sec++;
|
||||
tv_usec=d-1000000;
|
||||
}
|
||||
else{
|
||||
tv_usec=d;
|
||||
}
|
||||
|
||||
sum->tv_sec=tv_sec;
|
||||
sum->tv_usec=tv_usec;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
UINT8 r_timeval2int(tv)
|
||||
struct timeval *tv;
|
||||
{
|
||||
UINT8 r=0;
|
||||
|
||||
r=(tv->tv_sec);
|
||||
r*=1000000;
|
||||
r+=tv->tv_usec;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
UINT8 r_gettimeint()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv,0);
|
||||
|
||||
return r_timeval2int(&tv);
|
||||
}
|
280
common/lib/rb_local.mk
Normal file
280
common/lib/rb_local.mk
Normal file
|
@ -0,0 +1,280 @@
|
|||
#
|
||||
# rb_local.mk
|
||||
#
|
||||
# $Source$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# $Name$
|
||||
# $Disclaimer$
|
||||
#
|
||||
# Copyright (C) 2001, Terisa Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ekr@terisa.com
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE USER-DEFINED MAKE ENVIRONMENT
|
||||
#
|
||||
# These fields are specified by the user. The remainder of
|
||||
# this file is generated from this user-specified information.
|
||||
#
|
||||
# COMMON_LIB_DEFINES:
|
||||
# cpp defines, with the -D flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_INCLUDES:
|
||||
# cpp include directories, with the -I flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_INTERNAL:
|
||||
# headers files which are local to a specific module directory,
|
||||
# and should not be used by other parts of the toolkit or by
|
||||
# the user
|
||||
#
|
||||
# COMMON_LIB_LIBNAME:
|
||||
# the library associated with this module directory, used in
|
||||
# most cases for debugging purposes
|
||||
#
|
||||
# COMMON_LIB_LIBPATHS:
|
||||
# link-time directories to search for libraries, with the -L flag
|
||||
# preceeding each
|
||||
#
|
||||
# COMMON_LIB_LIBRARIES:
|
||||
# link-time libraries, with the -l flag preceeding each
|
||||
#
|
||||
# COMMON_LIB_LOCALFLAGS:
|
||||
# compile-time flags specific to compiling only the files in
|
||||
# this module directory--this variable should only be set in
|
||||
# extremely exceptional cases
|
||||
#
|
||||
# COMMON_LIB_MAKEFILES:
|
||||
# the makefiles
|
||||
#
|
||||
# COMMON_LIB_PREFIX:
|
||||
# defines the module name, which also serves as the
|
||||
# prefix for all the variable names defined in this file
|
||||
#
|
||||
# COMMON_LIB_PRIVATE:
|
||||
# the private, for-toolkit-use-only API header files
|
||||
#
|
||||
# COMMON_LIB_PROGRAMS:
|
||||
# programs to build
|
||||
#
|
||||
# COMMON_LIB_PUBLIC:
|
||||
# the header files that define the public API for the toolkit
|
||||
# and any other 'public' files that should be copied to
|
||||
# the build directory
|
||||
#
|
||||
# COMMON_LIB_SOURCES:
|
||||
# the source files to compile to object
|
||||
#
|
||||
COMMON_LIB_DEFINES =
|
||||
COMMON_LIB_INCLUDES =
|
||||
COMMON_LIB_INTERNAL =
|
||||
COMMON_LIB_LIBNAME = libcommon.$(LIBSUFFIX)
|
||||
COMMON_LIB_LIBPATHS =
|
||||
COMMON_LIB_LIBRARIES =
|
||||
COMMON_LIB_LOCALFLAGS =
|
||||
COMMON_LIB_MAKEFILES = targets.mk
|
||||
COMMON_LIB_PREFIX = COMMON_LIB
|
||||
COMMON_LIB_PRIVATE =
|
||||
COMMON_LIB_PROGRAMS =
|
||||
COMMON_LIB_PUBLIC =
|
||||
COMMON_LIB_SOURCES = debug.c r_assoc.c r_bitfield.c r_data.c \
|
||||
r_errors.c r_list.c r_replace.c r_time.c
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE AUTOMATICALLY-GENERATED MAKE ENVIRONMENT
|
||||
#
|
||||
# COMMON_LIB_OBJECTS:
|
||||
# object files to build
|
||||
#
|
||||
# COMMON_LIB_UNUSED:
|
||||
# obsolete files in the module directory that are not
|
||||
# used during the build process
|
||||
#
|
||||
# COMMON_LIB_USED:
|
||||
# all files in the module directory that are used
|
||||
# during the build process
|
||||
#
|
||||
COMMON_LIB_OBJECTS = debug.$(OBJSUFFIX) r_assoc.$(OBJSUFFIX) \
|
||||
r_bitfield.$(OBJSUFFIX) r_data.$(OBJSUFFIX) \
|
||||
r_errors.$(OBJSUFFIX) r_list.$(OBJSUFFIX) \
|
||||
r_replace.$(OBJSUFFIX) r_time.$(OBJSUFFIX)
|
||||
COMMON_LIB_UNUSED = assoc.h debug.h local.mk r_assoc_test.c r_data.h \
|
||||
rb_local.mk
|
||||
COMMON_LIB_USED = $(COMMON_LIB_INTERNAL:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_MAKEFILES:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_PRIVATE:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_PUBLIC:%=$(COMMON_LIB_SRCDIR)%) \
|
||||
$(COMMON_LIB_SOURCES:%=$(COMMON_LIB_SRCDIR)%)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# NOTES
|
||||
#
|
||||
# The following variables may be used during the build process,
|
||||
# but are not defined in this file. If they are to be set
|
||||
# to something other than the default blank, then they must
|
||||
# be set by the calling make system.
|
||||
#
|
||||
# COMMON_LIB_SRCDIR:
|
||||
# if the build target directory is different from the
|
||||
# module directory (the source directory), then this
|
||||
# variable contains the relative or full path of
|
||||
# the module directory
|
||||
#
|
||||
# LIBARS:
|
||||
# the library archive files (with fully-specified paths) that
|
||||
# executables built from this module directory depend upon
|
||||
#
|
||||
# LIBPATHS:
|
||||
# the paths to search for library archives (specified with
|
||||
# the -L)
|
||||
#
|
||||
# LIBRARIES:
|
||||
# the libraries to use while building executables from
|
||||
# this module directory (specified with the -l)
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GLOBAL ENVIRONMENT
|
||||
#
|
||||
DEFINES += $(COMMON_LIB_DEFINES)
|
||||
INCLUDES += $(COMMON_LIB_INCLUDES)
|
||||
LIBPATHS += $(COMMON_LIB_LIBPATHS)
|
||||
LIBRARIES += $(COMMON_LIB_LIBRARIES)
|
||||
OBJECTS += $(COMMON_LIB_OBJECTS)
|
||||
PUBLIC += $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GENERIC DEPENDENCIES
|
||||
#
|
||||
# default:
|
||||
# default dependency, must be the first dependency in this makefile
|
||||
#
|
||||
# all:
|
||||
# build everything in this module directory
|
||||
#
|
||||
# build:
|
||||
# make only the toolkit build files of this module directory
|
||||
#
|
||||
# ci:
|
||||
# perform an RCS check-in of this module directory
|
||||
#
|
||||
# clean:
|
||||
# remove the compiled files
|
||||
#
|
||||
# clean_public:
|
||||
# remove the public header files that have been copied
|
||||
# to a public build directory
|
||||
#
|
||||
# objects:
|
||||
# build the object files (this dependency is used for
|
||||
# building the toolkit library)
|
||||
#
|
||||
# private:
|
||||
# build only the private API header files
|
||||
#
|
||||
# public:
|
||||
# build only the public API header files
|
||||
#
|
||||
default: $(COMMON_LIB_LIBNAME)
|
||||
default: $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
all: $(COMMON_LIB_PUBLIC)
|
||||
all: $(COMMON_LIB_OBJECTS)
|
||||
all: $(COMMON_LIB_LIBNAME)
|
||||
all: $(COMMON_LIB_PROGRAMS)
|
||||
build: $(COMMON_LIB_PUBLIC)
|
||||
build: $(COMMON_LIB_OBJECTS)
|
||||
ci: common_lib_ci
|
||||
clean: common_lib_clean
|
||||
clean_public: common_lib_clean_public
|
||||
objects: $(COMMON_LIB_OBJECTS)
|
||||
private: $(COMMON_LIB_PRIVATE)
|
||||
public: $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# LOCAL UTILITY DEPENDENCIES
|
||||
#
|
||||
# utility dependencies are necessary because of some
|
||||
# make-isms having to do with dependencies
|
||||
#
|
||||
|
||||
common_lib_ci:
|
||||
$(CI) $(CIFLAGS) $(COMMON_LIB_USED)
|
||||
|
||||
common_lib_clean:
|
||||
$(RM) $(RMFLAGS) $(COMMON_LIB_OBJECTS) $(COMMON_LIB_LIBNAME) $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
common_lib_clean_public:
|
||||
$(RM) $(RMFLAGS) $(COMMON_LIB_PUBLIC)
|
||||
|
||||
common_lib_objects: $(COMMON_LIB_OBJECTS)
|
||||
|
||||
common_lib_programs: $(COMMON_LIB_PROGRAMS)
|
||||
|
||||
common_lib_public: $(COMMON_LIB_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# BUILD DEPENDENCIES
|
||||
#
|
||||
# build dependencies invoke the rule used to build each
|
||||
# class of file
|
||||
#
|
||||
|
||||
$(COMMON_LIB_LIBNAME):
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
$(COMMON_LIB_OBJECTS):
|
||||
$(COMPILE.c) $(COMMON_LIB_SRCDIR)$(@:%.$(OBJSUFFIX)=%.c) $(DEFINES) $(INCLUDES) $(COMMON_LIB_LOCALFLAGS)
|
||||
|
||||
$(COMMON_LIB_PUBLIC):
|
||||
$(CP) $(CPFLAGS) $(COMMON_LIB_SRCDIR)$@ $@
|
||||
|
||||
$(COMMON_LIB_PROGRAMS):
|
||||
$(LINK.c) $@.$(OBJSUFFIX) $(LDLIBS) $(LIBS) $(LIBRARIES) $(LIBPATHS)
|
||||
#LIBS above is obsolete (use LIBARARIES instead)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# FILE DEPENDENCIES
|
||||
#
|
||||
# file dependencies state, for each file that is built,
|
||||
# which file(s) it depends upon
|
||||
#
|
||||
|
||||
debug.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)debug.h
|
||||
debug.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)debug.c
|
||||
|
||||
r_assoc.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_assoc.c
|
||||
|
||||
r_bitfield.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_bitfield.c
|
||||
|
||||
r_data.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_data.h
|
||||
r_data.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_data.c
|
||||
|
||||
r_errors.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_errors.c
|
||||
|
||||
r_list.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_list.c
|
||||
|
||||
r_replace.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_replace.c
|
||||
|
||||
r_time.$(OBJSUFFIX): $(COMMON_LIB_SRCDIR)r_time.c
|
||||
|
||||
$(COMMON_LIB_LIBNAME): $(COMMON_LIB_OBJECTS)
|
2
common/lib/targets.mk
Normal file
2
common/lib/targets.mk
Normal file
|
@ -0,0 +1,2 @@
|
|||
include $(COMMON_LIB_SRCDIR)local.mk
|
||||
|
0
common/lib/threads/null/targets.mk
Normal file
0
common/lib/threads/null/targets.mk
Normal file
151
common/lib/threads/pthreads/pthread.c
Normal file
151
common/lib/threads/pthreads/pthread.c
Normal file
|
@ -0,0 +1,151 @@
|
|||
/**
|
||||
pthread.c
|
||||
|
||||
Copyright (C) 1999, RTFM, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
ekr@rtfm.com Tue Feb 23 15:08:03 1999
|
||||
*/
|
||||
|
||||
|
||||
static char *RCSSTRING="$Id: pthread.c,v 1.1.1.1 2000/10/09 00:45:39 ekr Exp $";
|
||||
|
||||
#include <r_common.h>
|
||||
#include <r_thread.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static int thread_count=0;
|
||||
|
||||
typedef struct {
|
||||
void (*func) PROTO_LIST((void *));
|
||||
void *arg;
|
||||
} helper;
|
||||
|
||||
|
||||
static void *r_thread_real_create PROTO_LIST((void *arg));
|
||||
|
||||
static void *r_thread_real_create(arg)
|
||||
void *arg;
|
||||
{
|
||||
helper *h;
|
||||
|
||||
h=(helper *)arg;
|
||||
|
||||
thread_count++;
|
||||
|
||||
h->func(h->arg);
|
||||
|
||||
thread_count--;
|
||||
free(h);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_thread_fork(func,arg,id)
|
||||
void (*func) PROTO_LIST((void *));
|
||||
void *arg;
|
||||
r_thread *id;
|
||||
{
|
||||
pthread_t thread;
|
||||
helper *h;
|
||||
int r,_status;
|
||||
|
||||
h=(helper *)malloc(sizeof(helper));
|
||||
|
||||
h->func=func;
|
||||
h->arg=arg;
|
||||
|
||||
if(r=pthread_create(&thread,0,r_thread_real_create,(void *)h))
|
||||
ABORT(R_INTERNAL);
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int r_thread_yield()
|
||||
{
|
||||
pthread_yield();
|
||||
}
|
||||
|
||||
int r_thread_exit()
|
||||
{
|
||||
thread_count--;
|
||||
pthread_exit(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_thread_wait_last()
|
||||
{
|
||||
do {
|
||||
pthread_yield();
|
||||
usleep(10000);
|
||||
DBG((0,"%d threads left",thread_count));
|
||||
} while (thread_count);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_rwlock_create(lockp)
|
||||
r_rwlock **lockp;
|
||||
{
|
||||
pthread_rwlock_t *lock;
|
||||
int r;
|
||||
|
||||
if(!(lock=(pthread_rwlock_t *)malloc(sizeof(pthread_rwlock_t))))
|
||||
ERETURN(R_NO_MEMORY);
|
||||
|
||||
if(r=pthread_rwlock_init(lock,0))
|
||||
ERETURN(R_INTERNAL);
|
||||
|
||||
*lockp=(void *)lock;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_rwlock_destroy(lock)
|
||||
r_rwlock **lock;
|
||||
{
|
||||
pthread_rwlock_t *plock;
|
||||
|
||||
if(!lock || !*lock)
|
||||
return(0);
|
||||
|
||||
plock=(pthread_rwlock_t *)(*lock);
|
||||
|
||||
pthread_rwlock_destroy(plock);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int r_rwlock_lock(lock,action)
|
||||
r_rwlock *lock;
|
||||
int action;
|
||||
{
|
||||
pthread_rwlock_t *plock;
|
||||
int r,_status;
|
||||
|
||||
plock=(pthread_rwlock_t *)lock;
|
||||
|
||||
switch(action){
|
||||
case R_RWLOCK_UNLOCK:
|
||||
if(r=pthread_rwlock_unlock(plock))
|
||||
ABORT(R_INTERNAL);
|
||||
break;
|
||||
case R_RWLOCK_RLOCK:
|
||||
if(r=pthread_rwlock_rdlock(plock))
|
||||
ABORT(R_INTERNAL);
|
||||
break;
|
||||
case R_RWLOCK_WLOCK:
|
||||
if(r=pthread_rwlock_wrlock(plock))
|
||||
ABORT(R_INTERNAL);
|
||||
break;
|
||||
default:
|
||||
ABORT(R_BAD_ARGS);
|
||||
}
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
|
||||
|
259
common/lib/threads/pthreads/targets.mk
Normal file
259
common/lib/threads/pthreads/targets.mk
Normal file
|
@ -0,0 +1,259 @@
|
|||
#
|
||||
# targets.mk
|
||||
#
|
||||
# $Source: /usr/local/CVS/ssldump/common/lib/threads/pthreads/targets.mk,v $
|
||||
# $Revision: 1.1.1.1 $
|
||||
# $Date: 2000/10/09 00:45:39 $
|
||||
# $Name: $
|
||||
# $Disclaimer$
|
||||
#
|
||||
# Copyright (C) 1999, Terisa Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# ekr@terisa.com
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE USER-DEFINED MAKE ENVIRONMENT
|
||||
#
|
||||
# These fields are specified by the user. The remainder of
|
||||
# this file is generated from this user-specified information.
|
||||
#
|
||||
# THREADS_PTHREADS_DEFINES:
|
||||
# cpp defines, with the -D flag preceeding each
|
||||
#
|
||||
# THREADS_PTHREADS_INCLUDES:
|
||||
# cpp include directories, with the -I flag preceeding each
|
||||
#
|
||||
# THREADS_PTHREADS_INTERNAL:
|
||||
# headers files which are local to a specific module directory,
|
||||
# and should not be used by other parts of the toolkit or by
|
||||
# the user
|
||||
#
|
||||
# THREADS_PTHREADS_LIBNAME:
|
||||
# the library associated with this module directory, used in
|
||||
# most cases for debugging purposes
|
||||
#
|
||||
# THREADS_PTHREADS_LIBPATHS:
|
||||
# link-time directories to search for libraries, with the -L flag
|
||||
# preceeding each
|
||||
#
|
||||
# THREADS_PTHREADS_LIBRARIES:
|
||||
# link-time libraries, with the -l flag preceeding each
|
||||
#
|
||||
# THREADS_PTHREADS_LOCALFLAGS:
|
||||
# compile-time flags specific to compiling only the files in
|
||||
# this module directory--this variable should only be set in
|
||||
# extremely exceptional cases
|
||||
#
|
||||
# THREADS_PTHREADS_MAKEFILES:
|
||||
# the makefiles
|
||||
#
|
||||
# THREADS_PTHREADS_PREFIX:
|
||||
# defines the module name, which also serves as the
|
||||
# prefix for all the variable names defined in this file
|
||||
#
|
||||
# THREADS_PTHREADS_PRIVATE:
|
||||
# the private, for-toolkit-use-only API header files
|
||||
#
|
||||
# THREADS_PTHREADS_PROGRAMS:
|
||||
# programs to build
|
||||
#
|
||||
# THREADS_PTHREADS_PUBLIC:
|
||||
# the header files that define the public API for the toolkit
|
||||
# and any other 'public' files that should be copied to
|
||||
# the build directory
|
||||
#
|
||||
# THREADS_PTHREADS_SOURCES:
|
||||
# the source files to compile to object
|
||||
#
|
||||
THREADS_PTHREADS_DEFINES =
|
||||
THREADS_PTHREADS_INCLUDES =
|
||||
THREADS_PTHREADS_INTERNAL =
|
||||
THREADS_PTHREADS_LIBNAME =
|
||||
THREADS_PTHREADS_LIBPATHS =
|
||||
THREADS_PTHREADS_LIBRARIES =
|
||||
THREADS_PTHREADS_LOCALFLAGS =
|
||||
THREADS_PTHREADS_MAKEFILES =
|
||||
THREADS_PTHREADS_PREFIX = THREADS_PTHREADS
|
||||
THREADS_PTHREADS_PRIVATE =
|
||||
THREADS_PTHREADS_PROGRAMS =
|
||||
THREADS_PTHREADS_PUBLIC =
|
||||
THREADS_PTHREADS_SOURCES = pthread.c
|
||||
|
||||
|
||||
|
||||
#
|
||||
# CONFIGURE AUTOMATICALLY-GENERATED MAKE ENVIRONMENT
|
||||
#
|
||||
# THREADS_PTHREADS_OBJECTS:
|
||||
# object files to build
|
||||
#
|
||||
# THREADS_PTHREADS_UNUSED:
|
||||
# obsolete files in the module directory that are not
|
||||
# used during the build process
|
||||
#
|
||||
# THREADS_PTHREADS_USED:
|
||||
# all files in the module directory that are used
|
||||
# during the build process
|
||||
#
|
||||
THREADS_PTHREADS_OBJECTS = pthread.$(OBJSUFFIX)
|
||||
THREADS_PTHREADS_UNUSED = targets.mk
|
||||
THREADS_PTHREADS_USED = $(THREADS_PTHREADS_INTERNAL:%=$(THREADS_PTHREADS_SRCDIR)%) \
|
||||
$(THREADS_PTHREADS_MAKEFILES:%=$(THREADS_PTHREADS_SRCDIR)%) \
|
||||
$(THREADS_PTHREADS_PRIVATE:%=$(THREADS_PTHREADS_SRCDIR)%) \
|
||||
$(THREADS_PTHREADS_PUBLIC:%=$(THREADS_PTHREADS_SRCDIR)%) \
|
||||
$(THREADS_PTHREADS_SOURCES:%=$(THREADS_PTHREADS_SRCDIR)%)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# NOTES
|
||||
#
|
||||
# The following variables may be used during the build process,
|
||||
# but are not defined in this file. If they are to be set
|
||||
# to something other than the default blank, then they must
|
||||
# be set by the calling make system.
|
||||
#
|
||||
# THREADS_PTHREADS_SRCDIR:
|
||||
# if the build target directory is different from the
|
||||
# module directory (the source directory), then this
|
||||
# variable contains the relative or full path of
|
||||
# the module directory
|
||||
#
|
||||
# LIBARS:
|
||||
# the library archive files (with fully-specified paths) that
|
||||
# executables built from this module directory depend upon
|
||||
#
|
||||
# LIBPATHS:
|
||||
# the paths to search for library archives (specified with
|
||||
# the -L)
|
||||
#
|
||||
# LIBRARIES:
|
||||
# the libraries to use while building executables from
|
||||
# this module directory (specified with the -l)
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GLOBAL ENVIRONMENT
|
||||
#
|
||||
DEFINES += $(THREADS_PTHREADS_DEFINES)
|
||||
INCLUDES += $(THREADS_PTHREADS_INCLUDES)
|
||||
LIBPATHS += $(THREADS_PTHREADS_LIBPATHS)
|
||||
LIBRARIES += $(THREADS_PTHREADS_LIBRARIES)
|
||||
OBJECTS += $(THREADS_PTHREADS_OBJECTS)
|
||||
PUBLIC += $(THREADS_PTHREADS_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# GENERIC DEPENDENCIES
|
||||
#
|
||||
# default:
|
||||
# default dependency, must be the first dependency in this makefile
|
||||
#
|
||||
# all:
|
||||
# build everything in this module directory
|
||||
#
|
||||
# build:
|
||||
# make only the toolkit build files of this module directory
|
||||
#
|
||||
# ci:
|
||||
# perform an RCS check-in of this module directory
|
||||
#
|
||||
# clean:
|
||||
# remove the compiled files
|
||||
#
|
||||
# clean_public:
|
||||
# remove the public header files that have been copied
|
||||
# to a public build directory
|
||||
#
|
||||
# objects:
|
||||
# build the object files (this dependency is used for
|
||||
# building the toolkit library)
|
||||
#
|
||||
# private:
|
||||
# build only the private API header files
|
||||
#
|
||||
# public:
|
||||
# build only the public API header files
|
||||
#
|
||||
default: $(THREADS_PTHREADS_LIBNAME)
|
||||
default: $(THREADS_PTHREADS_PROGRAMS)
|
||||
|
||||
all: $(THREADS_PTHREADS_PUBLIC)
|
||||
all: $(THREADS_PTHREADS_OBJECTS)
|
||||
all: $(THREADS_PTHREADS_LIBNAME)
|
||||
all: $(THREADS_PTHREADS_PROGRAMS)
|
||||
build: $(THREADS_PTHREADS_PUBLIC)
|
||||
build: $(THREADS_PTHREADS_OBJECTS)
|
||||
ci: threads_pthreads_ci
|
||||
clean: threads_pthreads_clean
|
||||
clean_public: threads_pthreads_clean_public
|
||||
objects: $(THREADS_PTHREADS_OBJECTS)
|
||||
private: $(THREADS_PTHREADS_PRIVATE)
|
||||
public: $(THREADS_PTHREADS_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# LOCAL UTILITY DEPENDENCIES
|
||||
#
|
||||
# utility dependencies are necessary because of some
|
||||
# make-isms having to do with dependencies
|
||||
#
|
||||
|
||||
threads_pthreads_ci:
|
||||
$(CI) $(CIFLAGS) $(THREADS_PTHREADS_USED)
|
||||
|
||||
threads_pthreads_clean:
|
||||
$(RM) $(RMFLAGS) $(THREADS_PTHREADS_OBJECTS) $(THREADS_PTHREADS_LIBNAME) $(THREADS_PTHREADS_PROGRAMS)
|
||||
|
||||
threads_pthreads_clean_public:
|
||||
$(RM) $(RMFLAGS) $(THREADS_PTHREADS_PUBLIC)
|
||||
|
||||
threads_pthreads_objects: $(THREADS_PTHREADS_OBJECTS)
|
||||
|
||||
threads_pthreads_programs: $(THREADS_PTHREADS_PROGRAMS)
|
||||
|
||||
threads_pthreads_public: $(THREADS_PTHREADS_PUBLIC)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# BUILD DEPENDENCIES
|
||||
#
|
||||
# build dependencies invoke the rule used to build each
|
||||
# class of file
|
||||
#
|
||||
|
||||
$(THREADS_PTHREADS_LIBNAME):
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
$(THREADS_PTHREADS_OBJECTS):
|
||||
$(COMPILE.c) $(THREADS_PTHREADS_SRCDIR)$(@:%.$(OBJSUFFIX)=%.c) $(DEFINES) $(INCLUDES) $(THREADS_PTHREADS_LOCALFLAGS)
|
||||
|
||||
$(THREADS_PTHREADS_PUBLIC):
|
||||
$(CP) $(CPFLAGS) $(THREADS_PTHREADS_SRCDIR)$@ $@
|
||||
|
||||
$(THREADS_PTHREADS_PROGRAMS):
|
||||
$(LINK.c) $@.$(OBJSUFFIX) $(LDLIBS) $(LIBS) $(LIBRARIES) $(LIBPATHS)
|
||||
#LIBS above is obsolete (use LIBARARIES instead)
|
||||
|
||||
|
||||
|
||||
#
|
||||
# FILE DEPENDENCIES
|
||||
#
|
||||
# file dependencies state, for each file that is built,
|
||||
# which file(s) it depends upon
|
||||
#
|
||||
|
||||
pthread.$(OBJSUFFIX): $(THREADS_PTHREADS_SRCDIR)pthread.c
|
||||
|
||||
$(THREADS_PTHREADS_LIBNAME): $(THREADS_PTHREADS_OBJECTS)
|
4
common/lib/threads/targets.mk
Normal file
4
common/lib/threads/targets.mk
Normal file
|
@ -0,0 +1,4 @@
|
|||
THREADS_SRCDIR=$(COMMON_LIB_SRCDIR)threads/
|
||||
THREADS_PTHREADS_SRCDIR=$(THREADS_SRCDIR)pthreads/
|
||||
|
||||
include $(THREADS_SRCDIR)$(THREADS_TYPE)/targets.mk
|
693
config.guess
vendored
Executable file
693
config.guess
vendored
Executable file
|
@ -0,0 +1,693 @@
|
|||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Written by Per Bothner <bothner@cygnus.com>.
|
||||
# The master version of this file is at the FSF in /home/gd/gnu/lib.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit system type (host/target name).
|
||||
#
|
||||
# Only a few systems have been added to this list; please add others
|
||||
# (but try to keep the structure clean).
|
||||
#
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 8/24/94.)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
exit 0 ;;
|
||||
Amiga*:UNIX_System_V:4.0:*)
|
||||
echo m68k-cbm-sysv4
|
||||
exit 0;;
|
||||
amiga:NetBSD:*:*)
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-cbm-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
NILE:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
|
||||
exit 0 ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:NetBSD:*:*)
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-atari-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-sun-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-apple-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RISC*:Mach:*:*)
|
||||
echo mips-dec-mach_bsd4.3
|
||||
exit 0 ;;
|
||||
RISC*:ULTRIX:*:*)
|
||||
echo mips-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
VAX*:ULTRIX*:*:*)
|
||||
echo vax-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:*:*:UMIPS | mips:*:*:RISCos)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
int main (argc, argv) int argc; char **argv; {
|
||||
#if defined (host_mips) && defined (MIPSEB)
|
||||
#if defined (SYSTYPE_SYSV)
|
||||
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_SVR4)
|
||||
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
|
||||
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy \
|
||||
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
m88k:CX/UX:7*:*)
|
||||
echo m88k-harris-cxux7
|
||||
exit 0 ;;
|
||||
m88k:*:4*:R4*)
|
||||
echo m88k-motorola-sysv4
|
||||
exit 0 ;;
|
||||
m88k:*:3*:R3*)
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
|
||||
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
|
||||
echo m88k-dg-dgux${UNAME_RELEASE}
|
||||
else
|
||||
echo m88k-dg-dguxbcs${UNAME_RELEASE}
|
||||
fi
|
||||
else echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit 0 ;;
|
||||
M88*:*:R3*:*)
|
||||
# Delta 88k system running SVR3
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
|
||||
echo m88k-tektronix-sysv3
|
||||
exit 0 ;;
|
||||
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
|
||||
echo m68k-tektronix-bsd
|
||||
exit 0 ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
|
||||
exit 0 ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
i?86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit 0 ;;
|
||||
*:AIX:2:3)
|
||||
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
puts("powerpc-ibm-aix3.2.5");
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
else
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:4)
|
||||
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
else
|
||||
IBM_REV=4.${UNAME_RELEASE}
|
||||
fi
|
||||
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
|
||||
exit 0 ;;
|
||||
*:AIX:*:*)
|
||||
echo rs6000-ibm-aix
|
||||
exit 0 ;;
|
||||
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
|
||||
echo romp-ibm-bsd4.4
|
||||
exit 0 ;;
|
||||
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
|
||||
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
|
||||
exit 0 ;; # report: romp-ibm BSD 4.3
|
||||
*:BOSX:*:*)
|
||||
echo rs6000-bull-bosx
|
||||
exit 0 ;;
|
||||
DPX/2?00:B.O.S.:*:*)
|
||||
echo m68k-bull-sysv3
|
||||
exit 0 ;;
|
||||
9000/[34]??:4.3bsd:1.*:*)
|
||||
echo m68k-hp-bsd
|
||||
exit 0 ;;
|
||||
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
|
||||
echo m68k-hp-bsd4.4
|
||||
exit 0 ;;
|
||||
9000/[3478]??:HP-UX:*:*)
|
||||
case "${UNAME_MACHINE}" in
|
||||
9000/31? ) HP_ARCH=m68000 ;;
|
||||
9000/[34]?? ) HP_ARCH=m68k ;;
|
||||
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
|
||||
9000/8?? ) HP_ARCH=hppa1.0 ;;
|
||||
esac
|
||||
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
3050*:HI-UX:*:*)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
|
||||
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
|
||||
results, however. */
|
||||
if (CPU_IS_PA_RISC (cpu))
|
||||
{
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
|
||||
default: puts ("hppa-hitachi-hiuxwe2"); break;
|
||||
}
|
||||
}
|
||||
else if (CPU_IS_HP_MC68K (cpu))
|
||||
puts ("m68k-hitachi-hiuxwe2");
|
||||
else puts ("unknown-hitachi-hiuxwe2");
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
echo hppa1.1-hp-bsd
|
||||
exit 0 ;;
|
||||
9000/8??:4.3bsd:*:*)
|
||||
echo hppa1.0-hp-bsd
|
||||
exit 0 ;;
|
||||
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
|
||||
echo hppa1.1-hp-osf
|
||||
exit 0 ;;
|
||||
hp8??:OSF1:*:*)
|
||||
echo hppa1.0-hp-osf
|
||||
exit 0 ;;
|
||||
i?86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
echo ${UNAME_MACHINE}-unknown-osf1mk
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-osf1
|
||||
fi
|
||||
exit 0 ;;
|
||||
parisc*:Lites*:*:*)
|
||||
echo hppa1.1-hp-lites
|
||||
exit 0 ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY*[A-Z]90:*:*:*)
|
||||
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
|
||||
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
|
||||
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
||||
exit 0 ;;
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F300:UNIX_System_V:*:*)
|
||||
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
F301:UNIX_System_V:*:*)
|
||||
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:OpenBSD:*:*)
|
||||
echo m68k-hp-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:NetBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
exit 0 ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
|
||||
echo "powerpc-unknown-linux-gnu" ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
echo alpha-unknown-linux-gnu ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "sparc" ; then
|
||||
echo sparc-unknown-linux-gnu ; exit 0
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us
|
||||
# useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
test ! -d /usr/lib/ldscripts/. \
|
||||
&& echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
printf ("%s-pc-linux-gnu\n", argv[1]);
|
||||
#else
|
||||
printf ("%s-pc-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
fi ;;
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
|
||||
# are messed up and put the nodename in both sysname and nodename.
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
i?86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
paragon:*:*:*)
|
||||
echo i860-intel-osf1
|
||||
exit 0 ;;
|
||||
i860:*:4.*:*) # i860-SVR4
|
||||
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
|
||||
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
|
||||
else # Add other i860-SVR4 vendors below as they are discovered.
|
||||
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
|
||||
fi
|
||||
exit 0 ;;
|
||||
mini*:CTIX:SYS*5:*)
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4 && exit 0 ;;
|
||||
m68*:LynxOS:2.*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i?86:LynxOS:2.*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
echo mips-dde-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RM*:SINIX-*:*:*)
|
||||
echo mips-sni-sysv4
|
||||
exit 0 ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
echo ${UNAME_MACHINE}-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
echo hppa1.1-stratus-sysv4
|
||||
exit 0 ;;
|
||||
*:*:*:FTX*)
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
cat >dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__arm) && defined (__acorn) && defined (__unix)
|
||||
printf ("arm-acorn-riscix"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (hp300) && !defined (hpux)
|
||||
printf ("m68k-hp-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
|
||||
|
||||
# Convex versions that predate uname can use getsysinfo(1)
|
||||
|
||||
if [ -x /usr/convex/getsysinfo ]
|
||||
then
|
||||
case `getsysinfo -f cpu_type` in
|
||||
c1*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
c2*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
c34*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
c38*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
c4*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#echo '(Unable to guess system type)' 1>&2
|
||||
|
||||
exit 1
|
927
config.sub
vendored
Executable file
927
config.sub
vendored
Executable file
|
@ -0,0 +1,927 @@
|
|||
#! /bin/sh
|
||||
# Configuration validation subroutine script, version 1.1.
|
||||
# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
# If it is invalid, we print an error message on stderr and exit with code 1.
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
# that are meaningful with *any* GNU software.
|
||||
# Each package is responsible for reporting which valid configurations
|
||||
# it does not support. The user should be able to distinguish
|
||||
# a failure to support a valid configuration from a meaningless
|
||||
# configuration.
|
||||
|
||||
# The goal of this file is to map all the various variations of a given
|
||||
# machine specification into a single specification in the form:
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or in some cases, the newer four-part form:
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# It is wrong to echo any other type of specification.
|
||||
|
||||
if [ x$1 = x ]
|
||||
then
|
||||
echo Configuration name missing. 1>&2
|
||||
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
|
||||
echo "or $0 ALIAS" 1>&2
|
||||
echo where ALIAS is a recognized configuration type. 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# First pass through any local machine types.
|
||||
case $1 in
|
||||
*local*)
|
||||
echo $1
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
linux-gnu*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
then os=`echo $1 | sed 's/.*-/-/'`
|
||||
else os=; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
### Let's recognize common machines as not being operating systems so
|
||||
### that things like config.sub decstation-3100 work. We also
|
||||
### recognize some manufacturers as not being operating systems, so we
|
||||
### can provide default operating systems below.
|
||||
case $os in
|
||||
-sun*os*)
|
||||
# Prevent following clause from handling this invalid input.
|
||||
;;
|
||||
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
|
||||
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
|
||||
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco5)
|
||||
os=sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco4)
|
||||
os=-sco3.2v4
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2.[4-9]*)
|
||||
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2v[4-9]*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-isc)
|
||||
os=-isc2.2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-clix*)
|
||||
basic_machine=clipper-intergraph
|
||||
;;
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
-ptx*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-windowsnt*)
|
||||
os=`echo $os | sed -e 's/windowsnt/winnt/'`
|
||||
;;
|
||||
-psos*)
|
||||
os=-psos
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode aliases for certain CPU-COMPANY combinations.
|
||||
case $basic_machine in
|
||||
# Recognize the basic CPU types without company name.
|
||||
# Some are omitted here because they have special meanings below.
|
||||
tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
|
||||
| arme[lb] | pyramid \
|
||||
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
|
||||
| alpha | we32k | ns16k | clipper | i370 | sh \
|
||||
| powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
|
||||
| pdp11 | mips64el | mips64orion | mips64orionel \
|
||||
| sparc | sparclet | sparclite | sparc64)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i[3456]86)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
*-*-*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
|
||||
| sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
|
||||
| none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
|
||||
| hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
|
||||
| pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
|
||||
| pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
|
||||
basic_machine=m68000-att
|
||||
;;
|
||||
3b*)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
alliant | fx80)
|
||||
basic_machine=fx80-alliant
|
||||
;;
|
||||
altos | altos3068)
|
||||
basic_machine=m68k-altos
|
||||
;;
|
||||
am29k)
|
||||
basic_machine=a29k-none
|
||||
os=-bsd
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
;;
|
||||
amiga | amiga-*)
|
||||
basic_machine=m68k-cbm
|
||||
;;
|
||||
amigados)
|
||||
basic_machine=m68k-cbm
|
||||
os=-amigados
|
||||
;;
|
||||
amigaunix | amix)
|
||||
basic_machine=m68k-cbm
|
||||
os=-sysv4
|
||||
;;
|
||||
apollo68)
|
||||
basic_machine=m68k-apollo
|
||||
os=-sysv
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
;;
|
||||
balance)
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c2)
|
||||
basic_machine=c2-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c32)
|
||||
basic_machine=c32-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c34)
|
||||
basic_machine=c34-convex
|
||||
os=-bsd
|
||||
;;
|
||||
convex-c38)
|
||||
basic_machine=c38-convex
|
||||
os=-bsd
|
||||
;;
|
||||
cray | ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cray2)
|
||||
basic_machine=cray2-cray
|
||||
os=-unicos
|
||||
;;
|
||||
[ctj]90-cray)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
|
||||
basic_machine=mips-dec
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
basic_machine=m68k-motorola
|
||||
;;
|
||||
delta88)
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
;;
|
||||
dpx2* | dpx2*-bull)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv3
|
||||
;;
|
||||
ebmon29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-ebmon
|
||||
;;
|
||||
elxsi)
|
||||
basic_machine=elxsi-elxsi
|
||||
os=-bsd
|
||||
;;
|
||||
encore | umax | mmax)
|
||||
basic_machine=ns32k-encore
|
||||
;;
|
||||
fx2800)
|
||||
basic_machine=i860-alliant
|
||||
;;
|
||||
genix)
|
||||
basic_machine=ns32k-ns
|
||||
;;
|
||||
gmicro)
|
||||
basic_machine=tron-gmicro
|
||||
os=-sysv
|
||||
;;
|
||||
h3050r* | hiux*)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
h8300hms)
|
||||
basic_machine=h8300-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
harris)
|
||||
basic_machine=m88k-harris
|
||||
os=-sysv3
|
||||
;;
|
||||
hp300-*)
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp300bsd)
|
||||
basic_machine=m68k-hp
|
||||
os=-bsd
|
||||
;;
|
||||
hp300hpux)
|
||||
basic_machine=m68k-hp
|
||||
os=-hpux
|
||||
;;
|
||||
hp9k2[0-9][0-9] | hp9k31[0-9])
|
||||
basic_machine=m68000-hp
|
||||
;;
|
||||
hp9k3[2-9][0-9])
|
||||
basic_machine=m68k-hp
|
||||
;;
|
||||
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
|
||||
basic_machine=hppa1.1-hp
|
||||
;;
|
||||
hp9k8[0-9][0-9] | hp8[0-9][0-9])
|
||||
basic_machine=hppa1.0-hp
|
||||
;;
|
||||
hppa-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i[3456]86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i[3456]86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i[3456]86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i[3456]86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
iris | iris4d)
|
||||
basic_machine=mips-sgi
|
||||
case $os in
|
||||
-irix*)
|
||||
;;
|
||||
*)
|
||||
os=-irix4
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
isi68 | isi)
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
magnum | m3230)
|
||||
basic_machine=mips-mips
|
||||
os=-sysv
|
||||
;;
|
||||
merlin)
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
ncr3000)
|
||||
basic_machine=i486-ncr
|
||||
os=-sysv4
|
||||
;;
|
||||
news | news700 | news800 | news900)
|
||||
basic_machine=m68k-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news1000)
|
||||
basic_machine=m68030-sony
|
||||
os=-newsos
|
||||
;;
|
||||
news-3600 | risc-news)
|
||||
basic_machine=mips-sony
|
||||
os=-newsos
|
||||
;;
|
||||
next | m*-next )
|
||||
basic_machine=m68k-next
|
||||
case $os in
|
||||
-nextstep* )
|
||||
;;
|
||||
-ns2*)
|
||||
os=-nextstep2
|
||||
;;
|
||||
*)
|
||||
os=-nextstep3
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
nh3000)
|
||||
basic_machine=m68k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nh[45]000)
|
||||
basic_machine=m88k-harris
|
||||
os=-cxux
|
||||
;;
|
||||
nindy960)
|
||||
basic_machine=i960-intel
|
||||
os=-nindy
|
||||
;;
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
pa-hitachi)
|
||||
basic_machine=hppa1.1-hitachi
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
paragon)
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
pbb)
|
||||
basic_machine=m68k-tti
|
||||
;;
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5)
|
||||
basic_machine=i586-intel
|
||||
;;
|
||||
pentiumpro | p6)
|
||||
basic_machine=i686-intel
|
||||
;;
|
||||
pentium-* | p5-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
k5)
|
||||
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
|
||||
basic_machine=i586-amd
|
||||
;;
|
||||
nexen)
|
||||
# We don't have specific support for Nexgen yet, so just call it a Pentium
|
||||
basic_machine=i586-nexgen
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
;;
|
||||
power) basic_machine=rs6000-ibm
|
||||
;;
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
;;
|
||||
rm[46]00)
|
||||
basic_machine=mips-siemens
|
||||
;;
|
||||
rtpc | rtpc-*)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
sh)
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sps7)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv2
|
||||
;;
|
||||
spur)
|
||||
basic_machine=spur-unknown
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
;;
|
||||
sun2os3)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun2os4)
|
||||
basic_machine=m68000-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun3os3)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun3os4)
|
||||
basic_machine=m68k-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4os3)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos3
|
||||
;;
|
||||
sun4os4)
|
||||
basic_machine=sparc-sun
|
||||
os=-sunos4
|
||||
;;
|
||||
sun4sol2)
|
||||
basic_machine=sparc-sun
|
||||
os=-solaris2
|
||||
;;
|
||||
sun3 | sun3-*)
|
||||
basic_machine=m68k-sun
|
||||
;;
|
||||
sun4)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
sun386 | sun386i | roadrunner)
|
||||
basic_machine=i386-sun
|
||||
;;
|
||||
symmetry)
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
ultra3)
|
||||
basic_machine=a29k-nyu
|
||||
os=-sym1
|
||||
;;
|
||||
vaxv)
|
||||
basic_machine=vax-dec
|
||||
os=-sysv
|
||||
;;
|
||||
vms)
|
||||
basic_machine=vax-dec
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
basic_machine=i960-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks68)
|
||||
basic_machine=m68k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
vxworks29k)
|
||||
basic_machine=a29k-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
xmp)
|
||||
basic_machine=xmp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
;;
|
||||
|
||||
# Here we handle the default manufacturer of certain CPU types. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
mips)
|
||||
basic_machine=mips-mips
|
||||
;;
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
vax)
|
||||
basic_machine=vax-dec
|
||||
;;
|
||||
pdp11)
|
||||
basic_machine=pdp11-dec
|
||||
;;
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sparc)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
orion)
|
||||
basic_machine=orion-highlevel
|
||||
;;
|
||||
orion105)
|
||||
basic_machine=clipper-highlevel
|
||||
;;
|
||||
*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Here we canonicalize certain aliases for manufacturers.
|
||||
case $basic_machine in
|
||||
*-digital*)
|
||||
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
|
||||
;;
|
||||
*-commodore*)
|
||||
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode manufacturer-specific aliases for certain operating systems.
|
||||
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-solaris1 | -solaris1.*)
|
||||
os=`echo $os | sed -e 's|solaris1|sunos4|'`
|
||||
;;
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-unixware* | svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -linux-gnu* | -uxpv*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
-sunos6*)
|
||||
os=`echo $os | sed -e 's|sunos6|solaris3|'`
|
||||
;;
|
||||
-osfrose*)
|
||||
os=-osfrose
|
||||
;;
|
||||
-osf*)
|
||||
os=-osf
|
||||
;;
|
||||
-utek*)
|
||||
os=-bsd
|
||||
;;
|
||||
-dynix*)
|
||||
os=-bsd
|
||||
;;
|
||||
-acis*)
|
||||
os=-aos
|
||||