From 9ca901c1b70b17d851426483d9f54611cfa8e395 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 19 Mar 2018 16:02:37 -0700 Subject: fixes #296 Typed options should validate option type fixes #302 nng_dialer/listener/pipe_getopt_sockaddr desired This adds plumbing to pass and check the type of options all the way through. NNG_ZT_OPT_ORBIT is type UINT64, but you can use the untyped form to pass two of them if needed. No typed access for retrieving strings yet. I think this should allocate a pointer and copy that out, but that's for later. --- src/protocol/reqrep0/rep.c | 6 +++++- src/protocol/reqrep0/req.c | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/protocol/reqrep0') diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c index 9906de4b..429d55e7 100644 --- a/src/protocol/reqrep0/rep.c +++ b/src/protocol/reqrep0/rep.c @@ -476,16 +476,20 @@ static nni_proto_pipe_ops rep0_pipe_ops = { static nni_proto_sock_option rep0_sock_options[] = { { .pso_name = NNG_OPT_RAW, + .pso_type = NNI_TYPE_BOOL, .pso_getopt = rep0_sock_getopt_raw, .pso_setopt = rep0_sock_setopt_raw, }, { .pso_name = NNG_OPT_MAXTTL, + .pso_type = NNI_TYPE_INT32, .pso_getopt = rep0_sock_getopt_maxttl, .pso_setopt = rep0_sock_setopt_maxttl, }, // terminate list - { NULL, NULL, NULL }, + { + .pso_name = NULL, + }, }; static nni_proto_sock_ops rep0_sock_ops = { diff --git a/src/protocol/reqrep0/req.c b/src/protocol/reqrep0/req.c index d87a5d1f..63ae07a0 100644 --- a/src/protocol/reqrep0/req.c +++ b/src/protocol/reqrep0/req.c @@ -629,21 +629,26 @@ static nni_proto_pipe_ops req0_pipe_ops = { static nni_proto_sock_option req0_sock_options[] = { { .pso_name = NNG_OPT_RAW, + .pso_type = NNI_TYPE_BOOL, .pso_getopt = req0_sock_getopt_raw, .pso_setopt = req0_sock_setopt_raw, }, { .pso_name = NNG_OPT_MAXTTL, + .pso_type = NNI_TYPE_INT32, .pso_getopt = req0_sock_getopt_maxttl, .pso_setopt = req0_sock_setopt_maxttl, }, { .pso_name = NNG_OPT_REQ_RESENDTIME, + .pso_type = NNI_TYPE_DURATION, .pso_getopt = req0_sock_getopt_resendtime, .pso_setopt = req0_sock_setopt_resendtime, }, // terminate list - { NULL, NULL, NULL }, + { + .pso_name = NULL, + }, }; static nni_proto_sock_ops req0_sock_ops = { -- cgit v1.2.3-70-g09d2