aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental
diff options
context:
space:
mode:
Diffstat (limited to 'src/supplemental')
-rw-r--r--src/supplemental/tls/tls_dialer.c12
-rw-r--r--src/supplemental/tls/tls_listener.c12
-rw-r--r--src/supplemental/tls/tls_stream.c12
-rw-r--r--src/supplemental/websocket/websocket.c172
4 files changed, 104 insertions, 104 deletions
diff --git a/src/supplemental/tls/tls_dialer.c b/src/supplemental/tls/tls_dialer.c
index 5927edd8..0b2acee7 100644
--- a/src/supplemental/tls/tls_dialer.c
+++ b/src/supplemental/tls/tls_dialer.c
@@ -92,7 +92,7 @@ tls_dialer_dial(void *arg, nng_aio *aio)
nng_stream_dialer_dial(d->d, &ts->conn_aio);
}
-static int
+static nng_err
tls_dialer_set_tls(void *arg, nng_tls_config *cfg)
{
tls_dialer *d = arg;
@@ -114,20 +114,20 @@ tls_dialer_set_tls(void *arg, nng_tls_config *cfg)
nni_mtx_unlock(&d->lk);
nng_tls_config_free(old);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tls_dialer_get_tls(void *arg, nng_tls_config **cfg)
{
tls_dialer *d = arg;
nni_mtx_lock(&d->lk);
*cfg = d->cfg;
nni_mtx_unlock(&d->lk);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tls_dialer_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
tls_dialer *d = arg;
@@ -135,7 +135,7 @@ tls_dialer_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
return (nni_stream_dialer_get(d->d, name, buf, szp, t));
}
-static int
+static nng_err
tls_dialer_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
diff --git a/src/supplemental/tls/tls_listener.c b/src/supplemental/tls/tls_listener.c
index 0ab0f57b..5d2d8599 100644
--- a/src/supplemental/tls/tls_listener.c
+++ b/src/supplemental/tls/tls_listener.c
@@ -99,7 +99,7 @@ tls_listener_accept(void *arg, nng_aio *aio)
nng_stream_listener_accept(l->l, &ts->conn_aio);
}
-static int
+static nng_err
tls_listener_set_tls(void *arg, nng_tls_config *cfg)
{
tls_listener *l = arg;
@@ -120,20 +120,20 @@ tls_listener_set_tls(void *arg, nng_tls_config *cfg)
nni_mtx_unlock(&l->lk);
nng_tls_config_free(old);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tls_listener_get_tls(void *arg, nng_tls_config **cfg)
{
tls_listener *l = arg;
nni_mtx_lock(&l->lk);
*cfg = l->cfg;
nni_mtx_unlock(&l->lk);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tls_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
@@ -142,7 +142,7 @@ tls_listener_get(
return (nni_stream_listener_get(l->l, name, buf, szp, t));
}
-static int
+static nng_err
tls_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
diff --git a/src/supplemental/tls/tls_stream.c b/src/supplemental/tls/tls_stream.c
index 7ac8d5b9..8a7f26d8 100644
--- a/src/supplemental/tls/tls_stream.c
+++ b/src/supplemental/tls/tls_stream.c
@@ -134,7 +134,7 @@ tls_stream_conn_cb(void *arg)
nni_aio_finish(ts->user_aio, 0, 0);
}
-static int tls_stream_get(
+static nng_err tls_stream_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t);
int
@@ -173,7 +173,7 @@ nni_tls_stream_alloc(tls_stream **tsp, nng_tls_config *cfg, nng_aio *user_aio)
return (0);
}
-static int
+static nng_err
tls_get_verified(void *arg, void *buf, size_t *szp, nni_type t)
{
tls_stream *ts = arg;
@@ -181,7 +181,7 @@ tls_get_verified(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(nni_tls_verified(&ts->conn), buf, szp, t));
}
-static int
+static nng_err
tls_get_peer_cn(void *arg, void *buf, size_t *szp, nni_type t)
{
NNI_ARG_UNUSED(szp);
@@ -192,7 +192,7 @@ tls_get_peer_cn(void *arg, void *buf, size_t *szp, nni_type t)
tls_stream *ts = arg;
*(char **) buf = (char *) nni_tls_peer_cn(&ts->conn);
- return (0);
+ return (NNG_OK);
}
static const nni_option tls_stream_options[] = {
@@ -209,11 +209,11 @@ static const nni_option tls_stream_options[] = {
},
};
-static int
+static nng_err
tls_stream_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
tls_stream *ts = arg;
- int rv;
+ nng_err rv;
if ((rv = nni_stream_get(ts->conn.bio, name, buf, szp, t)) !=
NNG_ENOTSUP) {
diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c
index 36312b69..4ddf8918 100644
--- a/src/supplemental/websocket/websocket.c
+++ b/src/supplemental/websocket/websocket.c
@@ -181,11 +181,11 @@ static void ws_read_cb(void *);
static void ws_write_cb(void *);
static void ws_close_error(nni_ws *ws, uint16_t code);
-static void ws_str_free(void *);
-static void ws_str_close(void *);
-static void ws_str_send(void *, nng_aio *);
-static void ws_str_recv(void *, nng_aio *);
-static int ws_str_get(void *, const char *, void *, size_t *, nni_type);
+static void ws_str_free(void *);
+static void ws_str_close(void *);
+static void ws_str_send(void *, nng_aio *);
+static void ws_str_recv(void *, nng_aio *);
+static nng_err ws_str_get(void *, const char *, void *, size_t *, nni_type);
static void ws_listener_close(void *);
static void ws_listener_free(void *);
@@ -1726,17 +1726,17 @@ ws_listener_listen(void *arg)
return (NNG_OK);
}
-static int
+static nng_err
ws_listener_set_size(
nni_ws_listener *l, size_t *valp, const void *buf, size_t sz, nni_type t)
{
- size_t val;
- int rv;
+ size_t val;
+ nng_err rv;
// Max size is limited to 4 GB, but you really never want to have
// to have a larger value. If you think you need that, you're doing it
// wrong. You *can* set the size to 0 for unlimited.
- if ((rv = nni_copyin_size(&val, buf, sz, 0, NNI_MAXSZ, t)) == 0) {
+ if ((rv = nni_copyin_size(&val, buf, sz, 0, NNI_MAXSZ, t)) == NNG_OK) {
nni_mtx_lock(&l->mtx);
*valp = val;
nni_mtx_unlock(&l->mtx);
@@ -1744,7 +1744,7 @@ ws_listener_set_size(
return (rv);
}
-static int
+static nng_err
ws_listener_get_size(
nni_ws_listener *l, size_t *valp, void *buf, size_t *szp, nni_type t)
{
@@ -1755,55 +1755,55 @@ ws_listener_get_size(
return (nni_copyout_size(val, buf, szp, t));
}
-static int
+static nng_err
ws_listener_set_maxframe(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_set_size(l, &l->maxframe, buf, sz, t));
}
-static int
+static nng_err
ws_listener_get_maxframe(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_get_size(l, &l->maxframe, buf, szp, t));
}
-static int
+static nng_err
ws_listener_set_fragsize(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_set_size(l, &l->fragsize, buf, sz, t));
}
-static int
+static nng_err
ws_listener_get_fragsize(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_get_size(l, &l->fragsize, buf, szp, t));
}
-static int
+static nng_err
ws_listener_set_recvmax(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_set_size(l, &l->recvmax, buf, sz, t));
}
-static int
+static nng_err
ws_listener_get_recvmax(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
return (ws_listener_get_size(l, &l->recvmax, buf, szp, t));
}
-static int
+static nng_err
ws_listener_set_proto(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
- if ((rv = ws_check_string(buf, sz, t)) == 0) {
+ if ((rv = ws_check_string(buf, sz, t)) == NNG_OK) {
char *ns;
if ((ns = nni_strdup(buf)) == NULL) {
rv = NNG_ENOMEM;
@@ -1819,25 +1819,25 @@ ws_listener_set_proto(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_listener_get_proto(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&l->mtx);
rv = nni_copyout_str(l->proto != NULL ? l->proto : "", buf, szp, t);
nni_mtx_unlock(&l->mtx);
return (rv);
}
-static int
+static nng_err
ws_listener_set_msgmode(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
bool b;
- if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
+ if ((rv = nni_copyin_bool(&b, buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&l->mtx);
l->isstream = !b;
nni_mtx_unlock(&l->mtx);
@@ -1845,14 +1845,14 @@ ws_listener_set_msgmode(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_listener_set_recv_text(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
bool b;
- if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
+ if ((rv = nni_copyin_bool(&b, buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&l->mtx);
l->recv_text = b;
nni_mtx_unlock(&l->mtx);
@@ -1860,14 +1860,14 @@ ws_listener_set_recv_text(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_listener_set_send_text(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
bool b;
- if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
+ if ((rv = nni_copyin_bool(&b, buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&l->mtx);
l->send_text = b;
nni_mtx_unlock(&l->mtx);
@@ -1875,22 +1875,22 @@ ws_listener_set_send_text(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_listener_get_recv_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&l->mtx);
rv = nni_copyout_bool(l->recv_text, buf, szp, t);
nni_mtx_unlock(&l->mtx);
return (rv);
}
-static int
+static nng_err
ws_listener_get_send_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&l->mtx);
rv = nni_copyout_bool(l->send_text, buf, szp, t);
nni_mtx_unlock(&l->mtx);
@@ -1937,13 +1937,13 @@ static const nni_option ws_listener_options[] = {
},
};
-static int
+static nng_err
ws_listener_set_header(nni_ws_listener *l, const char *name, const void *buf,
size_t sz, nni_type t)
{
- int rv;
+ nng_err rv;
name += strlen(NNG_OPT_WS_HEADER);
- if ((rv = ws_check_string(buf, sz, t)) == 0) {
+ if ((rv = ws_check_string(buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&l->mtx);
rv = ws_set_header(&l->headers, name, buf);
nni_mtx_unlock(&l->mtx);
@@ -1951,12 +1951,12 @@ ws_listener_set_header(nni_ws_listener *l, const char *name, const void *buf,
return (rv);
}
-static int
+static nng_err
ws_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
rv = nni_setopt(ws_listener_options, name, l, buf, sz, t);
if (rv == NNG_ENOTSUP) {
@@ -1971,12 +1971,12 @@ ws_listener_set(
return (rv);
}
-static int
+static nng_err
ws_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
nni_ws_listener *l = arg;
- int rv;
+ nng_err rv;
rv = nni_getopt(ws_listener_options, name, l, buf, szp, t);
if (rv == NNG_ENOTSUP) {
@@ -1985,14 +1985,14 @@ ws_listener_get(
return (rv);
}
-static int
+static nng_err
ws_listener_get_tls(void *arg, nng_tls_config **cfgp)
{
nni_ws_listener *l = arg;
return (nni_http_server_get_tls(l->server, cfgp));
}
-static int
+static nng_err
ws_listener_set_tls(void *arg, nng_tls_config *cfg)
{
nni_ws_listener *l = arg;
@@ -2254,11 +2254,11 @@ ws_dialer_dial(void *arg, nni_aio *aio)
nni_mtx_unlock(&d->mtx);
}
-static int
+static nng_err
ws_dialer_set_msgmode(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
bool b;
if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
@@ -2269,14 +2269,14 @@ ws_dialer_set_msgmode(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_dialer_set_recv_text(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
bool b;
- if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
+ if ((rv = nni_copyin_bool(&b, buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&d->mtx);
d->recv_text = b;
nni_mtx_unlock(&d->mtx);
@@ -2284,14 +2284,14 @@ ws_dialer_set_recv_text(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_dialer_set_send_text(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
bool b;
- if ((rv = nni_copyin_bool(&b, buf, sz, t)) == 0) {
+ if ((rv = nni_copyin_bool(&b, buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&d->mtx);
d->send_text = b;
nni_mtx_unlock(&d->mtx);
@@ -2299,17 +2299,17 @@ ws_dialer_set_send_text(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_dialer_set_size(
nni_ws_dialer *d, size_t *valp, const void *buf, size_t sz, nni_type t)
{
- size_t val;
- int rv;
+ size_t val;
+ nng_err rv;
// Max size is limited to 4 GB, but you really never want to have
// to have a larger value. If you think you need that, you're doing it
// wrong. You *can* set the size to 0 for unlimited.
- if ((rv = nni_copyin_size(&val, buf, sz, 0, NNI_MAXSZ, t)) == 0) {
+ if ((rv = nni_copyin_size(&val, buf, sz, 0, NNI_MAXSZ, t)) == NNG_OK) {
nni_mtx_lock(&d->mtx);
*valp = val;
nni_mtx_unlock(&d->mtx);
@@ -2317,7 +2317,7 @@ ws_dialer_set_size(
return (rv);
}
-static int
+static nng_err
ws_dialer_get_size(
nni_ws_dialer *d, size_t *valp, void *buf, size_t *szp, nni_type t)
{
@@ -2328,55 +2328,55 @@ ws_dialer_get_size(
return (nni_copyout_size(val, buf, szp, t));
}
-static int
+static nng_err
ws_dialer_set_maxframe(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_set_size(d, &d->maxframe, buf, sz, t));
}
-static int
+static nng_err
ws_dialer_get_maxframe(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_get_size(d, &d->maxframe, buf, szp, t));
}
-static int
+static nng_err
ws_dialer_set_fragsize(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_set_size(d, &d->fragsize, buf, sz, t));
}
-static int
+static nng_err
ws_dialer_get_fragsize(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_get_size(d, &d->fragsize, buf, szp, t));
}
-static int
+static nng_err
ws_dialer_set_recvmax(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_set_size(d, &d->recvmax, buf, sz, t));
}
-static int
+static nng_err
ws_dialer_get_recvmax(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
return (ws_dialer_get_size(d, &d->recvmax, buf, szp, t));
}
-static int
+static nng_err
ws_dialer_set_proto(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
- if ((rv = ws_check_string(buf, sz, t)) == 0) {
+ if ((rv = ws_check_string(buf, sz, t)) == NNG_OK) {
char *ns;
if ((ns = nni_strdup(buf)) == NULL) {
rv = NNG_ENOMEM;
@@ -2392,33 +2392,33 @@ ws_dialer_set_proto(void *arg, const void *buf, size_t sz, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_dialer_get_proto(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&d->mtx);
rv = nni_copyout_str(d->proto != NULL ? d->proto : "", buf, szp, t);
nni_mtx_unlock(&d->mtx);
return (rv);
}
-static int
+static nng_err
ws_dialer_get_recv_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&d->mtx);
rv = nni_copyout_bool(d->recv_text, buf, szp, t);
nni_mtx_unlock(&d->mtx);
return (rv);
}
-static int
+static nng_err
ws_dialer_get_send_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&d->mtx);
rv = nni_copyout_bool(d->send_text, buf, szp, t);
nni_mtx_unlock(&d->mtx);
@@ -2466,13 +2466,13 @@ static const nni_option ws_dialer_options[] = {
},
};
-static int
+static nng_err
ws_dialer_set_header(
nni_ws_dialer *d, const char *name, const void *buf, size_t sz, nni_type t)
{
- int rv;
+ nng_err rv;
name += strlen(NNG_OPT_WS_HEADER);
- if ((rv = ws_check_string(buf, sz, t)) == 0) {
+ if ((rv = ws_check_string(buf, sz, t)) == NNG_OK) {
nni_mtx_lock(&d->mtx);
rv = ws_set_header(&d->headers, name, buf);
nni_mtx_unlock(&d->mtx);
@@ -2480,12 +2480,12 @@ ws_dialer_set_header(
return (rv);
}
-static int
+static nng_err
ws_dialer_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
rv = nni_setopt(ws_dialer_options, name, d, buf, sz, t);
if (rv == NNG_ENOTSUP) {
@@ -2500,11 +2500,11 @@ ws_dialer_set(
return (rv);
}
-static int
+static nng_err
ws_dialer_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
nni_ws_dialer *d = arg;
- int rv;
+ nng_err rv;
rv = nni_getopt(ws_dialer_options, name, d, buf, szp, t);
if (rv == NNG_ENOTSUP) {
@@ -2513,14 +2513,14 @@ ws_dialer_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
return (rv);
}
-static int
+static nng_err
ws_dialer_get_tls(void *arg, nng_tls_config **cfgp)
{
nni_ws_dialer *d = arg;
return (nni_http_client_get_tls(d->client, cfgp));
}
-static int
+static nng_err
ws_dialer_set_tls(void *arg, nng_tls_config *cfg)
{
nni_ws_dialer *d = arg;
@@ -2669,14 +2669,14 @@ ws_str_recv(void *arg, nng_aio *aio)
nni_mtx_unlock(&ws->mtx);
}
-static int
+static nng_err
ws_get_request_uri(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws *ws = arg;
return (nni_copyout_str(nni_http_get_uri(ws->http), buf, szp, t));
}
-static int
+static nng_err
ws_get_recv_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws *ws = arg;
@@ -2688,7 +2688,7 @@ ws_get_recv_text(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(b, buf, szp, t));
}
-static int
+static nng_err
ws_get_send_text(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_ws *ws = arg;
@@ -2718,7 +2718,7 @@ static const nni_option ws_options[] = {
},
};
-static int
+static nng_err
ws_get_header(nni_ws *ws, const char *nm, void *buf, size_t *szp, nni_type t)
{
const char *s;
@@ -2730,11 +2730,11 @@ ws_get_header(nni_ws *ws, const char *nm, void *buf, size_t *szp, nni_type t)
return (nni_copyout_str(s, buf, szp, t));
}
-static int
+static nng_err
ws_str_get(void *arg, const char *nm, void *buf, size_t *szp, nni_type t)
{
nni_ws *ws = arg;
- int rv;
+ nng_err rv;
nni_mtx_lock(&ws->mtx);
if (ws->closed) {