From c9a68bfe6bea2acc708bf49045f6cb65017a3306 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 24 Aug 2017 14:15:48 -0700 Subject: Eliminate legacy option settings, provide easier option IDs. This eliminates all the old #define's or enum values, making all option IDs now totally dynamic, and providing well-known string values for well-behaved applications. We have added tests of some of these options, including lookups, and so forth. We have also fixed a few problems; including at least one crasher bug when the timeouts on reconnect were zero. Protocol specific options are now handled in the protocol. We will be moving the initialization for a few of those well known entities to the protocol startup code, following the PAIRv1 pattern, later. Applications must therefore not depend on the value of the integer IDs, at least until the application has opened a socket of the appropriate type. --- src/nng.h | 67 +++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 23 deletions(-) (limited to 'src/nng.h') diff --git a/src/nng.h b/src/nng.h index e7d7fe2f..77a585cd 100644 --- a/src/nng.h +++ b/src/nng.h @@ -403,29 +403,50 @@ NNG_DECL int nng_respondent0_open(nng_socket *); #define NNG_OPT_SOCKET(c) (c) #define NNG_OPT_TRANSPORT_OPT(t, c) (0x10000 | ((t) << 16) | (c)) -enum nng_opt_enum { - NNG_OPT_RAW = NNG_OPT_SOCKET(0), - NNG_OPT_LINGER = NNG_OPT_SOCKET(1), - NNG_OPT_RCVBUF = NNG_OPT_SOCKET(2), - NNG_OPT_SNDBUF = NNG_OPT_SOCKET(3), - NNG_OPT_RCVTIMEO = NNG_OPT_SOCKET(4), - NNG_OPT_SNDTIMEO = NNG_OPT_SOCKET(5), - NNG_OPT_RECONN_TIME = NNG_OPT_SOCKET(6), - NNG_OPT_RECONN_MAXTIME = NNG_OPT_SOCKET(7), - NNG_OPT_RCVMAXSZ = NNG_OPT_SOCKET(8), - NNG_OPT_MAXTTL = NNG_OPT_SOCKET(9), - NNG_OPT_PROTOCOL = NNG_OPT_SOCKET(10), - NNG_OPT_SUBSCRIBE = NNG_OPT_SOCKET(11), - NNG_OPT_UNSUBSCRIBE = NNG_OPT_SOCKET(12), - NNG_OPT_SURVEYTIME = NNG_OPT_SOCKET(13), - NNG_OPT_RESENDTIME = NNG_OPT_SOCKET(14), - NNG_OPT_TRANSPORT = NNG_OPT_SOCKET(15), - NNG_OPT_LOCALADDR = NNG_OPT_SOCKET(16), - NNG_OPT_REMOTEADDR = NNG_OPT_SOCKET(17), - NNG_OPT_RCVFD = NNG_OPT_SOCKET(18), - NNG_OPT_SNDFD = NNG_OPT_SOCKET(19), -}; - +extern const char *nng_opt_raw; +extern const char *nng_opt_linger; +extern const char *nng_opt_recvbuf; +extern const char *nng_opt_sendbuf; +extern const char *nng_opt_recvtimeo; +extern const char *nng_opt_sendtimeo; +extern const char *nng_opt_recvmaxsz; +extern const char *nng_opt_reconnmint; +extern const char *nng_opt_reconnmaxt; +extern const char *nng_opt_maxttl; +extern const char *nng_opt_protocol; +extern const char *nng_opt_transport; +extern const char *nng_opt_recvfd; +extern const char *nng_opt_sendfd; +extern const char *nng_opt_locaddr; +extern const char *nng_opt_remaddr; +extern const char *nng_opt_req_resendtime; +extern const char *nng_opt_sub_subscribe; +extern const char *nng_opt_sub_unsubscribe; +extern const char *nng_opt_surveyor_surveytime; + +extern int nng_optid_raw; +extern int nng_optid_linger; +extern int nng_optid_recvbuf; +extern int nng_optid_sendbuf; +extern int nng_optid_recvtimeo; +extern int nng_optid_sendtimeo; +extern int nng_optid_recvmaxsz; +extern int nng_optid_reconnmint; +extern int nng_optid_reconnmaxt; +extern int nng_optid_maxttl; +extern int nng_optid_protocol; +extern int nng_optid_transport; +extern int nng_optid_recvfd; +extern int nng_optid_sendfd; +extern int nng_optid_locaddr; +extern int nng_optid_remaddr; + +// These protocol specific options may not be valid until a socket of +// the given protocol is opened! +extern int nng_optid_req_resendtime; +extern int nng_optid_sub_subscribe; +extern int nng_optid_sub_unsubscribe; +extern int nng_optid_surveyor_surveytime; // XXX: TBD: priorities, socket names, ipv4only // Statistics. These are for informational purposes only, and subject -- cgit v1.2.3-70-g09d2