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/transport/tcp/tcp.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/transport/tcp') diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index a74f1097..5741beea 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -776,10 +776,20 @@ nni_tcp_ep_getopt_linger(void *arg, void *v, size_t *szp) } static nni_tran_pipe_option nni_tcp_pipe_options[] = { - { NNG_OPT_LOCADDR, nni_tcp_pipe_getopt_locaddr }, - { NNG_OPT_REMADDR, nni_tcp_pipe_getopt_remaddr }, + { + .po_name = NNG_OPT_LOCADDR, + .po_type = NNI_TYPE_SOCKADDR, + .po_getopt = nni_tcp_pipe_getopt_locaddr, + }, + { + .po_name = NNG_OPT_REMADDR, + .po_type = NNI_TYPE_SOCKADDR, + .po_getopt = nni_tcp_pipe_getopt_remaddr, + }, // terminate list - { NULL, NULL } + { + .po_name = NULL, + }, }; static nni_tran_pipe nni_tcp_pipe_ops = { @@ -795,21 +805,26 @@ static nni_tran_pipe nni_tcp_pipe_ops = { static nni_tran_ep_option nni_tcp_ep_options[] = { { .eo_name = NNG_OPT_RECVMAXSZ, + .eo_type = NNI_TYPE_SIZE, .eo_getopt = nni_tcp_ep_getopt_recvmaxsz, .eo_setopt = nni_tcp_ep_setopt_recvmaxsz, }, { .eo_name = NNG_OPT_URL, + .eo_type = NNI_TYPE_STRING, .eo_getopt = nni_tcp_ep_getopt_url, .eo_setopt = NULL, }, { .eo_name = NNG_OPT_LINGER, + .eo_type = NNI_TYPE_DURATION, .eo_getopt = nni_tcp_ep_getopt_linger, .eo_setopt = nni_tcp_ep_setopt_linger, }, // terminate list - { NULL, NULL, NULL }, + { + .eo_name = NULL, + }, }; static nni_tran_ep nni_tcp_ep_ops = { -- cgit v1.2.3-70-g09d2