aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/tls_test.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2011-12-31 12:49:18 +0100
committerMartin Willi <martin@revosec.ch>2011-12-31 13:14:49 +0100
commitf8b2906929435d439450d8ac607d8d788d66a502 (patch)
tree0aae30cb1815368f8d52ffddc6a363455ab6ee33 /scripts/tls_test.c
parent3a87c89b1bee52fe84476907a93b83d87ff1462b (diff)
downloadstrongswan-f8b2906929435d439450d8ac607d8d788d66a502.tar.bz2
strongswan-f8b2906929435d439450d8ac607d8d788d66a502.tar.xz
Use the TLS socket splicing in tls_test script
Diffstat (limited to 'scripts/tls_test.c')
-rw-r--r--scripts/tls_test.c56
1 files changed, 2 insertions, 54 deletions
diff --git a/scripts/tls_test.c b/scripts/tls_test.c
index 9e0b4e256..560c4a4ba 100644
--- a/scripts/tls_test.c
+++ b/scripts/tls_test.c
@@ -38,58 +38,6 @@ static void usage(FILE *out, char *cmd)
}
/**
- * Stream between stdio and TLS socket
- */
-static int stream(int fd, tls_socket_t *tls)
-{
- while (TRUE)
- {
- fd_set set;
- chunk_t data;
-
- FD_ZERO(&set);
- FD_SET(fd, &set);
- FD_SET(0, &set);
-
- if (select(fd + 1, &set, NULL, NULL, NULL) == -1)
- {
- return 1;
- }
- if (FD_ISSET(fd, &set))
- {
- if (!tls->read(tls, &data))
- {
- return 0;
- }
- if (data.len)
- {
- ignore_result(write(1, data.ptr, data.len));
- free(data.ptr);
- }
- }
- if (FD_ISSET(0, &set))
- {
- char buf[1024];
- ssize_t len;
-
- len = read(0, buf, sizeof(buf));
- if (len == 0)
- {
- return 0;
- }
- if (len > 0)
- {
- if (!tls->write(tls, chunk_create(buf, len)))
- {
- DBG1(DBG_TLS, "TLS write error");
- return 1;
- }
- }
- }
- }
-}
-
-/**
* Client routine
*/
static int client(host_t *host, identification_t *server,
@@ -119,7 +67,7 @@ static int client(host_t *host, identification_t *server,
close(fd);
return 1;
}
- res = stream(fd, tls);
+ res = tls->splice(tls, 0, 1) ? 0 : 1;
tls->destroy(tls);
close(fd);
if (res)
@@ -176,7 +124,7 @@ static int serve(host_t *host, identification_t *server,
close(fd);
return 1;
}
- stream(cfd, tls);
+ tls->splice(tls, 0, 1);
DBG1(DBG_TLS, "%#H disconnected", host);
tls->destroy(tls);
}