]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_rtep/rtep_frsh_fna_c.c
Unified header for FNA
[frescor/fna.git] / src_rtep / rtep_frsh_fna_c.c
1 //----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2009 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 #include "frsh_fna.h"
55 #include "rtep_bandwith_reservation.h"
56
57 //////////////////////////////////////////////////////////////////////
58 //           MAPPING FUNCTIONS
59 //////////////////////////////////////////////////////////////////////
60
61 /**
62  * frsh_XXXX_map_network_address()
63  *
64  * To map a XXXX protocol network address into a FRSH address.
65  * The protocol must keep this mapping consistent. Instead of using a function
66  * a hardwired mapping could be used.
67  *
68  * @param[in] resource_id The network we are referring to (a protocol
69  * could be able to handle several networks at the same time)
70  * @param[in] in_address The network address we want to map to a frsh address
71  * @param[out] out_address The FRSH abstract network address
72  *
73  * @return
74  *   FNA_NO_ERROR: in this case it also means contract accepted \n
75  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
76  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
77  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
78  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
79  *
80  **/
81 int frsh_rtep_map_network_address
82       (const frsh_resource_id_t resource_id,
83        const rtep_station_id_t in_address,
84        frsh_network_address_t *out_address)
85 {
86     if (out_address == NULL) return -1;
87     *out_address = in_address;
88     return 0;
89 }
90
91 /**
92  * frsh_XXXX_map_stream_id()
93  *
94  * To map a XXXX protocol network stream, port, channel... into a FRSH stream.
95  * The protocol must keep this mapping consistent. Instead of using a function
96  * a hardwired mapping could be used.
97  *
98  * @param[in] resource_id The network we are referring to (a protocol
99  * could be able to handle several networks at the same time)
100  * @param[in] in_stream The network stream we want to map to a FRSH stream
101  * @param[out] out_stream The FRSH abstract network stream
102  *
103  * @return
104  *   FNA_NO_ERROR: in this case it also means contract accepted \n
105  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
106  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
107  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
108  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
109  *
110  **/
111 int frsh_rtep_map_stream_id
112       (const frsh_resource_id_t resource_id,
113        const rtep_channel_t in_stream,
114        frsh_stream_id_t *out_stream)
115 {
116     if (out_stream == NULL) return -1;
117     *out_stream = in_stream;
118     return 0;
119 }
120
121 ///////////////////////////////////////////////////////////////////
122 //           NEGOTIATION SERVICE PARAMETERS
123 ///////////////////////////////////////////////////////////////////
124
125 /**
126  * frsh_XXXX_negotiation_messages__vres_renegotiate()
127  *
128  * This function allows the application to change the minimum period
129  * of the negotiation messages sent through the network. It is similar
130  * to the service thread but for the network messages. We do not provide
131  * budget here because the size of the negotiation messages is fixed.
132  *
133  * This change is similar to a renegotiation so a schedulability test
134  * must be done to see if the change can be accepted or not.
135  *
136  * @param[in] resource_id The network we are referring to (a protocol
137  * could be able to handle several networks at the same time)
138  * @param[in] period The new period for negotiation messages
139  * @param[out] accepted If the change has been accepted or not
140  *
141  * @return
142  *   FNA_NO_ERROR: in this case it also means contract accepted \n
143  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
144  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
145  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
146  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
147  *
148  **/
149
150 int frsh_rtep_negotiation_messages_vres_renegotiate
151       (const frsh_resource_id_t resource_id,
152        const struct timespec *period)
153 {
154     return rtep_bwres_renegotiate_negotiation_period(period);
155 }
156
157 /**
158  * frsh_XXXX_negotiation_messages_vres_get_period()
159  *
160  * This function gets the minimum period of the negotiation messages
161  * sent through the network.
162  *
163  * @param[in] resource_id The network we are referring to (a protocol
164  * could be able to handle several networks at the same time)
165  * @param[out] period The period for negotiation messages
166  *
167  * @return
168  *   FNA_NO_ERROR: in this case it also means contract accepted \n
169  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
170  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
171  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
172  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
173  *
174  **/
175 int frsh_rtep_negotiation_messages_vres_get_period
176       (const frsh_resource_id_t resource_id,
177        struct timespec *period)
178 {
179     return rtep_bwres_get_negotiation_period (period);
180 }
181
182 /**
183  * frsh_XXXX_service_thread_vres_renegotiate()
184  *
185  * This function allows the application to change the period and
186  * budget of the service thread that makes the negotiations and
187  * schedulability tests in a network.
188  *
189  * The service thread starts with a default budget and period that
190  * should be configurable
191  *
192  * @param[in] resource_id The network we are referring to (a protocol
193  * could be able to handle several networks at the same time)
194  * @param[in] budget The new budget for the service thread
195  * @param[in] period The new period for the service thread
196  * @param[out] accepted If the negotiation has been accepted or not
197  *
198  * @return
199  *   FNA_NO_ERROR: in this case it also means contract accepted \n
200  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
201  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
202  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
203  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
204  *
205  **/
206 int frsh_rtep_service_thread_vres_renegotiate
207    (const frsh_resource_id_t resource_id,
208     const struct timespec *budget,
209     const struct timespec *period,
210     bool *accepted)
211 {
212     return -1;
213 }
214
215 /**
216  * frsh_XXXX_service_thread_vres_get_budget_and_period()
217  *
218  * This function gets the budget and period of a service thread.
219  *
220  * @param[in] resource_id The network we are referring to (a protocol
221  * could be able to handle several networks at the same time)
222  * @param[out] budget The budget of the service thread
223  * @param[out] period The period of the service thread
224  *
225  * @return
226  *   FNA_NO_ERROR: in this case it also means contract accepted \n
227  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
228  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
229  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
230  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
231  *
232  **/
233 int frsh_rtep_service_thread_vres_get_budget_and_period
234       (const frsh_resource_id_t resource_id,
235        struct timespec *budget,
236        struct timespec *period)
237 {
238     return -1;
239 }
240