]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_frsh_fna.c
c7bbbd65812d9a1a19224c22dae53ed613a1b094
[frescor/fna.git] / src_frescan / frescan_frsh_fna.c
1 //----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
3 //
4 //    Universidad de Cantabria,              SPAIN
5 //    University of York,                    UK
6 //    Scuola Superiore Sant'Anna,            ITALY
7 //    Kaiserslautern University,             GERMANY
8 //    Univ. Politecnica  Valencia,           SPAIN
9 //    Czech Technical University in Prague,  CZECH REPUBLIC
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //
16 //    See http://www.frescor.org
17 //
18 //        The FRESCOR project (FP6/2005/IST/5-034026) is funded
19 //        in part by the European Union Sixth Framework Programme
20 //        The European Union is not liable of any use that may be
21 //        made of this code.
22 //
23 //
24 //  based on previous work (FSF) done in the FIRST project
25 //
26 //   Copyright (C) 2005  Mälardalen University, SWEDEN
27 //                       Scuola Superiore S.Anna, ITALY
28 //                       Universidad de Cantabria, SPAIN
29 //                       University of York, UK
30 //
31 // This file is part of FNA (Frescor Network Adaptation)
32 //
33 // FNA is free software; you can redistribute it and/or modify it
34 // under terms of the GNU General Public License as published by the
35 // Free Software Foundation; either version 2, or (at your option) any
36 // later version.  FNA is distributed in the hope that it will be
37 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
38 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 // General Public License for more details. You should have received a
40 // copy of the GNU General Public License along with FNA; see file
41 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
42 // Cambridge, MA 02139, USA.
43 //
44 // As a special exception, including FNA header files in a file,
45 // instantiating FNA generics or templates, or linking other files
46 // with FNA objects to produce an executable application, does not
47 // by itself cause the resulting executable application to be covered
48 // by the GNU General Public License. This exception does not
49 // however invalidate any other reasons why the executable file might be
50 // covered by the GNU Public License.
51 // -----------------------------------------------------------------------
52
53 #include "frsh_fna.h"
54 #include "frescan.h"
55
56 #undef ERROR
57 #include "frescan_debug.h"
58
59 //////////////////////////////////////////////////////////////////////
60 //           MAPPING FUNCTIONS
61 //////////////////////////////////////////////////////////////////////
62
63 /**
64  * frsh_XXXX_map_network_address()
65  *
66  * To map a XXXX protocol network address into a FRSH address.
67  * The protocol must keep this mapping consistent. Instead of using a function
68  * a hardwired mapping could be used.
69  *
70  * @param[in] resource_id The network we are referring to (a protocol
71  * could be able to handle several networks at the same time)
72  * @param[in] in_address The network address we want to map to a frsh address
73  * @param[out] out_address The FRSH abstract network address
74  *
75  * @return
76  *   FNA_NO_ERROR: in this case it also means contract accepted \n
77  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
78  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
79  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
80  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
81  *
82  **/
83 int frsh_frescan_map_network_address
84       (const frsh_resource_id_t resource_id,
85        const frescan_node_t in_address,
86        frsh_network_address_t *out_address)
87 {
88     if (out_address == NULL) return -1;
89     *out_address = in_address;
90     return 0;
91 }
92
93 /**
94  * frsh_XXXX_map_stream_id()
95  *
96  * To map a XXXX protocol network stream, port, channel... into a FRSH stream.
97  * The protocol must keep this mapping consistent. Instead of using a function
98  * a hardwired mapping could be used.
99  *
100  * @param[in] resource_id The network we are referring to (a protocol
101  * could be able to handle several networks at the same time)
102  * @param[in] in_stream The network stream we want to map to a FRSH stream
103  * @param[out] out_stream The FRSH abstract network stream
104  *
105  * @return
106  *   FNA_NO_ERROR: in this case it also means contract accepted \n
107  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
108  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
109  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
110  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
111  *
112  **/
113 int frsh_frescan_map_stream_id
114       (const frsh_resource_id_t resource_id,
115        const frescan_channel_t in_stream,
116        frsh_stream_id_t *out_stream)
117 {
118     if (out_stream == NULL) return -1;
119     *out_stream = in_stream;
120     return 0;
121 }
122
123 ///////////////////////////////////////////////////////////////////
124 //           NEGOTIATION SERVICE PARAMETERS
125 ///////////////////////////////////////////////////////////////////
126
127 /**
128  * frsh_XXXX_negotiation_messages__vres_renegotiate()
129  *
130  * This function allows the application to change the minimum period
131  * of the negotiation messages sent through the network. It is similar
132  * to the service thread but for the network messages. We do not provide
133  * budget here because the size of the negotiation messages is fixed.
134  *
135  * This change is similar to a renegotiation so a schedulability test
136  * must be done to see if the change can be accepted or not.
137  *
138  * @param[in] resource_id The network we are referring to (a protocol
139  * could be able to handle several networks at the same time)
140  * @param[in] period The new period for negotiation messages
141  * @param[out] accepted If the change has been accepted or not
142  *
143  * @return
144  *   FNA_NO_ERROR: in this case it also means contract accepted \n
145  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
146  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
147  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
148  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
149  *
150  **/
151
152 int frsh_frescan_negotiation_messages_vres_renegotiate
153       (const frsh_resource_id_t resource_id,
154        const struct timespec *period)
155 {
156         ERROR("not implemented\n");
157         return -1;
158 }
159
160 /**
161  * frsh_XXXX_negotiation_messages_vres_get_period()
162  *
163  * This function gets the minimum period of the negotiation messages
164  * sent through the network.
165  *
166  * @param[in] resource_id The network we are referring to (a protocol
167  * could be able to handle several networks at the same time)
168  * @param[out] period The period for negotiation messages
169  *
170  * @return
171  *   FNA_NO_ERROR: in this case it also means contract accepted \n
172  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
173  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
174  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
175  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
176  *
177  **/
178 int frsh_frescan_negotiation_messages_vres_get_period
179       (const frsh_resource_id_t resource_id,
180        struct timespec *period)
181 {
182         ERROR("not implemented\n");
183         return -1;
184 }
185
186 /**
187  * frsh_XXXX_service_thread_vres_renegotiate()
188  *
189  * This function allows the application to change the period and
190  * budget of the service thread that makes the negotiations and
191  * schedulability tests in a network.
192  *
193  * The service thread starts with a default budget and period that
194  * should be configurable
195  *
196  * @param[in] resource_id The network we are referring to (a protocol
197  * could be able to handle several networks at the same time)
198  * @param[in] budget The new budget for the service thread
199  * @param[in] period The new period for the service thread
200  * @param[out] accepted If the negotiation has been accepted or not
201  *
202  * @return
203  *   FNA_NO_ERROR: in this case it also means contract accepted \n
204  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
205  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
206  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
207  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
208  *
209  **/
210 int frsh_frescan_service_thread_vres_renegotiate
211    (const frsh_resource_id_t resource_id,
212     const struct timespec *budget,
213     const struct timespec *period,
214     bool *accepted)
215 {
216         ERROR("not implemented\n");
217         return -1;
218 }
219
220 /**
221  * frsh_XXXX_service_thread_vres_get_budget_and_period()
222  *
223  * This function gets the budget and period of a service thread.
224  *
225  * @param[in] resource_id The network we are referring to (a protocol
226  * could be able to handle several networks at the same time)
227  * @param[out] budget The budget of the service thread
228  * @param[out] period The period of the service thread
229  *
230  * @return
231  *   FNA_NO_ERROR: in this case it also means contract accepted \n
232  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
233  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
234  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
235  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
236  *
237  **/
238 int frsh_frescan_service_thread_vres_get_budget_and_period
239       (const frsh_resource_id_t resource_id,
240        struct timespec *budget,
241        struct timespec *period)
242 {
243         ERROR("not implemented\n");
244         return -1;
245 }