diff options
author | pjd <pjd@FreeBSD.org> | 2011-01-31 18:35:17 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-01-31 18:35:17 +0000 |
commit | 214239b194b6861580bd58356d9abc3e0e9b50b6 (patch) | |
tree | 6ba0be808ae947b55743d27f5ae29dc66e331979 /sbin/hastd/proto_uds.c | |
parent | d916d2edb510181e3ab25256b84c439c5e1b8498 (diff) | |
download | FreeBSD-src-214239b194b6861580bd58356d9abc3e0e9b50b6.zip FreeBSD-src-214239b194b6861580bd58356d9abc3e0e9b50b6.tar.gz |
Implement two new functions for sending descriptor and receving descriptor
over UNIX domain sockets and socket pairs.
This is in preparation for capsicum.
MFC after: 1 week
Diffstat (limited to 'sbin/hastd/proto_uds.c')
-rw-r--r-- | sbin/hastd/proto_uds.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sbin/hastd/proto_uds.c b/sbin/hastd/proto_uds.c index a114c21..262d0c0 100644 --- a/sbin/hastd/proto_uds.c +++ b/sbin/hastd/proto_uds.c @@ -226,6 +226,32 @@ uds_recv(void *ctx, unsigned char *data, size_t size) } static int +uds_descriptor_send(void *ctx, int fd) +{ + struct uds_ctx *uctx = ctx; + + PJDLOG_ASSERT(uctx != NULL); + PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC); + PJDLOG_ASSERT(uctx->uc_fd >= 0); + PJDLOG_ASSERT(fd >= 0); + + return (proto_common_descriptor_send(uctx->uc_fd, fd)); +} + +static int +uds_descriptor_recv(void *ctx, 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); + PJDLOG_ASSERT(fdp != NULL); + + return (proto_common_descriptor_recv(uctx->uc_fd, fdp)); +} + +static int uds_descriptor(const void *ctx) { const struct uds_ctx *uctx = ctx; @@ -307,6 +333,8 @@ static struct hast_proto uds_proto = { .hp_accept = uds_accept, .hp_send = uds_send, .hp_recv = uds_recv, + .hp_descriptor_send = uds_descriptor_send, + .hp_descriptor_recv = uds_descriptor_recv, .hp_descriptor = uds_descriptor, .hp_local_address = uds_local_address, .hp_remote_address = uds_remote_address, |