Path: blob/main/lib/libcasper/services/cap_sysctl/cap_sysctl.h
48261 views
/*-1* Copyright (c) 2013 The FreeBSD Foundation2*3* This software was developed by Pawel Jakub Dawidek under sponsorship from4* the FreeBSD Foundation.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _CAP_SYSCTL_H_29#define _CAP_SYSCTL_H_3031#ifdef HAVE_CASPER32#define WITH_CASPER33#endif3435#include <sys/cdefs.h>3637#define CAP_SYSCTL_READ 0x0138#define CAP_SYSCTL_WRITE 0x0239#define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE)40#define CAP_SYSCTL_RECURSIVE 0x044142struct cap_sysctl_limit;43typedef struct cap_sysctl_limit cap_sysctl_limit_t;4445#ifdef WITH_CASPER4647__BEGIN_DECLS4849int cap_sysctl(cap_channel_t *chan, const int *name, u_int namelen, void *oldp,50size_t *oldlenp, const void *newp, size_t newlen);51int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,52size_t *oldlenp, const void *newp, size_t newlen);53int cap_sysctlnametomib(cap_channel_t *chan, const char *name, int *mibp,54size_t *sizep);5556cap_sysctl_limit_t *cap_sysctl_limit_init(cap_channel_t *);57cap_sysctl_limit_t *cap_sysctl_limit_name(cap_sysctl_limit_t *limit,58const char *name, int flags);59cap_sysctl_limit_t *cap_sysctl_limit_mib(cap_sysctl_limit_t *limit,60const int *mibp, u_int miblen, int flags);61int cap_sysctl_limit(cap_sysctl_limit_t *limit);6263__END_DECLS6465#else /* !WITH_CASPER */66static inline int67cap_sysctl(cap_channel_t *chan __unused, const int *name, u_int namelen,68void *oldp, size_t *oldlenp, const void *newp, size_t newlen)69{7071return (sysctl(name, namelen, oldp, oldlenp, newp, newlen));72}7374static inline int75cap_sysctlbyname(cap_channel_t *chan __unused, const char *name,76void *oldp, size_t *oldlenp, const void *newp, size_t newlen)77{7879return (sysctlbyname(name, oldp, oldlenp, newp, newlen));80}8182static inline int83cap_sysctlnametomib(cap_channel_t *chan __unused, const char *name, int *mibp,84size_t *sizep)85{8687return (sysctlnametomib(name, mibp, sizep));88}8990static inline cap_sysctl_limit_t *91cap_sysctl_limit_init(cap_channel_t *limit __unused)92{9394return (NULL);95}9697static inline cap_sysctl_limit_t *98cap_sysctl_limit_name(cap_sysctl_limit_t *limit __unused,99const char *name __unused, int flags __unused)100{101102return (NULL);103}104105static inline cap_sysctl_limit_t *106cap_sysctl_limit_mib(cap_sysctl_limit_t *limit __unused,107const int *mibp __unused, u_int miblen __unused,108int flags __unused)109{110111return (NULL);112}113114static inline int115cap_sysctl_limit(cap_sysctl_limit_t *limit __unused)116{117118return (0);119}120#endif /* WITH_CASPER */121122#endif /* !_CAP_SYSCTL_H_ */123124125