diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-03-19 16:02:37 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-03-20 09:53:58 -0700 |
| commit | 9ca901c1b70b17d851426483d9f54611cfa8e395 (patch) | |
| tree | a26b11e16f505ccdc77b5ac6681e0f9de705ff20 /src/core/pipe.c | |
| parent | 9b886a9999247d87c9f6d389c3e65a4bd39be010 (diff) | |
| download | nng-9ca901c1b70b17d851426483d9f54611cfa8e395.tar.gz nng-9ca901c1b70b17d851426483d9f54611cfa8e395.tar.bz2 nng-9ca901c1b70b17d851426483d9f54611cfa8e395.zip | |
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.
Diffstat (limited to 'src/core/pipe.c')
| -rw-r--r-- | src/core/pipe.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c index daee3834..40720906 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -289,7 +289,7 @@ nni_pipe_create(nni_ep *ep, void *tdata) } int -nni_pipe_getopt(nni_pipe *p, const char *name, void *val, size_t *szp) +nni_pipe_getopt(nni_pipe *p, const char *name, void *val, size_t *szp, int typ) { nni_tran_pipe_option *po; @@ -297,10 +297,14 @@ nni_pipe_getopt(nni_pipe *p, const char *name, void *val, size_t *szp) if (strcmp(po->po_name, name) != 0) { continue; } + if ((typ != NNI_TYPE_OPAQUE) && + (po->po_type != NNI_TYPE_OPAQUE) && (typ != po->po_type)) { + return (NNG_EBADTYPE); + } return (po->po_getopt(p->p_tran_data, val, szp)); } // Maybe the endpoint knows? - return (nni_ep_getopt(p->p_ep, name, val, szp)); + return (nni_ep_getopt(p->p_ep, name, val, szp, typ)); } void |
