From e0543fecaeb01ccdf7512004c54cd72b143b67c8 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 14 Dec 2016 10:21:39 -0800 Subject: Some endpoint work started. --- src/core/transport.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/core/transport.c') diff --git a/src/core/transport.c b/src/core/transport.c index c4ac9faf..97d51e23 100644 --- a/src/core/transport.c +++ b/src/core/transport.c @@ -20,6 +20,8 @@ * IN THE SOFTWARE. */ +#include + #include "core/nng_impl.h" /* @@ -33,6 +35,27 @@ static struct nni_transport *transports[] = { NULL }; +struct nni_transport * +nni_transport_find(const char *addr) +{ + /* address is of the form "://blah..." */ + const char *end; + int len; + int i; + struct nni_transport *ops; + + if ((end = strstr(addr, "://")) == NULL) { + return (NULL); + } + len = (int)(end - addr); + for (i = 0; (ops = transports[i]) != NULL; i++) { + if (strncmp(addr, ops->tran_scheme, len) == 0) { + return (ops); + } + } + return (NULL); +} + /* * nni_transport_init initializes the entire transport subsystem, including * each individual transport. -- cgit v1.2.3-70-g09d2