1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2015 The Android Open Source Project. 10 Copyright (C) 2018-2019 Aurora Free Open Source Software. 11 12 This file is part of the Aurora Free Open Source Software. This 13 organization promote free and open source software that you can 14 redistribute and/or modify under the terms of the GNU Lesser General 15 Public License Version 3 as published by the Free Software Foundation or 16 (at your option) any later version approved by the Aurora Free Open Source 17 Software Organization. The license is available in the package root path 18 as 'LICENSE' file. Please review the following information to ensure the 19 GNU Lesser General Public License version 3 requirements will be met: 20 https://www.gnu.org/licenses/lgpl.html . 21 22 Alternatively, this file may be used under the terms of the GNU General 23 Public License version 3 or later as published by the Free Software 24 Foundation. Please review the following information to ensure the GNU 25 General Public License requirements will be met: 26 https://www.gnu.org/licenses/gpl-3.0.html. 27 28 NOTE: All products, services or anything associated to trademarks and 29 service marks used or referenced on this file are the property of their 30 respective companies/owners or its subsidiaries. Other names and brands 31 may be claimed as the property of others. 32 33 For more info about intellectual property visit: aurorafoss.org or 34 directly send an email to: contact (at) aurorafoss.org . 35 36 This file has bindings for an existing code, part of The Android Open Source 37 Project implementation. Check it out at android.googlesource.com . 38 */ 39 40 module aurorafw.android.platform.multinetwork; 41 42 /** 43 * @addtogroup Networking 44 * @{ 45 */ 46 47 /** 48 * @file aurorafw/android/platform/multinetwork.d 49 */ 50 51 import core.stdc.config; 52 import core.sys.posix.netdb; 53 54 version (Android): 55 extern (C): 56 @system: 57 nothrow: 58 @nogc: 59 60 /** 61 * The corresponding C type for android.net.Network#getNetworkHandle() return 62 * values. The Java signed long value can be safely cast to a net_handle_t: 63 * 64 * [C] ((net_handle_t) java_long_network_handle) 65 * [C++] static_cast<net_handle_t>(java_long_network_handle) 66 * 67 * as appropriate. 68 */ 69 alias net_handle_t = c_ulong; 70 71 /** 72 * The value NETWORK_UNSPECIFIED indicates no specific network. 73 * 74 * For some functions (documented below), a previous binding may be cleared 75 * by an invocation with NETWORK_UNSPECIFIED. 76 * 77 * Depending on the context it may indicate an error. It is expressly 78 * not used to indicate some notion of the "current default network". 79 */ 80 enum NETWORK_UNSPECIFIED = cast(net_handle_t) 0; 81 82 /** 83 * All functions below that return an int return 0 on success or -1 84 * on failure with an appropriate errno value set. 85 */ 86 87 /** 88 * Set the network to be used by the given socket file descriptor. 89 * 90 * To clear a previous socket binding, invoke with NETWORK_UNSPECIFIED. 91 * 92 * This is the equivalent of: [android.net.Network#bindSocket()](https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket)) 93 * 94 */ 95 int android_setsocknetwork (net_handle_t network, int fd); 96 97 /** 98 * Binds the current process to |network|. All sockets created in the future 99 * (and not explicitly bound via android_setsocknetwork()) will be bound to 100 * |network|. All host name resolutions will be limited to |network| as well. 101 * Note that if the network identified by |network| ever disconnects, all 102 * sockets created in this way will cease to work and all host name 103 * resolutions will fail. This is by design so an application doesn't 104 * accidentally use sockets it thinks are still bound to a particular network. 105 * 106 * To clear a previous process binding, invoke with NETWORK_UNSPECIFIED. 107 * 108 * This is the equivalent of: [android.net.ConnectivityManager#setProcessDefaultNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network)) 109 * 110 */ 111 int android_setprocnetwork (net_handle_t network); 112 113 /** 114 * Perform hostname resolution via the DNS servers associated with |network|. 115 * 116 * All arguments (apart from |network|) are used identically as those passed 117 * to getaddrinfo(3). Return and error values are identical to those of 118 * getaddrinfo(3), and in particular gai_strerror(3) can be used as expected. 119 * Similar to getaddrinfo(3): 120 * - |hints| may be NULL (in which case man page documented defaults apply) 121 * - either |node| or |service| may be NULL, but not both 122 * - |res| must not be NULL 123 * 124 * This is the equivalent of: [android.net.Network#getAllByName()](https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String)) 125 * 126 */ 127 int android_getaddrinfofornetwork ( 128 net_handle_t network, 129 const(char)* node, 130 const(char)* service, 131 const(addrinfo)* hints, 132 addrinfo** res); 133 134 /* __ANDROID_API__ >= 23 */ 135 136 // ANDROID_MULTINETWORK_H 137 138 /** @} */