aboutsummaryrefslogtreecommitdiff
path: root/src/nng.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-24 14:15:48 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-24 14:20:34 -0700
commitc9a68bfe6bea2acc708bf49045f6cb65017a3306 (patch)
treee2b93b81b2962bdfb7953cb30fcfae08f0bd4093 /src/nng.c
parent68ff9c823d3cead2b11a003c40c8f5affc11dc71 (diff)
downloadnng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.gz
nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.bz2
nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.zip
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.
Diffstat (limited to 'src/nng.c')
-rw-r--r--src/nng.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nng.c b/src/nng.c
index 191c83fb..ca686686 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -881,12 +881,14 @@ nng_msg_getopt(nng_msg *msg, int opt, void *ptr, size_t *szp)
int
nng_option_lookup(const char *name)
{
+ (void) nni_init();
return (nni_option_lookup(name));
}
const char *
nng_option_name(int id)
{
+ (void) nni_init();
return (nni_option_name(id));
}
@@ -990,3 +992,49 @@ nng_thread_destroy(void *arg)
NNI_FREE_STRUCT(thr);
}
+
+// Constant option definitions. These are for well-known options,
+// so that the vast majority of consumers don't have to look these up.
+
+const char *nng_opt_raw = "raw";
+const char *nng_opt_linger = "linger";
+const char *nng_opt_recvbuf = "recv-buffer";
+const char *nng_opt_sendbuf = "send-buffer";
+const char *nng_opt_recvtimeo = "recv-timeout";
+const char *nng_opt_sendtimeo = "send-timeout";
+const char *nng_opt_recvmaxsz = "recv-size-max";
+const char *nng_opt_reconnmint = "reconnect-time-min";
+const char *nng_opt_reconnmaxt = "reconnect-time-min";
+const char *nng_opt_maxttl = "ttl-max";
+const char *nng_opt_protocol = "protocol";
+const char *nng_opt_transport = "transport";
+const char *nng_opt_recvfd = "recv-fd";
+const char *nng_opt_sendfd = "send-fd";
+const char *nng_opt_locaddr = "local-address";
+const char *nng_opt_remaddr = "remote-address";
+// Well known protocol options.
+const char *nng_opt_req_resendtime = "req:resend-time";
+const char *nng_opt_sub_subscribe = "sub:subscribe";
+const char *nng_opt_sub_unsubscribe = "sub:unsubscribe";
+const char *nng_opt_surveyor_surveytime = "surveyor:survey-time";
+
+int nng_optid_raw;
+int nng_optid_linger;
+int nng_optid_recvbuf;
+int nng_optid_sendbuf;
+int nng_optid_recvtimeo;
+int nng_optid_sendtimeo;
+int nng_optid_recvmaxsz;
+int nng_optid_reconnmint;
+int nng_optid_reconnmaxt;
+int nng_optid_maxttl;
+int nng_optid_protocol;
+int nng_optid_transport;
+int nng_optid_recvfd;
+int nng_optid_sendfd;
+int nng_optid_locaddr;
+int nng_optid_remaddr;
+int nng_optid_req_resendtime;
+int nng_optid_sub_subscribe;
+int nng_optid_sub_unsubscribe;
+int nng_optid_surveyor_surveytime;