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. --- tests/wssfile.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/wssfile.c') diff --git a/tests/wssfile.c b/tests/wssfile.c index 15f7008e..48736117 100644 --- a/tests/wssfile.c +++ b/tests/wssfile.c @@ -144,16 +144,21 @@ check_props(nng_msg *msg) p = nng_msg_get_pipe(msg); So(p > 0); + // Typed z = sizeof(nng_sockaddr); - So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0); + So(nng_pipe_getopt_sockaddr(p, NNG_OPT_LOCADDR, &la) == 0); So(z == sizeof(la)); So(validloopback(&la)); + // Untyped z = sizeof(nng_sockaddr); So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0); So(z == sizeof(ra)); So(validloopback(&ra)); + // Bad type + So(nng_pipe_getopt_size(p, NNG_OPT_LOCADDR, &z) == NNG_EBADTYPE); + // Request header z = 0; buf = NULL; @@ -298,7 +303,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", { char addr[NNG_MAXADDRLEN]; nng_msg * msg; nng_pipe p; - int v; + bool b; So(nng_pair_open(&s1) == 0); So(nng_pair_open(&s2) == 0); @@ -337,8 +342,8 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", { So(strcmp(nng_msg_body(msg), "hello") == 0); p = nng_msg_get_pipe(msg); So(p > 0); - So(nng_pipe_getopt_int(p, NNG_OPT_TLS_VERIFIED, &v) == 0); - So(v == 0); + So(nng_pipe_getopt_bool(p, NNG_OPT_TLS_VERIFIED, &b) == 0); + So(b == false); nng_msg_free(msg); }); @@ -350,7 +355,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", { char addr[NNG_MAXADDRLEN]; nng_msg * msg; nng_pipe p; - int v; + bool b; So(nng_pair_open(&s1) == 0); So(nng_pair_open(&s2) == 0); @@ -379,8 +384,8 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", { So(strcmp(nng_msg_body(msg), "hello") == 0); p = nng_msg_get_pipe(msg); So(p > 0); - So(nng_pipe_getopt_int(p, NNG_OPT_TLS_VERIFIED, &v) == 0); - So(v == 1); + So(nng_pipe_getopt_bool(p, NNG_OPT_TLS_VERIFIED, &b) == 0); + So(b == true); nng_msg_free(msg); }); -- cgit v1.2.3-70-g09d2