su
1.13.18
Toggle main menu visibility
Loading...
Searching...
No Matches
su_addrinfo.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the project nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
#ifndef SU_ADDRINFO_H
31
/* Defined when <sofia-sip/su_addrinfo.h> has been included */
32
#define SU_ADDRINFO_H
41
42
#ifndef SU_TYPES_H
43
#include <
sofia-sip/su_types.h
>
44
#endif
45
46
#if SU_HAVE_BSDSOCK
47
#include <netdb.h>
48
#endif
49
50
SOFIA_BEGIN_DECLS
51
52
#if !SU_HAVE_ADDRINFO
53
/*
54
* Error return codes from getaddrinfo()
55
*/
56
#ifndef EAI_ADDRFAMILY
57
#define EAI_ADDRFAMILY 1
/* address family for hostname not supported */
58
#define EAI_AGAIN 2
/* temporary failure in name resolution */
59
#define EAI_BADFLAGS 3
/* invalid value for ai_flags */
60
#define EAI_FAIL 4
/* non-recoverable failure in name resolution */
61
#define EAI_FAMILY 5
/* ai_family not supported */
62
#define EAI_MEMORY 6
/* memory allocation failure */
63
#define EAI_NODATA 7
/* no address associated with hostname */
64
#define EAI_NONAME 8
/* hostname nor servname provided, or not known */
65
#define EAI_SERVICE 9
/* servname not supported for ai_socktype */
66
#define EAI_SOCKTYPE 10
/* ai_socktype not supported */
67
#define EAI_SYSTEM 11
/* system error returned in errno */
68
#define EAI_BADHINTS 12
69
#define EAI_PROTOCOL 13
70
#define EAI_MAX 14
71
#endif
72
73
/*
74
* Flag values for getaddrinfo()
75
*/
76
#ifndef AI_PASSIVE
77
#define AI_PASSIVE 0x00000001
/* get address to use bind() */
78
#define AI_CANONNAME 0x00000002
/* fill ai_canonname */
79
#define AI_NUMERICHOST 0x00000004
/* prevent name resolution */
80
/* valid flags for addrinfo */
81
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
82
83
#define AI_ALL 0x00000100
/* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
84
#define AI_V4MAPPED_CFG 0x00000200
/* accept IPv4-mapped if kernel supports */
85
#define AI_ADDRCONFIG 0x00000400
/* only if any address is assigned */
86
#define AI_V4MAPPED 0x00000800
/* accept IPv4-mapped IPv6 address */
87
/* special recommended flags for getipnodebyname */
88
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
89
#endif
90
91
/*
92
* Constants for getnameinfo()
93
*/
94
#ifndef NI_MAXHOST
95
#define NI_MAXHOST 1025
96
#define NI_MAXSERV 32
97
#endif
98
99
/*
100
* Flag values for getnameinfo()
101
*/
102
#ifndef NI_NOFQDN
103
#define NI_NOFQDN 0x00000001
104
#define NI_NUMERICHOST 0x00000002
105
#define NI_NAMEREQD 0x00000004
106
#define NI_NUMERICSERV 0x00000008
107
#define NI_DGRAM 0x00000010
108
#endif
109
110
struct
addrinfo {
111
int
ai_flags;
/* AI_PASSIVE, AI_CANONNAME */
112
int
ai_family;
/* PF_xxx */
113
int
ai_socktype;
/* SOCK_xxx */
114
int
ai_protocol;
/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
115
size_t
ai_addrlen;
/* length of ai_addr */
116
char
*ai_canonname;
/* canonical name for hostname */
117
struct
sockaddr *ai_addr;
/* binary address */
118
struct
addrinfo *ai_next;
/* next structure in linked list */
119
};
120
#endif
/* SU_WITH_GETADDRINFO */
121
122
#ifndef EAI_BADHINTS
123
#define EAI_BADHINTS 10012
124
#endif
125
#ifndef EAI_PROTOCOL
126
#define EAI_PROTOCOL 10013
127
#endif
128
129
#ifndef AI_MASK
130
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
131
#endif
132
134
typedef
struct
addrinfo
su_addrinfo_t
;
135
137
SOFIAPUBFUN
138
int
su_getaddrinfo
(
char
const
*node,
char
const
*service,
139
su_addrinfo_t
const
*hints,
140
su_addrinfo_t
**res);
142
SOFIAPUBFUN
void
su_freeaddrinfo
(
su_addrinfo_t
*res);
143
145
SOFIAPUBFUN
char
const
*
su_gai_strerror
(
int
errcode);
146
147
union
su_sockaddr_u
;
148
149
SOFIAPUBFUN
150
int
su_getnameinfo(
const
union
su_sockaddr_u
*su,
size_t
sulen,
151
char
*host,
size_t
hostlen,
152
char
*serv,
size_t
servlen,
153
int
flags);
154
155
SOFIA_END_DECLS
156
157
#endif
/* !defined(SU_ADDRINFO_H) */
su_freeaddrinfo
void su_freeaddrinfo(su_addrinfo_t *res)
Free su_addrinfo_t structure allocated by su_getaddrinfo().
Definition
su_addrinfo.c:969
su_gai_strerror
char const * su_gai_strerror(int errcode)
Return string describing address translation error.
Definition
su_addrinfo.c:975
su_addrinfo_t
struct addrinfo su_addrinfo_t
RFC 1576 address info structure.
Definition
su_addrinfo.h:134
su_getaddrinfo
int su_getaddrinfo(char const *node, char const *service, su_addrinfo_t const *hints, su_addrinfo_t **res)
Translate address and service.
Definition
su_addrinfo.c:894
SOFIAPUBFUN
#define SOFIAPUBFUN
SOFIAPUBFUN declares an exported function.
Definition
su_config.h:66
su_types.h
Basic integer types for su library.
su_sockaddr_u
Common socket address structure.
Definition
su.h:157
Sofia-SIP 1.13.18 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.