196468787SJake Freeland /*-
296468787SJake Freeland * SPDX-License-Identifier: BSD-2-Clause
396468787SJake Freeland *
496468787SJake Freeland * Copyright (c) 2023 The FreeBSD Foundation
596468787SJake Freeland *
696468787SJake Freeland * This software was developed by Jake Freeland <jfree@FreeBSD.org>
796468787SJake Freeland * under sponsorship from the FreeBSD Foundation.
896468787SJake Freeland *
996468787SJake Freeland * Redistribution and use in source and binary forms, with or without
1096468787SJake Freeland * modification, are permitted provided that the following conditions
1196468787SJake Freeland * are met:
1296468787SJake Freeland * 1. Redistributions of source code must retain the above copyright
1396468787SJake Freeland * notice, this list of conditions and the following disclaimer.
1496468787SJake Freeland * 2. Redistributions in binary form must reproduce the above copyright
1596468787SJake Freeland * notice, this list of conditions and the following disclaimer in the
1696468787SJake Freeland * documentation and/or other materials provided with the distribution.
1796468787SJake Freeland *
1896468787SJake Freeland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1996468787SJake Freeland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2096468787SJake Freeland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2196468787SJake Freeland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2296468787SJake Freeland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2396468787SJake Freeland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2496468787SJake Freeland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2596468787SJake Freeland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2696468787SJake Freeland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2796468787SJake Freeland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2896468787SJake Freeland * SUCH DAMAGE.
2996468787SJake Freeland */
3096468787SJake Freeland
3196468787SJake Freeland #include <sys/types.h>
3296468787SJake Freeland #include <sys/socket.h>
3396468787SJake Freeland
3496468787SJake Freeland #include <libcasper.h>
352567168dSJake Freeland #include <string.h>
3696468787SJake Freeland
3796468787SJake Freeland #include <casper/cap_net.h>
3896468787SJake Freeland
3996468787SJake Freeland #include "syslogd_cap.h"
4096468787SJake Freeland
4196468787SJake Freeland /* This is where libcasper receives commands via nvlist. */
4296468787SJake Freeland static int
casper_command(const char * cmd,const nvlist_t * limits __unused,nvlist_t * nvlin,nvlist_t * nvlout)432567168dSJake Freeland casper_command(const char *cmd, const nvlist_t *limits __unused,
442567168dSJake Freeland nvlist_t *nvlin, nvlist_t *nvlout)
4596468787SJake Freeland {
4696468787SJake Freeland int error = EINVAL;
472567168dSJake Freeland
48*61a29ecaSJake Freeland if (strcmp(cmd, "p_open") == 0)
49*61a29ecaSJake Freeland error = casper_p_open(nvlin, nvlout);
50*61a29ecaSJake Freeland else if (strcmp(cmd, "readconfigfile") == 0)
512567168dSJake Freeland error = casper_readconfigfile(nvlin, nvlout);
52*61a29ecaSJake Freeland else if (strcmp(cmd, "ttymsg") == 0)
53*61a29ecaSJake Freeland error = casper_ttymsg(nvlin, nvlout);
54*61a29ecaSJake Freeland else if (strcmp(cmd, "wallmsg") == 0)
55*61a29ecaSJake Freeland error = casper_wallmsg(nvlin);
562567168dSJake Freeland
5796468787SJake Freeland return (error);
5896468787SJake Freeland }
5996468787SJake Freeland
6096468787SJake Freeland CREATE_SERVICE("syslogd.casper", NULL, casper_command, CASPER_SERVICE_STDIO);
61