From 6a50035b242b972c1d9b659ba63e037a0a8afe71 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 29 Dec 2017 14:21:20 -0800 Subject: fixes #166 Websocket TLS mapping This introduces the wss:// scheme, which is available and works like the ws:// scheme if TLS is enabled in the library. The library modularization is refactored somewhat, to make it easier to use. There is now a single NNG_ENABLE_TLS that enables TLS support under the hood. This also adds a new option for the TLS transport, NNG_OPT_TLS_CONFIG (and a similar one for WSS, NNG_OPT_TLS_WSS_CONFIG) that offer access to the underlying TLS configuration object, which now has a public API to go with it as well. Note that it is also possible to use pure HTTPS using the *private* API, which will be exposed in a public form soon. --- src/nng.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/nng.c') diff --git a/src/nng.c b/src/nng.c index 6cd78e1d..67eac2c4 100644 --- a/src/nng.c +++ b/src/nng.c @@ -404,6 +404,12 @@ nng_dialer_setopt_uint64(nng_dialer id, const char *name, uint64_t val) return (nng_dialer_setopt(id, name, &val, sizeof(val))); } +int +nng_dialer_setopt_ptr(nng_dialer id, const char *name, void *val) +{ + return (nng_dialer_setopt(id, name, &val, sizeof(val))); +} + int nng_dialer_getopt(nng_dialer id, const char *name, void *val, size_t *szp) { @@ -431,6 +437,13 @@ nng_dialer_getopt_uint64(nng_dialer id, const char *name, uint64_t *valp) return (nng_dialer_getopt(id, name, valp, &sz)); } +int +nng_dialer_getopt_ptr(nng_dialer id, const char *name, void **valp) +{ + size_t sz = sizeof(*valp); + return (nng_dialer_getopt(id, name, valp, &sz)); +} + int nng_dialer_getopt_ms(nng_dialer id, const char *name, nng_duration *valp) { @@ -469,6 +482,12 @@ nng_listener_setopt_uint64(nng_listener id, const char *name, uint64_t val) return (nng_listener_setopt(id, name, &val, sizeof(val))); } +int +nng_listener_setopt_ptr(nng_listener id, const char *name, void *val) +{ + return (nng_listener_setopt(id, name, &val, sizeof(val))); +} + int nng_listener_getopt(nng_listener id, const char *name, void *val, size_t *szp) { @@ -496,6 +515,13 @@ nng_listener_getopt_uint64(nng_listener id, const char *name, uint64_t *valp) return (nng_listener_getopt(id, name, valp, &sz)); } +int +nng_listener_getopt_ptr(nng_listener id, const char *name, void **valp) +{ + size_t sz = sizeof(*valp); + return (nng_listener_getopt(id, name, valp, &sz)); +} + int nng_listener_getopt_ms(nng_listener id, const char *name, nng_duration *valp) { @@ -587,6 +613,12 @@ nng_setopt_uint64(nng_socket sid, const char *name, uint64_t val) return (nng_setopt(sid, name, &val, sizeof(val))); } +int +nng_setopt_ptr(nng_socket sid, const char *name, void *val) +{ + return (nng_setopt(sid, name, &val, sizeof(val))); +} + int nng_getopt_int(nng_socket sid, const char *name, int *valp) { @@ -615,6 +647,13 @@ nng_getopt_ms(nng_socket sid, const char *name, nng_duration *valp) return (nng_getopt(sid, name, valp, &sz)); } +int +nng_getopt_ptr(nng_socket sid, const char *name, void **valp) +{ + size_t sz = sizeof(*valp); + return (nng_getopt(sid, name, valp, &sz)); +} + int nng_device(nng_socket s1, nng_socket s2) { -- cgit v1.2.3-70-g09d2