diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-22 22:04:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-22 22:04:48 +0100 |
commit | c87f73a07df468eccedbe1fdfa82bdd5b633a0d5 (patch) | |
tree | 0bb3f63e727a65dc84c33a03229b6760edee82ee /src/include | |
parent | dd7379052f3749d87d8c35969ec94b4580e998b5 (diff) | |
download | gnunet-c87f73a07df468eccedbe1fdfa82bdd5b633a0d5.tar.gz gnunet-c87f73a07df468eccedbe1fdfa82bdd5b633a0d5.zip |
move network type logic out of ATS code, move performance preferences into MQ
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_mq_lib.h | 47 | ||||
-rw-r--r-- | src/include/gnunet_nt_lib.h | 123 |
3 files changed, 170 insertions, 1 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 41b2b1382..185f649ac 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -87,6 +87,7 @@ gnunetinclude_HEADERS = \ | |||
87 | gnunet_nc_lib.h \ | 87 | gnunet_nc_lib.h \ |
88 | gnunet_network_lib.h \ | 88 | gnunet_network_lib.h \ |
89 | gnunet_nse_service.h \ | 89 | gnunet_nse_service.h \ |
90 | gnunet_nt_lib.h \ | ||
90 | gnunet_op_lib.h \ | 91 | gnunet_op_lib.h \ |
91 | gnunet_os_lib.h \ | 92 | gnunet_os_lib.h \ |
92 | gnunet_peer_lib.h \ | 93 | gnunet_peer_lib.h \ |
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 226b3389f..3d3a74e3b 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -875,6 +875,51 @@ const struct GNUNET_MessageHeader * | |||
875 | GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq); | 875 | GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq); |
876 | 876 | ||
877 | 877 | ||
878 | |||
879 | /** | ||
880 | * Enum defining all known preference categories. | ||
881 | */ | ||
882 | enum GNUNET_MQ_PreferenceKind | ||
883 | { | ||
884 | |||
885 | /** | ||
886 | * No preference was expressed. | ||
887 | */ | ||
888 | GNUNET_MQ_PREFERENCE_NONE = 0, | ||
889 | |||
890 | /** | ||
891 | * The preferred transmission for this envelope focuses on | ||
892 | * maximizing bandwidth. | ||
893 | */ | ||
894 | GNUNET_MQ_PREFERENCE_BANDWIDTH = 1, | ||
895 | |||
896 | /** | ||
897 | * The preferred transmission for this envelope foces on | ||
898 | * minimizing latency. | ||
899 | */ | ||
900 | GNUNET_MQ_PREFERENCE_LATENCY = 2, | ||
901 | |||
902 | /** | ||
903 | * The preferred transmission for this envelope foces on | ||
904 | * reliability. | ||
905 | */ | ||
906 | GNUNET_MQ_PREFERENCE_RELIABILITY = 3 | ||
907 | |||
908 | }; | ||
909 | |||
910 | |||
911 | /** | ||
912 | * Convert an `enum GNUNET_MQ_PreferenceType` to a string | ||
913 | * | ||
914 | * @param type the preference type | ||
915 | * @return a string or NULL if invalid | ||
916 | */ | ||
917 | const char * | ||
918 | GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type); | ||
919 | |||
920 | |||
921 | |||
922 | |||
878 | #endif | 923 | #endif |
879 | 924 | ||
880 | /** @} */ /* end of group mq */ | 925 | /** @} */ /* end of group mq */ |
diff --git a/src/include/gnunet_nt_lib.h b/src/include/gnunet_nt_lib.h new file mode 100644 index 000000000..3d89aa7b2 --- /dev/null +++ b/src/include/gnunet_nt_lib.h | |||
@@ -0,0 +1,123 @@ | |||
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 | /** | ||
19 | * @file network type characterization | ||
20 | * @author Christian Grothoff | ||
21 | * @author Matthias Wachs | ||
22 | * | ||
23 | * @defgroup nt network type characterization | ||
24 | * | ||
25 | * @{ | ||
26 | */ | ||
27 | #ifndef GNUNET_NT_LIB_H | ||
28 | #define GNUNET_NT_LIB_H | ||
29 | |||
30 | /** | ||
31 | * Types of networks (with separate quotas) we support. | ||
32 | */ | ||
33 | enum GNUNET_NetworkType | ||
34 | { | ||
35 | /** | ||
36 | * Category of last resort. | ||
37 | */ | ||
38 | GNUNET_NT_UNSPECIFIED = 0, | ||
39 | |||
40 | /** | ||
41 | * Loopback (same host). | ||
42 | */ | ||
43 | GNUNET_NT_LOOPBACK = 1, | ||
44 | |||
45 | /** | ||
46 | * Local area network. | ||
47 | */ | ||
48 | GNUNET_NT_LAN = 2, | ||
49 | |||
50 | /** | ||
51 | * Wide area network (i.e. Internet) | ||
52 | */ | ||
53 | GNUNET_NT_WAN = 3, | ||
54 | |||
55 | /** | ||
56 | * Wireless LAN (i.e. 802.11abgn) | ||
57 | */ | ||
58 | GNUNET_NT_WLAN = 4, | ||
59 | |||
60 | /** | ||
61 | * Bluetooth LAN | ||
62 | */ | ||
63 | GNUNET_NT_BT = 5 | ||
64 | |||
65 | /** | ||
66 | * Number of network types supported by ATS | ||
67 | */ | ||
68 | #define GNUNET_NT_COUNT 6 | ||
69 | |||
70 | }; | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Convert a `enum GNUNET_NetworkType` to a string | ||
75 | * | ||
76 | * @param net the network type | ||
77 | * @return a string or NULL if invalid | ||
78 | */ | ||
79 | const char * | ||
80 | GNUNET_NT_to_string (enum GNUNET_NetworkType net); | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Handle for the LAN Characterization library. | ||
85 | */ | ||
86 | struct GNUNET_NT_InterfaceScanner; | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Returns where the address is located: loopback, LAN or WAN. | ||
91 | * | ||
92 | * @param is handle from #GNUNET_ATS_interface_scanner_init() | ||
93 | * @param addr address | ||
94 | * @param addrlen address length | ||
95 | * @return type of the network the address belongs to | ||
96 | */ | ||
97 | enum GNUNET_NetworkType | ||
98 | GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is, | ||
99 | const struct sockaddr *addr, | ||
100 | socklen_t addrlen); | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Initialize the address characterization client handle. | ||
105 | * | ||
106 | * @return scanner handle, NULL on error | ||
107 | */ | ||
108 | struct GNUNET_NT_InterfaceScanner * | ||
109 | GNUNET_NT_scanner_init (void); | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Terminate interface scanner. | ||
114 | * | ||
115 | * @param is scanner we are done with | ||
116 | */ | ||
117 | void | ||
118 | GNUNET_NT_scanner_done (struct GNUNET_NT_InterfaceScanner *is); | ||
119 | |||
120 | |||
121 | #endif | ||
122 | |||
123 | /** @} */ /* end of group */ | ||