/*
- This file is part of GNUnet.
- Copyright (C) 2008--2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ This file is part of GNUnet.
+ Copyright (C) 2008--2013 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file testbed/gnunet-service-testbed_links.c
#ifdef LOG
#undef LOG
#endif
-#define LOG(kind,...) \
+#define LOG(kind, ...) \
GNUNET_log_from (kind, "testbed-links", __VA_ARGS__)
/**
* The slave host
*/
uint32_t slave_host_id;
-
};
/**
* Task id for the task to call notifications from the notification list
*/
- struct GNUNET_SCHEDULER_Task * notify_task;
+ struct GNUNET_SCHEDULER_Task *notify_task;
/**
* How many references are present currently to this neighbour's connection
/**
* The lcf_task handle
*/
-static struct GNUNET_SCHEDULER_Task * lcf_proc_task_id;
+static struct GNUNET_SCHEDULER_Task *lcf_proc_task_id;
/**
* The size of the route list
neighbour_list_add (struct Neighbour *n)
{
if (n->host_id >= neighbour_list_size)
- GST_array_grow_large_enough (neighbour_list, neighbour_list_size, n->host_id);
+ GST_array_grow_large_enough (neighbour_list, neighbour_list_size,
+ n->host_id);
GNUNET_assert (NULL == neighbour_list[n->host_id]);
neighbour_list[n->host_id] = n;
}
lcf->state = DELEGATED_HOST_REGISTERED;
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
break;
+
case DELEGATED_HOST_REGISTERED:
if (NULL != emsg)
goto registration_error;
lcf->state = SLAVE_HOST_REGISTERED;
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
break;
+
default:
GNUNET_assert (0); /* Shouldn't reach here */
}
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
}
break;
+
case DELEGATED_HOST_REGISTERED:
if (GNUNET_NO ==
GNUNET_TESTBED_is_host_registered_ (GST_host_list[lcf->slave_host_id],
lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf);
}
break;
+
case SLAVE_HOST_REGISTERED:
lcf->op = GNUNET_TESTBED_controller_link (lcf,
lcf->gateway->controller,
- GST_host_list[lcf->delegated_host_id],
+ GST_host_list[lcf->
+ delegated_host_id],
GST_host_list[lcf->slave_host_id],
lcf->is_subordinate);
lcf->timeout_task =
- GNUNET_SCHEDULER_add_delayed (GST_timeout,
- &lcf_forwarded_operation_timeout,
- lcf);
+ GNUNET_SCHEDULER_add_delayed (GST_timeout,
+ &lcf_forwarded_operation_timeout,
+ lcf);
lcf->state = FINISHED;
break;
+
case FINISHED:
if (NULL != lcf->op)
GNUNET_TESTBED_operation_done (lcf->op);
if (NULL == event->details.operation_finished.emsg)
send_controller_link_response (lcf->client, lcf->operation_id,
GNUNET_TESTBED_host_get_cfg_
- (GST_host_list[lcf->delegated_host_id]),
+ (GST_host_list[lcf->delegated_host_id]),
NULL);
else
send_controller_link_response (lcf->client, lcf->operation_id,
goto clean_lcc;
}
slave->controller =
- GNUNET_TESTBED_controller_connect (GST_host_list[slave->host_id],
- EVENT_MASK, &slave_event_cb,
- slave);
+ GNUNET_TESTBED_controller_connect (GST_host_list[slave->host_id],
+ EVENT_MASK, &slave_event_cb,
+ slave);
if (NULL != slave->controller)
{
send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL);
slave = NULL;
}
- clean_lcc:
+clean_lcc:
if (NULL != lcc)
{
if (NULL != lcc->client)
}
n->reference_cnt++;
n->notify_task =
- GNUNET_SCHEDULER_add_now (&neighbour_connect_notify_task, n);
+ GNUNET_SCHEDULER_add_now (&neighbour_connect_notify_task, n);
}
static void
oprelease_neighbour_conn (void *cls)
{
- struct Neighbour *n = cls;
-
- GNUNET_assert (0 == n->reference_cnt);
- GNUNET_assert (NULL == n->notify_task);
- GNUNET_assert (NULL == n->nl_head);
- if (NULL != n->controller)
- {
- LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
- GNUNET_TESTBED_controller_disconnect (n->controller);
- n->controller = NULL;
- }
- n->conn_op = NULL;
- n->inactive = 0;
+ struct Neighbour *n = cls;
+
+ GNUNET_assert (0 == n->reference_cnt);
+ GNUNET_assert (NULL == n->notify_task);
+ GNUNET_assert (NULL == n->nl_head);
+ if (NULL != n->controller)
+ {
+ LOG_DEBUG ("Closing connection to controller on host %u\n", n->host_id);
+ GNUNET_TESTBED_controller_disconnect (n->controller);
+ n->controller = NULL;
+ }
+ n->conn_op = NULL;
+ n->inactive = 0;
}
n->host_id);
h = GNUNET_new (struct NeighbourConnectNotification);
h->n = n;
- h->cb = cb;
+ h->cb = cb;
h->cb_cls = cb_cls;
GNUNET_CONTAINER_DLL_insert_tail (n->nl_head, n->nl_tail, h);
if (NULL == n->conn_op)
n->notify_task = NULL;
if (NULL == n->nl_head)
{
- if ( (0 == n->reference_cnt) && (0 == n->inactive) )
+ if ((0 == n->reference_cnt) && (0 == n->inactive))
{
n->inactive = 1;
GNUNET_TESTBED_operation_inactivate_ (n->conn_op);
static void
timeout_neighbour_connect (void *cls)
{
- struct NeighbourConnectCtxt *ncc = cls;
-
- ncc->timeout_task = NULL;
- send_controller_link_response (ncc->client,
- ncc->op_id,
- NULL,
- "Could not connect to delegated controller");
- cleanup_ncc (ncc);
+ struct NeighbourConnectCtxt *ncc = cls;
+
+ ncc->timeout_task = NULL;
+ send_controller_link_response (ncc->client,
+ ncc->op_id,
+ NULL,
+ "Could not connect to delegated controller");
+ cleanup_ncc (ncc);
}
n = GNUNET_new (struct Neighbour);
n->host_id = GNUNET_TESTBED_host_get_id_ (host);
- neighbour_list_add (n); /* just add; connect on-demand */
+ neighbour_list_add (n); /* just add; connect on-demand */
return n;
}
struct NeighbourConnectCtxt *ncc;
if ((delegated_host_id < neighbour_list_size) &&
- (NULL != neighbour_list[delegated_host_id]))
+ (NULL != neighbour_list[delegated_host_id]))
{
GNUNET_break (0);
GNUNET_SERVICE_client_drop (client);
GNUNET_SERVICE_client_continue (client);
return;
}
- if ( (delegated_host_id < GST_slave_list_size) &&
- (NULL != GST_slave_list[delegated_host_id]) )
+ if ((delegated_host_id < GST_slave_list_size) &&
+ (NULL != GST_slave_list[delegated_host_id]))
{
GNUNET_break (0);
GNUNET_SERVICE_client_drop (client);
lcf->delegated_host_id = delegated_host_id;
lcf->slave_host_id = slave_host_id;
route = GST_find_dest_route (slave_host_id);
- GNUNET_assert (NULL != route); /* because we add routes carefully */
+ GNUNET_assert (NULL != route); /* because we add routes carefully */
GNUNET_assert (route->dest < GST_slave_list_size);
GNUNET_assert (NULL != GST_slave_list[route->dest]);
lcf->is_subordinate = msg->is_subordinate;
GNUNET_SERVICE_client_continue (client);
return;
}
- if ( (delegated_host_id < route_list_size) &&
- (NULL != route_list[delegated_host_id]) )
+ if ((delegated_host_id < route_list_size) &&
+ (NULL != route_list[delegated_host_id]))
{
GNUNET_break_op (0); /* Are you trying to link delegated host twice
* with is subordinate flag set to GNUNET_YES? */
if (ncc->client == client)
cleanup_ncc (ncc);
}
- for (unsigned int i=0;i<GST_slave_list_size;i++)
+ for (unsigned int i = 0; i < GST_slave_list_size; i++)
{
struct Slave *slave = GST_slave_list[i];
struct LinkControllersContext *lcc;
for (lcf = lcf_head; NULL != lcf; lcf = lcfn)
{
lcfn = lcf->next;
- if ( (NULL != lcf) &&
- (client == lcf->client) )
+ if ((NULL != lcf) &&
+ (client == lcf->client))
{
if (NULL != lcf->op)
GNUNET_TESTBED_operation_done (lcf->op);