1 /* GNIO - GLib Network Layer of GIO
3 * Copyright (C) 2008 Christian Kellner
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Christian Kellner <gicmo@gnome.org>
26 #include "ginetaddress.h"
29 * SECTION:ginetaddress
30 * @short_description: Base class for implementing IPv4/IPv6 classes
36 G_DEFINE_ABSTRACT_TYPE (GInetAddress, g_inet_address, G_TYPE_OBJECT);
54 g_inet_address_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
56 GInetAddress *address = G_INET_ADDRESS (object);
61 g_value_set_boolean (value, G_INET_ADDRESS_GET_CLASS (address)->is_any (address));
64 case PROP_IS_LINKLOCAL:
65 g_value_set_boolean (value, G_INET_ADDRESS_GET_CLASS (address)->is_linklocal (address));
68 case PROP_IS_LOOPBACK:
69 g_value_set_boolean (value, G_INET_ADDRESS_GET_CLASS (address)->is_loopback (address));
73 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
78 g_inet_address_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
80 GInetAddress *address G_GNUC_UNUSED = G_INET_ADDRESS (object);
85 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
90 g_inet_address_class_init (GInetAddressClass *klass)
92 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
94 gobject_class->get_property = g_inet_address_get_property;
95 gobject_class->set_property = g_inet_address_set_property;
97 g_object_class_install_property (gobject_class, PROP_IS_ANY,
98 g_param_spec_boolean ("is-any",
102 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
104 g_object_class_install_property (gobject_class, PROP_IS_LINKLOCAL,
105 g_param_spec_boolean ("is-link-local",
109 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
111 g_object_class_install_property (gobject_class, PROP_IS_LOOPBACK,
112 g_param_spec_boolean ("is-loopback",
116 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
118 g_object_class_install_property (gobject_class, PROP_IS_SITELOCAL,
119 g_param_spec_boolean ("is-site-local",
123 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
125 g_object_class_install_property (gobject_class, PROP_IS_MULTICAST,
126 g_param_spec_boolean ("is-multicast",
130 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
132 g_object_class_install_property (gobject_class, PROP_IS_MC_GLOBAL,
133 g_param_spec_boolean ("is-mc-global",
137 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
139 g_object_class_install_property (gobject_class, PROP_IS_MC_LINKLOCAL,
140 g_param_spec_boolean ("is-mc-link-local",
144 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
146 g_object_class_install_property (gobject_class, PROP_IS_MC_NODELOCAL,
147 g_param_spec_boolean ("is-mc-node-local",
151 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
153 g_object_class_install_property (gobject_class, PROP_IS_MC_ORGLOCAL,
154 g_param_spec_boolean ("is-mc-org-local",
158 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
160 g_object_class_install_property (gobject_class, PROP_IS_MC_SITELOCAL,
161 g_param_spec_boolean ("is-mc-site-local",
165 G_PARAM_READABLE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME));
169 g_inet_address_init (GInetAddress *address)
174 /* ******************************************* */
175 /* Getters for properties */
178 get_boolean_property (GInetAddress *address, const gchar *property)
182 g_return_val_if_fail (G_IS_INET_ADDRESS (address), FALSE);
184 g_object_get (address, property, &value, NULL);
190 g_inet_address_is_any (GInetAddress *address)
192 return get_boolean_property (address, "is-any");
196 g_inet_address_is_linklocal (GInetAddress *address)
198 return get_boolean_property (address, "is-link-local");
202 g_inet_address_is_loopback (GInetAddress *address)
204 return get_boolean_property (address, "is-loopback");
208 g_inet_address_is_sitelocal (GInetAddress *address)
210 return get_boolean_property (address, "is-site-local");
214 g_inet_address_is_multicast (GInetAddress *address)
216 return get_boolean_property (address, "is-multicast");
220 g_inet_address_is_mc_global (GInetAddress *address)
222 return get_boolean_property (address, "is-mc-global");
226 g_inet_address_is_mc_linklocal (GInetAddress *address)
228 return get_boolean_property (address, "is-mc-link-local");
232 g_inet_address_is_mc_nodelocal (GInetAddress *address)
234 return get_boolean_property (address, "is-mc-node-local");
238 g_inet_address_is_mc_orglocal (GInetAddress *address)
240 return get_boolean_property (address, "is-mc-org-local");
244 g_inet_address_is_mc_sitelocal (GInetAddress *address)
246 return get_boolean_property (address, "is-mc-site-local");