]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - include/frsh_fna.h
preparing to do unix fna
[frescor/fna.git] / include / frsh_fna.h
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 //==============================================
54 //  ******** ****     **     **
55 //  **///// /**/**   /**    ****
56 //  **      /**//**  /**   **//**
57 //  ******* /** //** /**  **  //**
58 //  **////  /**  //**/** **********
59 //  **      /**   //****/**//////**
60 //  **      /**    //***/**     /**
61 //  /       //      /// //      //
62 //
63 // FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
64 //==============================================================
65
66 #ifndef _FRSH_FNA_H_
67 #define _FRSH_FNA_H_
68
69 #include "frsh_core_types.h" /* for frsh_resource_id_t */
70 #include "frsh_distributed_types.h" /* network_address_t, stream_id_t */
71 #include <time.h> /* for timespec */
72 #include <stdbool.h> /* for bool */
73 #include "fna_configuration.h"
74
75 #ifdef RTEP_FNA_ENABLED
76    #include "rtep.h"
77 #endif
78
79 /**
80  * @defgroup frshfna FNA Public Interface
81  *
82  * FNA is a Network adaption layer that allows to plugin new
83  * network protocols to the distributed module.
84  *
85  * It is divided in two parts:
86  *  - FRSH_FNA: public types and functions for the FRSH API
87  *  - FNA: private functions only used within FRSH.
88  *
89  **/
90
91 ////////////////////////////////////////////////////////////////////
92 //          MAPPING FUNCTIONS
93 ////////////////////////////////////////////////////////////////////
94
95 /**
96  * @defgroup frshfnamap FNA Mapping Functions
97  * @ingroup frshfna
98  *
99  * These functions are needed to map network specific types to FRSH types.
100  * Instead of providing this mapping functions a static hardwired configuration
101  * could be used.
102  *
103  * @{
104  **/
105
106 /**
107  * frsh_XXXX_map_network_address()
108  *
109  * To map a XXXX protocol network address into a FRSH address.
110  * The protocol must keep this mapping consistent. Instead of using a function
111  * a hardwired mapping could be used.
112  *
113  * @param[in] resource_id The network we are referring to (a protocol
114  * could be able to handle several networks at the same time)
115  * @param[in] in_address The network address we want to map to a frsh address
116  * @param[out] out_address The FRSH abstract network address
117  *
118  * @return
119  *   FNA_NO_ERROR: in this case it also means contract accepted \n
120  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
121  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
122  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
123  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
124  *
125  **/
126 #ifdef RTEP_FNA_ENABLED
127 int frsh_rtep_map_network_address(const frsh_resource_id_t resource_id,
128                                   const rtep_station_id_t in_address,
129                                   frsh_network_address_t *out_address);
130 #endif
131
132 /**
133  * frsh_XXXX_map_stream_id()
134  *
135  * To map a XXXX protocol network stream, port, channel... into a FRSH stream.
136  * The protocol must keep this mapping consistent. Instead of using a function
137  * a hardwired mapping could be used.
138  *
139  * @param[in] resource_id The network we are referring to (a protocol
140  * could be able to handle several networks at the same time)
141  * @param[in] in_stream The network stream we want to map to a FRSH stream
142  * @param[out] out_stream The FRSH abstract network stream
143  *
144  * @return
145  *   FNA_NO_ERROR: in this case it also means contract accepted \n
146  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
147  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
148  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
149  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
150  *
151  **/
152 #ifdef RTEP_FNA_ENABLED
153 int frsh_rtep_map_stream_id(const frsh_resource_id_t resource_id,
154                             const rtep_channel_t in_stream,
155                             frsh_stream_id_t *out_stream);
156 #endif
157
158 /*@}*/
159
160 ///////////////////////////////////////////////////////////////////
161 //           NEGOTIATION SERVICE PARAMETERS
162 ///////////////////////////////////////////////////////////////////
163 /**
164  * @defgroup frshfnaserv FNA Negotiation Service Parameters
165  * @ingroup frshfna
166  *
167  * These functions are needed to set/get the negotiation service parameters.
168  *
169  * @{
170  **/
171
172 /**
173  * frsh_XXXX_negotiation_messages__vres_renegotiate()
174  *
175  * This function allows the application to change the minimum period
176  * of the negotiation messages sent through the network. It is similar
177  * to the service thread but for the network messages. We do not provide
178  * budget here because the size of the negotiation messages is fixed.
179  *
180  * This change is similar to a renegotiation so a schedulability test
181  * must be done to see if the change can be accepted or not.
182  *
183  * @param[in] resource_id The network we are referring to (a protocol
184  * could be able to handle several networks at the same time)
185  * @param[in] period The new period for negotiation messages
186  * @param[out] accepted If the change has been accepted or not
187  *
188  * @return
189  *   FNA_NO_ERROR: in this case it also means contract accepted \n
190  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
191  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
192  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
193  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
194  *   FNA_ERR_REJECTED_CONTRACT : if the renegotiation fails \n
195  *
196  **/
197 #ifdef RTEP_FNA_ENABLED
198 int frsh_rtep_negotiation_messages_vres_renegotiate
199       (const frsh_resource_id_t resource_id,
200        const struct timespec *period);
201 #endif
202
203 /**
204  * frsh_XXXX_negotiation_messages_vres_get_period()
205  *
206  * This function gets the minimum period of the negotiation messages
207  * sent through the network.
208  *
209  * @param[in] resource_id The network we are referring to (a protocol
210  * could be able to handle several networks at the same time)
211  * @param[out] period The period for negotiation messages
212  *
213  * @return
214  *   FNA_NO_ERROR: in this case it also means contract accepted \n
215  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
216  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
217  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
218  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
219  *
220  **/
221 #ifdef RTEP_FNA_ENABLED
222 int frsh_rtep_negotiation_messages_vres_get_period
223       (const frsh_resource_id_t resource_id,
224        struct timespec *period);
225 #endif
226
227 /**
228  * frsh_XXXX_service_thread_vres_renegotiate()
229  *
230  * This function allows the application to change the period and
231  * budget of the service thread that makes the negotiations and
232  * schedulability tests in a network.
233  *
234  * The service thread starts with a default budget and period that
235  * should be configurable
236  *
237  * @param[in] resource_id The network we are referring to (a protocol
238  * could be able to handle several networks at the same time)
239  * @param[in] budget The new budget for the service thread
240  * @param[in] period The new period for the service thread
241  * @param[out] accepted If the negotiation has been accepted or not
242  *
243  * @return
244  *   FNA_NO_ERROR: in this case it also means contract accepted \n
245  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
246  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
247  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
248  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
249  *
250  **/
251 #ifdef RTEP_FNA_ENABLED
252 int frsh_rtep_service_thread_vres_renegotiate
253    (const frsh_resource_id_t resource_id,
254     const struct timespec *budget,
255     const struct timespec *period,
256     bool *accepted);
257 #endif
258
259 /**
260  * frsh_XXXX_service_thread_vres_get_budget_and_period()
261  *
262  * This function gets the budget and period of a service thread.
263  *
264  * @param[in] resource_id The network we are referring to (a protocol
265  * could be able to handle several networks at the same time)
266  * @param[out] budget The budget of the service thread
267  * @param[out] period The period of the service thread
268  *
269  * @return
270  *   FNA_NO_ERROR: in this case it also means contract accepted \n
271  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
272  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
273  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
274  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
275  *
276  **/
277 #ifdef RTEP_FNA_ENABLED
278 int frsh_rtep_service_thread_vres_get_budget_and_period
279       (const frsh_resource_id_t resource_id,
280        struct timespec *budget,
281        struct timespec *period);
282 #endif
283
284 /*@}*/
285
286 #endif /* _FRSH_FNA_H_ */