| 1 |
/* |
|---|
| 2 |
* This file is part of gtkD. |
|---|
| 3 |
* |
|---|
| 4 |
* gtkD is free software; you can redistribute it and/or modify |
|---|
| 5 |
* it under the terms of the GNU Lesser General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 3 |
|---|
| 7 |
* of the License, or (at your option) any later version, with |
|---|
| 8 |
* some exceptions, please read the COPYING file. |
|---|
| 9 |
* |
|---|
| 10 |
* gtkD 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 |
|---|
| 13 |
* GNU Lesser General Public License for more details. |
|---|
| 14 |
* |
|---|
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
|---|
| 16 |
* along with gtkD; if not, write to the Free Software |
|---|
| 17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
// generated automatically - do not change |
|---|
| 21 |
// find conversion definition on APILookup.txt |
|---|
| 22 |
// implement new conversion functionalities on the wrap.utils pakage |
|---|
| 23 |
|
|---|
| 24 |
/* |
|---|
| 25 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GInetAddress.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = InetAddress |
|---|
| 29 |
* strct = GInetAddress |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = InetAddress |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: Yes |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_inet_address_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* - g_inet_address_new_any |
|---|
| 45 |
* - g_inet_address_new_loopback |
|---|
| 46 |
* omit signals: |
|---|
| 47 |
* imports: |
|---|
| 48 |
* - glib.Str |
|---|
| 49 |
* structWrap: |
|---|
| 50 |
* module aliases: |
|---|
| 51 |
* local aliases: |
|---|
| 52 |
* overrides: |
|---|
| 53 |
* - toString |
|---|
| 54 |
*/ |
|---|
| 55 |
|
|---|
| 56 |
module gio.InetAddress; |
|---|
| 57 |
|
|---|
| 58 |
public import gtkc.giotypes; |
|---|
| 59 |
|
|---|
| 60 |
private import gtkc.gio; |
|---|
| 61 |
private import glib.ConstructionException; |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
private import glib.Str; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
private import gobject.ObjectG; |
|---|
| 69 |
|
|---|
| 70 |
/** |
|---|
| 71 |
* Description |
|---|
| 72 |
* GInetAddress represents an IPv4 or IPv6 internet address. Use |
|---|
| 73 |
* g_resolver_lookup_by_name() or g_resolver_lookup_by_name_async() to |
|---|
| 74 |
* look up the GInetAddress for a hostname. Use |
|---|
| 75 |
* g_resolver_lookup_by_address() or |
|---|
| 76 |
* g_resolver_lookup_by_address_async() to look up the hostname for a |
|---|
| 77 |
* GInetAddress. |
|---|
| 78 |
* To actually connect to a remote host, you will need a |
|---|
| 79 |
* GInetSocketAddress (which includes a GInetAddress as well as a |
|---|
| 80 |
* port number). |
|---|
| 81 |
*/ |
|---|
| 82 |
public class InetAddress : ObjectG |
|---|
| 83 |
{ |
|---|
| 84 |
|
|---|
| 85 |
/** the main Gtk struct */ |
|---|
| 86 |
protected GInetAddress* gInetAddress; |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
public GInetAddress* getInetAddressStruct() |
|---|
| 90 |
{ |
|---|
| 91 |
return gInetAddress; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
/** the main Gtk struct as a void* */ |
|---|
| 96 |
protected override void* getStruct() |
|---|
| 97 |
{ |
|---|
| 98 |
return cast(void*)gInetAddress; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
/** |
|---|
| 102 |
* Sets our main struct and passes it to the parent class |
|---|
| 103 |
*/ |
|---|
| 104 |
public this (GInetAddress* gInetAddress) |
|---|
| 105 |
{ |
|---|
| 106 |
if(gInetAddress is null) |
|---|
| 107 |
{ |
|---|
| 108 |
this = null; |
|---|
| 109 |
return; |
|---|
| 110 |
} |
|---|
| 111 |
//Check if there already is a D object for this gtk struct |
|---|
| 112 |
void* ptr = getDObject(cast(GObject*)gInetAddress); |
|---|
| 113 |
if( ptr !is null ) |
|---|
| 114 |
{ |
|---|
| 115 |
this = cast(InetAddress)ptr; |
|---|
| 116 |
return; |
|---|
| 117 |
} |
|---|
| 118 |
super(cast(GObject*)gInetAddress); |
|---|
| 119 |
this.gInetAddress = gInetAddress; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
protected override void setStruct(GObject* obj) |
|---|
| 123 |
{ |
|---|
| 124 |
super.setStruct(obj); |
|---|
| 125 |
gInetAddress = cast(GInetAddress*)obj; |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
/** |
|---|
| 129 |
* Creates a GInetAddress for the "any" address (unassigned/"don't |
|---|
| 130 |
* care") for family. |
|---|
| 131 |
* Since 2.22 |
|---|
| 132 |
* Params: |
|---|
| 133 |
* family = the address family |
|---|
| 134 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 135 |
*/ |
|---|
| 136 |
public this (GSocketFamily family, bool loopback = false) |
|---|
| 137 |
{ |
|---|
| 138 |
// GInetAddress * g_inet_address_new_any (GSocketFamily family); |
|---|
| 139 |
GInetAddress* p; |
|---|
| 140 |
|
|---|
| 141 |
if ( loopback ) |
|---|
| 142 |
{ |
|---|
| 143 |
p = g_inet_address_new_loopback(family); |
|---|
| 144 |
} |
|---|
| 145 |
else |
|---|
| 146 |
{ |
|---|
| 147 |
p = g_inet_address_new_any(family); |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
if(p is null) |
|---|
| 151 |
{ |
|---|
| 152 |
throw new ConstructionException("null returned by g_inet_address_new_any(family)"); |
|---|
| 153 |
} |
|---|
| 154 |
this(cast(GInetAddress*) p); |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
/** |
|---|
| 158 |
*/ |
|---|
| 159 |
|
|---|
| 160 |
/** |
|---|
| 161 |
* Parses string as an IP address and creates a new GInetAddress. |
|---|
| 162 |
* Since 2.22 |
|---|
| 163 |
* Params: |
|---|
| 164 |
* string = a string representation of an IP address |
|---|
| 165 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 166 |
*/ |
|---|
| 167 |
public this (string string) |
|---|
| 168 |
{ |
|---|
| 169 |
// GInetAddress * g_inet_address_new_from_string (const gchar *string); |
|---|
| 170 |
auto p = g_inet_address_new_from_string(Str.toStringz(string)); |
|---|
| 171 |
if(p is null) |
|---|
| 172 |
{ |
|---|
| 173 |
throw new ConstructionException("null returned by g_inet_address_new_from_string(Str.toStringz(string))"); |
|---|
| 174 |
} |
|---|
| 175 |
this(cast(GInetAddress*) p); |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
/** |
|---|
| 179 |
* Creates a new GInetAddress from the given family and bytes. |
|---|
| 180 |
* bytes should be 4 bytes for G_INET_ADDRESS_IPV4 and 16 bytes for |
|---|
| 181 |
* G_INET_ADDRESS_IPV6. |
|---|
| 182 |
* Since 2.22 |
|---|
| 183 |
* Params: |
|---|
| 184 |
* bytes = raw address data |
|---|
| 185 |
* family = the address family of bytes |
|---|
| 186 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 187 |
*/ |
|---|
| 188 |
public this (ubyte[] bytes, GSocketFamily family) |
|---|
| 189 |
{ |
|---|
| 190 |
// GInetAddress * g_inet_address_new_from_bytes (const guint8 *bytes, GSocketFamily family); |
|---|
| 191 |
auto p = g_inet_address_new_from_bytes(bytes.ptr, family); |
|---|
| 192 |
if(p is null) |
|---|
| 193 |
{ |
|---|
| 194 |
throw new ConstructionException("null returned by g_inet_address_new_from_bytes(bytes.ptr, family)"); |
|---|
| 195 |
} |
|---|
| 196 |
this(cast(GInetAddress*) p); |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
/** |
|---|
| 200 |
* Gets the raw binary address data from address. |
|---|
| 201 |
* Since 2.22 |
|---|
| 202 |
* Returns: a pointer to an internal array of the bytes in address, which should not be modified, stored, or freed. The size of this array can be gotten with g_inet_address_get_native_size(). |
|---|
| 203 |
*/ |
|---|
| 204 |
public ubyte[] toBytes() |
|---|
| 205 |
{ |
|---|
| 206 |
// const guint8 * g_inet_address_to_bytes (GInetAddress *address); |
|---|
| 207 |
auto p = g_inet_address_to_bytes(gInetAddress); |
|---|
| 208 |
return p[0 .. getNativeSize()]; |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
/** |
|---|
| 212 |
* Gets the size of the native raw binary address for address. This |
|---|
| 213 |
* is the size of the data that you get from g_inet_address_to_bytes(). |
|---|
| 214 |
* Since 2.22 |
|---|
| 215 |
* Returns: the number of bytes used for the native version of address. |
|---|
| 216 |
*/ |
|---|
| 217 |
public gsize getNativeSize() |
|---|
| 218 |
{ |
|---|
| 219 |
// gsize g_inet_address_get_native_size (GInetAddress *address); |
|---|
| 220 |
return g_inet_address_get_native_size(gInetAddress); |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
/** |
|---|
| 224 |
* Converts address to string form. |
|---|
| 225 |
* Since 2.22 |
|---|
| 226 |
* Returns: a representation of address as a string, which should be freed after use. |
|---|
| 227 |
*/ |
|---|
| 228 |
public override string toString() |
|---|
| 229 |
{ |
|---|
| 230 |
// gchar * g_inet_address_to_string (GInetAddress *address); |
|---|
| 231 |
return Str.toString(g_inet_address_to_string(gInetAddress)); |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
/** |
|---|
| 235 |
* Gets address's family |
|---|
| 236 |
* Since 2.22 |
|---|
| 237 |
* Returns: address's family |
|---|
| 238 |
*/ |
|---|
| 239 |
public GSocketFamily getFamily() |
|---|
| 240 |
{ |
|---|
| 241 |
// GSocketFamily g_inet_address_get_family (GInetAddress *address); |
|---|
| 242 |
return g_inet_address_get_family(gInetAddress); |
|---|
| 243 |
} |
|---|
| 244 |
|
|---|
| 245 |
/** |
|---|
| 246 |
* Tests whether address is the "any" address for its family. |
|---|
| 247 |
* Since 2.22 |
|---|
| 248 |
* Returns: TRUE if address is the "any" address for its family. |
|---|
| 249 |
*/ |
|---|
| 250 |
public int getIsAny() |
|---|
| 251 |
{ |
|---|
| 252 |
// gboolean g_inet_address_get_is_any (GInetAddress *address); |
|---|
| 253 |
return g_inet_address_get_is_any(gInetAddress); |
|---|
| 254 |
} |
|---|
| 255 |
|
|---|
| 256 |
/** |
|---|
| 257 |
* Tests whether address is the loopback address for its family. |
|---|
| 258 |
* Since 2.22 |
|---|
| 259 |
* Returns: TRUE if address is the loopback address for its family. |
|---|
| 260 |
*/ |
|---|
| 261 |
public int getIsLoopback() |
|---|
| 262 |
{ |
|---|
| 263 |
// gboolean g_inet_address_get_is_loopback (GInetAddress *address); |
|---|
| 264 |
return g_inet_address_get_is_loopback(gInetAddress); |
|---|
| 265 |
} |
|---|
| 266 |
|
|---|
| 267 |
/** |
|---|
| 268 |
* Tests whether address is a link-local address (that is, if it |
|---|
| 269 |
* identifies a host on a local network that is not connected to the |
|---|
| 270 |
* Internet). |
|---|
| 271 |
* Since 2.22 |
|---|
| 272 |
* Returns: TRUE if address is a link-local address. |
|---|
| 273 |
*/ |
|---|
| 274 |
public int getIsLinkLocal() |
|---|
| 275 |
{ |
|---|
| 276 |
// gboolean g_inet_address_get_is_link_local (GInetAddress *address); |
|---|
| 277 |
return g_inet_address_get_is_link_local(gInetAddress); |
|---|
| 278 |
} |
|---|
| 279 |
|
|---|
| 280 |
/** |
|---|
| 281 |
* Tests whether address is a site-local address such as 10.0.0.1 |
|---|
| 282 |
* (that is, the address identifies a host on a local network that can |
|---|
| 283 |
* not be reached directly from the Internet, but which may have |
|---|
| 284 |
* outgoing Internet connectivity via a NAT or firewall). |
|---|
| 285 |
* Since 2.22 |
|---|
| 286 |
* Returns: TRUE if address is a site-local address. |
|---|
| 287 |
*/ |
|---|
| 288 |
public int getIsSiteLocal() |
|---|
| 289 |
{ |
|---|
| 290 |
// gboolean g_inet_address_get_is_site_local (GInetAddress *address); |
|---|
| 291 |
return g_inet_address_get_is_site_local(gInetAddress); |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
/** |
|---|
| 295 |
* Tests whether address is a multicast address. |
|---|
| 296 |
* Since 2.22 |
|---|
| 297 |
* Returns: TRUE if address is a multicast address. |
|---|
| 298 |
*/ |
|---|
| 299 |
public int getIsMulticast() |
|---|
| 300 |
{ |
|---|
| 301 |
// gboolean g_inet_address_get_is_multicast (GInetAddress *address); |
|---|
| 302 |
return g_inet_address_get_is_multicast(gInetAddress); |
|---|
| 303 |
} |
|---|
| 304 |
|
|---|
| 305 |
/** |
|---|
| 306 |
* Tests whether address is a link-local multicast address. |
|---|
| 307 |
* Since 2.22 |
|---|
| 308 |
* Returns: TRUE if address is a link-local multicast address. |
|---|
| 309 |
*/ |
|---|
| 310 |
public int getIsMcLinkLocal() |
|---|
| 311 |
{ |
|---|
| 312 |
// gboolean g_inet_address_get_is_mc_link_local (GInetAddress *address); |
|---|
| 313 |
return g_inet_address_get_is_mc_link_local(gInetAddress); |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
/** |
|---|
| 317 |
* Tests whether address is a node-local multicast address. |
|---|
| 318 |
* Since 2.22 |
|---|
| 319 |
* Returns: TRUE if address is a node-local multicast address. |
|---|
| 320 |
*/ |
|---|
| 321 |
public int getIsMcNodeLocal() |
|---|
| 322 |
{ |
|---|
| 323 |
// gboolean g_inet_address_get_is_mc_node_local (GInetAddress *address); |
|---|
| 324 |
return g_inet_address_get_is_mc_node_local(gInetAddress); |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
/** |
|---|
| 328 |
* Tests whether address is a site-local multicast address. |
|---|
| 329 |
* Since 2.22 |
|---|
| 330 |
* Returns: TRUE if address is a site-local multicast address. |
|---|
| 331 |
*/ |
|---|
| 332 |
public int getIsMcSiteLocal() |
|---|
| 333 |
{ |
|---|
| 334 |
// gboolean g_inet_address_get_is_mc_site_local (GInetAddress *address); |
|---|
| 335 |
return g_inet_address_get_is_mc_site_local(gInetAddress); |
|---|
| 336 |
} |
|---|
| 337 |
|
|---|
| 338 |
/** |
|---|
| 339 |
* Tests whether address is an organization-local multicast address. |
|---|
| 340 |
* Since 2.22 |
|---|
| 341 |
* Returns: TRUE if address is an organization-local multicast address. |
|---|
| 342 |
*/ |
|---|
| 343 |
public int getIsMcOrgLocal() |
|---|
| 344 |
{ |
|---|
| 345 |
// gboolean g_inet_address_get_is_mc_org_local (GInetAddress *address); |
|---|
| 346 |
return g_inet_address_get_is_mc_org_local(gInetAddress); |
|---|
| 347 |
} |
|---|
| 348 |
|
|---|
| 349 |
/** |
|---|
| 350 |
* Tests whether address is a global multicast address. |
|---|
| 351 |
* Since 2.22 |
|---|
| 352 |
* Returns: TRUE if address is a global multicast address. |
|---|
| 353 |
*/ |
|---|
| 354 |
public int getIsMcGlobal() |
|---|
| 355 |
{ |
|---|
| 356 |
// gboolean g_inet_address_get_is_mc_global (GInetAddress *address); |
|---|
| 357 |
return g_inet_address_get_is_mc_global(gInetAddress); |
|---|
| 358 |
} |
|---|
| 359 |
} |
|---|