~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjlib/include/pj/addr_resolv.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: addr_resolv.h 4218 2012-08-07 02:18:15Z bennylp $ */
2
 
/* 
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19
 
 */
20
 
#ifndef __PJ_ADDR_RESOLV_H__
21
 
#define __PJ_ADDR_RESOLV_H__
22
 
 
23
 
/**
24
 
 * @file addr_resolv.h
25
 
 * @brief IP address resolution.
26
 
 */
27
 
 
28
 
#include <pj/sock.h>
29
 
 
30
 
PJ_BEGIN_DECL
31
 
 
32
 
/**
33
 
 * @defgroup pj_addr_resolve Network Address Resolution
34
 
 * @ingroup PJ_IO
35
 
 * @{
36
 
 *
37
 
 * This module provides function to resolve Internet address of the
38
 
 * specified host name. To resolve a particular host name, application
39
 
 * can just call #pj_gethostbyname().
40
 
 *
41
 
 * Example:
42
 
 * <pre>
43
 
 *   ...
44
 
 *   pj_hostent he;
45
 
 *   pj_status_t rc;
46
 
 *   pj_str_t host = pj_str("host.example.com");
47
 
 *   
48
 
 *   rc = pj_gethostbyname( &host, &he);
49
 
 *   if (rc != PJ_SUCCESS) {
50
 
 *      char errbuf[80];
51
 
 *      pj_strerror( rc, errbuf, sizeof(errbuf));
52
 
 *      PJ_LOG(2,("sample", "Unable to resolve host, error=%s", errbuf));
53
 
 *      return rc;
54
 
 *   }
55
 
 *
56
 
 *   // process address...
57
 
 *   addr.sin_addr.s_addr = *(pj_uint32_t*)he.h_addr;
58
 
 *   ...
59
 
 * </pre>
60
 
 *
61
 
 * It's pretty simple really...
62
 
 */
63
 
 
64
 
/** This structure describes an Internet host address. */
65
 
typedef struct pj_hostent
66
 
{
67
 
    char    *h_name;            /**< The official name of the host. */
68
 
    char   **h_aliases;         /**< Aliases list. */
69
 
    int      h_addrtype;        /**< Host address type. */
70
 
    int      h_length;          /**< Length of address. */
71
 
    char   **h_addr_list;       /**< List of addresses. */
72
 
} pj_hostent;
73
 
 
74
 
/** Shortcut to h_addr_list[0] */
75
 
#define h_addr h_addr_list[0]
76
 
 
77
 
/** 
78
 
 * This structure describes address information pj_getaddrinfo().
79
 
 */
80
 
typedef struct pj_addrinfo
81
 
{
82
 
    char         ai_canonname[PJ_MAX_HOSTNAME]; /**< Canonical name for host*/
83
 
    pj_sockaddr  ai_addr;                       /**< Binary address.        */
84
 
} pj_addrinfo;
85
 
 
86
 
 
87
 
/**
88
 
 * This function fills the structure of type pj_hostent for a given host name.
89
 
 * For host resolution function that also works with IPv6, please see
90
 
 * #pj_getaddrinfo().
91
 
 *
92
 
 * @param name      Host name to resolve. Specifying IPv4 address here
93
 
 *                  may fail on some platforms (e.g. Windows)
94
 
 * @param he        The pj_hostent structure to be filled. Note that
95
 
 *                  the pointers in this structure points to temporary
96
 
 *                  variables which value will be reset upon subsequent
97
 
 *                  invocation.
98
 
 *
99
 
 * @return          PJ_SUCCESS, or the appropriate error codes.
100
 
 */ 
101
 
PJ_DECL(pj_status_t) pj_gethostbyname(const pj_str_t *name, pj_hostent *he);
102
 
 
103
 
 
104
 
/**
105
 
 * Resolve the primary IP address of local host. 
106
 
 *
107
 
 * @param af        The desired address family to query. Valid values
108
 
 *                  are pj_AF_INET() or pj_AF_INET6().
109
 
 * @param addr      On successful resolution, the address family and address
110
 
 *                  part of this socket address will be filled up with the host
111
 
 *                  IP address, in network byte order. Other parts of the socket
112
 
 *                  address are untouched.
113
 
 *
114
 
 * @return          PJ_SUCCESS on success, or the appropriate error code.
115
 
 */
116
 
PJ_DECL(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr);
117
 
 
118
 
 
119
 
/**
120
 
 * Get the interface IP address to send data to the specified destination.
121
 
 *
122
 
 * @param af        The desired address family to query. Valid values
123
 
 *                  are pj_AF_INET() or pj_AF_INET6().
124
 
 * @param dst       The destination host.
125
 
 * @param itf_addr  On successful resolution, the address family and address
126
 
 *                  part of this socket address will be filled up with the host
127
 
 *                  IP address, in network byte order. Other parts of the socket
128
 
 *                  address should be ignored.
129
 
 * @param allow_resolve   If \a dst may contain hostname (instead of IP
130
 
 *                  address), specify whether hostname resolution should
131
 
 *                  be performed. If not, default interface address will
132
 
 *                  be returned.
133
 
 * @param p_dst_addr If not NULL, it will be filled with the IP address of
134
 
 *                  the destination host.
135
 
 *
136
 
 * @return          PJ_SUCCESS on success, or the appropriate error code.
137
 
 */
138
 
PJ_DECL(pj_status_t) pj_getipinterface(int af,
139
 
                                       const pj_str_t *dst,
140
 
                                       pj_sockaddr *itf_addr,
141
 
                                       pj_bool_t allow_resolve,
142
 
                                       pj_sockaddr *p_dst_addr);
143
 
 
144
 
/**
145
 
 * Get the IP address of the default interface. Default interface is the
146
 
 * interface of the default route.
147
 
 *
148
 
 * @param af        The desired address family to query. Valid values
149
 
 *                  are pj_AF_INET() or pj_AF_INET6().
150
 
 * @param addr      On successful resolution, the address family and address
151
 
 *                  part of this socket address will be filled up with the host
152
 
 *                  IP address, in network byte order. Other parts of the socket
153
 
 *                  address are untouched.
154
 
 *
155
 
 * @return          PJ_SUCCESS on success, or the appropriate error code.
156
 
 */
157
 
PJ_DECL(pj_status_t) pj_getdefaultipinterface(int af,
158
 
                                              pj_sockaddr *addr);
159
 
 
160
 
 
161
 
/**
162
 
 * This function translates the name of a service location (for example, 
163
 
 * a host name) and returns a set of addresses and associated information
164
 
 * to be used in creating a socket with which to address the specified 
165
 
 * service.
166
 
 *
167
 
 * @param af        The desired address family to query. Valid values
168
 
 *                  are pj_AF_INET(), pj_AF_INET6(), or pj_AF_UNSPEC().
169
 
 * @param name      Descriptive name or an address string, such as host
170
 
 *                  name.
171
 
 * @param count     On input, it specifies the number of elements in
172
 
 *                  \a ai array. On output, this will be set with the
173
 
 *                  number of address informations found for the
174
 
 *                  specified name.
175
 
 * @param ai        Array of address info to be filled with the information
176
 
 *                  about the host.
177
 
 *
178
 
 * @return          PJ_SUCCESS on success, or the appropriate error code.
179
 
 */
180
 
PJ_DECL(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *name,
181
 
                                    unsigned *count, pj_addrinfo ai[]);
182
 
 
183
 
 
184
 
 
185
 
/** @} */
186
 
 
187
 
PJ_END_DECL
188
 
 
189
 
#endif  /* __PJ_ADDR_RESOLV_H__ */
190