2 connection.c -- connection list management
3 Copyright (C) 2000-2013 Guus Sliepen <guus@meshlink.io>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "connection.h"
31 list_t *connection_list;
32 connection_t *everyone;
34 void init_connections(void) {
35 connection_list = list_alloc((list_action_t) free_connection);
36 everyone = new_connection();
37 everyone->name = xstrdup("everyone");
38 everyone->hostname = xstrdup("BROADCAST");
41 void exit_connections(void) {
42 list_delete_list(connection_list);
43 free_connection(everyone);
46 connection_t *new_connection(void) {
47 return xzalloc(sizeof(connection_t));
50 void free_connection(connection_t *c) {
54 sptps_stop(&c->sptps);
57 buffer_clear(&c->inbuf);
58 buffer_clear(&c->outbuf);
63 closesocket(c->socket);
69 exit_configuration(&c->config_tree);
74 void connection_add(connection_t *c) {
75 list_insert_tail(connection_list, c);
78 void connection_del(connection_t *c) {
79 list_delete(connection_list, c);