Annotation of rpl/src/getaddrinfo.h, revision 1.1

1.1     ! bertrand    1: /*
        !             2: ================================================================================
        !             3:   RPL/2 (R) version 4.0.18
        !             4:   Copyright (C) 1989-2010 Dr. BERTRAND Joël
        !             5: 
        !             6:   This file is part of RPL/2.
        !             7: 
        !             8:   RPL/2 is free software; you can redistribute it and/or modify it
        !             9:   under the terms of the CeCILL V2 License as published by the french
        !            10:   CEA, CNRS and INRIA.
        !            11:  
        !            12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
        !            13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
        !            14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
        !            15:   for more details.
        !            16:  
        !            17:   You should have received a copy of the CeCILL License
        !            18:   along with RPL/2. If not, write to info@cecill.info.
        !            19: ================================================================================
        !            20: */
        !            21: 
        !            22: /*
        !            23:  * Copyright (c) 2001, 02  Motoyuki Kasahara
        !            24:  *
        !            25:  * Redistribution and use in source and binary forms, with or without
        !            26:  * modification, are permitted provided that the following conditions
        !            27:  * are met:
        !            28:  * 1. Redistributions of source code must retain the above copyright
        !            29:  *    notice, this list of conditions and the following disclaimer.
        !            30:  * 2. Redistributions in binary form must reproduce the above copyright
        !            31:  *    notice, this list of conditions and the following disclaimer in the
        !            32:  *    documentation and/or other materials provided with the distribution.
        !            33:  * 3. Neither the name of the project nor the names of its contributors
        !            34:  *    may be used to endorse or promote products derived from this software
        !            35:  *    without specific prior written permission.
        !            36:  *
        !            37:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
        !            38:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            39:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            40:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
        !            41:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            42:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            43:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            44:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            45:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            46:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            47:  * SUCH DAMAGE.
        !            48:  */
        !            49: 
        !            50: #ifndef GETADDRINFO_H
        !            51: #define GETADDRINFO_H
        !            52: 
        !            53: #ifdef HAVE_CONFIG_H
        !            54: #include "config.h"
        !            55: #endif
        !            56: 
        !            57: #include <sys/types.h>
        !            58: 
        !            59: #ifdef WIN32
        !            60: #include <time.h>
        !            61: #include <winsock2.h>
        !            62: #ifdef DO_IPV6
        !            63: #include <ws2tcpip.h>
        !            64: #endif  /* DO_IPV6 */
        !            65: #include <windows.h>
        !            66: #else
        !            67: #include <sys/socket.h>
        !            68: #include <netdb.h>
        !            69: #endif
        !            70: 
        !            71: #ifdef __INNOTEK_LIBC__
        !            72: typedef int socklen_t;
        !            73: #endif
        !            74: 
        !            75: /********************************************************************/
        !            76: /*
        !            77:  * Undefine all the macros.
        !            78:  * <netdb.h> might defines some of them.
        !            79:  */
        !            80: #ifdef EAI_ADDRFAMILY
        !            81: #undef EAI_ADDRFAMILY
        !            82: #endif
        !            83: #ifdef EAI_AGAIN
        !            84: #undef EAI_AGAIN
        !            85: #endif
        !            86: #ifdef EAI_BADFLAGS
        !            87: #undef EAI_BADFLAGS
        !            88: #endif
        !            89: #ifdef EAI_FAIL
        !            90: #undef EAI_FAIL
        !            91: #endif
        !            92: #ifdef EAI_FAMILY
        !            93: #undef EAI_FAMILY
        !            94: #endif
        !            95: #ifdef EAI_MEMORY
        !            96: #undef EAI_MEMORY
        !            97: #endif
        !            98: #ifdef EAI_NONAME
        !            99: #undef EAI_NONAME
        !           100: #endif
        !           101: #ifdef EAI_OVERFLOW
        !           102: #undef EAI_OVERFLOW
        !           103: #endif
        !           104: #ifdef EAI_SERVICE
        !           105: #undef EAI_SERVICE
        !           106: #endif
        !           107: #ifdef EAI_SOCKTYPE
        !           108: #undef EAI_SOCKTYPE
        !           109: #endif
        !           110: #ifdef EAI_SYSTEM
        !           111: #undef EAI_SYSTEM
        !           112: #endif
        !           113: 
        !           114: #ifdef AI_PASSIVE
        !           115: #undef AI_PASSIVE
        !           116: #endif
        !           117: #ifdef AI_CANONNAME
        !           118: #undef AI_CANONNAME
        !           119: #endif
        !           120: #ifdef AI_NUMERICHOST
        !           121: #undef AI_NUMERICHOST
        !           122: #endif
        !           123: #ifdef AI_NUMERICSERV
        !           124: #undef AI_NUMERICSERV
        !           125: #endif
        !           126: #ifdef AI_V4MAPPED
        !           127: #undef AI_V4MAPPED
        !           128: #endif
        !           129: #ifdef AI_ALL
        !           130: #undef AI_ALL
        !           131: #endif
        !           132: #ifdef AI_ADDRCONFIG
        !           133: #undef AI_ADDRCONFIG
        !           134: #endif
        !           135: #ifdef AI_DEFAULT
        !           136: #undef AI_DEFAULT
        !           137: #endif
        !           138: 
        !           139: #ifdef NI_NOFQDN
        !           140: #undef NI_NOFQDN
        !           141: #endif
        !           142: #ifdef NI_NUMERICHOST
        !           143: #undef NI_NUMERICHOST
        !           144: #endif
        !           145: #ifdef NI_NAMEREQD
        !           146: #undef NI_NAMEREQD
        !           147: #endif
        !           148: #ifdef NI_NUMERICSERV
        !           149: #undef NI_NUMERICSERV
        !           150: #endif
        !           151: #ifdef NI_NUMERICSCOPE
        !           152: #undef NI_NUMERICSCOPE
        !           153: #endif
        !           154: 
        !           155: #ifdef NI_DGRAM
        !           156: #undef NI_DGRAM
        !           157: #endif
        !           158: #ifdef NI_MAXHOST
        !           159: #undef NI_MAXHOST
        !           160: #endif
        !           161: #ifdef NI_MAXSERV
        !           162: #undef NI_MAXSERV
        !           163: #endif
        !           164: 
        !           165: /*
        !           166:  * Fake struct and function names.
        !           167:  * <netdb.h> might declares all or some of them.
        !           168:  */
        !           169: #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO)
        !           170: #define addrinfo my_addrinfo
        !           171: #define gai_strerror my_gai_strerror
        !           172: #define freeaddrinfo my_freeaddrinfo
        !           173: #define getaddrinfo my_getaddrinfo
        !           174: #define getnameinfo my_getnameinfo
        !           175: #endif
        !           176: 
        !           177: /********************************************************************/
        !           178: /*
        !           179:  * Error codes.
        !           180:  */
        !           181: #define EAI_ADDRFAMILY 1
        !           182: #define EAI_AGAIN  2
        !           183: #define EAI_BADFLAGS   3
        !           184: #define EAI_FAIL   4
        !           185: #define EAI_FAMILY 5
        !           186: #define EAI_MEMORY 6
        !           187: #define EAI_NONAME 7
        !           188: #define EAI_OVERFLOW   8
        !           189: #define EAI_SERVICE    9
        !           190: #define EAI_SOCKTYPE   10
        !           191: #define EAI_SYSTEM 11
        !           192: 
        !           193: /*
        !           194:  * Flags for getaddrinfo().
        !           195:  */
        !           196: #define AI_ADDRCONFIG  0x0001
        !           197: #define AI_ALL     0x0002
        !           198: #define AI_CANONNAME   0x0004
        !           199: #define AI_NUMERICHOST 0x0008
        !           200: #define AI_NUMERICSERV 0x0010
        !           201: #define AI_PASSIVE 0x0020
        !           202: #define AI_V4MAPPED    0x0040
        !           203: #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
        !           204: 
        !           205: /*
        !           206:  * Flags for getnameinfo().
        !           207:  */
        !           208: #define NI_DGRAM   0x0001
        !           209: #define NI_NAMEREQD    0x0002
        !           210: #define NI_NOFQDN  0x0004
        !           211: #define NI_NUMERICHOST 0x0008
        !           212: #define NI_NUMERICSCOPE    0x0010
        !           213: #define NI_NUMERICSERV 0x0020
        !           214: 
        !           215: /*
        !           216:  * Maximum length of FQDN and servie name for getnameinfo().
        !           217:  */
        !           218: #define NI_MAXHOST 1025
        !           219: #define NI_MAXSERV 32
        !           220: 
        !           221: /*
        !           222:  * Address families and Protocol families.
        !           223:  */
        !           224: #ifndef AF_UNSPEC
        !           225: #define AF_UNSPEC AF_INET
        !           226: #endif
        !           227: #ifndef PF_UNSPEC
        !           228: #define PF_UNSPEC PF_INET
        !           229: #endif
        !           230: 
        !           231: /*
        !           232:  * struct addrinfo.
        !           233:  */
        !           234: struct addrinfo {
        !           235:     int ai_flags;
        !           236:     int ai_family;
        !           237:     int ai_socktype;
        !           238:     int ai_protocol;
        !           239:     socklen_t ai_addrlen;
        !           240:     char *ai_canonname;
        !           241:     struct sockaddr *ai_addr;
        !           242:     struct addrinfo *ai_next;
        !           243: };
        !           244: 
        !           245: /*
        !           246:  * Functions.
        !           247:  */
        !           248: #ifdef __STDC__
        !           249: #if defined (__cplusplus)
        !           250: extern "C" {
        !           251: #endif
        !           252: const char *gai_strerror(int);
        !           253: void freeaddrinfo(struct addrinfo *);
        !           254: int getaddrinfo(const char *, const char *, const struct addrinfo *,
        !           255:     struct addrinfo **);
        !           256: int getnameinfo(const struct sockaddr *, socklen_t, char *, 
        !           257:     socklen_t, char *, socklen_t, int);
        !           258: #if defined (__cplusplus)
        !           259: }
        !           260: #endif
        !           261: #else
        !           262: const char *gai_strerror();
        !           263: void freeaddrinfo();
        !           264: int getaddrinfo();
        !           265: int getnameinfo();
        !           266: #endif
        !           267: 
        !           268: #endif /* not GETADDRINFO_H */
        !           269: 
        !           270: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>