aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/posix')
-rw-r--r--src/platform/posix/posix_ipcconn.c28
-rw-r--r--src/platform/posix/posix_ipcdial.c8
-rw-r--r--src/platform/posix/posix_ipclisten.c28
-rw-r--r--src/platform/posix/posix_sockfd.c30
-rw-r--r--src/platform/posix/posix_tcpconn.c18
-rw-r--r--src/platform/posix/posix_tcpdial.c28
-rw-r--r--src/platform/posix/posix_tcplisten.c42
7 files changed, 93 insertions, 89 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c
index a585bafd..fd3cdbd8 100644
--- a/src/platform/posix/posix_ipcconn.c
+++ b/src/platform/posix/posix_ipcconn.c
@@ -299,26 +299,26 @@ ipc_recv(void *arg, nni_aio *aio)
nni_mtx_unlock(&c->mtx);
}
-static int
+static nng_err
ipc_get_peer_uid(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &id, &ignore,
- &ignore, &ignore)) != 0) {
+ &ignore, &ignore)) != NNG_OK) {
return (rv);
}
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
ipc_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
@@ -329,16 +329,16 @@ ipc_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
ipc_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &ignore, &ignore,
- &ignore, &id)) != 0) {
+ &ignore, &id)) != NNG_OK) {
return (rv);
}
if (id == -1) {
@@ -348,16 +348,16 @@ ipc_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
ipc_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
if ((rv = nni_posix_peerid(nni_posix_pfd_fd(&c->pfd), &ignore, &ignore,
- &id, &ignore)) != 0) {
+ &id, &ignore)) != NNG_OK) {
return (rv);
}
if (id == -1) {
@@ -367,7 +367,7 @@ ipc_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
ipc_get_addr(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
@@ -441,14 +441,14 @@ static const nni_option ipc_options[] = {
},
};
-static int
+static nng_err
ipc_get(void *arg, const char *name, void *val, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
return (nni_getopt(ipc_options, name, c, val, szp, t));
}
-static int
+static nng_err
ipc_set(void *arg, const char *name, const void *val, size_t sz, nni_type t)
{
ipc_conn *c = arg;
diff --git a/src/platform/posix/posix_ipcdial.c b/src/platform/posix/posix_ipcdial.c
index f9e87b72..a570bc4f 100644
--- a/src/platform/posix/posix_ipcdial.c
+++ b/src/platform/posix/posix_ipcdial.c
@@ -249,7 +249,7 @@ error:
nni_aio_finish_error(aio, rv);
}
-static int
+static nng_err
ipc_dialer_get_remaddr(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_dialer *d = arg;
@@ -258,7 +258,7 @@ ipc_dialer_get_remaddr(void *arg, void *buf, size_t *szp, nni_type t)
}
#ifdef NNG_TEST_LIB
-static int
+static nng_err
ipc_dialer_set_test_no_connect(
void *arg, const void *buf, size_t sz, nni_type t)
{
@@ -289,14 +289,14 @@ static const nni_option ipc_dialer_options[] = {
},
};
-static int
+static nng_err
ipc_dialer_get(void *arg, const char *nm, void *buf, size_t *szp, nni_type t)
{
ipc_dialer *d = arg;
return (nni_getopt(ipc_dialer_options, nm, d, buf, szp, t));
}
-static int
+static nng_err
ipc_dialer_set(
void *arg, const char *nm, const void *buf, size_t sz, nni_type t)
{
diff --git a/src/platform/posix/posix_ipclisten.c b/src/platform/posix/posix_ipclisten.c
index c651b9ab..6254bf81 100644
--- a/src/platform/posix/posix_ipclisten.c
+++ b/src/platform/posix/posix_ipclisten.c
@@ -179,7 +179,7 @@ ipc_listener_cancel(nni_aio *aio, void *arg, nng_err rv)
nni_mtx_unlock(&l->mtx);
}
-static int
+static nng_err
ipc_remove_stale(const char *path)
{
int fd;
@@ -213,24 +213,24 @@ ipc_remove_stale(const char *path)
}
}
(void) close(fd);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
ipc_listener_get_addr(void *arg, void *buf, size_t *szp, nni_type t)
{
ipc_listener *l = arg;
return (nni_copyout_sockaddr(&l->sa, buf, szp, t));
}
-static int
+static nng_err
ipc_listener_set_perms(void *arg, const void *buf, size_t sz, nni_type t)
{
ipc_listener *l = arg;
int mode;
- int rv;
+ nng_err rv;
- if ((rv = nni_copyin_int(&mode, buf, sz, 0, S_IFMT, t)) != 0) {
+ if ((rv = nni_copyin_int(&mode, buf, sz, 0, S_IFMT, t)) != NNG_OK) {
return (rv);
}
if (l->sa.s_family == NNG_AF_ABSTRACT) {
@@ -249,10 +249,10 @@ ipc_listener_set_perms(void *arg, const void *buf, size_t sz, nni_type t)
}
l->perms = mode;
nni_mtx_unlock(&l->mtx);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t)
{
ipc_listener *l = arg;
@@ -261,7 +261,7 @@ ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t)
socklen_t len = sizeof(ss);
int rv;
- if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != 0) {
+ if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != NNG_OK) {
return (rv);
}
@@ -286,15 +286,15 @@ ipc_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t)
nni_posix_pfd_init(&l->pfd, fd, ipc_listener_cb, l);
l->started = true;
nni_mtx_unlock(&l->mtx);
- return (0);
+ return (NNG_OK);
}
#ifdef NNG_TEST_LIB
// this is readable only for test code -- user code should never rely on this
-static int
+static nng_err
ipc_listener_get_listen_fd(void *arg, void *buf, size_t *szp, nni_type t)
{
- int rv;
+ nng_err rv;
ipc_listener *l = arg;
nni_mtx_lock(&l->mtx);
@@ -327,7 +327,7 @@ static const nni_option ipc_listener_options[] = {
},
};
-static int
+static nng_err
ipc_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
@@ -335,7 +335,7 @@ ipc_listener_get(
return (nni_getopt(ipc_listener_options, name, l, buf, szp, t));
}
-static int
+static nng_err
ipc_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
diff --git a/src/platform/posix/posix_sockfd.c b/src/platform/posix/posix_sockfd.c
index a76ef85f..6762987b 100644
--- a/src/platform/posix/posix_sockfd.c
+++ b/src/platform/posix/posix_sockfd.c
@@ -327,7 +327,7 @@ sfd_recv(void *arg, nni_aio *aio)
nni_mtx_unlock(&c->mtx);
}
-static int
+static nng_err
sfd_get_addr(void *arg, void *buf, size_t *szp, nni_type t)
{
NNI_ARG_UNUSED(arg);
@@ -336,46 +336,46 @@ sfd_get_addr(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_sockaddr(&sa, buf, szp, t));
}
-static int
+static nng_err
sfd_get_peer_uid(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_sfd_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
rv = nni_posix_peerid(c->fd, &id, &ignore, &ignore, &ignore);
- if (rv != 0) {
+ if (rv != NNG_OK) {
return (rv);
}
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
sfd_get_peer_gid(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_sfd_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
rv = nni_posix_peerid(c->fd, &ignore, &id, &ignore, &ignore);
- if (rv != 0) {
+ if (rv != NNG_OK) {
return (rv);
}
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
sfd_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_sfd_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
rv = nni_posix_peerid(c->fd, &ignore, &ignore, &ignore, &id);
- if (rv != 0) {
+ if (rv != NNG_OK) {
return (rv);
}
if (id == -1) {
@@ -385,16 +385,16 @@ sfd_get_peer_zoneid(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_int(id, buf, szp, t));
}
-static int
+static nng_err
sfd_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_sfd_conn *c = arg;
- int rv;
+ nng_err rv;
int ignore;
int id = 0;
rv = nni_posix_peerid(c->fd, &ignore, &ignore, &id, &ignore);
- if (rv != 0) {
+ if (rv != NNG_OK) {
return (rv);
}
if (id == -1) {
@@ -434,14 +434,14 @@ static const nni_option sfd_options[] = {
},
};
-static int
+static nng_err
sfd_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
nni_sfd_conn *c = arg;
return (nni_getopt(sfd_options, name, c, buf, szp, t));
}
-static int
+static nng_err
sfd_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
nni_sfd_conn *c = arg;
diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c
index 9b61a68e..674e3f46 100644
--- a/src/platform/posix/posix_tcpconn.c
+++ b/src/platform/posix/posix_tcpconn.c
@@ -332,26 +332,26 @@ tcp_recv(void *arg, nni_aio *aio)
nni_mtx_unlock(&c->mtx);
}
-static int
+static nng_err
tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
struct sockaddr_storage ss;
socklen_t len = sizeof(ss);
int fd = nni_posix_pfd_fd(&c->pfd);
- int rv;
+ nng_err rv;
nng_sockaddr sa;
if (getpeername(fd, (void *) &ss, &len) != 0) {
return (nni_plat_errno(errno));
}
- if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == 0) {
+ if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == NNG_OK) {
rv = nni_copyout_sockaddr(&sa, buf, szp, t);
}
return (rv);
}
-static int
+static nng_err
tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
@@ -364,13 +364,13 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t)
if (getsockname(fd, (void *) &ss, &len) != 0) {
return (nni_plat_errno(errno));
}
- if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == 0) {
+ if ((rv = nni_posix_sockaddr2nn(&sa, &ss, len)) == NNG_OK) {
rv = nni_copyout_sockaddr(&sa, buf, szp, t);
}
return (rv);
}
-static int
+static nng_err
tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
@@ -385,7 +385,7 @@ tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(val, buf, szp, t));
}
-static int
+static nng_err
tcp_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
@@ -422,14 +422,14 @@ static const nni_option tcp_options[] = {
},
};
-static int
+static nng_err
tcp_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
return (nni_getopt(tcp_options, name, c, buf, szp, t));
}
-static int
+static nng_err
tcp_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
nni_tcp_conn *c = arg;
diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c
index 52807892..181a667f 100644
--- a/src/platform/posix/posix_tcpdial.c
+++ b/src/platform/posix/posix_tcpdial.c
@@ -280,14 +280,15 @@ error:
nni_aio_finish_error(aio, rv);
}
-static int
+static nng_err
tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_tcp_dialer *d = arg;
- int rv;
+ nng_err rv;
bool b;
- if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) {
+ if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) ||
+ (d == NULL)) {
return (rv);
}
nni_mtx_lock(&d->mtx);
@@ -296,7 +297,7 @@ tcp_dialer_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t)
return (0);
}
-static int
+static nng_err
tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
{
bool b;
@@ -307,14 +308,15 @@ tcp_dialer_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(b, buf, szp, t));
}
-static int
+static nng_err
tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_tcp_dialer *d = arg;
- int rv;
+ nng_err rv;
bool b;
- if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (d == NULL)) {
+ if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) ||
+ (d == NULL)) {
return (rv);
}
nni_mtx_lock(&d->mtx);
@@ -323,7 +325,7 @@ tcp_dialer_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t)
return (0);
}
-static int
+static nng_err
tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t)
{
bool b;
@@ -334,7 +336,7 @@ tcp_dialer_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(b, buf, szp, t));
}
-static int
+static nng_err
tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t)
{
nni_tcp_dialer *d = arg;
@@ -348,7 +350,7 @@ tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_sockaddr(&sa, buf, szp, t));
}
-static int
+static nng_err
tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t)
{
nni_tcp_dialer *d = arg;
@@ -356,13 +358,13 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t)
struct sockaddr_storage ss;
struct sockaddr_in *sin;
size_t len;
- int rv;
+ nng_err rv;
#ifdef NNG_ENABLE_IPV6
struct sockaddr_in6 *sin6;
#endif
NNI_ARG_UNUSED(sz);
- if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != 0) {
+ if ((rv = nni_copyin_sockaddr(&sa, buf, t)) != NNG_OK) {
return (rv);
}
if ((len = nni_posix_nn2sockaddr(&ss, &sa)) == 0) {
@@ -400,7 +402,7 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t)
d->srclen = len;
nni_mtx_unlock(&d->mtx);
}
- return (0);
+ return (NNG_OK);
}
static const nni_option tcp_dialer_options[] = {
diff --git a/src/platform/posix/posix_tcplisten.c b/src/platform/posix/posix_tcplisten.c
index 29255df2..508f4d1e 100644
--- a/src/platform/posix/posix_tcplisten.c
+++ b/src/platform/posix/posix_tcplisten.c
@@ -301,7 +301,7 @@ tcp_listener_accept(void *arg, nni_aio *aio)
nni_mtx_unlock(&l->mtx);
}
-static int
+static nng_err
tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t)
{
tcp_listener *l = arg;
@@ -320,23 +320,24 @@ tcp_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_sockaddr(&sa, buf, szp, t));
}
-static int
+static nng_err
tcp_listener_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t)
{
tcp_listener *l = arg;
- int rv;
+ nng_err rv;
bool b;
- if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) {
+ if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) ||
+ (l == NULL)) {
return (rv);
}
nni_mtx_lock(&l->mtx);
l->nodelay = b;
nni_mtx_unlock(&l->mtx);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
{
bool b;
@@ -347,23 +348,24 @@ tcp_listener_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(b, buf, szp, t));
}
-static int
+static nng_err
tcp_listener_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t)
{
tcp_listener *l = arg;
- int rv;
+ nng_err rv;
bool b;
- if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (l == NULL)) {
+ if (((rv = nni_copyin_bool(&b, buf, sz, t)) != NNG_OK) ||
+ (l == NULL)) {
return (rv);
}
nni_mtx_lock(&l->mtx);
l->keepalive = b;
nni_mtx_unlock(&l->mtx);
- return (0);
+ return (NNG_OK);
}
-static int
+static nng_err
tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t)
{
bool b;
@@ -374,7 +376,7 @@ tcp_listener_get_keepalive(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_bool(b, buf, szp, t));
}
-static int
+static nng_err
tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t)
{
tcp_listener *l = arg;
@@ -403,16 +405,16 @@ tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t)
return (nni_copyout_int(port, buf, szp, t));
}
-static int
+static nng_err
tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t)
{
tcp_listener *l = arg;
int fd;
struct sockaddr_storage ss;
socklen_t len = sizeof(ss);
- int rv;
+ nng_err rv;
- if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != 0) {
+ if ((rv = nni_copyin_int(&fd, buf, sz, 0, NNI_MAXINT, t)) != NNG_OK) {
return (rv);
}
@@ -442,15 +444,15 @@ tcp_listener_set_listen_fd(void *arg, const void *buf, size_t sz, nni_type t)
nni_posix_pfd_init(&l->pfd, fd, tcp_listener_cb, l);
l->started = true;
nni_mtx_unlock(&l->mtx);
- return (0);
+ return (NNG_OK);
}
#ifdef NNG_TEST_LIB
// this is readable only for test code -- user code should never rely on this
-static int
+static nng_err
tcp_listener_get_listen_fd(void *arg, void *buf, size_t *szp, nni_type t)
{
- int rv;
+ nng_err rv;
tcp_listener *l = arg;
nni_mtx_lock(&l->mtx);
NNI_ASSERT(l->started);
@@ -492,14 +494,14 @@ static const nni_option tcp_listener_options[] = {
},
};
-static int
+static nng_err
tcp_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
return (nni_getopt(tcp_listener_options, name, arg, buf, szp, t));
}
-static int
+static nng_err
tcp_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{