]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_unix/unix_fna.c
preparing to do unix fna
[frescor/fna.git] / src_unix / unix_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 //==============================================
54 //  ******** ****     **     **
55 //  **///// /**/**   /**    ****
56 //  **      /**//**  /**   **//**
57 //  ******* /** //** /**  **  //**
58 //  **////  /**  //**/** **********
59 //  **      /**   //****/**//////**
60 //  **      /**    //***/**     /**
61 //  /       //      /// //      //
62 //
63 // FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
64 //==============================================================
65 #include <malloc.h>   /* for malloc and free */
66 #include "unix_fna.h" /* function prototypes */
67
68 #if 1
69 #include <stdio.h>
70 #define DEBUG(x,args...) printf("%s: " x, __func__ , ##args)
71 #else
72 #define DEBUG(x,args...)
73 #endif
74
75 //////////////////////////////////////////////////////////////////////
76 //           INITIALIZATION
77 //////////////////////////////////////////////////////////////////////
78
79 char *the_unix_stream_ids[MX_UNIX_STREAM_IDS] = {
80         "/tmp/stream00",
81         "/tmp/stream01",
82         "/tmp/stream02",
83         "/tmp/stream03",
84         "/tmp/stream04",
85         "/tmp/stream05"
86 };
87
88 /**
89  * unix_fna_init()
90  *
91  **/
92
93 int unix_fna_init(const frsh_resource_id_t resource_id)
94 {
95         DEBUG("NOT IMPLEMENTED\n");
96         return 0;
97 }
98
99 ///////////////////////////////////////////////////////////////////
100 //           VIRTUAL RESOURCES
101 ///////////////////////////////////////////////////////////////////
102
103 /**
104  * unix_fna_contract_negotiate()
105  *
106  **/
107
108 int unix_fna_contract_negotiate(const frsh_resource_id_t resource_id,
109                                 const frsh_contract_t *contract,
110                                 fna_vres_id_t *vres)
111 {
112         DEBUG("NOT IMPLEMENTED\n");
113         return 0;
114 }
115
116 /**
117  * unix_fna_contract_renegotiate_sync()
118  *
119  **/
120
121 int unix_fna_contract_renegotiate_sync(const frsh_resource_id_t resource_id,
122                                        const fna_vres_id_t vres,
123                                        const frsh_contract_t *new_contract)
124 {
125         DEBUG("NOT IMPLEMENTED\n");
126         return 0;
127 }
128
129 /**
130  * unix_fna_contract_renegotiate_async()
131  *
132  **/
133
134 int unix_fna_contract_renegotiate_async(const frsh_resource_id_t resource_id,
135                                         const fna_vres_id_t vres,
136                                         const frsh_contract_t *new_contract,
137                                         frsh_signal_t signal_to_notify,
138                                         frsh_signal_info_t signal_info)
139 {
140         DEBUG("NOT IMPLEMENTED\n");
141         return 0;
142 }
143
144 /**
145  * unix_fna_vres_get_renegotiation_status()
146  *
147  **/
148
149 int unix_fna_vres_get_renegotiation_status(const frsh_resource_id_t resource_id,
150                                            const fna_vres_id_t vres,
151                                            frsh_renegotiation_status_t *renegotiation_status)
152 {
153         DEBUG("NOT IMPLEMENTED\n");
154         return 0;
155 }
156
157 /**
158  * unix_fna_vres_destroy()
159  *
160  **/
161
162 int unix_fna_vres_destroy(const frsh_resource_id_t resource_id,
163                           const fna_vres_id_t vres)
164 {
165         DEBUG("NOT IMPLEMENTED\n");
166         return 0;
167 }
168
169 /**
170  * unix_fna_vres_get_contract()
171  *
172  **/
173
174 int unix_fna_vres_get_contract(const frsh_resource_id_t resource_id,
175                                const fna_vres_id_t vres,
176                                frsh_contract_t *contract)
177 {
178         DEBUG("NOT IMPLEMENTED\n");
179         return 0;
180 }
181
182 /**
183  * unix_fna_vres_get_usage()
184  *
185  **/
186
187 int unix_fna_vres_get_usage(const frsh_resource_id_t resource_id,
188                             const fna_vres_id_t vres,
189                             struct timespec *usage)
190 {
191         DEBUG("NOT IMPLEMENTED\n");
192         return 0;
193 }
194
195 /**
196  * unix_fna_vres_get_remaining_budget()
197  *
198  **/
199
200 int unix_fna_vres_get_remaining_budget(const frsh_resource_id_t resource_id,
201                                        const fna_vres_id_t vres,
202                                        struct timespec *remaining_budget)
203 {
204         DEBUG("NOT IMPLEMENTED\n");
205         return 0;
206 }
207
208 /**
209  * unix_fna_vres_get_budget_and_period()
210  *
211  **/
212
213 int unix_fna_vres_get_budget_and_period(const frsh_resource_id_t resource_id,
214                                         const fna_vres_id_t vres,
215                                         struct timespec *budget,
216                                         struct timespec *period)
217 {
218         DEBUG("NOT IMPLEMENTED\n");
219         return 0;
220 }
221
222 ///////////////////////////////////////////////////////////////////
223 //           SPARE CAPACITY FUNCIONS
224 ///////////////////////////////////////////////////////////////////
225
226 /**
227  * unix_fna_resource_get_capacity()
228  *
229  **/
230
231 int unix_fna_resource_get_capacity(const frsh_resource_id_t resource_id,
232                                    const int importance,
233                                    uint32_t *capacity)
234 {
235         DEBUG("NOT IMPLEMENTED\n");
236         return 0;
237 }
238
239 /**
240  * unix_fna_resource_get_total_weight()
241  *
242  **/
243
244 int unix_fna_resource_get_total_weight(const frsh_resource_id_t resource_id,
245                                        const int importance,
246                                        int *total_weight)
247 {
248         DEBUG("NOT IMPLEMENTED\n");
249         return 0;
250 }
251
252 /**
253  * unix_fna_vres_decrease_capacity()
254  *
255  **/
256
257 int unix_fna_vres_decrease_capacity(const frsh_resource_id_t resource_id,
258                                     const fna_vres_id_t vres,
259                                     const struct timespec new_budget,
260                                     const struct timespec new_period)
261 {
262         DEBUG("NOT IMPLEMENTED\n");
263         return 0;
264 }
265
266 ///////////////////////////////////////////////////////////////////
267 //           SEND RECEIVE OPERATIONS
268 ///////////////////////////////////////////////////////////////////
269
270 /**
271  * unix_fna_send_sync()
272  *
273  **/
274
275 int unix_fna_send_sync(const fna_endpoint_data_t *endpoint,
276                        const void *msg,
277                        const size_t size)
278 {
279         DEBUG("NOT IMPLEMENTED\n");
280         return 0;
281 }
282
283 /**
284  * unix_fna_send_async()
285  *
286  **/
287
288 int unix_fna_send_async(const fna_endpoint_data_t *endpoint,
289                         const void *msg,
290                         const size_t size)
291 {
292         DEBUG("send async\n");
293         return 0;
294 }
295
296 /**
297  * unix_fna_receive_sync()
298  *
299  **/
300
301 int unix_fna_receive_sync(const fna_endpoint_data_t *endpoint,
302                           void *buffer,
303                           const size_t buffer_size,
304                           size_t *received_bytes,
305                           frsh_network_address_t *from)
306 {
307         DEBUG("receive sync\n");
308         return 0;
309 }
310
311 /**
312  * unix_fna_receive_async()
313  *
314  **/
315
316 int unix_fna_receive_async(const fna_endpoint_data_t *endpoint,
317                            void *buffer,
318                            const size_t buffer_size,
319                            size_t *received_bytes,
320                            frsh_network_address_t *from)
321 {
322         DEBUG("NOT IMPLEMENTED\n");
323         return 0;
324 }
325
326 /**
327  * unix_fna_send_endpoint_get_status()
328  *
329  **/
330
331 int unix_fna_send_endpoint_get_status(const fna_endpoint_data_t *endpoint,
332                                       int *number_of_pending_messages,
333                                       frsh_endpoint_network_status_t *network_status,
334                                       frsh_protocol_status_t *protocol_status)
335 {
336         DEBUG("NOT IMPLEMENTED\n");
337         return 0;
338 }
339
340 /**
341  * unix_fna_receive_endpoint_created()
342  *
343  **/
344 int unix_fna_receive_endpoint_created(const fna_endpoint_data_t *endpoint)
345 {
346         DEBUG("NOT IMPLEMENTED\n");
347         return 0;
348 }
349
350 /**
351  * unix_fna_receive_endpoint_get_pending_messages
352  *
353  **/
354
355 int unix_fna_receive_endpoint_get_status(const fna_endpoint_data_t *endpoint,
356                                          int *number_of_pending_messages,
357                                          frsh_endpoint_network_status_t *network_status,
358                                          frsh_protocol_status_t *protocol_status)
359 {
360         DEBUG("NOT IMPLEMENTED\n");
361         return 0;
362 }
363
364 //////////////////////////////////////////////////////////////////////
365 //           NETWORK CONFIGURATION FUNCTIONS
366 //////////////////////////////////////////////////////////////////////
367
368 /**
369  * unix_fna_network_get_max_message_size()
370  *
371  **/
372
373 int unix_fna_network_get_max_message_size(const frsh_resource_id_t resource_id,
374                                           const frsh_network_address_t destination,
375                                           size_t *max_size)
376 {
377         DEBUG("NOT IMPLEMENTED\n");
378         return 0;
379 }
380
381 /**
382  * unix_fna_network_bytes_to_budget()
383  *
384  **/
385
386 int unix_fna_network_bytes_to_budget(const frsh_resource_id_t resource_id,
387                                      const size_t nbytes,
388                                      struct timespec *budget)
389 {
390         DEBUG("NOT IMPLEMENTED\n");
391         return 0;
392 }
393
394 /**
395  * unix_fna_network_budget_to_bytes()
396  *
397  **/
398
399 int unix_fna_network_budget_to_bytes(const frsh_resource_id_t resource_id,
400                                      const struct timespec *budget,
401                                      size_t *nbytes)
402 {
403         DEBUG("NOT IMPLEMENTED\n");
404         return 0;
405 }
406
407 /**
408  * unix_fna_network_get_min_eff_budget()
409  *
410  **/
411
412 int unix_fna_network_get_min_eff_budget(const frsh_resource_id_t resource_id,
413                                         struct timespec *budget)
414 {
415         DEBUG("NOT IMPLEMENTED\n");
416         return 0;
417 }
418
419 // GLOBAL variable to install the network protocol in FRESCOR
420
421 fna_operations_t unix_fna_operations = {
422         .fna_init = unix_fna_init,
423         .fna_contract_negotiate = unix_fna_contract_negotiate,
424         .fna_contract_renegotiate_sync = unix_fna_contract_renegotiate_sync,
425         .fna_contract_renegotiate_async = unix_fna_contract_renegotiate_async,
426         .fna_vres_get_renegotiation_status = unix_fna_vres_get_renegotiation_status,
427         .fna_vres_destroy = unix_fna_vres_destroy,
428         .fna_vres_get_contract = unix_fna_vres_get_contract,
429         .fna_vres_get_usage = unix_fna_vres_get_usage,
430         .fna_vres_get_remaining_budget = unix_fna_vres_get_remaining_budget,
431         .fna_vres_get_budget_and_period = unix_fna_vres_get_budget_and_period,
432         .fna_resource_get_capacity = unix_fna_resource_get_capacity,
433         .fna_resource_get_total_weight = unix_fna_resource_get_total_weight,
434         .fna_vres_decrease_capacity = unix_fna_vres_decrease_capacity,
435         .fna_send_sync = unix_fna_send_sync,
436         .fna_send_async = unix_fna_send_async,
437         .fna_receive_sync = unix_fna_receive_sync,
438         .fna_receive_async = unix_fna_receive_async,
439         .fna_send_endpoint_get_status = unix_fna_send_endpoint_get_status,
440         .fna_receive_endpoint_created = unix_fna_receive_endpoint_created,
441         .fna_receive_endpoint_get_status = unix_fna_receive_endpoint_get_status,
442         .fna_network_get_max_message_size = unix_fna_network_get_max_message_size,
443         .fna_network_bytes_to_budget = unix_fna_network_bytes_to_budget,
444         .fna_network_budget_to_bytes = unix_fna_network_budget_to_bytes,
445         .fna_network_get_min_eff_budget = unix_fna_network_get_min_eff_budget
446 };