]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Refactored: Moved BIO debug functions to OpenSSL backend
authorAdriaan de Jong <dejong@fox-it.com>
Tue, 28 Jun 2011 08:08:08 +0000 (10:08 +0200)
committerDavid Sommerseth <davids@redhat.com>
Fri, 21 Oct 2011 08:53:32 +0000 (10:53 +0200)
Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
ssl.c
ssl_openssl.c

diff --git a/ssl.c b/ssl.c
index b8940634fd09771a1d4a1cbbcc7659ec16dde5aa..9b44a86c3b43301b6194078bb9c447dc82df53e1 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -111,68 +111,6 @@ show_tls_performance_stats(void)
 
 #endif
 
-#ifdef BIO_DEBUG
-
-#warning BIO_DEBUG defined
-
-static FILE *biofp;                            /* GLOBAL */
-static bool biofp_toggle;                      /* GLOBAL */
-static time_t biofp_last_open;                 /* GLOBAL */
-static const int biofp_reopen_interval = 600;  /* GLOBAL */
-
-static void
-close_biofp()
-{
-  if (biofp)
-    {
-      ASSERT (!fclose (biofp));
-      biofp = NULL;
-    }
-}
-
-static void
-open_biofp()
-{
-  const time_t current = time (NULL);
-  const pid_t pid = getpid ();
-
-  if (biofp_last_open + biofp_reopen_interval < current)
-    close_biofp();
-  if (!biofp)
-    {
-      char fn[256];
-      openvpn_snprintf(fn, sizeof(fn), "bio/%d-%d.log", pid, biofp_toggle);
-      biofp = fopen (fn, "w");
-      ASSERT (biofp);
-      biofp_last_open = time (NULL);
-      biofp_toggle ^= 1;
-    }
-}
-
-static void
-bio_debug_data (const char *mode, BIO *bio, const uint8_t *buf, int len, const char *desc)
-{
-  struct gc_arena gc = gc_new ();
-  if (len > 0)
-    {
-      open_biofp();
-      fprintf(biofp, "BIO_%s %s time=" time_format " bio=" ptr_format " len=%d data=%s\n",
-             mode, desc, time (NULL), (ptr_type)bio, len, format_hex (buf, len, 0, &gc));
-      fflush (biofp);
-    }
-  gc_free (&gc);
-}
-
-static void
-bio_debug_oc (const char *mode, BIO *bio)
-{
-  open_biofp();
-  fprintf(biofp, "BIO %s time=" time_format " bio=" ptr_format "\n",
-         mode, time (NULL), (ptr_type)bio);
-  fflush (biofp);
-}
-
-#endif
 
 /*
  * Max number of bytes we will add
index 1c72b16625e823c39803971dd50a05413188bc46..2d5e914cdc6c13a5d8a93fe305fe5b387a991223 100644 (file)
@@ -840,6 +840,69 @@ tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file,
  *
  */
 
+#ifdef BIO_DEBUG
+
+#warning BIO_DEBUG defined
+
+static FILE *biofp;                            /* GLOBAL */
+static bool biofp_toggle;                      /* GLOBAL */
+static time_t biofp_last_open;                 /* GLOBAL */
+static const int biofp_reopen_interval = 600;  /* GLOBAL */
+
+static void
+close_biofp()
+{
+  if (biofp)
+    {
+      ASSERT (!fclose (biofp));
+      biofp = NULL;
+    }
+}
+
+static void
+open_biofp()
+{
+  const time_t current = time (NULL);
+  const pid_t pid = getpid ();
+
+  if (biofp_last_open + biofp_reopen_interval < current)
+    close_biofp();
+  if (!biofp)
+    {
+      char fn[256];
+      openvpn_snprintf(fn, sizeof(fn), "bio/%d-%d.log", pid, biofp_toggle);
+      biofp = fopen (fn, "w");
+      ASSERT (biofp);
+      biofp_last_open = time (NULL);
+      biofp_toggle ^= 1;
+    }
+}
+
+static void
+bio_debug_data (const char *mode, BIO *bio, const uint8_t *buf, int len, const char *desc)
+{
+  struct gc_arena gc = gc_new ();
+  if (len > 0)
+    {
+      open_biofp();
+      fprintf(biofp, "BIO_%s %s time=" time_format " bio=" ptr_format " len=%d data=%s\n",
+             mode, desc, time (NULL), (ptr_type)bio, len, format_hex (buf, len, 0, &gc));
+      fflush (biofp);
+    }
+  gc_free (&gc);
+}
+
+static void
+bio_debug_oc (const char *mode, BIO *bio)
+{
+  open_biofp();
+  fprintf(biofp, "BIO %s time=" time_format " bio=" ptr_format "\n",
+         mode, time (NULL), (ptr_type)bio);
+  fflush (biofp);
+}
+
+#endif
+
 /*
  * OpenVPN's interface to SSL/TLS authentication,
  * encryption, and decryption is exclusively