diff options
Diffstat (limited to 'src/testbed/testbed_api_underlay.c')
-rw-r--r-- | src/testbed/testbed_api_underlay.c | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/src/testbed/testbed_api_underlay.c b/src/testbed/testbed_api_underlay.c index 5cc8d8597..b0c712ca6 100644 --- a/src/testbed/testbed_api_underlay.c +++ b/src/testbed/testbed_api_underlay.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2008--2013 GNUnet e.V. | 3 | Copyright (C) 2008--2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testbed/testbed_api_underlay.c | 22 | * @file testbed/testbed_api_underlay.c |
@@ -30,8 +30,7 @@ | |||
30 | /** | 30 | /** |
31 | * An underlay link | 31 | * An underlay link |
32 | */ | 32 | */ |
33 | struct LinkProperty | 33 | struct LinkProperty { |
34 | { | ||
35 | /** | 34 | /** |
36 | * next pointer for list | 35 | * next pointer for list |
37 | */ | 36 | */ |
@@ -62,8 +61,7 @@ struct LinkProperty | |||
62 | /** | 61 | /** |
63 | * Container for holding a peer in whitelist/blacklist | 62 | * Container for holding a peer in whitelist/blacklist |
64 | */ | 63 | */ |
65 | struct ListEntry | 64 | struct ListEntry { |
66 | { | ||
67 | /** | 65 | /** |
68 | * the next pointer | 66 | * the next pointer |
69 | */ | 67 | */ |
@@ -80,8 +78,7 @@ struct ListEntry | |||
80 | * Model for configuring underlay links of a peer | 78 | * Model for configuring underlay links of a peer |
81 | * @ingroup underlay | 79 | * @ingroup underlay |
82 | */ | 80 | */ |
83 | struct GNUNET_TESTBED_UnderlayLinkModel | 81 | struct GNUNET_TESTBED_UnderlayLinkModel { |
84 | { | ||
85 | /** | 82 | /** |
86 | * The peer associated with this model | 83 | * The peer associated with this model |
87 | */ | 84 | */ |
@@ -110,15 +107,15 @@ struct GNUNET_TESTBED_UnderlayLinkModel | |||
110 | * @param model the model | 107 | * @param model the model |
111 | */ | 108 | */ |
112 | static void | 109 | static void |
113 | free_entries (struct GNUNET_TESTBED_UnderlayLinkModel *model) | 110 | free_entries(struct GNUNET_TESTBED_UnderlayLinkModel *model) |
114 | { | 111 | { |
115 | struct ListEntry *e; | 112 | struct ListEntry *e; |
116 | 113 | ||
117 | while (NULL != (e = model->entries)) | 114 | while (NULL != (e = model->entries)) |
118 | { | 115 | { |
119 | model->entries = e->next; | 116 | model->entries = e->next; |
120 | GNUNET_free (e); | 117 | GNUNET_free(e); |
121 | } | 118 | } |
122 | } | 119 | } |
123 | 120 | ||
124 | 121 | ||
@@ -128,15 +125,15 @@ free_entries (struct GNUNET_TESTBED_UnderlayLinkModel *model) | |||
128 | * @param model the model | 125 | * @param model the model |
129 | */ | 126 | */ |
130 | static void | 127 | static void |
131 | free_link_properties (struct GNUNET_TESTBED_UnderlayLinkModel *model) | 128 | free_link_properties(struct GNUNET_TESTBED_UnderlayLinkModel *model) |
132 | { | 129 | { |
133 | struct LinkProperty *p; | 130 | struct LinkProperty *p; |
134 | 131 | ||
135 | while (NULL != (p = model->props)) | 132 | while (NULL != (p = model->props)) |
136 | { | 133 | { |
137 | model->props = p->next; | 134 | model->props = p->next; |
138 | GNUNET_free (p); | 135 | GNUNET_free(p); |
139 | } | 136 | } |
140 | } | 137 | } |
141 | 138 | ||
142 | 139 | ||
@@ -150,13 +147,13 @@ free_link_properties (struct GNUNET_TESTBED_UnderlayLinkModel *model) | |||
150 | * @return the model | 147 | * @return the model |
151 | */ | 148 | */ |
152 | struct GNUNET_TESTBED_UnderlayLinkModel * | 149 | struct GNUNET_TESTBED_UnderlayLinkModel * |
153 | GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer, | 150 | GNUNET_TESTBED_underlaylinkmodel_create(struct GNUNET_TESTBED_Peer *peer, |
154 | enum GNUNET_TESTBED_UnderlayLinkModelType type) | 151 | enum GNUNET_TESTBED_UnderlayLinkModelType type) |
155 | { | 152 | { |
156 | struct GNUNET_TESTBED_UnderlayLinkModel *m; | 153 | struct GNUNET_TESTBED_UnderlayLinkModel *m; |
157 | 154 | ||
158 | GNUNET_assert (0 == peer->underlay_model_exists); | 155 | GNUNET_assert(0 == peer->underlay_model_exists); |
159 | m = GNUNET_new (struct GNUNET_TESTBED_UnderlayLinkModel); | 156 | m = GNUNET_new(struct GNUNET_TESTBED_UnderlayLinkModel); |
160 | peer->underlay_model_exists = 1; | 157 | peer->underlay_model_exists = 1; |
161 | m->type = type; | 158 | m->type = type; |
162 | return m; | 159 | return m; |
@@ -173,12 +170,12 @@ GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer, | |||
173 | * @param peer the peer to add | 170 | * @param peer the peer to add |
174 | */ | 171 | */ |
175 | void | 172 | void |
176 | GNUNET_TESTBED_underlaylinkmodel_add_peer (struct GNUNET_TESTBED_UnderlayLinkModel *model, | 173 | GNUNET_TESTBED_underlaylinkmodel_add_peer(struct GNUNET_TESTBED_UnderlayLinkModel *model, |
177 | struct GNUNET_TESTBED_Peer *peer) | 174 | struct GNUNET_TESTBED_Peer *peer) |
178 | { | 175 | { |
179 | struct ListEntry *entry; | 176 | struct ListEntry *entry; |
180 | 177 | ||
181 | entry = GNUNET_new (struct ListEntry); | 178 | entry = GNUNET_new(struct ListEntry); |
182 | entry->peer = peer; | 179 | entry->peer = peer; |
183 | entry->next = model->entries; | 180 | entry->next = model->entries; |
184 | model->entries = entry; | 181 | model->entries = entry; |
@@ -197,15 +194,15 @@ GNUNET_TESTBED_underlaylinkmodel_add_peer (struct GNUNET_TESTBED_UnderlayLinkMod | |||
197 | * @param bandwidth bandwidth of the link in kilobytes per second [kB/s] | 194 | * @param bandwidth bandwidth of the link in kilobytes per second [kB/s] |
198 | */ | 195 | */ |
199 | void | 196 | void |
200 | GNUNET_TESTBED_underlaylinkmodel_set_link (struct GNUNET_TESTBED_UnderlayLinkModel *model, | 197 | GNUNET_TESTBED_underlaylinkmodel_set_link(struct GNUNET_TESTBED_UnderlayLinkModel *model, |
201 | struct GNUNET_TESTBED_Peer *peer, | 198 | struct GNUNET_TESTBED_Peer *peer, |
202 | uint32_t latency, | 199 | uint32_t latency, |
203 | uint32_t loss, | 200 | uint32_t loss, |
204 | uint32_t bandwidth) | 201 | uint32_t bandwidth) |
205 | { | 202 | { |
206 | struct LinkProperty *prop; | 203 | struct LinkProperty *prop; |
207 | 204 | ||
208 | prop = GNUNET_new (struct LinkProperty); | 205 | prop = GNUNET_new(struct LinkProperty); |
209 | prop->peer = peer; | 206 | prop->peer = peer; |
210 | prop->latency = latency; | 207 | prop->latency = latency; |
211 | prop->loss = loss; | 208 | prop->loss = loss; |
@@ -224,12 +221,12 @@ GNUNET_TESTBED_underlaylinkmodel_set_link (struct GNUNET_TESTBED_UnderlayLinkMod | |||
224 | * @param model the model to unallocate | 221 | * @param model the model to unallocate |
225 | */ | 222 | */ |
226 | void | 223 | void |
227 | GNUNET_TESTBED_underlaylinkmodel_free (struct GNUNET_TESTBED_UnderlayLinkModel *model) | 224 | GNUNET_TESTBED_underlaylinkmodel_free(struct GNUNET_TESTBED_UnderlayLinkModel *model) |
228 | { | 225 | { |
229 | model->peer->underlay_model_exists = 0; | 226 | model->peer->underlay_model_exists = 0; |
230 | free_entries (model); | 227 | free_entries(model); |
231 | free_link_properties (model); | 228 | free_link_properties(model); |
232 | gnunet_free (model); | 229 | gnunet_free(model); |
233 | } | 230 | } |
234 | 231 | ||
235 | 232 | ||
@@ -240,12 +237,12 @@ GNUNET_TESTBED_underlaylinkmodel_free (struct GNUNET_TESTBED_UnderlayLinkModel * | |||
240 | * @param model the model to commit | 237 | * @param model the model to commit |
241 | */ | 238 | */ |
242 | void | 239 | void |
243 | GNUNET_TESTBED_underlaylinkmodel_commit (struct GNUNET_TESTBED_UnderlayLinkModel *model) | 240 | GNUNET_TESTBED_underlaylinkmodel_commit(struct GNUNET_TESTBED_UnderlayLinkModel *model) |
244 | { | 241 | { |
245 | /* FIXME: Marshal the model into a message */ | 242 | /* FIXME: Marshal the model into a message */ |
246 | GNUNET_break (0); | 243 | GNUNET_break(0); |
247 | /* do not reset the value of model->peer->underlay_model_exists */ | 244 | /* do not reset the value of model->peer->underlay_model_exists */ |
248 | free_entries (model); | 245 | free_entries(model); |
249 | free_link_properties (model); | 246 | free_link_properties(model); |
250 | GNUNET_free (model); | 247 | GNUNET_free(model); |
251 | } | 248 | } |