aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_underlay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_underlay.c')
-rw-r--r--src/testbed/testbed_api_underlay.c81
1 files changed, 46 insertions, 35 deletions
diff --git a/src/testbed/testbed_api_underlay.c b/src/testbed/testbed_api_underlay.c
index b0c712ca6..7e509fdfe 100644
--- a/src/testbed/testbed_api_underlay.c
+++ b/src/testbed/testbed_api_underlay.c
@@ -30,7 +30,8 @@
30/** 30/**
31 * An underlay link 31 * An underlay link
32 */ 32 */
33struct LinkProperty { 33struct LinkProperty
34{
34 /** 35 /**
35 * next pointer for list 36 * next pointer for list
36 */ 37 */
@@ -61,7 +62,8 @@ struct LinkProperty {
61/** 62/**
62 * Container for holding a peer in whitelist/blacklist 63 * Container for holding a peer in whitelist/blacklist
63 */ 64 */
64struct ListEntry { 65struct ListEntry
66{
65 /** 67 /**
66 * the next pointer 68 * the next pointer
67 */ 69 */
@@ -78,7 +80,8 @@ struct ListEntry {
78 * Model for configuring underlay links of a peer 80 * Model for configuring underlay links of a peer
79 * @ingroup underlay 81 * @ingroup underlay
80 */ 82 */
81struct GNUNET_TESTBED_UnderlayLinkModel { 83struct GNUNET_TESTBED_UnderlayLinkModel
84{
82 /** 85 /**
83 * The peer associated with this model 86 * The peer associated with this model
84 */ 87 */
@@ -107,15 +110,15 @@ struct GNUNET_TESTBED_UnderlayLinkModel {
107 * @param model the model 110 * @param model the model
108 */ 111 */
109static void 112static void
110free_entries(struct GNUNET_TESTBED_UnderlayLinkModel *model) 113free_entries (struct GNUNET_TESTBED_UnderlayLinkModel *model)
111{ 114{
112 struct ListEntry *e; 115 struct ListEntry *e;
113 116
114 while (NULL != (e = model->entries)) 117 while (NULL != (e = model->entries))
115 { 118 {
116 model->entries = e->next; 119 model->entries = e->next;
117 GNUNET_free(e); 120 GNUNET_free (e);
118 } 121 }
119} 122}
120 123
121 124
@@ -125,15 +128,15 @@ free_entries(struct GNUNET_TESTBED_UnderlayLinkModel *model)
125 * @param model the model 128 * @param model the model
126 */ 129 */
127static void 130static void
128free_link_properties(struct GNUNET_TESTBED_UnderlayLinkModel *model) 131free_link_properties (struct GNUNET_TESTBED_UnderlayLinkModel *model)
129{ 132{
130 struct LinkProperty *p; 133 struct LinkProperty *p;
131 134
132 while (NULL != (p = model->props)) 135 while (NULL != (p = model->props))
133 { 136 {
134 model->props = p->next; 137 model->props = p->next;
135 GNUNET_free(p); 138 GNUNET_free (p);
136 } 139 }
137} 140}
138 141
139 142
@@ -147,13 +150,15 @@ free_link_properties(struct GNUNET_TESTBED_UnderlayLinkModel *model)
147 * @return the model 150 * @return the model
148 */ 151 */
149struct GNUNET_TESTBED_UnderlayLinkModel * 152struct GNUNET_TESTBED_UnderlayLinkModel *
150GNUNET_TESTBED_underlaylinkmodel_create(struct GNUNET_TESTBED_Peer *peer, 153GNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer,
151 enum GNUNET_TESTBED_UnderlayLinkModelType type) 154 enum
155 GNUNET_TESTBED_UnderlayLinkModelType
156 type)
152{ 157{
153 struct GNUNET_TESTBED_UnderlayLinkModel *m; 158 struct GNUNET_TESTBED_UnderlayLinkModel *m;
154 159
155 GNUNET_assert(0 == peer->underlay_model_exists); 160 GNUNET_assert (0 == peer->underlay_model_exists);
156 m = GNUNET_new(struct GNUNET_TESTBED_UnderlayLinkModel); 161 m = GNUNET_new (struct GNUNET_TESTBED_UnderlayLinkModel);
157 peer->underlay_model_exists = 1; 162 peer->underlay_model_exists = 1;
158 m->type = type; 163 m->type = type;
159 return m; 164 return m;
@@ -170,12 +175,14 @@ GNUNET_TESTBED_underlaylinkmodel_create(struct GNUNET_TESTBED_Peer *peer,
170 * @param peer the peer to add 175 * @param peer the peer to add
171 */ 176 */
172void 177void
173GNUNET_TESTBED_underlaylinkmodel_add_peer(struct GNUNET_TESTBED_UnderlayLinkModel *model, 178GNUNET_TESTBED_underlaylinkmodel_add_peer (struct
174 struct GNUNET_TESTBED_Peer *peer) 179 GNUNET_TESTBED_UnderlayLinkModel *
180 model,
181 struct GNUNET_TESTBED_Peer *peer)
175{ 182{
176 struct ListEntry *entry; 183 struct ListEntry *entry;
177 184
178 entry = GNUNET_new(struct ListEntry); 185 entry = GNUNET_new (struct ListEntry);
179 entry->peer = peer; 186 entry->peer = peer;
180 entry->next = model->entries; 187 entry->next = model->entries;
181 model->entries = entry; 188 model->entries = entry;
@@ -194,15 +201,17 @@ GNUNET_TESTBED_underlaylinkmodel_add_peer(struct GNUNET_TESTBED_UnderlayLinkMode
194 * @param bandwidth bandwidth of the link in kilobytes per second [kB/s] 201 * @param bandwidth bandwidth of the link in kilobytes per second [kB/s]
195 */ 202 */
196void 203void
197GNUNET_TESTBED_underlaylinkmodel_set_link(struct GNUNET_TESTBED_UnderlayLinkModel *model, 204GNUNET_TESTBED_underlaylinkmodel_set_link (struct
198 struct GNUNET_TESTBED_Peer *peer, 205 GNUNET_TESTBED_UnderlayLinkModel *
199 uint32_t latency, 206 model,
200 uint32_t loss, 207 struct GNUNET_TESTBED_Peer *peer,
201 uint32_t bandwidth) 208 uint32_t latency,
209 uint32_t loss,
210 uint32_t bandwidth)
202{ 211{
203 struct LinkProperty *prop; 212 struct LinkProperty *prop;
204 213
205 prop = GNUNET_new(struct LinkProperty); 214 prop = GNUNET_new (struct LinkProperty);
206 prop->peer = peer; 215 prop->peer = peer;
207 prop->latency = latency; 216 prop->latency = latency;
208 prop->loss = loss; 217 prop->loss = loss;
@@ -221,12 +230,13 @@ GNUNET_TESTBED_underlaylinkmodel_set_link(struct GNUNET_TESTBED_UnderlayLinkMode
221 * @param model the model to unallocate 230 * @param model the model to unallocate
222 */ 231 */
223void 232void
224GNUNET_TESTBED_underlaylinkmodel_free(struct GNUNET_TESTBED_UnderlayLinkModel *model) 233GNUNET_TESTBED_underlaylinkmodel_free (struct
234 GNUNET_TESTBED_UnderlayLinkModel *model)
225{ 235{
226 model->peer->underlay_model_exists = 0; 236 model->peer->underlay_model_exists = 0;
227 free_entries(model); 237 free_entries (model);
228 free_link_properties(model); 238 free_link_properties (model);
229 gnunet_free(model); 239 gnunet_free (model);
230} 240}
231 241
232 242
@@ -237,12 +247,13 @@ GNUNET_TESTBED_underlaylinkmodel_free(struct GNUNET_TESTBED_UnderlayLinkModel *m
237 * @param model the model to commit 247 * @param model the model to commit
238 */ 248 */
239void 249void
240GNUNET_TESTBED_underlaylinkmodel_commit(struct GNUNET_TESTBED_UnderlayLinkModel *model) 250GNUNET_TESTBED_underlaylinkmodel_commit (struct
251 GNUNET_TESTBED_UnderlayLinkModel *model)
241{ 252{
242 /* FIXME: Marshal the model into a message */ 253 /* FIXME: Marshal the model into a message */
243 GNUNET_break(0); 254 GNUNET_break (0);
244 /* do not reset the value of model->peer->underlay_model_exists */ 255 /* do not reset the value of model->peer->underlay_model_exists */
245 free_entries(model); 256 free_entries (model);
246 free_link_properties(model); 257 free_link_properties (model);
247 GNUNET_free(model); 258 GNUNET_free (model);
248} 259}