Path: blob/main/lib/libcasper/services/cap_dns/cap_dns.h
48260 views
/*-1* Copyright (c) 2012 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_DNS_H_29#define _CAP_DNS_H_3031#ifdef HAVE_CASPER32#define WITH_CASPER33#endif3435#include <sys/cdefs.h>36#include <sys/socket.h> /* socklen_t */3738/*39* Pull these in if we're just inlining calls to the underlying40* libc functions.41*/42#ifndef WITH_CASPER43#include <sys/types.h>44#include <netdb.h>45#endif /* WITH_CASPER */4647struct addrinfo;48struct hostent;4950#ifdef WITH_CASPER51__BEGIN_DECLS5253struct hostent *cap_gethostbyname(cap_channel_t *chan, const char *name);54struct hostent *cap_gethostbyname2(cap_channel_t *chan, const char *name,55int type);56struct hostent *cap_gethostbyaddr(cap_channel_t *chan, const void *addr,57socklen_t len, int type);5859int cap_getaddrinfo(cap_channel_t *chan, const char *hostname,60const char *servname, const struct addrinfo *hints, struct addrinfo **res);61int cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa,62socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen,63int flags);6465int cap_dns_type_limit(cap_channel_t *chan, const char * const *types,66size_t ntypes);67int cap_dns_family_limit(cap_channel_t *chan, const int *families,68size_t nfamilies);6970__END_DECLS71#else7273static inline struct hostent *74cap_gethostbyname(cap_channel_t *chan __unused, const char *name)75{7677return (gethostbyname(name));78}7980static inline struct hostent *81cap_gethostbyname2(cap_channel_t *chan __unused, const char *name, int type)82{8384return (gethostbyname2(name, type));85}8687static inline struct hostent *88cap_gethostbyaddr(cap_channel_t *chan __unused, const void *addr,89socklen_t len, int type)90{9192return (gethostbyaddr(addr, len, type));93}9495static inline int cap_getaddrinfo(cap_channel_t *chan __unused,96const char *hostname, const char *servname, const struct addrinfo *hints,97struct addrinfo **res)98{99100return (getaddrinfo(hostname, servname, hints, res));101}102103static inline int cap_getnameinfo(cap_channel_t *chan __unused,104const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen,105char *serv, size_t servlen, int flags)106{107108return (getnameinfo(sa, salen, host, hostlen, serv, servlen, flags));109}110111static inline int112cap_dns_type_limit(cap_channel_t *chan __unused,113const char * const *types __unused,114size_t ntypes __unused)115{116117return (0);118}119120static inline int121cap_dns_family_limit(cap_channel_t *chan __unused,122const int *families __unused,123size_t nfamilies __unused)124{125126return (0);127}128#endif /* WITH_CASPER */129130#endif /* !_CAP_DNS_H_ */131132133