summaryrefslogtreecommitdiff
path: root/src/socket.h
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-07-26 10:33:24 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-07-26 14:23:55 +0200
commit7e051ae28c288c218584f75dbc6c097a3b2564c9 (patch)
tree9456e41b15aac3333770d58715c7487607318af3 /src/socket.h
parente9b7e84870bc1bfea4969a57d15e523133b46ecb (diff)
downloadgnutls-7e051ae28c288c218584f75dbc6c097a3b2564c9.tar.gz
tools: TLS handling has been incorporated into socket_open()
This is of particular usage to the server IP address loop, since we can detect fast open errors and retry handshake to the next IP address.
Diffstat (limited to 'src/socket.h')
-rw-r--r--src/socket.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/socket.h b/src/socket.h
index 1f1394f812..55e7230300 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -1,11 +1,18 @@
#include <gnutls/gnutls.h>
#include <gnutls/socket.h>
+#define SOCKET_FLAG_UDP 1
+#define SOCKET_FLAG_FASTOPEN (1<<1)
+#define SOCKET_FLAG_STARTTLS (1<<2)
+#define SOCKET_FLAG_RAW (1<<3) /* unencrypted */
+
+
typedef struct {
int fd;
gnutls_session_t session;
int secure;
char *hostname;
+ const char *app_proto;
char *ip;
char *service;
struct addrinfo *ptr;
@@ -20,6 +27,10 @@ typedef struct {
gnutls_datum_t rdata;
} socket_st;
+/* calling program must provide that */
+extern gnutls_session_t init_tls_session(const char *host);
+extern int do_handshake(socket_st * socket);
+
ssize_t socket_recv(const socket_st * socket, void *buffer,
int buffer_size);
ssize_t socket_recv_timeout(const socket_st * socket, void *buffer,
@@ -28,14 +39,12 @@ ssize_t socket_send(const socket_st * socket, const void *buffer,
int buffer_size);
ssize_t socket_send_range(const socket_st * socket, const void *buffer,
int buffer_size, gnutls_range_st * range);
-void socket_open(socket_st * hd, const char *hostname, const char *service,
- int flags, const char *msg);
+void
+socket_open(socket_st * hd, const char *hostname, const char *service,
+ const char *app_proto, int flags, const char *msg, gnutls_datum_t *rdata);
-void socket_starttls(socket_st * hd, const char *app_proto);
void socket_bye(socket_st * socket);
-void sockets_init(void);
-
int service_to_port(const char *service, const char *proto);
const char *port_to_service(const char *sport, const char *proto);
int starttls_proto_to_port(const char *app_proto);