/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2020 Rick Macklem4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#ifndef _RPC_RPCSEC_TLS_H_28#define _RPC_RPCSEC_TLS_H_2930/* System call used by the rpc.tlsclntd(8), rpc.tlsservd(8) daemons. */31int rpctls_syscall(uint64_t);3233/* Flag bits to indicate certificate results. */34#define RPCTLS_FLAGS_HANDSHAKE 0x0135#define RPCTLS_FLAGS_GOTCERT 0x0236#define RPCTLS_FLAGS_SELFSIGNED 0x0437#define RPCTLS_FLAGS_VERIFIED 0x0838#define RPCTLS_FLAGS_DISABLED 0x1039#define RPCTLS_FLAGS_CERTUSER 0x2040#define RPCTLS_FLAGS_HANDSHFAIL 0x404142/* Error return values for upcall rpcs. */43#define RPCTLSERR_OK 044#define RPCTLSERR_NOCLOSE 145#define RPCTLSERR_NOSSL 246#define RPCTLSERR_NOSOCKET 34748#ifdef _KERNEL49/* Functions that perform upcalls to the rpctlsd daemon. */50enum clnt_stat rpctls_connect(CLIENT *newclient, char *certname,51struct socket *so, uint32_t *reterr);52enum clnt_stat rpctls_cl_handlerecord(void *socookie, uint32_t *reterr);53enum clnt_stat rpctls_srv_handlerecord(void *socookie, uint32_t *reterr);54enum clnt_stat rpctls_cl_disconnect(void *socookie, uint32_t *reterr);55enum clnt_stat rpctls_srv_disconnect(void *socookie, uint32_t *reterr);5657/* Initialization function for rpcsec_tls. */58int rpctls_init(void);5960/* Get TLS information function. */61bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run,62bool rpctlssd_run);6364/* String for AUTH_TLS reply verifier. */65#define RPCTLS_START_STRING "STARTTLS"6667/* Macros for VIMAGE. */68/* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */69#define KRPC_VNET_NAME(n) VNET_NAME(n)70#define KRPC_VNET_DECLARE(t, n) VNET_DECLARE(t, n)71#define KRPC_VNET_DEFINE(t, n) VNET_DEFINE(t, n)72#define KRPC_VNET_DEFINE_STATIC(t, n) VNET_DEFINE_STATIC(t, n)73#define KRPC_VNET(n) VNET(n)7475#define CTLFLAG_KRPC_VNET CTLFLAG_VNET7677#define KRPC_CURVNET_SET(n) CURVNET_SET(n)78#define KRPC_CURVNET_SET_QUIET(n) CURVNET_SET_QUIET(n)79#define KRPC_CURVNET_RESTORE() CURVNET_RESTORE()80#define KRPC_TD_TO_VNET(n) TD_TO_VNET(n)8182#endif /* _KERNEL */8384#endif /* _RPC_RPCSEC_TLS_H_ */858687