1 /* GNIO - GLib Network Layer of GIO
3 * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
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 * Authors: Christian Kellner <gicmo@gnome.org>
21 * Samuel Cormier-Iijima <sciyoshi@gmail.com>
28 #include "ginet6address.h"
30 G_DEFINE_TYPE (GInet6Address, g_inet6_address, G_TYPE_INET_ADDRESS);
32 struct _GInet6AddressPrivate {
41 g_inet6_address_finalize (GObject *object)
43 GInet6Address *address G_GNUC_UNUSED = G_INET6_ADDRESS (object);
45 if (G_OBJECT_CLASS (g_inet6_address_parent_class)->finalize)
46 (*G_OBJECT_CLASS (g_inet6_address_parent_class)->finalize) (object);
50 g_inet6_address_dispose (GObject *object)
52 GInet6Address *address G_GNUC_UNUSED = G_INET6_ADDRESS (object);
54 if (G_OBJECT_CLASS (g_inet6_address_parent_class)->dispose)
55 (*G_OBJECT_CLASS (g_inet6_address_parent_class)->dispose) (object);
59 g_inet6_address_class_init (GInet6AddressClass *klass)
61 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
63 g_type_class_add_private (klass, sizeof (GInet6AddressPrivate));
65 gobject_class->finalize = g_inet6_address_finalize;
66 gobject_class->dispose = g_inet6_address_dispose;
70 g_inet6_address_init (GInet6Address *address)
72 address->priv = G_TYPE_INSTANCE_GET_PRIVATE (address,
74 GInet6AddressPrivate);
77 /* ************************************************************************* */
78 /* Public Functions */
81 g_inet6_address_from_string (const char *string)
87 g_inet6_address_to_string (GInet6Address *address)
93 g_inet6_address_from_bytes (guint8 bytes[])
95 GInet6Address *address = G_INET6_ADDRESS (g_object_new (G_TYPE_INET6_ADDRESS, NULL));
97 g_memmove (address->priv->addr.u6_addr8, bytes, 16);
103 g_inet6_address_to_bytes (GInet6Address *address)
109 g_inet6_address_new_loopback (void)
111 guint8 bytes[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
113 return g_inet6_address_from_bytes (bytes);
117 g_inet6_address_new_any (void)