- started to rebuild source layout
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
--- linux/Documentation/Configure.help.orig Tue Jan 9 16:29:20 2001
|
||||
+++ linux/Documentation/Configure.help Fri Aug 9 14:47:14 2002
|
||||
@@ -4979,2 +4979,62 @@
|
||||
|
||||
+IP Security Protocol (IPSEC) (EXPERIMENTAL)
|
||||
+CONFIG_IPSEC
|
||||
+ This unit is experimental code.
|
||||
+ Pick 'y' for static linking, 'm' for module support or 'n' for none.
|
||||
+ This option adds support for network layer packet encryption and/or
|
||||
+ authentication with participating hosts. The standards start with:
|
||||
+ RFCs 2411, 2407 and 2401. Others are mentioned where they refer to
|
||||
+ specific features below. There are more pending which can be
|
||||
+ found at: ftp://ftp.ietf.org/internet-drafts/draft-ietf-ipsec-*.
|
||||
+ A description of each document can also be found at:
|
||||
+ http://ietf.org/ids.by.wg/ipsec.html.
|
||||
+ Their charter can be found at:
|
||||
+ http://www.ietf.org/html.charters/ipsec-charter.html
|
||||
+ Snapshots and releases of the current work can be found at:
|
||||
+ http://www.freeswan.org/
|
||||
+
|
||||
+IPSEC: IP-in-IP encapsulation
|
||||
+CONFIG_IPSEC_IPIP
|
||||
+ This option provides support for tunnel mode IPSEC. It is recommended
|
||||
+ to enable this.
|
||||
+
|
||||
+IPSEC: Authentication Header
|
||||
+CONFIG_IPSEC_AH
|
||||
+ This option provides support for the IPSEC Authentication Header
|
||||
+ (IP protocol 51) which provides packet layer sender and content
|
||||
+ authentication. It is recommended to enable this. RFC2402
|
||||
+
|
||||
+HMAC-MD5 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_MD5
|
||||
+ Provides support for authentication using the HMAC MD5
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2403
|
||||
+
|
||||
+HMAC-SHA1 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_SHA1
|
||||
+ Provides support for Authentication Header using the HMAC SHA1
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2404
|
||||
+
|
||||
+IPSEC: Encapsulating Security Payload
|
||||
+CONFIG_IPSEC_ESP
|
||||
+ This option provides support for the IPSEC Encapsulation Security
|
||||
+ Payload (IP protocol 50) which provides packet layer content
|
||||
+ hiding. It is recommended to enable this. RFC2406
|
||||
+
|
||||
+3DES algorithm
|
||||
+CONFIG_IPSEC_ENC_3DES
|
||||
+ Provides support for Encapsulation Security Payload protocol, using
|
||||
+ the triple DES encryption algorithm. RFC2451
|
||||
+
|
||||
+IPSEC Debugging Option
|
||||
+CONFIG_IPSEC_DEBUG
|
||||
+ Enables IPSEC kernel debugging. It is further controlled by the
|
||||
+ user space utility 'klipsdebug'.
|
||||
+
|
||||
+IPSEC Regression Testing option
|
||||
+CONFIG_IPSEC_REGRESS
|
||||
+ Enables IPSEC regression testing. Creates a number of switches in
|
||||
+ /proc/sys/net/ipsec which cause various failure modes in KLIPS.
|
||||
+ For more details see FreeSWAN source under
|
||||
+ testing/doc/regression_options.txt.
|
||||
+
|
||||
# need an empty line after last entry, for sed script in Configure.
|
||||
@@ -1,70 +0,0 @@
|
||||
--- /a3/kernel_sources/linux-2.2.20/Documentation/Configure.help Fri Nov 2 11:39:05 2001
|
||||
+++ linux2.2/Documentation/Configure.help Mon Jul 29 15:42:26 2002
|
||||
@@ -15237,5 +15237,66 @@
|
||||
|
||||
-#
|
||||
+
|
||||
+IP Security Protocol (IPSEC) (EXPERIMENTAL)
|
||||
+CONFIG_IPSEC
|
||||
+ This unit is experimental code.
|
||||
+ Pick 'y' for static linking, 'm' for module support or 'n' for none.
|
||||
+ This option adds support for network layer packet encryption and/or
|
||||
+ authentication with participating hosts. The standards start with:
|
||||
+ RFCs 2411, 2407 and 2401. Others are mentioned where they refer to
|
||||
+ specific features below. There are more pending which can be found
|
||||
+ at: ftp://ftp.ietf.org/internet-drafts/draft-ietf-ipsec-*.
|
||||
+ A description of each document can also be found at:
|
||||
+ http://ietf.org/ids.by.wg/ipsec.html.
|
||||
+ Their charter can be found at:
|
||||
+ http://www.ietf.org/html.charters/ipsec-charter.html
|
||||
+ Snapshots and releases of the current work can be found at:
|
||||
+ http://www.freeswan.org/
|
||||
+
|
||||
+IPSEC: IP-in-IP encapsulation
|
||||
+CONFIG_IPSEC_IPIP
|
||||
+ This option provides support for tunnel mode IPSEC. It is recommended
|
||||
+ to enable this.
|
||||
+
|
||||
+IPSEC: Authentication Header
|
||||
+CONFIG_IPSEC_AH
|
||||
+ This option provides support for the IPSEC Authentication Header
|
||||
+ (IP protocol 51) which provides packet layer sender and content
|
||||
+ authentication. It is recommended to enable this. RFC2402
|
||||
+
|
||||
+HMAC-MD5 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_MD5
|
||||
+ Provides support for authentication using the HMAC MD5
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2403
|
||||
+
|
||||
+HMAC-SHA1 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_SHA1
|
||||
+ Provides support for Authentication Header using the HMAC SHA1
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2404
|
||||
+
|
||||
+IPSEC: Encapsulating Security Payload
|
||||
+CONFIG_IPSEC_ESP
|
||||
+ This option provides support for the IPSEC Encapsulation Security
|
||||
+ Payload (IP protocol 50) which provides packet layer content
|
||||
+ hiding. It is recommended to enable this. RFC2406
|
||||
+
|
||||
+3DES algorithm
|
||||
+CONFIG_IPSEC_ENC_3DES
|
||||
+ Provides support for Encapsulation Security Payload protocol, using
|
||||
+ the triple DES encryption algorithm. RFC2451
|
||||
+
|
||||
+IPSEC Debugging Option
|
||||
+CONFIG_IPSEC_DEBUG
|
||||
+ Enables IPSEC kernel debugging. It is further controlled by the
|
||||
+ user space utility 'klipsdebug'.
|
||||
+
|
||||
+IPSEC Regression Testing option
|
||||
+CONFIG_IPSEC_REGRESS
|
||||
+ Enables IPSEC regression testing. Creates a number of switches in
|
||||
+ /proc/sys/net/ipsec which cause various failure modes in KLIPS.
|
||||
+ For more details see FreeSWAN source under
|
||||
+ testing/doc/regression_options.txt.
|
||||
+
|
||||
+#
|
||||
# A couple of things I keep forgetting:
|
||||
# capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
|
||||
# Intel, IRQ, Linux, MSDOS, NetWare, NetWinder, NFS,
|
||||
@@ -1,69 +0,0 @@
|
||||
--- linux/Documentation/Configure.help.orig Fri Dec 21 12:41:53 2001
|
||||
+++ linux/Documentation/Configure.help Mon Jul 29 16:35:32 2002
|
||||
@@ -24237,5 +24237,65 @@
|
||||
|
||||
-#
|
||||
+IP Security Protocol (IPSEC) (EXPERIMENTAL)
|
||||
+CONFIG_IPSEC
|
||||
+ This unit is experimental code.
|
||||
+ Pick 'y' for static linking, 'm' for module support or 'n' for none.
|
||||
+ This option adds support for network layer packet encryption and/or
|
||||
+ authentication with participating hosts. The standards start with:
|
||||
+ RFCs 2411, 2407 and 2401. Others are mentioned where they refer to
|
||||
+ specific features below. There are more pending which can be found
|
||||
+ at: ftp://ftp.ietf.org/internet-drafts/draft-ietf-ipsec-*.
|
||||
+ A description of each document can also be found at:
|
||||
+ http://ietf.org/ids.by.wg/ipsec.html.
|
||||
+ Their charter can be found at:
|
||||
+ http://www.ietf.org/html.charters/ipsec-charter.html
|
||||
+ Snapshots and releases of the current work can be found at:
|
||||
+ http://www.freeswan.org/
|
||||
+
|
||||
+IPSEC: IP-in-IP encapsulation
|
||||
+CONFIG_IPSEC_IPIP
|
||||
+ This option provides support for tunnel mode IPSEC. It is recommended
|
||||
+ to enable this.
|
||||
+
|
||||
+IPSEC: Authentication Header
|
||||
+CONFIG_IPSEC_AH
|
||||
+ This option provides support for the IPSEC Authentication Header
|
||||
+ (IP protocol 51) which provides packet layer sender and content
|
||||
+ authentication. It is recommended to enable this. RFC2402
|
||||
+
|
||||
+HMAC-MD5 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_MD5
|
||||
+ Provides support for authentication using the HMAC MD5
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2403
|
||||
+
|
||||
+HMAC-SHA1 algorithm
|
||||
+CONFIG_IPSEC_AUTH_HMAC_SHA1
|
||||
+ Provides support for Authentication Header using the HMAC SHA1
|
||||
+ algorithm with 96 bits of hash used as the authenticator. RFC2404
|
||||
+
|
||||
+IPSEC: Encapsulating Security Payload
|
||||
+CONFIG_IPSEC_ESP
|
||||
+ This option provides support for the IPSEC Encapsulation Security
|
||||
+ Payload (IP protocol 50) which provides packet layer content
|
||||
+ hiding. It is recommended to enable this. RFC2406
|
||||
+
|
||||
+3DES algorithm
|
||||
+CONFIG_IPSEC_ENC_3DES
|
||||
+ Provides support for Encapsulation Security Payload protocol, using
|
||||
+ the triple DES encryption algorithm. RFC2451
|
||||
+
|
||||
+IPSEC Debugging Option
|
||||
+CONFIG_IPSEC_DEBUG
|
||||
+ Enables IPSEC kernel debugging. It is further controlled by the
|
||||
+ user space utility 'klipsdebug'.
|
||||
+
|
||||
+IPSEC Regression Testing option
|
||||
+CONFIG_IPSEC_REGRESS
|
||||
+ Enables IPSEC regression testing. Creates a number of switches in
|
||||
+ /proc/sys/net/ipsec which cause various failure modes in KLIPS.
|
||||
+ For more details see FreeSWAN source under
|
||||
+ testing/doc/regression_options.txt.
|
||||
+
|
||||
+#
|
||||
# A couple of things I keep forgetting:
|
||||
# capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
|
||||
# Intel, IRQ, ISDN, Linux, MSDOS, NetWare, NetWinder,
|
||||
@@ -1,32 +0,0 @@
|
||||
# FreeS/WAN subdir makefile
|
||||
# Copyright (C) 1998-2001 Henry Spencer.
|
||||
#
|
||||
# This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# RCSID $Id: Makefile,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
|
||||
FREESWANSRCDIR=..
|
||||
#SUBDIRS=net/ipsec
|
||||
|
||||
include $(FREESWANSRCDIR)/Makefile.inc
|
||||
|
||||
def:
|
||||
@echo "Please read doc/intro.html or INSTALL before running make"
|
||||
@false
|
||||
|
||||
cleanall distclean mostlyclean realclean install programs checkprograms check clean spotless modules install_file_list:
|
||||
@true
|
||||
|
||||
# @for d in $(SUBDIRS); \
|
||||
# do \
|
||||
# (cd $$d && $(MAKE) TOPDIR=${KERNELSRC} FREESWANSRCDIR=$(FREESWANSRCDIR)/.. $@ ) || exit 1 ; \
|
||||
# done
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
*
|
||||
* RCSID $Id: README.freeswan,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*
|
||||
|
||||
****************************************
|
||||
* IPSEC for Linux, Release 2.xx series *
|
||||
****************************************
|
||||
|
||||
|
||||
|
||||
1. Files
|
||||
|
||||
The contents of linux/net/ipsec/ (see below) join the linux kernel source tree.
|
||||
as provided for higher up.
|
||||
|
||||
The programs/ directory contains the user-level utilities which you need
|
||||
to run IPSEC. See the top-level top/INSTALL to compile and install them.
|
||||
|
||||
The test/ directory contains test scripts.
|
||||
|
||||
The doc/ directory contains -- what else -- documentation.
|
||||
|
||||
1.1. Kernel files
|
||||
|
||||
The following are found in net/ipsec/:
|
||||
|
||||
Makefile The Makefile
|
||||
Config.in The configuration script for make menuconfig
|
||||
defconfig Configuration defaults for first time.
|
||||
|
||||
radij.c General-purpose radix-tree operations
|
||||
|
||||
ipcomp.c IPCOMP interface code.
|
||||
|
||||
pfkey_v2.c PF_KEYv2 socket interface code.
|
||||
pfkey_v2_parser.c PF_KEYv2 message parsing and processing code.
|
||||
|
||||
ipsec_init.c Initialization code, /proc interface.
|
||||
ipsec_radij.c Interface with the radix tree code.
|
||||
ipsec_netlink.c Interface with the netlink code.
|
||||
ipsec_xform.c Routines and structures common to transforms.
|
||||
ipsec_tunnel.c The outgoing packet processing code.
|
||||
ipsec_rcv.c The incoming packet processing code.
|
||||
ipsec_md5c.c Somewhat modified RSADSI MD5 C code.
|
||||
ipsec_sha1.c Somewhat modified Steve Reid SHA-1 C code.
|
||||
|
||||
sysctl_net_ipsec.c /proc/sys/net/ipsec/* variable definitions.
|
||||
|
||||
version.c symbolic link to project version.
|
||||
|
||||
radij.h Headers for radij.c
|
||||
|
||||
ipcomp.h Headers used by IPCOMP code.
|
||||
|
||||
ipsec_radij.h Interface with the radix tree code.
|
||||
ipsec_netlink.h Headers used by the netlink interface.
|
||||
ipsec_encap.h Headers defining encapsulation structures.
|
||||
ipsec_xform.h Transform headers.
|
||||
ipsec_tunnel.h Headers used by tunneling code.
|
||||
ipsec_ipe4.h Headers for the IP-in-IP code.
|
||||
ipsec_ah.h Headers common to AH transforms.
|
||||
ipsec_md5h.h RSADSI MD5 headers.
|
||||
ipsec_sha1.h SHA-1 headers.
|
||||
ipsec_esp.h Headers common to ESP transfroms.
|
||||
ipsec_rcv.h Headers for incoming packet processing code.
|
||||
|
||||
1.2. User-level files.
|
||||
|
||||
The following are found in utils/:
|
||||
|
||||
eroute.c Create an "extended route" source code
|
||||
spi.c Set up Security Associations source code
|
||||
spigrp.c Link SPIs together source code.
|
||||
tncfg.c Configure the tunneling features of the virtual interface
|
||||
source code
|
||||
klipsdebug.c Set/reset klips debugging features source code.
|
||||
version.c symbolic link to project version.
|
||||
|
||||
eroute.8 Create an "extended route" manual page
|
||||
spi.8 Set up Security Associations manual page
|
||||
spigrp.8 Link SPIs together manual page
|
||||
tncfg.8 Configure the tunneling features of the virtual interface
|
||||
manual page
|
||||
klipsdebug.8 Set/reset klips debugging features manual page
|
||||
|
||||
eroute.5 /proc/net/ipsec_eroute format manual page
|
||||
spi.5 /proc/net/ipsec_spi format manual page
|
||||
spigrp.5 /proc/net/ipsec_spigrp format manual page
|
||||
tncfg.5 /proc/net/ipsec_tncfg format manual page
|
||||
klipsdebug.5 /proc/net/ipsec_klipsdebug format manual page
|
||||
version.5 /proc/net/ipsec_version format manual page
|
||||
pf_key.5 /proc/net/pf_key format manual page
|
||||
|
||||
Makefile Utilities makefile.
|
||||
|
||||
*.8 Manpages for the respective utils.
|
||||
|
||||
|
||||
1.3. Test files
|
||||
|
||||
The test scripts are locate in testing/ and and documentation is found
|
||||
at doc/src/umltesting.html. Automated testing via "make check" is available
|
||||
provided that the User-Mode-Linux patches are available.
|
||||
|
||||
*
|
||||
* $Log: README.freeswan,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.11 2002/07/28 23:00:14 mcr
|
||||
* removed docs on "test" directory.
|
||||
* some slight "updates"
|
||||
*
|
||||
* Revision 1.10 2002/05/06 21:34:19 mcr
|
||||
* Moved from linux/README,v
|
||||
*
|
||||
* Revision 1.9 2002/04/24 07:36:35 mcr
|
||||
* Moved from ./klips/README,v
|
||||
*
|
||||
* Revision 1.8 2000/11/06 05:42:58 rgb
|
||||
* Updated file list (had not been done in 2 years?).
|
||||
*
|
||||
* Revision 1.7 2000/08/21 17:30:09 rgb
|
||||
* Remove any references to src/.
|
||||
*
|
||||
* Revision 1.6 1999/04/06 04:54:22 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.5 1998/11/25 04:54:34 rgb
|
||||
* Updated files section to include newer transforms and other files.
|
||||
*
|
||||
* Revision 1.4 1998/05/01 03:47:17 rgb
|
||||
* Minor cleanup of utils filenames overlooked in major overhaul.
|
||||
*
|
||||
* Revision 1.3 1998/05/01 03:40:31 rgb
|
||||
* Major overhaul.
|
||||
* Removed install/initialise section with pointers to top-level INSTALL.txt.
|
||||
* Updated filelists and providing descriptions of all files.
|
||||
* Removed usage example and moved it to doc/*_setup.txt.
|
||||
*
|
||||
* Revision 1.2 1998/04/09 03:01:13 henry
|
||||
* INSTALL.txt moves up, loses its installation instructions, and turns
|
||||
* into the klips README.
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:13 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
*
|
||||
* Revision 0.7 rgb
|
||||
* Cleaned up several transmission bugs.
|
||||
*
|
||||
* Revision 0.6 1997/09? ak
|
||||
* Hooked in esp des-md5-96.
|
||||
* Added copyrights.
|
||||
*
|
||||
* Revision 0.5 1997/06/03 04:28:46 ji
|
||||
* Added transport mode.
|
||||
* Added esp 3des-md5-96.
|
||||
*
|
||||
* Revision 0.4 1997/01/14 21:35:31 ji
|
||||
* Added new transforms.
|
||||
* Cleaned up the user-level programs.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 11:59:33 ji
|
||||
* *** empty log message ***
|
||||
*
|
||||
*
|
||||
* New in this release (0.3; works with the 2.0.24 kernel)
|
||||
*
|
||||
* > Cleaned up a fair amount of crud.
|
||||
* > Fixed truncated names of /proc/net entries.
|
||||
* > Made RCS versioning visible to the external release.
|
||||
* > Rationalized debugging facilities.
|
||||
* > Rationalized untar directory structure.
|
||||
* > Fixed non-incrementing IV in DES-CBC
|
||||
* > Cleaned up this file a bit and provided additional examples
|
||||
@@ -1,477 +0,0 @@
|
||||
#ifndef _FREESWAN_H
|
||||
/*
|
||||
* header file for FreeS/WAN library functions
|
||||
* Copyright (C) 1998, 1999, 2000 Henry Spencer.
|
||||
* Copyright (C) 1999, 2000, 2001 Richard Guy Briggs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
* License for more details.
|
||||
*
|
||||
* RCSID $Id: freeswan.h,v 1.2 2004/03/22 21:53:17 as Exp $
|
||||
*/
|
||||
#define _FREESWAN_H /* seen it, no need to see it again */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* We've just got to have some datatypes defined... And annoyingly, just
|
||||
* where we get them depends on whether we're in userland or not.
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
|
||||
# include <linux/types.h>
|
||||
# include <linux/in.h>
|
||||
|
||||
#else /* __KERNEL__ */
|
||||
|
||||
# include <stdio.h>
|
||||
# include <netinet/in.h>
|
||||
|
||||
# define uint8_t u_int8_t
|
||||
# define uint16_t u_int16_t
|
||||
# define uint32_t u_int32_t
|
||||
# define uint64_t u_int64_t
|
||||
|
||||
# define DEBUG_NO_STATIC static
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#include <freeswan/ipsec_param.h>
|
||||
|
||||
|
||||
/*
|
||||
* Grab the kernel version to see if we have NET_21, and therefore
|
||||
* IPv6. Some of this is repeated from ipsec_kversions.h. Of course,
|
||||
* we aren't really testing if the kernel has IPv6, but rather if the
|
||||
* the include files do.
|
||||
*/
|
||||
#include <linux/version.h>
|
||||
#ifndef KERNEL_VERSION
|
||||
#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
|
||||
#define NET_21
|
||||
#endif
|
||||
|
||||
#ifndef IPPROTO_COMP
|
||||
# define IPPROTO_COMP 108
|
||||
#endif /* !IPPROTO_COMP */
|
||||
|
||||
#ifndef IPPROTO_INT
|
||||
# define IPPROTO_INT 61
|
||||
#endif /* !IPPROTO_INT */
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
# define DEBUG_NO_STATIC
|
||||
#else /* CONFIG_IPSEC_DEBUG */
|
||||
# define DEBUG_NO_STATIC static
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
#ifdef CONFIG_IPSEC_NAT_TRAVERSAL /* KERNEL ifdef */
|
||||
#ifndef NAT_TRAVERSAL
|
||||
#define NAT_TRAVERSAL
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NAT_TRAVERSAL
|
||||
#define ESPINUDP_WITH_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
|
||||
#define ESPINUDP_WITH_NON_ESP 2 /* draft-ietf-ipsec-nat-t-ike-02 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Basic data types for the address-handling functions.
|
||||
* ip_address and ip_subnet are supposed to be opaque types; do not
|
||||
* use their definitions directly, they are subject to change!
|
||||
*/
|
||||
|
||||
/* first, some quick fakes in case we're on an old system with no IPv6 */
|
||||
#ifndef s6_addr16
|
||||
struct in6_addr {
|
||||
union
|
||||
{
|
||||
__u8 u6_addr8[16];
|
||||
__u16 u6_addr16[8];
|
||||
__u32 u6_addr32[4];
|
||||
} in6_u;
|
||||
#define s6_addr in6_u.u6_addr8
|
||||
#define s6_addr16 in6_u.u6_addr16
|
||||
#define s6_addr32 in6_u.u6_addr32
|
||||
};
|
||||
struct sockaddr_in6 {
|
||||
unsigned short int sin6_family; /* AF_INET6 */
|
||||
__u16 sin6_port; /* Transport layer port # */
|
||||
__u32 sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
__u32 sin6_scope_id; /* scope id (new in RFC2553) */
|
||||
};
|
||||
#endif /* !s6_addr16 */
|
||||
|
||||
/* then the main types */
|
||||
typedef struct {
|
||||
union {
|
||||
struct sockaddr_in v4;
|
||||
struct sockaddr_in6 v6;
|
||||
} u;
|
||||
} ip_address;
|
||||
typedef struct {
|
||||
ip_address addr;
|
||||
int maskbits;
|
||||
} ip_subnet;
|
||||
|
||||
/* and the SA ID stuff */
|
||||
#ifdef __KERNEL__
|
||||
typedef __u32 ipsec_spi_t;
|
||||
#else
|
||||
typedef u_int32_t ipsec_spi_t;
|
||||
#endif
|
||||
typedef struct { /* to identify an SA, we need: */
|
||||
ip_address dst; /* A. destination host */
|
||||
ipsec_spi_t spi; /* B. 32-bit SPI, assigned by dest. host */
|
||||
# define SPI_PASS 256 /* magic values... */
|
||||
# define SPI_DROP 257 /* ...for use... */
|
||||
# define SPI_REJECT 258 /* ...with SA_INT */
|
||||
# define SPI_HOLD 259
|
||||
# define SPI_TRAP 260
|
||||
# define SPI_TRAPSUBNET 261
|
||||
int proto; /* C. protocol */
|
||||
# define SA_ESP 50 /* IPPROTO_ESP */
|
||||
# define SA_AH 51 /* IPPROTO_AH */
|
||||
# define SA_IPIP 4 /* IPPROTO_IPIP */
|
||||
# define SA_COMP 108 /* IPPROTO_COMP */
|
||||
# define SA_INT 61 /* IANA reserved for internal use */
|
||||
} ip_said;
|
||||
struct sa_id { /* old v4-only version */
|
||||
struct in_addr dst;
|
||||
ipsec_spi_t spi;
|
||||
int proto;
|
||||
};
|
||||
|
||||
/* misc */
|
||||
typedef const char *err_t; /* error message, or NULL for success */
|
||||
struct prng { /* pseudo-random-number-generator guts */
|
||||
unsigned char sbox[256];
|
||||
int i, j;
|
||||
unsigned long count;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* definitions for user space, taken from freeswan/ipsec_sa.h
|
||||
*/
|
||||
typedef uint32_t IPsecSAref_t;
|
||||
|
||||
#define IPSEC_SA_REF_FIELD_WIDTH (8 * sizeof(IPsecSAref_t))
|
||||
|
||||
#define IPsecSAref2NFmark(x) ((x) << (IPSEC_SA_REF_FIELD_WIDTH - IPSEC_SA_REF_TABLE_IDX_WIDTH))
|
||||
#define NFmark2IPsecSAref(x) ((x) >> (IPSEC_SA_REF_FIELD_WIDTH - IPSEC_SA_REF_TABLE_IDX_WIDTH))
|
||||
|
||||
#define IPSEC_SAREF_NULL (~((IPsecSAref_t)0))
|
||||
|
||||
/* GCC magic for use in function definitions! */
|
||||
#ifdef GCC_LINT
|
||||
# define PRINTF_LIKE(n) __attribute__ ((format(printf, n, n+1)))
|
||||
# define NEVER_RETURNS __attribute__ ((noreturn))
|
||||
# define UNUSED __attribute__ ((unused))
|
||||
# define BLANK_FORMAT " " /* GCC_LINT whines about empty formats */
|
||||
#else
|
||||
# define PRINTF_LIKE(n) /* ignore */
|
||||
# define NEVER_RETURNS /* ignore */
|
||||
# define UNUSED /* ignore */
|
||||
# define BLANK_FORMAT ""
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* new IPv6-compatible functions
|
||||
*/
|
||||
|
||||
/* text conversions */
|
||||
err_t ttoul(const char *src, size_t srclen, int format, unsigned long *dst);
|
||||
size_t ultot(unsigned long src, int format, char *buf, size_t buflen);
|
||||
#define ULTOT_BUF (22+1) /* holds 64 bits in octal */
|
||||
err_t ttoaddr(const char *src, size_t srclen, int af, ip_address *dst);
|
||||
err_t tnatoaddr(const char *src, size_t srclen, int af, ip_address *dst);
|
||||
size_t addrtot(const ip_address *src, int format, char *buf, size_t buflen);
|
||||
/* RFC 1886 old IPv6 reverse-lookup format is the bulkiest */
|
||||
#define ADDRTOT_BUF (32*2 + 3 + 1 + 3 + 1 + 1)
|
||||
err_t ttosubnet(const char *src, size_t srclen, int af, ip_subnet *dst);
|
||||
size_t subnettot(const ip_subnet *src, int format, char *buf, size_t buflen);
|
||||
#define SUBNETTOT_BUF (ADDRTOT_BUF + 1 + 3)
|
||||
err_t ttosa(const char *src, size_t srclen, ip_said *dst);
|
||||
size_t satot(const ip_said *src, int format, char *bufptr, size_t buflen);
|
||||
#define SATOT_BUF (5 + ULTOA_BUF + 1 + ADDRTOT_BUF)
|
||||
err_t ttodata(const char *src, size_t srclen, int base, char *buf,
|
||||
size_t buflen, size_t *needed);
|
||||
err_t ttodatav(const char *src, size_t srclen, int base,
|
||||
char *buf, size_t buflen, size_t *needed,
|
||||
char *errp, size_t errlen, unsigned int flags);
|
||||
#define TTODATAV_BUF 40 /* ttodatav's largest non-literal message */
|
||||
#define TTODATAV_IGNORESPACE (1<<1) /* ignore spaces in base64 encodings*/
|
||||
#define TTODATAV_SPACECOUNTS 0 /* do not ignore spaces in base64 */
|
||||
|
||||
size_t datatot(const char *src, size_t srclen, int format, char *buf,
|
||||
size_t buflen);
|
||||
size_t keyblobtoid(const unsigned char *src, size_t srclen, char *dst,
|
||||
size_t dstlen);
|
||||
size_t splitkeytoid(const unsigned char *e, size_t elen, const unsigned char *m,
|
||||
size_t mlen, char *dst, size_t dstlen);
|
||||
#define KEYID_BUF 10 /* up to 9 text digits plus NUL */
|
||||
err_t ttoprotoport(char *src, size_t src_len, u_int8_t *proto, u_int16_t *port,
|
||||
int *has_port_wildcard);
|
||||
|
||||
/* initializations */
|
||||
void initsaid(const ip_address *addr, ipsec_spi_t spi, int proto, ip_said *dst);
|
||||
err_t loopbackaddr(int af, ip_address *dst);
|
||||
err_t unspecaddr(int af, ip_address *dst);
|
||||
err_t anyaddr(int af, ip_address *dst);
|
||||
err_t initaddr(const unsigned char *src, size_t srclen, int af, ip_address *dst);
|
||||
err_t initsubnet(const ip_address *addr, int maskbits, int clash, ip_subnet *dst);
|
||||
err_t addrtosubnet(const ip_address *addr, ip_subnet *dst);
|
||||
|
||||
/* misc. conversions and related */
|
||||
err_t rangetosubnet(const ip_address *from, const ip_address *to, ip_subnet *dst);
|
||||
int addrtypeof(const ip_address *src);
|
||||
int subnettypeof(const ip_subnet *src);
|
||||
size_t addrlenof(const ip_address *src);
|
||||
size_t addrbytesptr(const ip_address *src, const unsigned char **dst);
|
||||
size_t addrbytesof(const ip_address *src, unsigned char *dst, size_t dstlen);
|
||||
int masktocount(const ip_address *src);
|
||||
void networkof(const ip_subnet *src, ip_address *dst);
|
||||
void maskof(const ip_subnet *src, ip_address *dst);
|
||||
|
||||
/* tests */
|
||||
int sameaddr(const ip_address *a, const ip_address *b);
|
||||
int addrcmp(const ip_address *a, const ip_address *b);
|
||||
int samesubnet(const ip_subnet *a, const ip_subnet *b);
|
||||
int addrinsubnet(const ip_address *a, const ip_subnet *s);
|
||||
int subnetinsubnet(const ip_subnet *a, const ip_subnet *b);
|
||||
int subnetishost(const ip_subnet *s);
|
||||
int samesaid(const ip_said *a, const ip_said *b);
|
||||
int sameaddrtype(const ip_address *a, const ip_address *b);
|
||||
int samesubnettype(const ip_subnet *a, const ip_subnet *b);
|
||||
int isanyaddr(const ip_address *src);
|
||||
int isunspecaddr(const ip_address *src);
|
||||
int isloopbackaddr(const ip_address *src);
|
||||
|
||||
/* low-level grot */
|
||||
int portof(const ip_address *src);
|
||||
void setportof(int port, ip_address *dst);
|
||||
struct sockaddr *sockaddrof(ip_address *src);
|
||||
size_t sockaddrlenof(const ip_address *src);
|
||||
|
||||
/* PRNG */
|
||||
void prng_init(struct prng *prng, const unsigned char *key, size_t keylen);
|
||||
void prng_bytes(struct prng *prng, unsigned char *dst, size_t dstlen);
|
||||
unsigned long prng_count(struct prng *prng);
|
||||
void prng_final(struct prng *prng);
|
||||
|
||||
/* odds and ends */
|
||||
const char *ipsec_version_code(void);
|
||||
const char *ipsec_version_string(void);
|
||||
const char **ipsec_copyright_notice(void);
|
||||
|
||||
const char *dns_string_rr(int rr, char *buf, int bufsize);
|
||||
const char *dns_string_datetime(time_t seconds,
|
||||
char *buf,
|
||||
int bufsize);
|
||||
|
||||
|
||||
/*
|
||||
* old functions, to be deleted eventually
|
||||
*/
|
||||
|
||||
/* unsigned long */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atoul(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
int base, /* 0 means figure it out */
|
||||
unsigned long *resultp
|
||||
);
|
||||
size_t /* space needed for full conversion */
|
||||
ultoa(
|
||||
unsigned long n,
|
||||
int base,
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
#define ULTOA_BUF 21 /* just large enough for largest result, */
|
||||
/* assuming 64-bit unsigned long! */
|
||||
|
||||
/* Internet addresses */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atoaddr(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
struct in_addr *addr
|
||||
);
|
||||
size_t /* space needed for full conversion */
|
||||
addrtoa(
|
||||
struct in_addr addr,
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
#define ADDRTOA_BUF 16 /* just large enough for largest result */
|
||||
|
||||
/* subnets */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atosubnet(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
struct in_addr *addr,
|
||||
struct in_addr *mask
|
||||
);
|
||||
size_t /* space needed for full conversion */
|
||||
subnettoa(
|
||||
struct in_addr addr,
|
||||
struct in_addr mask,
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
#define SUBNETTOA_BUF 32 /* large enough for worst case result */
|
||||
|
||||
/* ranges */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atoasr(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
char *type, /* 'a', 's', 'r' */
|
||||
struct in_addr *addrs /* two-element array */
|
||||
);
|
||||
size_t /* space needed for full conversion */
|
||||
rangetoa(
|
||||
struct in_addr *addrs, /* two-element array */
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
#define RANGETOA_BUF 34 /* large enough for worst case result */
|
||||
|
||||
/* data types for SA conversion functions */
|
||||
|
||||
/* SAs */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atosa(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
struct sa_id *sa
|
||||
);
|
||||
size_t /* space needed for full conversion */
|
||||
satoa(
|
||||
struct sa_id sa,
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
#define SATOA_BUF (3+ULTOA_BUF+ADDRTOA_BUF)
|
||||
|
||||
/* generic data, e.g. keys */
|
||||
const char * /* NULL for success, else string literal */
|
||||
atobytes(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
char *dst,
|
||||
size_t dstlen,
|
||||
size_t *lenp /* NULL means don't bother telling me */
|
||||
);
|
||||
size_t /* 0 failure, else true size */
|
||||
bytestoa(
|
||||
const char *src,
|
||||
size_t srclen,
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
|
||||
/* old versions of generic-data functions; deprecated */
|
||||
size_t /* 0 failure, else true size */
|
||||
atodata(
|
||||
const char *src,
|
||||
size_t srclen, /* 0 means strlen(src) */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
size_t /* 0 failure, else true size */
|
||||
datatoa(
|
||||
const char *src,
|
||||
size_t srclen,
|
||||
int format, /* character; 0 means default */
|
||||
char *dst,
|
||||
size_t dstlen
|
||||
);
|
||||
|
||||
/* part extraction and special addresses */
|
||||
struct in_addr
|
||||
subnetof(
|
||||
struct in_addr addr,
|
||||
struct in_addr mask
|
||||
);
|
||||
struct in_addr
|
||||
hostof(
|
||||
struct in_addr addr,
|
||||
struct in_addr mask
|
||||
);
|
||||
struct in_addr
|
||||
broadcastof(
|
||||
struct in_addr addr,
|
||||
struct in_addr mask
|
||||
);
|
||||
|
||||
/* mask handling */
|
||||
int
|
||||
goodmask(
|
||||
struct in_addr mask
|
||||
);
|
||||
int
|
||||
masktobits(
|
||||
struct in_addr mask
|
||||
);
|
||||
struct in_addr
|
||||
bitstomask(
|
||||
int n
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* general utilities
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/* option pickup from files (userland only because of use of FILE) */
|
||||
const char *optionsfrom(const char *filename, int *argcp, char ***argvp,
|
||||
int optind, FILE *errorreport);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Debugging levels for pfkey_lib_debug
|
||||
*/
|
||||
#define PF_KEY_DEBUG_PARSE_NONE 0
|
||||
#define PF_KEY_DEBUG_PARSE_PROBLEM 1
|
||||
#define PF_KEY_DEBUG_PARSE_STRUCT 2
|
||||
#define PF_KEY_DEBUG_PARSE_FLOW 4
|
||||
#define PF_KEY_DEBUG_PARSE_MAX 7
|
||||
|
||||
extern unsigned int pfkey_lib_debug; /* bits selecting what to report */
|
||||
|
||||
/*
|
||||
* pluto and lwdnsq need to know the maximum size of the commands to,
|
||||
* and replies from lwdnsq.
|
||||
*/
|
||||
|
||||
#define LWDNSQ_CMDBUF_LEN 1024
|
||||
#define LWDNSQ_RESULT_LEN_MAX 4096
|
||||
|
||||
#endif /* _FREESWAN_H */
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* IPCOMP zlib interface code.
|
||||
* Copyright (C) 2000 Svenning Soerensen <[email protected]>
|
||||
* Copyright (C) 2000, 2001 Richard Guy Briggs <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
|
||||
RCSID $Id: ipcomp.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
|
||||
*/
|
||||
|
||||
/* SSS */
|
||||
|
||||
#ifndef _IPCOMP_H
|
||||
#define _IPCOMP_H
|
||||
|
||||
/* Prefix all global deflate symbols with "ipcomp_" to avoid collisions with ppp_deflate & ext2comp */
|
||||
#ifndef IPCOMP_PREFIX
|
||||
#define IPCOMP_PREFIX
|
||||
#endif /* IPCOMP_PREFIX */
|
||||
|
||||
#ifndef IPPROTO_COMP
|
||||
#define IPPROTO_COMP 108
|
||||
#endif /* IPPROTO_COMP */
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int sysctl_ipsec_debug_ipcomp;
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
struct ipcomphdr { /* IPCOMP header */
|
||||
__u8 ipcomp_nh; /* Next header (protocol) */
|
||||
__u8 ipcomp_flags; /* Reserved, must be 0 */
|
||||
__u16 ipcomp_cpi; /* Compression Parameter Index */
|
||||
};
|
||||
|
||||
extern struct inet_protocol comp_protocol;
|
||||
extern int sysctl_ipsec_debug_ipcomp;
|
||||
|
||||
#define IPCOMP_UNCOMPRESSABLE 0x000000001
|
||||
#define IPCOMP_COMPRESSIONERROR 0x000000002
|
||||
#define IPCOMP_PARMERROR 0x000000004
|
||||
#define IPCOMP_DECOMPRESSIONERROR 0x000000008
|
||||
|
||||
#define IPCOMP_ADAPT_INITIAL_TRIES 8
|
||||
#define IPCOMP_ADAPT_INITIAL_SKIP 4
|
||||
#define IPCOMP_ADAPT_SUBSEQ_TRIES 2
|
||||
#define IPCOMP_ADAPT_SUBSEQ_SKIP 8
|
||||
|
||||
/* Function prototypes */
|
||||
struct sk_buff *skb_compress(struct sk_buff *skb, struct ipsec_sa *ips, unsigned int *flags);
|
||||
struct sk_buff *skb_decompress(struct sk_buff *skb, struct ipsec_sa *ips, unsigned int *flags);
|
||||
|
||||
#endif /* _IPCOMP_H */
|
||||
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
* Authentication Header declarations
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_ah.h,v 1.2 2004/03/22 21:53:18 as Exp $
|
||||
*/
|
||||
|
||||
#include "ipsec_md5h.h"
|
||||
#include "ipsec_sha1.h"
|
||||
|
||||
#ifndef IPPROTO_AH
|
||||
#define IPPROTO_AH 51
|
||||
#endif /* IPPROTO_AH */
|
||||
|
||||
#define AH_FLENGTH 12 /* size of fixed part */
|
||||
#define AHMD5_KMAX 64 /* MD5 max 512 bits key */
|
||||
#define AHMD5_AMAX 12 /* MD5 96 bits of authenticator */
|
||||
|
||||
#define AHMD596_KLEN 16 /* MD5 128 bits key */
|
||||
#define AHSHA196_KLEN 20 /* SHA1 160 bits key */
|
||||
|
||||
#define AHMD596_ALEN 16 /* MD5 128 bits authentication length */
|
||||
#define AHSHA196_ALEN 20 /* SHA1 160 bits authentication length */
|
||||
|
||||
#define AHMD596_BLKLEN 64 /* MD5 block length */
|
||||
#define AHSHA196_BLKLEN 64 /* SHA1 block length */
|
||||
#define AHSHA2_256_BLKLEN 64 /* SHA2-256 block length */
|
||||
#define AHSHA2_384_BLKLEN 128 /* SHA2-384 block length (?) */
|
||||
#define AHSHA2_512_BLKLEN 128 /* SHA2-512 block length */
|
||||
|
||||
#define AH_BLKLEN_MAX 128 /* keep up to date! */
|
||||
|
||||
#define AH_AMAX AHSHA196_ALEN /* keep up to date! */
|
||||
#define AHHMAC_HASHLEN 12 /* authenticator length of 96bits */
|
||||
#define AHHMAC_RPLLEN 4 /* 32 bit replay counter */
|
||||
|
||||
#define DB_AH_PKTRX 0x0001
|
||||
#define DB_AH_PKTRX2 0x0002
|
||||
#define DB_AH_DMP 0x0004
|
||||
#define DB_AH_IPSA 0x0010
|
||||
#define DB_AH_XF 0x0020
|
||||
#define DB_AH_INAU 0x0040
|
||||
#define DB_AH_REPLAY 0x0100
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* General HMAC algorithm is described in RFC 2104 */
|
||||
|
||||
#define HMAC_IPAD 0x36
|
||||
#define HMAC_OPAD 0x5C
|
||||
|
||||
struct md5_ctx {
|
||||
MD5_CTX ictx; /* context after H(K XOR ipad) */
|
||||
MD5_CTX octx; /* context after H(K XOR opad) */
|
||||
};
|
||||
|
||||
struct sha1_ctx {
|
||||
SHA1_CTX ictx; /* context after H(K XOR ipad) */
|
||||
SHA1_CTX octx; /* context after H(K XOR opad) */
|
||||
};
|
||||
|
||||
struct auth_alg {
|
||||
void (*init)(void *ctx);
|
||||
void (*update)(void *ctx, unsigned char *bytes, __u32 len);
|
||||
void (*final)(unsigned char *hash, void *ctx);
|
||||
int hashlen;
|
||||
};
|
||||
|
||||
extern struct inet_protocol ah_protocol;
|
||||
|
||||
struct options;
|
||||
|
||||
extern int
|
||||
ah_rcv(struct sk_buff *skb,
|
||||
struct device *dev,
|
||||
struct options *opt,
|
||||
__u32 daddr,
|
||||
unsigned short len,
|
||||
__u32 saddr,
|
||||
int redo,
|
||||
struct inet_protocol *protocol);
|
||||
|
||||
struct ahhdr /* Generic AH header */
|
||||
{
|
||||
__u8 ah_nh; /* Next header (protocol) */
|
||||
__u8 ah_hl; /* AH length, in 32-bit words */
|
||||
__u16 ah_rv; /* reserved, must be 0 */
|
||||
__u32 ah_spi; /* Security Parameters Index */
|
||||
__u32 ah_rpl; /* Replay prevention */
|
||||
__u8 ah_data[AHHMAC_HASHLEN];/* Authentication hash */
|
||||
};
|
||||
#define AH_BASIC_LEN 8 /* basic AH header is 8 bytes, nh,hl,rv,spi
|
||||
* and the ah_hl, says how many bytes after that
|
||||
* to cover. */
|
||||
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int debug_ah;
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_ah.h,v $
|
||||
* Revision 1.2 2004/03/22 21:53:18 as
|
||||
* merged alg-0.8.1 branch with HEAD
|
||||
*
|
||||
* Revision 1.1.4.1 2004/03/16 09:48:18 as
|
||||
* alg-0.8.1rc12 patch merged
|
||||
*
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.20 2003/02/06 02:21:34 rgb
|
||||
*
|
||||
* Moved "struct auth_alg" from ipsec_rcv.c to ipsec_ah.h .
|
||||
* Changed "struct ah" to "struct ahhdr" and "struct esp" to "struct esphdr".
|
||||
* Removed "#ifdef INBOUND_POLICY_CHECK_eroute" dead code.
|
||||
*
|
||||
* Revision 1.19 2002/09/16 21:19:13 mcr
|
||||
* fixes for west-ah-icmp-01 - length of AH header must be
|
||||
* calculated properly, and next_header field properly copied.
|
||||
*
|
||||
* Revision 1.18 2002/05/14 02:37:02 rgb
|
||||
* Change reference from _TDB to _IPSA.
|
||||
*
|
||||
* Revision 1.17 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_ah.h,v
|
||||
*
|
||||
* Revision 1.16 2002/02/20 01:27:06 rgb
|
||||
* Ditched a pile of structs only used by the old Netlink interface.
|
||||
*
|
||||
* Revision 1.15 2001/12/11 02:35:57 rgb
|
||||
* Change "struct net_device" to "struct device" for 2.2 compatibility.
|
||||
*
|
||||
* Revision 1.14 2001/11/26 09:23:47 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.13.2.1 2001/09/25 02:18:24 mcr
|
||||
* replace "struct device" with "struct netdevice"
|
||||
*
|
||||
* Revision 1.13 2001/06/14 19:35:08 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.12 2000/09/12 03:21:20 rgb
|
||||
* Cleared out unused htonq.
|
||||
*
|
||||
* Revision 1.11 2000/09/08 19:12:55 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.10 2000/01/21 06:13:10 rgb
|
||||
* Tidied up spacing.
|
||||
* Added macros for HMAC padding magic numbers.(kravietz)
|
||||
*
|
||||
* Revision 1.9 1999/12/07 18:16:23 rgb
|
||||
* Fixed comments at end of #endif lines.
|
||||
*
|
||||
* Revision 1.8 1999/04/11 00:28:56 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.7 1999/04/06 04:54:25 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.6 1999/01/26 02:06:01 rgb
|
||||
* Removed CONFIG_IPSEC_ALGO_SWITCH macro.
|
||||
*
|
||||
* Revision 1.5 1999/01/22 06:17:49 rgb
|
||||
* Updated macro comments.
|
||||
* Added context types to support algorithm switch code.
|
||||
* 64-bit clean-up -- converting 'u long long' to __u64.
|
||||
*
|
||||
* Revision 1.4 1998/07/14 15:54:56 rgb
|
||||
* Add #ifdef __KERNEL__ to protect kernel-only structures.
|
||||
*
|
||||
* Revision 1.3 1998/06/30 18:05:16 rgb
|
||||
* Comment out references to htonq.
|
||||
*
|
||||
* Revision 1.2 1998/06/25 19:33:46 rgb
|
||||
* Add prototype for protocol receive function.
|
||||
* Rearrange for more logical layout.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:43 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.4 1998/05/18 22:28:43 rgb
|
||||
* Disable key printing facilities from /proc/net/ipsec_*.
|
||||
*
|
||||
* Revision 1.3 1998/04/21 21:29:07 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.2 1998/04/12 22:03:17 rgb
|
||||
* Updated ESP-3DES-HMAC-MD5-96,
|
||||
* ESP-DES-HMAC-MD5-96,
|
||||
* AH-HMAC-MD5-96,
|
||||
* AH-HMAC-SHA1-96 since Henry started freeswan cvs repository
|
||||
* from old standards (RFC182[5-9] to new (as of March 1998) drafts.
|
||||
*
|
||||
* Fixed eroute references in /proc/net/ipsec*.
|
||||
*
|
||||
* Started to patch module unloading memory leaks in ipsec_netlink and
|
||||
* radij tree unloading.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:05:55 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:02 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* Added definitions for new AH transforms.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:35:48 ji
|
||||
* Minor Cleanup.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Modular extensions service and registration functions interface
|
||||
*
|
||||
* Author: JuanJo Ciarlante <[email protected]>
|
||||
*
|
||||
* $Id: ipsec_alg.h,v 1.2 2004/03/22 21:53:18 as Exp $
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef IPSEC_ALG_H
|
||||
#define IPSEC_ALG_H
|
||||
|
||||
/*
|
||||
* gcc >= 3.2 has removed __FUNCTION__, replaced by C99 __func__
|
||||
* *BUT* its a compiler variable.
|
||||
*/
|
||||
#if (__GNUC__ >= 3)
|
||||
#ifndef __FUNCTION__
|
||||
#define __FUNCTION__ __func__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Version 0.8.1-0 */
|
||||
#define IPSEC_ALG_VERSION 0x00080100
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/list.h>
|
||||
#include <asm/atomic.h>
|
||||
/*
|
||||
* The following structs are used via pointers in ipsec_alg object to
|
||||
* avoid ipsec_alg.h coupling with freeswan headers, thus simplifying
|
||||
* module development
|
||||
*/
|
||||
struct ipsec_sa;
|
||||
struct esp;
|
||||
|
||||
/**************************************
|
||||
*
|
||||
* Main registration object
|
||||
*
|
||||
*************************************/
|
||||
#define IPSEC_ALG_VERSION_QUAD(v) \
|
||||
(v>>24),((v>>16)&0xff),((v>>8)&0xff),(v&0xff)
|
||||
/*
|
||||
* Main ipsec_alg objects: "OOPrograming wannabe"
|
||||
* Hierachy (carefully handled with _minimal_ cast'ing):
|
||||
*
|
||||
* ipsec_alg+
|
||||
* +->ipsec_alg_enc (ixt_alg_type=SADB_EXT_SUPPORTED_ENCRYPT)
|
||||
* +->ipsec_alg_auth (ixt_alg_type=SADB_EXT_SUPPORTED_AUTH)
|
||||
*/
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* INTERFACE object: struct ipsec_alg
|
||||
*
|
||||
***************************************************************/
|
||||
|
||||
/*
|
||||
* common part for every struct ipsec_alg_*
|
||||
* (sortof poor's man OOP)
|
||||
*/
|
||||
#define IPSEC_ALG_STRUCT_COMMON \
|
||||
unsigned ixt_version; /* only allow this version (or 'near')*/ \
|
||||
struct list_head ixt_list; /* dlinked list */ \
|
||||
struct module *ixt_module; /* THIS_MODULE */ \
|
||||
unsigned ixt_state; /* state flags */ \
|
||||
atomic_t ixt_refcnt; /* ref. count when pointed from ipsec_sa */ \
|
||||
char ixt_name[16]; /* descriptive short name, eg. "3des" */ \
|
||||
void *ixt_data; /* private for algo implementation */ \
|
||||
uint8_t ixt_blocksize; /* blocksize in bytes */ \
|
||||
\
|
||||
/* THIS IS A COPY of struct supported (lib/pfkey.h) \
|
||||
* please keep in sync until we migrate 'supported' stuff \
|
||||
* to ipsec_alg \
|
||||
*/ \
|
||||
uint16_t ixt_alg_type; /* correspond to IPSEC_ALG_{ENCRYPT,AUTH} */ \
|
||||
uint8_t ixt_alg_id; /* enc. alg. number, eg. ESP_3DES */ \
|
||||
uint8_t ixt_ivlen; /* ivlen in bits, expected to be multiple of 8! */ \
|
||||
uint16_t ixt_keyminbits;/* min. keybits (of entropy) */ \
|
||||
uint16_t ixt_keymaxbits;/* max. keybits (of entropy) */
|
||||
|
||||
#define ixt_support ixt_alg_type
|
||||
|
||||
#define IPSEC_ALG_ST_SUPP 0x01
|
||||
#define IPSEC_ALG_ST_REGISTERED 0x02
|
||||
#define IPSEC_ALG_ST_EXCL 0x04
|
||||
struct ipsec_alg {
|
||||
IPSEC_ALG_STRUCT_COMMON
|
||||
};
|
||||
/*
|
||||
* Note the const in cbc_encrypt IV arg:
|
||||
* some ciphers like to toast passed IV (eg. 3DES): make a local IV copy
|
||||
*/
|
||||
struct ipsec_alg_enc {
|
||||
IPSEC_ALG_STRUCT_COMMON
|
||||
unsigned ixt_e_keylen; /* raw key length in bytes */
|
||||
unsigned ixt_e_ctx_size; /* sa_p->key_e_size */
|
||||
int (*ixt_e_set_key)(struct ipsec_alg_enc *alg, __u8 *key_e, const __u8 *key, size_t keysize);
|
||||
__u8 *(*ixt_e_new_key)(struct ipsec_alg_enc *alg, const __u8 *key, size_t keysize);
|
||||
void (*ixt_e_destroy_key)(struct ipsec_alg_enc *alg, __u8 *key_e);
|
||||
int (*ixt_e_cbc_encrypt)(struct ipsec_alg_enc *alg, __u8 *key_e, __u8 *in, int ilen, const __u8 *iv, int encrypt);
|
||||
};
|
||||
struct ipsec_alg_auth {
|
||||
IPSEC_ALG_STRUCT_COMMON
|
||||
unsigned ixt_a_keylen; /* raw key length in bytes */
|
||||
unsigned ixt_a_ctx_size; /* sa_p->key_a_size */
|
||||
unsigned ixt_a_authlen; /* 'natural' auth. hash len (bytes) */
|
||||
int (*ixt_a_hmac_set_key)(struct ipsec_alg_auth *alg, __u8 *key_a, const __u8 *key, int keylen);
|
||||
int (*ixt_a_hmac_hash)(struct ipsec_alg_auth *alg, __u8 *key_a, const __u8 *dat, int len, __u8 *hash, int hashlen);
|
||||
};
|
||||
/*
|
||||
* These are _copies_ of SADB_EXT_SUPPORTED_{AUTH,ENCRYPT},
|
||||
* to avoid header coupling for true constants
|
||||
* about headers ... "cp is your friend" --Linus
|
||||
*/
|
||||
#define IPSEC_ALG_TYPE_AUTH 14
|
||||
#define IPSEC_ALG_TYPE_ENCRYPT 15
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* INTERFACE for module loading,testing, and unloading
|
||||
*
|
||||
***************************************************************/
|
||||
/* - registration calls */
|
||||
int register_ipsec_alg(struct ipsec_alg *);
|
||||
int unregister_ipsec_alg(struct ipsec_alg *);
|
||||
/* - optional (simple test) for algos */
|
||||
int ipsec_alg_test(unsigned alg_type, unsigned alg_id, int testparm);
|
||||
/* inline wrappers (usefull for type validation */
|
||||
static inline int register_ipsec_alg_enc(struct ipsec_alg_enc *ixt) {
|
||||
return register_ipsec_alg((struct ipsec_alg*)ixt);
|
||||
}
|
||||
static inline int unregister_ipsec_alg_enc(struct ipsec_alg_enc *ixt) {
|
||||
return unregister_ipsec_alg((struct ipsec_alg*)ixt);
|
||||
}
|
||||
static inline int register_ipsec_alg_auth(struct ipsec_alg_auth *ixt) {
|
||||
return register_ipsec_alg((struct ipsec_alg*)ixt);
|
||||
}
|
||||
static inline int unregister_ipsec_alg_auth(struct ipsec_alg_auth *ixt) {
|
||||
return unregister_ipsec_alg((struct ipsec_alg*)ixt);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* INTERFACE for ENC services: key creation, encrypt function
|
||||
*
|
||||
*****************************************************************/
|
||||
|
||||
#define IPSEC_ALG_ENCRYPT 1
|
||||
#define IPSEC_ALG_DECRYPT 0
|
||||
|
||||
/* encryption key context creation function */
|
||||
int ipsec_alg_enc_key_create(struct ipsec_sa *sa_p);
|
||||
/*
|
||||
* ipsec_alg_esp_encrypt(): encrypt ilen bytes in idat returns
|
||||
* 0 or ERR<0
|
||||
*/
|
||||
int ipsec_alg_esp_encrypt(struct ipsec_sa *sa_p, __u8 *idat, int ilen, const __u8 *iv, int action);
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* INTERFACE for AUTH services: key creation, hash functions
|
||||
*
|
||||
***************************************************************/
|
||||
int ipsec_alg_auth_key_create(struct ipsec_sa *sa_p);
|
||||
int ipsec_alg_sa_esp_hash(const struct ipsec_sa *sa_p, const __u8 *espp, int len, __u8 *hash, int hashlen) ;
|
||||
#define ipsec_alg_sa_esp_update(c,k,l) ipsec_alg_sa_esp_hash(c,k,l,NULL,0)
|
||||
|
||||
/* only called from ipsec_init.c */
|
||||
int ipsec_alg_init(void);
|
||||
|
||||
/* algo module glue for static algos */
|
||||
void ipsec_alg_static_init(void);
|
||||
typedef int (*ipsec_alg_init_func_t) (void);
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* INTERFACE for ipsec_sa init and wipe
|
||||
*
|
||||
**********************************************/
|
||||
|
||||
/* returns true if ipsec_sa has ipsec_alg obj attached */
|
||||
/*
|
||||
* Initializes ipsec_sa's ipsec_alg object, using already loaded
|
||||
* proto, authalg, encalg.; links ipsec_alg objects (enc, auth)
|
||||
*/
|
||||
int ipsec_alg_sa_init(struct ipsec_sa *sa_p);
|
||||
/*
|
||||
* Destroys ipsec_sa's ipsec_alg object
|
||||
* unlinking ipsec_alg objects
|
||||
*/
|
||||
int ipsec_alg_sa_wipe(struct ipsec_sa *sa_p);
|
||||
|
||||
/**********************************************
|
||||
*
|
||||
* 2.2 backport for some 2.4 useful module stuff
|
||||
*
|
||||
**********************************************/
|
||||
#ifdef MODULE
|
||||
#ifndef THIS_MODULE
|
||||
#define THIS_MODULE (&__this_module)
|
||||
#endif
|
||||
#ifndef module_init
|
||||
typedef int (*__init_module_func_t)(void);
|
||||
typedef void (*__cleanup_module_func_t)(void);
|
||||
|
||||
#define module_init(x) \
|
||||
int init_module(void) __attribute__((alias(#x))); \
|
||||
static inline __init_module_func_t __init_module_inline(void) \
|
||||
{ return x; }
|
||||
#define module_exit(x) \
|
||||
void cleanup_module(void) __attribute__((alias(#x))); \
|
||||
static inline __cleanup_module_func_t __cleanup_module_inline(void) \
|
||||
{ return x; }
|
||||
#endif
|
||||
|
||||
#define IPSEC_ALG_MODULE_INIT( func_name ) \
|
||||
static int func_name(void); \
|
||||
module_init(func_name); \
|
||||
static int __init func_name(void)
|
||||
#define IPSEC_ALG_MODULE_EXIT( func_name ) \
|
||||
static void func_name(void); \
|
||||
module_exit(func_name); \
|
||||
static void __exit func_name(void)
|
||||
#else /* not MODULE */
|
||||
#ifndef THIS_MODULE
|
||||
#define THIS_MODULE NULL
|
||||
#endif
|
||||
/*
|
||||
* I only want module_init() magic
|
||||
* when algo.c file *is THE MODULE*, in all other
|
||||
* cases, initialization is called explicitely from ipsec_alg_init()
|
||||
*/
|
||||
#define IPSEC_ALG_MODULE_INIT( func_name ) \
|
||||
extern int func_name(void); \
|
||||
int func_name(void)
|
||||
#define IPSEC_ALG_MODULE_EXIT( func_name ) \
|
||||
extern void func_name(void); \
|
||||
void func_name(void)
|
||||
#endif
|
||||
|
||||
#endif /* IPSEC_ALG_H */
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* declarations relevant to encapsulation-like operations
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_encap.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_ENCAP_H_
|
||||
|
||||
#define SENT_IP4 16 /* data is two struct in_addr + proto + ports*/
|
||||
/* (2 * sizeof(struct in_addr)) */
|
||||
/* sizeof(struct sockaddr_encap)
|
||||
- offsetof(struct sockaddr_encap, Sen.Sip4.Src) */
|
||||
|
||||
struct sockaddr_encap
|
||||
{
|
||||
__u8 sen_len; /* length */
|
||||
__u8 sen_family; /* AF_ENCAP */
|
||||
__u16 sen_type; /* see SENT_* */
|
||||
union
|
||||
{
|
||||
struct /* SENT_IP4 */
|
||||
{
|
||||
struct in_addr Src;
|
||||
struct in_addr Dst;
|
||||
__u8 Proto;
|
||||
__u16 Sport;
|
||||
__u16 Dport;
|
||||
} Sip4;
|
||||
} Sen;
|
||||
};
|
||||
|
||||
#define sen_ip_src Sen.Sip4.Src
|
||||
#define sen_ip_dst Sen.Sip4.Dst
|
||||
#define sen_proto Sen.Sip4.Proto
|
||||
#define sen_sport Sen.Sip4.Sport
|
||||
#define sen_dport Sen.Sip4.Dport
|
||||
|
||||
#ifndef AF_ENCAP
|
||||
#define AF_ENCAP 26
|
||||
#endif /* AF_ENCAP */
|
||||
|
||||
#define _IPSEC_ENCAP_H_
|
||||
#endif /* _IPSEC_ENCAP_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_encap.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.17 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_encap.h,v
|
||||
*
|
||||
* Revision 1.16 2001/11/26 09:23:47 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.15.2.1 2001/09/25 02:18:54 mcr
|
||||
* struct eroute moved to ipsec_eroute.h
|
||||
*
|
||||
* Revision 1.15 2001/09/14 16:58:36 rgb
|
||||
* Added support for storing the first and last packets through a HOLD.
|
||||
*
|
||||
* Revision 1.14 2001/09/08 21:13:31 rgb
|
||||
* Added pfkey ident extension support for ISAKMPd. (NetCelo)
|
||||
*
|
||||
* Revision 1.13 2001/06/14 19:35:08 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.12 2001/05/27 06:12:10 rgb
|
||||
* Added structures for pid, packet count and last access time to eroute.
|
||||
* Added packet count to beginning of /proc/net/ipsec_eroute.
|
||||
*
|
||||
* Revision 1.11 2000/09/08 19:12:56 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.10 2000/03/22 16:15:36 rgb
|
||||
* Fixed renaming of dev_get (MB).
|
||||
*
|
||||
* Revision 1.9 2000/01/21 06:13:26 rgb
|
||||
* Added a macro for AF_ENCAP
|
||||
*
|
||||
* Revision 1.8 1999/12/31 14:56:55 rgb
|
||||
* MB fix for 2.3 dev-use-count.
|
||||
*
|
||||
* Revision 1.7 1999/11/18 04:09:18 rgb
|
||||
* Replaced all kernel version macros to shorter, readable form.
|
||||
*
|
||||
* Revision 1.6 1999/09/24 00:34:13 rgb
|
||||
* Add Marc Boucher's support for 2.3.xx+.
|
||||
*
|
||||
* Revision 1.5 1999/04/11 00:28:57 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.4 1999/04/06 04:54:25 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.3 1998/10/19 14:44:28 rgb
|
||||
* Added inclusion of freeswan.h.
|
||||
* sa_id structure implemented and used: now includes protocol.
|
||||
*
|
||||
* Revision 1.2 1998/07/14 18:19:33 rgb
|
||||
* Added #ifdef __KERNEL__ directives to restrict scope of header.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:44 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.2 1998/04/21 21:29:10 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:05:58 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:02 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* Minor cosmetic changes.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:35:48 ji
|
||||
* Minor Cleanup.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* @(#) declarations of eroute structures
|
||||
*
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs <[email protected]>
|
||||
* Copyright (C) 2001 Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_eroute.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*
|
||||
* derived from ipsec_encap.h 1.15 on 2001/9/18 by mcr.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_EROUTE_H_
|
||||
|
||||
#include "radij.h"
|
||||
#include "ipsec_encap.h"
|
||||
#include "ipsec_radij.h"
|
||||
|
||||
/*
|
||||
* The "type" is really part of the address as far as the routing
|
||||
* system is concerned. By using only one bit in the type field
|
||||
* for each type, we sort-of make sure that different types of
|
||||
* encapsulation addresses won't be matched against the wrong type.
|
||||
*/
|
||||
|
||||
/*
|
||||
* An entry in the radix tree
|
||||
*/
|
||||
|
||||
struct rjtentry
|
||||
{
|
||||
struct radij_node rd_nodes[2]; /* tree glue, and other values */
|
||||
#define rd_key(r) ((struct sockaddr_encap *)((r)->rd_nodes->rj_key))
|
||||
#define rd_mask(r) ((struct sockaddr_encap *)((r)->rd_nodes->rj_mask))
|
||||
short rd_flags;
|
||||
short rd_count;
|
||||
};
|
||||
|
||||
struct ident
|
||||
{
|
||||
__u16 type; /* identity type */
|
||||
__u64 id; /* identity id */
|
||||
__u8 len; /* identity len */
|
||||
caddr_t data; /* identity data */
|
||||
};
|
||||
|
||||
/*
|
||||
* An encapsulation route consists of a pointer to a
|
||||
* radix tree entry and a SAID (a destination_address/SPI/protocol triple).
|
||||
*/
|
||||
|
||||
struct eroute
|
||||
{
|
||||
struct rjtentry er_rjt;
|
||||
struct sa_id er_said;
|
||||
uint32_t er_pid;
|
||||
uint32_t er_count;
|
||||
uint64_t er_lasttime;
|
||||
struct sockaddr_encap er_eaddr; /* MCR get rid of _encap, it is silly*/
|
||||
struct sockaddr_encap er_emask;
|
||||
struct ident er_ident_s;
|
||||
struct ident er_ident_d;
|
||||
struct sk_buff* er_first;
|
||||
struct sk_buff* er_last;
|
||||
};
|
||||
|
||||
#define er_dst er_said.dst
|
||||
#define er_spi er_said.spi
|
||||
|
||||
#define _IPSEC_EROUTE_H_
|
||||
#endif /* _IPSEC_EROUTE_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_eroute.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.3 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_eroute.h,v
|
||||
*
|
||||
* Revision 1.2 2001/11/26 09:16:13 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.1.2.1 2001/09/25 02:18:54 mcr
|
||||
* struct eroute moved to ipsec_eroute.h
|
||||
*
|
||||
*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*
|
||||
*/
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* @(#) definition of ipsec_errs structure
|
||||
*
|
||||
* Copyright (C) 2001 Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_errs.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file describes the errors/statistics that FreeSWAN collects.
|
||||
*
|
||||
*/
|
||||
|
||||
struct ipsec_errs {
|
||||
__u32 ips_alg_errs; /* number of algorithm errors */
|
||||
__u32 ips_auth_errs; /* # of authentication errors */
|
||||
__u32 ips_encsize_errs; /* # of encryption size errors*/
|
||||
__u32 ips_encpad_errs; /* # of encryption pad errors*/
|
||||
__u32 ips_replaywin_errs; /* # of pkt sequence errors */
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: ipsec_errs.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.3 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_errs.h,v
|
||||
*
|
||||
* Revision 1.2 2001/11/26 09:16:13 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.1.2.1 2001/09/25 02:25:57 mcr
|
||||
* lifetime structure created and common functions created.
|
||||
*
|
||||
*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*
|
||||
*/
|
||||
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_esp.h,v 1.2 2004/03/22 21:53:18 as Exp $
|
||||
*/
|
||||
|
||||
#include "freeswan/ipsec_md5h.h"
|
||||
#include "freeswan/ipsec_sha1.h"
|
||||
|
||||
#include "crypto/des.h"
|
||||
|
||||
#ifndef IPPROTO_ESP
|
||||
#define IPPROTO_ESP 50
|
||||
#endif /* IPPROTO_ESP */
|
||||
|
||||
#define ESP_HEADER_LEN 8 /* 64 bits header (spi+rpl)*/
|
||||
|
||||
#define EMT_ESPDESCBC_ULEN 20 /* coming from user mode */
|
||||
#define EMT_ESPDES_KMAX 64 /* 512 bit secret key enough? */
|
||||
#define EMT_ESPDES_KEY_SZ 8 /* 56 bit secret key with parity = 64 bits */
|
||||
#define EMT_ESP3DES_KEY_SZ 24 /* 168 bit secret key with parity = 192 bits */
|
||||
#define EMT_ESPDES_IV_SZ 8 /* IV size */
|
||||
#define ESP_DESCBC_BLKLEN 8 /* DES-CBC block size */
|
||||
|
||||
#define ESP_IV_MAXSZ 16 /* This is _critical_ */
|
||||
#define ESP_IV_MAXSZ_INT (ESP_IV_MAXSZ/sizeof(int))
|
||||
|
||||
#define DB_ES_PKTRX 0x0001
|
||||
#define DB_ES_PKTRX2 0x0002
|
||||
#define DB_ES_IPSA 0x0010
|
||||
#define DB_ES_XF 0x0020
|
||||
#define DB_ES_IPAD 0x0040
|
||||
#define DB_ES_INAU 0x0080
|
||||
#define DB_ES_OINFO 0x0100
|
||||
#define DB_ES_OINFO2 0x0200
|
||||
#define DB_ES_OH 0x0400
|
||||
#define DB_ES_REPLAY 0x0800
|
||||
|
||||
#ifdef __KERNEL__
|
||||
struct des_eks {
|
||||
des_key_schedule ks;
|
||||
};
|
||||
|
||||
extern struct inet_protocol esp_protocol;
|
||||
|
||||
struct options;
|
||||
|
||||
extern int
|
||||
esp_rcv(struct sk_buff *skb,
|
||||
struct device *dev,
|
||||
struct options *opt,
|
||||
__u32 daddr,
|
||||
unsigned short len,
|
||||
__u32 saddr,
|
||||
int redo,
|
||||
struct inet_protocol *protocol);
|
||||
|
||||
/* Only for 64 bits IVs, eg. ESP_3DES :P */
|
||||
struct esphdr
|
||||
{
|
||||
__u32 esp_spi; /* Security Parameters Index */
|
||||
__u32 esp_rpl; /* Replay counter */
|
||||
__u8 esp_iv[8]; /* iv */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int debug_esp;
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_esp.h,v $
|
||||
* Revision 1.2 2004/03/22 21:53:18 as
|
||||
* merged alg-0.8.1 branch with HEAD
|
||||
*
|
||||
* Revision 1.1.4.1 2004/03/16 09:48:18 as
|
||||
* alg-0.8.1rc12 patch merged
|
||||
*
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.21 2003/02/06 02:21:34 rgb
|
||||
*
|
||||
* Moved "struct auth_alg" from ipsec_rcv.c to ipsec_ah.h .
|
||||
* Changed "struct ah" to "struct ahhdr" and "struct esp" to "struct esphdr".
|
||||
* Removed "#ifdef INBOUND_POLICY_CHECK_eroute" dead code.
|
||||
*
|
||||
* Revision 1.20 2002/05/14 02:37:02 rgb
|
||||
* Change reference from _TDB to _IPSA.
|
||||
*
|
||||
* Revision 1.19 2002/04/24 07:55:32 mcr
|
||||
* #include patches and Makefiles for post-reorg compilation.
|
||||
*
|
||||
* Revision 1.18 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_esp.h,v
|
||||
*
|
||||
* Revision 1.17 2002/02/20 01:27:07 rgb
|
||||
* Ditched a pile of structs only used by the old Netlink interface.
|
||||
*
|
||||
* Revision 1.16 2001/12/11 02:35:57 rgb
|
||||
* Change "struct net_device" to "struct device" for 2.2 compatibility.
|
||||
*
|
||||
* Revision 1.15 2001/11/26 09:23:48 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.14.2.3 2001/10/23 04:16:42 mcr
|
||||
* get definition of des_key_schedule from des.h
|
||||
*
|
||||
* Revision 1.14.2.2 2001/10/22 20:33:13 mcr
|
||||
* use "des_key_schedule" structure instead of cooking our own.
|
||||
*
|
||||
* Revision 1.14.2.1 2001/09/25 02:18:25 mcr
|
||||
* replace "struct device" with "struct netdevice"
|
||||
*
|
||||
* Revision 1.14 2001/06/14 19:35:08 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.13 2000/09/08 19:12:56 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.12 2000/08/01 14:51:50 rgb
|
||||
* Removed _all_ remaining traces of DES.
|
||||
*
|
||||
* Revision 1.11 2000/01/10 16:36:20 rgb
|
||||
* Ditch last of EME option flags, including initiator.
|
||||
*
|
||||
* Revision 1.10 1999/12/07 18:16:22 rgb
|
||||
* Fixed comments at end of #endif lines.
|
||||
*
|
||||
* Revision 1.9 1999/04/11 00:28:57 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.8 1999/04/06 04:54:25 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.7 1999/01/26 02:06:00 rgb
|
||||
* Removed CONFIG_IPSEC_ALGO_SWITCH macro.
|
||||
*
|
||||
* Revision 1.6 1999/01/22 15:22:05 rgb
|
||||
* Re-enable IV in the espblkrply_edata structure to avoid breaking pluto
|
||||
* until pluto can be fixed properly.
|
||||
*
|
||||
* Revision 1.5 1999/01/22 06:18:16 rgb
|
||||
* Updated macro comments.
|
||||
* Added key schedule types to support algorithm switch code.
|
||||
*
|
||||
* Revision 1.4 1998/08/12 00:07:32 rgb
|
||||
* Added data structures for new xforms: null, {,3}dessha1.
|
||||
*
|
||||
* Revision 1.3 1998/07/14 15:57:01 rgb
|
||||
* Add #ifdef __KERNEL__ to protect kernel-only structures.
|
||||
*
|
||||
* Revision 1.2 1998/06/25 19:33:46 rgb
|
||||
* Add prototype for protocol receive function.
|
||||
* Rearrange for more logical layout.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:45 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.6 1998/06/05 02:28:08 rgb
|
||||
* Minor comment fix.
|
||||
*
|
||||
* Revision 1.5 1998/05/27 22:34:00 rgb
|
||||
* Changed structures to accomodate key separation.
|
||||
*
|
||||
* Revision 1.4 1998/05/18 22:28:43 rgb
|
||||
* Disable key printing facilities from /proc/net/ipsec_*.
|
||||
*
|
||||
* Revision 1.3 1998/04/21 21:29:07 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.2 1998/04/12 22:03:20 rgb
|
||||
* Updated ESP-3DES-HMAC-MD5-96,
|
||||
* ESP-DES-HMAC-MD5-96,
|
||||
* AH-HMAC-MD5-96,
|
||||
* AH-HMAC-SHA1-96 since Henry started freeswan cvs repository
|
||||
* from old standards (RFC182[5-9] to new (as of March 1998) drafts.
|
||||
*
|
||||
* Fixed eroute references in /proc/net/ipsec*.
|
||||
*
|
||||
* Started to patch module unloading memory leaks in ipsec_netlink and
|
||||
* radij tree unloading.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:00 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:02 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.5 1997/06/03 04:24:48 ji
|
||||
* Added ESP-3DES-MD5-96 transform.
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* Added definitions for new ESP transforms.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:35:48 ji
|
||||
* Minor Cleanup.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* IP-in-IP Header declarations
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_ipe4.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
/* The packet header is an IP header! */
|
||||
|
||||
struct ipe4_xdata /* transform table data */
|
||||
{
|
||||
struct in_addr i4_src;
|
||||
struct in_addr i4_dst;
|
||||
};
|
||||
|
||||
#define EMT_IPE4_ULEN 8 /* coming from user mode */
|
||||
|
||||
|
||||
/*
|
||||
* $Log: ipsec_ipe4.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.5 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_ipe4.h,v
|
||||
*
|
||||
* Revision 1.4 2001/06/14 19:35:08 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.3 1999/04/11 00:28:57 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.2 1999/04/06 04:54:25 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:47 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:07 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:03 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* No changes.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:48:53 ji
|
||||
* Release update only.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,227 +0,0 @@
|
||||
#ifndef _FREESWAN_KVERSIONS_H
|
||||
/*
|
||||
* header file for FreeS/WAN library functions
|
||||
* Copyright (C) 1998, 1999, 2000 Henry Spencer.
|
||||
* Copyright (C) 1999, 2000, 2001 Richard Guy Briggs
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
* License for more details.
|
||||
*
|
||||
* RCSID $Id: ipsec_kversion.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
#define _FREESWAN_KVERSIONS_H /* seen it, no need to see it again */
|
||||
|
||||
/*
|
||||
* this file contains a series of atomic defines that depend upon
|
||||
* kernel version numbers. The kernel versions are arranged
|
||||
* in version-order number (which is often not chronological)
|
||||
* and each clause enables or disables a feature.
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, assorted kernel-version-dependent trickery.
|
||||
*/
|
||||
#include <linux/version.h>
|
||||
#ifndef KERNEL_VERSION
|
||||
#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
|
||||
#define HEADER_CACHE_BIND_21
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
|
||||
#define SPINLOCK
|
||||
#define PROC_FS_21
|
||||
#define NETLINK_SOCK
|
||||
#define NET_21
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,19)
|
||||
#define net_device_stats enet_statistics
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
|
||||
#define SPINLOCK_23
|
||||
#define NETDEV_23
|
||||
# ifndef CONFIG_IP_ALIAS
|
||||
# define CONFIG_IP_ALIAS
|
||||
# endif
|
||||
#include <linux/socket.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netlink.h>
|
||||
# ifdef NETLINK_XFRM
|
||||
# define NETDEV_25
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,25)
|
||||
#define PROC_FS_2325
|
||||
#undef PROC_FS_21
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30)
|
||||
#define PROC_NO_DUMMY
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,35)
|
||||
#define SKB_COPY_EXPAND
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,37)
|
||||
#define IP_SELECT_IDENT
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,50)) && defined(CONFIG_NETFILTER)
|
||||
#define SKB_RESET_NFCT
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,2)
|
||||
#define IP_SELECT_IDENT_NEW
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4)
|
||||
#define IPH_is_SKB_PULLED
|
||||
#define SKB_COW_NEW
|
||||
#define PROTO_HANDLER_SINGLE_PARM
|
||||
#define IP_FRAGMENT_LINEARIZE 1
|
||||
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
|
||||
# ifdef REDHAT_BOGOSITY
|
||||
# define IP_SELECT_IDENT_NEW
|
||||
# define IPH_is_SKB_PULLED
|
||||
# define SKB_COW_NEW
|
||||
# define PROTO_HANDLER_SINGLE_PARM
|
||||
# endif /* REDHAT_BOGOSITY */
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) */
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
|
||||
#define MALLOC_SLAB
|
||||
#define LINUX_KERNEL_HAS_SNPRINTF
|
||||
#endif
|
||||
|
||||
#ifdef NET_21
|
||||
# include <linux/in6.h>
|
||||
#else
|
||||
/* old kernel in.h has some IPv6 stuff, but not quite enough */
|
||||
# define s6_addr16 s6_addr
|
||||
# define AF_INET6 10
|
||||
# define uint8_t __u8
|
||||
# define uint16_t __u16
|
||||
# define uint32_t __u32
|
||||
# define uint64_t __u64
|
||||
#endif
|
||||
|
||||
#ifdef NET_21
|
||||
# define ipsec_kfree_skb(a) kfree_skb(a)
|
||||
#else /* NET_21 */
|
||||
# define ipsec_kfree_skb(a) kfree_skb(a, FREE_WRITE)
|
||||
#endif /* NET_21 */
|
||||
|
||||
#ifdef NETDEV_23
|
||||
# define device net_device
|
||||
# define ipsec_dev_get dev_get_by_name
|
||||
# define __ipsec_dev_get __dev_get_by_name
|
||||
# define ipsec_dev_put(x) dev_put(x)
|
||||
# define __ipsec_dev_put(x) __dev_put(x)
|
||||
# define ipsec_dev_hold(x) dev_hold(x)
|
||||
#else /* NETDEV_23 */
|
||||
# define ipsec_dev_get dev_get
|
||||
# define __ipsec_dev_put(x)
|
||||
# define ipsec_dev_put(x)
|
||||
# define ipsec_dev_hold(x)
|
||||
#endif /* NETDEV_23 */
|
||||
|
||||
#ifndef SPINLOCK
|
||||
# include <linux/bios32.h>
|
||||
/* simulate spin locks and read/write locks */
|
||||
typedef struct {
|
||||
volatile char lock;
|
||||
} spinlock_t;
|
||||
|
||||
typedef struct {
|
||||
volatile unsigned int lock;
|
||||
} rwlock_t;
|
||||
|
||||
# define spin_lock_init(x) { (x)->lock = 0;}
|
||||
# define rw_lock_init(x) { (x)->lock = 0; }
|
||||
|
||||
# define spin_lock(x) { while ((x)->lock) barrier(); (x)->lock=1;}
|
||||
# define spin_lock_irq(x) { cli(); spin_lock(x);}
|
||||
# define spin_lock_irqsave(x,flags) { save_flags(flags); spin_lock_irq(x);}
|
||||
|
||||
# define spin_unlock(x) { (x)->lock=0;}
|
||||
# define spin_unlock_irq(x) { spin_unlock(x); sti();}
|
||||
# define spin_unlock_irqrestore(x,flags) { spin_unlock(x); restore_flags(flags);}
|
||||
|
||||
# define read_lock(x) spin_lock(x)
|
||||
# define read_lock_irq(x) spin_lock_irq(x)
|
||||
# define read_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
|
||||
|
||||
# define read_unlock(x) spin_unlock(x)
|
||||
# define read_unlock_irq(x) spin_unlock_irq(x)
|
||||
# define read_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
|
||||
|
||||
# define write_lock(x) spin_lock(x)
|
||||
# define write_lock_irq(x) spin_lock_irq(x)
|
||||
# define write_lock_irqsave(x,flags) spin_lock_irqsave(x,flags)
|
||||
|
||||
# define write_unlock(x) spin_unlock(x)
|
||||
# define write_unlock_irq(x) spin_unlock_irq(x)
|
||||
# define write_unlock_irqrestore(x,flags) spin_unlock_irqrestore(x,flags)
|
||||
#endif /* !SPINLOCK */
|
||||
|
||||
#ifndef SPINLOCK_23
|
||||
# define spin_lock_bh(x) spin_lock_irq(x)
|
||||
# define spin_unlock_bh(x) spin_unlock_irq(x)
|
||||
|
||||
# define read_lock_bh(x) read_lock_irq(x)
|
||||
# define read_unlock_bh(x) read_unlock_irq(x)
|
||||
|
||||
# define write_lock_bh(x) write_lock_irq(x)
|
||||
# define write_unlock_bh(x) write_unlock_irq(x)
|
||||
#endif /* !SPINLOCK_23 */
|
||||
|
||||
#endif /* _FREESWAN_KVERSIONS_H */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_kversion.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.7 2003/07/31 22:48:08 mcr
|
||||
* derive NET25-ness from presence of NETLINK_XFRM macro.
|
||||
*
|
||||
* Revision 1.6 2003/06/24 20:22:32 mcr
|
||||
* added new global: ipsecdevices[] so that we can keep track of
|
||||
* the ipsecX devices. They will be referenced with dev_hold(),
|
||||
* so 2.2 may need this as well.
|
||||
*
|
||||
* Revision 1.5 2003/04/03 17:38:09 rgb
|
||||
* Centralised ipsec_kfree_skb and ipsec_dev_{get,put}.
|
||||
*
|
||||
* Revision 1.4 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_kversion.h,v
|
||||
*
|
||||
* Revision 1.3 2002/04/12 03:21:17 mcr
|
||||
* three parameter version of ip_select_ident appears first
|
||||
* in 2.4.2 (RH7.1) not 2.4.4.
|
||||
*
|
||||
* Revision 1.2 2002/03/08 21:35:22 rgb
|
||||
* Defined LINUX_KERNEL_HAS_SNPRINTF to shut up compiler warnings after
|
||||
* 2.4.9. (Andreas Piesk).
|
||||
*
|
||||
* Revision 1.1 2002/01/29 02:11:42 mcr
|
||||
* removal of kversions.h - sources that needed it now use ipsec_param.h.
|
||||
* updating of IPv6 structures to match latest in6.h version.
|
||||
* removed dead code from freeswan.h that also duplicated kversions.h
|
||||
* code.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Definitions relevant to IPSEC lifetimes
|
||||
* Copyright (C) 2001 Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_life.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*
|
||||
* This file derived from ipsec_xform.h on 2001/9/18 by mcr.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file describes the book keeping fields for the
|
||||
* IPsec Security Association Structure. ("ipsec_sa")
|
||||
*
|
||||
* This structure is never allocated directly by kernel code,
|
||||
* (it is always a static/auto or is part of a structure)
|
||||
* so it does not have a reference count.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_LIFE_H_
|
||||
|
||||
/*
|
||||
* _count is total count.
|
||||
* _hard is hard limit (kill SA after this number)
|
||||
* _soft is soft limit (try to renew SA after this number)
|
||||
* _last is used in some special cases.
|
||||
*
|
||||
*/
|
||||
|
||||
struct ipsec_lifetime64
|
||||
{
|
||||
__u64 ipl_count;
|
||||
__u64 ipl_soft;
|
||||
__u64 ipl_hard;
|
||||
__u64 ipl_last;
|
||||
};
|
||||
|
||||
struct ipsec_lifetimes
|
||||
{
|
||||
/* number of bytes processed */
|
||||
struct ipsec_lifetime64 ipl_bytes;
|
||||
|
||||
/* number of packets processed */
|
||||
struct ipsec_lifetime64 ipl_packets;
|
||||
|
||||
/* time since SA was added */
|
||||
struct ipsec_lifetime64 ipl_addtime;
|
||||
|
||||
/* time since SA was first used */
|
||||
struct ipsec_lifetime64 ipl_usetime;
|
||||
|
||||
/* from rfc2367:
|
||||
* For CURRENT, the number of different connections,
|
||||
* endpoints, or flows that the association has been
|
||||
* allocated towards. For HARD and SOFT, the number of
|
||||
* these the association may be allocated towards
|
||||
* before it expires. The concept of a connection,
|
||||
* flow, or endpoint is system specific.
|
||||
*
|
||||
* mcr(2001-9-18) it is unclear what purpose these serve for FreeSWAN.
|
||||
* They are maintained for PF_KEY compatibility.
|
||||
*/
|
||||
struct ipsec_lifetime64 ipl_allocations;
|
||||
};
|
||||
|
||||
enum ipsec_life_alive {
|
||||
ipsec_life_harddied = -1,
|
||||
ipsec_life_softdied = 0,
|
||||
ipsec_life_okay = 1
|
||||
};
|
||||
|
||||
enum ipsec_life_type {
|
||||
ipsec_life_timebased = 1,
|
||||
ipsec_life_countbased= 0
|
||||
};
|
||||
|
||||
#define _IPSEC_LIFE_H_
|
||||
#endif /* _IPSEC_LIFE_H_ */
|
||||
|
||||
|
||||
/*
|
||||
* $Log: ipsec_life.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.3 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_life.h,v
|
||||
*
|
||||
* Revision 1.2 2001/11/26 09:16:14 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.1.2.1 2001/09/25 02:25:58 mcr
|
||||
* lifetime structure created and common functions created.
|
||||
*
|
||||
*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*
|
||||
*/
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* RCSID $Id: ipsec_md5h.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* The rest of this file is Copyright RSA DSI. See the following comments
|
||||
* for the full Copyright notice.
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_MD5H_H_
|
||||
#define _IPSEC_MD5H_H_
|
||||
|
||||
/* GLOBAL.H - RSAREF types and constants
|
||||
*/
|
||||
|
||||
/* PROTOTYPES should be set to one if and only if the compiler supports
|
||||
function argument prototyping.
|
||||
The following makes PROTOTYPES default to 0 if it has not already
|
||||
been defined with C compiler flags.
|
||||
*/
|
||||
#ifndef PROTOTYPES
|
||||
#define PROTOTYPES 1
|
||||
#endif /* !PROTOTYPES */
|
||||
|
||||
/* POINTER defines a generic pointer type */
|
||||
typedef __u8 *POINTER;
|
||||
|
||||
/* UINT2 defines a two byte word */
|
||||
typedef __u16 UINT2;
|
||||
|
||||
/* UINT4 defines a four byte word */
|
||||
typedef __u32 UINT4;
|
||||
|
||||
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
|
||||
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
|
||||
returns an empty list.
|
||||
*/
|
||||
|
||||
#if PROTOTYPES
|
||||
#define PROTO_LIST(list) list
|
||||
#else /* PROTOTYPES */
|
||||
#define PROTO_LIST(list) ()
|
||||
#endif /* PROTOTYPES */
|
||||
|
||||
|
||||
/* MD5.H - header file for MD5C.C
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
/* MD5 context. */
|
||||
typedef struct {
|
||||
UINT4 state[4]; /* state (ABCD) */
|
||||
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5Init PROTO_LIST ((void *));
|
||||
void MD5Update PROTO_LIST
|
||||
((void *, unsigned char *, __u32));
|
||||
void MD5Final PROTO_LIST ((unsigned char [16], void *));
|
||||
|
||||
#endif /* _IPSEC_MD5H_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_md5h.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.8 2002/09/10 01:45:09 mcr
|
||||
* changed type of MD5_CTX and SHA1_CTX to void * so that
|
||||
* the function prototypes would match, and could be placed
|
||||
* into a pointer to a function.
|
||||
*
|
||||
* Revision 1.7 2002/04/24 07:36:46 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_md5h.h,v
|
||||
*
|
||||
* Revision 1.6 1999/12/13 13:59:13 rgb
|
||||
* Quick fix to argument size to Update bugs.
|
||||
*
|
||||
* Revision 1.5 1999/12/07 18:16:23 rgb
|
||||
* Fixed comments at end of #endif lines.
|
||||
*
|
||||
* Revision 1.4 1999/04/06 04:54:26 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.3 1999/01/22 06:19:58 rgb
|
||||
* 64-bit clean-up.
|
||||
*
|
||||
* Revision 1.2 1998/11/30 13:22:54 rgb
|
||||
* Rationalised all the klips kernel file headers. They are much shorter
|
||||
* now and won't conflict under RH5.2.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:48 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.2 1998/04/23 20:54:03 rgb
|
||||
* Fixed md5 and sha1 include file nesting issues, to be cleaned up when
|
||||
* verified.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:04:21 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
* these two include files modified not to include others except in kernel
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:03 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* No changes.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:48:53 ji
|
||||
* Release update only.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* @(#) FreeSWAN tunable paramaters
|
||||
*
|
||||
* Copyright (C) 2001 Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_param.h,v 1.2 2004/04/28 08:07:11 as Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file provides a set of #define's which may be tuned by various
|
||||
* people/configurations. It keeps all compile-time tunables in one place.
|
||||
*
|
||||
* This file should be included before all other IPsec kernel-only files.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_PARAM_H_
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include "ipsec_kversion.h"
|
||||
|
||||
/* Set number of ipsecX virtual devices here. */
|
||||
/* This must be < exp(field width of IPSEC_DEV_FORMAT) */
|
||||
/* It must also be reasonable so as not to overload the memory and CPU */
|
||||
/* constraints of the host. */
|
||||
#define IPSEC_NUM_IF 4
|
||||
/* The field width must be < IF_NAM_SIZ - strlen("ipsec") - 1. */
|
||||
/* With "ipsec" being 5 characters, that means 10 is the max field width */
|
||||
/* but machine memory and CPU constraints are not likely to tollerate */
|
||||
/* more than 3 digits. The default is one digit. */
|
||||
/* Update: userland scripts get upset if they can't find "ipsec0", so */
|
||||
/* for now, no "0"-padding should be used (which would have been helpful */
|
||||
/* to make text-searches work */
|
||||
#define IPSEC_DEV_FORMAT "ipsec%d"
|
||||
/* For, say, 500 virtual ipsec devices, I would recommend: */
|
||||
/* #define IPSEC_NUM_IF 500 */
|
||||
/* #define IPSEC_DEV_FORMAT "ipsec%03d" */
|
||||
/* Note that the "interfaces=" line in /etc/ipsec.conf would be, um, challenging. */
|
||||
|
||||
/* use dynamic ipsecX device allocation */
|
||||
#ifndef CONFIG_IPSEC_DYNDEV
|
||||
#define CONFIG_IPSEC_DYNDEV 1
|
||||
#endif /* CONFIG_IPSEC_DYNDEV */
|
||||
|
||||
|
||||
#ifdef CONFIG_IPSEC_BIGGATE
|
||||
# define SADB_HASHMOD 8069
|
||||
#else /* CONFIG_IPSEC_BIGGATE */
|
||||
# define SADB_HASHMOD 257
|
||||
#endif /* CONFIG_IPSEC_BIGGATE */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/*
|
||||
* This is for the SA reference table. This number is related to the
|
||||
* maximum number of SAs that KLIPS can concurrently deal with, plus enough
|
||||
* space for keeping expired SAs around.
|
||||
*
|
||||
* TABLE_MAX_WIDTH is the number of bits that we will use.
|
||||
* MAIN_TABLE_WIDTH is the number of bits used for the primary index table.
|
||||
*
|
||||
*/
|
||||
#ifndef IPSEC_SA_REF_TABLE_IDX_WIDTH
|
||||
# define IPSEC_SA_REF_TABLE_IDX_WIDTH 16
|
||||
#endif
|
||||
|
||||
#ifndef IPSEC_SA_REF_MAINTABLE_IDX_WIDTH
|
||||
# define IPSEC_SA_REF_MAINTABLE_IDX_WIDTH 4
|
||||
#endif
|
||||
|
||||
#ifndef IPSEC_SA_REF_FREELIST_NUM_ENTRIES
|
||||
# define IPSEC_SA_REF_FREELIST_NUM_ENTRIES 256
|
||||
#endif
|
||||
|
||||
#ifndef IPSEC_SA_REF_CODE
|
||||
# define IPSEC_SA_REF_CODE 1
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/* This is defined for 2.4, but not 2.2.... */
|
||||
#ifndef ARPHRD_VOID
|
||||
# define ARPHRD_VOID 0xFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Worry about PROC_FS stuff
|
||||
*/
|
||||
#if defined(PROC_FS_2325)
|
||||
/* kernel 2.4 */
|
||||
# define IPSEC_PROC_LAST_ARG ,int *eof,void *data
|
||||
# define IPSEC_PROCFS_DEBUG_NO_STATIC
|
||||
# define IPSEC_PROC_SUBDIRS
|
||||
#else
|
||||
/* kernel <2.4 */
|
||||
# define IPSEC_PROCFS_DEBUG_NO_STATIC DEBUG_NO_STATIC
|
||||
|
||||
# ifndef PROC_NO_DUMMY
|
||||
# define IPSEC_PROC_LAST_ARG , int dummy
|
||||
# else
|
||||
# define IPSEC_PROC_LAST_ARG
|
||||
# endif /* !PROC_NO_DUMMY */
|
||||
#endif /* PROC_FS_2325 */
|
||||
|
||||
#if !defined(LINUX_KERNEL_HAS_SNPRINTF)
|
||||
/* GNU CPP specific! */
|
||||
# define snprintf(buf, len, fmt...) sprintf(buf, ##fmt)
|
||||
#endif /* !LINUX_KERNEL_HAS_SNPRINTF */
|
||||
|
||||
#ifdef SPINLOCK
|
||||
# ifdef SPINLOCK_23
|
||||
# include <linux/spinlock.h> /* *lock* */
|
||||
# else /* SPINLOCK_23 */
|
||||
# include <asm/spinlock.h> /* *lock* */
|
||||
# endif /* SPINLOCK_23 */
|
||||
#endif /* SPINLOCK */
|
||||
|
||||
#ifndef KLIPS_FIXES_DES_PARITY
|
||||
# define KLIPS_FIXES_DES_PARITY 1
|
||||
#endif /* !KLIPS_FIXES_DES_PARITY */
|
||||
|
||||
/* we don't really want to print these unless there are really big problems */
|
||||
#ifndef KLIPS_DIVULGE_CYPHER_KEY
|
||||
# define KLIPS_DIVULGE_CYPHER_KEY 0
|
||||
#endif /* !KLIPS_DIVULGE_CYPHER_KEY */
|
||||
|
||||
#ifndef KLIPS_DIVULGE_HMAC_KEY
|
||||
# define KLIPS_DIVULGE_HMAC_KEY 0
|
||||
#endif /* !KLIPS_DIVULGE_HMAC_KEY */
|
||||
|
||||
#ifndef IPSEC_DISALLOW_IPOPTIONS
|
||||
# define IPSEC_DISALLOW_IPOPTIONS 1
|
||||
#endif /* !KLIPS_DIVULGE_HMAC_KEY */
|
||||
|
||||
/* extra toggles for regression testing */
|
||||
#ifdef CONFIG_IPSEC_REGRESS
|
||||
|
||||
/*
|
||||
* should pfkey_acquire() become 100% lossy?
|
||||
*
|
||||
*/
|
||||
extern int sysctl_ipsec_regress_pfkey_lossage;
|
||||
#ifndef KLIPS_PFKEY_ACQUIRE_LOSSAGE
|
||||
# ifdef CONFIG_IPSEC_PFKEY_ACQUIRE_LOSSAGE
|
||||
# define KLIPS_PFKEY_ACQUIRE_LOSSAGE 100
|
||||
# else /* CONFIG_IPSEC_PFKEY_ACQUIRE_LOSSAGE */
|
||||
/* not by default! */
|
||||
# define KLIPS_PFKEY_ACQUIRE_LOSSAGE 0
|
||||
# endif /* CONFIG_IPSEC_PFKEY_ACQUIRE_LOSSAGE */
|
||||
#endif /* KLIPS_PFKEY_ACQUIRE_LOSSAGE */
|
||||
|
||||
#endif /* CONFIG_IPSEC_REGRESS */
|
||||
|
||||
/*
|
||||
* debugging routines.
|
||||
*/
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern void ipsec_print_ip(struct iphdr *ip);
|
||||
|
||||
#define KLIPS_PRINT(flag, format, args...) \
|
||||
((flag) ? printk(KERN_INFO format , ## args) : 0)
|
||||
#define KLIPS_PRINTMORE(flag, format, args...) \
|
||||
((flag) ? printk(format , ## args) : 0)
|
||||
#define KLIPS_IP_PRINT(flag, ip) \
|
||||
((flag) ? ipsec_print_ip(ip) : 0)
|
||||
#else /* CONFIG_IPSEC_DEBUG */
|
||||
#define KLIPS_PRINT(flag, format, args...) do ; while(0)
|
||||
#define KLIPS_PRINTMORE(flag, format, args...) do ; while(0)
|
||||
#define KLIPS_IP_PRINT(flag, ip) do ; while(0)
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
* Stupid kernel API differences in APIs. Not only do some
|
||||
* kernels not have ip_select_ident, but some have differing APIs,
|
||||
* and SuSE has one with one parameter, but no way of checking to
|
||||
* see what is really what.
|
||||
*/
|
||||
|
||||
#ifdef SUSE_LINUX_2_4_19_IS_STUPID
|
||||
#define KLIPS_IP_SELECT_IDENT(iph, skb) ip_select_ident(iph)
|
||||
#else
|
||||
|
||||
/* simplest case, nothing */
|
||||
#if !defined(IP_SELECT_IDENT)
|
||||
#define KLIPS_IP_SELECT_IDENT(iph, skb) do { iph->id = htons(ip_id_count++); } while(0)
|
||||
#endif
|
||||
|
||||
/* kernels > 2.3.37-ish */
|
||||
#if defined(IP_SELECT_IDENT) && !defined(IP_SELECT_IDENT_NEW)
|
||||
#define KLIPS_IP_SELECT_IDENT(iph, skb) ip_select_ident(iph, skb->dst)
|
||||
#endif
|
||||
|
||||
/* kernels > 2.4.2 */
|
||||
#if defined(IP_SELECT_IDENT) && defined(IP_SELECT_IDENT_NEW)
|
||||
#define KLIPS_IP_SELECT_IDENT(iph, skb) ip_select_ident(iph, skb->dst, NULL)
|
||||
#endif
|
||||
|
||||
#endif /* SUSE_LINUX_2_4_19_IS_STUPID */
|
||||
|
||||
/*
|
||||
* make klips fail test:east-espiv-01.
|
||||
* exploit is at testing/attacks/espiv
|
||||
*
|
||||
*/
|
||||
#define KLIPS_IMPAIRMENT_ESPIV_CBC_ATTACK 0
|
||||
|
||||
|
||||
/* IP_FRAGMENT_LINEARIZE is set in freeswan.h if Kernel > 2.4.4 */
|
||||
#ifndef IP_FRAGMENT_LINEARIZE
|
||||
# define IP_FRAGMENT_LINEARIZE 0
|
||||
#endif /* IP_FRAGMENT_LINEARIZE */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#define _IPSEC_PARAM_H_
|
||||
#endif /* _IPSEC_PARAM_H_ */
|
||||
@@ -1,225 +0,0 @@
|
||||
#ifndef _IPSEC_POLICY_H
|
||||
/*
|
||||
* policy interface file between pluto and applications
|
||||
* Copyright (C) 2003 Michael Richardson <[email protected]>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
||||
* License for more details.
|
||||
*
|
||||
* RCSID $Id: ipsec_policy.h,v 1.4 2004/10/04 22:43:56 as Exp $
|
||||
*/
|
||||
#define _IPSEC_POLICY_H /* seen it, no need to see it again */
|
||||
|
||||
|
||||
/*
|
||||
* this file defines an interface between an application (or rather an
|
||||
* application library) and a key/policy daemon. It provides for inquiries
|
||||
* as to the current state of a connected socket, as well as for general
|
||||
* questions.
|
||||
*
|
||||
* In general, the interface is defined as a series of functional interfaces,
|
||||
* and the policy messages should be internal. However, because this is in
|
||||
* fact an ABI between pieces of the system that may get compiled and revised
|
||||
* seperately, this ABI must be public and revision controlled.
|
||||
*
|
||||
* It is expected that the daemon will always support previous versions.
|
||||
*/
|
||||
|
||||
#define IPSEC_POLICY_MSG_REVISION (unsigned)200305061
|
||||
|
||||
enum ipsec_policy_command {
|
||||
IPSEC_CMD_QUERY_FD = 1,
|
||||
IPSEC_CMD_QUERY_HOSTPAIR = 2,
|
||||
IPSEC_CMD_QUERY_DSTONLY = 3,
|
||||
};
|
||||
|
||||
struct ipsec_policy_msg_head {
|
||||
u_int32_t ipm_version;
|
||||
u_int32_t ipm_msg_len;
|
||||
u_int32_t ipm_msg_type;
|
||||
u_int32_t ipm_msg_seq;
|
||||
};
|
||||
|
||||
enum ipsec_privacy_quality {
|
||||
IPSEC_PRIVACY_NONE = 0,
|
||||
IPSEC_PRIVACY_INTEGRAL = 4, /* not private at all. AH-like */
|
||||
IPSEC_PRIVACY_UNKNOWN = 8, /* something is claimed, but details unavail */
|
||||
IPSEC_PRIVACY_ROT13 = 12, /* trivially breakable, i.e. 1DES */
|
||||
IPSEC_PRIVACY_GAK = 16, /* known eavesdroppers */
|
||||
IPSEC_PRIVACY_PRIVATE = 32, /* secure for at least a decade */
|
||||
IPSEC_PRIVACY_STRONG = 64, /* ridiculously secure */
|
||||
IPSEC_PRIVACY_TORTOISE = 192, /* even stronger, but very slow */
|
||||
IPSEC_PRIVACY_OTP = 224, /* some kind of *true* one time pad */
|
||||
};
|
||||
|
||||
enum ipsec_bandwidth_quality {
|
||||
IPSEC_QOS_UNKNOWN = 0, /* unknown bandwidth */
|
||||
IPSEC_QOS_INTERACTIVE = 16, /* reasonably moderate jitter, moderate fast.
|
||||
Good enough for telnet/ssh. */
|
||||
IPSEC_QOS_VOIP = 32, /* faster crypto, predicable jitter */
|
||||
IPSEC_QOS_FTP = 64, /* higher throughput crypto, perhaps hardware
|
||||
offloaded, but latency/jitter may be bad */
|
||||
IPSEC_QOS_WIRESPEED = 128, /* expect to be able to fill your pipe */
|
||||
};
|
||||
|
||||
/* moved from programs/pluto/constants.h */
|
||||
/* IPsec AH transform values
|
||||
* RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.3
|
||||
* and in http://www.iana.org/assignments/isakmp-registry
|
||||
*/
|
||||
enum ipsec_authentication_algo {
|
||||
AH_NONE = 0,
|
||||
AH_MD5 = 2,
|
||||
AH_SHA = 3,
|
||||
AH_DES = 4,
|
||||
AH_SHA2_256 = 5,
|
||||
AH_SHA2_384 = 6,
|
||||
AH_SHA2_512 = 7,
|
||||
AH_RIPEMD = 8
|
||||
};
|
||||
|
||||
/* IPsec ESP transform values
|
||||
* RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.4
|
||||
* and from http://www.iana.org/assignments/isakmp-registry
|
||||
*/
|
||||
|
||||
enum ipsec_cipher_algo {
|
||||
ESP_NONE = 0,
|
||||
ESP_DES_IV64 = 1,
|
||||
ESP_DES = 2,
|
||||
ESP_3DES = 3,
|
||||
ESP_RC5 = 4,
|
||||
ESP_IDEA = 5,
|
||||
ESP_CAST = 6,
|
||||
ESP_BLOWFISH = 7,
|
||||
ESP_3IDEA = 8,
|
||||
ESP_DES_IV32 = 9,
|
||||
ESP_RC4 = 10,
|
||||
ESP_NULL = 11,
|
||||
ESP_AES = 12,
|
||||
ESP_AES_CTR = 13,
|
||||
ESP_AES_CCM_8 = 14,
|
||||
ESP_AES_CCM_12 = 15,
|
||||
ESP_AES_CCM_16 = 16,
|
||||
ESP_SERPENT = 252,
|
||||
ESP_TWOFISH = 253
|
||||
};
|
||||
|
||||
/* IPCOMP transform values
|
||||
* RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.5
|
||||
*/
|
||||
|
||||
enum ipsec_comp_algo {
|
||||
IPSCOMP_NONE = 0,
|
||||
IPCOMP_OUI = 1,
|
||||
IPCOMP_DEFLATE = 2,
|
||||
IPCOMP_LZS = 3,
|
||||
IPCOMP_LZJH = 4
|
||||
};
|
||||
|
||||
/* Identification type values
|
||||
* RFC 2407 The Internet IP security Domain of Interpretation for ISAKMP 4.6.2.1
|
||||
*/
|
||||
|
||||
enum ipsec_id_type {
|
||||
ID_IMPOSSIBLE= (-2), /* private to Pluto */
|
||||
ID_MYID= (-1), /* private to Pluto */
|
||||
ID_NONE= 0, /* private to Pluto */
|
||||
ID_IPV4_ADDR= 1,
|
||||
ID_FQDN= 2,
|
||||
ID_USER_FQDN= 3,
|
||||
ID_IPV4_ADDR_SUBNET= 4,
|
||||
ID_IPV6_ADDR= 5,
|
||||
ID_IPV6_ADDR_SUBNET= 6,
|
||||
ID_IPV4_ADDR_RANGE= 7,
|
||||
ID_IPV6_ADDR_RANGE= 8,
|
||||
ID_DER_ASN1_DN= 9,
|
||||
ID_DER_ASN1_GN= 10,
|
||||
ID_KEY_ID= 11
|
||||
};
|
||||
|
||||
/* Certificate type values
|
||||
* RFC 2408 ISAKMP, chapter 3.9
|
||||
*/
|
||||
enum ipsec_cert_type {
|
||||
CERT_NONE= 0,
|
||||
CERT_PKCS7_WRAPPED_X509= 1, /* self-signed certificate from disk */
|
||||
CERT_PGP= 2,
|
||||
CERT_DNS_SIGNED_KEY= 3, /* KEY RR from DNS */
|
||||
CERT_X509_SIGNATURE= 4,
|
||||
CERT_X509_KEY_EXCHANGE= 5,
|
||||
CERT_KERBEROS_TOKENS= 6,
|
||||
CERT_CRL= 7,
|
||||
CERT_ARL= 8,
|
||||
CERT_SPKI= 9,
|
||||
CERT_X509_ATTRIBUTE= 10,
|
||||
CERT_RAW_RSA= 11, /* raw RSA from config file */
|
||||
};
|
||||
|
||||
/* a SIG record in ASCII */
|
||||
struct ipsec_dns_sig {
|
||||
char fqdn[256];
|
||||
char dns_sig[768]; /* empty string if not signed */
|
||||
};
|
||||
|
||||
struct ipsec_raw_key {
|
||||
char id_name[256];
|
||||
char fs_keyid[8];
|
||||
};
|
||||
|
||||
struct ipsec_identity {
|
||||
enum ipsec_id_type ii_type;
|
||||
enum ipsec_cert_type ii_format;
|
||||
union {
|
||||
struct ipsec_dns_sig ipsec_dns_signed;
|
||||
/* some thing for PGP */
|
||||
/* some thing for PKIX */
|
||||
struct ipsec_raw_key ipsec_raw_key;
|
||||
} ii_credential;
|
||||
};
|
||||
|
||||
#define IPSEC_MAX_CREDENTIALS 32
|
||||
|
||||
struct ipsec_policy_cmd_query {
|
||||
struct ipsec_policy_msg_head head;
|
||||
|
||||
/* Query section */
|
||||
ip_address query_local; /* us */
|
||||
ip_address query_remote; /* them */
|
||||
u_short src_port, dst_port;
|
||||
|
||||
/* Answer section */
|
||||
enum ipsec_privacy_quality strength;
|
||||
enum ipsec_bandwidth_quality bandwidth;
|
||||
enum ipsec_authentication_algo auth_detail;
|
||||
enum ipsec_cipher_algo esp_detail;
|
||||
enum ipsec_comp_algo comp_detail;
|
||||
|
||||
int credential_count;
|
||||
|
||||
struct ipsec_identity credentials[IPSEC_MAX_CREDENTIALS];
|
||||
};
|
||||
|
||||
#define IPSEC_POLICY_SOCKET "/var/run/pluto.info"
|
||||
|
||||
/* prototypes */
|
||||
extern err_t ipsec_policy_lookup(int fd, struct ipsec_policy_cmd_query *result);
|
||||
extern err_t ipsec_policy_init(void);
|
||||
extern err_t ipsec_policy_final(void);
|
||||
extern err_t ipsec_policy_readmsg(int policysock,
|
||||
unsigned char *buf, size_t buflen);
|
||||
extern err_t ipsec_policy_sendrecv(unsigned char *buf, size_t buflen);
|
||||
extern err_t ipsec_policy_cgilookup(struct ipsec_policy_cmd_query *result);
|
||||
|
||||
|
||||
extern const char *ipsec_policy_version_code(void);
|
||||
extern const char *ipsec_policy_version_string(void);
|
||||
|
||||
#endif /* _IPSEC_POLICY_H */
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* @(#) prototypes for FreeSWAN functions
|
||||
*
|
||||
* Copyright (C) 2001 Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_proto.h,v 1.3 2004/06/13 19:55:14 as Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_PROTO_H_
|
||||
|
||||
#include "ipsec_param.h"
|
||||
|
||||
/*
|
||||
* This file is a kernel only file that declares prototypes for
|
||||
* all intra-module function calls and global data structures.
|
||||
*
|
||||
* Include this file last.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ipsec_init.c */
|
||||
extern struct prng ipsec_prng;
|
||||
|
||||
/* ipsec_sa.c */
|
||||
extern struct ipsec_sa *ipsec_sadb_hash[SADB_HASHMOD];
|
||||
extern spinlock_t tdb_lock;
|
||||
extern int ipsec_sadb_init(void);
|
||||
|
||||
extern struct ipsec_sa *ipsec_sa_getbyid(struct sa_id*);
|
||||
extern int ipsec_sa_put(struct ipsec_sa *);
|
||||
extern /* void */ int ipsec_sa_del(struct ipsec_sa *);
|
||||
extern /* void */ int ipsec_sa_delchain(struct ipsec_sa *);
|
||||
extern /* void */ int ipsec_sa_add(struct ipsec_sa *);
|
||||
|
||||
extern int ipsec_sadb_cleanup(__u8);
|
||||
extern int ipsec_sa_wipe(struct ipsec_sa *);
|
||||
|
||||
/* debug declarations */
|
||||
|
||||
/* ipsec_proc.c */
|
||||
extern int ipsec_proc_init(void);
|
||||
extern void ipsec_proc_cleanup(void);
|
||||
|
||||
/* ipsec_radij.c */
|
||||
extern int ipsec_makeroute(struct sockaddr_encap *ea,
|
||||
struct sockaddr_encap *em,
|
||||
struct sa_id said,
|
||||
uint32_t pid,
|
||||
struct sk_buff *skb,
|
||||
struct ident *ident_s,
|
||||
struct ident *ident_d);
|
||||
|
||||
extern int ipsec_breakroute(struct sockaddr_encap *ea,
|
||||
struct sockaddr_encap *em,
|
||||
struct sk_buff **first,
|
||||
struct sk_buff **last);
|
||||
|
||||
int ipsec_radijinit(void);
|
||||
int ipsec_cleareroutes(void);
|
||||
int ipsec_radijcleanup(void);
|
||||
|
||||
/* ipsec_life.c */
|
||||
extern enum ipsec_life_alive ipsec_lifetime_check(struct ipsec_lifetime64 *il64,
|
||||
const char *lifename,
|
||||
const char *saname,
|
||||
enum ipsec_life_type ilt,
|
||||
enum ipsec_direction idir,
|
||||
struct ipsec_sa *ips);
|
||||
|
||||
|
||||
extern int ipsec_lifetime_format(char *buffer,
|
||||
int buflen,
|
||||
char *lifename,
|
||||
enum ipsec_life_type timebaselife,
|
||||
struct ipsec_lifetime64 *lifetime);
|
||||
|
||||
extern void ipsec_lifetime_update_hard(struct ipsec_lifetime64 *lifetime,
|
||||
__u64 newvalue);
|
||||
|
||||
extern void ipsec_lifetime_update_soft(struct ipsec_lifetime64 *lifetime,
|
||||
__u64 newvalue);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
|
||||
extern int debug_xform;
|
||||
extern int debug_eroute;
|
||||
extern int debug_spi;
|
||||
extern int debug_netlink;
|
||||
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
|
||||
|
||||
|
||||
#define _IPSEC_PROTO_H
|
||||
#endif /* _IPSEC_PROTO_H_ */
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* @(#) Definitions relevant to the IPSEC <> radij tree interfacing
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_radij.h,v 1.3 2004/04/28 05:44:29 as Exp $
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_RADIJ_H
|
||||
|
||||
#include <freeswan.h>
|
||||
|
||||
int ipsec_walk(char *);
|
||||
|
||||
int ipsec_rj_walker_procprint(struct radij_node *, void *);
|
||||
int ipsec_rj_walker_delete(struct radij_node *, void *);
|
||||
|
||||
/* This structure is used to pass information between
|
||||
* ipsec_eroute_get_info and ipsec_rj_walker_procprint
|
||||
* (through rj_walktree) and between calls of ipsec_rj_walker_procprint.
|
||||
*/
|
||||
struct wsbuf
|
||||
{
|
||||
/* from caller of ipsec_eroute_get_info: */
|
||||
char *const buffer; /* start of buffer provided */
|
||||
const int length; /* length of buffer provided */
|
||||
const off_t offset; /* file position of first character of interest */
|
||||
/* accumulated by ipsec_rj_walker_procprint: */
|
||||
int len; /* number of character filled into buffer */
|
||||
off_t begin; /* file position contained in buffer[0] (<=offset) */
|
||||
};
|
||||
|
||||
|
||||
extern struct radij_node_head *rnh;
|
||||
extern spinlock_t eroute_lock;
|
||||
|
||||
struct eroute * ipsec_findroute(struct sockaddr_encap *);
|
||||
|
||||
#define O1(x) (int)(((x)>>24)&0xff)
|
||||
#define O2(x) (int)(((x)>>16)&0xff)
|
||||
#define O3(x) (int)(((x)>>8)&0xff)
|
||||
#define O4(x) (int)(((x))&0xff)
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int debug_radij;
|
||||
void rj_dumptrees(void);
|
||||
|
||||
#define DB_RJ_DUMPTREES 0x0001
|
||||
#define DB_RJ_FINDROUTE 0x0002
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
#define _IPSEC_RADIJ_H
|
||||
#endif
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_rcv.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
#define DB_RX_PKTRX 0x0001
|
||||
#define DB_RX_PKTRX2 0x0002
|
||||
#define DB_RX_DMP 0x0004
|
||||
#define DB_RX_IPSA 0x0010
|
||||
#define DB_RX_XF 0x0020
|
||||
#define DB_RX_IPAD 0x0040
|
||||
#define DB_RX_INAU 0x0080
|
||||
#define DB_RX_OINFO 0x0100
|
||||
#define DB_RX_OINFO2 0x0200
|
||||
#define DB_RX_OH 0x0400
|
||||
#define DB_RX_REPLAY 0x0800
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/* struct options; */
|
||||
|
||||
#define __NO_VERSION__
|
||||
#include <linux/module.h>
|
||||
#include <linux/config.h> /* for CONFIG_IP_FORWARD */
|
||||
#include <linux/version.h>
|
||||
#include <freeswan.h>
|
||||
|
||||
#define IPSEC_BIRTH_TEMPLATE_MAXLEN 256
|
||||
|
||||
struct ipsec_birth_reply {
|
||||
int packet_template_len;
|
||||
unsigned char packet_template[IPSEC_BIRTH_TEMPLATE_MAXLEN];
|
||||
};
|
||||
|
||||
extern struct ipsec_birth_reply ipsec_ipv4_birth_packet;
|
||||
extern struct ipsec_birth_reply ipsec_ipv6_birth_packet;
|
||||
|
||||
extern int
|
||||
#ifdef PROTO_HANDLER_SINGLE_PARM
|
||||
ipsec_rcv(struct sk_buff *skb);
|
||||
#else /* PROTO_HANDLER_SINGLE_PARM */
|
||||
ipsec_rcv(struct sk_buff *skb,
|
||||
#ifdef NET_21
|
||||
unsigned short xlen);
|
||||
#else /* NET_21 */
|
||||
struct device *dev,
|
||||
struct options *opt,
|
||||
__u32 daddr,
|
||||
unsigned short len,
|
||||
__u32 saddr,
|
||||
int redo,
|
||||
struct inet_protocol *protocol);
|
||||
#endif /* NET_21 */
|
||||
#endif /* PROTO_HANDLER_SINGLE_PARM */
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int debug_rcv;
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
extern int sysctl_ipsec_inbound_policy_check;
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_rcv.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.17 2002/09/03 16:32:32 mcr
|
||||
* definitions of ipsec_birth_reply.
|
||||
*
|
||||
* Revision 1.16 2002/05/14 02:36:00 rgb
|
||||
* Change references to _TDB to _IPSA.
|
||||
*
|
||||
* Revision 1.15 2002/04/24 07:36:47 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_rcv.h,v
|
||||
*
|
||||
* Revision 1.14 2001/09/07 22:15:48 rgb
|
||||
* Fix for removal of transport layer protocol handler arg in 2.4.4.
|
||||
*
|
||||
* Revision 1.13 2001/06/14 19:35:09 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.12 2001/03/16 07:36:44 rgb
|
||||
* Fixed #endif comment to sate compiler.
|
||||
*
|
||||
* Revision 1.11 2000/09/21 04:34:21 rgb
|
||||
* Moved declaration of sysctl_ipsec_inbound_policy_check outside
|
||||
* CONFIG_IPSEC_DEBUG. (MB)
|
||||
*
|
||||
* Revision 1.10 2000/09/18 02:36:10 rgb
|
||||
* Exported sysctl_ipsec_inbound_policy_check for skb_decompress().
|
||||
*
|
||||
* Revision 1.9 2000/09/08 19:12:56 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.8 1999/11/18 04:09:19 rgb
|
||||
* Replaced all kernel version macros to shorter, readable form.
|
||||
*
|
||||
* Revision 1.7 1999/05/25 01:45:37 rgb
|
||||
* Fix version macros for 2.0.x as a module.
|
||||
*
|
||||
* Revision 1.6 1999/05/08 21:24:27 rgb
|
||||
* Add includes for 2.2.x include into net/ipv4/protocol.c
|
||||
*
|
||||
* Revision 1.5 1999/05/05 22:02:32 rgb
|
||||
* Add a quick and dirty port to 2.2 kernels by Marc Boucher <[email protected]>.
|
||||
*
|
||||
* Revision 1.4 1999/04/11 00:28:59 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.3 1999/04/06 04:54:27 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.2 1999/01/22 20:06:59 rgb
|
||||
* Fixed cut-and-paste error from ipsec_esp.h.
|
||||
*
|
||||
* Revision 1.1 1999/01/21 20:29:12 rgb
|
||||
* Converted from transform switching to algorithm switching.
|
||||
*
|
||||
* Log: ipsec_esp.h,v
|
||||
* Revision 1.4 1998/08/12 00:07:32 rgb
|
||||
* Added data structures for new xforms: null, {,3}dessha1.
|
||||
*
|
||||
* Revision 1.3 1998/07/14 15:57:01 rgb
|
||||
* Add #ifdef __KERNEL__ to protect kernel-only structures.
|
||||
*
|
||||
* Revision 1.2 1998/06/25 19:33:46 rgb
|
||||
* Add prototype for protocol receive function.
|
||||
* Rearrange for more logical layout.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:45 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.6 1998/06/05 02:28:08 rgb
|
||||
* Minor comment fix.
|
||||
*
|
||||
* Revision 1.5 1998/05/27 22:34:00 rgb
|
||||
* Changed structures to accomodate key separation.
|
||||
*
|
||||
* Revision 1.4 1998/05/18 22:28:43 rgb
|
||||
* Disable key printing facilities from /proc/net/ipsec_*.
|
||||
*
|
||||
* Revision 1.3 1998/04/21 21:29:07 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.2 1998/04/12 22:03:20 rgb
|
||||
* Updated ESP-3DES-HMAC-MD5-96,
|
||||
* ESP-DES-HMAC-MD5-96,
|
||||
* AH-HMAC-MD5-96,
|
||||
* AH-HMAC-SHA1-96 since Henry started freeswan cvs repository
|
||||
* from old standards (RFC182[5-9] to new (as of March 1998) drafts.
|
||||
*
|
||||
* Fixed eroute references in /proc/net/ipsec*.
|
||||
*
|
||||
* Started to patch module unloading memory leaks in ipsec_netlink and
|
||||
* radij tree unloading.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:00 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:02 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.5 1997/06/03 04:24:48 ji
|
||||
* Added ESP-3DES-MD5-96 transform.
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* Added definitions for new ESP transforms.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:35:48 ji
|
||||
* Minor Cleanup.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,338 +0,0 @@
|
||||
/*
|
||||
* @(#) Definitions of IPsec Security Association (ipsec_sa)
|
||||
*
|
||||
* Copyright (C) 2001, 2002, 2003
|
||||
* Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_sa.h,v 1.3 2004/04/28 08:07:11 as Exp $
|
||||
*
|
||||
* This file derived from ipsec_xform.h on 2001/9/18 by mcr.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file describes the IPsec Security Association Structure.
|
||||
*
|
||||
* This structure keeps track of a single transform that may be done
|
||||
* to a set of packets. It can describe applying the transform or
|
||||
* apply the reverse. (e.g. compression vs expansion). However, it
|
||||
* only describes one at a time. To describe both, two structures would
|
||||
* be used, but since the sides of the transform are performed
|
||||
* on different machines typically it is usual to have only one side
|
||||
* of each association.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_SA_H_
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include "ipsec_stats.h"
|
||||
#include "ipsec_life.h"
|
||||
#include "ipsec_eroute.h"
|
||||
#endif /* __KERNEL__ */
|
||||
#include "ipsec_param.h"
|
||||
|
||||
|
||||
/* SAs are held in a table.
|
||||
* Entries in this table are referenced by IPsecSAref_t values.
|
||||
* IPsecSAref_t values are conceptually subscripts. Because
|
||||
* we want to allocate the table piece-meal, the subscripting
|
||||
* is implemented with two levels, a bit like paged virtual memory.
|
||||
* This representation mechanism is known as an Iliffe Vector.
|
||||
*
|
||||
* The Main table (AKA the refTable) consists of 2^IPSEC_SA_REF_MAINTABLE_IDX_WIDTH
|
||||
* pointers to subtables.
|
||||
* Each subtable has 2^IPSEC_SA_REF_SUBTABLE_IDX_WIDTH entries, each of which
|
||||
* is a pointer to an SA.
|
||||
*
|
||||
* An IPsecSAref_t contains either an exceptional value (signified by the
|
||||
* high-order bit being on) or a reference to a table entry. A table entry
|
||||
* reference has the subtable subscript in the low-order
|
||||
* IPSEC_SA_REF_SUBTABLE_IDX_WIDTH bits and the Main table subscript
|
||||
* in the next lowest IPSEC_SA_REF_MAINTABLE_IDX_WIDTH bits.
|
||||
*
|
||||
* The Maintable entry for an IPsecSAref_t x, a pointer to its subtable, is
|
||||
* IPsecSAref2table(x). It is of type struct IPsecSArefSubTable *.
|
||||
*
|
||||
* The pointer to the SA for x is IPsecSAref2SA(x). It is of type
|
||||
* struct ipsec_sa*. The macro definition clearly shows the two-level
|
||||
* access needed to find the SA pointer.
|
||||
*
|
||||
* The Maintable is allocated when IPsec is initialized.
|
||||
* Each subtable is allocated when needed, but the first is allocated
|
||||
* when IPsec is initialized.
|
||||
*
|
||||
* IPsecSAref_t is designed to be smaller than an NFmark so that
|
||||
* they can be stored in NFmarks and still leave a few bits for other
|
||||
* purposes. The spare bits are in the low order of the NFmark
|
||||
* but in the high order of the IPsecSAref_t, so conversion is required.
|
||||
* We pick the upper bits of NFmark on the theory that they are less likely to
|
||||
* interfere with more pedestrian uses of nfmark.
|
||||
*/
|
||||
|
||||
|
||||
typedef unsigned short int IPsecRefTableUnusedCount;
|
||||
|
||||
#define IPSEC_SA_REF_TABLE_NUM_ENTRIES (1 << IPSEC_SA_REF_TABLE_IDX_WIDTH)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#if ((IPSEC_SA_REF_TABLE_IDX_WIDTH - (1 + IPSEC_SA_REF_MAINTABLE_IDX_WIDTH)) < 0)
|
||||
#error "IPSEC_SA_REF_TABLE_IDX_WIDTH("IPSEC_SA_REF_TABLE_IDX_WIDTH") MUST be < 1 + IPSEC_SA_REF_MAINTABLE_IDX_WIDTH("IPSEC_SA_REF_MAINTABLE_IDX_WIDTH")"
|
||||
#endif
|
||||
|
||||
#define IPSEC_SA_REF_SUBTABLE_IDX_WIDTH (IPSEC_SA_REF_TABLE_IDX_WIDTH - IPSEC_SA_REF_MAINTABLE_IDX_WIDTH)
|
||||
|
||||
#define IPSEC_SA_REF_MAINTABLE_NUM_ENTRIES (1 << IPSEC_SA_REF_MAINTABLE_IDX_WIDTH)
|
||||
#define IPSEC_SA_REF_SUBTABLE_NUM_ENTRIES (1 << IPSEC_SA_REF_SUBTABLE_IDX_WIDTH)
|
||||
|
||||
#ifdef CONFIG_NETFILTER
|
||||
#define IPSEC_SA_REF_HOST_FIELD(x) ((struct sk_buff*)(x))->nfmark
|
||||
#define IPSEC_SA_REF_HOST_FIELD_TYPE typeof(IPSEC_SA_REF_HOST_FIELD(NULL))
|
||||
#else /* CONFIG_NETFILTER */
|
||||
/* just make it work for now, it doesn't matter, since there is no nfmark */
|
||||
#define IPSEC_SA_REF_HOST_FIELD_TYPE unsigned long
|
||||
#endif /* CONFIG_NETFILTER */
|
||||
#define IPSEC_SA_REF_HOST_FIELD_WIDTH (8 * sizeof(IPSEC_SA_REF_HOST_FIELD_TYPE))
|
||||
#define IPSEC_SA_REF_FIELD_WIDTH (8 * sizeof(IPsecSAref_t))
|
||||
|
||||
#define IPSEC_SA_REF_MASK (IPSEC_SAREF_NULL >> (IPSEC_SA_REF_FIELD_WIDTH - IPSEC_SA_REF_TABLE_IDX_WIDTH))
|
||||
#define IPSEC_SA_REF_TABLE_MASK ((IPSEC_SAREF_NULL >> (IPSEC_SA_REF_FIELD_WIDTH - IPSEC_SA_REF_MAINTABLE_IDX_WIDTH)) << IPSEC_SA_REF_SUBTABLE_IDX_WIDTH)
|
||||
#define IPSEC_SA_REF_ENTRY_MASK (IPSEC_SAREF_NULL >> (IPSEC_SA_REF_FIELD_WIDTH - IPSEC_SA_REF_SUBTABLE_IDX_WIDTH))
|
||||
|
||||
#define IPsecSAref2table(x) (((x) & IPSEC_SA_REF_TABLE_MASK) >> IPSEC_SA_REF_SUBTABLE_IDX_WIDTH)
|
||||
#define IPsecSAref2entry(x) ((x) & IPSEC_SA_REF_ENTRY_MASK)
|
||||
#define IPsecSArefBuild(x,y) (((x) << IPSEC_SA_REF_SUBTABLE_IDX_WIDTH) + (y))
|
||||
|
||||
#define IPsecSAref2SA(x) (ipsec_sadb.refTable[IPsecSAref2table(x)]->entry[IPsecSAref2entry(x)])
|
||||
#define IPsecSA2SAref(x) ((x)->ips_ref)
|
||||
|
||||
#define EMT_INBOUND 0x01 /* SA direction, 1=inbound */
|
||||
|
||||
/* 'struct ipsec_sa' should be 64bit aligned when allocated. */
|
||||
struct ipsec_sa
|
||||
{
|
||||
IPsecSAref_t ips_ref; /* reference table entry number */
|
||||
atomic_t ips_refcount; /* reference count for this struct */
|
||||
struct ipsec_sa *ips_hnext; /* next in hash chain */
|
||||
struct ipsec_sa *ips_inext; /* pointer to next xform */
|
||||
struct ipsec_sa *ips_onext; /* pointer to prev xform */
|
||||
|
||||
struct ifnet *ips_rcvif; /* related rcv encap interface */
|
||||
|
||||
struct sa_id ips_said; /* SA ID */
|
||||
|
||||
__u32 ips_seq; /* seq num of msg that initiated this SA */
|
||||
__u32 ips_pid; /* PID of process that initiated this SA */
|
||||
__u8 ips_authalg; /* auth algorithm for this SA */
|
||||
__u8 ips_encalg; /* enc algorithm for this SA */
|
||||
|
||||
struct ipsec_stats ips_errs;
|
||||
|
||||
__u8 ips_replaywin; /* replay window size */
|
||||
__u8 ips_state; /* state of SA */
|
||||
__u32 ips_replaywin_lastseq; /* last pkt sequence num */
|
||||
__u64 ips_replaywin_bitmap; /* bitmap of received pkts */
|
||||
__u32 ips_replaywin_maxdiff; /* max pkt sequence difference */
|
||||
|
||||
__u32 ips_flags; /* generic xform flags */
|
||||
|
||||
|
||||
struct ipsec_lifetimes ips_life; /* lifetime records */
|
||||
|
||||
/* selector information */
|
||||
struct sockaddr*ips_addr_s; /* src sockaddr */
|
||||
struct sockaddr*ips_addr_d; /* dst sockaddr */
|
||||
struct sockaddr*ips_addr_p; /* proxy sockaddr */
|
||||
__u16 ips_addr_s_size;
|
||||
__u16 ips_addr_d_size;
|
||||
__u16 ips_addr_p_size;
|
||||
ip_address ips_flow_s;
|
||||
ip_address ips_flow_d;
|
||||
ip_address ips_mask_s;
|
||||
ip_address ips_mask_d;
|
||||
|
||||
__u16 ips_key_bits_a; /* size of authkey in bits */
|
||||
__u16 ips_auth_bits; /* size of authenticator in bits */
|
||||
__u16 ips_key_bits_e; /* size of enckey in bits */
|
||||
__u16 ips_iv_bits; /* size of IV in bits */
|
||||
__u8 ips_iv_size;
|
||||
__u16 ips_key_a_size;
|
||||
__u16 ips_key_e_size;
|
||||
|
||||
caddr_t ips_key_a; /* authentication key */
|
||||
caddr_t ips_key_e; /* encryption key */
|
||||
caddr_t ips_iv; /* Initialisation Vector */
|
||||
|
||||
struct ident ips_ident_s; /* identity src */
|
||||
struct ident ips_ident_d; /* identity dst */
|
||||
|
||||
#ifdef CONFIG_IPSEC_IPCOMP
|
||||
__u16 ips_comp_adapt_tries; /* ipcomp self-adaption tries */
|
||||
__u16 ips_comp_adapt_skip; /* ipcomp self-adaption to-skip */
|
||||
__u64 ips_comp_ratio_cbytes; /* compressed bytes */
|
||||
__u64 ips_comp_ratio_dbytes; /* decompressed (or uncompressed) bytes */
|
||||
#endif /* CONFIG_IPSEC_IPCOMP */
|
||||
|
||||
#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
||||
__u8 ips_natt_type;
|
||||
__u8 ips_natt_reserved[3];
|
||||
__u16 ips_natt_sport;
|
||||
__u16 ips_natt_dport;
|
||||
|
||||
struct sockaddr *ips_natt_oa;
|
||||
__u16 ips_natt_oa_size;
|
||||
__u16 ips_natt_reserved2;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
__u32 ips_sens_dpd;
|
||||
__u8 ips_sens_sens_level;
|
||||
__u8 ips_sens_sens_len;
|
||||
__u64* ips_sens_sens_bitmap;
|
||||
__u8 ips_sens_integ_level;
|
||||
__u8 ips_sens_integ_len;
|
||||
__u64* ips_sens_integ_bitmap;
|
||||
#endif
|
||||
struct ipsec_alg_enc *ips_alg_enc;
|
||||
struct ipsec_alg_auth *ips_alg_auth;
|
||||
IPsecSAref_t ips_ref_rel;
|
||||
};
|
||||
|
||||
struct IPsecSArefSubTable
|
||||
{
|
||||
struct ipsec_sa* entry[IPSEC_SA_REF_SUBTABLE_NUM_ENTRIES];
|
||||
};
|
||||
|
||||
struct ipsec_sadb {
|
||||
struct IPsecSArefSubTable* refTable[IPSEC_SA_REF_MAINTABLE_NUM_ENTRIES];
|
||||
IPsecSAref_t refFreeList[IPSEC_SA_REF_FREELIST_NUM_ENTRIES];
|
||||
int refFreeListHead;
|
||||
int refFreeListTail;
|
||||
IPsecSAref_t refFreeListCont;
|
||||
IPsecSAref_t said_hash[SADB_HASHMOD];
|
||||
spinlock_t sadb_lock;
|
||||
};
|
||||
|
||||
extern struct ipsec_sadb ipsec_sadb;
|
||||
|
||||
extern int ipsec_SAref_recycle(void);
|
||||
extern int ipsec_SArefSubTable_alloc(unsigned table);
|
||||
extern int ipsec_saref_freelist_init(void);
|
||||
extern int ipsec_sadb_init(void);
|
||||
extern struct ipsec_sa *ipsec_sa_alloc(int*error); /* pass in error var by pointer */
|
||||
extern IPsecSAref_t ipsec_SAref_alloc(int*erorr); /* pass in error var by pointer */
|
||||
extern int ipsec_sa_free(struct ipsec_sa* ips);
|
||||
extern struct ipsec_sa *ipsec_sa_getbyid(struct sa_id *said);
|
||||
extern int ipsec_sa_put(struct ipsec_sa *ips);
|
||||
extern int ipsec_sa_add(struct ipsec_sa *ips);
|
||||
extern int ipsec_sa_del(struct ipsec_sa *ips);
|
||||
extern int ipsec_sa_delchain(struct ipsec_sa *ips);
|
||||
extern int ipsec_sadb_cleanup(__u8 proto);
|
||||
extern int ipsec_sadb_free(void);
|
||||
extern int ipsec_sa_wipe(struct ipsec_sa *ips);
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
enum ipsec_direction {
|
||||
ipsec_incoming = 1,
|
||||
ipsec_outgoing = 2
|
||||
};
|
||||
|
||||
#define _IPSEC_SA_H_
|
||||
#endif /* _IPSEC_SA_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_sa.h,v $
|
||||
* Revision 1.3 2004/04/28 08:07:11 as
|
||||
* added dhr's freeswan-2.06 changes
|
||||
*
|
||||
* Revision 1.2 2004/03/22 21:53:18 as
|
||||
* merged alg-0.8.1 branch with HEAD
|
||||
*
|
||||
* Revision 1.1.2.1.2.1 2004/03/16 09:48:18 as
|
||||
* alg-0.8.1rc12 patch merged
|
||||
*
|
||||
* Revision 1.1.2.1 2004/03/15 22:30:06 as
|
||||
* nat-0.6c patch merged
|
||||
*
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.15 2003/05/11 00:53:09 mcr
|
||||
* IPsecSAref_t and macros were moved to freeswan.h.
|
||||
*
|
||||
* Revision 1.14 2003/02/12 19:31:55 rgb
|
||||
* Fixed bug in "file seen" machinery.
|
||||
* Updated copyright year.
|
||||
*
|
||||
* Revision 1.13 2003/01/30 02:31:52 rgb
|
||||
*
|
||||
* Re-wrote comments describing SAref system for accuracy.
|
||||
* Rename SAref table macro names for clarity.
|
||||
* Convert IPsecSAref_t from signed to unsigned to fix apparent SAref exhaustion bug.
|
||||
* Transmit error code through to caller from callee for better diagnosis of problems.
|
||||
* Enclose all macro arguments in parens to avoid any possible obscrure bugs.
|
||||
*
|
||||
* Revision 1.12 2002/10/07 18:31:19 rgb
|
||||
* Change comment to reflect the flexible nature of the main and sub-table widths.
|
||||
* Added a counter for the number of unused entries in each subtable.
|
||||
* Further break up host field type macro to host field.
|
||||
* Move field width sanity checks to ipsec_sa.c
|
||||
* Define a mask for an entire saref.
|
||||
*
|
||||
* Revision 1.11 2002/09/20 15:40:33 rgb
|
||||
* Re-write most of the SAref macros and types to eliminate any pointer references to Entrys.
|
||||
* Fixed SAref/nfmark macros.
|
||||
* Rework saref freeslist.
|
||||
* Place all ipsec sadb globals into one struct.
|
||||
* Restrict some bits to kernel context for use to klips utils.
|
||||
*
|
||||
* Revision 1.10 2002/09/20 05:00:34 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.9 2002/09/17 17:19:29 mcr
|
||||
* make it compile even if there is no netfilter - we lost
|
||||
* functionality, but it works, especially on 2.2.
|
||||
*
|
||||
* Revision 1.8 2002/07/28 22:59:53 mcr
|
||||
* clarified/expanded one comment.
|
||||
*
|
||||
* Revision 1.7 2002/07/26 08:48:31 rgb
|
||||
* Added SA ref table code.
|
||||
*
|
||||
* Revision 1.6 2002/05/31 17:27:48 rgb
|
||||
* Comment fix.
|
||||
*
|
||||
* Revision 1.5 2002/05/27 18:55:03 rgb
|
||||
* Remove final vistiges of tdb references via IPSEC_KLIPS1_COMPAT.
|
||||
*
|
||||
* Revision 1.4 2002/05/23 07:13:36 rgb
|
||||
* Convert "usecount" to "refcount" to remove ambiguity.
|
||||
*
|
||||
* Revision 1.3 2002/04/24 07:36:47 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_sa.h,v
|
||||
*
|
||||
* Revision 1.2 2001/11/26 09:16:15 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.1.2.1 2001/09/25 02:24:58 mcr
|
||||
* struct tdb -> struct ipsec_sa.
|
||||
* sa(tdb) manipulation functions renamed and moved to ipsec_sa.c
|
||||
* ipsec_xform.c removed. header file still contains useful things.
|
||||
*
|
||||
*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*
|
||||
*/
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* RCSID $Id: ipsec_sha1.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Here is the original comment from the distribution:
|
||||
|
||||
SHA-1 in C
|
||||
By Steve Reid <[email protected]>
|
||||
100% Public Domain
|
||||
|
||||
* Adapted for use by the IPSEC code by John Ioannidis
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _IPSEC_SHA1_H_
|
||||
#define _IPSEC_SHA1_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__u32 state[5];
|
||||
__u32 count[2];
|
||||
__u8 buffer[64];
|
||||
} SHA1_CTX;
|
||||
|
||||
void SHA1Transform(__u32 state[5], __u8 buffer[64]);
|
||||
void SHA1Init(void *context);
|
||||
void SHA1Update(void *context, unsigned char *data, __u32 len);
|
||||
void SHA1Final(unsigned char digest[20], void *context);
|
||||
|
||||
|
||||
#endif /* _IPSEC_SHA1_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_sha1.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.7 2002/09/10 01:45:09 mcr
|
||||
* changed type of MD5_CTX and SHA1_CTX to void * so that
|
||||
* the function prototypes would match, and could be placed
|
||||
* into a pointer to a function.
|
||||
*
|
||||
* Revision 1.6 2002/04/24 07:36:47 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_sha1.h,v
|
||||
*
|
||||
* Revision 1.5 1999/12/13 13:59:13 rgb
|
||||
* Quick fix to argument size to Update bugs.
|
||||
*
|
||||
* Revision 1.4 1999/12/07 18:16:23 rgb
|
||||
* Fixed comments at end of #endif lines.
|
||||
*
|
||||
* Revision 1.3 1999/04/06 04:54:27 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.2 1998/11/30 13:22:54 rgb
|
||||
* Rationalised all the klips kernel file headers. They are much shorter
|
||||
* now and won't conflict under RH5.2.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:50 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.2 1998/04/23 20:54:05 rgb
|
||||
* Fixed md5 and sha1 include file nesting issues, to be cleaned up when
|
||||
* verified.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:04:21 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
* these two include files modified not to include others except in kernel
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:04 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* New transform
|
||||
*
|
||||
*/
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* @(#) definition of ipsec_stats structure
|
||||
*
|
||||
* Copyright (C) 2001 Richard Guy Briggs <[email protected]>
|
||||
* and Michael Richardson <[email protected]>
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_stats.h,v 1.2 2004/03/30 19:33:52 as Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file describes the errors/statistics that FreeSWAN collects.
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_STATS_H_
|
||||
|
||||
struct ipsec_stats {
|
||||
__u32 ips_alg_errs; /* number of algorithm errors */
|
||||
__u32 ips_auth_errs; /* # of authentication errors */
|
||||
__u32 ips_encsize_errs; /* # of encryption size errors*/
|
||||
__u32 ips_encpad_errs; /* # of encryption pad errors*/
|
||||
__u32 ips_replaywin_errs; /* # of pkt sequence errors */
|
||||
};
|
||||
|
||||
extern int ipsec_snprintf(char * buf, ssize_t size, const char *fmt, ...);
|
||||
|
||||
#define _IPSEC_STATS_H_
|
||||
#endif /* _IPSEC_STATS_H_ */
|
||||
@@ -1,265 +0,0 @@
|
||||
/*
|
||||
* IPSEC tunneling code
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_tunnel.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
|
||||
#ifdef NET_21
|
||||
# define DEV_QUEUE_XMIT(skb, device, pri) {\
|
||||
skb->dev = device; \
|
||||
neigh_compat_output(skb); \
|
||||
/* skb->dst->output(skb); */ \
|
||||
}
|
||||
# define ICMP_SEND(skb_in, type, code, info, dev) \
|
||||
icmp_send(skb_in, type, code, htonl(info))
|
||||
# define IP_SEND(skb, dev) \
|
||||
ip_send(skb);
|
||||
#else /* NET_21 */
|
||||
# define DEV_QUEUE_XMIT(skb, device, pri) {\
|
||||
dev_queue_xmit(skb, device, pri); \
|
||||
}
|
||||
# define ICMP_SEND(skb_in, type, code, info, dev) \
|
||||
icmp_send(skb_in, type, code, info, dev)
|
||||
# define IP_SEND(skb, dev) \
|
||||
if(ntohs(iph->tot_len) > physmtu) { \
|
||||
ip_fragment(NULL, skb, dev, 0); \
|
||||
ipsec_kfree_skb(skb); \
|
||||
} else { \
|
||||
dev_queue_xmit(skb, dev, SOPRI_NORMAL); \
|
||||
}
|
||||
#endif /* NET_21 */
|
||||
|
||||
|
||||
/*
|
||||
* Heavily based on drivers/net/new_tunnel.c. Lots
|
||||
* of ideas also taken from the 2.1.x version of drivers/net/shaper.c
|
||||
*/
|
||||
|
||||
struct ipsectunnelconf
|
||||
{
|
||||
__u32 cf_cmd;
|
||||
union
|
||||
{
|
||||
char cfu_name[12];
|
||||
} cf_u;
|
||||
#define cf_name cf_u.cfu_name
|
||||
};
|
||||
|
||||
#define IPSEC_SET_DEV (SIOCDEVPRIVATE)
|
||||
#define IPSEC_DEL_DEV (SIOCDEVPRIVATE + 1)
|
||||
#define IPSEC_CLR_DEV (SIOCDEVPRIVATE + 2)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/version.h>
|
||||
#ifndef KERNEL_VERSION
|
||||
# define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
|
||||
#endif
|
||||
struct ipsecpriv
|
||||
{
|
||||
struct sk_buff_head sendq;
|
||||
struct device *dev;
|
||||
struct wait_queue *wait_queue;
|
||||
char locked;
|
||||
int (*hard_start_xmit) (struct sk_buff *skb,
|
||||
struct device *dev);
|
||||
int (*hard_header) (struct sk_buff *skb,
|
||||
struct device *dev,
|
||||
unsigned short type,
|
||||
void *daddr,
|
||||
void *saddr,
|
||||
unsigned len);
|
||||
#ifdef NET_21
|
||||
int (*rebuild_header)(struct sk_buff *skb);
|
||||
#else /* NET_21 */
|
||||
int (*rebuild_header)(void *buff, struct device *dev,
|
||||
unsigned long raddr, struct sk_buff *skb);
|
||||
#endif /* NET_21 */
|
||||
int (*set_mac_address)(struct device *dev, void *addr);
|
||||
#ifndef NET_21
|
||||
void (*header_cache_bind)(struct hh_cache **hhp, struct device *dev,
|
||||
unsigned short htype, __u32 daddr);
|
||||
#endif /* !NET_21 */
|
||||
void (*header_cache_update)(struct hh_cache *hh, struct device *dev, unsigned char * haddr);
|
||||
struct net_device_stats *(*get_stats)(struct device *dev);
|
||||
struct net_device_stats mystats;
|
||||
int mtu; /* What is the desired MTU? */
|
||||
};
|
||||
|
||||
extern char ipsec_tunnel_c_version[];
|
||||
|
||||
extern struct device *ipsecdevices[IPSEC_NUM_IF];
|
||||
|
||||
int ipsec_tunnel_init_devices(void);
|
||||
|
||||
/* void */ int ipsec_tunnel_cleanup_devices(void);
|
||||
|
||||
extern /* void */ int ipsec_init(void);
|
||||
|
||||
extern int ipsec_tunnel_start_xmit(struct sk_buff *skb, struct device *dev);
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
extern int debug_tunnel;
|
||||
extern int sysctl_ipsec_debug_verbose;
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#ifdef CONFIG_IPSEC_DEBUG
|
||||
#define DB_TN_INIT 0x0001
|
||||
#define DB_TN_PROCFS 0x0002
|
||||
#define DB_TN_XMIT 0x0010
|
||||
#define DB_TN_OHDR 0x0020
|
||||
#define DB_TN_CROUT 0x0040
|
||||
#define DB_TN_OXFS 0x0080
|
||||
#define DB_TN_REVEC 0x0100
|
||||
#endif /* CONFIG_IPSEC_DEBUG */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_tunnel.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.28 2003/06/24 20:22:32 mcr
|
||||
* added new global: ipsecdevices[] so that we can keep track of
|
||||
* the ipsecX devices. They will be referenced with dev_hold(),
|
||||
* so 2.2 may need this as well.
|
||||
*
|
||||
* Revision 1.27 2003/04/03 17:38:09 rgb
|
||||
* Centralised ipsec_kfree_skb and ipsec_dev_{get,put}.
|
||||
*
|
||||
* Revision 1.26 2003/02/12 19:32:20 rgb
|
||||
* Updated copyright year.
|
||||
*
|
||||
* Revision 1.25 2002/05/27 18:56:07 rgb
|
||||
* Convert to dynamic ipsec device allocation.
|
||||
*
|
||||
* Revision 1.24 2002/04/24 07:36:48 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_tunnel.h,v
|
||||
*
|
||||
* Revision 1.23 2001/11/06 19:50:44 rgb
|
||||
* Moved IP_SEND, ICMP_SEND, DEV_QUEUE_XMIT macros to ipsec_tunnel.h for
|
||||
* use also by pfkey_v2_parser.c
|
||||
*
|
||||
* Revision 1.22 2001/09/15 16:24:05 rgb
|
||||
* Re-inject first and last HOLD packet when an eroute REPLACE is done.
|
||||
*
|
||||
* Revision 1.21 2001/06/14 19:35:10 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.20 2000/09/15 11:37:02 rgb
|
||||
* Merge in heavily modified Svenning Soerensen's <[email protected]>
|
||||
* IPCOMP zlib deflate code.
|
||||
*
|
||||
* Revision 1.19 2000/09/08 19:12:56 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.18 2000/07/28 13:50:54 rgb
|
||||
* Changed enet_statistics to net_device_stats and added back compatibility
|
||||
* for pre-2.1.19.
|
||||
*
|
||||
* Revision 1.17 1999/11/19 01:12:15 rgb
|
||||
* Purge unneeded proc_info prototypes, now that static linking uses
|
||||
* dynamic proc_info registration.
|
||||
*
|
||||
* Revision 1.16 1999/11/18 18:51:00 rgb
|
||||
* Changed all device registrations for static linking to
|
||||
* dynamic to reduce the number and size of patches.
|
||||
*
|
||||
* Revision 1.15 1999/11/18 04:14:21 rgb
|
||||
* Replaced all kernel version macros to shorter, readable form.
|
||||
* Added CONFIG_PROC_FS compiler directives in case it is shut off.
|
||||
* Added Marc Boucher's 2.3.25 proc patches.
|
||||
*
|
||||
* Revision 1.14 1999/05/25 02:50:10 rgb
|
||||
* Fix kernel version macros for 2.0.x static linking.
|
||||
*
|
||||
* Revision 1.13 1999/05/25 02:41:06 rgb
|
||||
* Add ipsec_klipsdebug support for static linking.
|
||||
*
|
||||
* Revision 1.12 1999/05/05 22:02:32 rgb
|
||||
* Add a quick and dirty port to 2.2 kernels by Marc Boucher <[email protected]>.
|
||||
*
|
||||
* Revision 1.11 1999/04/29 15:19:50 rgb
|
||||
* Add return values to init and cleanup functions.
|
||||
*
|
||||
* Revision 1.10 1999/04/16 16:02:39 rgb
|
||||
* Bump up macro to 4 ipsec I/Fs.
|
||||
*
|
||||
* Revision 1.9 1999/04/15 15:37:25 rgb
|
||||
* Forward check changes from POST1_00 branch.
|
||||
*
|
||||
* Revision 1.5.2.1 1999/04/02 04:26:14 rgb
|
||||
* Backcheck from HEAD, pre1.0.
|
||||
*
|
||||
* Revision 1.8 1999/04/11 00:29:01 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.7 1999/04/06 04:54:28 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.6 1999/03/31 05:44:48 rgb
|
||||
* Keep PMTU reduction private.
|
||||
*
|
||||
* Revision 1.5 1999/02/10 22:31:20 rgb
|
||||
* Change rebuild_header member to reflect generality of link layer.
|
||||
*
|
||||
* Revision 1.4 1998/12/01 13:22:04 rgb
|
||||
* Added support for debug printing of version info.
|
||||
*
|
||||
* Revision 1.3 1998/07/29 20:42:46 rgb
|
||||
* Add a macro for clearing all tunnel devices.
|
||||
* Rearrange structures and declarations for sharing with userspace.
|
||||
*
|
||||
* Revision 1.2 1998/06/25 20:01:45 rgb
|
||||
* Make prototypes available for ipsec_init and ipsec proc_dir_entries
|
||||
* for static linking.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:50 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.3 1998/05/18 21:51:50 rgb
|
||||
* Added macros for num of I/F's and a procfs debug switch.
|
||||
*
|
||||
* Revision 1.2 1998/04/21 21:29:09 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:13 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:05 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.5 1997/06/03 04:24:48 ji
|
||||
* Added transport mode.
|
||||
* Changed the way routing is done.
|
||||
* Lots of bug fixes.
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* No changes.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:39:04 ji
|
||||
* Minor cleanups.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,274 +0,0 @@
|
||||
/*
|
||||
* Definitions relevant to IPSEC transformations
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_xform.h,v 1.3 2004/09/29 22:26:13 as Exp $
|
||||
*/
|
||||
|
||||
#ifndef _IPSEC_XFORM_H_
|
||||
|
||||
#include <freeswan.h>
|
||||
#include "ipsec_policy.h"
|
||||
|
||||
#define XF_NONE 0 /* No transform set */
|
||||
#define XF_IP4 1 /* IPv4 inside IPv4 */
|
||||
#define XF_AHMD5 2 /* AH MD5 */
|
||||
#define XF_AHSHA 3 /* AH SHA */
|
||||
#define XF_ESP3DES 5 /* ESP DES3-CBC */
|
||||
#define XF_AHHMACMD5 6 /* AH-HMAC-MD5 with opt replay prot */
|
||||
#define XF_AHHMACSHA1 7 /* AH-HMAC-SHA1 with opt replay prot */
|
||||
#define XF_ESP3DESMD5 9 /* triple DES, HMAC-MD-5, 128-bits of authentication */
|
||||
#define XF_ESP3DESMD596 10 /* triple DES, HMAC-MD-5, 96-bits of authentication */
|
||||
#define XF_ESPNULLMD596 12 /* NULL, HMAC-MD-5 with 96-bits of authentication */
|
||||
#define XF_ESPNULLSHA196 13 /* NULL, HMAC-SHA-1 with 96-bits of authentication */
|
||||
#define XF_ESP3DESSHA196 14 /* triple DES, HMAC-SHA-1, 96-bits of authentication */
|
||||
#define XF_IP6 15 /* IPv6 inside IPv6 */
|
||||
#define XF_COMPDEFLATE 16 /* IPCOMP deflate */
|
||||
|
||||
#define XF_CLR 126 /* Clear SA table */
|
||||
#define XF_DEL 127 /* Delete SA */
|
||||
|
||||
#define XFT_AUTH 0x0001
|
||||
#define XFT_CONF 0x0100
|
||||
|
||||
/* available if CONFIG_IPSEC_DEBUG is defined */
|
||||
#define DB_XF_INIT 0x0001
|
||||
|
||||
#define PROTO2TXT(x) \
|
||||
(x) == IPPROTO_AH ? "AH" : \
|
||||
(x) == IPPROTO_ESP ? "ESP" : \
|
||||
(x) == IPPROTO_IPIP ? "IPIP" : \
|
||||
(x) == IPPROTO_COMP ? "COMP" : \
|
||||
"UNKNOWN_proto"
|
||||
static inline const char *enc_name_id (unsigned id) {
|
||||
static char buf[16];
|
||||
snprintf(buf, sizeof(buf), "_ID%d", id);
|
||||
return buf;
|
||||
}
|
||||
static inline const char *auth_name_id (unsigned id) {
|
||||
static char buf[16];
|
||||
snprintf(buf, sizeof(buf), "_ID%d", id);
|
||||
return buf;
|
||||
}
|
||||
#define IPS_XFORM_NAME(x) \
|
||||
PROTO2TXT((x)->ips_said.proto), \
|
||||
(x)->ips_said.proto == IPPROTO_COMP ? \
|
||||
((x)->ips_encalg == SADB_X_CALG_DEFLATE ? \
|
||||
"_DEFLATE" : "_UNKNOWN_comp") : \
|
||||
(x)->ips_encalg == ESP_NONE ? "" : \
|
||||
(x)->ips_encalg == ESP_3DES ? "_3DES" : \
|
||||
(x)->ips_encalg == ESP_AES ? "_AES" : \
|
||||
(x)->ips_encalg == ESP_SERPENT ? "_SERPENT" : \
|
||||
(x)->ips_encalg == ESP_TWOFISH ? "_TWOFISH" : \
|
||||
enc_name_id(x->ips_encalg)/* "_UNKNOWN_encr" */, \
|
||||
(x)->ips_authalg == AH_NONE ? "" : \
|
||||
(x)->ips_authalg == AH_MD5 ? "_HMAC_MD5" : \
|
||||
(x)->ips_authalg == AH_SHA ? "_HMAC_SHA1" : \
|
||||
(x)->ips_authalg == AH_SHA2_256 ? "_HMAC_SHA2_256" : \
|
||||
(x)->ips_authalg == AH_SHA2_384 ? "_HMAC_SHA2_384" : \
|
||||
(x)->ips_authalg == AH_SHA2_512 ? "_HMAC_SHA2_512" : \
|
||||
auth_name_id(x->ips_authalg) /* "_UNKNOWN_auth" */ \
|
||||
|
||||
#define _IPSEC_XFORM_H_
|
||||
#endif /* _IPSEC_XFORM_H_ */
|
||||
|
||||
/*
|
||||
* $Log: ipsec_xform.h,v $
|
||||
* Revision 1.3 2004/09/29 22:26:13 as
|
||||
* included ipsec_policy.h
|
||||
*
|
||||
* Revision 1.2 2004/03/22 21:53:18 as
|
||||
* merged alg-0.8.1 branch with HEAD
|
||||
*
|
||||
* Revision 1.1.4.1 2004/03/16 09:48:18 as
|
||||
* alg-0.8.1rc12 patch merged
|
||||
*
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.36 2002/04/24 07:36:48 mcr
|
||||
* Moved from ./klips/net/ipsec/ipsec_xform.h,v
|
||||
*
|
||||
* Revision 1.35 2001/11/26 09:23:51 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.33.2.1 2001/09/25 02:24:58 mcr
|
||||
* struct tdb -> struct ipsec_sa.
|
||||
* sa(tdb) manipulation functions renamed and moved to ipsec_sa.c
|
||||
* ipsec_xform.c removed. header file still contains useful things.
|
||||
*
|
||||
* Revision 1.34 2001/11/06 19:47:17 rgb
|
||||
* Changed lifetime_packets to uint32 from uint64.
|
||||
*
|
||||
* Revision 1.33 2001/09/08 21:13:34 rgb
|
||||
* Added pfkey ident extension support for ISAKMPd. (NetCelo)
|
||||
*
|
||||
* Revision 1.32 2001/07/06 07:40:01 rgb
|
||||
* Reformatted for readability.
|
||||
* Added inbound policy checking fields for use with IPIP SAs.
|
||||
*
|
||||
* Revision 1.31 2001/06/14 19:35:11 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.30 2001/05/30 08:14:03 rgb
|
||||
* Removed vestiges of esp-null transforms.
|
||||
*
|
||||
* Revision 1.29 2001/01/30 23:42:47 rgb
|
||||
* Allow pfkey msgs from pid other than user context required for ACQUIRE
|
||||
* and subsequent ADD or UDATE.
|
||||
*
|
||||
* Revision 1.28 2000/11/06 04:30:40 rgb
|
||||
* Add Svenning's adaptive content compression.
|
||||
*
|
||||
* Revision 1.27 2000/09/19 00:38:25 rgb
|
||||
* Fixed algorithm name bugs introduced for ipcomp.
|
||||
*
|
||||
* Revision 1.26 2000/09/17 21:36:48 rgb
|
||||
* Added proto2txt macro.
|
||||
*
|
||||
* Revision 1.25 2000/09/17 18:56:47 rgb
|
||||
* Added IPCOMP support.
|
||||
*
|
||||
* Revision 1.24 2000/09/12 19:34:12 rgb
|
||||
* Defined XF_IP6 from Gerhard for ipv6 tunnel support.
|
||||
*
|
||||
* Revision 1.23 2000/09/12 03:23:14 rgb
|
||||
* Cleaned out now unused tdb_xform and tdb_xdata members of struct tdb.
|
||||
*
|
||||
* Revision 1.22 2000/09/08 19:12:56 rgb
|
||||
* Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG.
|
||||
*
|
||||
* Revision 1.21 2000/09/01 18:32:43 rgb
|
||||
* Added (disabled) sensitivity members to tdb struct.
|
||||
*
|
||||
* Revision 1.20 2000/08/30 05:31:01 rgb
|
||||
* Removed all the rest of the references to tdb_spi, tdb_proto, tdb_dst.
|
||||
* Kill remainder of tdb_xform, tdb_xdata, xformsw.
|
||||
*
|
||||
* Revision 1.19 2000/08/01 14:51:52 rgb
|
||||
* Removed _all_ remaining traces of DES.
|
||||
*
|
||||
* Revision 1.18 2000/01/21 06:17:45 rgb
|
||||
* Tidied up spacing.
|
||||
*
|
||||
* Revision 1.17 1999/11/17 15:53:40 rgb
|
||||
* Changed all occurrences of #include "../../../lib/freeswan.h"
|
||||
* to #include <freeswan.h> which works due to -Ilibfreeswan in the
|
||||
* klips/net/ipsec/Makefile.
|
||||
*
|
||||
* Revision 1.16 1999/10/16 04:23:07 rgb
|
||||
* Add stats for replaywin_errs, replaywin_max_sequence_difference,
|
||||
* authentication errors, encryption size errors, encryption padding
|
||||
* errors, and time since last packet.
|
||||
*
|
||||
* Revision 1.15 1999/10/16 00:29:11 rgb
|
||||
* Added SA lifetime packet counting variables.
|
||||
*
|
||||
* Revision 1.14 1999/10/01 00:04:14 rgb
|
||||
* Added tdb structure locking.
|
||||
* Add function to initialize tdb hash table.
|
||||
*
|
||||
* Revision 1.13 1999/04/29 15:20:57 rgb
|
||||
* dd return values to init and cleanup functions.
|
||||
* Eliminate unnessessary usage of tdb_xform member to further switch
|
||||
* away from the transform switch to the algorithm switch.
|
||||
* Change gettdb parameter to a pointer to reduce stack loading and
|
||||
* facilitate parameter sanity checking.
|
||||
* Add a parameter to tdbcleanup to be able to delete a class of SAs.
|
||||
*
|
||||
* Revision 1.12 1999/04/15 15:37:25 rgb
|
||||
* Forward check changes from POST1_00 branch.
|
||||
*
|
||||
* Revision 1.9.2.2 1999/04/13 20:35:57 rgb
|
||||
* Fix spelling mistake in comment.
|
||||
*
|
||||
* Revision 1.9.2.1 1999/03/30 17:13:52 rgb
|
||||
* Extend struct tdb to support pfkey.
|
||||
*
|
||||
* Revision 1.11 1999/04/11 00:29:01 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.10 1999/04/06 04:54:28 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.9 1999/01/26 02:09:31 rgb
|
||||
* Removed CONFIG_IPSEC_ALGO_SWITCH macro.
|
||||
* Removed dead code.
|
||||
*
|
||||
* Revision 1.8 1999/01/22 06:29:35 rgb
|
||||
* Added algorithm switch code.
|
||||
* Cruft clean-out.
|
||||
*
|
||||
* Revision 1.7 1998/11/10 05:37:35 rgb
|
||||
* Add support for SA direction flag.
|
||||
*
|
||||
* Revision 1.6 1998/10/19 14:44:29 rgb
|
||||
* Added inclusion of freeswan.h.
|
||||
* sa_id structure implemented and used: now includes protocol.
|
||||
*
|
||||
* Revision 1.5 1998/08/12 00:12:30 rgb
|
||||
* Added macros for new xforms. Added prototypes for new xforms.
|
||||
*
|
||||
* Revision 1.4 1998/07/28 00:04:20 rgb
|
||||
* Add macro for clearing the SA table.
|
||||
*
|
||||
* Revision 1.3 1998/07/14 18:06:46 rgb
|
||||
* Added #ifdef __KERNEL__ directives to restrict scope of header.
|
||||
*
|
||||
* Revision 1.2 1998/06/23 03:02:19 rgb
|
||||
* Created a prototype for ipsec_tdbcleanup when it was moved from
|
||||
* ipsec_init.c.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:27:51 henry
|
||||
* move sources from klips/src to klips/net/ipsec, to keep stupid
|
||||
* kernel-build scripts happier in the presence of symlinks
|
||||
*
|
||||
* Revision 1.4 1998/06/11 05:55:31 rgb
|
||||
* Added transform version string pointer to xformsw structure definition.
|
||||
* Added extern declarations for transform version strings.
|
||||
*
|
||||
* Revision 1.3 1998/05/18 22:02:54 rgb
|
||||
* Modify the *_zeroize function prototypes to include one parameter.
|
||||
*
|
||||
* Revision 1.2 1998/04/21 21:29:08 rgb
|
||||
* Rearrange debug switches to change on the fly debug output from user
|
||||
* space. Only kernel changes checked in at this time. radij.c was also
|
||||
* changed to temporarily remove buggy debugging code in rj_delete causing
|
||||
* an OOPS and hence, netlink device open errors.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:14 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:06 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.5 1997/06/03 04:24:48 ji
|
||||
* Added ESP-3DES-MD5-96
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* Added new transforms.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:39:04 ji
|
||||
* Minor cleanups.
|
||||
* Rationalized debugging code.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
* Local variables:
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*
|
||||
*/
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* IPSEC tunneling code
|
||||
* Copyright (C) 1996, 1997 John Ioannidis.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: ipsec_xmit.h,v 1.3 2004/06/13 19:37:07 as Exp $
|
||||
*/
|
||||
|
||||
#include "freeswan/ipsec_sa.h"
|
||||
|
||||
enum ipsec_xmit_value
|
||||
{
|
||||
IPSEC_XMIT_STOLEN=2,
|
||||
IPSEC_XMIT_PASS=1,
|
||||
IPSEC_XMIT_OK=0,
|
||||
IPSEC_XMIT_ERRMEMALLOC=-1,
|
||||
IPSEC_XMIT_ESP_BADALG=-2,
|
||||
IPSEC_XMIT_BADPROTO=-3,
|
||||
IPSEC_XMIT_ESP_PUSHPULLERR=-4,
|
||||
IPSEC_XMIT_BADLEN=-5,
|
||||
IPSEC_XMIT_AH_BADALG=-6,
|
||||
IPSEC_XMIT_SAIDNOTFOUND=-7,
|
||||
IPSEC_XMIT_SAIDNOTLIVE=-8,
|
||||
IPSEC_XMIT_REPLAYROLLED=-9,
|
||||
IPSEC_XMIT_LIFETIMEFAILED=-10,
|
||||
IPSEC_XMIT_CANNOTFRAG=-11,
|
||||
IPSEC_XMIT_MSSERR=-12,
|
||||
IPSEC_XMIT_ERRSKBALLOC=-13,
|
||||
IPSEC_XMIT_ENCAPFAIL=-14,
|
||||
IPSEC_XMIT_NODEV=-15,
|
||||
IPSEC_XMIT_NOPRIVDEV=-16,
|
||||
IPSEC_XMIT_NOPHYSDEV=-17,
|
||||
IPSEC_XMIT_NOSKB=-18,
|
||||
IPSEC_XMIT_NOIPV6=-19,
|
||||
IPSEC_XMIT_NOIPOPTIONS=-20,
|
||||
IPSEC_XMIT_TTLEXPIRED=-21,
|
||||
IPSEC_XMIT_BADHHLEN=-22,
|
||||
IPSEC_XMIT_PUSHPULLERR=-23,
|
||||
IPSEC_XMIT_ROUTEERR=-24,
|
||||
IPSEC_XMIT_RECURSDETECT=-25,
|
||||
IPSEC_XMIT_IPSENDFAILURE=-26,
|
||||
#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
||||
IPSEC_XMIT_ESPUDP=-27,
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ipsec_xmit_state
|
||||
{
|
||||
struct sk_buff *skb; /* working skb pointer */
|
||||
struct device *dev; /* working dev pointer */
|
||||
struct ipsecpriv *prv; /* Our device' private space */
|
||||
struct sk_buff *oskb; /* Original skb pointer */
|
||||
struct net_device_stats *stats; /* This device's statistics */
|
||||
struct iphdr *iph; /* Our new IP header */
|
||||
__u32 newdst; /* The other SG's IP address */
|
||||
__u32 orgdst; /* Original IP destination address */
|
||||
__u32 orgedst; /* 1st SG's IP address */
|
||||
__u32 newsrc; /* The new source SG's IP address */
|
||||
__u32 orgsrc; /* Original IP source address */
|
||||
__u32 innersrc; /* Innermost IP source address */
|
||||
int iphlen; /* IP header length */
|
||||
int pyldsz; /* upper protocol payload size */
|
||||
int headroom;
|
||||
int tailroom;
|
||||
int max_headroom; /* The extra header space needed */
|
||||
int max_tailroom; /* The extra stuffing needed */
|
||||
int ll_headroom; /* The extra link layer hard_header space needed */
|
||||
int tot_headroom; /* The total header space needed */
|
||||
int tot_tailroom; /* The totalstuffing needed */
|
||||
__u8 *saved_header; /* saved copy of the hard header */
|
||||
unsigned short sport, dport;
|
||||
|
||||
struct sockaddr_encap matcher; /* eroute search key */
|
||||
struct eroute *eroute;
|
||||
struct ipsec_sa *ipsp, *ipsq; /* ipsec_sa pointers */
|
||||
char sa_txt[SATOA_BUF];
|
||||
size_t sa_len;
|
||||
int hard_header_stripped; /* has the hard header been removed yet? */
|
||||
int hard_header_len;
|
||||
struct device *physdev;
|
||||
/* struct device *virtdev; */
|
||||
short physmtu;
|
||||
short mtudiff;
|
||||
#ifdef NET_21
|
||||
struct rtable *route;
|
||||
#endif /* NET_21 */
|
||||
struct sa_id outgoing_said;
|
||||
#ifdef NET_21
|
||||
int pass;
|
||||
#endif /* NET_21 */
|
||||
int error;
|
||||
uint32_t eroute_pid;
|
||||
struct ipsec_sa ips;
|
||||
#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
||||
uint8_t natt_type;
|
||||
uint8_t natt_head;
|
||||
uint16_t natt_sport;
|
||||
uint16_t natt_dport;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if 0 /* save for alg refactorisation */
|
||||
struct xform_functions
|
||||
{
|
||||
enum ipsec_xmit_value (*checks)(struct ipsec_xmit_state *ixs,
|
||||
struct sk_buff *skb);
|
||||
enum ipsec_xmit_value (*encrypt)(struct ipsec_xmit_state *ixs);
|
||||
|
||||
enum ipsec_xmit_value (*setup_auth)(struct ipsec_xmit_state *ixs,
|
||||
struct sk_buff *skb,
|
||||
__u32 *replay,
|
||||
unsigned char **authenticator);
|
||||
enum ipsec_xmit_value (*calc_auth)(struct ipsec_xmit_state *ixs,
|
||||
struct sk_buff *skb);
|
||||
};
|
||||
#endif
|
||||
|
||||
enum ipsec_xmit_value
|
||||
ipsec_xmit_sanity_check_dev(struct ipsec_xmit_state *ixs);
|
||||
|
||||
enum ipsec_xmit_value
|
||||
ipsec_xmit_sanity_check_skb(struct ipsec_xmit_state *ixs);
|
||||
|
||||
enum ipsec_xmit_value
|
||||
ipsec_xmit_encap_bundle(struct ipsec_xmit_state *ixs);
|
||||
|
||||
extern int ipsec_xmit_trap_count;
|
||||
extern int ipsec_xmit_trap_sendcount;
|
||||
|
||||
extern void ipsec_extract_ports(struct iphdr * iph, struct sockaddr_encap * er);
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* RCSID $Id: radij.h,v 1.1 2004/03/15 20:35:25 as Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is defived from ${SRC}/sys/net/radix.h of BSD 4.4lite
|
||||
*
|
||||
* Variable and procedure names have been modified so that they don't
|
||||
* conflict with the original BSD code, as a small number of modifications
|
||||
* have been introduced and we may want to reuse this code in BSD.
|
||||
*
|
||||
* The `j' in `radij' is pronounced as a voiceless guttural (like a Greek
|
||||
* chi or a German ch sound (as `doch', not as in `milch'), or even a
|
||||
* spanish j as in Juan. It is not as far back in the throat like
|
||||
* the corresponding Hebrew sound, nor is it a soft breath like the English h.
|
||||
* It has nothing to do with the Dutch ij sound.
|
||||
*
|
||||
* Here is the appropriate copyright notice:
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)radix.h 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
#ifndef _RADIJ_H_
|
||||
#define _RADIJ_H_
|
||||
|
||||
/*
|
||||
#define RJ_DEBUG
|
||||
*/
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#ifndef __P
|
||||
#ifdef __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Radix search tree node layout.
|
||||
*/
|
||||
|
||||
struct radij_node
|
||||
{
|
||||
struct radij_mask *rj_mklist; /* list of masks contained in subtree */
|
||||
struct radij_node *rj_p; /* parent */
|
||||
short rj_b; /* bit offset; -1-index(netmask) */
|
||||
char rj_bmask; /* node: mask for bit test*/
|
||||
u_char rj_flags; /* enumerated next */
|
||||
#define RJF_NORMAL 1 /* leaf contains normal route */
|
||||
#define RJF_ROOT 2 /* leaf is root leaf for tree */
|
||||
#define RJF_ACTIVE 4 /* This node is alive (for rtfree) */
|
||||
union {
|
||||
struct { /* leaf only data: */
|
||||
caddr_t rj_Key; /* object of search */
|
||||
caddr_t rj_Mask; /* netmask, if present */
|
||||
struct radij_node *rj_Dupedkey;
|
||||
} rj_leaf;
|
||||
struct { /* node only data: */
|
||||
int rj_Off; /* where to start compare */
|
||||
struct radij_node *rj_L;/* progeny */
|
||||
struct radij_node *rj_R;/* progeny */
|
||||
}rj_node;
|
||||
} rj_u;
|
||||
#ifdef RJ_DEBUG
|
||||
int rj_info;
|
||||
struct radij_node *rj_twin;
|
||||
struct radij_node *rj_ybro;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define rj_dupedkey rj_u.rj_leaf.rj_Dupedkey
|
||||
#define rj_key rj_u.rj_leaf.rj_Key
|
||||
#define rj_mask rj_u.rj_leaf.rj_Mask
|
||||
#define rj_off rj_u.rj_node.rj_Off
|
||||
#define rj_l rj_u.rj_node.rj_L
|
||||
#define rj_r rj_u.rj_node.rj_R
|
||||
|
||||
/*
|
||||
* Annotations to tree concerning potential routes applying to subtrees.
|
||||
*/
|
||||
|
||||
extern struct radij_mask {
|
||||
short rm_b; /* bit offset; -1-index(netmask) */
|
||||
char rm_unused; /* cf. rj_bmask */
|
||||
u_char rm_flags; /* cf. rj_flags */
|
||||
struct radij_mask *rm_mklist; /* more masks to try */
|
||||
caddr_t rm_mask; /* the mask */
|
||||
int rm_refs; /* # of references to this struct */
|
||||
} *rj_mkfreelist;
|
||||
|
||||
#define MKGet(m) {\
|
||||
if (rj_mkfreelist) {\
|
||||
m = rj_mkfreelist; \
|
||||
rj_mkfreelist = (m)->rm_mklist; \
|
||||
} else \
|
||||
R_Malloc(m, struct radij_mask *, sizeof (*(m))); }\
|
||||
|
||||
#define MKFree(m) { (m)->rm_mklist = rj_mkfreelist; rj_mkfreelist = (m);}
|
||||
|
||||
struct radij_node_head {
|
||||
struct radij_node *rnh_treetop;
|
||||
int rnh_addrsize; /* permit, but not require fixed keys */
|
||||
int rnh_pktsize; /* permit, but not require fixed keys */
|
||||
#if 0
|
||||
struct radij_node *(*rnh_addaddr) /* add based on sockaddr */
|
||||
__P((void *v, void *mask,
|
||||
struct radij_node_head *head, struct radij_node nodes[]));
|
||||
#endif
|
||||
int (*rnh_addaddr) /* add based on sockaddr */
|
||||
__P((void *v, void *mask,
|
||||
struct radij_node_head *head, struct radij_node nodes[]));
|
||||
struct radij_node *(*rnh_addpkt) /* add based on packet hdr */
|
||||
__P((void *v, void *mask,
|
||||
struct radij_node_head *head, struct radij_node nodes[]));
|
||||
#if 0
|
||||
struct radij_node *(*rnh_deladdr) /* remove based on sockaddr */
|
||||
__P((void *v, void *mask, struct radij_node_head *head));
|
||||
#endif
|
||||
int (*rnh_deladdr) /* remove based on sockaddr */
|
||||
__P((void *v, void *mask, struct radij_node_head *head, struct radij_node **node));
|
||||
struct radij_node *(*rnh_delpkt) /* remove based on packet hdr */
|
||||
__P((void *v, void *mask, struct radij_node_head *head));
|
||||
struct radij_node *(*rnh_matchaddr) /* locate based on sockaddr */
|
||||
__P((void *v, struct radij_node_head *head));
|
||||
struct radij_node *(*rnh_matchpkt) /* locate based on packet hdr */
|
||||
__P((void *v, struct radij_node_head *head));
|
||||
int (*rnh_walktree) /* traverse tree */
|
||||
__P((struct radij_node_head *head, int (*f)(struct radij_node *rn, void *w), void *w));
|
||||
struct radij_node rnh_nodes[3]; /* empty tree for common case */
|
||||
};
|
||||
|
||||
|
||||
#define Bcmp(a, b, n) memcmp(((caddr_t)(b)), ((caddr_t)(a)), (unsigned)(n))
|
||||
#define Bcopy(a, b, n) memmove(((caddr_t)(b)), ((caddr_t)(a)), (unsigned)(n))
|
||||
#define Bzero(p, n) memset((caddr_t)(p), 0, (unsigned)(n))
|
||||
#define R_Malloc(p, t, n) ((p = (t) kmalloc((size_t)(n), GFP_ATOMIC)), Bzero((p),(n)))
|
||||
#define Free(p) kfree((caddr_t)p);
|
||||
|
||||
void rj_init __P((void));
|
||||
int rj_inithead __P((void **, int));
|
||||
int rj_refines __P((void *, void *));
|
||||
int rj_walktree __P((struct radij_node_head *head, int (*f)(struct radij_node *rn, void *w), void *w));
|
||||
struct radij_node
|
||||
*rj_addmask __P((void *, int, int)) /* , rgb */ ;
|
||||
int /* * */ rj_addroute __P((void *, void *, struct radij_node_head *,
|
||||
struct radij_node [2])) /* , rgb */ ;
|
||||
int /* * */ rj_delete __P((void *, void *, struct radij_node_head *, struct radij_node **)) /* , rgb */ ;
|
||||
struct radij_node /* rgb */
|
||||
*rj_insert __P((void *, struct radij_node_head *, int *,
|
||||
struct radij_node [2])),
|
||||
*rj_match __P((void *, struct radij_node_head *)),
|
||||
*rj_newpair __P((void *, int, struct radij_node[2])),
|
||||
*rj_search __P((void *, struct radij_node *)),
|
||||
*rj_search_m __P((void *, struct radij_node *, void *));
|
||||
|
||||
void rj_deltree(struct radij_node_head *);
|
||||
void rj_delnodes(struct radij_node *);
|
||||
void rj_free_mkfreelist(void);
|
||||
int radijcleartree(void);
|
||||
int radijcleanup(void);
|
||||
|
||||
extern struct radij_node_head *mask_rjhead;
|
||||
extern int maj_keylen;
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* _RADIJ_H_ */
|
||||
|
||||
|
||||
/*
|
||||
* $Log: radij.h,v $
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.12 2002/04/24 07:36:48 mcr
|
||||
* Moved from ./klips/net/ipsec/radij.h,v
|
||||
*
|
||||
* Revision 1.11 2001/09/20 15:33:00 rgb
|
||||
* Min/max cleanup.
|
||||
*
|
||||
* Revision 1.10 1999/11/18 04:09:20 rgb
|
||||
* Replaced all kernel version macros to shorter, readable form.
|
||||
*
|
||||
* Revision 1.9 1999/05/05 22:02:33 rgb
|
||||
* Add a quick and dirty port to 2.2 kernels by Marc Boucher <[email protected]>.
|
||||
*
|
||||
* Revision 1.8 1999/04/29 15:24:58 rgb
|
||||
* Add check for existence of macros min/max.
|
||||
*
|
||||
* Revision 1.7 1999/04/11 00:29:02 henry
|
||||
* GPL boilerplate
|
||||
*
|
||||
* Revision 1.6 1999/04/06 04:54:29 rgb
|
||||
* Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes
|
||||
* patch shell fixes.
|
||||
*
|
||||
* Revision 1.5 1999/01/22 06:30:32 rgb
|
||||
* 64-bit clean-up.
|
||||
*
|
||||
* Revision 1.4 1998/11/30 13:22:55 rgb
|
||||
* Rationalised all the klips kernel file headers. They are much shorter
|
||||
* now and won't conflict under RH5.2.
|
||||
*
|
||||
* Revision 1.3 1998/10/25 02:43:27 rgb
|
||||
* Change return type on rj_addroute and rj_delete and add and argument
|
||||
* to the latter to be able to transmit more infomation about errors.
|
||||
*
|
||||
* Revision 1.2 1998/07/14 18:09:51 rgb
|
||||
* Add a routine to clear eroute table.
|
||||
* Added #ifdef __KERNEL__ directives to restrict scope of header.
|
||||
*
|
||||
* Revision 1.1 1998/06/18 21:30:22 henry
|
||||
* move sources from klips/src to klips/net/ipsec to keep stupid kernel
|
||||
* build scripts happier about symlinks
|
||||
*
|
||||
* Revision 1.4 1998/05/25 20:34:16 rgb
|
||||
* Remove temporary ipsec_walk, rj_deltree and rj_delnodes functions.
|
||||
*
|
||||
* Rename ipsec_rj_walker (ipsec_walk) to ipsec_rj_walker_procprint and
|
||||
* add ipsec_rj_walker_delete.
|
||||
*
|
||||
* Recover memory for eroute table on unload of module.
|
||||
*
|
||||
* Revision 1.3 1998/04/22 16:51:37 rgb
|
||||
* Tidy up radij debug code from recent rash of modifications to debug code.
|
||||
*
|
||||
* Revision 1.2 1998/04/14 17:30:38 rgb
|
||||
* Fix up compiling errors for radij tree memory reclamation.
|
||||
*
|
||||
* Revision 1.1 1998/04/09 03:06:16 henry
|
||||
* sources moved up from linux/net/ipsec
|
||||
*
|
||||
* Revision 1.1.1.1 1998/04/08 05:35:04 henry
|
||||
* RGB's ipsec-0.8pre2.tar.gz ipsec-0.8
|
||||
*
|
||||
* Revision 0.4 1997/01/15 01:28:15 ji
|
||||
* No changes.
|
||||
*
|
||||
* Revision 0.3 1996/11/20 14:44:45 ji
|
||||
* Release update only.
|
||||
*
|
||||
* Revision 0.2 1996/11/02 00:18:33 ji
|
||||
* First limited release.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -1,33 +0,0 @@
|
||||
struct mast_callbacks {
|
||||
int (*packet_encap)(struct device *mast, void *context,
|
||||
struct sk_buff *skb, int flowref);
|
||||
int (*link_inquire)(struct device *mast, void *context);
|
||||
};
|
||||
|
||||
|
||||
struct device *mast_init (int family,
|
||||
struct mast_callbacks *callbacks,
|
||||
unsigned int flags,
|
||||
unsigned int desired_unit,
|
||||
unsigned int max_flowref,
|
||||
void *context);
|
||||
|
||||
int mast_destroy(struct device *mast);
|
||||
|
||||
int mast_recv(struct device *mast, struct sk_buff *skb, int flowref);
|
||||
|
||||
/* free this skb as being useless, increment failure count. */
|
||||
int mast_toast(struct device *mast, struct sk_buff *skb, int flowref);
|
||||
|
||||
int mast_linkstat (struct device *mast, int flowref,
|
||||
int status);
|
||||
|
||||
int mast_setreference (struct device *mast,
|
||||
int defaultSA);
|
||||
|
||||
int mast_setneighbor (struct device *mast,
|
||||
struct sockaddr *source,
|
||||
struct sockaddr *destination,
|
||||
int flowref);
|
||||
|
||||
|
||||
@@ -1,498 +0,0 @@
|
||||
/*
|
||||
* FreeS/WAN specific PF_KEY headers
|
||||
* Copyright (C) 1999, 2000, 2001 Richard Guy Briggs.
|
||||
*
|
||||
* This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RCSID $Id: pfkey.h,v 1.2 2004/03/22 21:53:18 as Exp $
|
||||
*/
|
||||
|
||||
#ifndef __NET_IPSEC_PF_KEY_H
|
||||
#define __NET_IPSEC_PF_KEY_H
|
||||
#ifdef __KERNEL__
|
||||
extern struct proto_ops pfkey_proto_ops;
|
||||
typedef struct sock pfkey_sock;
|
||||
extern int debug_pfkey;
|
||||
|
||||
extern /* void */ int pfkey_init(void);
|
||||
extern /* void */ int pfkey_cleanup(void);
|
||||
|
||||
extern struct sock *pfkey_sock_list;
|
||||
struct socket_list
|
||||
{
|
||||
struct socket *socketp;
|
||||
struct socket_list *next;
|
||||
};
|
||||
extern int pfkey_list_insert_socket(struct socket*, struct socket_list**);
|
||||
extern int pfkey_list_remove_socket(struct socket*, struct socket_list**);
|
||||
extern struct socket_list *pfkey_open_sockets;
|
||||
extern struct socket_list *pfkey_registered_sockets[SADB_SATYPE_MAX+1];
|
||||
|
||||
/*
|
||||
* There is a field-by-field copy in klips/net/ipsec/ipsec_alg.h
|
||||
* please keep in sync until we migrate all support stuff
|
||||
* to ipsec_alg objects
|
||||
*/
|
||||
struct supported
|
||||
{
|
||||
uint16_t supported_alg_exttype;
|
||||
uint8_t supported_alg_id;
|
||||
uint8_t supported_alg_ivlen;
|
||||
uint16_t supported_alg_minbits;
|
||||
uint16_t supported_alg_maxbits;
|
||||
};
|
||||
extern struct supported_list *pfkey_supported_list[SADB_SATYPE_MAX+1];
|
||||
struct supported_list
|
||||
{
|
||||
struct supported *supportedp;
|
||||
struct supported_list *next;
|
||||
};
|
||||
extern int pfkey_list_insert_supported(struct supported*, struct supported_list**);
|
||||
extern int pfkey_list_remove_supported(struct supported*, struct supported_list**);
|
||||
|
||||
struct sockaddr_key
|
||||
{
|
||||
uint16_t key_family; /* PF_KEY */
|
||||
uint16_t key_pad; /* not used */
|
||||
uint32_t key_pid; /* process ID */
|
||||
};
|
||||
|
||||
struct pfkey_extracted_data
|
||||
{
|
||||
struct ipsec_sa* ips;
|
||||
struct ipsec_sa* ips2;
|
||||
struct eroute *eroute;
|
||||
};
|
||||
|
||||
extern int
|
||||
pfkey_alloc_eroute(struct eroute** eroute);
|
||||
|
||||
extern int
|
||||
pfkey_sa_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_lifetime_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_address_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_key_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_ident_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_sens_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_prop_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_supported_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_spirange_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_x_kmprivate_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_x_satype_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int
|
||||
pfkey_x_debug_process(struct sadb_ext *pfkey_ext,
|
||||
struct pfkey_extracted_data* extr);
|
||||
|
||||
extern int pfkey_register_reply(int satype, struct sadb_msg *);
|
||||
extern int pfkey_upmsg(struct socket *, struct sadb_msg *);
|
||||
extern int pfkey_expire(struct ipsec_sa *, int);
|
||||
extern int pfkey_acquire(struct ipsec_sa *);
|
||||
#else /* ! __KERNEL__ */
|
||||
|
||||
extern void (*pfkey_debug_func)(const char *message, ...);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
extern uint8_t satype2proto(uint8_t satype);
|
||||
extern uint8_t proto2satype(uint8_t proto);
|
||||
extern char* satype2name(uint8_t satype);
|
||||
extern char* proto2name(uint8_t proto);
|
||||
|
||||
struct key_opt
|
||||
{
|
||||
uint32_t key_pid; /* process ID */
|
||||
struct sock *sk;
|
||||
};
|
||||
|
||||
#define key_pid(sk) ((struct key_opt*)&((sk)->protinfo))->key_pid
|
||||
|
||||
#define IPSEC_PFKEYv2_ALIGN (sizeof(uint64_t)/sizeof(uint8_t))
|
||||
#define BITS_PER_OCTET 8
|
||||
#define OCTETBITS 8
|
||||
#define PFKEYBITS 64
|
||||
#define DIVUP(x,y) ((x + y -1) / y) /* divide, rounding upwards */
|
||||
#define ALIGN_N(x,y) (DIVUP(x,y) * y) /* align on y boundary */
|
||||
|
||||
#define PFKEYv2_MAX_MSGSIZE 4096
|
||||
|
||||
/*
|
||||
* PF_KEYv2 permitted and required extensions in and out bitmaps
|
||||
*/
|
||||
struct pf_key_ext_parsers_def {
|
||||
int (*parser)(struct sadb_ext*);
|
||||
char *parser_name;
|
||||
};
|
||||
|
||||
|
||||
extern unsigned int extensions_bitmaps[2/*in/out*/][2/*perm/req*/][SADB_MAX + 1/*ext*/];
|
||||
#define EXT_BITS_IN 0
|
||||
#define EXT_BITS_OUT 1
|
||||
#define EXT_BITS_PERM 0
|
||||
#define EXT_BITS_REQ 1
|
||||
|
||||
extern void pfkey_extensions_init(struct sadb_ext *extensions[SADB_EXT_MAX + 1]);
|
||||
extern void pfkey_extensions_free(struct sadb_ext *extensions[SADB_EXT_MAX + 1]);
|
||||
extern void pfkey_msg_free(struct sadb_msg **pfkey_msg);
|
||||
|
||||
extern int pfkey_msg_parse(struct sadb_msg *pfkey_msg,
|
||||
struct pf_key_ext_parsers_def *ext_parsers[],
|
||||
struct sadb_ext **extensions,
|
||||
int dir);
|
||||
|
||||
/*
|
||||
* PF_KEYv2 build function prototypes
|
||||
*/
|
||||
|
||||
int
|
||||
pfkey_msg_hdr_build(struct sadb_ext** pfkey_ext,
|
||||
uint8_t msg_type,
|
||||
uint8_t satype,
|
||||
uint8_t msg_errno,
|
||||
uint32_t seq,
|
||||
uint32_t pid);
|
||||
|
||||
int
|
||||
pfkey_sa_ref_build(struct sadb_ext ** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint32_t spi, /* in network order */
|
||||
uint8_t replay_window,
|
||||
uint8_t sa_state,
|
||||
uint8_t auth,
|
||||
uint8_t encrypt,
|
||||
uint32_t flags,
|
||||
uint32_t/*IPsecSAref_t*/ ref);
|
||||
|
||||
int
|
||||
pfkey_sa_build(struct sadb_ext ** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint32_t spi, /* in network order */
|
||||
uint8_t replay_window,
|
||||
uint8_t sa_state,
|
||||
uint8_t auth,
|
||||
uint8_t encrypt,
|
||||
uint32_t flags);
|
||||
|
||||
int
|
||||
pfkey_lifetime_build(struct sadb_ext ** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint32_t allocations,
|
||||
uint64_t bytes,
|
||||
uint64_t addtime,
|
||||
uint64_t usetime,
|
||||
uint32_t packets);
|
||||
|
||||
int
|
||||
pfkey_address_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint8_t proto,
|
||||
uint8_t prefixlen,
|
||||
struct sockaddr* address);
|
||||
|
||||
int
|
||||
pfkey_key_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint16_t key_bits,
|
||||
char* key);
|
||||
|
||||
int
|
||||
pfkey_ident_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint16_t ident_type,
|
||||
uint64_t ident_id,
|
||||
uint8_t ident_len,
|
||||
char* ident_string);
|
||||
|
||||
#ifdef NAT_TRAVERSAL
|
||||
#ifdef __KERNEL__
|
||||
extern int pfkey_nat_t_new_mapping(struct ipsec_sa *, struct sockaddr *, __u16);
|
||||
extern int pfkey_x_nat_t_type_process(struct sadb_ext *pfkey_ext, struct pfkey_extracted_data* extr);
|
||||
extern int pfkey_x_nat_t_port_process(struct sadb_ext *pfkey_ext, struct pfkey_extracted_data* extr);
|
||||
#endif /* __KERNEL__ */
|
||||
int
|
||||
pfkey_x_nat_t_type_build(struct sadb_ext** pfkey_ext,
|
||||
uint8_t type);
|
||||
int
|
||||
pfkey_x_nat_t_port_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint16_t port);
|
||||
#endif
|
||||
|
||||
int
|
||||
pfkey_sens_build(struct sadb_ext** pfkey_ext,
|
||||
uint32_t dpd,
|
||||
uint8_t sens_level,
|
||||
uint8_t sens_len,
|
||||
uint64_t* sens_bitmap,
|
||||
uint8_t integ_level,
|
||||
uint8_t integ_len,
|
||||
uint64_t* integ_bitmap);
|
||||
|
||||
int pfkey_x_protocol_build(struct sadb_ext **, uint8_t);
|
||||
|
||||
|
||||
int
|
||||
pfkey_prop_build(struct sadb_ext** pfkey_ext,
|
||||
uint8_t replay,
|
||||
unsigned int comb_num,
|
||||
struct sadb_comb* comb);
|
||||
|
||||
int
|
||||
pfkey_supported_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
unsigned int alg_num,
|
||||
struct sadb_alg* alg);
|
||||
|
||||
int
|
||||
pfkey_spirange_build(struct sadb_ext** pfkey_ext,
|
||||
uint16_t exttype,
|
||||
uint32_t min,
|
||||
uint32_t max);
|
||||
|
||||
int
|
||||
pfkey_x_kmprivate_build(struct sadb_ext** pfkey_ext);
|
||||
|
||||
int
|
||||
pfkey_x_satype_build(struct sadb_ext** pfkey_ext,
|
||||
uint8_t satype);
|
||||
|
||||
int
|
||||
pfkey_x_debug_build(struct sadb_ext** pfkey_ext,
|
||||
uint32_t tunnel,
|
||||
uint32_t netlink,
|
||||
uint32_t xform,
|
||||
uint32_t eroute,
|
||||
uint32_t spi,
|
||||
uint32_t radij,
|
||||
uint32_t esp,
|
||||
uint32_t ah,
|
||||
uint32_t rcv,
|
||||
uint32_t pfkey,
|
||||
uint32_t ipcomp,
|
||||
uint32_t verbose);
|
||||
|
||||
int
|
||||
pfkey_msg_build(struct sadb_msg** pfkey_msg,
|
||||
struct sadb_ext* extensions[],
|
||||
int dir);
|
||||
|
||||
/* in pfkey_v2_debug.c - routines to decode numbers -> strings */
|
||||
const char *
|
||||
pfkey_v2_sadb_ext_string(int extnum);
|
||||
|
||||
const char *
|
||||
pfkey_v2_sadb_type_string(int sadb_type);
|
||||
|
||||
|
||||
#endif /* __NET_IPSEC_PF_KEY_H */
|
||||
|
||||
/*
|
||||
* $Log: pfkey.h,v $
|
||||
* Revision 1.2 2004/03/22 21:53:18 as
|
||||
* merged alg-0.8.1 branch with HEAD
|
||||
*
|
||||
* Revision 1.1.2.1.2.1 2004/03/16 09:48:18 as
|
||||
* alg-0.8.1rc12 patch merged
|
||||
*
|
||||
* Revision 1.1.2.1 2004/03/15 22:30:06 as
|
||||
* nat-0.6c patch merged
|
||||
*
|
||||
* Revision 1.1 2004/03/15 20:35:25 as
|
||||
* added files from freeswan-2.04-x509-1.5.3
|
||||
*
|
||||
* Revision 1.42 2003/08/25 22:08:19 mcr
|
||||
* removed pfkey_proto_init() from pfkey.h for 2.6 support.
|
||||
*
|
||||
* Revision 1.41 2003/05/07 17:28:57 mcr
|
||||
* new function pfkey_debug_func added for us in debugging from
|
||||
* pfkey library.
|
||||
*
|
||||
* Revision 1.40 2003/01/30 02:31:34 rgb
|
||||
*
|
||||
* Convert IPsecSAref_t from signed to unsigned to fix apparent SAref exhaustion bug.
|
||||
*
|
||||
* Revision 1.39 2002/09/20 15:40:21 rgb
|
||||
* Switch from pfkey_alloc_ipsec_sa() to ipsec_sa_alloc().
|
||||
* Added ref parameter to pfkey_sa_build().
|
||||
* Cleaned out unused cruft.
|
||||
*
|
||||
* Revision 1.38 2002/05/14 02:37:24 rgb
|
||||
* Change all references to tdb, TDB or Tunnel Descriptor Block to ips,
|
||||
* ipsec_sa or ipsec_sa.
|
||||
* Added function prototypes for the functions moved to
|
||||
* pfkey_v2_ext_process.c.
|
||||
*
|
||||
* Revision 1.37 2002/04/24 07:36:49 mcr
|
||||
* Moved from ./lib/pfkey.h,v
|
||||
*
|
||||
* Revision 1.36 2002/01/20 20:34:49 mcr
|
||||
* added pfkey_v2_sadb_type_string to decode sadb_type to string.
|
||||
*
|
||||
* Revision 1.35 2001/11/27 05:27:47 mcr
|
||||
* pfkey parses are now maintained by a structure
|
||||
* that includes their name for debug purposes.
|
||||
*
|
||||
* Revision 1.34 2001/11/26 09:23:53 rgb
|
||||
* Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes.
|
||||
*
|
||||
* Revision 1.33 2001/11/06 19:47:47 rgb
|
||||
* Added packet parameter to lifetime and comb structures.
|
||||
*
|
||||
* Revision 1.32 2001/09/08 21:13:34 rgb
|
||||
* Added pfkey ident extension support for ISAKMPd. (NetCelo)
|
||||
*
|
||||
* Revision 1.31 2001/06/14 19:35:16 rgb
|
||||
* Update copyright date.
|
||||
*
|
||||
* Revision 1.30 2001/02/27 07:04:52 rgb
|
||||
* Added satype2name prototype.
|
||||
*
|
||||
* Revision 1.29 2001/02/26 19:59:33 rgb
|
||||
* Ditch unused sadb_satype2proto[], replaced by satype2proto().
|
||||
*
|
||||
* Revision 1.28 2000/10/10 20:10:19 rgb
|
||||
* Added support for debug_ipcomp and debug_verbose to klipsdebug.
|
||||
*
|
||||
* Revision 1.27 2000/09/21 04:20:45 rgb
|
||||
* Fixed array size off-by-one error. (Thanks Svenning!)
|
||||
*
|
||||
* Revision 1.26 2000/09/12 03:26:05 rgb
|
||||
* Added pfkey_acquire prototype.
|
||||
*
|
||||
* Revision 1.25 2000/09/08 19:21:28 rgb
|
||||
* Fix pfkey_prop_build() parameter to be only single indirection.
|
||||
*
|
||||
* Revision 1.24 2000/09/01 18:46:42 rgb
|
||||
* Added a supported algorithms array lists, one per satype and registered
|
||||
* existing algorithms.
|
||||
* Fixed pfkey_list_{insert,remove}_{socket,support}() to allow change to
|
||||
* list.
|
||||
*
|
||||
* Revision 1.23 2000/08/27 01:55:26 rgb
|
||||
* Define OCTETBITS and PFKEYBITS to avoid using 'magic' numbers in code.
|
||||
*
|
||||
* Revision 1.22 2000/08/20 21:39:23 rgb
|
||||
* Added kernel prototypes for kernel funcitions pfkey_upmsg() and
|
||||
* pfkey_expire().
|
||||
*
|
||||
* Revision 1.21 2000/08/15 17:29:23 rgb
|
||||
* Fixes from SZI to untested pfkey_prop_build().
|
||||
*
|
||||
* Revision 1.20 2000/05/10 20:14:19 rgb
|
||||
* Fleshed out sensitivity, proposal and supported extensions.
|
||||
*
|
||||
* Revision 1.19 2000/03/16 14:07:23 rgb
|
||||
* Renamed ALIGN macro to avoid fighting with others in kernel.
|
||||
*
|
||||
* Revision 1.18 2000/01/22 23:24:06 rgb
|
||||
* Added prototypes for proto2satype(), satype2proto() and proto2name().
|
||||
*
|
||||
* Revision 1.17 2000/01/21 06:26:59 rgb
|
||||
* Converted from double tdb arguments to one structure (extr)
|
||||
* containing pointers to all temporary information structures.
|
||||
* Added klipsdebug switching capability.
|
||||
* Dropped unused argument to pfkey_x_satype_build().
|
||||
*
|
||||
* Revision 1.16 1999/12/29 21:17:41 rgb
|
||||
* Changed pfkey_msg_build() I/F to include a struct sadb_msg**
|
||||
* parameter for cleaner manipulation of extensions[] and to guard
|
||||
* against potential memory leaks.
|
||||
* Changed the I/F to pfkey_msg_free() for the same reason.
|
||||
*
|
||||
* Revision 1.15 1999/12/09 23:12:54 rgb
|
||||
* Added macro for BITS_PER_OCTET.
|
||||
* Added argument to pfkey_sa_build() to do eroutes.
|
||||
*
|
||||
* Revision 1.14 1999/12/08 20:33:25 rgb
|
||||
* Changed sa_family_t to uint16_t for 2.0.xx compatibility.
|
||||
*
|
||||
* Revision 1.13 1999/12/07 19:53:40 rgb
|
||||
* Removed unused first argument from extension parsers.
|
||||
* Changed __u* types to uint* to avoid use of asm/types.h and
|
||||
* sys/types.h in userspace code.
|
||||
* Added function prototypes for pfkey message and extensions
|
||||
* initialisation and cleanup.
|
||||
*
|
||||
* Revision 1.12 1999/12/01 22:19:38 rgb
|
||||
* Change pfkey_sa_build to accept an SPI in network byte order.
|
||||
*
|
||||
* Revision 1.11 1999/11/27 11:55:26 rgb
|
||||
* Added extern sadb_satype2proto to enable moving protocol lookup table
|
||||
* to lib/pfkey_v2_parse.c.
|
||||
* Delete unused, moved typedefs.
|
||||
* Add argument to pfkey_msg_parse() for direction.
|
||||
* Consolidated the 4 1-d extension bitmap arrays into one 4-d array.
|
||||
*
|
||||
* Revision 1.10 1999/11/23 22:29:21 rgb
|
||||
* This file has been moved in the distribution from klips/net/ipsec to
|
||||
* lib.
|
||||
* Add macros for dealing with alignment and rounding up more opaquely.
|
||||
* The uint<n>_t type defines have been moved to freeswan.h to avoid
|
||||
* chicken-and-egg problems.
|
||||
* Add macros for dealing with alignment and rounding up more opaque.
|
||||
* Added prototypes for using extention header bitmaps.
|
||||
* Added prototypes of all the build functions.
|
||||
*
|
||||
* Revision 1.9 1999/11/20 21:59:48 rgb
|
||||
* Moved socketlist type declarations and prototypes for shared use.
|
||||
* Slightly modified scope of sockaddr_key declaration.
|
||||
*
|
||||
* Revision 1.8 1999/11/17 14:34:25 rgb
|
||||
* Protect sa_family_t from being used in userspace with GLIBC<2.
|
||||
*
|
||||
* Revision 1.7 1999/10/27 19:40:35 rgb
|
||||
* Add a maximum PFKEY packet size macro.
|
||||
*
|
||||
* Revision 1.6 1999/10/26 16:58:58 rgb
|
||||
* Created a sockaddr_key and key_opt socket extension structures.
|
||||
*
|
||||
* Revision 1.5 1999/06/10 05:24:41 rgb
|
||||
* Renamed variables to reduce confusion.
|
||||
*
|
||||
* Revision 1.4 1999/04/29 15:21:11 rgb
|
||||
* Add pfkey support to debugging.
|
||||
* Add return values to init and cleanup functions.
|
||||
*
|
||||
* Revision 1.3 1999/04/15 17:58:07 rgb
|
||||
* Add RCSID labels.
|
||||
*
|
||||
*/
|
||||
@@ -1,385 +0,0 @@
|
||||
/*
|
||||
* RCSID $Id: pfkeyv2.h,v 1.5 2004/10/04 22:43:56 as Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
RFC 2367 PF_KEY Key Management API July 1998
|
||||
|
||||
|
||||
Appendix D: Sample Header File
|
||||
|
||||
This file defines structures and symbols for the PF_KEY Version 2
|
||||
key management interface. It was written at the U.S. Naval Research
|
||||
Laboratory. This file is in the public domain. The authors ask that
|
||||
you leave this credit intact on any copies of this file.
|
||||
*/
|
||||
#ifndef __PFKEY_V2_H
|
||||
#define __PFKEY_V2_H 1
|
||||
|
||||
#define PF_KEY_V2 2
|
||||
#define PFKEYV2_REVISION 199806L
|
||||
|
||||
#define SADB_RESERVED 0
|
||||
#define SADB_GETSPI 1
|
||||
#define SADB_UPDATE 2
|
||||
#define SADB_ADD 3
|
||||
#define SADB_DELETE 4
|
||||
#define SADB_GET 5
|
||||
#define SADB_ACQUIRE 6
|
||||
#define SADB_REGISTER 7
|
||||
#define SADB_EXPIRE 8
|
||||
#define SADB_FLUSH 9
|
||||
#define SADB_DUMP 10
|
||||
#define SADB_X_PROMISC 11
|
||||
#define SADB_X_PCHANGE 12
|
||||
#define SADB_X_GRPSA 13
|
||||
#define SADB_X_ADDFLOW 14
|
||||
#define SADB_X_DELFLOW 15
|
||||
#define SADB_X_DEBUG 16
|
||||
#ifdef NAT_TRAVERSAL
|
||||
#define SADB_X_NAT_T_NEW_MAPPING 17
|
||||
#define SADB_MAX 17
|
||||
#else
|
||||
#define SADB_MAX 16
|
||||
#endif
|
||||
|
||||
struct sadb_msg {
|
||||
uint8_t sadb_msg_version;
|
||||
uint8_t sadb_msg_type;
|
||||
uint8_t sadb_msg_errno;
|
||||
uint8_t sadb_msg_satype;
|
||||
uint16_t sadb_msg_len;
|
||||
uint16_t sadb_msg_reserved;
|
||||
uint32_t sadb_msg_seq;
|
||||
uint32_t sadb_msg_pid;
|
||||
};
|
||||
|
||||
struct sadb_ext {
|
||||
uint16_t sadb_ext_len;
|
||||
uint16_t sadb_ext_type;
|
||||
};
|
||||
|
||||
struct sadb_sa {
|
||||
uint16_t sadb_sa_len;
|
||||
uint16_t sadb_sa_exttype;
|
||||
uint32_t sadb_sa_spi;
|
||||
uint8_t sadb_sa_replay;
|
||||
uint8_t sadb_sa_state;
|
||||
uint8_t sadb_sa_auth;
|
||||
uint8_t sadb_sa_encrypt;
|
||||
uint32_t sadb_sa_flags;
|
||||
uint32_t /*IPsecSAref_t*/ sadb_x_sa_ref; /* 32 bits */
|
||||
uint8_t sadb_x_reserved[4];
|
||||
};
|
||||
|
||||
struct sadb_sa_v1 {
|
||||
uint16_t sadb_sa_len;
|
||||
uint16_t sadb_sa_exttype;
|
||||
uint32_t sadb_sa_spi;
|
||||
uint8_t sadb_sa_replay;
|
||||
uint8_t sadb_sa_state;
|
||||
uint8_t sadb_sa_auth;
|
||||
uint8_t sadb_sa_encrypt;
|
||||
uint32_t sadb_sa_flags;
|
||||
};
|
||||
|
||||
struct sadb_lifetime {
|
||||
uint16_t sadb_lifetime_len;
|
||||
uint16_t sadb_lifetime_exttype;
|
||||
uint32_t sadb_lifetime_allocations;
|
||||
uint64_t sadb_lifetime_bytes;
|
||||
uint64_t sadb_lifetime_addtime;
|
||||
uint64_t sadb_lifetime_usetime;
|
||||
uint32_t sadb_x_lifetime_packets;
|
||||
uint32_t sadb_x_lifetime_reserved;
|
||||
};
|
||||
|
||||
struct sadb_address {
|
||||
uint16_t sadb_address_len;
|
||||
uint16_t sadb_address_exttype;
|
||||
uint8_t sadb_address_proto;
|
||||
uint8_t sadb_address_prefixlen;
|
||||
uint16_t sadb_address_reserved;
|
||||
};
|
||||
|
||||
struct sadb_key {
|
||||
uint16_t sadb_key_len;
|
||||
uint16_t sadb_key_exttype;
|
||||
uint16_t sadb_key_bits;
|
||||
uint16_t sadb_key_reserved;
|
||||
};
|
||||
|
||||
struct sadb_ident {
|
||||
uint16_t sadb_ident_len;
|
||||
uint16_t sadb_ident_exttype;
|
||||
uint16_t sadb_ident_type;
|
||||
uint16_t sadb_ident_reserved;
|
||||
uint64_t sadb_ident_id;
|
||||
};
|
||||
|
||||
struct sadb_sens {
|
||||
uint16_t sadb_sens_len;
|
||||
uint16_t sadb_sens_exttype;
|
||||
uint32_t sadb_sens_dpd;
|
||||
uint8_t sadb_sens_sens_level;
|
||||
uint8_t sadb_sens_sens_len;
|
||||
uint8_t sadb_sens_integ_level;
|
||||
uint8_t sadb_sens_integ_len;
|
||||
uint32_t sadb_sens_reserved;
|
||||
};
|
||||
|
||||
struct sadb_prop {
|
||||
uint16_t sadb_prop_len;
|
||||
uint16_t sadb_prop_exttype;
|
||||
uint8_t sadb_prop_replay;
|
||||
uint8_t sadb_prop_reserved[3];
|
||||
};
|
||||
|
||||
struct sadb_comb {
|
||||
uint8_t sadb_comb_auth;
|
||||
uint8_t sadb_comb_encrypt;
|
||||
uint16_t sadb_comb_flags;
|
||||
uint16_t sadb_comb_auth_minbits;
|
||||
uint16_t sadb_comb_auth_maxbits;
|
||||
uint16_t sadb_comb_encrypt_minbits;
|
||||
uint16_t sadb_comb_encrypt_maxbits;
|
||||
uint32_t sadb_comb_reserved;
|
||||
uint32_t sadb_comb_soft_allocations;
|
||||
uint32_t sadb_comb_hard_allocations;
|
||||
uint64_t sadb_comb_soft_bytes;
|
||||
uint64_t sadb_comb_hard_bytes;
|
||||
uint64_t sadb_comb_soft_addtime;
|
||||
uint64_t sadb_comb_hard_addtime;
|
||||
uint64_t sadb_comb_soft_usetime;
|
||||
uint64_t sadb_comb_hard_usetime;
|
||||
uint32_t sadb_x_comb_soft_packets;
|
||||
uint32_t sadb_x_comb_hard_packets;
|
||||
};
|
||||
|
||||
struct sadb_supported {
|
||||
uint16_t sadb_supported_len;
|
||||
uint16_t sadb_supported_exttype;
|
||||
uint32_t sadb_supported_reserved;
|
||||
};
|
||||
|
||||
struct sadb_alg {
|
||||
uint8_t sadb_alg_id;
|
||||
uint8_t sadb_alg_ivlen;
|
||||
uint16_t sadb_alg_minbits;
|
||||
uint16_t sadb_alg_maxbits;
|
||||
uint16_t sadb_alg_reserved;
|
||||
};
|
||||
|
||||
struct sadb_spirange {
|
||||
uint16_t sadb_spirange_len;
|
||||
uint16_t sadb_spirange_exttype;
|
||||
uint32_t sadb_spirange_min;
|
||||
uint32_t sadb_spirange_max;
|
||||
uint32_t sadb_spirange_reserved;
|
||||
};
|
||||
|
||||
struct sadb_x_kmprivate {
|
||||
uint16_t sadb_x_kmprivate_len;
|
||||
uint16_t sadb_x_kmprivate_exttype;
|
||||
uint32_t sadb_x_kmprivate_reserved;
|
||||
};
|
||||
|
||||
struct sadb_x_satype {
|
||||
uint16_t sadb_x_satype_len;
|
||||
uint16_t sadb_x_satype_exttype;
|
||||
uint8_t sadb_x_satype_satype;
|
||||
uint8_t sadb_x_satype_reserved[3];
|
||||
};
|
||||
|
||||
struct sadb_x_policy {
|
||||
uint16_t sadb_x_policy_len;
|
||||
uint16_t sadb_x_policy_exttype;
|
||||
uint16_t sadb_x_policy_type;
|
||||
uint8_t sadb_x_policy_dir;
|
||||
uint8_t sadb_x_policy_reserved;
|
||||
uint32_t sadb_x_policy_id;
|
||||
uint32_t sadb_x_policy_reserved2;
|
||||
};
|
||||
|
||||
struct sadb_x_debug {
|
||||
uint16_t sadb_x_debug_len;
|
||||
uint16_t sadb_x_debug_exttype;
|
||||
uint32_t sadb_x_debug_tunnel;
|
||||
uint32_t sadb_x_debug_netlink;
|
||||
uint32_t sadb_x_debug_xform;
|
||||
uint32_t sadb_x_debug_eroute;
|
||||
uint32_t sadb_x_debug_spi;
|
||||
uint32_t sadb_x_debug_radij;
|
||||
uint32_t sadb_x_debug_esp;
|
||||
uint32_t sadb_x_debug_ah;
|
||||
uint32_t sadb_x_debug_rcv;
|
||||
uint32_t sadb_x_debug_pfkey;
|
||||
uint32_t sadb_x_debug_ipcomp;
|
||||
uint32_t sadb_x_debug_verbose;
|
||||
uint8_t sadb_x_debug_reserved[4];
|
||||
};
|
||||
|
||||
#ifdef NAT_TRAVERSAL
|
||||
struct sadb_x_nat_t_type {
|
||||
uint16_t sadb_x_nat_t_type_len;
|
||||
uint16_t sadb_x_nat_t_type_exttype;
|
||||
uint8_t sadb_x_nat_t_type_type;
|
||||
uint8_t sadb_x_nat_t_type_reserved[3];
|
||||
};
|
||||
struct sadb_x_nat_t_port {
|
||||
uint16_t sadb_x_nat_t_port_len;
|
||||
uint16_t sadb_x_nat_t_port_exttype;
|
||||
uint16_t sadb_x_nat_t_port_port;
|
||||
uint16_t sadb_x_nat_t_port_reserved;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A protocol structure for passing through the transport level
|
||||
* protocol. It contains more fields than are actually used/needed
|
||||
* but it is this way to be compatible with the structure used in
|
||||
* OpenBSD (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/net/pfkeyv2.h)
|
||||
*/
|
||||
struct sadb_protocol {
|
||||
uint16_t sadb_protocol_len;
|
||||
uint16_t sadb_protocol_exttype;
|
||||
uint8_t sadb_protocol_proto;
|
||||
uint8_t sadb_protocol_direction;
|
||||
uint8_t sadb_protocol_flags;
|
||||
uint8_t sadb_protocol_reserved2;
|
||||
};
|
||||
|
||||
#define SADB_EXT_RESERVED 0
|
||||
#define SADB_EXT_SA 1
|
||||
#define SADB_EXT_LIFETIME_CURRENT 2
|
||||
#define SADB_EXT_LIFETIME_HARD 3
|
||||
#define SADB_EXT_LIFETIME_SOFT 4
|
||||
#define SADB_EXT_ADDRESS_SRC 5
|
||||
#define SADB_EXT_ADDRESS_DST 6
|
||||
#define SADB_EXT_ADDRESS_PROXY 7
|
||||
#define SADB_EXT_KEY_AUTH 8
|
||||
#define SADB_EXT_KEY_ENCRYPT 9
|
||||
#define SADB_EXT_IDENTITY_SRC 10
|
||||
#define SADB_EXT_IDENTITY_DST 11
|
||||
#define SADB_EXT_SENSITIVITY 12
|
||||
#define SADB_EXT_PROPOSAL 13
|
||||
#define SADB_EXT_SUPPORTED_AUTH 14
|
||||
#define SADB_EXT_SUPPORTED_ENCRYPT 15
|
||||
#define SADB_EXT_SPIRANGE 16
|
||||
#define SADB_X_EXT_KMPRIVATE 17
|
||||
#define SADB_X_EXT_SATYPE2 18
|
||||
#ifdef KERNEL26_HAS_KAME_DUPLICATES
|
||||
#define SADB_X_EXT_POLICY 18
|
||||
#endif
|
||||
#define SADB_X_EXT_SA2 19
|
||||
#define SADB_X_EXT_ADDRESS_DST2 20
|
||||
#define SADB_X_EXT_ADDRESS_SRC_FLOW 21
|
||||
#define SADB_X_EXT_ADDRESS_DST_FLOW 22
|
||||
#define SADB_X_EXT_ADDRESS_SRC_MASK 23
|
||||
#define SADB_X_EXT_ADDRESS_DST_MASK 24
|
||||
#define SADB_X_EXT_DEBUG 25
|
||||
#define SADB_X_EXT_PROTOCOL 26
|
||||
#ifdef NAT_TRAVERSAL
|
||||
#define SADB_X_EXT_NAT_T_TYPE 27
|
||||
#define SADB_X_EXT_NAT_T_SPORT 28
|
||||
#define SADB_X_EXT_NAT_T_DPORT 29
|
||||
#define SADB_X_EXT_NAT_T_OA 30
|
||||
#define SADB_EXT_MAX 30
|
||||
#else
|
||||
#define SADB_EXT_MAX 26
|
||||
#endif
|
||||
|
||||
/* SADB_X_DELFLOW required over and above SADB_X_SAFLAGS_CLEARFLOW */
|
||||
#define SADB_X_EXT_ADDRESS_DELFLOW \
|
||||
( (1<<SADB_X_EXT_ADDRESS_SRC_FLOW) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_DST_FLOW) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_SRC_MASK) \
|
||||
| (1<<SADB_X_EXT_ADDRESS_DST_MASK))
|
||||
|
||||
#define SADB_SATYPE_UNSPEC 0
|
||||
#define SADB_SATYPE_AH 2
|
||||
#define SADB_SATYPE_ESP 3
|
||||
#define SADB_SATYPE_RSVP 5
|
||||
#define SADB_SATYPE_OSPFV2 6
|
||||
#define SADB_SATYPE_RIPV2 7
|
||||
#define SADB_SATYPE_MIP 8
|
||||
#define SADB_X_SATYPE_IPIP 9
|
||||
#ifdef KERNEL26_HAS_KAME_DUPLICATES
|
||||
#define SADB_X_SATYPE_IPCOMP 9 /* ICK! */
|
||||
#endif
|
||||
#define SADB_X_SATYPE_COMP 10
|
||||
#define SADB_X_SATYPE_INT 11
|
||||
#define SADB_SATYPE_MAX 11
|
||||
|
||||
#define SADB_SASTATE_LARVAL 0
|
||||
#define SADB_SASTATE_MATURE 1
|
||||
#define SADB_SASTATE_DYING 2
|
||||
#define SADB_SASTATE_DEAD 3
|
||||
#define SADB_SASTATE_MAX 3
|
||||
|
||||
#define SADB_SAFLAGS_PFS 1
|
||||
#define SADB_X_SAFLAGS_REPLACEFLOW 2
|
||||
#define SADB_X_SAFLAGS_CLEARFLOW 4
|
||||
#define SADB_X_SAFLAGS_INFLOW 8
|
||||
|
||||
/* not obvious, but these are the same values as used in isakmp,
|
||||
* and in freeswan/ipsec_policy.h. If you need to add any, they
|
||||
* should be added as according to
|
||||
* http://www.iana.org/assignments/isakmp-registry
|
||||
*
|
||||
* and if not, then please try to use a private-use value, and
|
||||
* consider asking IANA to assign a value.
|
||||
*/
|
||||
#define SADB_AALG_NONE 0
|
||||
#define SADB_AALG_MD5_HMAC 2
|
||||
#define SADB_AALG_SHA1_HMAC 3
|
||||
#define SADB_AALG_DES_MAC 4
|
||||
#define SADB_AALG_SHA2_256_HMAC 5
|
||||
#define SADB_AALG_SHA2_384_HMAC 6
|
||||
#define SADB_AALG_SHA2_512_HMAC 7
|
||||
#define SADB_AALG_RIPEMD_160_HMAC 8
|
||||
#define SADB_AALG_AES_XCBC_MAC 9
|
||||
#define SADB_X_AALG_NULL 251 /* kame */
|
||||
#define SADB_AALG_MAX 251
|
||||
|
||||
#define SADB_EALG_NONE 0
|
||||
#define SADB_EALG_DES_CBC 2
|
||||
#define SADB_EALG_3DES_CBC 3
|
||||
#define SADB_EALG_RC5_CBC 4
|
||||
#define SADB_EALG_IDEA_CBC 5
|
||||
#define SADB_EALG_CAST_CBC 6
|
||||
#define SADB_EALG_BLOWFISH_CBC 7
|
||||
#define SADB_EALG_NULL 11
|
||||
#define SADB_EALG_AES_CBC 12
|
||||
#define SADB_EALG_AES_CTR 13
|
||||
#define SADB_X_EALG_SERPENT_CBC 252
|
||||
#define SADB_X_EALG_TWOFISH_CBC 253
|
||||
#define SADB_EALG_MAX 253
|
||||
|
||||
#define SADB_X_CALG_NONE 0
|
||||
#define SADB_X_CALG_OUI 1
|
||||
#define SADB_X_CALG_DEFLATE 2
|
||||
#define SADB_X_CALG_LZS 3
|
||||
#define SADB_X_CALG_V42BIS 4
|
||||
#ifdef KERNEL26_HAS_KAME_DUPLICATES
|
||||
#define SADB_X_CALG_LZJH 4
|
||||
#endif
|
||||
#define SADB_X_CALG_MAX 4
|
||||
|
||||
#define SADB_X_TALG_NONE 0
|
||||
#define SADB_X_TALG_IPv4_in_IPv4 1
|
||||
#define SADB_X_TALG_IPv6_in_IPv4 2
|
||||
#define SADB_X_TALG_IPv4_in_IPv6 3
|
||||
#define SADB_X_TALG_IPv6_in_IPv6 4
|
||||
#define SADB_X_TALG_MAX 4
|
||||
|
||||
|
||||
#define SADB_IDENTTYPE_RESERVED 0
|
||||
#define SADB_IDENTTYPE_PREFIX 1
|
||||
#define SADB_IDENTTYPE_FQDN 2
|
||||
#define SADB_IDENTTYPE_USERFQDN 3
|
||||
#define SADB_X_IDENTTYPE_CONNECTION 4
|
||||
#define SADB_IDENTTYPE_MAX 4
|
||||
|
||||
#define SADB_KEY_FLAGS_MAX 0
|
||||
#endif /* __PFKEY_V2_H */
|
||||
@@ -1,893 +0,0 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.1.4, March 11th, 2002
|
||||
|
||||
Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
[email protected] [email protected]
|
||||
|
||||
|
||||
The data format used by the zlib library is described by RFCs (Request for
|
||||
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
|
||||
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
||||
*/
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#define _ZLIB_H
|
||||
|
||||
#include "zconf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.1.4"
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
decompression functions, including integrity checks of the uncompressed
|
||||
data. This version of the library supports only one compression method
|
||||
(deflation) but other algorithms will be added later and will have the same
|
||||
stream interface.
|
||||
|
||||
Compression can be done in a single step if the buffers are large
|
||||
enough (for example if an input file is mmap'ed), or can be done by
|
||||
repeated calls of the compression function. In the latter case, the
|
||||
application must provide more input and/or consume the output
|
||||
(providing more output space) before each call.
|
||||
|
||||
The library also supports reading and writing files in gzip (.gz) format
|
||||
with an interface similar to that of stdio.
|
||||
|
||||
The library does not install any signal handler. The decoder checks
|
||||
the consistency of the compressed data, so the library should never
|
||||
crash even in case of corrupted input.
|
||||
*/
|
||||
|
||||
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
||||
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||
|
||||
struct internal_state;
|
||||
|
||||
typedef struct z_stream_s {
|
||||
Bytef *next_in; /* next input byte */
|
||||
uInt avail_in; /* number of bytes available at next_in */
|
||||
uLong total_in; /* total nb of input bytes read so far */
|
||||
|
||||
Bytef *next_out; /* next output byte should be put there */
|
||||
uInt avail_out; /* remaining free space at next_out */
|
||||
uLong total_out; /* total nb of bytes output so far */
|
||||
|
||||
const char *msg; /* last error message, NULL if no error */
|
||||
struct internal_state FAR *state; /* not visible by applications */
|
||||
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
free_func zfree; /* used to free the internal state */
|
||||
voidpf opaque; /* private data object passed to zalloc and zfree */
|
||||
|
||||
int data_type; /* best guess about the data type: ascii or binary */
|
||||
uLong adler; /* adler32 value of the uncompressed data */
|
||||
uLong reserved; /* reserved for future use */
|
||||
} z_stream;
|
||||
|
||||
typedef z_stream FAR *z_streamp;
|
||||
|
||||
/*
|
||||
The application must update next_in and avail_in when avail_in has
|
||||
dropped to zero. It must update next_out and avail_out when avail_out
|
||||
has dropped to zero. The application must initialize zalloc, zfree and
|
||||
opaque before calling the init function. All other fields are set by the
|
||||
compression library and must not be updated by the application.
|
||||
|
||||
The opaque value provided by the application will be passed as the first
|
||||
parameter for calls of zalloc and zfree. This can be useful for custom
|
||||
memory management. The compression library attaches no meaning to the
|
||||
opaque value.
|
||||
|
||||
zalloc must return Z_NULL if there is not enough memory for the object.
|
||||
If zlib is used in a multi-threaded application, zalloc and zfree must be
|
||||
thread safe.
|
||||
|
||||
On 16-bit systems, the functions zalloc and zfree must be able to allocate
|
||||
exactly 65536 bytes, but will not be required to allocate more than this
|
||||
if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
|
||||
pointers returned by zalloc for objects of exactly 65536 bytes *must*
|
||||
have their offset normalized to zero. The default allocation function
|
||||
provided by this library ensures this (see zutil.c). To reduce memory
|
||||
requirements and avoid any allocation of 64K objects, at the expense of
|
||||
compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
|
||||
|
||||
The fields total_in and total_out can be used for statistics or
|
||||
progress reports. After compression, total_in holds the total size of
|
||||
the uncompressed data and may be saved for use in the decompressor
|
||||
(particularly if the decompressor wants to decompress everything in
|
||||
a single step).
|
||||
*/
|
||||
|
||||
/* constants */
|
||||
|
||||
#define Z_NO_FLUSH 0
|
||||
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
|
||||
#define Z_SYNC_FLUSH 2
|
||||
#define Z_FULL_FLUSH 3
|
||||
#define Z_FINISH 4
|
||||
/* Allowed flush values; see deflate() below for details */
|
||||
|
||||
#define Z_OK 0
|
||||
#define Z_STREAM_END 1
|
||||
#define Z_NEED_DICT 2
|
||||
#define Z_ERRNO (-1)
|
||||
#define Z_STREAM_ERROR (-2)
|
||||
#define Z_DATA_ERROR (-3)
|
||||
#define Z_MEM_ERROR (-4)
|
||||
#define Z_BUF_ERROR (-5)
|
||||
#define Z_VERSION_ERROR (-6)
|
||||
/* Return codes for the compression/decompression functions. Negative
|
||||
* values are errors, positive values are used for special but normal events.
|
||||
*/
|
||||
|
||||
#define Z_NO_COMPRESSION 0
|
||||
#define Z_BEST_SPEED 1
|
||||
#define Z_BEST_COMPRESSION 9
|
||||
#define Z_DEFAULT_COMPRESSION (-1)
|
||||
/* compression levels */
|
||||
|
||||
#define Z_FILTERED 1
|
||||
#define Z_HUFFMAN_ONLY 2
|
||||
#define Z_DEFAULT_STRATEGY 0
|
||||
/* compression strategy; see deflateInit2() below for details */
|
||||
|
||||
#define Z_BINARY 0
|
||||
#define Z_ASCII 1
|
||||
#define Z_UNKNOWN 2
|
||||
/* Possible values of the data_type field */
|
||||
|
||||
#define Z_DEFLATED 8
|
||||
/* The deflate compression method (the only one supported in this version) */
|
||||
|
||||
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
||||
|
||||
#define zlib_version zlibVersion()
|
||||
/* for compatibility with versions < 1.0.2 */
|
||||
|
||||
/* basic functions */
|
||||
|
||||
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
|
||||
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||
If the first character differs, the library code actually used is
|
||||
not compatible with the zlib.h header file used by the application.
|
||||
This check is automatically made by deflateInit and inflateInit.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
||||
|
||||
Initializes the internal stream state for compression. The fields
|
||||
zalloc, zfree and opaque must be initialized before by the caller.
|
||||
If zalloc and zfree are set to Z_NULL, deflateInit updates them to
|
||||
use default allocation functions.
|
||||
|
||||
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
|
||||
1 gives best speed, 9 gives best compression, 0 gives no compression at
|
||||
all (the input data is simply copied a block at a time).
|
||||
Z_DEFAULT_COMPRESSION requests a default compromise between speed and
|
||||
compression (currently equivalent to level 6).
|
||||
|
||||
deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if level is not a valid compression level,
|
||||
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
|
||||
with the version assumed by the caller (ZLIB_VERSION).
|
||||
msg is set to null if there is no error message. deflateInit does not
|
||||
perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
deflate compresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may introduce some
|
||||
output latency (reading input without producing any output) except when
|
||||
forced to flush.
|
||||
|
||||
The detailed semantics are as follows. deflate performs one or both of the
|
||||
following actions:
|
||||
|
||||
- Compress more input starting at next_in and update next_in and avail_in
|
||||
accordingly. If not all input can be processed (because there is not
|
||||
enough room in the output buffer), next_in and avail_in are updated and
|
||||
processing will resume at this point for the next call of deflate().
|
||||
|
||||
- Provide more output starting at next_out and update next_out and avail_out
|
||||
accordingly. This action is forced if the parameter flush is non zero.
|
||||
Forcing flush frequently degrades the compression ratio, so this parameter
|
||||
should be set only when necessary (in interactive applications).
|
||||
Some output may be provided even if flush is not set.
|
||||
|
||||
Before the call of deflate(), the application should ensure that at least
|
||||
one of the actions is possible, by providing more input and/or consuming
|
||||
more output, and updating avail_in or avail_out accordingly; avail_out
|
||||
should never be zero before the call. The application can consume the
|
||||
compressed output when it wants, for example when the output buffer is full
|
||||
(avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
|
||||
and with zero avail_out, it must be called again after making room in the
|
||||
output buffer because there might be more output pending.
|
||||
|
||||
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
|
||||
flushed to the output buffer and the output is aligned on a byte boundary, so
|
||||
that the decompressor can get all input data available so far. (In particular
|
||||
avail_in is zero after the call if enough output space has been provided
|
||||
before the call.) Flushing may degrade compression for some compression
|
||||
algorithms and so it should be used only when necessary.
|
||||
|
||||
If flush is set to Z_FULL_FLUSH, all output is flushed as with
|
||||
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
|
||||
restart from this point if previous compressed data has been damaged or if
|
||||
random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
|
||||
the compression.
|
||||
|
||||
If deflate returns with avail_out == 0, this function must be called again
|
||||
with the same value of the flush parameter and more output space (updated
|
||||
avail_out), until the flush is complete (deflate returns with non-zero
|
||||
avail_out).
|
||||
|
||||
If the parameter flush is set to Z_FINISH, pending input is processed,
|
||||
pending output is flushed and deflate returns with Z_STREAM_END if there
|
||||
was enough output space; if deflate returns with Z_OK, this function must be
|
||||
called again with Z_FINISH and more output space (updated avail_out) but no
|
||||
more input data, until it returns with Z_STREAM_END or an error. After
|
||||
deflate has returned Z_STREAM_END, the only possible operations on the
|
||||
stream are deflateReset or deflateEnd.
|
||||
|
||||
Z_FINISH can be used immediately after deflateInit if all the compression
|
||||
is to be done in a single step. In this case, avail_out must be at least
|
||||
0.1% larger than avail_in plus 12 bytes. If deflate does not return
|
||||
Z_STREAM_END, then it must be called again as described above.
|
||||
|
||||
deflate() sets strm->adler to the adler32 checksum of all input read
|
||||
so far (that is, total_in bytes).
|
||||
|
||||
deflate() may update data_type if it can make a good guess about
|
||||
the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
|
||||
binary. This field is only for information purposes and does not affect
|
||||
the compression algorithm in any manner.
|
||||
|
||||
deflate() returns Z_OK if some progress has been made (more input
|
||||
processed or more output produced), Z_STREAM_END if all input has been
|
||||
consumed and all output has been produced (only when flush is set to
|
||||
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
|
||||
if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
|
||||
(for example avail_in or avail_out was zero).
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
pending output.
|
||||
|
||||
deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
|
||||
stream state was inconsistent, Z_DATA_ERROR if the stream was freed
|
||||
prematurely (some input or output was discarded). In the error case,
|
||||
msg may be set but then points to a static string (which must not be
|
||||
deallocated).
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
||||
|
||||
Initializes the internal stream state for decompression. The fields
|
||||
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
|
||||
the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
|
||||
value depends on the compression method), inflateInit determines the
|
||||
compression method from the zlib header and allocates all data structures
|
||||
accordingly; otherwise the allocation will be deferred to the first call of
|
||||
inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
|
||||
use default allocation functions.
|
||||
|
||||
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||
version assumed by the caller. msg is set to null if there is no error
|
||||
message. inflateInit does not perform any decompression apart from reading
|
||||
the zlib header if present: this will be done by inflate(). (So next_in and
|
||||
avail_in may be modified, but next_out and avail_out are unchanged.)
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
inflate decompresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may some
|
||||
introduce some output latency (reading input without producing any output)
|
||||
except when forced to flush.
|
||||
|
||||
The detailed semantics are as follows. inflate performs one or both of the
|
||||
following actions:
|
||||
|
||||
- Decompress more input starting at next_in and update next_in and avail_in
|
||||
accordingly. If not all input can be processed (because there is not
|
||||
enough room in the output buffer), next_in is updated and processing
|
||||
will resume at this point for the next call of inflate().
|
||||
|
||||
- Provide more output starting at next_out and update next_out and avail_out
|
||||
accordingly. inflate() provides as much output as possible, until there
|
||||
is no more input data or no more space in the output buffer (see below
|
||||
about the flush parameter).
|
||||
|
||||
Before the call of inflate(), the application should ensure that at least
|
||||
one of the actions is possible, by providing more input and/or consuming
|
||||
more output, and updating the next_* and avail_* values accordingly.
|
||||
The application can consume the uncompressed output when it wants, for
|
||||
example when the output buffer is full (avail_out == 0), or after each
|
||||
call of inflate(). If inflate returns Z_OK and with zero avail_out, it
|
||||
must be called again after making room in the output buffer because there
|
||||
might be more output pending.
|
||||
|
||||
If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
|
||||
output as possible to the output buffer. The flushing behavior of inflate is
|
||||
not specified for values of the flush parameter other than Z_SYNC_FLUSH
|
||||
and Z_FINISH, but the current implementation actually flushes as much output
|
||||
as possible anyway.
|
||||
|
||||
inflate() should normally be called until it returns Z_STREAM_END or an
|
||||
error. However if all decompression is to be performed in a single step
|
||||
(a single call of inflate), the parameter flush should be set to
|
||||
Z_FINISH. In this case all pending input is processed and all pending
|
||||
output is flushed; avail_out must be large enough to hold all the
|
||||
uncompressed data. (The size of the uncompressed data may have been saved
|
||||
by the compressor for this purpose.) The next operation on this stream must
|
||||
be inflateEnd to deallocate the decompression state. The use of Z_FINISH
|
||||
is never required, but can be used to inform inflate that a faster routine
|
||||
may be used for the single inflate() call.
|
||||
|
||||
If a preset dictionary is needed at this point (see inflateSetDictionary
|
||||
below), inflate sets strm-adler to the adler32 checksum of the
|
||||
dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
|
||||
it sets strm->adler to the adler32 checksum of all output produced
|
||||
so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
|
||||
an error code as described below. At the end of the stream, inflate()
|
||||
checks that its computed adler32 checksum is equal to that saved by the
|
||||
compressor and returns Z_STREAM_END only if the checksum is correct.
|
||||
|
||||
inflate() returns Z_OK if some progress has been made (more input processed
|
||||
or more output produced), Z_STREAM_END if the end of the compressed data has
|
||||
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
|
||||
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
|
||||
corrupted (input stream not conforming to the zlib format or incorrect
|
||||
adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
|
||||
(for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if no progress is possible or if there was not
|
||||
enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
|
||||
case, the application may then call inflateSync to look for a good
|
||||
compression block.
|
||||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
pending output.
|
||||
|
||||
inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
|
||||
was inconsistent. In the error case, msg may be set but then points to a
|
||||
static string (which must not be deallocated).
|
||||
*/
|
||||
|
||||
/* Advanced functions */
|
||||
|
||||
/*
|
||||
The following functions are needed only in some special applications.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||
int level,
|
||||
int method,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy));
|
||||
|
||||
This is another version of deflateInit with more compression options. The
|
||||
fields next_in, zalloc, zfree and opaque must be initialized before by
|
||||
the caller.
|
||||
|
||||
The method parameter is the compression method. It must be Z_DEFLATED in
|
||||
this version of the library.
|
||||
|
||||
The windowBits parameter is the base two logarithm of the window size
|
||||
(the size of the history buffer). It should be in the range 8..15 for this
|
||||
version of the library. Larger values of this parameter result in better
|
||||
compression at the expense of memory usage. The default value is 15 if
|
||||
deflateInit is used instead.
|
||||
|
||||
The memLevel parameter specifies how much memory should be allocated
|
||||
for the internal compression state. memLevel=1 uses minimum memory but
|
||||
is slow and reduces compression ratio; memLevel=9 uses maximum memory
|
||||
for optimal speed. The default value is 8. See zconf.h for total memory
|
||||
usage as a function of windowBits and memLevel.
|
||||
|
||||
The strategy parameter is used to tune the compression algorithm. Use the
|
||||
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
|
||||
filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
|
||||
string match). Filtered data consists mostly of small values with a
|
||||
somewhat random distribution. In this case, the compression algorithm is
|
||||
tuned to compress them better. The effect of Z_FILTERED is to force more
|
||||
Huffman coding and less string matching; it is somewhat intermediate
|
||||
between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
|
||||
the compression ratio but not the correctness of the compressed output even
|
||||
if it is not set appropriately.
|
||||
|
||||
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
||||
method). msg is set to null if there is no error message. deflateInit2 does
|
||||
not perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the compression dictionary from the given byte sequence
|
||||
without producing any compressed output. This function must be called
|
||||
immediately after deflateInit, deflateInit2 or deflateReset, before any
|
||||
call of deflate. The compressor and decompressor must use exactly the same
|
||||
dictionary (see inflateSetDictionary).
|
||||
|
||||
The dictionary should consist of strings (byte sequences) that are likely
|
||||
to be encountered later in the data to be compressed, with the most commonly
|
||||
used strings preferably put towards the end of the dictionary. Using a
|
||||
dictionary is most useful when the data to be compressed is short and can be
|
||||
predicted with good accuracy; the data can then be compressed better than
|
||||
with the default empty dictionary.
|
||||
|
||||
Depending on the size of the compression data structures selected by
|
||||
deflateInit or deflateInit2, a part of the dictionary may in effect be
|
||||
discarded, for example if the dictionary is larger than the window size in
|
||||
deflate or deflate2. Thus the strings most likely to be useful should be
|
||||
put at the end of the dictionary, not at the front.
|
||||
|
||||
Upon return of this function, strm->adler is set to the Adler32 value
|
||||
of the dictionary; the decompressor may later use this value to determine
|
||||
which dictionary has been used by the compressor. (The Adler32 value
|
||||
applies to the whole dictionary even if only a subset of the dictionary is
|
||||
actually used by the compressor.)
|
||||
|
||||
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
inconsistent (for example if deflate has already been called for this stream
|
||||
or if the compression method is bsort). deflateSetDictionary does not
|
||||
perform any compression: this will be done by deflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||
z_streamp source));
|
||||
/*
|
||||
Sets the destination stream as a complete copy of the source stream.
|
||||
|
||||
This function can be useful when several compression strategies will be
|
||||
tried, for example when there are several ways of pre-processing the input
|
||||
data with a filter. The streams that will be discarded should then be freed
|
||||
by calling deflateEnd. Note that deflateCopy duplicates the internal
|
||||
compression state which can be quite large, so this strategy is slow and
|
||||
can consume lots of memory.
|
||||
|
||||
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||
(such as zalloc being NULL). msg is left unchanged in both source and
|
||||
destination.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to deflateEnd followed by deflateInit,
|
||||
but does not free and reallocate all the internal compression state.
|
||||
The stream will keep the same compression level and any other attributes
|
||||
that may have been set by deflateInit2.
|
||||
|
||||
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||
int level,
|
||||
int strategy));
|
||||
/*
|
||||
Dynamically update the compression level and compression strategy. The
|
||||
interpretation of level and strategy is as in deflateInit2. This can be
|
||||
used to switch between compression and straight copy of the input data, or
|
||||
to switch to a different kind of input data requiring a different
|
||||
strategy. If the compression level is changed, the input available so far
|
||||
is compressed with the old level (and may be flushed); the new level will
|
||||
take effect only at the next call of deflate().
|
||||
|
||||
Before the call of deflateParams, the stream state must be set as for
|
||||
a call of deflate(), since the currently available input may have to
|
||||
be compressed and flushed. In particular, strm->avail_out must be non-zero.
|
||||
|
||||
deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
|
||||
if strm->avail_out was zero.
|
||||
*/
|
||||
|
||||
/*
|
||||
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||
int windowBits));
|
||||
|
||||
This is another version of inflateInit with an extra parameter. The
|
||||
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
|
||||
before by the caller.
|
||||
|
||||
The windowBits parameter is the base two logarithm of the maximum window
|
||||
size (the size of the history buffer). It should be in the range 8..15 for
|
||||
this version of the library. The default value is 15 if inflateInit is used
|
||||
instead. If a compressed stream with a larger window size is given as
|
||||
input, inflate() will return with the error code Z_DATA_ERROR instead of
|
||||
trying to allocate a larger window.
|
||||
|
||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||
memLevel). msg is set to null if there is no error message. inflateInit2
|
||||
does not perform any decompression apart from reading the zlib header if
|
||||
present: this will be done by inflate(). (So next_in and avail_in may be
|
||||
modified, but next_out and avail_out are unchanged.)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the decompression dictionary from the given uncompressed byte
|
||||
sequence. This function must be called immediately after a call of inflate
|
||||
if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||
can be determined from the Adler32 value returned by this call of
|
||||
inflate. The compressor and decompressor must use exactly the same
|
||||
dictionary (see deflateSetDictionary).
|
||||
|
||||
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
|
||||
expected one (incorrect Adler32 value). inflateSetDictionary does not
|
||||
perform any decompression: this will be done by subsequent calls of
|
||||
inflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||
/*
|
||||
Skips invalid compressed data until a full flush point (see above the
|
||||
description of deflate with Z_FULL_FLUSH) can be found, or until all
|
||||
available input is skipped. No output is provided.
|
||||
|
||||
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
|
||||
if no more input was provided, Z_DATA_ERROR if no flush point has been found,
|
||||
or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
|
||||
case, the application may save the current current value of total_in which
|
||||
indicates where valid compressed data was found. In the error case, the
|
||||
application may repeatedly call inflateSync, providing more input each time,
|
||||
until success or end of the input data.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to inflateEnd followed by inflateInit,
|
||||
but does not free and reallocate all the internal decompression state.
|
||||
The stream will keep attributes that may have been set by inflateInit2.
|
||||
|
||||
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||
stream state was inconsistent (such as zalloc or state being NULL).
|
||||
*/
|
||||
|
||||
|
||||
/* utility functions */
|
||||
|
||||
/*
|
||||
The following utility functions are implemented on top of the
|
||||
basic stream-oriented functions. To simplify the interface, some
|
||||
default options are assumed (compression level and memory usage,
|
||||
standard memory allocation functions). The source code of these
|
||||
utility functions can easily be modified if you need special options.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be at least 0.1% larger than
|
||||
sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
|
||||
compressed buffer.
|
||||
This function can be used to compress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
compress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen,
|
||||
int level));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||
length of the source buffer. Upon entry, destLen is the total size of the
|
||||
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||
|
||||
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be large enough to hold the
|
||||
entire uncompressed data. (The size of the uncompressed data must have
|
||||
been saved previously by the compressor and transmitted to the decompressor
|
||||
by some mechanism outside the scope of this compression library.)
|
||||
Upon exit, destLen is the actual size of the compressed buffer.
|
||||
This function can be used to decompress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
|
||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
*/
|
||||
|
||||
|
||||
typedef voidp gzFile;
|
||||
|
||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||
/*
|
||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||
is as in fopen ("rb" or "wb") but can also include a compression level
|
||||
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
||||
Huffman only compression as in "wb1h". (See the description
|
||||
of deflateInit2 for more information about the strategy parameter.)
|
||||
|
||||
gzopen can be used to read a file which is not in gzip format; in this
|
||||
case gzread will directly read from the file without decompression.
|
||||
|
||||
gzopen returns NULL if the file could not be opened or if there was
|
||||
insufficient memory to allocate the (de)compression state; errno
|
||||
can be checked to distinguish the two cases (if errno is zero, the
|
||||
zlib error is Z_MEM_ERROR). */
|
||||
|
||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||
/*
|
||||
gzdopen() associates a gzFile with the file descriptor fd. File
|
||||
descriptors are obtained from calls like open, dup, creat, pipe or
|
||||
fileno (in the file has been previously opened with fopen).
|
||||
The mode parameter is as in gzopen.
|
||||
The next call of gzclose on the returned gzFile will also close the
|
||||
file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
|
||||
descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
|
||||
gzdopen returns NULL if there was insufficient memory to allocate
|
||||
the (de)compression state.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||
/*
|
||||
Dynamically update the compression level or strategy. See the description
|
||||
of deflateInit2 for the meaning of these parameters.
|
||||
gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
|
||||
opened for writing.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||
/*
|
||||
Reads the given number of uncompressed bytes from the compressed file.
|
||||
If the input file was not in gzip format, gzread copies the given number
|
||||
of bytes into the buffer.
|
||||
gzread returns the number of uncompressed bytes actually read (0 for
|
||||
end of file, -1 for error). */
|
||||
|
||||
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
||||
const voidp buf, unsigned len));
|
||||
/*
|
||||
Writes the given number of uncompressed bytes into the compressed file.
|
||||
gzwrite returns the number of uncompressed bytes actually written
|
||||
(0 in case of error).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
||||
/*
|
||||
Converts, formats, and writes the args to the compressed file under
|
||||
control of the format string, as in fprintf. gzprintf returns the number of
|
||||
uncompressed bytes actually written (0 in case of error).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||
/*
|
||||
Writes the given null-terminated string to the compressed file, excluding
|
||||
the terminating null character.
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||
/*
|
||||
Reads bytes from the compressed file until len-1 characters are read, or
|
||||
a newline character is read and transferred to buf, or an end-of-file
|
||||
condition is encountered. The string is then terminated with a null
|
||||
character.
|
||||
gzgets returns buf, or Z_NULL in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||
/*
|
||||
Writes c, converted to an unsigned char, into the compressed file.
|
||||
gzputc returns the value that was written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||
/*
|
||||
Reads one byte from the compressed file. gzgetc returns this byte
|
||||
or -1 in case of end of file or error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||
/*
|
||||
Flushes all pending output into the compressed file. The parameter
|
||||
flush is as in the deflate() function. The return value is the zlib
|
||||
error number (see function gzerror below). gzflush returns Z_OK if
|
||||
the flush parameter is Z_FINISH and all output could be flushed.
|
||||
gzflush should be called only when strictly necessary because it can
|
||||
degrade compression.
|
||||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||
z_off_t offset, int whence));
|
||||
/*
|
||||
Sets the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. The offset represents a number of bytes in the
|
||||
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||
the value SEEK_END is not supported.
|
||||
If the file is opened for reading, this function is emulated but can be
|
||||
extremely slow. If the file is opened for writing, only forward seeks are
|
||||
supported; gzseek then compresses a sequence of zeroes up to the new
|
||||
starting position.
|
||||
|
||||
gzseek returns the resulting offset location as measured in bytes from
|
||||
the beginning of the uncompressed stream, or -1 in case of error, in
|
||||
particular if the file is opened for writing and the new starting position
|
||||
would be before the current position.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||
/*
|
||||
Rewinds the given file. This function is supported only for reading.
|
||||
|
||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
||||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||
/*
|
||||
Returns the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. This position represents a number of bytes in the
|
||||
uncompressed data stream.
|
||||
|
||||
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||
/*
|
||||
Returns 1 when EOF has previously been detected reading the given
|
||||
input stream, otherwise zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||
/*
|
||||
Flushes all pending output if necessary, closes the compressed file
|
||||
and deallocates all the (de)compression state. The return value is the zlib
|
||||
error number (see function gzerror below).
|
||||
*/
|
||||
|
||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||
/*
|
||||
Returns the error message for the last error which occurred on the
|
||||
given compressed file. errnum is set to zlib error number. If an
|
||||
error occurred in the file system and not in the compression library,
|
||||
errnum is set to Z_ERRNO and the application may consult errno
|
||||
to get the exact error code.
|
||||
*/
|
||||
|
||||
/* checksum functions */
|
||||
|
||||
/*
|
||||
These functions are not related to compression but are exported
|
||||
anyway because they might be useful in applications using the
|
||||
compression library.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
the required initial value for the checksum.
|
||||
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||
much faster. Usage example:
|
||||
|
||||
uLong adler = adler32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
adler = adler32(adler, buffer, length);
|
||||
}
|
||||
if (adler != original_adler) error();
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
uLong crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
crc = crc32(crc, buffer, length);
|
||||
}
|
||||
if (crc != original_crc) error();
|
||||
*/
|
||||
|
||||
|
||||
/* various hacks, don't look :) */
|
||||
|
||||
/* deflateInit and inflateInit are macros to allow checking the zlib version
|
||||
* and the compiler's view of z_stream:
|
||||
*/
|
||||
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel,
|
||||
int strategy, const char *version,
|
||||
int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size));
|
||||
#define deflateInit(strm, level) \
|
||||
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit(strm) \
|
||||
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
||||
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
||||
(strategy), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit2(strm, windowBits) \
|
||||
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
||||
|
||||
|
||||
#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
|
||||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||
#endif
|
||||
|
||||
ZEXTERN const char * ZEXPORT zError OF((int err));
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZLIB_H */
|
||||
@@ -1,225 +0,0 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id: zutil.h,v 1.1 2004/03/15 20:35:25 as Exp $ */
|
||||
|
||||
#ifndef _Z_UTIL_H
|
||||
#define _Z_UTIL_H
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
#include <linux/string.h>
|
||||
#define HAVE_MEMCPY
|
||||
|
||||
#if 0 // #ifdef STDC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifndef __KERNEL__
|
||||
#ifdef NO_ERRNO_H
|
||||
extern int errno;
|
||||
#else
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#ifdef MSDOS
|
||||
# define OS_CODE 0x00
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 0x06
|
||||
#endif
|
||||
|
||||
#ifdef WIN32 /* Window 95 & Windows NT */
|
||||
# define OS_CODE 0x0b
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 0x02
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 0x01
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 0x05
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
# define OS_CODE 0x07
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||
# define OS_CODE 0x0F
|
||||
#endif
|
||||
|
||||
#ifdef TOPS20
|
||||
# define OS_CODE 0x0a
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
||||
# define fdopen(fd,type) _fdopen(fd,type)
|
||||
#endif
|
||||
|
||||
|
||||
/* Common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 0x03 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
#endif
|
||||
|
||||
#if defined(pyr)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
extern int z_verbose;
|
||||
extern void z_error OF((char *m));
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
|
||||
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
|
||||
uInt len));
|
||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
#endif /* _Z_UTIL_H */
|
||||
@@ -1,121 +0,0 @@
|
||||
# (kernel) Makefile for IPCOMP zlib deflate code
|
||||
# Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
|
||||
# Copyright (C) 2000 Svenning Soerensen
|
||||
#
|
||||
# This program 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. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# RCSID $Id: Makefile,v 1.1 2004/03/15 20:35:26 as Exp $
|
||||
#
|
||||
|
||||
|
||||
|
||||
include ../Makefile.inc
|
||||
|
||||
|
||||
|
||||
ifndef TOPDIR
|
||||
TOPDIR := /usr/src/linux
|
||||
endif
|
||||
|
||||
|
||||
L_TARGET := zlib.a
|
||||
|
||||
obj-y :=
|
||||
|
||||
include Makefile.objs
|
||||
|
||||
EXTRA_CFLAGS += $(KLIPSCOMPILE)
|
||||
|
||||
EXTRA_CFLAGS += -Wall
|
||||
#EXTRA_CFLAGS += -Wconversion
|
||||
#EXTRA_CFLAGS += -Wmissing-prototypes
|
||||
EXTRA_CFLAGS += -Wpointer-arith
|
||||
#EXTRA_CFLAGS += -Wcast-qual
|
||||
#EXTRA_CFLAGS += -Wmissing-declarations
|
||||
EXTRA_CFLAGS += -Wstrict-prototypes
|
||||
#EXTRA_CFLAGS += -pedantic
|
||||
#EXTRA_CFLAGS += -W
|
||||
#EXTRA_CFLAGS += -Wwrite-strings
|
||||
EXTRA_CFLAGS += -Wbad-function-cast
|
||||
EXTRA_CFLAGS += -DIPCOMP_PREFIX
|
||||
|
||||
.S.o:
|
||||
$(CC) -D__ASSEMBLY__ -DNO_UNDERLINE -traditional -c $< -o $*.o
|
||||
|
||||
asm-obj-$(CONFIG_M586) += match586.o
|
||||
asm-obj-$(CONFIG_M586TSC) += match586.o
|
||||
asm-obj-$(CONFIG_M586MMX) += match586.o
|
||||
asm-obj-$(CONFIG_M686) += match686.o
|
||||
asm-obj-$(CONFIG_MPENTIUMIII) += match686.o
|
||||
asm-obj-$(CONFIG_MPENTIUM4) += match686.o
|
||||
asm-obj-$(CONFIG_MK6) += match586.o
|
||||
asm-obj-$(CONFIG_MK7) += match686.o
|
||||
asm-obj-$(CONFIG_MCRUSOE) += match586.o
|
||||
asm-obj-$(CONFIG_MWINCHIPC6) += match586.o
|
||||
asm-obj-$(CONFIG_MWINCHIP2) += match686.o
|
||||
asm-obj-$(CONFIG_MWINCHIP3D) += match686.o
|
||||
|
||||
obj-y += $(asm-obj-y)
|
||||
ifneq ($(strip $(asm-obj-y)),)
|
||||
EXTRA_CFLAGS += -DASMV
|
||||
endif
|
||||
|
||||
active-objs := $(sort $(obj-y) $(obj-m))
|
||||
L_OBJS := $(obj-y)
|
||||
M_OBJS := $(obj-m)
|
||||
MIX_OBJS := $(filter $(export-objs), $(active-objs))
|
||||
|
||||
include $(TOPDIR)/Rules.make
|
||||
|
||||
$(obj-y) : $(TOPDIR)/include/linux/config.h $(TOPDIR)/include/linux/autoconf.h
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.a
|
||||
|
||||
checkprograms:
|
||||
programs: $(L_TARGET)
|
||||
|
||||
#
|
||||
# $Log: Makefile,v $
|
||||
# Revision 1.1 2004/03/15 20:35:26 as
|
||||
# added files from freeswan-2.04-x509-1.5.3
|
||||
#
|
||||
# Revision 1.9 2002/04/24 07:55:32 mcr
|
||||
# #include patches and Makefiles for post-reorg compilation.
|
||||
#
|
||||
# Revision 1.8 2002/04/24 07:36:44 mcr
|
||||
# Moved from ./zlib/Makefile,v
|
||||
#
|
||||
# Revision 1.7 2002/03/27 23:34:35 mcr
|
||||
# added programs: target
|
||||
#
|
||||
# Revision 1.6 2001/12/05 20:19:08 henry
|
||||
# use new compile-control variable
|
||||
#
|
||||
# Revision 1.5 2001/11/27 16:38:08 mcr
|
||||
# added new "checkprograms" target to deal with programs that
|
||||
# are required for "make check", but that may not be ready to
|
||||
# build for every user due to external dependancies.
|
||||
#
|
||||
# Revision 1.4 2001/10/24 14:46:24 henry
|
||||
# Makefile.inc
|
||||
#
|
||||
# Revision 1.3 2001/04/21 23:05:24 rgb
|
||||
# Update asm directives for 2.4 style makefiles.
|
||||
#
|
||||
# Revision 1.2 2001/01/29 22:22:00 rgb
|
||||
# Convert to 2.4 new style with back compat.
|
||||
#
|
||||
# Revision 1.1.1.1 2000/09/29 18:51:33 rgb
|
||||
# zlib_beginnings
|
||||
#
|
||||
#
|
||||
@@ -1,27 +0,0 @@
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += adler32.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += deflate.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += infblock.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += infcodes.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += inffast.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += inflate.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += inftrees.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += infutil.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += trees.o
|
||||
obj-$(CONFIG_IPSEC_IPCOMP) += zutil.o
|
||||
|
||||
asm-obj-$(CONFIG_M586) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_M586TSC) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_M586MMX) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_M686) += ${LIBZLIBSRCDIR}/match686.o
|
||||
asm-obj-$(CONFIG_MPENTIUMIII) += ${LIBZLIBSRCDIR}/match686.o
|
||||
asm-obj-$(CONFIG_MPENTIUM4) += ${LIBZLIBSRCDIR}/match686.o
|
||||
asm-obj-$(CONFIG_MK6) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_MK7) += ${LIBZLIBSRCDIR}/match686.o
|
||||
asm-obj-$(CONFIG_MCRUSOE) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_MWINCHIPC6) += ${LIBZLIBSRCDIR}/match586.o
|
||||
asm-obj-$(CONFIG_MWINCHIP2) += ${LIBZLIBSRCDIR}/match686.o
|
||||
asm-obj-$(CONFIG_MWINCHIP3D) += ${LIBZLIBSRCDIR}/match686.o
|
||||
|
||||
EXTRA_CFLAGS += -DIPCOMP_PREFIX
|
||||
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
zlib 1.1.4 is a general purpose data compression library. All the code
|
||||
is thread safe. The data format used by the zlib library
|
||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
format) and rfc1952.txt (gzip format). These documents are also available in
|
||||
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact [email protected]). A usage
|
||||
example of the library is given in the file example.c which also tests that
|
||||
the library is working correctly. Another example is given in the file
|
||||
minigzip.c. The compression library itself is composed of all source files
|
||||
except example.c and minigzip.c.
|
||||
|
||||
To compile all files and run the test program, follow the instructions
|
||||
given at the top of Makefile. In short "make test; make install"
|
||||
should work for most machines. For Unix: "./configure; make test; make install"
|
||||
For MSDOS, use one of the special makefiles such as Makefile.msc.
|
||||
For VMS, use Make_vms.com or descrip.mms.
|
||||
|
||||
Questions about zlib should be sent to <[email protected]>, or to
|
||||
Gilles Vollant <[email protected]> for the Windows DLL version.
|
||||
The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/
|
||||
Before reporting a problem, please check this site to verify that
|
||||
you have the latest version of zlib; otherwise get the latest version and
|
||||
check whether the problem still exists or not.
|
||||
|
||||
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html
|
||||
before asking for help.
|
||||
|
||||
Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.1.4 are documented in the file ChangeLog.
|
||||
The only changes made since 1.1.3 are bug corrections:
|
||||
|
||||
- ZFREE was repeated on same allocation on some error conditions.
|
||||
This creates a security problem described in
|
||||
http://www.zlib.org/advisory-2002-03-11.txt
|
||||
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
|
||||
- Avoid accesses before window for invalid distances with inflate window
|
||||
less than 32K.
|
||||
- force windowBits > 8 to avoid a bug in the encoder for a window size
|
||||
of 256 bytes. (A complete fix will be available in 1.1.5).
|
||||
|
||||
The beta version 1.1.5beta includes many more changes. A new official
|
||||
version 1.1.5 will be released as soon as extensive testing has been
|
||||
completed on it.
|
||||
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
See the zlib home page http://www.zlib.org for details.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <[email protected]>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites
|
||||
http://www.cpan.org/modules/by-module/Compress/
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <[email protected]>
|
||||
is available in Python 1.5 and later versions, see
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
|
||||
A zlib binding for TCL written by Andreas Kupries <[email protected]>
|
||||
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
|
||||
|
||||
An experimental package to read and write files in .zip format,
|
||||
written on top of zlib by Gilles Vollant <[email protected]>, is
|
||||
available at http://www.winimage.com/zLibDll/unzip.html
|
||||
and also in the contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
|
||||
The zlib DLL support was initially done by Alessandro Iacopetti and is
|
||||
now maintained by Gilles Vollant <[email protected]>. Check the zlib DLL
|
||||
home page at http://www.winimage.com/zLibDll
|
||||
|
||||
From Visual Basic, you can call the DLL functions which do not take
|
||||
a structure as argument: compress, uncompress and all gz* functions.
|
||||
See contrib/visual-basic.txt for more information, or get
|
||||
http://www.tcfb.com/dowseware/cmp-z-it.zip
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization.
|
||||
With -O, one libpng test fails. The test works in 32 bit mode (with
|
||||
the -n32 compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
|
||||
it works when compiled with cc.
|
||||
|
||||
- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
|
||||
is necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
|
||||
with other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For Turbo C the small model is supported only with reduced performance to
|
||||
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||
|
||||
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
|
||||
Per Harald Myrvang <[email protected]>
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib;
|
||||
they are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2002 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
[email protected] [email protected]
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not*
|
||||
receiving lengthy legal documents to sign. The sources are provided
|
||||
for free but without warranty of any kind. The library has been
|
||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
||||
include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include
|
||||
in the file ChangeLog history information documenting your changes.
|
||||
@@ -1,13 +0,0 @@
|
||||
The only changes made to these files for use in FreeS/WAN are:
|
||||
|
||||
- In zconf.h, macros are defined to prefix global symbols with "ipcomp_"
|
||||
(or "_ipcomp"), when compiled with -DIPCOMP_PREFIX.
|
||||
- The copyright strings are defined local (static)
|
||||
|
||||
The above changes are made to avoid name collisions with ppp_deflate
|
||||
and ext2compr.
|
||||
|
||||
- Files not needed for FreeS/WAN have been removed
|
||||
|
||||
See the "README" file for information about where to obtain the complete
|
||||
zlib package.
|
||||
@@ -1,49 +0,0 @@
|
||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: adler32.c,v 1.1 2004/03/15 20:35:26 as Exp $ */
|
||||
|
||||
#include <zlib/zlib.h>
|
||||
#include "zconf.h"
|
||||
|
||||
#define BASE 65521L /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long s1 = adler & 0xffff;
|
||||
unsigned long s2 = (adler >> 16) & 0xffff;
|
||||
int k;
|
||||
|
||||
if (buf == Z_NULL) return 1L;
|
||||
|
||||
while (len > 0) {
|
||||
k = len < NMAX ? len : NMAX;
|
||||
len -= k;
|
||||
while (k >= 16) {
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
k -= 16;
|
||||
}
|
||||
if (k != 0) do {
|
||||
s1 += *buf++;
|
||||
s2 += s1;
|
||||
} while (--k);
|
||||
s1 %= BASE;
|
||||
s2 %= BASE;
|
||||
}
|
||||
return (s2 << 16) | s1;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,318 +0,0 @@
|
||||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id: deflate.h,v 1.1 2004/03/15 20:35:26 as Exp $ */
|
||||
|
||||
#ifndef _DEFLATE_H
|
||||
#define _DEFLATE_H
|
||||
|
||||
#include "zlib/zutil.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* Internal compression state.
|
||||
*/
|
||||
|
||||
#define LENGTH_CODES 29
|
||||
/* number of length codes, not counting the special END_BLOCK code */
|
||||
|
||||
#define LITERALS 256
|
||||
/* number of literal bytes 0..255 */
|
||||
|
||||
#define L_CODES (LITERALS+1+LENGTH_CODES)
|
||||
/* number of Literal or Length codes, including the END_BLOCK code */
|
||||
|
||||
#define D_CODES 30
|
||||
/* number of distance codes */
|
||||
|
||||
#define BL_CODES 19
|
||||
/* number of codes used to transfer the bit lengths */
|
||||
|
||||
#define HEAP_SIZE (2*L_CODES+1)
|
||||
/* maximum heap size */
|
||||
|
||||
#define MAX_BITS 15
|
||||
/* All codes must not exceed MAX_BITS bits */
|
||||
|
||||
#define INIT_STATE 42
|
||||
#define BUSY_STATE 113
|
||||
#define FINISH_STATE 666
|
||||
/* Stream status */
|
||||
|
||||
|
||||
/* Data structure describing a single value and its code string. */
|
||||
typedef struct ct_data_s {
|
||||
union {
|
||||
ush freq; /* frequency count */
|
||||
ush code; /* bit string */
|
||||
} fc;
|
||||
union {
|
||||
ush dad; /* father node in Huffman tree */
|
||||
ush len; /* length of bit string */
|
||||
} dl;
|
||||
} FAR ct_data;
|
||||
|
||||
#define Freq fc.freq
|
||||
#define Code fc.code
|
||||
#define Dad dl.dad
|
||||
#define Len dl.len
|
||||
|
||||
typedef struct static_tree_desc_s static_tree_desc;
|
||||
|
||||
typedef struct tree_desc_s {
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} FAR tree_desc;
|
||||
|
||||
typedef ush Pos;
|
||||
typedef Pos FAR Posf;
|
||||
typedef unsigned IPos;
|
||||
|
||||
/* A Pos is an index in the character window. We use short instead of int to
|
||||
* save space in the various tables. IPos is used only for parameter passing.
|
||||
*/
|
||||
|
||||
typedef struct internal_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
int status; /* as the name implies */
|
||||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
int pending; /* nb of bytes in the pending buffer */
|
||||
int noheader; /* suppress zlib header and adler32 */
|
||||
Byte data_type; /* UNKNOWN, BINARY or ASCII */
|
||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
/* used by deflate.c: */
|
||||
|
||||
uInt w_size; /* LZ77 window size (32K by default) */
|
||||
uInt w_bits; /* log2(w_size) (8..16) */
|
||||
uInt w_mask; /* w_size - 1 */
|
||||
|
||||
Bytef *window;
|
||||
/* Sliding window. Input bytes are read into the second half of the window,
|
||||
* and move to the first half later to keep a dictionary of at least wSize
|
||||
* bytes. With this organization, matches are limited to a distance of
|
||||
* wSize-MAX_MATCH bytes, but this ensures that IO is always
|
||||
* performed with a length multiple of the block size. Also, it limits
|
||||
* the window size to 64K, which is quite useful on MSDOS.
|
||||
* To do: use the user input buffer as sliding window.
|
||||
*/
|
||||
|
||||
ulg window_size;
|
||||
/* Actual size of window: 2*wSize, except when the user input buffer
|
||||
* is directly used as sliding window.
|
||||
*/
|
||||
|
||||
Posf *prev;
|
||||
/* Link to older string with same hash index. To limit the size of this
|
||||
* array to 64K, this link is maintained only for the last 32K strings.
|
||||
* An index in this array is thus a window index modulo 32K.
|
||||
*/
|
||||
|
||||
Posf *head; /* Heads of the hash chains or NIL. */
|
||||
|
||||
uInt ins_h; /* hash index of string to be inserted */
|
||||
uInt hash_size; /* number of elements in hash table */
|
||||
uInt hash_bits; /* log2(hash_size) */
|
||||
uInt hash_mask; /* hash_size-1 */
|
||||
|
||||
uInt hash_shift;
|
||||
/* Number of bits by which ins_h must be shifted at each input
|
||||
* step. It must be such that after MIN_MATCH steps, the oldest
|
||||
* byte no longer takes part in the hash key, that is:
|
||||
* hash_shift * MIN_MATCH >= hash_bits
|
||||
*/
|
||||
|
||||
long block_start;
|
||||
/* Window position at the beginning of the current output block. Gets
|
||||
* negative when the window is moved backwards.
|
||||
*/
|
||||
|
||||
uInt match_length; /* length of best match */
|
||||
IPos prev_match; /* previous match */
|
||||
int match_available; /* set if previous match exists */
|
||||
uInt strstart; /* start of string to insert */
|
||||
uInt match_start; /* start of matching string */
|
||||
uInt lookahead; /* number of valid bytes ahead in window */
|
||||
|
||||
uInt prev_length;
|
||||
/* Length of the best match at previous step. Matches not greater than this
|
||||
* are discarded. This is used in the lazy match evaluation.
|
||||
*/
|
||||
|
||||
uInt max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this
|
||||
* length. A higher limit improves compression ratio but degrades the
|
||||
* speed.
|
||||
*/
|
||||
|
||||
uInt max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly
|
||||
* smaller than this value. This mechanism is used only for compression
|
||||
* levels >= 4.
|
||||
*/
|
||||
# define max_insert_length max_lazy_match
|
||||
/* Insert new strings in the hash table only if the match length is not
|
||||
* greater than this length. This saves time but degrades compression.
|
||||
* max_insert_length is used only for compression levels <= 3.
|
||||
*/
|
||||
|
||||
int level; /* compression level (1..9) */
|
||||
int strategy; /* favor or force Huffman coding*/
|
||||
|
||||
uInt good_match;
|
||||
/* Use a faster search when the previous match is longer than this */
|
||||
|
||||
int nice_match; /* Stop searching when current match exceeds this */
|
||||
|
||||
/* used by trees.c: */
|
||||
/* Didn't use ct_data typedef below to supress compiler warning */
|
||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
|
||||
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
|
||||
|
||||
struct tree_desc_s l_desc; /* desc. for literal tree */
|
||||
struct tree_desc_s d_desc; /* desc. for distance tree */
|
||||
struct tree_desc_s bl_desc; /* desc. for bit length tree */
|
||||
|
||||
ush bl_count[MAX_BITS+1];
|
||||
/* number of codes at each bit length for an optimal tree */
|
||||
|
||||
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
|
||||
int heap_len; /* number of elements in the heap */
|
||||
int heap_max; /* element of largest frequency */
|
||||
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
|
||||
* The same heap array is used to build all trees.
|
||||
*/
|
||||
|
||||
uch depth[2*L_CODES+1];
|
||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
uchf *l_buf; /* buffer for literals or lengths */
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
* limiting lit_bufsize to 64K:
|
||||
* - frequencies can be kept in 16 bit counters
|
||||
* - if compression is not successful for the first block, all input
|
||||
* data is still in the window so we can still emit a stored block even
|
||||
* when input comes from standard input. (This can also be done for
|
||||
* all blocks if lit_bufsize is not greater than 32K.)
|
||||
* - if compression is not successful for a file smaller than 64K, we can
|
||||
* even emit a stored file instead of a stored block (saving 5 bytes).
|
||||
* This is applicable only for zip (not gzip or zlib).
|
||||
* - creating new Huffman trees less frequently may not provide fast
|
||||
* adaptation to changes in the input data statistics. (Take for
|
||||
* example a binary file with poorly compressible code followed by
|
||||
* a highly compressible string table.) Smaller buffer sizes give
|
||||
* fast adaptation but have of course the overhead of transmitting
|
||||
* trees more frequently.
|
||||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
uInt last_lit; /* running index in l_buf */
|
||||
|
||||
ushf *d_buf;
|
||||
/* Buffer for distances. To simplify the code, d_buf and l_buf have
|
||||
* the same number of elements. To use different lengths, an extra flag
|
||||
* array would be necessary.
|
||||
*/
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
uInt matches; /* number of string matches in current block */
|
||||
int last_eob_len; /* bit length of EOB code for last block */
|
||||
|
||||
#ifdef DEBUG
|
||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
|
||||
#endif
|
||||
|
||||
ush bi_buf;
|
||||
/* Output buffer. bits are inserted starting at the bottom (least
|
||||
* significant bits).
|
||||
*/
|
||||
int bi_valid;
|
||||
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
||||
* are always zero.
|
||||
*/
|
||||
|
||||
} FAR deflate_state;
|
||||
|
||||
/* Output a byte on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
|
||||
|
||||
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||
/* Minimum amount of lookahead, except at the end of the input file.
|
||||
* See deflate.c for comments about the MIN_MATCH+1.
|
||||
*/
|
||||
|
||||
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
|
||||
/* In order to simplify the code, particularly on 16 bit machines, match
|
||||
* distances are limited to MAX_DIST instead of WSIZE.
|
||||
*/
|
||||
|
||||
/* in trees.c */
|
||||
void _tr_init OF((deflate_state *s));
|
||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
void _tr_align OF((deflate_state *s));
|
||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG
|
||||
/* Inline versions of _tr_tally for speed: */
|
||||
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
extern uch _length_code[];
|
||||
extern uch _dist_code[];
|
||||
#else
|
||||
extern const uch _length_code[];
|
||||
extern const uch _dist_code[];
|
||||
#endif
|
||||
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->last_lit] = 0; \
|
||||
s->l_buf[s->last_lit++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (length); \
|
||||
ush dist = (distance); \
|
||||
s->d_buf[s->last_lit] = dist; \
|
||||
s->l_buf[s->last_lit++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->last_lit == s->lit_bufsize-1); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
flush = _tr_tally(s, distance, length)
|
||||
#endif
|
||||
|
||||
#endif /* _DEFLATE_H */
|
||||
@@ -1,403 +0,0 @@
|
||||
/* infblock.c -- interpret and process block types to last block
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* Table for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt border[] = { /* Order of the bit length code lengths */
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
/*
|
||||
Notes beyond the 1.93a appnote.txt:
|
||||
|
||||
1. Distance pointers never point before the beginning of the output
|
||||
stream.
|
||||
2. Distance pointers can point back across blocks, up to 32k away.
|
||||
3. There is an implied maximum of 7 bits for the bit length table and
|
||||
15 bits for the actual data.
|
||||
4. If only one code exists, then it is encoded using one bit. (Zero
|
||||
would be more efficient, but perhaps a little confusing.) If two
|
||||
codes exist, they are coded using one bit each (0 and 1).
|
||||
5. There is no way of sending zero distance codes--a dummy must be
|
||||
sent if there are none. (History: a pre 2.0 version of PKZIP would
|
||||
store blocks with no distance codes, but this was discovered to be
|
||||
too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
|
||||
zero distance codes, which is sent as one code of zero bits in
|
||||
length.
|
||||
6. There are up to 286 literal/length codes. Code 256 represents the
|
||||
end-of-block. Note however that the static length tree defines
|
||||
288 codes just to fill out the Huffman codes. Codes 286 and 287
|
||||
cannot be used though, since there is no length base or extra bits
|
||||
defined for them. Similarily, there are up to 30 distance codes.
|
||||
However, static trees define 32 codes (all 5 bits) to fill out the
|
||||
Huffman codes, but the last two had better not show up in the data.
|
||||
7. Unzip can check dynamic Huffman blocks for complete code sets.
|
||||
The exception is that a single code would not be complete (see #4).
|
||||
8. The five bits following the block type is really the number of
|
||||
literal codes sent minus 257.
|
||||
9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
|
||||
(1+6+6). Therefore, to output three times the length, you output
|
||||
three codes (1+1+1), whereas to output four times the same length,
|
||||
you only need two codes (1+3). Hmm.
|
||||
10. In the tree reconstruction algorithm, Code = Code + Increment
|
||||
only if BitLength(i) is not zero. (Pretty obvious.)
|
||||
11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
|
||||
12. Note: length code 284 can represent 227-258, but length code 285
|
||||
really is 258. The last length deserves its own, short code
|
||||
since it gets used a lot in very redundant files. The length
|
||||
258 is special since 258 - 3 (the min match length) is 255.
|
||||
13. The literal/length and distance code bit lengths are read as a
|
||||
single stream of lengths. It is possible (and advantageous) for
|
||||
a repeat code (16, 17, or 18) to go across the boundary between
|
||||
the two sets of lengths.
|
||||
*/
|
||||
|
||||
|
||||
void inflate_blocks_reset(s, z, c)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
uLongf *c;
|
||||
{
|
||||
if (c != Z_NULL)
|
||||
*c = s->check;
|
||||
if (s->mode == BTREE || s->mode == DTREE)
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
if (s->mode == CODES)
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
s->mode = TYPE;
|
||||
s->bitk = 0;
|
||||
s->bitb = 0;
|
||||
s->read = s->write = s->window;
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
|
||||
Tracev((stderr, "inflate: blocks reset\n"));
|
||||
}
|
||||
|
||||
|
||||
inflate_blocks_statef *inflate_blocks_new(z, c, w)
|
||||
z_streamp z;
|
||||
check_func c;
|
||||
uInt w;
|
||||
{
|
||||
inflate_blocks_statef *s;
|
||||
|
||||
if ((s = (inflate_blocks_statef *)ZALLOC
|
||||
(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
|
||||
return s;
|
||||
if ((s->hufts =
|
||||
(inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
return Z_NULL;
|
||||
}
|
||||
s->end = s->window + w;
|
||||
s->checkfn = c;
|
||||
s->mode = TYPE;
|
||||
Tracev((stderr, "inflate: blocks allocated\n"));
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt t; /* temporary storage */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input based on current state */
|
||||
while (1) switch (s->mode)
|
||||
{
|
||||
case TYPE:
|
||||
NEEDBITS(3)
|
||||
t = (uInt)b & 7;
|
||||
s->last = t & 1;
|
||||
switch (t >> 1)
|
||||
{
|
||||
case 0: /* stored */
|
||||
Tracev((stderr, "inflate: stored block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
t = k & 7; /* go to byte boundary */
|
||||
DUMPBITS(t)
|
||||
s->mode = LENS; /* get length of stored block */
|
||||
break;
|
||||
case 1: /* fixed */
|
||||
Tracev((stderr, "inflate: fixed codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
|
||||
inflate_trees_fixed(&bl, &bd, &tl, &td, z);
|
||||
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
|
||||
if (s->sub.decode.codes == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
DUMPBITS(3)
|
||||
s->mode = CODES;
|
||||
break;
|
||||
case 2: /* dynamic */
|
||||
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
||||
s->last ? " (last)" : ""));
|
||||
DUMPBITS(3)
|
||||
s->mode = TABLE;
|
||||
break;
|
||||
case 3: /* illegal */
|
||||
DUMPBITS(3)
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid block type";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
break;
|
||||
case LENS:
|
||||
NEEDBITS(32)
|
||||
if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid stored block lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.left = (uInt)b & 0xffff;
|
||||
b = k = 0; /* dump bits */
|
||||
Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
|
||||
s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
|
||||
break;
|
||||
case STORED:
|
||||
if (n == 0)
|
||||
LEAVE
|
||||
NEEDOUT
|
||||
t = s->sub.left;
|
||||
if (t > n) t = n;
|
||||
if (t > m) t = m;
|
||||
zmemcpy(q, p, t);
|
||||
p += t; n -= t;
|
||||
q += t; m -= t;
|
||||
if ((s->sub.left -= t) != 0)
|
||||
break;
|
||||
Tracev((stderr, "inflate: stored end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
s->mode = s->last ? DRY : TYPE;
|
||||
break;
|
||||
case TABLE:
|
||||
NEEDBITS(14)
|
||||
s->sub.trees.table = t = (uInt)b & 0x3fff;
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
|
||||
{
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"too many length or distance symbols";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#endif
|
||||
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
|
||||
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
DUMPBITS(14)
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||
s->mode = BTREE;
|
||||
case BTREE:
|
||||
while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
|
||||
{
|
||||
NEEDBITS(3)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
|
||||
DUMPBITS(3)
|
||||
}
|
||||
while (s->sub.trees.index < 19)
|
||||
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
|
||||
s->sub.trees.bb = 7;
|
||||
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
|
||||
&s->sub.trees.tb, s->hufts, z);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
r = t;
|
||||
if (r == Z_DATA_ERROR)
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
}
|
||||
LEAVE
|
||||
}
|
||||
s->sub.trees.index = 0;
|
||||
Tracev((stderr, "inflate: bits tree ok\n"));
|
||||
s->mode = DTREE;
|
||||
case DTREE:
|
||||
while (t = s->sub.trees.table,
|
||||
s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
|
||||
{
|
||||
inflate_huft *h;
|
||||
uInt i, j, c;
|
||||
|
||||
t = s->sub.trees.bb;
|
||||
NEEDBITS(t)
|
||||
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
|
||||
t = h->bits;
|
||||
c = h->base;
|
||||
if (c < 16)
|
||||
{
|
||||
DUMPBITS(t)
|
||||
s->sub.trees.blens[s->sub.trees.index++] = c;
|
||||
}
|
||||
else /* c == 16..18 */
|
||||
{
|
||||
i = c == 18 ? 7 : c - 14;
|
||||
j = c == 18 ? 11 : 3;
|
||||
NEEDBITS(t + i)
|
||||
DUMPBITS(t)
|
||||
j += (uInt)b & inflate_mask[i];
|
||||
DUMPBITS(i)
|
||||
i = s->sub.trees.index;
|
||||
t = s->sub.trees.table;
|
||||
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
|
||||
(c == 16 && i < 1))
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
z->msg = (char*)"invalid bit length repeat";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
|
||||
do {
|
||||
s->sub.trees.blens[i++] = c;
|
||||
} while (--j);
|
||||
s->sub.trees.index = i;
|
||||
}
|
||||
}
|
||||
s->sub.trees.tb = Z_NULL;
|
||||
{
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl, *td;
|
||||
inflate_codes_statef *c;
|
||||
|
||||
bl = 9; /* must be <= 9 for lookahead assumptions */
|
||||
bd = 6; /* must be <= 9 for lookahead assumptions */
|
||||
t = s->sub.trees.table;
|
||||
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
|
||||
s->sub.trees.blens, &bl, &bd, &tl, &td,
|
||||
s->hufts, z);
|
||||
if (t != Z_OK)
|
||||
{
|
||||
if (t == (uInt)Z_DATA_ERROR)
|
||||
{
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = BAD;
|
||||
}
|
||||
r = t;
|
||||
LEAVE
|
||||
}
|
||||
Tracev((stderr, "inflate: trees ok\n"));
|
||||
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
|
||||
{
|
||||
r = Z_MEM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
s->sub.decode.codes = c;
|
||||
}
|
||||
ZFREE(z, s->sub.trees.blens);
|
||||
s->mode = CODES;
|
||||
case CODES:
|
||||
UPDATE
|
||||
if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
|
||||
return inflate_flush(s, z, r);
|
||||
r = Z_OK;
|
||||
inflate_codes_free(s->sub.decode.codes, z);
|
||||
LOAD
|
||||
Tracev((stderr, "inflate: codes end, %lu total out\n",
|
||||
z->total_out + (q >= s->read ? q - s->read :
|
||||
(s->end - s->read) + (q - s->window))));
|
||||
if (!s->last)
|
||||
{
|
||||
s->mode = TYPE;
|
||||
break;
|
||||
}
|
||||
s->mode = DRY;
|
||||
case DRY:
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
s->mode = DONE;
|
||||
case DONE:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BAD:
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int inflate_blocks_free(s, z)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_blocks_reset(s, z, Z_NULL);
|
||||
ZFREE(z, s->window);
|
||||
ZFREE(z, s->hufts);
|
||||
ZFREE(z, s);
|
||||
Tracev((stderr, "inflate: blocks freed\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
void inflate_set_dictionary(s, d, n)
|
||||
inflate_blocks_statef *s;
|
||||
const Bytef *d;
|
||||
uInt n;
|
||||
{
|
||||
zmemcpy(s->window, d, n);
|
||||
s->read = s->write = s->window + n;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
|
||||
* IN assertion: s != Z_NULL
|
||||
*/
|
||||
int inflate_blocks_sync_point(s)
|
||||
inflate_blocks_statef *s;
|
||||
{
|
||||
return s->mode == LENS;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/* infblock.h -- header to use infblock.c
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
struct inflate_blocks_state;
|
||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
|
||||
|
||||
extern inflate_blocks_statef * inflate_blocks_new OF((
|
||||
z_streamp z,
|
||||
check_func c, /* check function */
|
||||
uInt w)); /* window size */
|
||||
|
||||
extern int inflate_blocks OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int)); /* initial return code */
|
||||
|
||||
extern void inflate_blocks_reset OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
uLongf *)); /* check value on output */
|
||||
|
||||
extern int inflate_blocks_free OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp));
|
||||
|
||||
extern void inflate_set_dictionary OF((
|
||||
inflate_blocks_statef *s,
|
||||
const Bytef *d, /* dictionary */
|
||||
uInt n)); /* dictionary length */
|
||||
|
||||
extern int inflate_blocks_sync_point OF((
|
||||
inflate_blocks_statef *s));
|
||||
@@ -1,251 +0,0 @@
|
||||
/* infcodes.c -- process literals and length/distance pairs
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
START, /* x: set up for LEN */
|
||||
LEN, /* i: get length/literal/eob next */
|
||||
LENEXT, /* i: getting length extra (have base) */
|
||||
DIST, /* i: get distance next */
|
||||
DISTEXT, /* i: getting distance extra */
|
||||
COPY, /* o: copying bytes in window, waiting for space */
|
||||
LIT, /* o: got literal, waiting for output space */
|
||||
WASH, /* o: got eob, possibly still output waiting */
|
||||
END, /* x: got eob and all data flushed */
|
||||
BADCODE} /* x: got error */
|
||||
inflate_codes_mode;
|
||||
|
||||
/* inflate codes private state */
|
||||
struct inflate_codes_state {
|
||||
|
||||
/* mode */
|
||||
inflate_codes_mode mode; /* current inflate_codes mode */
|
||||
|
||||
/* mode dependent information */
|
||||
uInt len;
|
||||
union {
|
||||
struct {
|
||||
inflate_huft *tree; /* pointer into tree */
|
||||
uInt need; /* bits needed */
|
||||
} code; /* if LEN or DIST, where in tree */
|
||||
uInt lit; /* if LIT, literal */
|
||||
struct {
|
||||
uInt get; /* bits to get for extra */
|
||||
uInt dist; /* distance back to copy from */
|
||||
} copy; /* if EXT or COPY, where and how much */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
Byte lbits; /* ltree bits decoded per branch */
|
||||
Byte dbits; /* dtree bits decoder per branch */
|
||||
inflate_huft *ltree; /* literal/length/eob tree */
|
||||
inflate_huft *dtree; /* distance tree */
|
||||
|
||||
};
|
||||
|
||||
|
||||
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_codes_statef *c;
|
||||
|
||||
if ((c = (inflate_codes_statef *)
|
||||
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
|
||||
{
|
||||
c->mode = START;
|
||||
c->lbits = (Byte)bl;
|
||||
c->dbits = (Byte)bd;
|
||||
c->ltree = tl;
|
||||
c->dtree = td;
|
||||
Tracev((stderr, "inflate: codes new\n"));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
int inflate_codes(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt j; /* temporary storage */
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
Bytef *f; /* pointer to copy strings from */
|
||||
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
|
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */
|
||||
LOAD
|
||||
|
||||
/* process input and output based on current state */
|
||||
while (1) switch (c->mode)
|
||||
{ /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
|
||||
case START: /* x: set up for LEN */
|
||||
#ifndef SLOW
|
||||
if (m >= 258 && n >= 10)
|
||||
{
|
||||
UPDATE
|
||||
r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
|
||||
LOAD
|
||||
if (r != Z_OK)
|
||||
{
|
||||
c->mode = r == Z_STREAM_END ? WASH : BADCODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !SLOW */
|
||||
c->sub.code.need = c->lbits;
|
||||
c->sub.code.tree = c->ltree;
|
||||
c->mode = LEN;
|
||||
case LEN: /* i: get length/literal/eob next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e == 0) /* literal */
|
||||
{
|
||||
c->sub.lit = t->base;
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", t->base));
|
||||
c->mode = LIT;
|
||||
break;
|
||||
}
|
||||
if (e & 16) /* length */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->len = t->base;
|
||||
c->mode = LENEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
if (e & 32) /* end of block */
|
||||
{
|
||||
Tracevv((stderr, "inflate: end of block\n"));
|
||||
c->mode = WASH;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case LENEXT: /* i: getting length extra (have base) */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->len += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
c->sub.code.need = c->dbits;
|
||||
c->sub.code.tree = c->dtree;
|
||||
Tracevv((stderr, "inflate: length %u\n", c->len));
|
||||
c->mode = DIST;
|
||||
case DIST: /* i: get distance next */
|
||||
j = c->sub.code.need;
|
||||
NEEDBITS(j)
|
||||
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
|
||||
DUMPBITS(t->bits)
|
||||
e = (uInt)(t->exop);
|
||||
if (e & 16) /* distance */
|
||||
{
|
||||
c->sub.copy.get = e & 15;
|
||||
c->sub.copy.dist = t->base;
|
||||
c->mode = DISTEXT;
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0) /* next table */
|
||||
{
|
||||
c->sub.code.need = e;
|
||||
c->sub.code.tree = t + t->base;
|
||||
break;
|
||||
}
|
||||
c->mode = BADCODE; /* invalid code */
|
||||
z->msg = (char*)"invalid distance code";
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
case DISTEXT: /* i: getting distance extra */
|
||||
j = c->sub.copy.get;
|
||||
NEEDBITS(j)
|
||||
c->sub.copy.dist += (uInt)b & inflate_mask[j];
|
||||
DUMPBITS(j)
|
||||
Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
|
||||
c->mode = COPY;
|
||||
case COPY: /* o: copying bytes in window, waiting for space */
|
||||
f = q - c->sub.copy.dist;
|
||||
while (f < s->window) /* modulo window size-"while" instead */
|
||||
f += s->end - s->window; /* of "if" handles invalid distances */
|
||||
while (c->len)
|
||||
{
|
||||
NEEDOUT
|
||||
OUTBYTE(*f++)
|
||||
if (f == s->end)
|
||||
f = s->window;
|
||||
c->len--;
|
||||
}
|
||||
c->mode = START;
|
||||
break;
|
||||
case LIT: /* o: got literal, waiting for output space */
|
||||
NEEDOUT
|
||||
OUTBYTE(c->sub.lit)
|
||||
c->mode = START;
|
||||
break;
|
||||
case WASH: /* o: got eob, possibly more output */
|
||||
if (k > 7) /* return unused byte, if any */
|
||||
{
|
||||
Assert(k < 16, "inflate_codes grabbed too many bytes")
|
||||
k -= 8;
|
||||
n++;
|
||||
p--; /* can always return one */
|
||||
}
|
||||
FLUSH
|
||||
if (s->read != s->write)
|
||||
LEAVE
|
||||
c->mode = END;
|
||||
case END:
|
||||
r = Z_STREAM_END;
|
||||
LEAVE
|
||||
case BADCODE: /* x: got error */
|
||||
r = Z_DATA_ERROR;
|
||||
LEAVE
|
||||
default:
|
||||
r = Z_STREAM_ERROR;
|
||||
LEAVE
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void inflate_codes_free(c, z)
|
||||
inflate_codes_statef *c;
|
||||
z_streamp z;
|
||||
{
|
||||
ZFREE(z, c);
|
||||
Tracev((stderr, "inflate: codes free\n"));
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* infcodes.h -- header to use infcodes.c
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef _INFCODES_H
|
||||
#define _INFCODES_H
|
||||
|
||||
struct inflate_codes_state;
|
||||
typedef struct inflate_codes_state FAR inflate_codes_statef;
|
||||
|
||||
extern inflate_codes_statef *inflate_codes_new OF((
|
||||
uInt, uInt,
|
||||
inflate_huft *, inflate_huft *,
|
||||
z_streamp ));
|
||||
|
||||
extern int inflate_codes OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
extern void inflate_codes_free OF((
|
||||
inflate_codes_statef *,
|
||||
z_streamp ));
|
||||
|
||||
#endif /* _INFCODES_H */
|
||||
@@ -1,183 +0,0 @@
|
||||
/* inffast.c -- process literals and length/distance pairs fast
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "inftrees.h"
|
||||
#include "infblock.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
#include "inffast.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
/* macros for bit input with no checking and for returning unused bytes */
|
||||
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
|
||||
|
||||
/* Called with number of bytes left to write in window at least 258
|
||||
(the maximum string length) and number of input bytes available
|
||||
at least ten. The ten bytes are six bytes for the longest length/
|
||||
distance pair plus four bytes for overloading the bit buffer. */
|
||||
|
||||
int inflate_fast(bl, bd, tl, td, s, z)
|
||||
uInt bl, bd;
|
||||
inflate_huft *tl;
|
||||
inflate_huft *td; /* need separate declaration for Borland C++ */
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
{
|
||||
inflate_huft *t; /* temporary pointer */
|
||||
uInt e; /* extra bits or operation */
|
||||
uLong b; /* bit buffer */
|
||||
uInt k; /* bits in bit buffer */
|
||||
Bytef *p; /* input data pointer */
|
||||
uInt n; /* bytes available there */
|
||||
Bytef *q; /* output window write pointer */
|
||||
uInt m; /* bytes to end of window or read pointer */
|
||||
uInt ml; /* mask for literal/length tree */
|
||||
uInt md; /* mask for distance tree */
|
||||
uInt c; /* bytes to copy */
|
||||
uInt d; /* distance back to copy from */
|
||||
Bytef *r; /* copy source pointer */
|
||||
|
||||
/* load input, output, bit values */
|
||||
LOAD
|
||||
|
||||
/* initialize masks */
|
||||
ml = inflate_mask[bl];
|
||||
md = inflate_mask[bd];
|
||||
|
||||
/* do until not enough input or output space for fast loop */
|
||||
do { /* assume called with m >= 258 && n >= 10 */
|
||||
/* get literal/length code */
|
||||
GRABBITS(20) /* max bits for literal/length code */
|
||||
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits for length */
|
||||
e &= 15;
|
||||
c = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * length %u\n", c));
|
||||
|
||||
/* decode distance base of block to copy */
|
||||
GRABBITS(15); /* max bits for distance code */
|
||||
e = (t = td + ((uInt)b & md))->exop;
|
||||
do {
|
||||
DUMPBITS(t->bits)
|
||||
if (e & 16)
|
||||
{
|
||||
/* get extra bits to add to distance base */
|
||||
e &= 15;
|
||||
GRABBITS(e) /* get extra bits (up to 13) */
|
||||
d = t->base + ((uInt)b & inflate_mask[e]);
|
||||
DUMPBITS(e)
|
||||
Tracevv((stderr, "inflate: * distance %u\n", d));
|
||||
|
||||
/* do the copy */
|
||||
m -= c;
|
||||
r = q - d;
|
||||
if (r < s->window) /* wrap if needed */
|
||||
{
|
||||
do {
|
||||
r += s->end - s->window; /* force pointer in window */
|
||||
} while (r < s->window); /* covers invalid distances */
|
||||
e = s->end - r;
|
||||
if (c > e)
|
||||
{
|
||||
c -= e; /* wrapped copy */
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--e);
|
||||
r = s->window;
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--c);
|
||||
}
|
||||
else /* normal copy */
|
||||
{
|
||||
*q++ = *r++; c--;
|
||||
*q++ = *r++; c--;
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--c);
|
||||
}
|
||||
}
|
||||
else /* normal copy */
|
||||
{
|
||||
*q++ = *r++; c--;
|
||||
*q++ = *r++; c--;
|
||||
do {
|
||||
*q++ = *r++;
|
||||
} while (--c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
e = (t += ((uInt)b & inflate_mask[e]))->exop;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid distance code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
break;
|
||||
}
|
||||
if ((e & 64) == 0)
|
||||
{
|
||||
t += t->base;
|
||||
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
|
||||
{
|
||||
DUMPBITS(t->bits)
|
||||
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
|
||||
"inflate: * literal '%c'\n" :
|
||||
"inflate: * literal 0x%02x\n", t->base));
|
||||
*q++ = (Byte)t->base;
|
||||
m--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (e & 32)
|
||||
{
|
||||
Tracevv((stderr, "inflate: * end of block\n"));
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_STREAM_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
z->msg = (char*)"invalid literal/length code";
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
} while (1);
|
||||
} while (m >= 258 && n >= 10);
|
||||
|
||||
/* not enough input or output--restore pointers and return */
|
||||
UNGRAB
|
||||
UPDATE
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/* inffast.h -- header to use inffast.c
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef _INFFAST_H
|
||||
#define _INFFAST_H
|
||||
|
||||
extern int inflate_fast OF((
|
||||
uInt,
|
||||
uInt,
|
||||
inflate_huft *,
|
||||
inflate_huft *,
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ));
|
||||
|
||||
#endif /* _INFFAST_H */
|
||||
@@ -1,151 +0,0 @@
|
||||
/* inffixed.h -- table for decoding fixed codes
|
||||
* Generated automatically by the maketree.c program
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
local uInt fixed_bl = 9;
|
||||
local uInt fixed_bd = 5;
|
||||
local inflate_huft fixed_tl[] = {
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
|
||||
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
|
||||
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
|
||||
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
|
||||
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
|
||||
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
|
||||
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
|
||||
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
|
||||
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
|
||||
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
|
||||
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
|
||||
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
|
||||
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
|
||||
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
|
||||
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
|
||||
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
|
||||
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
|
||||
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
|
||||
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
|
||||
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
|
||||
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
|
||||
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
|
||||
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
|
||||
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
|
||||
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
|
||||
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
|
||||
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
|
||||
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
|
||||
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
|
||||
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
|
||||
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
|
||||
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
|
||||
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
|
||||
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
|
||||
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
|
||||
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
|
||||
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
|
||||
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
|
||||
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
|
||||
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
|
||||
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
|
||||
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
|
||||
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
|
||||
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
|
||||
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
|
||||
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
|
||||
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
|
||||
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
|
||||
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
|
||||
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
|
||||
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
|
||||
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
|
||||
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
|
||||
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
|
||||
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
|
||||
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
|
||||
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
|
||||
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
|
||||
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
|
||||
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
|
||||
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
|
||||
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
|
||||
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
|
||||
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
|
||||
};
|
||||
local inflate_huft fixed_td[] = {
|
||||
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
|
||||
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
|
||||
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
|
||||
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
|
||||
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
|
||||
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
|
||||
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
|
||||
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
|
||||
};
|
||||
@@ -1,368 +0,0 @@
|
||||
/* inflate.c -- zlib interface to inflate modules
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "infblock.h"
|
||||
|
||||
struct inflate_blocks_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
typedef enum {
|
||||
METHOD, /* waiting for method byte */
|
||||
FLAG, /* waiting for flag byte */
|
||||
DICT4, /* four dictionary check bytes to go */
|
||||
DICT3, /* three dictionary check bytes to go */
|
||||
DICT2, /* two dictionary check bytes to go */
|
||||
DICT1, /* one dictionary check byte to go */
|
||||
DICT0, /* waiting for inflateSetDictionary */
|
||||
BLOCKS, /* decompressing blocks */
|
||||
CHECK4, /* four check bytes to go */
|
||||
CHECK3, /* three check bytes to go */
|
||||
CHECK2, /* two check bytes to go */
|
||||
CHECK1, /* one check byte to go */
|
||||
DONE, /* finished check, done */
|
||||
BAD} /* got an error--stay here */
|
||||
inflate_mode;
|
||||
|
||||
/* inflate private state */
|
||||
struct internal_state {
|
||||
|
||||
/* mode */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt method; /* if FLAGS, method byte */
|
||||
struct {
|
||||
uLong was; /* computed check value */
|
||||
uLong need; /* stream check value */
|
||||
} check; /* if CHECK, check values to compare */
|
||||
uInt marker; /* if BAD, inflateSync's marker bytes count */
|
||||
} sub; /* submode */
|
||||
|
||||
/* mode independent information */
|
||||
int nowrap; /* flag for no wrapper */
|
||||
uInt wbits; /* log2(window size) (8..15, defaults to 15) */
|
||||
inflate_blocks_statef
|
||||
*blocks; /* current inflate_blocks state */
|
||||
|
||||
};
|
||||
|
||||
|
||||
int ZEXPORT inflateReset(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->total_in = z->total_out = 0;
|
||||
z->msg = Z_NULL;
|
||||
z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
|
||||
inflate_blocks_reset(z->state->blocks, z, Z_NULL);
|
||||
Tracev((stderr, "inflate: reset\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateEnd(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->blocks != Z_NULL)
|
||||
inflate_blocks_free(z->state->blocks, z);
|
||||
ZFREE(z, z->state);
|
||||
z->state = Z_NULL;
|
||||
Tracev((stderr, "inflate: end\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit2_(z, w, version, stream_size)
|
||||
z_streamp z;
|
||||
int w;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||
stream_size != sizeof(z_stream))
|
||||
return Z_VERSION_ERROR;
|
||||
|
||||
/* initialize state */
|
||||
if (z == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
z->msg = Z_NULL;
|
||||
if (z->zalloc == Z_NULL)
|
||||
{
|
||||
return Z_STREAM_ERROR;
|
||||
/* z->zalloc = zcalloc;
|
||||
z->opaque = (voidpf)0;
|
||||
*/
|
||||
}
|
||||
if (z->zfree == Z_NULL) return Z_STREAM_ERROR; /* z->zfree = zcfree; */
|
||||
if ((z->state = (struct internal_state FAR *)
|
||||
ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
z->state->blocks = Z_NULL;
|
||||
|
||||
/* handle undocumented nowrap option (no zlib header or check) */
|
||||
z->state->nowrap = 0;
|
||||
if (w < 0)
|
||||
{
|
||||
w = - w;
|
||||
z->state->nowrap = 1;
|
||||
}
|
||||
|
||||
/* set window size */
|
||||
if (w < 8 || w > 15)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
z->state->wbits = (uInt)w;
|
||||
|
||||
/* create inflate_blocks state */
|
||||
if ((z->state->blocks =
|
||||
inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
|
||||
== Z_NULL)
|
||||
{
|
||||
inflateEnd(z);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
Tracev((stderr, "inflate: allocated\n"));
|
||||
|
||||
/* reset state */
|
||||
inflateReset(z);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateInit_(z, version, stream_size)
|
||||
z_streamp z;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
return inflateInit2_(z, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
||||
|
||||
#define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
|
||||
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
|
||||
|
||||
int ZEXPORT inflate(z, f)
|
||||
z_streamp z;
|
||||
int f;
|
||||
{
|
||||
int r;
|
||||
uInt b;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
|
||||
r = Z_BUF_ERROR;
|
||||
while (1) switch (z->state->mode)
|
||||
{
|
||||
case METHOD:
|
||||
NEEDBYTE
|
||||
if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"unknown compression method";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"invalid window size";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
z->state->mode = FLAG;
|
||||
case FLAG:
|
||||
NEEDBYTE
|
||||
b = NEXTBYTE;
|
||||
if (((z->state->sub.method << 8) + b) % 31)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect header check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
if (!(b & PRESET_DICT))
|
||||
{
|
||||
z->state->mode = BLOCKS;
|
||||
break;
|
||||
}
|
||||
z->state->mode = DICT4;
|
||||
case DICT4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = DICT3;
|
||||
case DICT3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = DICT2;
|
||||
case DICT2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = DICT1;
|
||||
case DICT1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
z->adler = z->state->sub.check.need;
|
||||
z->state->mode = DICT0;
|
||||
return Z_NEED_DICT;
|
||||
case DICT0:
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"need dictionary";
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
return Z_STREAM_ERROR;
|
||||
case BLOCKS:
|
||||
r = inflate_blocks(z->state->blocks, z, r);
|
||||
if (r == Z_DATA_ERROR)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0; /* can try inflateSync */
|
||||
break;
|
||||
}
|
||||
if (r == Z_OK)
|
||||
r = f;
|
||||
if (r != Z_STREAM_END)
|
||||
return r;
|
||||
r = f;
|
||||
inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
|
||||
if (z->state->nowrap)
|
||||
{
|
||||
z->state->mode = DONE;
|
||||
break;
|
||||
}
|
||||
z->state->mode = CHECK4;
|
||||
case CHECK4:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need = (uLong)NEXTBYTE << 24;
|
||||
z->state->mode = CHECK3;
|
||||
case CHECK3:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 16;
|
||||
z->state->mode = CHECK2;
|
||||
case CHECK2:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE << 8;
|
||||
z->state->mode = CHECK1;
|
||||
case CHECK1:
|
||||
NEEDBYTE
|
||||
z->state->sub.check.need += (uLong)NEXTBYTE;
|
||||
|
||||
if (z->state->sub.check.was != z->state->sub.check.need)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->msg = (char*)"incorrect data check";
|
||||
z->state->sub.marker = 5; /* can't try inflateSync */
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: zlib check ok\n"));
|
||||
z->state->mode = DONE;
|
||||
case DONE:
|
||||
return Z_STREAM_END;
|
||||
case BAD:
|
||||
return Z_DATA_ERROR;
|
||||
default:
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
#ifdef NEED_DUMMY_RETURN
|
||||
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSetDictionary(z, dictionary, dictLength)
|
||||
z_streamp z;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
uInt length = dictLength;
|
||||
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
|
||||
z->adler = 1L;
|
||||
|
||||
if (length >= ((uInt)1<<z->state->wbits))
|
||||
{
|
||||
length = (1<<z->state->wbits)-1;
|
||||
dictionary += dictLength - length;
|
||||
}
|
||||
inflate_set_dictionary(z->state->blocks, dictionary, length);
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int ZEXPORT inflateSync(z)
|
||||
z_streamp z;
|
||||
{
|
||||
uInt n; /* number of bytes to look at */
|
||||
Bytef *p; /* pointer to bytes */
|
||||
uInt m; /* number of marker bytes found in a row */
|
||||
uLong r, w; /* temporaries to save total_in and total_out */
|
||||
|
||||
/* set up */
|
||||
if (z == Z_NULL || z->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (z->state->mode != BAD)
|
||||
{
|
||||
z->state->mode = BAD;
|
||||
z->state->sub.marker = 0;
|
||||
}
|
||||
if ((n = z->avail_in) == 0)
|
||||
return Z_BUF_ERROR;
|
||||
p = z->next_in;
|
||||
m = z->state->sub.marker;
|
||||
|
||||
/* search */
|
||||
while (n && m < 4)
|
||||
{
|
||||
static const Byte mark[4] = {0, 0, 0xff, 0xff};
|
||||
if (*p == mark[m])
|
||||
m++;
|
||||
else if (*p)
|
||||
m = 0;
|
||||
else
|
||||
m = 4 - m;
|
||||
p++, n--;
|
||||
}
|
||||
|
||||
/* restore */
|
||||
z->total_in += p - z->next_in;
|
||||
z->next_in = p;
|
||||
z->avail_in = n;
|
||||
z->state->sub.marker = m;
|
||||
|
||||
/* return no joy or set up to restart on a new block */
|
||||
if (m != 4)
|
||||
return Z_DATA_ERROR;
|
||||
r = z->total_in; w = z->total_out;
|
||||
inflateReset(z);
|
||||
z->total_in = r; z->total_out = w;
|
||||
z->state->mode = BLOCKS;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Returns true if inflate is currently at the end of a block generated
|
||||
* by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
|
||||
* implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
|
||||
* but removes the length bytes of the resulting empty stored block. When
|
||||
* decompressing, PPP checks that at the end of input packet, inflate is
|
||||
* waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(z)
|
||||
z_streamp z;
|
||||
{
|
||||
if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
return inflate_blocks_sync_point(z->state->blocks);
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "inftrees.h"
|
||||
|
||||
#if !defined(BUILDFIXED) && !defined(STDC)
|
||||
# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
|
||||
#endif
|
||||
|
||||
local const char inflate_copyright[] =
|
||||
" inflate 1.1.4 Copyright 1995-2002 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
include such an acknowledgment, I would appreciate that you keep this
|
||||
copyright string in the executable of your product.
|
||||
*/
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* simplify the use of the inflate_huft type with some defines */
|
||||
#define exop word.what.Exop
|
||||
#define bits word.what.Bits
|
||||
|
||||
|
||||
local int huft_build OF((
|
||||
uIntf *, /* code lengths in bits */
|
||||
uInt, /* number of codes */
|
||||
uInt, /* number of "simple" codes */
|
||||
const uIntf *, /* list of base values for non-simple codes */
|
||||
const uIntf *, /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR*,/* result: starting table */
|
||||
uIntf *, /* maximum lookup bits (returns actual) */
|
||||
inflate_huft *, /* space for trees */
|
||||
uInt *, /* hufts used in space */
|
||||
uIntf * )); /* space for values */
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
/* see note #13 above about 258 */
|
||||
local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
|
||||
local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577};
|
||||
local const uInt cpdext[30] = { /* Extra bits for distance codes */
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13};
|
||||
|
||||
/*
|
||||
Huffman code decoding is performed using a multi-level table lookup.
|
||||
The fastest way to decode is to simply build a lookup table whose
|
||||
size is determined by the longest code. However, the time it takes
|
||||
to build this table can also be a factor if the data being decoded
|
||||
is not very long. The most common codes are necessarily the
|
||||
shortest codes, so those codes dominate the decoding time, and hence
|
||||
the speed. The idea is you can have a shorter table that decodes the
|
||||
shorter, more probable codes, and then point to subsidiary tables for
|
||||
the longer codes. The time it costs to decode the longer codes is
|
||||
then traded against the time it takes to make longer tables.
|
||||
|
||||
This results of this trade are in the variables lbits and dbits
|
||||
below. lbits is the number of bits the first level table for literal/
|
||||
length codes can decode in one step, and dbits is the same thing for
|
||||
the distance codes. Subsequent tables are also less than or equal to
|
||||
those sizes. These values may be adjusted either when all of the
|
||||
codes are shorter than that, in which case the longest code length in
|
||||
bits is used, or when the shortest code is *longer* than the requested
|
||||
table size, in which case the length of the shortest code in bits is
|
||||
used.
|
||||
|
||||
There are two different values for the two tables, since they code a
|
||||
different number of possibilities each. The literal/length table
|
||||
codes 286 possible values, or in a flat code, a little over eight
|
||||
bits. The distance table codes 30 possible values, or a little less
|
||||
than five bits, flat. The optimum values for speed end up being
|
||||
about one bit more than those, so lbits is 8+1 and dbits is 5+1.
|
||||
The optimum values may differ though from machine to machine, and
|
||||
possibly even between compilers. Your mileage may vary.
|
||||
*/
|
||||
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
|
||||
#define BMAX 15 /* maximum bit length of any code */
|
||||
|
||||
local int huft_build(b, n, s, d, e, t, m, hp, hn, v)
|
||||
uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
|
||||
uInt n; /* number of codes (assumed <= 288) */
|
||||
uInt s; /* number of simple-valued codes (0..s-1) */
|
||||
const uIntf *d; /* list of base values for non-simple codes */
|
||||
const uIntf *e; /* list of extra bits for non-simple codes */
|
||||
inflate_huft * FAR *t; /* result: starting table */
|
||||
uIntf *m; /* maximum lookup bits, returns actual */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
uInt *hn; /* hufts used in space */
|
||||
uIntf *v; /* working area: values in order of bit length */
|
||||
/* Given a list of code lengths and a maximum table size, make a set of
|
||||
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||
if the given code set is incomplete (the tables are still built in this
|
||||
case), or Z_DATA_ERROR if the input is invalid. */
|
||||
{
|
||||
|
||||
uInt a; /* counter for codes of length k */
|
||||
uInt c[BMAX+1]; /* bit length count table */
|
||||
uInt f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register uInt i; /* counter, current code */
|
||||
register uInt j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
|
||||
register uIntf *p; /* pointer into c[], b[], or v[] */
|
||||
inflate_huft *q; /* points to current table */
|
||||
struct inflate_huft_s r; /* table entry for structure assignment */
|
||||
inflate_huft *u[BMAX]; /* table stack */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
uInt x[BMAX+1]; /* bit offsets, then code stack */
|
||||
uIntf *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
uInt z; /* number of entries in current table */
|
||||
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
p = c;
|
||||
#define C0 *p++ = 0;
|
||||
#define C2 C0 C0 C0 C0
|
||||
#define C4 C2 C2 C2 C2
|
||||
C4 /* clear c[]--assume BMAX+1 is 16 */
|
||||
p = b; i = n;
|
||||
do {
|
||||
c[*p++]++; /* assume all entries <= BMAX */
|
||||
} while (--i);
|
||||
if (c[0] == n) /* null input--all zero length codes */
|
||||
{
|
||||
*t = (inflate_huft *)Z_NULL;
|
||||
*m = 0;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
l = *m;
|
||||
for (j = 1; j <= BMAX; j++)
|
||||
if (c[j])
|
||||
break;
|
||||
k = j; /* minimum code length */
|
||||
if ((uInt)l < j)
|
||||
l = j;
|
||||
for (i = BMAX; i; i--)
|
||||
if (c[i])
|
||||
break;
|
||||
g = i; /* maximum code length */
|
||||
if ((uInt)l > i)
|
||||
l = i;
|
||||
*m = l;
|
||||
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */
|
||||
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||
if ((y -= c[j]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
if ((y -= c[i]) < 0)
|
||||
return Z_DATA_ERROR;
|
||||
c[i] += y;
|
||||
|
||||
|
||||
/* Generate starting offsets into the value table for each length */
|
||||
x[1] = j = 0;
|
||||
p = c + 1; xp = x + 2;
|
||||
while (--i) { /* note that i == g from above */
|
||||
*xp++ = (j += *p++);
|
||||
}
|
||||
|
||||
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = b; i = 0;
|
||||
do {
|
||||
if ((j = *p++) != 0)
|
||||
v[x[j]++] = i;
|
||||
} while (++i < n);
|
||||
n = x[g]; /* set n to length of v */
|
||||
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
x[0] = i = 0; /* first Huffman code is zero */
|
||||
p = v; /* grab values in bit order */
|
||||
h = -1; /* no tables yet--level -1 */
|
||||
w = -l; /* bits decoded == (l * h) */
|
||||
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
|
||||
q = (inflate_huft *)Z_NULL; /* ditto */
|
||||
z = 0; /* ditto */
|
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */
|
||||
for (; k <= g; k++)
|
||||
{
|
||||
a = c[k];
|
||||
while (a--)
|
||||
{
|
||||
/* here i is the Huffman code of length k bits for value *p */
|
||||
/* make tables up to required level */
|
||||
while (k > w + l)
|
||||
{
|
||||
h++;
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = g - w;
|
||||
z = z > (uInt)l ? l : z; /* table size upper limit */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
|
||||
{ /* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
if (j < z)
|
||||
while (++j < z) /* try smaller tables up to z bits */
|
||||
{
|
||||
if ((f <<= 1) <= *++xp)
|
||||
break; /* enough codes to use up j bits */
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
/* allocate new table */
|
||||
if (*hn + z > MANY) /* (note: doesn't matter for fixed) */
|
||||
return Z_DATA_ERROR; /* overflow of MANY */
|
||||
u[h] = q = hp + *hn;
|
||||
*hn += z;
|
||||
|
||||
/* connect to last table, if there is one */
|
||||
if (h)
|
||||
{
|
||||
x[h] = i; /* save pattern for backing up */
|
||||
r.bits = (Byte)l; /* bits to dump before this table */
|
||||
r.exop = (Byte)j; /* bits in this table */
|
||||
j = i >> (w - l);
|
||||
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
|
||||
u[h-1][j] = r; /* connect to last table */
|
||||
}
|
||||
else
|
||||
*t = q; /* first table is returned result */
|
||||
}
|
||||
|
||||
/* set up table entry in r */
|
||||
r.bits = (Byte)(k - w);
|
||||
if (p >= v + n)
|
||||
r.exop = 128 + 64; /* out of values--invalid code */
|
||||
else if (*p < s)
|
||||
{
|
||||
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
|
||||
r.base = *p++; /* simple code is just the value */
|
||||
}
|
||||
else
|
||||
{
|
||||
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
|
||||
r.base = d[*p++ - s];
|
||||
}
|
||||
|
||||
/* fill code-like entries with r */
|
||||
f = 1 << (k - w);
|
||||
for (j = i >> w; j < z; j += f)
|
||||
q[j] = r;
|
||||
|
||||
/* backwards increment the k-bit code i */
|
||||
for (j = 1 << (k - 1); i & j; j >>= 1)
|
||||
i ^= j;
|
||||
i ^= j;
|
||||
|
||||
/* backup over finished tables */
|
||||
mask = (1 << w) - 1; /* needed on HP, cc -O bug */
|
||||
while ((i & mask) != x[h])
|
||||
{
|
||||
h--; /* don't need to update q */
|
||||
w -= l;
|
||||
mask = (1 << w) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Return Z_BUF_ERROR if we were given an incomplete table */
|
||||
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_bits(c, bb, tb, hp, z)
|
||||
uIntf *c; /* 19 code lengths */
|
||||
uIntf *bb; /* bits tree desired/actual depth */
|
||||
inflate_huft * FAR *tb; /* bits tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL,
|
||||
tb, bb, hp, &hn, v);
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
|
||||
else if (r == Z_BUF_ERROR || *bb == 0)
|
||||
{
|
||||
z->msg = (char*)"incomplete dynamic bit lengths tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z)
|
||||
uInt nl; /* number of literal/length codes */
|
||||
uInt nd; /* number of distance codes */
|
||||
uIntf *c; /* that many (total) code lengths */
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
inflate_huft *hp; /* space for trees */
|
||||
z_streamp z; /* for messages */
|
||||
{
|
||||
int r;
|
||||
uInt hn = 0; /* hufts used in space */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate work area */
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
||||
/* build literal/length tree */
|
||||
r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
|
||||
if (r != Z_OK || *bl == 0)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* build distance tree */
|
||||
r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
|
||||
if (r != Z_OK || (*bd == 0 && nl > 257))
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = (char*)"oversubscribed distance tree";
|
||||
else if (r == Z_BUF_ERROR) {
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
r = Z_OK;
|
||||
}
|
||||
#else
|
||||
z->msg = (char*)"incomplete distance tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
else if (r != Z_MEM_ERROR)
|
||||
{
|
||||
z->msg = (char*)"empty distance tree with lengths";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
ZFREE(z, v);
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
/* build fixed tables only once--keep them here */
|
||||
#ifdef BUILDFIXED
|
||||
local int fixed_built = 0;
|
||||
#define FIXEDH 544 /* number of hufts used by fixed tables */
|
||||
local inflate_huft fixed_mem[FIXEDH];
|
||||
local uInt fixed_bl;
|
||||
local uInt fixed_bd;
|
||||
local inflate_huft *fixed_tl;
|
||||
local inflate_huft *fixed_td;
|
||||
#else
|
||||
#include "inffixed.h"
|
||||
#endif
|
||||
|
||||
|
||||
int inflate_trees_fixed(bl, bd, tl, td, z)
|
||||
uIntf *bl; /* literal desired/actual bit depth */
|
||||
uIntf *bd; /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *tl; /* literal/length tree result */
|
||||
inflate_huft * FAR *td; /* distance tree result */
|
||||
z_streamp z; /* for memory allocation */
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
/* build fixed tables if not already */
|
||||
if (!fixed_built)
|
||||
{
|
||||
int k; /* temporary variable */
|
||||
uInt f = 0; /* number of hufts used in fixed_mem */
|
||||
uIntf *c; /* length list for huft_build */
|
||||
uIntf *v; /* work area for huft_build */
|
||||
|
||||
/* allocate memory */
|
||||
if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
return Z_MEM_ERROR;
|
||||
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
|
||||
{
|
||||
ZFREE(z, c);
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* literal table */
|
||||
for (k = 0; k < 144; k++)
|
||||
c[k] = 8;
|
||||
for (; k < 256; k++)
|
||||
c[k] = 9;
|
||||
for (; k < 280; k++)
|
||||
c[k] = 7;
|
||||
for (; k < 288; k++)
|
||||
c[k] = 8;
|
||||
fixed_bl = 9;
|
||||
huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* distance table */
|
||||
for (k = 0; k < 30; k++)
|
||||
c[k] = 5;
|
||||
fixed_bd = 5;
|
||||
huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd,
|
||||
fixed_mem, &f, v);
|
||||
|
||||
/* done */
|
||||
ZFREE(z, v);
|
||||
ZFREE(z, c);
|
||||
fixed_built = 1;
|
||||
}
|
||||
#endif
|
||||
*bl = fixed_bl;
|
||||
*bd = fixed_bd;
|
||||
*tl = fixed_tl;
|
||||
*td = fixed_td;
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* Huffman code lookup table entry--this entry is four bytes for machines
|
||||
that have 16-bit pointers (e.g. PC's in the small or medium model). */
|
||||
|
||||
#ifndef _INFTREES_H
|
||||
#define _INFTREES_H
|
||||
|
||||
typedef struct inflate_huft_s FAR inflate_huft;
|
||||
|
||||
struct inflate_huft_s {
|
||||
union {
|
||||
struct {
|
||||
Byte Exop; /* number of extra bits or operation */
|
||||
Byte Bits; /* number of bits in this code or subcode */
|
||||
} what;
|
||||
uInt pad; /* pad structure to a power of 2 (4 bytes for */
|
||||
} word; /* 16-bit, 8 bytes for 32-bit int's) */
|
||||
uInt base; /* literal, length base, distance base,
|
||||
or table offset */
|
||||
};
|
||||
|
||||
/* Maximum size of dynamic tree. The maximum found in a long but non-
|
||||
exhaustive search was 1004 huft structures (850 for length/literals
|
||||
and 154 for distances, the latter actually the result of an
|
||||
exhaustive search). The actual maximum is not known, but the
|
||||
value below is more than safe. */
|
||||
#define MANY 1440
|
||||
|
||||
extern int inflate_trees_bits OF((
|
||||
uIntf *, /* 19 code lengths */
|
||||
uIntf *, /* bits tree desired/actual depth */
|
||||
inflate_huft * FAR *, /* bits tree result */
|
||||
inflate_huft *, /* space for trees */
|
||||
z_streamp)); /* for messages */
|
||||
|
||||
extern int inflate_trees_dynamic OF((
|
||||
uInt, /* number of literal/length codes */
|
||||
uInt, /* number of distance codes */
|
||||
uIntf *, /* that many (total) code lengths */
|
||||
uIntf *, /* literal desired/actual bit depth */
|
||||
uIntf *, /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *, /* literal/length tree result */
|
||||
inflate_huft * FAR *, /* distance tree result */
|
||||
inflate_huft *, /* space for trees */
|
||||
z_streamp)); /* for messages */
|
||||
|
||||
extern int inflate_trees_fixed OF((
|
||||
uIntf *, /* literal desired/actual bit depth */
|
||||
uIntf *, /* distance desired/actual bit depth */
|
||||
inflate_huft * FAR *, /* literal/length tree result */
|
||||
inflate_huft * FAR *, /* distance tree result */
|
||||
z_streamp)); /* for memory allocation */
|
||||
|
||||
#endif /* _INFTREES_H */
|
||||
@@ -1,87 +0,0 @@
|
||||
/* inflate_util.c -- data and routines common to blocks and codes
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
#include "infblock.h"
|
||||
#include "inftrees.h"
|
||||
#include "infcodes.h"
|
||||
#include "infutil.h"
|
||||
|
||||
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
/* And'ing with mask[n] masks the lower n bits */
|
||||
uInt inflate_mask[17] = {
|
||||
0x0000,
|
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
int inflate_flush(s, z, r)
|
||||
inflate_blocks_statef *s;
|
||||
z_streamp z;
|
||||
int r;
|
||||
{
|
||||
uInt n;
|
||||
Bytef *p;
|
||||
Bytef *q;
|
||||
|
||||
/* local copies of source and destination pointers */
|
||||
p = z->next_out;
|
||||
q = s->read;
|
||||
|
||||
/* compute number of bytes to copy as far as end of window */
|
||||
n = (uInt)((q <= s->write ? s->write : s->end) - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy as far as end of window */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
|
||||
/* see if more to copy at beginning of window */
|
||||
if (q == s->end)
|
||||
{
|
||||
/* wrap pointers */
|
||||
q = s->window;
|
||||
if (s->write == s->end)
|
||||
s->write = s->window;
|
||||
|
||||
/* compute bytes to copy */
|
||||
n = (uInt)(s->write - q);
|
||||
if (n > z->avail_out) n = z->avail_out;
|
||||
if (n && r == Z_BUF_ERROR) r = Z_OK;
|
||||
|
||||
/* update counters */
|
||||
z->avail_out -= n;
|
||||
z->total_out += n;
|
||||
|
||||
/* update check information */
|
||||
if (s->checkfn != Z_NULL)
|
||||
z->adler = s->check = (*s->checkfn)(s->check, q, n);
|
||||
|
||||
/* copy */
|
||||
zmemcpy(p, q, n);
|
||||
p += n;
|
||||
q += n;
|
||||
}
|
||||
|
||||
/* update pointers */
|
||||
z->next_out = p;
|
||||
s->read = q;
|
||||
|
||||
/* done */
|
||||
return r;
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/* infutil.h -- types and macros common to blocks and codes
|
||||
* Copyright (C) 1995-2002 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef _INFUTIL_H
|
||||
#define _INFUTIL_H
|
||||
|
||||
typedef enum {
|
||||
TYPE, /* get type bits (3, including end bit) */
|
||||
LENS, /* get lengths for stored */
|
||||
STORED, /* processing stored block */
|
||||
TABLE, /* get table lengths */
|
||||
BTREE, /* get bit lengths tree for a dynamic block */
|
||||
DTREE, /* get length, distance trees for a dynamic block */
|
||||
CODES, /* processing fixed or dynamic block */
|
||||
DRY, /* output remaining window bytes */
|
||||
DONE, /* finished last block, done */
|
||||
BAD} /* got a data error--stuck here */
|
||||
inflate_block_mode;
|
||||
|
||||
/* inflate blocks semi-private state */
|
||||
struct inflate_blocks_state {
|
||||
|
||||
/* mode */
|
||||
inflate_block_mode mode; /* current inflate_block mode */
|
||||
|
||||
/* mode dependent information */
|
||||
union {
|
||||
uInt left; /* if STORED, bytes left to copy */
|
||||
struct {
|
||||
uInt table; /* table lengths (14 bits) */
|
||||
uInt index; /* index into blens (or border) */
|
||||
uIntf *blens; /* bit lengths of codes */
|
||||
uInt bb; /* bit length tree depth */
|
||||
inflate_huft *tb; /* bit length decoding tree */
|
||||
} trees; /* if DTREE, decoding info for trees */
|
||||
struct {
|
||||
inflate_codes_statef
|
||||
*codes;
|
||||
} decode; /* if CODES, current state */
|
||||
} sub; /* submode */
|
||||
uInt last; /* true if this block is the last block */
|
||||
|
||||
/* mode independent information */
|
||||
uInt bitk; /* bits in bit buffer */
|
||||
uLong bitb; /* bit buffer */
|
||||
inflate_huft *hufts; /* single malloc for tree space */
|
||||
Bytef *window; /* sliding window */
|
||||
Bytef *end; /* one byte after sliding window */
|
||||
Bytef *read; /* window read pointer */
|
||||
Bytef *write; /* window write pointer */
|
||||
check_func checkfn; /* check function */
|
||||
uLong check; /* check on output */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* defines for inflate input/output */
|
||||
/* update pointers and return */
|
||||
#define UPDBITS {s->bitb=b;s->bitk=k;}
|
||||
#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
|
||||
#define UPDOUT {s->write=q;}
|
||||
#define UPDATE {UPDBITS UPDIN UPDOUT}
|
||||
#define LEAVE {UPDATE return inflate_flush(s,z,r);}
|
||||
/* get bytes and bits */
|
||||
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
|
||||
#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
|
||||
#define NEXTBYTE (n--,*p++)
|
||||
#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
|
||||
#define DUMPBITS(j) {b>>=(j);k-=(j);}
|
||||
/* output bytes */
|
||||
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
|
||||
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
|
||||
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
|
||||
#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
|
||||
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
|
||||
#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
|
||||
/* load local pointers */
|
||||
#define LOAD {LOADIN LOADOUT}
|
||||
|
||||
/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
|
||||
extern uInt inflate_mask[17];
|
||||
|
||||
/* copy as much as possible from the sliding window to the output area */
|
||||
extern int inflate_flush OF((
|
||||
inflate_blocks_statef *,
|
||||
z_streamp ,
|
||||
int));
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#endif /* _INFUTIL_H */
|
||||
@@ -1,357 +0,0 @@
|
||||
/* match.s -- Pentium-optimized version of longest_match()
|
||||
* Written for zlib 1.1.2
|
||||
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License.
|
||||
*/
|
||||
|
||||
#ifndef NO_UNDERLINE
|
||||
#define match_init _ipcomp_match_init
|
||||
#define longest_match _ipcomp_longest_match
|
||||
#else
|
||||
#define match_init ipcomp_match_init
|
||||
#define longest_match ipcomp_longest_match
|
||||
#endif
|
||||
|
||||
#define MAX_MATCH (258)
|
||||
#define MIN_MATCH (3)
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
|
||||
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
|
||||
|
||||
/* stack frame offsets */
|
||||
|
||||
#define wmask 0 /* local copy of s->wmask */
|
||||
#define window 4 /* local copy of s->window */
|
||||
#define windowbestlen 8 /* s->window + bestlen */
|
||||
#define chainlenscanend 12 /* high word: current chain len */
|
||||
/* low word: last bytes sought */
|
||||
#define scanstart 16 /* first two bytes of string */
|
||||
#define scanalign 20 /* dword-misalignment of string */
|
||||
#define nicematch 24 /* a good enough match size */
|
||||
#define bestlen 28 /* size of best match so far */
|
||||
#define scan 32 /* ptr to string wanting match */
|
||||
|
||||
#define LocalVarsSize (36)
|
||||
/* saved ebx 36 */
|
||||
/* saved edi 40 */
|
||||
/* saved esi 44 */
|
||||
/* saved ebp 48 */
|
||||
/* return address 52 */
|
||||
#define deflatestate 56 /* the function arguments */
|
||||
#define curmatch 60
|
||||
|
||||
/* Offsets for fields in the deflate_state structure. These numbers
|
||||
* are calculated from the definition of deflate_state, with the
|
||||
* assumption that the compiler will dword-align the fields. (Thus,
|
||||
* changing the definition of deflate_state could easily cause this
|
||||
* program to crash horribly, without so much as a warning at
|
||||
* compile time. Sigh.)
|
||||
*/
|
||||
#define dsWSize 36
|
||||
#define dsWMask 44
|
||||
#define dsWindow 48
|
||||
#define dsPrev 56
|
||||
#define dsMatchLen 88
|
||||
#define dsPrevMatch 92
|
||||
#define dsStrStart 100
|
||||
#define dsMatchStart 104
|
||||
#define dsLookahead 108
|
||||
#define dsPrevLen 112
|
||||
#define dsMaxChainLen 116
|
||||
#define dsGoodMatch 132
|
||||
#define dsNiceMatch 136
|
||||
|
||||
|
||||
.file "match.S"
|
||||
|
||||
.globl match_init, longest_match
|
||||
|
||||
.text
|
||||
|
||||
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
|
||||
|
||||
longest_match:
|
||||
|
||||
/* Save registers that the compiler may be using, and adjust %esp to */
|
||||
/* make room for our stack frame. */
|
||||
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
subl $LocalVarsSize, %esp
|
||||
|
||||
/* Retrieve the function arguments. %ecx will hold cur_match */
|
||||
/* throughout the entire function. %edx will hold the pointer to the */
|
||||
/* deflate_state structure during the function's setup (before */
|
||||
/* entering the main loop). */
|
||||
|
||||
movl deflatestate(%esp), %edx
|
||||
movl curmatch(%esp), %ecx
|
||||
|
||||
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
|
||||
|
||||
movl dsNiceMatch(%edx), %eax
|
||||
movl dsLookahead(%edx), %ebx
|
||||
cmpl %eax, %ebx
|
||||
jl LookaheadLess
|
||||
movl %eax, %ebx
|
||||
LookaheadLess: movl %ebx, nicematch(%esp)
|
||||
|
||||
/* register Bytef *scan = s->window + s->strstart; */
|
||||
|
||||
movl dsWindow(%edx), %esi
|
||||
movl %esi, window(%esp)
|
||||
movl dsStrStart(%edx), %ebp
|
||||
lea (%esi,%ebp), %edi
|
||||
movl %edi, scan(%esp)
|
||||
|
||||
/* Determine how many bytes the scan ptr is off from being */
|
||||
/* dword-aligned. */
|
||||
|
||||
movl %edi, %eax
|
||||
negl %eax
|
||||
andl $3, %eax
|
||||
movl %eax, scanalign(%esp)
|
||||
|
||||
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
|
||||
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
|
||||
|
||||
movl dsWSize(%edx), %eax
|
||||
subl $MIN_LOOKAHEAD, %eax
|
||||
subl %eax, %ebp
|
||||
jg LimitPositive
|
||||
xorl %ebp, %ebp
|
||||
LimitPositive:
|
||||
|
||||
/* unsigned chain_length = s->max_chain_length; */
|
||||
/* if (s->prev_length >= s->good_match) { */
|
||||
/* chain_length >>= 2; */
|
||||
/* } */
|
||||
|
||||
movl dsPrevLen(%edx), %eax
|
||||
movl dsGoodMatch(%edx), %ebx
|
||||
cmpl %ebx, %eax
|
||||
movl dsMaxChainLen(%edx), %ebx
|
||||
jl LastMatchGood
|
||||
shrl $2, %ebx
|
||||
LastMatchGood:
|
||||
|
||||
/* chainlen is decremented once beforehand so that the function can */
|
||||
/* use the sign flag instead of the zero flag for the exit test. */
|
||||
/* It is then shifted into the high word, to make room for the scanend */
|
||||
/* scanend value, which it will always accompany. */
|
||||
|
||||
decl %ebx
|
||||
shll $16, %ebx
|
||||
|
||||
/* int best_len = s->prev_length; */
|
||||
|
||||
movl dsPrevLen(%edx), %eax
|
||||
movl %eax, bestlen(%esp)
|
||||
|
||||
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
|
||||
|
||||
addl %eax, %esi
|
||||
movl %esi, windowbestlen(%esp)
|
||||
|
||||
/* register ush scan_start = *(ushf*)scan; */
|
||||
/* register ush scan_end = *(ushf*)(scan+best_len-1); */
|
||||
|
||||
movw (%edi), %bx
|
||||
movw %bx, scanstart(%esp)
|
||||
movw -1(%edi,%eax), %bx
|
||||
movl %ebx, chainlenscanend(%esp)
|
||||
|
||||
/* Posf *prev = s->prev; */
|
||||
/* uInt wmask = s->w_mask; */
|
||||
|
||||
movl dsPrev(%edx), %edi
|
||||
movl dsWMask(%edx), %edx
|
||||
mov %edx, wmask(%esp)
|
||||
|
||||
/* Jump into the main loop. */
|
||||
|
||||
jmp LoopEntry
|
||||
|
||||
.balign 16
|
||||
|
||||
/* do {
|
||||
* match = s->window + cur_match;
|
||||
* if (*(ushf*)(match+best_len-1) != scan_end ||
|
||||
* *(ushf*)match != scan_start) continue;
|
||||
* [...]
|
||||
* } while ((cur_match = prev[cur_match & wmask]) > limit
|
||||
* && --chain_length != 0);
|
||||
*
|
||||
* Here is the inner loop of the function. The function will spend the
|
||||
* majority of its time in this loop, and majority of that time will
|
||||
* be spent in the first ten instructions.
|
||||
*
|
||||
* Within this loop:
|
||||
* %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend)
|
||||
* %ecx = curmatch
|
||||
* %edx = curmatch & wmask
|
||||
* %esi = windowbestlen - i.e., (window + bestlen)
|
||||
* %edi = prev
|
||||
* %ebp = limit
|
||||
*
|
||||
* Two optimization notes on the choice of instructions:
|
||||
*
|
||||
* The first instruction uses a 16-bit address, which costs an extra,
|
||||
* unpairable cycle. This is cheaper than doing a 32-bit access and
|
||||
* zeroing the high word, due to the 3-cycle misalignment penalty which
|
||||
* would occur half the time. This also turns out to be cheaper than
|
||||
* doing two separate 8-bit accesses, as the memory is so rarely in the
|
||||
* L1 cache.
|
||||
*
|
||||
* The window buffer, however, apparently spends a lot of time in the
|
||||
* cache, and so it is faster to retrieve the word at the end of the
|
||||
* match string with two 8-bit loads. The instructions that test the
|
||||
* word at the beginning of the match string, however, are executed
|
||||
* much less frequently, and there it was cheaper to use 16-bit
|
||||
* instructions, which avoided the necessity of saving off and
|
||||
* subsequently reloading one of the other registers.
|
||||
*/
|
||||
LookupLoop:
|
||||
/* 1 U & V */
|
||||
movw (%edi,%edx,2), %cx /* 2 U pipe */
|
||||
movl wmask(%esp), %edx /* 2 V pipe */
|
||||
cmpl %ebp, %ecx /* 3 U pipe */
|
||||
jbe LeaveNow /* 3 V pipe */
|
||||
subl $0x00010000, %ebx /* 4 U pipe */
|
||||
js LeaveNow /* 4 V pipe */
|
||||
LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */
|
||||
andl %ecx, %edx /* 5 V pipe */
|
||||
cmpb %bl, %al /* 6 U pipe */
|
||||
jnz LookupLoop /* 6 V pipe */
|
||||
movb (%esi,%ecx), %ah
|
||||
cmpb %bh, %ah
|
||||
jnz LookupLoop
|
||||
movl window(%esp), %eax
|
||||
movw (%eax,%ecx), %ax
|
||||
cmpw scanstart(%esp), %ax
|
||||
jnz LookupLoop
|
||||
|
||||
/* Store the current value of chainlen. */
|
||||
|
||||
movl %ebx, chainlenscanend(%esp)
|
||||
|
||||
/* Point %edi to the string under scrutiny, and %esi to the string we */
|
||||
/* are hoping to match it up with. In actuality, %esi and %edi are */
|
||||
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
|
||||
/* initialized to -(MAX_MATCH_8 - scanalign). */
|
||||
|
||||
movl window(%esp), %esi
|
||||
movl scan(%esp), %edi
|
||||
addl %ecx, %esi
|
||||
movl scanalign(%esp), %eax
|
||||
movl $(-MAX_MATCH_8), %edx
|
||||
lea MAX_MATCH_8(%edi,%eax), %edi
|
||||
lea MAX_MATCH_8(%esi,%eax), %esi
|
||||
|
||||
/* Test the strings for equality, 8 bytes at a time. At the end,
|
||||
* adjust %edx so that it is offset to the exact byte that mismatched.
|
||||
*
|
||||
* We already know at this point that the first three bytes of the
|
||||
* strings match each other, and they can be safely passed over before
|
||||
* starting the compare loop. So what this code does is skip over 0-3
|
||||
* bytes, as much as necessary in order to dword-align the %edi
|
||||
* pointer. (%esi will still be misaligned three times out of four.)
|
||||
*
|
||||
* It should be confessed that this loop usually does not represent
|
||||
* much of the total running time. Replacing it with a more
|
||||
* straightforward "rep cmpsb" would not drastically degrade
|
||||
* performance.
|
||||
*/
|
||||
LoopCmps:
|
||||
movl (%esi,%edx), %eax
|
||||
movl (%edi,%edx), %ebx
|
||||
xorl %ebx, %eax
|
||||
jnz LeaveLoopCmps
|
||||
movl 4(%esi,%edx), %eax
|
||||
movl 4(%edi,%edx), %ebx
|
||||
xorl %ebx, %eax
|
||||
jnz LeaveLoopCmps4
|
||||
addl $8, %edx
|
||||
jnz LoopCmps
|
||||
jmp LenMaximum
|
||||
LeaveLoopCmps4: addl $4, %edx
|
||||
LeaveLoopCmps: testl $0x0000FFFF, %eax
|
||||
jnz LenLower
|
||||
addl $2, %edx
|
||||
shrl $16, %eax
|
||||
LenLower: subb $1, %al
|
||||
adcl $0, %edx
|
||||
|
||||
/* Calculate the length of the match. If it is longer than MAX_MATCH, */
|
||||
/* then automatically accept it as the best possible match and leave. */
|
||||
|
||||
lea (%edi,%edx), %eax
|
||||
movl scan(%esp), %edi
|
||||
subl %edi, %eax
|
||||
cmpl $MAX_MATCH, %eax
|
||||
jge LenMaximum
|
||||
|
||||
/* If the length of the match is not longer than the best match we */
|
||||
/* have so far, then forget it and return to the lookup loop. */
|
||||
|
||||
movl deflatestate(%esp), %edx
|
||||
movl bestlen(%esp), %ebx
|
||||
cmpl %ebx, %eax
|
||||
jg LongerMatch
|
||||
movl chainlenscanend(%esp), %ebx
|
||||
movl windowbestlen(%esp), %esi
|
||||
movl dsPrev(%edx), %edi
|
||||
movl wmask(%esp), %edx
|
||||
andl %ecx, %edx
|
||||
jmp LookupLoop
|
||||
|
||||
/* s->match_start = cur_match; */
|
||||
/* best_len = len; */
|
||||
/* if (len >= nice_match) break; */
|
||||
/* scan_end = *(ushf*)(scan+best_len-1); */
|
||||
|
||||
LongerMatch: movl nicematch(%esp), %ebx
|
||||
movl %eax, bestlen(%esp)
|
||||
movl %ecx, dsMatchStart(%edx)
|
||||
cmpl %ebx, %eax
|
||||
jge LeaveNow
|
||||
movl window(%esp), %esi
|
||||
addl %eax, %esi
|
||||
movl %esi, windowbestlen(%esp)
|
||||
movl chainlenscanend(%esp), %ebx
|
||||
movw -1(%edi,%eax), %bx
|
||||
movl dsPrev(%edx), %edi
|
||||
movl %ebx, chainlenscanend(%esp)
|
||||
movl wmask(%esp), %edx
|
||||
andl %ecx, %edx
|
||||
jmp LookupLoop
|
||||
|
||||
/* Accept the current string, with the maximum possible length. */
|
||||
|
||||
LenMaximum: movl deflatestate(%esp), %edx
|
||||
movl $MAX_MATCH, bestlen(%esp)
|
||||
movl %ecx, dsMatchStart(%edx)
|
||||
|
||||
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
|
||||
/* return s->lookahead; */
|
||||
|
||||
LeaveNow:
|
||||
movl deflatestate(%esp), %edx
|
||||
movl bestlen(%esp), %ebx
|
||||
movl dsLookahead(%edx), %eax
|
||||
cmpl %eax, %ebx
|
||||
jg LookaheadRet
|
||||
movl %ebx, %eax
|
||||
LookaheadRet:
|
||||
|
||||
/* Restore the stack and return from whence we came. */
|
||||
|
||||
addl $LocalVarsSize, %esp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
match_init: ret
|
||||
@@ -1,330 +0,0 @@
|
||||
/* match.s -- Pentium-Pro-optimized version of longest_match()
|
||||
* Written for zlib 1.1.2
|
||||
* Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License.
|
||||
*/
|
||||
|
||||
#ifndef NO_UNDERLINE
|
||||
#define match_init _ipcomp_match_init
|
||||
#define longest_match _ipcomp_longest_match
|
||||
#else
|
||||
#define match_init ipcomp_match_init
|
||||
#define longest_match ipcomp_longest_match
|
||||
#endif
|
||||
|
||||
#define MAX_MATCH (258)
|
||||
#define MIN_MATCH (3)
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1)
|
||||
#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7)
|
||||
|
||||
/* stack frame offsets */
|
||||
|
||||
#define chainlenwmask 0 /* high word: current chain len */
|
||||
/* low word: s->wmask */
|
||||
#define window 4 /* local copy of s->window */
|
||||
#define windowbestlen 8 /* s->window + bestlen */
|
||||
#define scanstart 16 /* first two bytes of string */
|
||||
#define scanend 12 /* last two bytes of string */
|
||||
#define scanalign 20 /* dword-misalignment of string */
|
||||
#define nicematch 24 /* a good enough match size */
|
||||
#define bestlen 28 /* size of best match so far */
|
||||
#define scan 32 /* ptr to string wanting match */
|
||||
|
||||
#define LocalVarsSize (36)
|
||||
/* saved ebx 36 */
|
||||
/* saved edi 40 */
|
||||
/* saved esi 44 */
|
||||
/* saved ebp 48 */
|
||||
/* return address 52 */
|
||||
#define deflatestate 56 /* the function arguments */
|
||||
#define curmatch 60
|
||||
|
||||
/* Offsets for fields in the deflate_state structure. These numbers
|
||||
* are calculated from the definition of deflate_state, with the
|
||||
* assumption that the compiler will dword-align the fields. (Thus,
|
||||
* changing the definition of deflate_state could easily cause this
|
||||
* program to crash horribly, without so much as a warning at
|
||||
* compile time. Sigh.)
|
||||
*/
|
||||
#define dsWSize 36
|
||||
#define dsWMask 44
|
||||
#define dsWindow 48
|
||||
#define dsPrev 56
|
||||
#define dsMatchLen 88
|
||||
#define dsPrevMatch 92
|
||||
#define dsStrStart 100
|
||||
#define dsMatchStart 104
|
||||
#define dsLookahead 108
|
||||
#define dsPrevLen 112
|
||||
#define dsMaxChainLen 116
|
||||
#define dsGoodMatch 132
|
||||
#define dsNiceMatch 136
|
||||
|
||||
|
||||
.file "match.S"
|
||||
|
||||
.globl match_init, longest_match
|
||||
|
||||
.text
|
||||
|
||||
/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
|
||||
|
||||
longest_match:
|
||||
|
||||
/* Save registers that the compiler may be using, and adjust %esp to */
|
||||
/* make room for our stack frame. */
|
||||
|
||||
pushl %ebp
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
subl $LocalVarsSize, %esp
|
||||
|
||||
/* Retrieve the function arguments. %ecx will hold cur_match */
|
||||
/* throughout the entire function. %edx will hold the pointer to the */
|
||||
/* deflate_state structure during the function's setup (before */
|
||||
/* entering the main loop). */
|
||||
|
||||
movl deflatestate(%esp), %edx
|
||||
movl curmatch(%esp), %ecx
|
||||
|
||||
/* uInt wmask = s->w_mask; */
|
||||
/* unsigned chain_length = s->max_chain_length; */
|
||||
/* if (s->prev_length >= s->good_match) { */
|
||||
/* chain_length >>= 2; */
|
||||
/* } */
|
||||
|
||||
movl dsPrevLen(%edx), %eax
|
||||
movl dsGoodMatch(%edx), %ebx
|
||||
cmpl %ebx, %eax
|
||||
movl dsWMask(%edx), %eax
|
||||
movl dsMaxChainLen(%edx), %ebx
|
||||
jl LastMatchGood
|
||||
shrl $2, %ebx
|
||||
LastMatchGood:
|
||||
|
||||
/* chainlen is decremented once beforehand so that the function can */
|
||||
/* use the sign flag instead of the zero flag for the exit test. */
|
||||
/* It is then shifted into the high word, to make room for the wmask */
|
||||
/* value, which it will always accompany. */
|
||||
|
||||
decl %ebx
|
||||
shll $16, %ebx
|
||||
orl %eax, %ebx
|
||||
movl %ebx, chainlenwmask(%esp)
|
||||
|
||||
/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */
|
||||
|
||||
movl dsNiceMatch(%edx), %eax
|
||||
movl dsLookahead(%edx), %ebx
|
||||
cmpl %eax, %ebx
|
||||
jl LookaheadLess
|
||||
movl %eax, %ebx
|
||||
LookaheadLess: movl %ebx, nicematch(%esp)
|
||||
|
||||
/* register Bytef *scan = s->window + s->strstart; */
|
||||
|
||||
movl dsWindow(%edx), %esi
|
||||
movl %esi, window(%esp)
|
||||
movl dsStrStart(%edx), %ebp
|
||||
lea (%esi,%ebp), %edi
|
||||
movl %edi, scan(%esp)
|
||||
|
||||
/* Determine how many bytes the scan ptr is off from being */
|
||||
/* dword-aligned. */
|
||||
|
||||
movl %edi, %eax
|
||||
negl %eax
|
||||
andl $3, %eax
|
||||
movl %eax, scanalign(%esp)
|
||||
|
||||
/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */
|
||||
/* s->strstart - (IPos)MAX_DIST(s) : NIL; */
|
||||
|
||||
movl dsWSize(%edx), %eax
|
||||
subl $MIN_LOOKAHEAD, %eax
|
||||
subl %eax, %ebp
|
||||
jg LimitPositive
|
||||
xorl %ebp, %ebp
|
||||
LimitPositive:
|
||||
|
||||
/* int best_len = s->prev_length; */
|
||||
|
||||
movl dsPrevLen(%edx), %eax
|
||||
movl %eax, bestlen(%esp)
|
||||
|
||||
/* Store the sum of s->window + best_len in %esi locally, and in %esi. */
|
||||
|
||||
addl %eax, %esi
|
||||
movl %esi, windowbestlen(%esp)
|
||||
|
||||
/* register ush scan_start = *(ushf*)scan; */
|
||||
/* register ush scan_end = *(ushf*)(scan+best_len-1); */
|
||||
/* Posf *prev = s->prev; */
|
||||
|
||||
movzwl (%edi), %ebx
|
||||
movl %ebx, scanstart(%esp)
|
||||
movzwl -1(%edi,%eax), %ebx
|
||||
movl %ebx, scanend(%esp)
|
||||
movl dsPrev(%edx), %edi
|
||||
|
||||
/* Jump into the main loop. */
|
||||
|
||||
movl chainlenwmask(%esp), %edx
|
||||
jmp LoopEntry
|
||||
|
||||
.balign 16
|
||||
|
||||
/* do {
|
||||
* match = s->window + cur_match;
|
||||
* if (*(ushf*)(match+best_len-1) != scan_end ||
|
||||
* *(ushf*)match != scan_start) continue;
|
||||
* [...]
|
||||
* } while ((cur_match = prev[cur_match & wmask]) > limit
|
||||
* && --chain_length != 0);
|
||||
*
|
||||
* Here is the inner loop of the function. The function will spend the
|
||||
* majority of its time in this loop, and majority of that time will
|
||||
* be spent in the first ten instructions.
|
||||
*
|
||||
* Within this loop:
|
||||
* %ebx = scanend
|
||||
* %ecx = curmatch
|
||||
* %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
|
||||
* %esi = windowbestlen - i.e., (window + bestlen)
|
||||
* %edi = prev
|
||||
* %ebp = limit
|
||||
*/
|
||||
LookupLoop:
|
||||
andl %edx, %ecx
|
||||
movzwl (%edi,%ecx,2), %ecx
|
||||
cmpl %ebp, %ecx
|
||||
jbe LeaveNow
|
||||
subl $0x00010000, %edx
|
||||
js LeaveNow
|
||||
LoopEntry: movzwl -1(%esi,%ecx), %eax
|
||||
cmpl %ebx, %eax
|
||||
jnz LookupLoop
|
||||
movl window(%esp), %eax
|
||||
movzwl (%eax,%ecx), %eax
|
||||
cmpl scanstart(%esp), %eax
|
||||
jnz LookupLoop
|
||||
|
||||
/* Store the current value of chainlen. */
|
||||
|
||||
movl %edx, chainlenwmask(%esp)
|
||||
|
||||
/* Point %edi to the string under scrutiny, and %esi to the string we */
|
||||
/* are hoping to match it up with. In actuality, %esi and %edi are */
|
||||
/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */
|
||||
/* initialized to -(MAX_MATCH_8 - scanalign). */
|
||||
|
||||
movl window(%esp), %esi
|
||||
movl scan(%esp), %edi
|
||||
addl %ecx, %esi
|
||||
movl scanalign(%esp), %eax
|
||||
movl $(-MAX_MATCH_8), %edx
|
||||
lea MAX_MATCH_8(%edi,%eax), %edi
|
||||
lea MAX_MATCH_8(%esi,%eax), %esi
|
||||
|
||||
/* Test the strings for equality, 8 bytes at a time. At the end,
|
||||
* adjust %edx so that it is offset to the exact byte that mismatched.
|
||||
*
|
||||
* We already know at this point that the first three bytes of the
|
||||
* strings match each other, and they can be safely passed over before
|
||||
* starting the compare loop. So what this code does is skip over 0-3
|
||||
* bytes, as much as necessary in order to dword-align the %edi
|
||||
* pointer. (%esi will still be misaligned three times out of four.)
|
||||
*
|
||||
* It should be confessed that this loop usually does not represent
|
||||
* much of the total running time. Replacing it with a more
|
||||
* straightforward "rep cmpsb" would not drastically degrade
|
||||
* performance.
|
||||
*/
|
||||
LoopCmps:
|
||||
movl (%esi,%edx), %eax
|
||||
xorl (%edi,%edx), %eax
|
||||
jnz LeaveLoopCmps
|
||||
movl 4(%esi,%edx), %eax
|
||||
xorl 4(%edi,%edx), %eax
|
||||
jnz LeaveLoopCmps4
|
||||
addl $8, %edx
|
||||
jnz LoopCmps
|
||||
jmp LenMaximum
|
||||
LeaveLoopCmps4: addl $4, %edx
|
||||
LeaveLoopCmps: testl $0x0000FFFF, %eax
|
||||
jnz LenLower
|
||||
addl $2, %edx
|
||||
shrl $16, %eax
|
||||
LenLower: subb $1, %al
|
||||
adcl $0, %edx
|
||||
|
||||
/* Calculate the length of the match. If it is longer than MAX_MATCH, */
|
||||
/* then automatically accept it as the best possible match and leave. */
|
||||
|
||||
lea (%edi,%edx), %eax
|
||||
movl scan(%esp), %edi
|
||||
subl %edi, %eax
|
||||
cmpl $MAX_MATCH, %eax
|
||||
jge LenMaximum
|
||||
|
||||
/* If the length of the match is not longer than the best match we */
|
||||
/* have so far, then forget it and return to the lookup loop. */
|
||||
|
||||
movl deflatestate(%esp), %edx
|
||||
movl bestlen(%esp), %ebx
|
||||
cmpl %ebx, %eax
|
||||
jg LongerMatch
|
||||
movl windowbestlen(%esp), %esi
|
||||
movl dsPrev(%edx), %edi
|
||||
movl scanend(%esp), %ebx
|
||||
movl chainlenwmask(%esp), %edx
|
||||
jmp LookupLoop
|
||||
|
||||
/* s->match_start = cur_match; */
|
||||
/* best_len = len; */
|
||||
/* if (len >= nice_match) break; */
|
||||
/* scan_end = *(ushf*)(scan+best_len-1); */
|
||||
|
||||
LongerMatch: movl nicematch(%esp), %ebx
|
||||
movl %eax, bestlen(%esp)
|
||||
movl %ecx, dsMatchStart(%edx)
|
||||
cmpl %ebx, %eax
|
||||
jge LeaveNow
|
||||
movl window(%esp), %esi
|
||||
addl %eax, %esi
|
||||
movl %esi, windowbestlen(%esp)
|
||||
movzwl -1(%edi,%eax), %ebx
|
||||
movl dsPrev(%edx), %edi
|
||||
movl %ebx, scanend(%esp)
|
||||
movl chainlenwmask(%esp), %edx
|
||||
jmp LookupLoop
|
||||
|
||||
/* Accept the current string, with the maximum possible length. */
|
||||
|
||||
LenMaximum: movl deflatestate(%esp), %edx
|
||||
movl $MAX_MATCH, bestlen(%esp)
|
||||
movl %ecx, dsMatchStart(%edx)
|
||||
|
||||
/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */
|
||||
/* return s->lookahead; */
|
||||
|
||||
LeaveNow:
|
||||
movl deflatestate(%esp), %edx
|
||||
movl bestlen(%esp), %ebx
|
||||
movl dsLookahead(%edx), %eax
|
||||
cmpl %eax, %ebx
|
||||
jg LookaheadRet
|
||||
movl %ebx, %eax
|
||||
LookaheadRet:
|
||||
|
||||
/* Restore the stack and return from whence we came. */
|
||||
|
||||
addl $LocalVarsSize, %esp
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
match_init: ret
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,128 +0,0 @@
|
||||
/* header created automatically with -DGEN_TREES_H */
|
||||
|
||||
local const ct_data static_ltree[L_CODES+2] = {
|
||||
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
|
||||
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
|
||||
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
|
||||
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
|
||||
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
|
||||
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
|
||||
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
|
||||
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
|
||||
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
|
||||
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
|
||||
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
|
||||
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
|
||||
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
|
||||
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
|
||||
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
|
||||
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
|
||||
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
|
||||
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
|
||||
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
|
||||
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
|
||||
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
|
||||
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
|
||||
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
|
||||
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
|
||||
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
|
||||
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
|
||||
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
|
||||
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
|
||||
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
|
||||
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
|
||||
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
|
||||
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
|
||||
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
|
||||
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
|
||||
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
|
||||
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
|
||||
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
|
||||
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
|
||||
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
|
||||
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
|
||||
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
|
||||
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
|
||||
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
|
||||
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
|
||||
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
|
||||
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
|
||||
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
|
||||
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
|
||||
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
|
||||
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
|
||||
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
|
||||
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
|
||||
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
|
||||
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
|
||||
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
|
||||
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
|
||||
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
|
||||
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
|
||||
};
|
||||
|
||||
local const ct_data static_dtree[D_CODES] = {
|
||||
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
|
||||
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
|
||||
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
|
||||
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
|
||||
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
|
||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||
};
|
||||
|
||||
const uch _dist_code[DIST_CODE_LEN] = {
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
|
||||
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||
};
|
||||
|
||||
local const int base_length[LENGTH_CODES] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
|
||||
64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||
};
|
||||
|
||||
local const int base_dist[D_CODES] = {
|
||||
0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
|
||||
32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
|
||||
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: zconf.h,v 1.1 2004/03/15 20:35:26 as Exp $ */
|
||||
|
||||
#ifndef _ZCONF_H
|
||||
#define _ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef IPCOMP_PREFIX
|
||||
# define deflateInit_ ipcomp_deflateInit_
|
||||
# define deflate ipcomp_deflate
|
||||
# define deflateEnd ipcomp_deflateEnd
|
||||
# define inflateInit_ ipcomp_inflateInit_
|
||||
# define inflate ipcomp_inflate
|
||||
# define inflateEnd ipcomp_inflateEnd
|
||||
# define deflateInit2_ ipcomp_deflateInit2_
|
||||
# define deflateSetDictionary ipcomp_deflateSetDictionary
|
||||
# define deflateCopy ipcomp_deflateCopy
|
||||
# define deflateReset ipcomp_deflateReset
|
||||
# define deflateParams ipcomp_deflateParams
|
||||
# define inflateInit2_ ipcomp_inflateInit2_
|
||||
# define inflateSetDictionary ipcomp_inflateSetDictionary
|
||||
# define inflateSync ipcomp_inflateSync
|
||||
# define inflateSyncPoint ipcomp_inflateSyncPoint
|
||||
# define inflateReset ipcomp_inflateReset
|
||||
# define compress ipcomp_compress
|
||||
# define compress2 ipcomp_compress2
|
||||
# define uncompress ipcomp_uncompress
|
||||
# define adler32 ipcomp_adler32
|
||||
# define crc32 ipcomp_crc32
|
||||
# define get_crc_table ipcomp_get_crc_table
|
||||
/* SSS: these also need to be prefixed to avoid clash with ppp_deflate and ext2compression */
|
||||
# define inflate_blocks ipcomp_deflate_blocks
|
||||
# define inflate_blocks_free ipcomp_deflate_blocks_free
|
||||
# define inflate_blocks_new ipcomp_inflate_blocks_new
|
||||
# define inflate_blocks_reset ipcomp_inflate_blocks_reset
|
||||
# define inflate_blocks_sync_point ipcomp_inflate_blocks_sync_point
|
||||
# define inflate_set_dictionary ipcomp_inflate_set_dictionary
|
||||
# define inflate_codes ipcomp_inflate_codes
|
||||
# define inflate_codes_free ipcomp_inflate_codes_free
|
||||
# define inflate_codes_new ipcomp_inflate_codes_new
|
||||
# define inflate_fast ipcomp_inflate_fast
|
||||
# define inflate_trees_bits ipcomp_inflate_trees_bits
|
||||
# define inflate_trees_dynamic ipcomp_inflate_trees_dynamic
|
||||
# define inflate_trees_fixed ipcomp_inflate_trees_fixed
|
||||
# define inflate_flush ipcomp_inflate_flush
|
||||
# define inflate_mask ipcomp_inflate_mask
|
||||
# define _dist_code _ipcomp_dist_code
|
||||
# define _length_code _ipcomp_length_code
|
||||
# define _tr_align _ipcomp_tr_align
|
||||
# define _tr_flush_block _ipcomp_tr_flush_block
|
||||
# define _tr_init _ipcomp_tr_init
|
||||
# define _tr_stored_block _ipcomp_tr_stored_block
|
||||
# define _tr_tally _ipcomp_tr_tally
|
||||
# define zError ipcomp_zError
|
||||
# define z_errmsg ipcomp_z_errmsg
|
||||
# define zlibVersion ipcomp_zlibVersion
|
||||
# define match_init ipcomp_match_init
|
||||
# define longest_match ipcomp_longest_match
|
||||
#endif
|
||||
|
||||
#ifdef Z_PREFIX
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
# define WIN32
|
||||
#endif
|
||||
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
|
||||
# ifndef __32BIT__
|
||||
# define __32BIT__
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#if defined(MSDOS) && !defined(__32BIT__)
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
|
||||
# define STDC
|
||||
#endif
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some Mac compilers merge all .h files incorrectly: */
|
||||
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
|
||||
# define NO_DUMMY_DECL
|
||||
#endif
|
||||
|
||||
/* Old Borland C incorrectly complains about missing returns: */
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
||||
# define NEED_DUMMY_RETURN
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
# ifndef __32BIT__
|
||||
# define SMALL_MEDIUM
|
||||
# define FAR _far
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Compile with -DZLIB_DLL for Windows DLL support */
|
||||
#if defined(ZLIB_DLL)
|
||||
# if defined(_WINDOWS) || defined(WINDOWS)
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR _cdecl _export
|
||||
# endif
|
||||
# endif
|
||||
# if defined (__BORLANDC__)
|
||||
# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
|
||||
# include <windows.h>
|
||||
# define ZEXPORT __declspec(dllexport) WINAPI
|
||||
# define ZEXPORTRVA __declspec(dllexport) WINAPIV
|
||||
# else
|
||||
# if defined (_Windows) && defined (__DLL__)
|
||||
# define ZEXPORT _export
|
||||
# define ZEXPORTVA _export
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# if defined (ZLIB_DLL)
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# include <unistd.h> /* for SEEK_* and off_t */
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
# pragma map(deflateInit_,"DEIN")
|
||||
# pragma map(deflateInit2_,"DEIN2")
|
||||
# pragma map(deflateEnd,"DEEND")
|
||||
# pragma map(inflateInit_,"ININ")
|
||||
# pragma map(inflateInit2_,"ININ2")
|
||||
# pragma map(inflateEnd,"INEND")
|
||||
# pragma map(inflateSync,"INSY")
|
||||
# pragma map(inflateSetDictionary,"INSEDI")
|
||||
# pragma map(inflate_blocks,"INBL")
|
||||
# pragma map(inflate_blocks_new,"INBLNE")
|
||||
# pragma map(inflate_blocks_free,"INBLFR")
|
||||
# pragma map(inflate_blocks_reset,"INBLRE")
|
||||
# pragma map(inflate_codes_free,"INCOFR")
|
||||
# pragma map(inflate_codes,"INCO")
|
||||
# pragma map(inflate_fast,"INFA")
|
||||
# pragma map(inflate_flush,"INFLU")
|
||||
# pragma map(inflate_mask,"INMA")
|
||||
# pragma map(inflate_set_dictionary,"INSEDI2")
|
||||
# pragma map(ipcomp_inflate_copyright,"INCOPY")
|
||||
# pragma map(inflate_trees_bits,"INTRBI")
|
||||
# pragma map(inflate_trees_dynamic,"INTRDY")
|
||||
# pragma map(inflate_trees_fixed,"INTRFI")
|
||||
# pragma map(inflate_trees_free,"INTRFR")
|
||||
#endif
|
||||
|
||||
#endif /* _ZCONF_H */
|
||||
@@ -1,227 +0,0 @@
|
||||
/* zutil.c -- target dependent utility functions for the compression library
|
||||
* Copyright (C) 1995-2002 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id: zutil.c,v 1.1 2004/03/15 20:35:26 as Exp $ */
|
||||
|
||||
#include <zlib/zutil.h>
|
||||
|
||||
#define MY_ZCALLOC
|
||||
|
||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||
|
||||
#ifndef STDC
|
||||
extern void exit OF((int));
|
||||
#endif
|
||||
|
||||
const char *z_errmsg[10] = {
|
||||
"need dictionary", /* Z_NEED_DICT 2 */
|
||||
"stream end", /* Z_STREAM_END 1 */
|
||||
"", /* Z_OK 0 */
|
||||
"file error", /* Z_ERRNO (-1) */
|
||||
"stream error", /* Z_STREAM_ERROR (-2) */
|
||||
"data error", /* Z_DATA_ERROR (-3) */
|
||||
"insufficient memory", /* Z_MEM_ERROR (-4) */
|
||||
"buffer error", /* Z_BUF_ERROR (-5) */
|
||||
"incompatible version",/* Z_VERSION_ERROR (-6) */
|
||||
""};
|
||||
|
||||
|
||||
const char * ZEXPORT zlibVersion()
|
||||
{
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
# ifndef verbose
|
||||
# define verbose 0
|
||||
# endif
|
||||
int z_verbose = verbose;
|
||||
|
||||
void z_error (m)
|
||||
char *m;
|
||||
{
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(err)
|
||||
int err;
|
||||
{
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void zmemcpy(dest, source, len)
|
||||
Bytef* dest;
|
||||
const Bytef* source;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = *source++; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
|
||||
int zmemcmp(s1, s2, len)
|
||||
const Bytef* s1;
|
||||
const Bytef* s2;
|
||||
uInt len;
|
||||
{
|
||||
uInt j;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zmemzero(dest, len)
|
||||
Bytef* dest;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
*dest++ = 0; /* ??? to be unrolled */
|
||||
} while (--len != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__)
|
||||
/* Small and medium model in Turbo C are for now limited to near allocation
|
||||
* with reduced MAX_WBITS and MAX_MEM_LEVEL
|
||||
*/
|
||||
# define MY_ZCALLOC
|
||||
|
||||
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
|
||||
* and farmalloc(64K) returns a pointer with an offset of 8, so we
|
||||
* must fix the pointer. Warning: the pointer must be put back to its
|
||||
* original form in order to free it, use zcfree().
|
||||
*/
|
||||
|
||||
#define MAX_PTR 10
|
||||
/* 10*64K = 640K */
|
||||
|
||||
local int next_ptr = 0;
|
||||
|
||||
typedef struct ptr_table_s {
|
||||
voidpf org_ptr;
|
||||
voidpf new_ptr;
|
||||
} ptr_table;
|
||||
|
||||
local ptr_table table[MAX_PTR];
|
||||
/* This table is used to remember the original form of pointers
|
||||
* to large buffers (64K). Such pointers are normalized with a zero offset.
|
||||
* Since MSDOS is not a preemptive multitasking OS, this table is not
|
||||
* protected from concurrent access. This hack doesn't work anyway on
|
||||
* a protected system like OS/2. Use Microsoft C instead.
|
||||
*/
|
||||
|
||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
voidpf buf = opaque; /* just to make some compilers happy */
|
||||
ulg bsize = (ulg)items*size;
|
||||
|
||||
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
||||
* will return a usable pointer which doesn't have to be normalized.
|
||||
*/
|
||||
if (bsize < 65520L) {
|
||||
buf = farmalloc(bsize);
|
||||
if (*(ush*)&buf != 0) return buf;
|
||||
} else {
|
||||
buf = farmalloc(bsize + 16L);
|
||||
}
|
||||
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
|
||||
table[next_ptr].org_ptr = buf;
|
||||
|
||||
/* Normalize the pointer to seg:0 */
|
||||
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
|
||||
*(ush*)&buf = 0;
|
||||
table[next_ptr++].new_ptr = buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void zcfree (voidpf opaque, voidpf ptr)
|
||||
{
|
||||
int n;
|
||||
if (*(ush*)&ptr != 0) { /* object < 64K */
|
||||
farfree(ptr);
|
||||
return;
|
||||
}
|
||||
/* Find the original pointer */
|
||||
for (n = 0; n < next_ptr; n++) {
|
||||
if (ptr != table[n].new_ptr) continue;
|
||||
|
||||
farfree(table[n].org_ptr);
|
||||
while (++n < next_ptr) {
|
||||
table[n-1] = table[n];
|
||||
}
|
||||
next_ptr--;
|
||||
return;
|
||||
}
|
||||
ptr = opaque; /* just to make some compilers happy */
|
||||
Assert(0, "zcfree: ptr not found");
|
||||
}
|
||||
#endif
|
||||
#endif /* __TURBOC__ */
|
||||
|
||||
|
||||
#if defined(M_I86) && !defined(__32BIT__)
|
||||
/* Microsoft C in 16-bit mode */
|
||||
|
||||
# define MY_ZCALLOC
|
||||
|
||||
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
|
||||
# define _halloc halloc
|
||||
# define _hfree hfree
|
||||
#endif
|
||||
|
||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
if (opaque) opaque = 0; /* to make compiler happy */
|
||||
return _halloc((long)items, size);
|
||||
}
|
||||
|
||||
void zcfree (voidpf opaque, voidpf ptr)
|
||||
{
|
||||
if (opaque) opaque = 0; /* to make compiler happy */
|
||||
_hfree(ptr);
|
||||
}
|
||||
|
||||
#endif /* MSC */
|
||||
|
||||
|
||||
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
||||
|
||||
#ifndef STDC
|
||||
extern voidp calloc OF((uInt items, uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
voidpf zcalloc (opaque, items, size)
|
||||
voidpf opaque;
|
||||
unsigned items;
|
||||
unsigned size;
|
||||
{
|
||||
if (opaque) items += size - size; /* make compiler happy */
|
||||
return (voidpf)calloc(items, size);
|
||||
}
|
||||
|
||||
void zcfree (opaque, ptr)
|
||||
voidpf opaque;
|
||||
voidpf ptr;
|
||||
{
|
||||
free(ptr);
|
||||
if (opaque) return; /* make compiler happy */
|
||||
}
|
||||
|
||||
#endif /* MY_ZCALLOC */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user