summaryrefslogtreecommitdiff
path: root/src/libstrongswan
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2008-02-07 13:56:17 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2008-02-07 13:56:17 +0000
commitbcc8f7ca7fd8e8ff6e8a4d579251458313133598 (patch)
treea86b42b486c954937b32ffeaaa725804cb1458ec /src/libstrongswan
parent49104abddf3d71d5abf5cf75dc7f95fa6c55fa63 (diff)
downloadvyos-strongswan-bcc8f7ca7fd8e8ff6e8a4d579251458313133598.tar.gz
vyos-strongswan-bcc8f7ca7fd8e8ff6e8a4d579251458313133598.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.1.10)
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/crypto/ac.c8
-rw-r--r--src/libstrongswan/crypto/ca.c6
-rwxr-xr-xsrc/libstrongswan/crypto/crl.c6
-rwxr-xr-xsrc/libstrongswan/crypto/x509.c8
-rw-r--r--src/libstrongswan/library.c19
-rw-r--r--src/libstrongswan/printf_hook.c23
-rw-r--r--src/libstrongswan/printf_hook.h3
-rw-r--r--src/libstrongswan/utils/lexparser.c32
-rw-r--r--src/libstrongswan/utils/lexparser.h9
9 files changed, 92 insertions, 22 deletions
diff --git a/src/libstrongswan/crypto/ac.c b/src/libstrongswan/crypto/ac.c
index 1367494f8..641ce5d64 100644
--- a/src/libstrongswan/crypto/ac.c
+++ b/src/libstrongswan/crypto/ac.c
@@ -20,7 +20,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * RCSID $Id: ac.c 3300 2007-10-12 21:53:18Z andreas $
+ * RCSID $Id: ac.c 3355 2007-11-20 12:06:40Z martin $
*/
#include <string.h>
@@ -544,7 +544,7 @@ static void list(const private_x509ac_t *this, FILE *out, bool utc)
fprintf(out, " validity: not before %#T, ", &this->notBefore, utc);
if (now < this->notBefore)
{
- fprintf(out, "not valid yet (valid in %V)\n", &now, &this->notBefore);
+ fprintf(out, "not valid yet (valid in %#V)\n", &now, &this->notBefore);
}
else
{
@@ -554,14 +554,14 @@ static void list(const private_x509ac_t *this, FILE *out, bool utc)
fprintf(out, " not after %#T, ", &this->notAfter, utc);
if (now > this->notAfter)
{
- fprintf(out, "expired (%V ago)\n", &now, &this->notAfter);
+ fprintf(out, "expired (%#V ago)\n", &now, &this->notAfter);
}
else
{
fprintf(out, "ok");
if (now > this->notAfter - ACERT_WARNING_INTERVAL * 60 * 60 * 24)
{
- fprintf(out, " (expires in %V)", &now, &this->notAfter);
+ fprintf(out, " (expires in %#V)", &now, &this->notAfter);
}
fprintf(out, " \n");
}
diff --git a/src/libstrongswan/crypto/ca.c b/src/libstrongswan/crypto/ca.c
index a78590954..510e3528e 100644
--- a/src/libstrongswan/crypto/ca.c
+++ b/src/libstrongswan/crypto/ca.c
@@ -279,11 +279,11 @@ static void list_certinfos(private_ca_info_t *this, FILE *out, bool utc)
fprintf(out, "%#T, until %#T, ", &thisUpdate, utc, &nextUpdate, utc);
if (now > nextUpdate)
{
- fprintf(out, "expired (%V ago)\n", &now, &nextUpdate);
+ fprintf(out, "expired (%#V ago)\n", &now, &nextUpdate);
}
else
{
- fprintf(out, "ok (expires in %V)\n", &now, &nextUpdate);
+ fprintf(out, "ok (expires in %#V)\n", &now, &nextUpdate);
}
fprintf(out, " serial: %#B, %N\n", &serial,
cert_status_names, certinfo->get_status(certinfo));
@@ -654,7 +654,7 @@ static cert_status_t verify_by_ocsp(private_ca_info_t* this,
if (comparison > 0)
{
- iterator->insert_after(iterator, (void *)cached_certinfo);
+ this->certinfos->insert_last(this->certinfos, (void *)cached_certinfo);
}
else
{
diff --git a/src/libstrongswan/crypto/crl.c b/src/libstrongswan/crypto/crl.c
index d52078ea9..ab23bb9ec 100755
--- a/src/libstrongswan/crypto/crl.c
+++ b/src/libstrongswan/crypto/crl.c
@@ -19,7 +19,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * RCSID $Id: crl.c 3300 2007-10-12 21:53:18Z andreas $
+ * RCSID $Id: crl.c 3355 2007-11-20 12:06:40Z martin $
*/
#include <sys/stat.h>
@@ -463,11 +463,11 @@ static void list(private_crl_t *this, FILE* out, bool utc)
}
else if (now > this->nextUpdate)
{
- fprintf(out, "expired (%V ago)\n", &now, &this->nextUpdate);
+ fprintf(out, "expired (%#V ago)\n", &now, &this->nextUpdate);
}
else if (now > this->nextUpdate - CRL_WARNING_INTERVAL * 60 * 60 * 24)
{
- fprintf(out, "ok (expires in %V)\n", &now, &this->nextUpdate);
+ fprintf(out, "ok (expires in %#V)\n", &now, &this->nextUpdate);
}
else
{
diff --git a/src/libstrongswan/crypto/x509.c b/src/libstrongswan/crypto/x509.c
index d9093fc62..6f154b36f 100755
--- a/src/libstrongswan/crypto/x509.c
+++ b/src/libstrongswan/crypto/x509.c
@@ -24,7 +24,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * RCSID $Id: x509.c 3301 2007-10-12 21:56:30Z andreas $
+ * RCSID $Id: x509.c 3355 2007-11-20 12:06:40Z martin $
*/
#include <gmp.h>
@@ -1182,7 +1182,7 @@ static void list(private_x509_t *this, FILE *out, bool utc)
fprintf(out, " validity: not before %#T, ", &this->notBefore, utc);
if (now < this->notBefore)
{
- fprintf(out, "not valid yet (valid in %V)\n", &now, &this->notBefore);
+ fprintf(out, "not valid yet (valid in %#V)\n", &now, &this->notBefore);
}
else
{
@@ -1192,14 +1192,14 @@ static void list(private_x509_t *this, FILE *out, bool utc)
fprintf(out, " not after %#T, ", &this->notAfter, utc);
if (now > this->notAfter)
{
- fprintf(out, "expired (%V ago)\n", &now, &this->notAfter);
+ fprintf(out, "expired (%#V ago)\n", &now, &this->notAfter);
}
else
{
fprintf(out, "ok");
if (now > this->notAfter - CERT_WARNING_INTERVAL * 60 * 60 * 24)
{
- fprintf(out, " (expires in %V)", &now, &this->notAfter);
+ fprintf(out, " (expires in %#V)", &now, &this->notAfter);
}
fprintf(out, " \n");
}
diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c
index 9f96d119c..f66818bc2 100644
--- a/src/libstrongswan/library.c
+++ b/src/libstrongswan/library.c
@@ -150,11 +150,20 @@ static int print_time(FILE *stream, const struct printf_info *info,
static int print_time_delta(FILE *stream, const struct printf_info *info,
const void *const *args)
{
- time_t *start = *((time_t**)(args[0]));
- time_t *end = *((time_t**)(args[1]));
- u_int delta = abs(*end - *start);
-
char* unit = "second";
+ time_t *arg1, *arg2;
+ time_t delta;
+
+ arg1 = *((time_t**)(args[0]));
+ if (info->alt)
+ {
+ arg2 = *((time_t**)(args[1]));
+ delta = abs(*arg1 - *arg2);
+ }
+ else
+ {
+ delta = *arg1;
+ }
if (delta > 2 * 60 * 60 * 24)
{
@@ -180,5 +189,5 @@ static int print_time_delta(FILE *stream, const struct printf_info *info,
static void __attribute__ ((constructor))print_register()
{
register_printf_function(PRINTF_TIME, print_time, arginfo_ptr_alt_ptr_int);
- register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_ptr_ptr);
+ register_printf_function(PRINTF_TIME_DELTA, print_time_delta, arginfo_ptr_alt_ptr_ptr);
}
diff --git a/src/libstrongswan/printf_hook.c b/src/libstrongswan/printf_hook.c
index 0407e8c82..baf339640 100644
--- a/src/libstrongswan/printf_hook.c
+++ b/src/libstrongswan/printf_hook.c
@@ -116,3 +116,26 @@ int arginfo_ptr_alt_ptr_int(const struct printf_info *info, size_t n, int *argty
}
return 1;
}
+
+/**
+ * special arginfo handler respecting alt flag
+ */
+int arginfo_ptr_alt_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes)
+{
+ if (info->alt)
+ {
+ if (n > 1)
+ {
+ argtypes[0] = PA_POINTER;
+ argtypes[1] = PA_POINTER;
+ }
+ return 2;
+ }
+
+ if (n > 0)
+ {
+ argtypes[0] = PA_POINTER;
+ }
+ return 1;
+}
+
diff --git a/src/libstrongswan/printf_hook.h b/src/libstrongswan/printf_hook.h
index 03bcf447d..77b228da0 100644
--- a/src/libstrongswan/printf_hook.h
+++ b/src/libstrongswan/printf_hook.h
@@ -44,7 +44,7 @@
#define PRINTF_TRAFFIC_SELECTOR 'R'
/** 1 argument: time_t *time; with #-modifier 2 arguments: time_t *time, bool utc */
#define PRINTF_TIME 'T'
-/** 2 arguments: time_t *begin, time_t *end */
+/** 1 argument: time_t *delta; with #-modifier 2 arguments: time_t *begin, time_t *end */
#define PRINTF_TIME_DELTA 'V'
/**
@@ -55,6 +55,7 @@ int arginfo_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes);
int arginfo_ptr_int(const struct printf_info *info, size_t n, int *argtypes);
int arginfo_int_int(const struct printf_info *info, size_t n, int *argtypes);
int arginfo_ptr_alt_ptr_int(const struct printf_info *info, size_t n, int *argtypes);
+int arginfo_ptr_alt_ptr_ptr(const struct printf_info *info, size_t n, int *argtypes);
int arginfo_int_alt_int_int(const struct printf_info *info, size_t n, int *argtypes);
#endif /* PRINTF_HOOK_H_ */
diff --git a/src/libstrongswan/utils/lexparser.c b/src/libstrongswan/utils/lexparser.c
index 9d3f06593..7cc89fc90 100644
--- a/src/libstrongswan/utils/lexparser.c
+++ b/src/libstrongswan/utils/lexparser.c
@@ -17,8 +17,12 @@
* 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: lexparser.c 3353 2007-11-19 12:27:08Z martin $
*/
+/* memrchr is a GNU extension */
+#define _GNU_SOURCE
#include <string.h>
#include "lexparser.h"
@@ -45,7 +49,7 @@ bool match(const char *pattern, const chunk_t *ch)
}
/**
- * extracts a token ending with a given termination symbol
+ * extracts a token ending with the first occurrence of a given termination symbol
*/
bool extract_token(chunk_t *token, const char termination, chunk_t *src)
{
@@ -71,6 +75,32 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src)
}
/**
+ * extracts a token ending with the last occurrence of a given termination symbol
+ */
+bool extract_last_token(chunk_t *token, const char termination, chunk_t *src)
+{
+ u_char *eot = memrchr(src->ptr, termination, src->len);
+
+ /* initialize empty token */
+ *token = chunk_empty;
+
+ if (eot == NULL) /* termination symbol not found */
+ {
+ return FALSE;
+ }
+
+ /* extract token */
+ token->ptr = src->ptr;
+ token->len = (u_int)(eot - src->ptr);
+
+ /* advance src pointer after termination symbol */
+ src->ptr = eot + 1;
+ src->len -= (token->len + 1);
+
+ return TRUE;
+}
+
+/**
* fetches a new line terminated by \n or \r\n
*/
bool fetchline(chunk_t *src, chunk_t *line)
diff --git a/src/libstrongswan/utils/lexparser.h b/src/libstrongswan/utils/lexparser.h
index e3c2c4c70..775898139 100644
--- a/src/libstrongswan/utils/lexparser.h
+++ b/src/libstrongswan/utils/lexparser.h
@@ -17,6 +17,8 @@
* 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: lexparser.h 3346 2007-11-16 20:23:29Z andreas $
*/
#include <library.h>
@@ -32,11 +34,16 @@ bool eat_whitespace(chunk_t *src);
bool match(const char *pattern, const chunk_t *ch);
/**
- * @brief Extracts a token ending with a given termination symbol
+ * @brief Extracts a token ending with the first occurence a given termination symbol
*/
bool extract_token(chunk_t *token, const char termination, chunk_t *src);
/**
+ * @brief Extracts a token ending with the last occurence a given termination symbol
+ */
+bool extract_last_token(chunk_t *token, const char termination, chunk_t *src);
+
+/**
* @brief Fetches a new text line terminated by \n or \r\n
*/
bool fetchline(chunk_t *src, chunk_t *line);