summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libressl/Makefile3
-rw-r--r--src/lib/libressl/ressl.h4
-rw-r--r--src/lib/libressl/ressl_server.c66
3 files changed, 72 insertions, 1 deletions
diff --git a/src/lib/libressl/Makefile b/src/lib/libressl/Makefile
index 397fefdf69..0a481f0009 100644
--- a/src/lib/libressl/Makefile
+++ b/src/lib/libressl/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.3 2014/07/13 22:42:01 jsing Exp $ 1# $OpenBSD: Makefile,v 1.4 2014/07/13 23:36:24 jsing Exp $
2 2
3CFLAGS+= -Wall -Werror -Wimplicit 3CFLAGS+= -Wall -Werror -Wimplicit
4CFLAGS+= -DLIBRESSL_INTERNAL 4CFLAGS+= -DLIBRESSL_INTERNAL
@@ -12,6 +12,7 @@ HDRS= ressl.h
12SRCS= ressl.c \ 12SRCS= ressl.c \
13 ressl_client.c \ 13 ressl_client.c \
14 ressl_config.c \ 14 ressl_config.c \
15 ressl_server.c \
15 ressl_util.c \ 16 ressl_util.c \
16 ressl_verify.c 17 ressl_verify.c
17 18
diff --git a/src/lib/libressl/ressl.h b/src/lib/libressl/ressl.h
index e7e0a9c51b..dc99368fe6 100644
--- a/src/lib/libressl/ressl.h
+++ b/src/lib/libressl/ressl.h
@@ -37,12 +37,16 @@ void ressl_config_insecure_no_verify(struct ressl_config *config);
37void ressl_config_verify(struct ressl_config *config); 37void ressl_config_verify(struct ressl_config *config);
38 38
39struct ressl *ressl_client(void); 39struct ressl *ressl_client(void);
40struct ressl *ressl_server(void);
40int ressl_configure(struct ressl *ctx, struct ressl_config *config); 41int ressl_configure(struct ressl *ctx, struct ressl_config *config);
41void ressl_reset(struct ressl *ctx); 42void ressl_reset(struct ressl *ctx);
42void ressl_free(struct ressl *ctx); 43void ressl_free(struct ressl *ctx);
43 44
45int ressl_accept(struct ressl *ctx);
46int ressl_accept_socket(struct ressl *ctx, int socket);
44int ressl_connect(struct ressl *ctx, const char *host, const char *port); 47int ressl_connect(struct ressl *ctx, const char *host, const char *port);
45int ressl_connect_socket(struct ressl *ctx, int s, const char *hostname); 48int ressl_connect_socket(struct ressl *ctx, int s, const char *hostname);
49int ressl_listen(struct ressl *ctx, const char *host, const char *port, int af);
46int ressl_read(struct ressl *ctx, char *buf, size_t buflen, size_t *outlen); 50int ressl_read(struct ressl *ctx, char *buf, size_t buflen, size_t *outlen);
47int ressl_write(struct ressl *ctx, const char *buf, size_t buflen, 51int ressl_write(struct ressl *ctx, const char *buf, size_t buflen,
48 size_t *outlen); 52 size_t *outlen);
diff --git a/src/lib/libressl/ressl_server.c b/src/lib/libressl/ressl_server.c
new file mode 100644
index 0000000000..243b4bfb09
--- /dev/null
+++ b/src/lib/libressl/ressl_server.c
@@ -0,0 +1,66 @@
1/*
2 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "ressl_internal.h"
18
19struct ressl *
20ressl_server(void)
21{
22 struct ressl *ctx;
23
24 if ((ctx = ressl_new()) == NULL)
25 return (NULL);
26
27 ctx->flags |= RESSL_SERVER;
28
29 return (ctx);
30}
31
32int
33ressl_listen(struct ressl *ctx, const char *host, const char *port, int af)
34{
35 if ((ctx->flags & RESSL_SERVER) == 0) {
36 ressl_set_error(ctx, "not a server context");
37 goto err;
38 }
39
40err:
41 return (1);
42}
43
44int
45ressl_accept(struct ressl *ctx)
46{
47 if ((ctx->flags & RESSL_SERVER) == 0) {
48 ressl_set_error(ctx, "not a server context");
49 goto err;
50 }
51
52err:
53 return (1);
54}
55
56int
57ressl_accept_socket(struct ressl *ctx, int socket)
58{
59 if ((ctx->flags & RESSL_SERVER) == 0) {
60 ressl_set_error(ctx, "not a server context");
61 goto err;
62 }
63
64err:
65 return (1);
66}