defining data structures for validation
[oweals/gnunet.git] / src / include / gnunet_nt_lib.h
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  * @file network type characterization
22  * @author Christian Grothoff
23  * @author Matthias Wachs
24  *
25  * @defgroup nt  network type characterization
26  *
27  * @{
28  */
29 #ifndef GNUNET_NT_LIB_H
30 #define GNUNET_NT_LIB_H
31
32 /**
33  * Types of networks (with separate quotas) we support.
34  */
35 enum GNUNET_NetworkType
36 {
37   /**
38    * Category of last resort.
39    */
40   GNUNET_NT_UNSPECIFIED = 0,
41
42   /**
43    * Loopback (same host).
44    */
45   GNUNET_NT_LOOPBACK = 1,
46
47   /**
48    * Local area network.
49    */
50   GNUNET_NT_LAN = 2,
51
52   /**
53    * Wide area network (i.e. Internet)
54    */
55   GNUNET_NT_WAN = 3,
56
57   /**
58    * Wireless LAN (i.e. 802.11abgn)
59    */
60   GNUNET_NT_WLAN = 4,
61
62   /**
63    * Bluetooth LAN
64    */
65   GNUNET_NT_BT = 5
66
67 /**
68  * Number of network types supported by ATS
69  */
70 #define GNUNET_NT_COUNT 6
71
72 };
73
74
75 /**
76  * Convert a `enum GNUNET_NetworkType` to a string
77  *
78  * @param net the network type
79  * @return a string or NULL if invalid
80  */
81 const char *
82 GNUNET_NT_to_string (enum GNUNET_NetworkType net);
83
84
85 /**
86  * Handle for the LAN Characterization library.
87  */
88 struct GNUNET_NT_InterfaceScanner;
89
90
91 /**
92  * Returns where the address is located: loopback, LAN or WAN.
93  *
94  * @param is handle from #GNUNET_ATS_interface_scanner_init()
95  * @param addr address
96  * @param addrlen address length
97  * @return type of the network the address belongs to
98  */
99 enum GNUNET_NetworkType
100 GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is,
101                             const struct sockaddr *addr,
102                             socklen_t addrlen);
103
104
105 /**
106  * Initialize the address characterization client handle.
107  *
108  * @return scanner handle, NULL on error
109  */
110 struct GNUNET_NT_InterfaceScanner *
111 GNUNET_NT_scanner_init (void);
112
113
114 /**
115  * Terminate interface scanner.
116  *
117  * @param is scanner we are done with
118  */
119 void
120 GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is);
121
122
123 #endif
124
125 /** @} */  /* end of group */