diff options
| author | Garrett D'Amore <garrett@damore.org> | 2016-12-14 10:21:39 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2016-12-14 10:21:39 -0800 |
| commit | e0543fecaeb01ccdf7512004c54cd72b143b67c8 (patch) | |
| tree | e369ac7c00cb96690327a96e04caaff83b15f658 | |
| parent | 75aee14e2951cfbd4d8d22375a9f4301890da1ee (diff) | |
| download | nng-e0543fecaeb01ccdf7512004c54cd72b143b67c8.tar.gz nng-e0543fecaeb01ccdf7512004c54cd72b143b67c8.tar.bz2 nng-e0543fecaeb01ccdf7512004c54cd72b143b67c8.zip | |
Some endpoint work started.
| -rw-r--r-- | src/core/endpt.h | 37 | ||||
| -rw-r--r-- | src/core/transport.c | 23 | ||||
| -rw-r--r-- | src/core/transport.h | 8 |
3 files changed, 68 insertions, 0 deletions
diff --git a/src/core/endpt.h b/src/core/endpt.h new file mode 100644 index 00000000..4a0921dc --- /dev/null +++ b/src/core/endpt.h @@ -0,0 +1,37 @@ +/* + * Copyright 2016 Garrett D'Amore <garrett@damore.org> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CORE_ENDPT_H +#define CORE_ENDPT_H + +/* + * This file contains definitions for endpoints. + */ + +int nni_endpt_create(nng_endpt_t *, nng_socket_t, const char *); +void nni_endpt_destroy(nng_endpt_t); +int nni_endpt_dial(nng_endpt_t, nng_pipe_t *); +int nni_endpt_listen(nng_endpt_t); +int nni_endpt_accept(nng_endpt_t, nng_pipe_t *); +int nni_endpt_close(nng_endpt_t); + +#endif /* CORE_ENDPT_H */
\ No newline at end of file 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. diff --git a/src/core/transport.h b/src/core/transport.h index 71eb8a28..4edfecf5 100644 --- a/src/core/transport.h +++ b/src/core/transport.h @@ -173,4 +173,12 @@ struct nni_pipe_ops { int (*p_getopt)(void *, int, void *, size_t *); }; +/* + * These APIs are used by the framework internally, and not for use by + * transport implementations. + */ +extern struct nni_transport *nni_transport_find(const char *); +extern void nni_transport_init(void); +extern void nni_transport_fini(void); + #endif /* CORE_TRANSPORT_H */ |
