listen_socket_t listen_socket[MAXSOCKETS];
int listen_sockets;
-list_t *outgoing_list = NULL;
/* Setup sockets */
void try_outgoing_connections(void) {
/* If there is no outgoing list yet, create one. Otherwise, mark all outgoings as deleted. */
- if(!outgoing_list) {
- outgoing_list = list_alloc((list_action_t)free_outgoing);
+ if(!mesh->outgoings) {
+ mesh->outgoings = list_alloc((list_action_t)free_outgoing);
} else {
- for list_each(outgoing_t, outgoing, outgoing_list)
+ for list_each(outgoing_t, outgoing, mesh->outgoings)
outgoing->timeout = -1;
}
/* Make sure there is one outgoing_t in the list for each ConnectTo. */
// TODO: Drop support for ConnectTo since AutoConnect is now always on?
- for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
+ for(config_t *cfg = lookup_config(mesh->config, "ConnectTo"); cfg; cfg = lookup_config_next(mesh->config, cfg)) {
char *name;
get_config_string(cfg, &name);
bool found = false;
- for list_each(outgoing_t, outgoing, outgoing_list) {
+ for list_each(outgoing_t, outgoing, mesh->outgoings) {
if(!strcmp(outgoing->name, name)) {
found = true;
outgoing->timeout = 0;
if(!found) {
outgoing_t *outgoing = xzalloc(sizeof *outgoing);
outgoing->name = name;
- list_insert_tail(outgoing_list, outgoing);
+ list_insert_tail(mesh->outgoings, outgoing);
setup_outgoing_connection(outgoing);
}
}
/* Terminate any connections whose outgoing_t is to be deleted. */
- for list_each(connection_t, c, connection_list) {
+ for list_each(connection_t, c, mesh->connections) {
if(c->outgoing && c->outgoing->timeout == -1) {
c->outgoing = NULL;
logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name);
/* Delete outgoing_ts for which there is no ConnectTo. */
- for list_each(outgoing_t, outgoing, outgoing_list)
+ for list_each(outgoing_t, outgoing, mesh->outgoings)
if(outgoing->timeout == -1)
- list_delete_node(outgoing_list, node);
+ list_delete_node(mesh->outgoings, node);
}