]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_data.c
b35c441c08247540370d849efedbff58e6622019
[frescor/fna.git] / src_frescan / frescan_data.c
1 /*!
2  * @file frescan_data.c
3  *
4  * @brief global data used from different modules in frescan
5  *
6  * @version 0.01
7  *
8  * @date 12-Mar-2008
9  *
10  * @author
11  *      Daniel Sangorrin
12  *
13  * @comments
14  *
15  * In frescan_data module we store global data to FRESCAN to make the protocol
16  * easier and efficient to implement.
17  *
18  * @license
19  *
20  * -----------------------------------------------------------------------
21  *  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
22  *
23  *    Universidad de Cantabria,              SPAIN
24  *    University of York,                    UK
25  *    Scuola Superiore Sant'Anna,            ITALY
26  *    Kaiserslautern University,             GERMANY
27  *    Univ. Politécnica  Valencia,           SPAIN
28  *    Czech Technical University in Prague,  CZECH REPUBLIC
29  *    ENEA                                   SWEDEN
30  *    Thales Communication S.A.              FRANCE
31  *    Visual Tools S.A.                      SPAIN
32  *    Rapita Systems Ltd                     UK
33  *    Evidence                               ITALY
34  *
35  *    See http://www.frescor.org for a link to partners' websites
36  *
37  *           FRESCOR project (FP6/2005/IST/5-034026) is funded
38  *        in part by the European Union Sixth Framework Programme
39  *        The European Union is not liable of any use that may be
40  *        made of this code.
41  *
42  *  This file is part of FRESCAN
43  *
44  *  FRESCAN is free software; you can  redistribute it and/or  modify
45  *  it under the terms of  the GNU General Public License as published by
46  *  the Free Software Foundation;  either  version 2, or (at  your option)
47  *  any later version.
48  *
49  *  FRESCAN  is distributed  in  the hope  that  it  will  be useful,  but
50  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
51  *  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
52  *  General Public License for more details.
53  *
54  *  You should have  received a  copy of  the  GNU  General Public License
55  *  distributed  with  FRESCAN;  see file COPYING.   If not,  write to the
56  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
57  *  02111-1307, USA.
58  *
59  * As a special exception, including FRESCAN header files in a file,
60  * instantiating FRESCAN generics or templates, or linking other files
61  * with FRESCAN objects to produce an executable application, does not
62  * by itself cause the resulting executable application to be covered
63  * by the GNU General Public License. This exception does not
64  * however invalidate any other reasons why the executable file might be
65  * covered by the GNU Public License.
66  * -----------------------------------------------------------------------
67  *
68  */
69
70 #include "frescan_data.h"
71 #include "frescan_debug.h"
72
73 frescan_network_data_t the_networks[FRESCAN_MX_NETWORKS];
74 frescan_server_data_t the_servers_pool[FRESCAN_MX_NETWORKS][FRESCAN_MX_IDS];
75 freelist_t the_servers_pool_freelist[FRESCAN_MX_NETWORKS];
76 frescan_server_data_t the_active_servers[FRESCAN_MX_NETWORKS];
77
78 /**
79  * frescan_data_init() - init the data global variables
80  *
81  */
82
83 int frescan_data_init(int fd, frescan_init_params_t *params)
84 {
85         frescan_ss_t id;
86         frescan_prio_t prio;
87         frescan_node_t src;
88
89         the_networks[params->net].fd = fd;
90         the_networks[params->net].local_node = params->node;
91         the_networks[params->net].last_packet = NULL;
92         the_networks[params->net].last_packet_prio = 0;
93
94         FRESCAN_CREATE_LOCK(&the_networks[params->net].lock);
95
96         for(id=0; id<FRESCAN_MX_IDS; id++) {
97                 for(src=0; src<FRESCAN_MX_NODES; src++) {
98                         the_networks[params->net].id_queues[src][id] = NULL;
99                 }
100         }
101
102         for(prio=0; prio<FRESCAN_MX_PRIOS; prio++) {
103                 for(src=0; src<FRESCAN_MX_NODES; src++) {
104                         the_networks[params->net].id_fp_queues[src][prio] = NULL;
105                 }
106         }
107
108         return 0;
109 }