1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3 * Authors: Michael Zucchi <notzed@ximian.com>
4 * Jeffrey Stedfast <fejj@ximian.com>
6 * Copyright (C) 2004 Ximian, Inc.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU Lesser General Public
10 * License as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
23 #ifndef CAMEL_NET_UTILS_H
24 #define CAMEL_NET_UTILS_H 1
26 #include <sys/types.h>
29 #include <sys/socket.h>
38 struct _CamelException;
42 /* Some of this is copied from GNU's netdb.h
44 Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
45 This file is part of the GNU C Library.
47 The GNU C Library is free software; you can redistribute it and/or
48 modify it under the terms of the GNU Lesser General Public
49 License as published by the Free Software Foundation; either
50 version 2.1 of the License, or (at your option) any later version.
58 struct sockaddr *ai_addr;
60 struct addrinfo *ai_next;
63 #define AI_CANONNAME 0x0002 /* Request for canonical name. */
64 #define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
66 /* Error values for `getaddrinfo' function. */
67 #define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
68 #define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
69 #define EAI_AGAIN -3 /* Temporary failure in name resolution. */
70 #define EAI_FAIL -4 /* Non-recoverable failure in name res. */
71 #define EAI_NODATA -5 /* No address associated with NAME. */
72 #define EAI_FAMILY -6 /* `ai_family' not supported. */
73 #define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
74 #define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
75 #define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
76 #define EAI_MEMORY -10 /* Memory allocation failure. */
77 #define EAI_SYSTEM -11 /* System error returned in `errno'. */
78 #define EAI_OVERFLOW -12 /* Argument buffer overflow. */
80 #define NI_MAXHOST 1025
83 #define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
84 #define NI_NUMERICSERV 2 /* Don't convert port number to name. */
85 #define NI_NOFQDN 4 /* Only return nodename portion. */
86 #define NI_NAMEREQD 8 /* Don't return numeric addresses. */
87 #define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
91 struct addrinfo *camel_getaddrinfo(const char *name, const char *service,
92 const struct addrinfo *hints, struct _CamelException *ex);
93 void camel_freeaddrinfo(struct addrinfo *host);
94 int camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv,
95 int flags, struct _CamelException *ex);
99 #endif /* CAMEL_NET_UTILS_H */