Debian Codegraph @

Xpjproject/pjlib/include/pj/ip_helper.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJ_IP_ROUTE_H__
20 #define __PJ_IP_ROUTE_H__
21
22 /**
23 * @file ip_helper.h
24 * @brief IP helper API
25 */
26
27 #include <pj/sock.h>
28 #include <pj/string.h>
29
30 PJ_BEGIN_DECL
31
32 /**
33 * @defgroup pj_ip_helper IP Interface and Routing Helper
34 * @ingroup PJ_IO
35 * @{
36 *
37 * This module provides functions to query local host's IP interface and
38 * routing table.
39 */
40
41 /**
42 * This structure describes IP routing entry.
43 */
44 typedef union pj_ip_route_entry
45 {
46 /** IP routing entry for IP version 4 routing */
47 struct
48 {
49 pj_in_addr if_addr; /**< Local interface IP address. */
50 pj_in_addr dst_addr; /**< Destination IP address. */
51 pj_in_addr mask; /**< Destination mask. */
52 } ipv4;
53 } pj_ip_route_entry;
54
55 /**
56 * This structure describes options for pj_enum_ip_interface2().
57 */
58 typedef struct pj_enum_ip_option
59 {
60 /**
61 * Family of the address to be retrieved. Application may specify
62 * pj_AF_UNSPEC() to retrieve all addresses, or pj_AF_INET() or
63 * pj_AF_INET6() to retrieve interfaces with specific address family.
64 *
65 * Default: pj_AF_UNSPEC().
66 */
67 int af;
68
69 /**
70 * IPv6 addresses can have a DEPRECATED flag, if this flag is set, any
71 * DEPRECATED IPv6 address will be omitted. Currently this is only
72 * available for Linux, on other platforms, if this flag is set,
73 * pj_enum_ip_interface2() will return PJ_ENOTSUP.
74 *
75 * Default: PJ_FALSE.
76 */
77 pj_bool_t omit_deprecated_ipv6;
78
79 } pj_enum_ip_option;
80
81
82 /**
83 * Get default values of IP enumeration option.
84 *
85 * @param opt The IP enumeration option.
86 */
87 PJ_INLINE(void) pj_enum_ip_option_default(pj_enum_ip_option *opt)
88 {
89 pj_bzero(opt, sizeof(*opt));
90 }
91
92
93 /**
94 * Enumerate the local IP interfaces currently active in the host.
95 *
96 * @param af Family of the address to be retrieved. Application
97 * may specify pj_AF_UNSPEC() to retrieve all addresses,
98 * or pj_AF_INET() or pj_AF_INET6() to retrieve interfaces
99 * with specific address family.
100 * @param count On input, specify the number of entries. On output,
101 * it will be filled with the actual number of entries.
102 * @param ifs Array of socket addresses, which address part will
103 * be filled with the interface address. The address
104 * family part will be initialized with the address
105 * family of the IP address.
106 *
107 * @return PJ_SUCCESS on success, or the appropriate error code.
108 */
109 PJ_DECL(pj_status_t) pj_enum_ip_interface(int af,
110 unsigned *count,
111 pj_sockaddr ifs[]);
112
113
114 /**
115 * Enumerate the local IP interfaces currently active in the host with
116 * capability to filter DEPRECATED IPv6 addresses (currently only for Linux).
117 *
118 * @param opt The option, default option will be used if NULL.
119 * @param count On input, specify the number of entries. On output,
120 * it will be filled with the actual number of entries.
121 * @param ifs Array of socket (with flags) addresses, which address part
122 * will be filled with the interface address. The address
123 * family part will be initialized with the address
124 * family of the IP address.
125 *
126 * @return PJ_SUCCESS on success, or the appropriate error code.
127 */
128 PJ_DECL(pj_status_t) pj_enum_ip_interface2(const pj_enum_ip_option *opt,
129 unsigned *count,
130 pj_sockaddr ifs[]);
131
132 /**
133 * Enumerate the IP routing table for this host.
134 *
135 * @param count On input, specify the number of routes entries. On output,
136 * it will be filled with the actual number of route entries.
137 * @param routes Array of IP routing entries.
138 *
139 * @return PJ_SUCCESS on success, or the appropriate error code.
140 */
141 PJ_DECL(pj_status_t) pj_enum_ip_route(unsigned *count,
142 pj_ip_route_entry routes[]);
143
144
145
146 /** @} */
147
148 PJ_END_DECL
149
150
151 #endif /* __PJ_IP_ROUTE_H__ */
152