diff options
Diffstat (limited to 'src/core/transport.c')
| -rw-r--r-- | src/core/transport.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <string.h> + #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 "<scheme>://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. |
