1296047Soshogbo/*-
2296047Soshogbo * Copyright (c) 2013 The FreeBSD Foundation
3296047Soshogbo * Copyright (c) 2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
4296047Soshogbo * All rights reserved.
5296047Soshogbo *
6296047Soshogbo * This software was developed by Pawel Jakub Dawidek under sponsorship from
7296047Soshogbo * the FreeBSD Foundation.
8296047Soshogbo *
9296047Soshogbo * Redistribution and use in source and binary forms, with or without
10296047Soshogbo * modification, are permitted provided that the following conditions
11296047Soshogbo * are met:
12296047Soshogbo * 1. Redistributions of source code must retain the above copyright
13296047Soshogbo *    notice, this list of conditions and the following disclaimer.
14296047Soshogbo * 2. Redistributions in binary form must reproduce the above copyright
15296047Soshogbo *    notice, this list of conditions and the following disclaimer in the
16296047Soshogbo *    documentation and/or other materials provided with the distribution.
17296047Soshogbo *
18296047Soshogbo * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
19296047Soshogbo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20296047Soshogbo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21296047Soshogbo * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
22296047Soshogbo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23296047Soshogbo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24296047Soshogbo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25296047Soshogbo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26296047Soshogbo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27296047Soshogbo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28296047Soshogbo * SUCH DAMAGE.
29296047Soshogbo *
30296047Soshogbo * $FreeBSD: stable/11/lib/libcasper/libcasper/libcasper_impl.h 370004 2021-06-16 20:30:46Z git2svn $
31296047Soshogbo */
32296047Soshogbo
33296047Soshogbo#ifndef	_LIBCASPER_IMPL_H_
34296047Soshogbo#define	_LIBCASPER_IMPL_H_
35296047Soshogbo
36296047Soshogbo#include <stdbool.h>
37296047Soshogbo
38296047Soshogbo#include "libcasper.h"
39296047Soshogbo#include "libcasper_service.h"
40296047Soshogbo
41296047Soshogbostruct service;
42296047Soshogbostruct service_connection;
43296047Soshogbo
44296047Soshogbobool fd_is_valid(int fd);
45370004Sgit2svnvoid fd_fix_environment(int *fdp);
46296047Soshogbo
47296047Soshogbo/* Private service functions. */
48296047Soshogbostruct service	*service_alloc(const char *name,
49296047Soshogbo		    service_limit_func_t *limitfunc,
50301572Soshogbo		    service_command_func_t *commandfunc, uint64_t flags);
51296047Soshogbovoid		 service_free(struct service *service);
52296047Soshogbovoid		 service_message(struct service *service,
53296047Soshogbo		    struct service_connection *sconn);
54301572Soshogbovoid		 service_start(struct service *service, int sock, int procfd);
55296047Soshogboconst char	*service_name(struct service *service);
56296047Soshogbo
57296047Soshogbo/* Private service connection functions. */
58296047Soshogbostruct service_connection	*service_connection_add(struct service *service,
59296047Soshogbo				    int sock, const nvlist_t *limits);
60296047Soshogbovoid				 service_connection_remove(
61296047Soshogbo				    struct service *service,
62296047Soshogbo				    struct service_connection *sconn);
63296047Soshogboint				 service_connection_clone(
64296047Soshogbo				    struct service *service,
65296047Soshogbo				    struct service_connection *sconn);
66296047Soshogbostruct service_connection	*service_connection_first(
67296047Soshogbo				    struct service *service);
68296047Soshogbostruct service_connection	*service_connection_next(
69296047Soshogbo				    struct service_connection *sconn);
70296047Soshogbocap_channel_t			*service_connection_get_chan(
71296047Soshogbo				    const struct service_connection *sconn);
72296047Soshogboint				 service_connection_get_sock(
73296047Soshogbo				    const struct service_connection *sconn);
74296047Soshogboconst nvlist_t			*service_connection_get_limits(
75296047Soshogbo				    const struct service_connection *sconn);
76296047Soshogbovoid				 service_connection_set_limits(
77296047Soshogbo				    struct service_connection *sconn,
78296047Soshogbo				    nvlist_t *limits);
79296047Soshogbo
80296047Soshogbo/* Private libcasper functions. */
81296047Soshogbovoid	casper_main_loop(int fd);
82296047Soshogbo
83296047Soshogbo#endif	/* !_LIBCASPER_IMPL_H_ */
84