2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _ADR_STREAM_H
2N/A#define _ADR_STREAM_H
2N/A
2N/A#include <sys/types.h>
2N/A#include <openssl/ssl.h>
2N/A#include <openssl/err.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * A UNIX file descriptor normally is a sufficient abstraction for a
2N/A * connection. Unfortunately, complex layered protocols like SSL
2N/A * require some sort of userland linkage, and short of creating pipes
2N/A * to ourselves and threads to service them, we are no longer able to
2N/A * use file descriptors alone.
2N/A *
2N/A * Here we define a basic stream abstraction. It supports for basic
2N/A * operations: read, write, close, and free. read, write, and close
2N/A * are expected to be asynchronously callable. Traditionally, close
2N/A * and free were combined in close(2), but here we separate them so
2N/A * that streams can be closed in one thread while others are reading or
2N/A * writing without risk of use-after-free. free is obviously not
2N/A * asynchronously callable.
2N/A *
2N/A * Note: this functionality doesn't really fit in libadr, but is
2N/A * required by both protocol-independent portions of the rad daemon and
2N/A * by the rad protocol client code. To economize on libraries we are
2N/A * putting its implementation here until there is a critical mass of
2N/A * similar functionality.
2N/A */
2N/A
2N/Atypedef struct adr_stream adr_stream_t;
2N/A
2N/Aadr_stream_t *adr_stream_create(ssize_t (*)(void *, char *, size_t),
2N/A ssize_t (*)(void *, const char *, size_t),
2N/A void (*)(void *), void (*)(void *), void *);
2N/Assize_t adr_stream_read(adr_stream_t *, char *, size_t);
2N/Assize_t adr_stream_write(adr_stream_t *, const char *, size_t);
2N/Avoid adr_stream_close(adr_stream_t *);
2N/Avoid adr_stream_free(adr_stream_t *);
2N/A
2N/A/*
2N/A * Implementations of file descriptor and SSL streams are provided
2N/A * for convenience.
2N/A */
2N/A
2N/Aadr_stream_t *adr_stream_create_fd(int);
2N/Aadr_stream_t *adr_stream_create_fds(int, int);
2N/Aadr_stream_t *adr_stream_create_ssl(SSL *, int);
2N/Avoid adr_ssl_init(void);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _ADR_STREAM_H */