gnunet_nt_lib.h (2862B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2010-2015, 2018 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 21 #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 22 #error "Only <gnunet_util_lib.h> can be included directly." 23 #endif 24 25 /** 26 * @addtogroup Backbone 27 * @{ 28 * 29 * @file network type characterization 30 * @author Christian Grothoff 31 * @author Matthias Wachs 32 * 33 * @defgroup nt Network type characterization 34 * 35 * @{ 36 */ 37 #ifndef GNUNET_NT_LIB_H 38 #define GNUNET_NT_LIB_H 39 40 /** 41 * Types of networks (with separate quotas) we support. 42 */ 43 enum GNUNET_NetworkType 44 { 45 /** 46 * Category of last resort. 47 */ 48 GNUNET_NT_UNSPECIFIED = 0, 49 50 /** 51 * Loopback (same host). 52 */ 53 GNUNET_NT_LOOPBACK = 1, 54 55 /** 56 * Local area network. 57 */ 58 GNUNET_NT_LAN = 2, 59 60 /** 61 * Wide area network (i.e. Internet) 62 */ 63 GNUNET_NT_WAN = 3, 64 65 /** 66 * Wireless LAN (i.e. 802.11abgn) 67 */ 68 GNUNET_NT_WLAN = 4, 69 70 /** 71 * Bluetooth LAN 72 */ 73 GNUNET_NT_BT = 5 74 75 /** 76 * Number of network types supported by ATS 77 */ 78 #define GNUNET_NT_COUNT 6 79 }; 80 81 82 /** 83 * Convert a `enum GNUNET_NetworkType` to a string 84 * 85 * @param net the network type 86 * @return a string or NULL if invalid 87 */ 88 const char * 89 GNUNET_NT_to_string (enum GNUNET_NetworkType net); 90 91 92 /** 93 * Handle for the LAN Characterization library. 94 */ 95 struct GNUNET_NT_InterfaceScanner; 96 97 98 /** 99 * Returns where the address is located: loopback, LAN or WAN. 100 * 101 * @param is handle from #GNUNET_ATS_interface_scanner_init() 102 * @param addr address 103 * @param addrlen address length 104 * @return type of the network the address belongs to 105 */ 106 enum GNUNET_NetworkType 107 GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is, 108 const struct sockaddr *addr, 109 socklen_t addrlen); 110 111 112 /** 113 * Initialize the address characterization client handle. 114 * 115 * @return scanner handle, NULL on error 116 */ 117 struct GNUNET_NT_InterfaceScanner * 118 GNUNET_NT_scanner_init (void); 119 120 121 /** 122 * Terminate interface scanner. 123 * 124 * @param is scanner we are done with 125 */ 126 void 127 GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is); 128 129 130 #endif 131 132 /** @} */ /* end of group */ 133 134 /** @} */ /* end of group addition to backbone */