aboutsummaryrefslogtreecommitdiff
path: root/src/transport/ipc/ipc.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-09-20 12:11:53 -0700
committerGarrett D'Amore <garrett@damore.org>2017-09-22 12:33:50 -0700
commite236dc8141f4d00dc926fbfba7739dabf96ebcdd (patch)
tree3c88190966eac4d888008d5076e7edd1817f64a2 /src/transport/ipc/ipc.c
parentf04cfd27e2d67b0fc89b079410fc11b55b6d1979 (diff)
downloadnng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.tar.gz
nng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.tar.bz2
nng-e236dc8141f4d00dc926fbfba7739dabf96ebcdd.zip
More pipe option handling, pipe API support. Url option.
This fleshes most of the pipe API out, making it available to end user code. It also adds a URL option that is independent of the address options (which would be sockaddrs.) Also, we are now setting the pipe for req/rep. The other protocols need to have the same logic added to set the receive pipe on the message. (Pair is already done.)
Diffstat (limited to 'src/transport/ipc/ipc.c')
-rw-r--r--src/transport/ipc/ipc.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 5abd9e3a..b65adfee 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -28,6 +28,7 @@ struct nni_ipc_pipe {
uint16_t peer;
uint16_t proto;
size_t rcvmax;
+ nng_sockaddr sa;
uint8_t txhead[1 + sizeof(uint64_t)];
uint8_t rxhead[1 + sizeof(uint64_t)];
@@ -128,10 +129,13 @@ nni_ipc_pipe_init(nni_ipc_pipe **pipep, nni_ipc_ep *ep, void *ipp)
return (rv);
}
- p->proto = ep->proto;
- p->rcvmax = ep->rcvmax;
- p->ipp = ipp;
- p->addr = ep->addr;
+ p->proto = ep->proto;
+ p->rcvmax = ep->rcvmax;
+ p->ipp = ipp;
+ p->addr = ep->addr;
+ p->sa.s_un.s_path.sa_family = NNG_AF_IPC;
+ nni_strlcpy(p->sa.s_un.s_path.sa_path, p->addr + strlen("ipc://"),
+ sizeof(p->sa.s_un.s_path.sa_path));
*pipep = p;
return (0);
@@ -461,24 +465,20 @@ nni_ipc_pipe_peer(void *arg)
static int
nni_ipc_pipe_getopt(void *arg, int option, void *buf, size_t *szp)
{
-#if 0
- nni_inproc_pipe *pipe = arg;
- size_t len;
-
- switch (option) {
- case NNG_OPT_LOCALADDR:
- case NNG_OPT_REMOTEADDR:
- len = strlen(pipe->addr) + 1;
- if (len > *szp) {
- (void) memcpy(buf, pipe->addr, *szp);
- } else {
- (void) memcpy(buf, pipe->addr, len);
- }
- *szp = len;
- return (0);
+
+ nni_ipc_pipe *pipe = arg;
+ size_t len;
+ int rv;
+
+ if ((option == nng_optid_locaddr) || (option == nng_optid_remaddr)) {
+ rv = nni_getopt_sockaddr(&pipe->sa, buf, szp);
+ } else if (option == nng_optid_recvmaxsz) {
+ rv = nni_getopt_size(pipe->rcvmax, &buf, szp);
+
+ } else {
+ rv = NNG_ENOTSUP;
}
-#endif
- return (NNG_ENOTSUP);
+ return (rv);
}
static void