summaryrefslogtreecommitdiff
path: root/src/libfreeswan
diff options
context:
space:
mode:
authorRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:20:09 +0100
committerRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:20:09 +0100
commit568905f488e63e28778f87ac0e38d845f45bae79 (patch)
treed9969a147e36413583ff4bc75542d34c955f8823 /src/libfreeswan
parentf73fba54dc8b30c6482e1e8abf15bbf455592fcd (diff)
downloadvyos-strongswan-568905f488e63e28778f87ac0e38d845f45bae79.tar.gz
vyos-strongswan-568905f488e63e28778f87ac0e38d845f45bae79.zip
Imported Upstream version 4.5.1
Diffstat (limited to 'src/libfreeswan')
-rw-r--r--src/libfreeswan/Makefile.am12
-rw-r--r--src/libfreeswan/Makefile.in40
-rw-r--r--src/libfreeswan/atosa.3217
-rw-r--r--src/libfreeswan/atosa.c198
-rw-r--r--src/libfreeswan/copyright.c12
-rw-r--r--src/libfreeswan/freeswan.h29
-rw-r--r--src/libfreeswan/keyblobtoid.3102
-rw-r--r--src/libfreeswan/keyblobtoid.c146
-rw-r--r--src/libfreeswan/prng.3120
-rw-r--r--src/libfreeswan/prng.c200
-rw-r--r--src/libfreeswan/satoa.c100
11 files changed, 29 insertions, 1147 deletions
diff --git a/src/libfreeswan/Makefile.am b/src/libfreeswan/Makefile.am
index 5fee39da9..09f5fe2cd 100644
--- a/src/libfreeswan/Makefile.am
+++ b/src/libfreeswan/Makefile.am
@@ -1,10 +1,10 @@
noinst_LIBRARIES = libfreeswan.a
libfreeswan_a_SOURCES = addrtoa.c addrtot.c addrtypeof.c anyaddr.c atoaddr.c atoasr.c \
- atosa.c atosubnet.c atoul.c copyright.c datatot.c freeswan.h \
+ atosubnet.c atoul.c copyright.c datatot.c freeswan.h \
goodmask.c initaddr.c initsaid.c initsubnet.c internal.h ipsec_param.h \
- keyblobtoid.c pfkey_v2_build.c pfkey_v2_debug.c \
- pfkey_v2_ext_bits.c pfkey_v2_parse.c portof.c prng.c rangetoa.c \
- pfkey.h pfkeyv2.h rangetosubnet.c sameaddr.c satoa.c \
+ pfkey_v2_build.c pfkey_v2_debug.c \
+ pfkey_v2_ext_bits.c pfkey_v2_parse.c portof.c rangetoa.c \
+ pfkey.h pfkeyv2.h rangetosubnet.c sameaddr.c \
satot.c subnetof.c subnettoa.c subnettot.c \
subnettypeof.c ttoaddr.c ttodata.c ttoprotoport.c ttosa.c ttosubnet.c ttoul.c \
ultoa.c ultot.c
@@ -14,7 +14,7 @@ INCLUDES = \
-I$(top_srcdir)/src/libhydra \
-I$(top_srcdir)/src/pluto
-dist_man3_MANS = anyaddr.3 atoaddr.3 atoasr.3 atosa.3 atoul.3 goodmask.3 initaddr.3 initsubnet.3 \
- keyblobtoid.3 portof.3 prng.3 rangetosubnet.3 sameaddr.3 subnetof.3 \
+dist_man3_MANS = anyaddr.3 atoaddr.3 atoasr.3 atoul.3 goodmask.3 initaddr.3 initsubnet.3 \
+ portof.3 rangetosubnet.3 sameaddr.3 subnetof.3 \
ttoaddr.3 ttodata.3 ttosa.3 ttoul.3
diff --git a/src/libfreeswan/Makefile.in b/src/libfreeswan/Makefile.in
index 28ba035c6..88ceab557 100644
--- a/src/libfreeswan/Makefile.in
+++ b/src/libfreeswan/Makefile.in
@@ -58,19 +58,17 @@ libfreeswan_a_AR = $(AR) $(ARFLAGS)
libfreeswan_a_LIBADD =
am_libfreeswan_a_OBJECTS = addrtoa.$(OBJEXT) addrtot.$(OBJEXT) \
addrtypeof.$(OBJEXT) anyaddr.$(OBJEXT) atoaddr.$(OBJEXT) \
- atoasr.$(OBJEXT) atosa.$(OBJEXT) atosubnet.$(OBJEXT) \
- atoul.$(OBJEXT) copyright.$(OBJEXT) datatot.$(OBJEXT) \
- goodmask.$(OBJEXT) initaddr.$(OBJEXT) initsaid.$(OBJEXT) \
- initsubnet.$(OBJEXT) keyblobtoid.$(OBJEXT) \
+ atoasr.$(OBJEXT) atosubnet.$(OBJEXT) atoul.$(OBJEXT) \
+ copyright.$(OBJEXT) datatot.$(OBJEXT) goodmask.$(OBJEXT) \
+ initaddr.$(OBJEXT) initsaid.$(OBJEXT) initsubnet.$(OBJEXT) \
pfkey_v2_build.$(OBJEXT) pfkey_v2_debug.$(OBJEXT) \
pfkey_v2_ext_bits.$(OBJEXT) pfkey_v2_parse.$(OBJEXT) \
- portof.$(OBJEXT) prng.$(OBJEXT) rangetoa.$(OBJEXT) \
- rangetosubnet.$(OBJEXT) sameaddr.$(OBJEXT) satoa.$(OBJEXT) \
- satot.$(OBJEXT) subnetof.$(OBJEXT) subnettoa.$(OBJEXT) \
- subnettot.$(OBJEXT) subnettypeof.$(OBJEXT) ttoaddr.$(OBJEXT) \
- ttodata.$(OBJEXT) ttoprotoport.$(OBJEXT) ttosa.$(OBJEXT) \
- ttosubnet.$(OBJEXT) ttoul.$(OBJEXT) ultoa.$(OBJEXT) \
- ultot.$(OBJEXT)
+ portof.$(OBJEXT) rangetoa.$(OBJEXT) rangetosubnet.$(OBJEXT) \
+ sameaddr.$(OBJEXT) satot.$(OBJEXT) subnetof.$(OBJEXT) \
+ subnettoa.$(OBJEXT) subnettot.$(OBJEXT) subnettypeof.$(OBJEXT) \
+ ttoaddr.$(OBJEXT) ttodata.$(OBJEXT) ttoprotoport.$(OBJEXT) \
+ ttosa.$(OBJEXT) ttosubnet.$(OBJEXT) ttoul.$(OBJEXT) \
+ ultoa.$(OBJEXT) ultot.$(OBJEXT)
libfreeswan_a_OBJECTS = $(am_libfreeswan_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -234,9 +232,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -275,6 +271,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
@@ -287,11 +285,11 @@ xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
noinst_LIBRARIES = libfreeswan.a
libfreeswan_a_SOURCES = addrtoa.c addrtot.c addrtypeof.c anyaddr.c atoaddr.c atoasr.c \
- atosa.c atosubnet.c atoul.c copyright.c datatot.c freeswan.h \
+ atosubnet.c atoul.c copyright.c datatot.c freeswan.h \
goodmask.c initaddr.c initsaid.c initsubnet.c internal.h ipsec_param.h \
- keyblobtoid.c pfkey_v2_build.c pfkey_v2_debug.c \
- pfkey_v2_ext_bits.c pfkey_v2_parse.c portof.c prng.c rangetoa.c \
- pfkey.h pfkeyv2.h rangetosubnet.c sameaddr.c satoa.c \
+ pfkey_v2_build.c pfkey_v2_debug.c \
+ pfkey_v2_ext_bits.c pfkey_v2_parse.c portof.c rangetoa.c \
+ pfkey.h pfkeyv2.h rangetosubnet.c sameaddr.c \
satot.c subnetof.c subnettoa.c subnettot.c \
subnettypeof.c ttoaddr.c ttodata.c ttoprotoport.c ttosa.c ttosubnet.c ttoul.c \
ultoa.c ultot.c
@@ -301,8 +299,8 @@ INCLUDES = \
-I$(top_srcdir)/src/libhydra \
-I$(top_srcdir)/src/pluto
-dist_man3_MANS = anyaddr.3 atoaddr.3 atoasr.3 atosa.3 atoul.3 goodmask.3 initaddr.3 initsubnet.3 \
- keyblobtoid.3 portof.3 prng.3 rangetosubnet.3 sameaddr.3 subnetof.3 \
+dist_man3_MANS = anyaddr.3 atoaddr.3 atoasr.3 atoul.3 goodmask.3 initaddr.3 initsubnet.3 \
+ portof.3 rangetosubnet.3 sameaddr.3 subnetof.3 \
ttoaddr.3 ttodata.3 ttosa.3 ttoul.3
all: all-am
@@ -359,7 +357,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/anyaddr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoaddr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoasr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atosa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atosubnet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atoul.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copyright.Po@am__quote@
@@ -368,17 +365,14 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initaddr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initsaid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initsubnet.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyblobtoid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfkey_v2_build.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfkey_v2_debug.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfkey_v2_ext_bits.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfkey_v2_parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/portof.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prng.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rangetoa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rangetosubnet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sameaddr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/satoa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/satot.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnetof.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnettoa.Po@am__quote@
diff --git a/src/libfreeswan/atosa.3 b/src/libfreeswan/atosa.3
deleted file mode 100644
index f57fcf1e9..000000000
--- a/src/libfreeswan/atosa.3
+++ /dev/null
@@ -1,217 +0,0 @@
-.TH IPSEC_ATOSA 3 "11 June 2001"
-.SH NAME
-ipsec atosa, satoa \- convert IPsec Security Association IDs to and from ASCII
-.SH SYNOPSIS
-.B "#include <freeswan.h>
-.sp
-.B "const char *atosa(const char *src, size_t srclen,"
-.ti +1c
-.B "struct sa_id *sa);
-.br
-.B "size_t satoa(struct sa_id sa, int format,"
-.ti +1c
-.B "char *dst, size_t dstlen);"
-.sp
-.B "struct sa_id {"
-.ti +1c
-.B "struct in_addr dst;"
-.ti +1c
-.B "ipsec_spi_t spi;"
-.ti +1c
-.B "int proto;"
-.br
-.B "};"
-.SH DESCRIPTION
-These functions are obsolete; see
-.IR ipsec_ttosa (3)
-for their replacements.
-.PP
-.I Atosa
-converts an ASCII Security Association (SA) specifier into an
-.B sa_id
-structure (containing
-a destination-host address
-in network byte order,
-an SPI number in network byte order, and
-a protocol code).
-.I Satoa
-does the reverse conversion, back to an ASCII SA specifier.
-.PP
-An SA is specified in ASCII with a mail-like syntax, e.g.
-.BR esp507@1.2.3.4 .
-An SA specifier contains
-a protocol prefix (currently
-.BR ah ,
-.BR esp ,
-or
-.BR tun ),
-an unsigned integer SPI number,
-and an IP address.
-The SPI number can be decimal or hexadecimal
-(with
-.B 0x
-prefix), as accepted by
-.IR ipsec_atoul (3).
-The IP address can be any form accepted by
-.IR ipsec_atoaddr (3),
-e.g. dotted-decimal address or DNS name.
-.PP
-As a special case, the SA specifier
-.B %passthrough
-signifies the special SA used to indicate that packets should be
-passed through unaltered.
-(At present, this is a synonym for
-.BR tun0x0@0.0.0.0 ,
-but that is subject to change without notice.)
-This form is known to both
-.I atosa
-and
-.IR satoa ,
-so the internal form of
-.B %passthrough
-is never visible.
-.PP
-The
-.B <freeswan.h>
-header file supplies the
-.B sa_id
-structure, as well as a data type
-.B ipsec_spi_t
-which is an unsigned 32-bit integer.
-(There is no consistency between kernel and user on what such a type
-is called, hence the header hides the differences.)
-.PP
-The protocol code uses the same numbers that IP does.
-For user convenience, given the difficulty in acquiring the exact set of
-protocol names used by the kernel,
-.B <freeswan.h>
-defines the names
-.BR SA_ESP ,
-.BR SA_AH ,
-and
-.B SA_IPIP
-to have the same values as the kernel names
-.BR IPPROTO_ESP ,
-.BR IPPROTO_AH ,
-and
-.BR IPPROTO_IPIP .
-.PP
-The
-.I srclen
-parameter of
-.I atosa
-specifies the length of the ASCII string pointed to by
-.IR src ;
-it is an error for there to be anything else
-(e.g., a terminating NUL) within that length.
-As a convenience for cases where an entire NUL-terminated string is
-to be converted,
-a
-.I srclen
-value of
-.B 0
-is taken to mean
-.BR strlen(src) .
-.PP
-The
-.I dstlen
-parameter of
-.I satoa
-specifies the size of the
-.I dst
-parameter;
-under no circumstances are more than
-.I dstlen
-bytes written to
-.IR dst .
-A result which will not fit is truncated.
-.I Dstlen
-can be zero, in which case
-.I dst
-need not be valid and no result is written,
-but the return value is unaffected;
-in all other cases, the (possibly truncated) result is NUL-terminated.
-The
-.I freeswan.h
-header file defines a constant,
-.BR SATOA_BUF ,
-which is the size of a buffer just large enough for worst-case results.
-.PP
-The
-.I format
-parameter of
-.I satoa
-specifies what format is to be used for the conversion.
-The value
-.B 0
-(not the ASCII character
-.BR '0' ,
-but a zero value)
-specifies a reasonable default
-(currently
-lowercase protocol prefix, lowercase hexadecimal SPI, dotted-decimal address).
-The value
-.B d
-causes the SPI to be generated in decimal instead.
-.PP
-.I Atosa
-returns
-.B NULL
-for success and
-a pointer to a string-literal error message for failure;
-see DIAGNOSTICS.
-.I Satoa
-returns
-.B 0
-for a failure, and otherwise
-always returns the size of buffer which would
-be needed to
-accommodate the full conversion result, including terminating NUL;
-it is the caller's responsibility to check this against the size of
-the provided buffer to determine whether truncation has occurred.
-.SH SEE ALSO
-ipsec_atoul(3), ipsec_atoaddr(3), inet(3)
-.SH DIAGNOSTICS
-Fatal errors in
-.I atosa
-are:
-empty input;
-input too small to be a legal SA specifier;
-no
-.B @
-in input;
-unknown protocol prefix;
-conversion error in
-.I atoul
-or
-.IR atoaddr .
-.PP
-Fatal errors in
-.I satoa
-are:
-unknown format; unknown protocol code.
-.SH HISTORY
-Written for the FreeS/WAN project by Henry Spencer.
-.SH BUGS
-The
-.B tun
-protocol code is a FreeS/WANism which may eventually disappear.
-.PP
-The restriction of ASCII-to-binary error reports to literal strings
-(so that callers don't need to worry about freeing them or copying them)
-does limit the precision of error reporting.
-.PP
-The ASCII-to-binary error-reporting convention lends itself
-to slightly obscure code,
-because many readers will not think of NULL as signifying success.
-A good way to make it clearer is to write something like:
-.PP
-.RS
-.nf
-.B "const char *error;"
-.sp
-.B "error = atoaddr( /* ... */ );"
-.B "if (error != NULL) {"
-.B " /* something went wrong */"
-.fi
-.RE
diff --git a/src/libfreeswan/atosa.c b/src/libfreeswan/atosa.c
deleted file mode 100644
index 7339b4c3e..000000000
--- a/src/libfreeswan/atosa.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * convert from ASCII form of SA ID to binary
- * Copyright (C) 1998, 1999 Henry Spencer.
- *
- * 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.
- */
-#include "internal.h"
-#include "freeswan.h"
-
-static struct satype {
- char *prefix;
- size_t prelen; /* strlen(prefix) */
- int proto;
-} satypes[] = {
- { "ah", 2, SA_AH },
- { "esp", 3, SA_ESP },
- { "tun", 3, SA_IPIP },
- { "comp", 4, SA_COMP },
- { NULL, 0, 0, }
-};
-
-/*
- - atosa - convert ASCII "ah507@10.0.0.1" to SA identifier
- */
-const char * /* NULL for success, else string literal */
-atosa(src, srclen, sa)
-const char *src;
-size_t srclen; /* 0 means "apply strlen" */
-struct sa_id *sa;
-{
- const char *at;
- const char *addr;
- const char *spi = NULL;
- struct satype *sat;
- unsigned long ul;
- const char *oops;
-# define MINLEN 5 /* ah0@0 is as short as it can get */
- static char ptname[] = PASSTHROUGHNAME;
-# define PTNLEN (sizeof(ptname)-1) /* -1 for NUL */
-
- if (srclen == 0)
- srclen = strlen(src);
- if (srclen == 0)
- return "empty string";
- if (srclen < MINLEN)
- return "string too short to be SA specifier";
- if (srclen == PTNLEN && memcmp(src, ptname, PTNLEN) == 0) {
- src = PASSTHROUGHIS;
- srclen = strlen(src);
- }
-
- at = memchr(src, '@', srclen);
- if (at == NULL)
- return "no @ in SA specifier";
-
- for (sat = satypes; sat->prefix != NULL; sat++)
- if (sat->prelen < srclen &&
- strncmp(src, sat->prefix, sat->prelen) == 0) {
- sa->proto = sat->proto;
- spi = src + sat->prelen;
- break; /* NOTE BREAK OUT */
- }
- if (sat->prefix == NULL)
- return "SA specifier lacks valid protocol prefix";
-
- if (spi >= at)
- return "no SPI in SA specifier";
- oops = atoul(spi, at - spi, 13, &ul);
- if (oops != NULL)
- return oops;
- sa->spi = htonl(ul);
-
- addr = at + 1;
- oops = atoaddr(addr, srclen - (addr - src), &sa->dst);
- if (oops != NULL)
- return oops;
-
- return NULL;
-}
-
-
-
-#ifdef ATOSA_MAIN
-
-#include <stdio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-void regress(void);
-
-int
-main(int argc, char *argv[])
-{
- struct sa_id sa;
- char buf[100];
- const char *oops;
- size_t n;
-
- if (argc < 2) {
- fprintf(stderr, "Usage: %s {ahnnn@aaa|-r}\n", argv[0]);
- exit(2);
- }
-
- if (strcmp(argv[1], "-r") == 0) {
- regress();
- fprintf(stderr, "regress() returned?!?\n");
- exit(1);
- }
-
- oops = atosa(argv[1], 0, &sa);
- if (oops != NULL) {
- fprintf(stderr, "%s: conversion failed: %s\n", argv[0], oops);
- exit(1);
- }
- n = satoa(sa, 0, buf, sizeof(buf));
- if (n > sizeof(buf)) {
- fprintf(stderr, "%s: reverse conv of `%d'", argv[0], sa.proto);
- fprintf(stderr, "%lu@", (long unsigned int)sa.spi);
- fprintf(stderr, "%s", inet_ntoa(sa.dst));
- fprintf(stderr, " failed: need %ld bytes, have only %ld\n",
- (long)n, (long)sizeof(buf));
- exit(1);
- }
- printf("%s\n", buf);
-
- exit(0);
-}
-
-struct rtab {
- char *input;
- char *output; /* NULL means error expected */
-} rtab[] = {
- {"esp257@1.2.3.0", "esp257@1.2.3.0"},
- {"ah0x20@1.2.3.4", "ah32@1.2.3.4"},
- {"tun011@111.2.3.99", "tun11@111.2.3.99"},
- {"", NULL},
- {"_", NULL},
- {"ah2.2", NULL},
- {"goo2@1.2.3.4", NULL},
- {"esp9@1.2.3.4", "esp9@1.2.3.4"},
- {"espp9@1.2.3.4", NULL},
- {"es9@1.2.3.4", NULL},
- {"ah@1.2.3.4", NULL},
- {"esp7x7@1.2.3.4", NULL},
- {"esp77@1.0x2.3.4", NULL},
- {PASSTHROUGHNAME, PASSTHROUGHNAME},
- {NULL, NULL}
-};
-
-void
-regress(void)
-{
- struct rtab *r;
- int status = 0;
- struct sa_id sa;
- char in[100];
- char buf[100];
- const char *oops;
- size_t n;
-
- for (r = rtab; r->input != NULL; r++) {
- strcpy(in, r->input);
- oops = atosa(in, 0, &sa);
- if (oops != NULL && r->output == NULL)
- {} /* okay, error expected */
- else if (oops != NULL) {
- printf("`%s' atosa failed: %s\n", r->input, oops);
- status = 1;
- } else if (r->output == NULL) {
- printf("`%s' atosa succeeded unexpectedly\n",
- r->input);
- status = 1;
- } else {
- n = satoa(sa, 'd', buf, sizeof(buf));
- if (n > sizeof(buf)) {
- printf("`%s' satoa failed: need %ld\n",
- r->input, (long)n);
- status = 1;
- } else if (strcmp(r->output, buf) != 0) {
- printf("`%s' gave `%s', expected `%s'\n",
- r->input, buf, r->output);
- status = 1;
- }
- }
- }
- exit(status);
-}
-
-#endif /* ATOSA_MAIN */
diff --git a/src/libfreeswan/copyright.c b/src/libfreeswan/copyright.c
index 65585b62e..e55e849f7 100644
--- a/src/libfreeswan/copyright.c
+++ b/src/libfreeswan/copyright.c
@@ -27,13 +27,13 @@ static const char *co[] = {
" Christoph Gysin, Andreas Hess, Patric Lichtsteiner, Michael Meier,",
" Andreas Schleiss, Ariane Seiler, Mario Strasser, Lukas Suter,",
" Roger Wegmann, Simon Zwahlen,",
- " Zuercher Hochschule Winterthur (Switzerland).",
+ " ZHW Zuercher Hochschule Winterthur (Switzerland).",
"",
- " Philip Boetschi, Tobias Brunner, Adrian Doerig, Andreas Eigenmann,",
- " Fabian Hartmann, Noah Heusser, Jan Hutter, Thomas Kallenberg,",
- " Daniel Roethlisberger, Joel Stillhart, Martin Willi, Daniel Wydler,",
- " Andreas Steffen,",
- " Hochschule fuer Technik Rapperswil (Switzerland).",
+ " Philip Boetschi, Tobias Brunner, Sansar Choinyambuu, Adrian Doerig,",
+ " Andreas Eigenmann, Fabian Hartmann, Noah Heusser, Jan Hutter,",
+ " Thomas Kallenberg, Daniel Roethlisberger, Joel Stillhart, Martin Willi,",
+ " Daniel Wydler, Andreas Steffen,",
+ " HSR Hochschule fuer Technik Rapperswil (Switzerland).",
"",
"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",
diff --git a/src/libfreeswan/freeswan.h b/src/libfreeswan/freeswan.h
index 342f59987..724165bde 100644
--- a/src/libfreeswan/freeswan.h
+++ b/src/libfreeswan/freeswan.h
@@ -158,11 +158,6 @@ err_t ttodatav(const char *src, size_t srclen, int base,
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,
bool *has_port_wildcard);
@@ -206,12 +201,6 @@ 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_copyright_notice(void);
@@ -294,24 +283,6 @@ rangetoa(
);
#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(
diff --git a/src/libfreeswan/keyblobtoid.3 b/src/libfreeswan/keyblobtoid.3
deleted file mode 100644
index 8b5bfb0a2..000000000
--- a/src/libfreeswan/keyblobtoid.3
+++ /dev/null
@@ -1,102 +0,0 @@
-.TH IPSEC_KEYBLOBTOID 3 "25 March 2002"
-.SH NAME
-ipsec keyblobtoid, splitkeytoid \- generate key IDs from RSA keys
-.SH SYNOPSIS
-.B "#include <freeswan.h>
-.sp
-.B "size_t keyblobtoid(const unsigned char *blob,"
-.ti +1c
-.B "size_t bloblen, char *dst, size_t dstlen);"
-.br
-.B "size_t splitkeytoid(const unsigned char *e, size_t elen,"
-.ti +1c
-.B "const unsigned char *m, size_t mlen, char *dst,
-.ti +1c
-.B "size_t dstlen);"
-.SH DESCRIPTION
-.I Keyblobtoid
-and
-.I splitkeytoid
-generate
-key IDs
-from RSA keys,
-for use in messages and reporting,
-writing the result to
-.IR dst .
-A
-.I key ID
-is a short ASCII string identifying a key;
-currently it is just the first nine characters of the base64
-encoding of the RFC 2537/3110 ``byte blob'' representation of the key.
-(Beware that no finite key ID can be collision-proof:
-there is always some small chance of two random keys having the
-same ID.)
-.PP
-.I Keyblobtoid
-generates a key ID from a key which is already in the form of an
-RFC 2537/3110 binary key
-.I blob
-(encoded exponent length, exponent, modulus).
-.PP
-.I Splitkeytoid
-generates a key ID from a key given in the form of a separate
-(binary) exponent
-.I e
-and modulus
-.IR m .
-.PP
-The
-.I dstlen
-parameter of either
-specifies the size of the
-.I dst
-parameter;
-under no circumstances are more than
-.I dstlen
-bytes written to
-.IR dst .
-A result which will not fit is truncated.
-.I Dstlen
-can be zero, in which case
-.I dst
-need not be valid and no result is written,
-but the return value is unaffected;
-in all other cases, the (possibly truncated) result is NUL-terminated.
-The
-.I freeswan.h
-header file defines a constant
-.B KEYID_BUF
-which is the size of a buffer large enough for worst-case results.
-.PP
-Both functions return
-.B 0
-for a failure, and otherwise
-always return the size of buffer which would
-be needed to
-accommodate the full conversion result, including terminating NUL;
-it is the caller's responsibility to check this against the size of
-the provided buffer to determine whether truncation has occurred.
-.P
-With keys generated by
-.IR ipsec_rsasigkey (3),
-the first two base64 digits are always the same,
-and the third carries only about one bit of information.
-It's worse with keys using longer fixed exponents,
-e.g. the 24-bit exponent that's common in X.509 certificates.
-However, being able to relate key IDs to the full
-base64 text form of keys by eye is sufficiently useful that this
-waste of space seems justifiable.
-The choice of nine digits is a compromise between bulk and
-probability of collision.
-.SH SEE ALSO
-RFC 3110,
-\fIRSA/SHA-1 SIGs and RSA KEYs in the Domain Name System (DNS)\fR,
-Eastlake, 2001
-(superseding the older but better-known RFC 2537).
-.SH DIAGNOSTICS
-Fatal errors are:
-key too short to supply enough bits to construct a complete key ID
-(almost certainly indicating a garbage key);
-exponent too long for its length to be representable.
-.SH HISTORY
-Written for the FreeS/WAN project by Henry Spencer.
diff --git a/src/libfreeswan/keyblobtoid.c b/src/libfreeswan/keyblobtoid.c
deleted file mode 100644
index 89ab5fced..000000000
--- a/src/libfreeswan/keyblobtoid.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * generate printable key IDs
- * Copyright (C) 2002 Henry Spencer.
- *
- * 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.
- */
-#include "internal.h"
-#include "freeswan.h"
-
-/*
- - keyblobtoid - generate a printable key ID from an RFC 2537/3110 key blob
- * Current algorithm is just to use first nine base64 digits.
- */
-size_t
-keyblobtoid(src, srclen, dst, dstlen)
-const unsigned char *src;
-size_t srclen;
-char *dst; /* need not be valid if dstlen is 0 */
-size_t dstlen;
-{
- char buf[KEYID_BUF];
- size_t ret;
-# define NDIG 9
-
- if (srclen < (NDIG*6 + 7)/8) {
- strcpy(buf, "?len= ?");
- buf[5] = '0' + srclen;
- ret = 0;
- } else {
- (void) datatot(src, srclen, 64, buf, NDIG+1);
- ret = NDIG+1;
- }
-
- if (dstlen > 0) {
- if (strlen(buf)+1 > dstlen)
- *(buf + dstlen - 1) = '\0';
- strcpy(dst, buf);
- }
- return ret;
-}
-
-/*
- - splitkeytoid - generate a printable key ID from exponent/modulus pair
- * Just constructs the beginnings of a key blob and calls keyblobtoid().
- */
-size_t
-splitkeytoid(e, elen, m, mlen, dst, dstlen)
-const unsigned char *e;
-size_t elen;
-const unsigned char *m;
-size_t mlen;
-char *dst; /* need not be valid if dstlen is 0 */
-size_t dstlen;
-{
- unsigned char buf[KEYID_BUF]; /* ample room */
- unsigned char *bufend = buf + sizeof(buf);
- unsigned char *p;
- size_t n;
-
- p = buf;
- if (elen <= 255)
- *p++ = elen;
- else if ((elen &~ 0xffff) == 0) {
- *p++ = 0;
- *p++ = (elen>>8) & 0xff;
- *p++ = elen & 0xff;
- } else
- return 0; /* unrepresentable exponent length */
-
- n = bufend - p;
- if (elen < n)
- n = elen;
- memcpy(p, e, n);
- p += n;
-
- n = bufend - p;
- if (n > 0) {
- if (mlen < n)
- n = mlen;
- memcpy(p, m, n);
- p += n;
- }
-
- return keyblobtoid(buf, p - buf, dst, dstlen);
-}
-
-
-
-#ifdef KEYBLOBTOID_MAIN
-
-#include <stdio.h>
-
-void regress();
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- typedef unsigned char uc;
- uc hexblob[] = "\x01\x03\x85\xf2\xd6\x76\x9b\x03\x59\xb6\x21\x52";
- uc hexe[] = "\x03";
- uc hexm[] = "\x85\xf2\xd6\x76\x9b\x03\x59\xb6\x21\x52\xef\x85";
- char b64nine[] = "AQOF8tZ2m";
- char b64six[] = "AQOF8t";
- char buf[100];
- size_t n;
- char *b = b64nine;
- size_t bl = strlen(b) + 1;
- int st = 0;
-
- n = keyblobtoid(hexblob, strlen(hexblob), buf, sizeof(buf));
- if (n != bl) {
- fprintf(stderr, "%s: keyblobtoid returned %d not %d\n",
- argv[0], n, bl);
- st = 1;
- }
- if (strcmp(buf, b) != 0) {
- fprintf(stderr, "%s: keyblobtoid generated `%s' not `%s'\n",
- argv[0], buf, b);
- st = 1;
- }
- n = splitkeytoid(hexe, strlen(hexe), hexm, strlen(hexm), buf,
- sizeof(buf));
- if (n != bl) {
- fprintf(stderr, "%s: splitkeytoid returned %d not %d\n",
- argv[0], n, bl);
- st = 1;
- }
- if (strcmp(buf, b) != 0) {
- fprintf(stderr, "%s: splitkeytoid generated `%s' not `%s'\n",
- argv[0], buf, b);
- st = 1;
- }
- exit(st);
-}
-
-#endif /* KEYBLOBTOID_MAIN */
diff --git a/src/libfreeswan/prng.3 b/src/libfreeswan/prng.3
deleted file mode 100644
index 48c6ceed0..000000000
--- a/src/libfreeswan/prng.3
+++ /dev/null
@@ -1,120 +0,0 @@
-.TH IPSEC_PRNG 3 "1 April 2002"
-.SH NAME
-ipsec prng_init \- initialize IPsec pseudorandom-number generator
-.br
-ipsec prng_bytes \- get bytes from IPsec pseudorandom-number generator
-.br
-ipsec prng_final \- close down IPsec pseudorandom-number generator
-.SH SYNOPSIS
-.B "#include <freeswan.h>
-.sp
-.B "void prng_init(struct prng *prng,"
-.ti +1c
-.B "const unsigned char *key, size_t keylen);"
-.br
-.B "void prng_bytes(struct prng *prng, char *dst,"
-.ti +1c
-.B "size_t dstlen);"
-.br
-.B "unsigned long prng_count(struct prng *prng);"
-.br
-.B "void prng_final(struct prng *prng);"
-.SH DESCRIPTION
-.I Prng_init
-initializes a crypto-quality pseudo-random-number generator from a key;
-.I prng_bytes
-obtains pseudo-random bytes from it;
-.I prng_count
-reports the number of bytes extracted from it to date;
-.I prng_final
-closes it down.
-It is the user's responsibility to initialize a PRNG before using it,
-and not to use it again after it is closed down.
-.PP
-.I Prng_init
-initializes,
-or re-initializes,
-the specified
-.I prng
-from the
-.IR key ,
-whose length is given by
-.IR keylen .
-The user must allocate the
-.B "struct prng"
-pointed to by
-.IR prng .
-There is no particular constraint on the length of the key,
-although a key longer than 256 bytes is unnecessary because
-only the first 256 would be used.
-Initialization requires on the order of 3000 integer operations,
-independent of key length.
-.PP
-.I Prng_bytes
-obtains
-.I dstlen
-pseudo-random bytes from the PRNG and puts them in
-.IR buf .
-This is quite fast,
-on the order of 10 integer operations per byte.
-.PP
-.I Prng_count
-reports the number of bytes obtained from the PRNG
-since it was (last) initialized.
-.PP
-.I Prng_final
-closes down a PRNG by
-zeroing its internal memory,
-obliterating all trace of the state used to generate its previous output.
-This requires on the order of 250 integer operations.
-.PP
-The
-.B <freeswan.h>
-header file supplies the definition of the
-.B prng
-structure.
-Examination of its innards is discouraged, as they may change.
-.PP
-The PRNG algorithm
-used by these functions is currently identical to that of RC4(TM).
-This algorithm is cryptographically strong,
-sufficiently unpredictable that even a hostile observer will
-have difficulty determining the next byte of output from past history,
-provided it is initialized from a reasonably large key composed of
-highly random bytes (see
-.IR random (4)).
-The usual run of software pseudo-random-number generators
-(e.g.
-.IR random (3))
-are
-.I not
-cryptographically strong.
-.PP
-The well-known attacks against RC4(TM),
-e.g. as found in 802.11b's WEP encryption system,
-apply only if multiple PRNGs are initialized with closely-related keys
-(e.g., using a counter appended to a base key).
-If such keys are used, the first few hundred pseudo-random bytes
-from each PRNG should be discarded,
-to give the PRNGs a chance to randomize their innards properly.
-No useful attacks are known if the key is well randomized to begin with.
-.SH SEE ALSO
-random(3), random(4)
-.br
-Bruce Schneier,
-\fIApplied Cryptography\fR, 2nd ed., 1996, ISBN 0-471-11709-9,
-pp. 397-8.
-.SH HISTORY
-Written for the FreeS/WAN project by Henry Spencer.
-.SH BUGS
-If an attempt is made to obtain more than 4e9 bytes
-between initializations,
-the PRNG will continue to work but
-.IR prng_count 's
-output will stick at
-.BR 4000000000 .
-Fixing this would require a longer integer type and does
-not seem worth the trouble,
-since you should probably re-initialize before then anyway...
-.PP
-``RC4'' is a trademark of RSA Data Security, Inc.
diff --git a/src/libfreeswan/prng.c b/src/libfreeswan/prng.c
deleted file mode 100644
index 347f13f89..000000000
--- a/src/libfreeswan/prng.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * crypto-class pseudorandom number generator
- * currently uses same algorithm as RC4(TM), from Schneier 2nd ed p397
- * Copyright (C) 2002 Henry Spencer.
- *
- * 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.
- */
-#include "internal.h"
-#include "freeswan.h"
-
-/*
- - prng_init - initialize PRNG from a key
- */
-void
-prng_init(prng, key, keylen)
-struct prng *prng;
-const unsigned char *key;
-size_t keylen;
-{
- unsigned char k[256];
- int i, j;
- unsigned const char *p;
- unsigned const char *keyend = key + keylen;
- unsigned char t;
-
- for (i = 0; i <= 255; i++)
- prng->sbox[i] = i;
- p = key;
- for (i = 0; i <= 255; i++) {
- k[i] = *p++;
- if (p >= keyend)
- p = key;
- }
- j = 0;
- for (i = 0; i <= 255; i++) {
- j = (j + prng->sbox[i] + k[i]) & 0xff;
- t = prng->sbox[i];
- prng->sbox[i] = prng->sbox[j];
- prng->sbox[j] = t;
- k[i] = 0; /* clear out key memory */
- }
- prng->i = 0;
- prng->j = 0;
- prng->count = 0;
-}
-
-/*
- - prng_bytes - get some pseudorandom bytes from PRNG
- */
-void
-prng_bytes(prng, dst, dstlen)
-struct prng *prng;
-unsigned char *dst;
-size_t dstlen;
-{
- int i, j, t;
- unsigned char *p = dst;
- size_t remain = dstlen;
-# define MAX 4000000000ul
-
- while (remain > 0) {
- i = (prng->i + 1) & 0xff;
- prng->i = i;
- j = (prng->j + prng->sbox[i]) & 0xff;
- prng->j = j;
- t = prng->sbox[i];
- prng->sbox[i] = prng->sbox[j];
- prng->sbox[j] = t;
- t = (t + prng->sbox[i]) & 0xff;
- *p++ = prng->sbox[t];
- remain--;
- }
- if (prng->count < MAX - dstlen)
- prng->count += dstlen;
- else
- prng->count = MAX;
-}
-
-/*
- - prnt_count - how many bytes have been extracted from PRNG so far?
- */
-unsigned long
-prng_count(prng)
-struct prng *prng;
-{
- return prng->count;
-}
-
-/*
- - prng_final - clear out PRNG to ensure nothing left in memory
- */
-void
-prng_final(prng)
-struct prng *prng;
-{
- int i;
-
- for (i = 0; i <= 255; i++)
- prng->sbox[i] = 0;
- prng->i = 0;
- prng->j = 0;
- prng->count = 0; /* just for good measure */
-}
-
-
-
-#ifdef PRNG_MAIN
-
-#include <stdio.h>
-
-void regress();
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- struct prng pr;
- unsigned char buf[100];
- unsigned char *p;
- size_t n;
-
- if (argc < 2) {
- fprintf(stderr, "Usage: %s {key|-r}\n", argv[0]);
- exit(2);
- }
-
- if (strcmp(argv[1], "-r") == 0) {
- regress();
- fprintf(stderr, "regress() returned?!?\n");
- exit(1);
- }
-
- prng_init(&pr, argv[1], strlen(argv[1]));
- prng_bytes(&pr, buf, 32);
- printf("0x");
- for (p = buf, n = 32; n > 0; p++, n--)
- printf("%02x", *p);
- printf("\n%lu bytes\n", prng_count(&pr));
- prng_final(&pr);
- exit(0);
-}
-
-void
-regress()
-{
- struct prng pr;
- unsigned char buf[100];
- unsigned char *p;
- size_t n;
- /* somewhat non-random sample key */
- unsigned char key[] = "here we go gathering nuts in May";
- /* first thirty bytes of output from that key */
- unsigned char good[] = "\x3f\x02\x8e\x4a\x2a\xea\x23\x18\x92\x7c"
- "\x09\x52\x83\x61\xaa\x26\xce\xbb\x9d\x71"
- "\x71\xe5\x10\x22\xaf\x60\x54\x8d\x5b\x28";
- int nzero, none;
- int show = 0;
-
- prng_init(&pr, key, strlen(key));
- prng_bytes(&pr, buf, sizeof(buf));
- for (p = buf, n = sizeof(buf); n > 0; p++, n--) {
- if (*p == 0)
- nzero++;
- if (*p == 255)
- none++;
- }
- if (nzero > 3 || none > 3) {
- fprintf(stderr, "suspiciously non-random output!\n");
- show = 1;
- }
- if (memcmp(buf, good, strlen(good)) != 0) {
- fprintf(stderr, "incorrect output!\n");
- show = 1;
- }
- if (show) {
- fprintf(stderr, "0x");
- for (p = buf, n = sizeof(buf); n > 0; p++, n--)
- fprintf(stderr, "%02x", *p);
- fprintf(stderr, "\n");
- exit(1);
- }
- if (prng_count(&pr) != sizeof(buf)) {
- fprintf(stderr, "got %u bytes, but count is %lu\n",
- sizeof(buf), prng_count(&pr));
- exit(1);
- }
- prng_final(&pr);
- exit(0);
-}
-
-#endif /* PRNG_MAIN */
diff --git a/src/libfreeswan/satoa.c b/src/libfreeswan/satoa.c
deleted file mode 100644
index 09a152727..000000000
--- a/src/libfreeswan/satoa.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * convert from binary form of SA ID to ASCII
- * Copyright (C) 1998, 1999, 2001 Henry Spencer.
- *
- * 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.
- */
-#include "internal.h"
-#include "freeswan.h"
-
-static struct typename {
- char type;
- char *name;
-} typenames[] = {
- { SA_AH, "ah" },
- { SA_ESP, "esp" },
- { SA_IPIP, "tun" },
- { SA_COMP, "comp" },
- { SA_INT, "int" },
- { 0, NULL }
-};
-
-/*
- - satoa - convert SA to ASCII "ah507@1.2.3.4"
- */
-size_t /* space needed for full conversion */
-satoa(sa, format, dst, dstlen)
-struct sa_id sa;
-int format; /* character */
-char *dst; /* need not be valid if dstlen is 0 */
-size_t dstlen;
-{
- size_t len = 0; /* 0 means not handled yet */
- int base;
- struct typename *tn;
- char buf[30+ADDRTOA_BUF];
-
- switch (format) {
- case 0:
- base = 16; /* temporarily at least */
- break;
- case 'd':
- base = 10;
- break;
- default:
- return 0;
- break;
- }
-
- for (tn = typenames; tn->name != NULL; tn++)
- if (sa.proto == tn->type)
- break;
- if (tn->name == NULL)
- return 0;
-
- if (strcmp(tn->name, PASSTHROUGHTYPE) == 0 &&
- sa.spi == PASSTHROUGHSPI &&
- sa.dst.s_addr == PASSTHROUGHDST) {
- strcpy(buf, PASSTHROUGHNAME);
- len = strlen(buf);
- } else if (sa.proto == SA_INT && sa.dst.s_addr == 0) {
- char *p;
-
- switch (ntohl(sa.spi)) {
- case SPI_PASS: p = "%pass"; break;
- case SPI_DROP: p = "%drop"; break;
- case SPI_REJECT: p = "%reject"; break;
- case SPI_HOLD: p = "%hold"; break;
- case SPI_TRAP: p = "%trap"; break;
- case SPI_TRAPSUBNET: p = "%trapsubnet"; break;
- default: p = NULL; break;
- }
- if (p != NULL) {
- strcpy(buf, p);
- len = strlen(buf);
- }
- }
-
- if (len == 0) {
- strcpy(buf, tn->name);
- len = strlen(buf);
- len += ultoa(ntohl(sa.spi), base, buf+len, sizeof(buf)-len);
- *(buf+len-1) = '@';
- len += addrtoa(sa.dst, 0, buf+len, sizeof(buf)-len);
- }
-
- if (dst != NULL) {
- if (len > dstlen)
- *(buf+dstlen-1) = '\0';
- strcpy(dst, buf);
- }
- return len;
-}