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