1
/* GNet - Networking library
2
* Copyright (C) 2000 David Helder
3
* Copyright (C) 2000 Andrew Lanoix
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* 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.
22
#ifndef _GNET_INETADDR_H
23
#define _GNET_INETADDR_H
28
#include <winsock2.h> /* This needs to be here */
33
#endif /* __cplusplus */
38
All fields in GInetAddr are private and should be accessed only by
39
using the functions below.
42
typedef struct _GInetAddr GInetAddr;
51
* GInetAddrAsyncStatus:
53
* Status of a asynchronous lookup (from gnet_inetaddr_new_async()
54
* or gnet_inetaddr_get_name_async()), passed by
55
* GInetAddrNewAsyncFunc or GInetAddrGetNameAsyncFunc. More errors
56
* may be added in the future, so it's best to compare against
57
* %GINETADDR_ASYNC_STATUS_OK.
61
GINETADDR_ASYNC_STATUS_OK,
62
GINETADDR_ASYNC_STATUS_ERROR
63
} GInetAddrAsyncStatus;
68
* GInetAddrNewAsyncID:
70
* ID of an asynchronous InetAddr creation started with
71
* gnet_inetaddr_new_async(). The creation can be canceled by
72
* calling gnet_inetaddr_new_async_cancel() with the ID.
75
typedef gpointer GInetAddrNewAsyncID;
80
* GInetAddrNewAsyncFunc:
81
* @inetaddr: InetAddr that was looked up
82
* @status: Status of the lookup
85
* Callback for gnet_inetaddr_new_async().
88
typedef void (*GInetAddrNewAsyncFunc)(GInetAddr* inetaddr,
89
GInetAddrAsyncStatus status,
95
* GInetAddrGetNameAsyncID:
97
* ID of an asynchronous InetAddr name lookup started with
98
* gnet_inetaddr_get_name_async(). The lookup can be canceled by
99
* calling gnet_inetaddr_get_name_async_cancel() with the ID.
102
typedef gpointer GInetAddrGetNameAsyncID;
107
* GInetAddrGetNameAsyncFunc:
108
* @inetaddr: InetAddr whose was looked up
109
* @status: Status of the lookup
110
* @name: Nice name of the address
113
* Callback for gnet_inetaddr_get_name_async(). Delete the name
114
* when you're done with it.
117
typedef void (*GInetAddrGetNameAsyncFunc)(GInetAddr* inetaddr,
118
GInetAddrAsyncStatus status,
127
GInetAddr* gnet_inetaddr_new (const gchar* name, gint port);
130
gnet_inetaddr_new_async (const gchar* name, gint port,
131
GInetAddrNewAsyncFunc func, gpointer data);
133
void gnet_inetaddr_new_async_cancel (GInetAddrNewAsyncID id);
135
GInetAddr* gnet_inetaddr_new_nonblock (const gchar* name, gint port);
137
GInetAddr* gnet_inetaddr_clone (const GInetAddr* ia);
139
void gnet_inetaddr_delete (GInetAddr* ia);
141
void gnet_inetaddr_ref (GInetAddr* ia);
142
void gnet_inetaddr_unref (GInetAddr* ia);
147
gchar* gnet_inetaddr_get_name (/* const */ GInetAddr* ia);
149
GInetAddrGetNameAsyncID
150
gnet_inetaddr_get_name_async (GInetAddr* ia,
151
GInetAddrGetNameAsyncFunc func,
154
void gnet_inetaddr_get_name_async_cancel (GInetAddrGetNameAsyncID id);
156
gchar* gnet_inetaddr_get_canonical_name (const GInetAddr* ia);
158
gint gnet_inetaddr_get_port (const GInetAddr* ia);
160
void gnet_inetaddr_set_port (const GInetAddr* ia, guint port);
165
gboolean gnet_inetaddr_is_canonical (const gchar* name);
167
gboolean gnet_inetaddr_is_internet (const GInetAddr* inetaddr);
168
gboolean gnet_inetaddr_is_private (const GInetAddr* inetaddr);
169
gboolean gnet_inetaddr_is_reserved (const GInetAddr* inetaddr);
170
gboolean gnet_inetaddr_is_loopback (const GInetAddr* inetaddr);
171
gboolean gnet_inetaddr_is_multicast (const GInetAddr* inetaddr);
172
gboolean gnet_inetaddr_is_broadcast (const GInetAddr* inetaddr);
177
guint gnet_inetaddr_hash (gconstpointer p);
178
gint gnet_inetaddr_equal (gconstpointer p1, gconstpointer p2);
179
gint gnet_inetaddr_noport_equal (gconstpointer p1, gconstpointer p2);
184
gchar* gnet_inetaddr_gethostname (void);
185
GInetAddr* gnet_inetaddr_gethostaddr (void);
190
GInetAddr* gnet_inetaddr_new_any (void);
191
GInetAddr* gnet_inetaddr_autodetect_internet_interface (void);
192
GInetAddr* gnet_inetaddr_get_interface_to (const GInetAddr* addr);
193
GInetAddr* gnet_inetaddr_get_internet_interface (void);
195
gboolean gnet_inetaddr_is_internet_domainname (const gchar* name);
200
GList* gnet_inetaddr_list_interfaces (void);
205
#endif /* __cplusplus */
207
#endif /* _GNET_INETADDR_H */