static int uds_recv(void *ctx, unsigned char *data, size_t size, int *fdp) { struct uds_ctx *uctx = ctx; PJDLOG_ASSERT(uctx != NULL); PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC); PJDLOG_ASSERT(uctx->uc_fd >= 0); return (proto_common_recv(uctx->uc_fd, data, size, fdp)); }
static int tcp_recv(void *ctx, unsigned char *data, size_t size, int *fdp) { struct tcp_ctx *tctx = ctx; PJDLOG_ASSERT(tctx != NULL); PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(fdp == NULL); return (proto_common_recv(tctx->tc_fd, data, size, NULL)); }
static int sp_recv(void *ctx, unsigned char *data, size_t size, int *fdp) { struct sp_ctx *spctx = ctx; int fd; PJDLOG_ASSERT(spctx != NULL); PJDLOG_ASSERT(spctx->sp_magic == SP_CTX_MAGIC); switch (spctx->sp_side) { case SP_SIDE_UNDEF: /* * If the first operation done by the caller is proto_recv(), * we assume this is the server. */ /* FALLTHROUGH */ spctx->sp_side = SP_SIDE_SERVER; /* Close other end. */ close(spctx->sp_fd[0]); spctx->sp_fd[0] = -1; case SP_SIDE_SERVER: PJDLOG_ASSERT(spctx->sp_fd[1] >= 0); fd = spctx->sp_fd[1]; break; case SP_SIDE_CLIENT: PJDLOG_ASSERT(spctx->sp_fd[0] >= 0); fd = spctx->sp_fd[0]; break; default: PJDLOG_ABORT("Invalid socket side (%d).", spctx->sp_side); } /* Someone is just trying to decide about side. */ if (data == NULL) return (0); return (proto_common_recv(fd, data, size, fdp)); }