aboutsummaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-03 10:12:28 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-03 10:45:51 -0800
commit49076237cc0b82e7007535e789f3fadc19a18c45 (patch)
tree6336768366f8d8bca987f8742ddcb1df73fd3c98 /src/core/socket.c
parent11485d2723f22dc60e4cefea3ffb3fd8a378d931 (diff)
downloadnng-49076237cc0b82e7007535e789f3fadc19a18c45.tar.gz
nng-49076237cc0b82e7007535e789f3fadc19a18c45.tar.bz2
nng-49076237cc0b82e7007535e789f3fadc19a18c45.zip
Remove NNI_TYPE_OPAQUE altogether.
This also fixes a couple of minor bugs -- changing the socket name could be incorrect as the termination was not applied properly, and the ZeroTier code got a change -- note that it is only possible in this revised version to pass a single moon ID for ZT orbit. The ZT code is a bit stale, and untested anyway.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index b3fb96b2..c911fa40 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -210,11 +210,9 @@ static int
sock_set_sockname(void *s, const void *buf, size_t sz, nni_type t)
{
int rv;
- if (sz >= 64) {
- return (NNG_EINVAL);
- }
- rv = (nni_copyin_str(
- SOCK(s)->s_name, buf, sizeof(SOCK(s)->s_name), sz, t));
+ NNI_ARG_UNUSED(sz);
+ rv =
+ (nni_copyin_str(SOCK(s)->s_name, buf, sizeof(SOCK(s)->s_name), t));
#ifdef NNG_ENABLE_STATS
if (rv == 0) {
nni_stat_set_string(&SOCK(s)->st_name, SOCK(s)->s_name);
@@ -988,7 +986,8 @@ nni_sock_setopt(
}
} else if (strcmp(name, NNG_OPT_RECVMAXSZ) == 0) {
- if ((rv = nni_copyin_size(NULL, v, sz, 0, NNI_MAXSZ, t)) !=
+ size_t scratch;
+ if ((rv = nni_copyin_size(&scratch, v, sz, 0, NNI_MAXSZ, t)) !=
0) {
return (rv);
}
@@ -1080,17 +1079,9 @@ nni_sock_getopt(
if (strcmp(sopt->name, name) == 0) {
size_t sz = sopt->sz;
- if ((sopt->typ != NNI_TYPE_OPAQUE) &&
- (t != sopt->typ)) {
-
- if (t != NNI_TYPE_OPAQUE) {
- nni_mtx_unlock(&s->s_mx);
- return (NNG_EBADTYPE);
- }
- if (*szp != sopt->sz) {
- nni_mtx_unlock(&s->s_mx);
- return (NNG_EINVAL);
- }
+ if (t != sopt->typ) {
+ nni_mtx_unlock(&s->s_mx);
+ return (NNG_EBADTYPE);
}
if (szp != NULL) {