1896052c1SHartmut Brandt /* 2748b5b1eSHartmut Brandt * Copyright (C) 2004-2005 3896052c1SHartmut Brandt * Hartmut Brandt. 4896052c1SHartmut Brandt * All rights reserved. 5896052c1SHartmut Brandt * 6896052c1SHartmut Brandt * Author: Harti Brandt <harti@freebsd.org> 7896052c1SHartmut Brandt * 8896052c1SHartmut Brandt * Redistribution and use in source and binary forms, with or without 9896052c1SHartmut Brandt * modification, are permitted provided that the following conditions 10896052c1SHartmut Brandt * are met: 11896052c1SHartmut Brandt * 1. Redistributions of source code must retain the above copyright 12896052c1SHartmut Brandt * notice, this list of conditions and the following disclaimer. 13896052c1SHartmut Brandt * 2. Redistributions in binary form must reproduce the above copyright 14896052c1SHartmut Brandt * notice, this list of conditions and the following disclaimer in the 15896052c1SHartmut Brandt * documentation and/or other materials provided with the distribution. 16896052c1SHartmut Brandt * 17896052c1SHartmut Brandt * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18896052c1SHartmut Brandt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19896052c1SHartmut Brandt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20896052c1SHartmut Brandt * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 21896052c1SHartmut Brandt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22896052c1SHartmut Brandt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23896052c1SHartmut Brandt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24896052c1SHartmut Brandt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25896052c1SHartmut Brandt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26896052c1SHartmut Brandt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27896052c1SHartmut Brandt * SUCH DAMAGE. 28896052c1SHartmut Brandt * 29748b5b1eSHartmut Brandt * $Begemot: bsnmp/lib/support.h,v 1.2 2005/10/06 07:14:59 brandt_h Exp $ 30896052c1SHartmut Brandt * 31896052c1SHartmut Brandt * Functions that are missing on certain systems. This header file is not 32896052c1SHartmut Brandt * to be installed. 33896052c1SHartmut Brandt */ 34896052c1SHartmut Brandt #ifndef bsnmp_support_h_ 35896052c1SHartmut Brandt #define bsnmp_support_h_ 36896052c1SHartmut Brandt 37896052c1SHartmut Brandt #include <sys/cdefs.h> 38896052c1SHartmut Brandt 39896052c1SHartmut Brandt #ifndef HAVE_ERR_H 40896052c1SHartmut Brandt void err(int, const char *, ...) __printflike(2, 3) __dead2; 41896052c1SHartmut Brandt void errx(int, const char *, ...) __printflike(2, 3) __dead2; 42896052c1SHartmut Brandt 43896052c1SHartmut Brandt void warn(const char *, ...) __printflike(1, 2); 44896052c1SHartmut Brandt void warnx(const char *, ...) __printflike(1, 2); 45896052c1SHartmut Brandt #endif 46896052c1SHartmut Brandt 47896052c1SHartmut Brandt #ifndef HAVE_STRLCPY 48896052c1SHartmut Brandt size_t strlcpy(char *, const char *, size_t); 49896052c1SHartmut Brandt #endif 50896052c1SHartmut Brandt 51896052c1SHartmut Brandt #ifndef HAVE_GETADDRINFO 52896052c1SHartmut Brandt 53896052c1SHartmut Brandt struct addrinfo { 54896052c1SHartmut Brandt u_int ai_flags; 55896052c1SHartmut Brandt int ai_family; 56896052c1SHartmut Brandt int ai_socktype; 57896052c1SHartmut Brandt int ai_protocol; 58896052c1SHartmut Brandt struct sockaddr *ai_addr; 59896052c1SHartmut Brandt int ai_addrlen; 60896052c1SHartmut Brandt struct addrinfo *ai_next; 61896052c1SHartmut Brandt }; 62896052c1SHartmut Brandt #define AI_CANONNAME 0x0001 63896052c1SHartmut Brandt 64896052c1SHartmut Brandt int getaddrinfo(const char *, const char *, const struct addrinfo *, 65896052c1SHartmut Brandt struct addrinfo **); 66896052c1SHartmut Brandt const char *gai_strerror(int); 67896052c1SHartmut Brandt void freeaddrinfo(struct addrinfo *); 68896052c1SHartmut Brandt 69896052c1SHartmut Brandt #endif 70896052c1SHartmut Brandt 71748b5b1eSHartmut Brandt /* 72748b5b1eSHartmut Brandt * For systems with missing stdint.h or inttypes.h 73748b5b1eSHartmut Brandt */ 74748b5b1eSHartmut Brandt #if !defined(INT32_MIN) 75748b5b1eSHartmut Brandt #define INT32_MIN (-0x7fffffff-1) 76748b5b1eSHartmut Brandt #endif 77748b5b1eSHartmut Brandt #if !defined(INT32_MAX) 78748b5b1eSHartmut Brandt #define INT32_MAX (0x7fffffff) 79748b5b1eSHartmut Brandt #endif 80748b5b1eSHartmut Brandt #if !defined(UINT32_MAX) 81748b5b1eSHartmut Brandt #define UINT32_MAX (0xffffffff) 82748b5b1eSHartmut Brandt #endif 83748b5b1eSHartmut Brandt 84748b5b1eSHartmut Brandt /* 85748b5b1eSHartmut Brandt * Systems missing SA_SIZE(). Taken from FreeBSD net/route.h:1.63 86748b5b1eSHartmut Brandt */ 87748b5b1eSHartmut Brandt #ifndef SA_SIZE 88748b5b1eSHartmut Brandt 89748b5b1eSHartmut Brandt #define SA_SIZE(sa) \ 90748b5b1eSHartmut Brandt ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \ 91748b5b1eSHartmut Brandt sizeof(long) : \ 92748b5b1eSHartmut Brandt 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) 93748b5b1eSHartmut Brandt 94748b5b1eSHartmut Brandt #endif 95748b5b1eSHartmut Brandt 96896052c1SHartmut Brandt #endif 97