2 * This file is part of the Nice GLib ICE library.
4 * (C) 2020 Fabrice Bellet <fabrice@bellet.info>
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Nice GLib ICE library.
18 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
19 * Corporation. All Rights Reserved.
21 * Alternatively, the contents of this file may be used under the terms of the
22 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
23 * case the provisions of LGPL are applicable instead of those above. If you
24 * wish to allow use of your version of this file only under the terms of the
25 * LGPL and not to allow others to use your version of this file under the
26 * MPL, indicate your decision by deleting the provisions above and replace
27 * them with the notice and other provisions required by the LGPL. If you do
28 * not delete the provisions above, a recipient may use your version of this
29 * file under either the MPL or the LGPL.
37 #include "../agent/interfaces.c"
46 struct sockaddr_in in;
47 struct sockaddr_in6 in6;
50 /* test private addresses */
51 nice_address_set_from_string (&addr, "10.1.2.3");
52 nice_address_copy_to_sockaddr (&addr, &sin.addr);
53 g_assert (nice_interfaces_is_private_ip (&sin.addr));
55 nice_address_set_from_string (&addr, "172.22.22.22");
56 nice_address_copy_to_sockaddr (&addr, &sin.addr);
57 g_assert (nice_interfaces_is_private_ip (&sin.addr));
59 nice_address_set_from_string (&addr, "192.168.122.1");
60 nice_address_copy_to_sockaddr (&addr, &sin.addr);
61 g_assert (nice_interfaces_is_private_ip (&sin.addr));
63 nice_address_set_from_string (&addr, "169.254.1.2");
64 nice_address_copy_to_sockaddr (&addr, &sin.addr);
65 g_assert (nice_interfaces_is_private_ip (&sin.addr));
67 /* test public addresses */
68 nice_address_set_from_string (&addr, "1.2.3.4");
69 nice_address_copy_to_sockaddr (&addr, &sin.addr);
70 g_assert (nice_interfaces_is_private_ip (&sin.addr) == FALSE);
80 struct sockaddr_in in;
81 struct sockaddr_in6 in6;
84 /* test private addresses */
85 nice_address_set_from_string (&addr,
86 "fe8f:2233:4455:6677:8899:aabb:ccdd:eeff");
87 nice_address_copy_to_sockaddr (&addr, &sin.addr);
88 g_assert (nice_interfaces_is_private_ip (&sin.addr));
90 /* test public addresses */
91 nice_address_set_from_string (&addr,
92 "11:2233:4455:6677:8899:aabb:ccdd:eeff");
93 nice_address_copy_to_sockaddr (&addr, &sin.addr);
94 g_assert (nice_interfaces_is_private_ip (&sin.addr) == FALSE);
96 #endif /* G_OS_UNIX */