/usr/include/nice/address.h is in libnice-dev 0.1.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | /*
* This file is part of the Nice GLib ICE library.
*
* (C) 2006-2009 Collabora Ltd.
* Contact: Youness Alaoui
* (C) 2006-2009 Nokia Corporation. All rights reserved.
* Contact: Kai Vehmanen
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
* Contributors:
* Youness Alaoui, Collabora Ltd.
* Dafydd Harries, Collabora Ltd.
* Kai Vehmanen
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifndef __LIBNICE_ADDRESS_H__
#define __LIBNICE_ADDRESS_H__
/**
* SECTION:address
* @short_description: IP address convenience library
* @stability: Stable
*
* The #NiceAddress structure will allow you to easily set/get and modify an IPv4
* or IPv6 address in order to communicate with the #NiceAgent.
*/
#include <glib.h>
#ifdef G_OS_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
G_BEGIN_DECLS
/**
* NiceAddress:
*
* The #NiceAddress structure that represents an IPv4 or IPv6 address.
*/
struct _NiceAddress
{
union
{
struct sockaddr addr;
struct sockaddr_in ip4;
struct sockaddr_in6 ip6;
} s;
};
/**
* NICE_ADDRESS_STRING_LEN:
*
* The maximum string length representation of an address.
* When using nice_address_to_string() make sure the string has a size of
* at least %NICE_ADDRESS_STRING_LEN
*/
#define NICE_ADDRESS_STRING_LEN INET6_ADDRSTRLEN
typedef struct _NiceAddress NiceAddress;
/**
* nice_address_init:
* @addr: The #NiceAddress to init
*
* Initialize a #NiceAddress into an undefined address
*/
void
nice_address_init (NiceAddress *addr);
/**
* nice_address_new:
*
* Create a new #NiceAddress with undefined address
* You must free it with nice_address_free()
*
* Returns: The new #NiceAddress
*/
NiceAddress *
nice_address_new (void);
/**
* nice_address_free:
* @addr: The #NiceAddress to free
*
* Frees a #NiceAddress created with nice_address_new() or nice_address_dup()
*/
void
nice_address_free (NiceAddress *addr);
/**
* nice_address_dup:
* @addr: The #NiceAddress to dup
*
* Creates a new #NiceAddress with the same address as @addr
*
* Returns: The new #NiceAddress
*/
NiceAddress *
nice_address_dup (const NiceAddress *addr);
/**
* nice_address_set_ipv4:
* @addr: The #NiceAddress to modify
* @addr_ipv4: The IPv4 address
*
* Set @addr to an IPv4 address using the data from @addr_ipv4
*
<note>
<para>
This function will reset the port to 0, so make sure you call it before
nice_address_set_port()
</para>
</note>
*/
void
nice_address_set_ipv4 (NiceAddress *addr, guint32 addr_ipv4);
/**
* nice_address_set_ipv6:
* @addr: The #NiceAddress to modify
* @addr_ipv6: The IPv6 address
*
* Set @addr to an IPv6 address using the data from @addr_ipv6
*
<note>
<para>
This function will reset the port to 0, so make sure you call it before
nice_address_set_port()
</para>
</note>
*/
void
nice_address_set_ipv6 (NiceAddress *addr, const guchar *addr_ipv6);
/**
* nice_address_set_port:
* @addr: The #NiceAddress to modify
* @port: The port to set
*
* Set the port of @addr to @port
*/
void
nice_address_set_port (NiceAddress *addr, guint port);
/**
* nice_address_get_port:
* @addr: The #NiceAddress to query
*
* Retreive the port of @addr
*
* Returns: The port of @addr
*/
guint
nice_address_get_port (const NiceAddress *addr);
/**
* nice_address_set_from_string:
* @addr: The #NiceAddress to modify
* @str: The string to set
*
* Sets an IPv4 or IPv6 address from the string @str
*
* Returns: %TRUE if success, %FALSE on error
*/
gboolean
nice_address_set_from_string (NiceAddress *addr, const gchar *str);
/**
* nice_address_set_from_sockaddr:
* @addr: The #NiceAddress to modify
* @sin: The sockaddr to set
*
* Sets an IPv4 or IPv6 address from the sockaddr structure @sin
*
*/
void
nice_address_set_from_sockaddr (NiceAddress *addr, const struct sockaddr *sin);
/**
* nice_address_copy_to_sockaddr:
* @addr: The #NiceAddress to query
* @sin: The sockaddr to fill
*
* Fills the sockaddr structure @sin with the address contained in @addr
*
*/
void
nice_address_copy_to_sockaddr (const NiceAddress *addr, struct sockaddr *sin);
/**
* nice_address_equal:
* @a: First #NiceAddress to compare
* @b: Second #NiceAddress to compare
*
* Compares two #NiceAddress structures to see if they contain the same address
* and the same port.
*
* Returns: %TRUE if @a and @b are the same address, %FALSE if they are different
*/
gboolean
nice_address_equal (const NiceAddress *a, const NiceAddress *b);
/**
* nice_address_equal_no_port:
* @a: First #NiceAddress to compare
* @b: Second #NiceAddress to compare
*
* Compares two #NiceAddress structures to see if they contain the same address,
* ignoring the port.
*
* Returns: %TRUE if @a and @b are the same address, %FALSE if they
* are different
*
* Since: 0.1.8
*/
gboolean
nice_address_equal_no_port (const NiceAddress *a, const NiceAddress *b);
/**
* nice_address_to_string:
* @addr: The #NiceAddress to query
* @dst: The string to fill
*
* Transforms the address @addr into a human readable string
*
*/
void
nice_address_to_string (const NiceAddress *addr, gchar *dst);
/**
* nice_address_is_private:
* @addr: The #NiceAddress to query
*
* Verifies if the address in @addr is a private address or not
*
* Returns: %TRUE if @addr is a private address, %FALSE otherwise
*/
gboolean
nice_address_is_private (const NiceAddress *addr);
/**
* nice_address_is_valid:
* @addr: The #NiceAddress to query
*
* Validate whether the #NiceAddress @addr is a valid IPv4 or IPv6 address
*
* Returns: %TRUE if @addr is valid, %FALSE otherwise
*/
G_GNUC_WARN_UNUSED_RESULT
gboolean
nice_address_is_valid (const NiceAddress *addr);
/**
* nice_address_ip_version:
* @addr: The #NiceAddress to query
*
* Returns the IP version of the address
*
* Returns: 4 for IPv4, 6 for IPv6 and 0 for undefined address
*/
G_GNUC_WARN_UNUSED_RESULT
int
nice_address_ip_version (const NiceAddress *addr);
G_END_DECLS
#endif /* __LIBNICE_ADDRESS_H__ */
|