diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-10-02 17:32:11 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-10-03 09:47:08 -0700 |
| commit | 6fef4c1e5bf73ad76e7cdcfb65540f1308045339 (patch) | |
| tree | ca50ca2c27fb2d0a44ee9dc317cc0b673eaf9e66 /src/transport/tcp | |
| parent | 6e945e18f3f3e9b7f9ee614eac6d3bf681f768d9 (diff) | |
| download | nng-6fef4c1e5bf73ad76e7cdcfb65540f1308045339.tar.gz nng-6fef4c1e5bf73ad76e7cdcfb65540f1308045339.tar.bz2 nng-6fef4c1e5bf73ad76e7cdcfb65540f1308045339.zip | |
fixes #5 Address properties
Added TCP socket address properties on pipes.
This adds the plumbing for the various platform specifics, and
includes both v4 and v6 handling.
We've included a TCPv6 test as well.
Diffstat (limited to 'src/transport/tcp')
| -rw-r--r-- | src/transport/tcp/tcp.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index 413d8fa5..37bd49c7 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -407,6 +407,32 @@ nni_tcp_pipe_peer(void *arg) } static int +nni_tcp_pipe_getopt_locaddr(void *arg, void *v, size_t *szp) +{ + nni_tcp_pipe *p = arg; + int rv; + nng_sockaddr sa; + + if ((rv = nni_plat_tcp_pipe_sockname(p->tpp, &sa)) == 0) { + rv = nni_getopt_sockaddr(&sa, v, szp); + } + return (rv); +} + +static int +nni_tcp_pipe_getopt_remaddr(void *arg, void *v, size_t *szp) +{ + nni_tcp_pipe *p = arg; + int rv; + nng_sockaddr sa; + + if ((rv = nni_plat_tcp_pipe_peername(p->tpp, &sa)) == 0) { + rv = nni_getopt_sockaddr(&sa, v, szp); + } + return (rv); +} + +static int nni_tcp_parse_pair(char *pair, char **hostp, char **servp) { char *host, *serv, *end; @@ -785,10 +811,8 @@ nni_tcp_ep_getopt_linger(void *arg, void *v, size_t *szp) } static nni_tran_pipe_option nni_tcp_pipe_options[] = { -#if 0 - { NNG_OPT_LOCADDR, nni_tcp_pipe_get_locaddr }, - { NNG_OPT_REMADDR, nni_tcp_pipe_get_remaddr }, -#endif + { NNG_OPT_LOCADDR, nni_tcp_pipe_getopt_locaddr }, + { NNG_OPT_REMADDR, nni_tcp_pipe_getopt_remaddr }, // terminate list { NULL, NULL } }; |
