1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // 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
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FRSH API
36 // FRSH API is free software; you can redistribute it and/or modify
37 // it under the terms of the GNU General Public License as published by
38 // the Free Software Foundation; either version 2, or (at your option)
41 // FRSH API is distributed in the hope that it will be useful, but
42 // WITHOUT ANY WARRANTY; without even the implied warranty of
43 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 // General Public License for more details.
46 // You should have received a copy of the GNU General Public License
47 // distributed with FRSH API; see file COPYING. If not, write to the
48 // Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
51 // As a special exception, if you include this header file into source
52 // files to be compiled, this header file does not by itself cause
53 // the resulting executable to be covered by the GNU General Public
54 // License. This exception does not however invalidate any other
55 // reasons why the executable file might be covered by the GNU General
57 // -----------------------------------------------------------------------
59 //==============================================
60 // ******** **** ** **
61 // **///// /**/** /** ****
62 // ** /**//** /** **//**
63 // ******* /** //** /** ** //**
64 // **//// /** //**/** **********
65 // ** /** //****/**//////**
66 // ** /** //***/** /**
69 // FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
70 //==============================================================
75 #include "frsh_core_types.h" /* for frsh_resource_id_t, frsh_contract_t, etc */
76 #include "fna_error.h" /* for ERROR constants */
77 #include <stdint.h> /* for uint32_t, UINT32_MAX */
80 * @defgroup fna FNA Private Interface
82 * FNA is a Network adaption layer that allows to plugin new
83 * network protocols to the distributed module.
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.
91 //////////////////////////////////////////////////////////////////////
93 //////////////////////////////////////////////////////////////////////
96 * @defgroup fnainit FNA Initialization
99 * These functions need to be called before using any network
107 * This function will be hooked to the frsh_init function and it is
108 * intented to initialize the protocol and its structures.
110 * @param[in] resource_id The network we are referring to (a protocol
111 * could be able to handle several networks at the same time)
115 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
116 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
117 * FNA_ERR_ALREADY_INITIALIZED:
118 * if the function has already been called before (with success) \n
121 int fna_init(const frsh_resource_id_t resource_id);
125 ///////////////////////////////////////////////////////////////////
127 ///////////////////////////////////////////////////////////////////
130 * @defgroup fnavres FNA Virtual Resources
133 * The following functions are used to negotiate, renegotiate and cancel
134 * virtual network resources.
142 * Internal virtual resource id. The type fna_vres_id_t is a pointer to void.
143 * The FRSH layer will keep a map between the frsh_vres_id_t, this
144 * pointer and the resource_id. This pointer could be used as the ID
145 * itself using casting, or as internal pointer to any structure.
148 typedef void *fna_vres_id_t;
153 * The operation negotiates a contract and if accepted it will return
154 * a fna_vres_id_t. It will also check that the given contract_id is unique
155 * within the network.
157 * In object oriented terminology it is similar to a constructor of the
158 * virtual resource class.
160 * If the on-line admission test is enabled, it determines whether the
161 * contract can be admitted or not based on the current contracts
162 * established in the network. Then it creates the vres and
163 * recalculates all necessary parameters for the contracts already
164 * present in the system.
166 * This is a potentially blocking operation, it returns when the
167 * system has either rejected the contract, or admitted it and made it
170 * @param[in] resource_id The network we are referring to (a protocol
171 * could be able to handle several networks at the same time)
172 * @param[in] contract The contract parameters to negotiate
173 * @param[out] vres The internal virtual resource id
176 * FNA_NO_ERROR: in this case it also means contract accepted \n
177 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
178 * FNA_ERR_TOO_MANY_VRES: if there is no space for more vres \n
179 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
180 * FNA_ERR_CONTRACT_REJECTED: if the contract is not accepted \n
181 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
182 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
183 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
187 (const frsh_resource_id_t resource_id,
188 const frsh_contract_t *contract,
189 fna_vres_id_t *vres);
192 * fna_vres_renegotiate_sync()
194 * The operation renegotiates a contract for an existing vres. If
195 * the on-line admission test is enabled it determines whether the
196 * contract can be admitted or not based on the current contracts
197 * established in the system. If it cannot be admitted, the old
198 * contract remains in effect and an error is returned. If it can be
199 * admitted, it recalculates all necessary parameters for the
200 * contracts already present in the system and returns zero. This is a
201 * potentially blocking operation; it returns when the system has
202 * either rejected the new contract, or admitted it and made it
205 * @param[in] resource_id The network we are referring to (a protocol
206 * could be able to handle several networks at the same time)
207 * @param[in] vres The internal virtual resource id to renegotiate
208 * @param[in] new_contract The new contract
211 * FNA_NO_ERROR: in this case it also means contract accepted \n
212 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
213 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
214 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
215 * FNA_ERR_CONTRACT_REJECTED: if the contract is not accepted \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
221 int fna_vres_renegotiate_sync
222 (const frsh_resource_id_t resource_id,
223 const fna_vres_id_t vres,
224 const frsh_contract_t *new_contract);
227 * fna_vres_renegotiate_async()
229 * The operation enqueues a renegotiate operation for an existing
230 * vres, and returns immediately. The renegotiate operation is
231 * performed asynchronously, as soon as it is practical; meanwhile the
232 * system operation will continue normally. When the renegotiation is
233 * made, if the on-line admission test is enabled it determines
234 * whether the contract can be admitted or not based on the current
235 * contracts established in the system. If it cannot be admitted, the
236 * old contract remains in effect. If it can be admitted, it
237 * recalculates all necessary parameters for the contracts already
238 * present in the system.
240 * When the operation is completed, notification is made to the
241 * caller, if requested, via a signal. The status of the operation (in
242 * progress, admitted, rejected) can be checked with the
243 * frsh_vres_get_renegotiation_status() operation. The argument
244 * sig_notify can be FRSH_NULL_SIGNAL (no notification), or any FRSH
245 * signal value and in this case signal_info is to be sent with the signal.
247 * @param[in] resource_id The network we are referring to (a protocol
248 * could be able to handle several networks at the same time)
249 * @param[in] vres The internal virtual resource id to renegotiate
250 * @param[in] new_contract The new contract
251 * @param[in] signal_to_notify Signal number to use to notify vres of
252 * the negotiation result. If FRSH_NULL_SIGNAL, no signal will be raised.
253 * @param[in] signal_info: Associated info that will come with the signal.
254 * This parameter will be ignored if signal_to_notify == FRSH_NULL_SIGNAL.
257 * FNA_NO_ERROR: in this case it also means contract accepted \n
258 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
259 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
260 * FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
261 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
262 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
263 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL, or sig_notify is neither
264 * NULL nor a valid POSIX signal \n
267 int fna_vres_renegotiate_async
268 (const frsh_resource_id_t resource_id,
269 const fna_vres_id_t vres,
270 const frsh_contract_t *new_contract,
271 frsh_signal_t signal_to_notify,
272 frsh_signal_info_t signal_info);
275 * fna_vres_get_renegotiation_status()
277 * The operation reports on the status of the last renegotiation
278 * operation enqueued for the specified vres. It is callable even
279 * after notification of the completion of such operation, if
282 * If the vres is not and has not been involved in any of the
283 * frsh_contract_renegotiate_async() or frsh_group_change_mode_async()
284 * operations, the status returned is FNA_NOT_REQUESTED
286 * @param[in] resource_id The network we are referring to (a protocol
287 * could be able to handle several networks at the same time)
288 * @param[in] vres The internal virtual resource id we want the status from
289 * @param[in] renegotiation_status The status of the last renegotiation on
290 * vres (FRSH_RS_IN_PROGRESS, FRSH_RS_REJECTED, FRSH_RS_ADMITTED,
291 * FRSH_RS_NOT_REQUESTED)
294 * FNA_NO_ERROR: in this case it also means contract accepted \n
295 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
296 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
297 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
298 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
299 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
302 int fna_vres_get_renegotiation_status
303 (const frsh_resource_id_t resource_id,
304 const fna_vres_id_t vres,
305 frsh_renegotiation_status_t *renegotiation_status);
310 * The operation eliminates the specified vres
311 * and recalculates all necessary parameters for the contracts
312 * remaining in the system. This is a potentially blocking operation;
313 * it returns when the system has made the changes effective.
315 * @param[in] resource_id The network we are referring to (a protocol
316 * could be able to handle several networks at the same time)
317 * @param[in] vres The internal virtual resource id to destroy
320 * FNA_NO_ERROR: in this case it also means contract accepted \n
321 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
322 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
323 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
324 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
325 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
329 (const frsh_resource_id_t resource_id,
330 const fna_vres_id_t vres);
333 * fna_vres_get_contract()
335 * This operation stores the contract parameters currently associated
336 * with the specified vres in the variable pointed to by
337 * contract. It returns an error if the vres_id is not recognised.
339 * @param[in] resource_id The network we are referring to (a protocol
340 * could be able to handle several networks at the same time)
341 * @param[in] vres The internal virtual resource id
342 * @param[out] contract The contract parameters that we want
345 * FNA_NO_ERROR: in this case it also means contract accepted \n
346 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
347 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
348 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
349 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
350 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
353 int fna_vres_get_contract
354 (const frsh_resource_id_t resource_id,
355 const fna_vres_id_t vres,
356 frsh_contract_t *contract);
359 * fna_vres_get_usage()
361 * This function gets the execution time spent by all messages that have been
362 * sent through the specified vres.
364 * @param[in] resource_id The network we are referring to (a protocol
365 * could be able to handle several networks at the same time)
366 * @param[in] vres The internal virtual resource id
367 * @param[out] usage Execution time spent by this vres
370 * FNA_NO_ERROR: in this case it also means contract accepted \n
371 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
372 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
373 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
374 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
375 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
378 int fna_vres_get_usage
379 (const frsh_resource_id_t resource_id,
380 const fna_vres_id_t vres,
381 struct timespec *usage);
384 * fna_vres_get_remaining_budget()
386 * This function stores in the variable pointed to by budget the
387 * remaining execution-time budget associated with the specified
388 * vres in the present period.
390 * @param[in] resource_id The network we are referring to (a protocol
391 * could be able to handle several networks at the same time)
392 * @param[in] vres The internal virtual resource id
393 * @param[out] remaining_budget The remaining budget for this period
396 * FNA_NO_ERROR: in this case it also means contract accepted \n
397 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
398 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
399 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
400 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
401 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
404 int fna_vres_get_remaining_budget
405 (const frsh_resource_id_t resource_id,
406 const fna_vres_id_t vres,
407 struct timespec *remaining_budget);
410 * fna_vres_get_budget_and_period()
412 * This function gets the budget and period associated with the specified vres
413 * for each period. If one of these pointers is NULL, the corresponding
414 * information is not stored.
416 * @param[in] resource_id The network we are referring to (a protocol
417 * could be able to handle several networks at the same time)
418 * @param[in] vres The internal virtual resource id
419 * @param[out] budget The budget associated to vres
420 * @param[out] period The period associated to vres
423 * FNA_NO_ERROR: in this case it also means contract accepted \n
424 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
425 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
426 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
427 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
428 * FNA_ERR_BAD_ARGUMENT: if both pointers are NULL \n
431 int fna_vres_get_budget_and_period
432 (const frsh_resource_id_t resource_id,
433 const fna_vres_id_t vres,
434 struct timespec *budget,
435 struct timespec *period);
439 ///////////////////////////////////////////////////////////////////
440 // SPARE CAPACITY FUNCIONS
441 ///////////////////////////////////////////////////////////////////
444 * @defgroup fnaspare FNA Spare Capacity
447 * The following functions are used to get spare capacity data
453 * fna_resource_get_capacity()
455 * This operation gets the spare capacity currently assigned to a importance
456 * level. If we divide this value by UINT32_MAX we will get the network
457 * utilization associated to the spare capacity of a importance level.
459 * The following is typically in stdint.h: \n
460 * - typedef unsigned int uint32_t; \n
461 * - # define UINT32_MAX (4294967295U) \n
463 * @param[in] resource_id The network we are referring to (a protocol
464 * could be able to handle several networks at the same time)
465 * @param[in] importance The importance we want the capacity of
466 * @param[out] capacity The spare capacity for that importance level
469 * FNA_NO_ERROR: in this case it also means contract accepted \n
470 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
471 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
472 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
473 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
476 int fna_resource_get_capacity
477 (const frsh_resource_id_t resource_id,
478 const int importance,
482 * fna_resource_get_total_weight()
484 * This function gets the sum of the weight parameters for all vres in a
485 * network of an importance level.
487 * @param[in] resource_id The network we are referring to (a protocol
488 * could be able to handle several networks at the same time)
489 * @param[in] importance The importance we want the total weight of
490 * @param[out] total_weight The total weight for that importance level
493 * FNA_NO_ERROR: in this case it also means contract accepted \n
494 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
495 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
496 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
497 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
500 int fna_resource_get_total_weight
501 (const frsh_resource_id_t resource_id,
502 const int importance,
506 * fna_vres_decrease_capacity()
508 * This function allows to ask for less budget and period than what we
509 * received. The request must be compatible with the rest of contract
510 * parameters of the vres. If we want to recover the released capacity
511 * we will need to renegotiate.
513 * @param[in] resource_id The network we are referring to (a protocol
514 * could be able to handle several networks at the same time)
515 * @param[in] vres The internal virtual resource id
516 * @param[in] new_budget The new_budget
517 * @param[in] new_period The new Period
520 * FNA_NO_ERROR: in this case it also means contract accepted \n
521 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
522 * FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
523 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
524 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
525 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
526 * FNA_ERR_CONTRACT_REJECTED: if it is incompatible with the current
530 int fna_vres_decrease_capacity
531 (const frsh_resource_id_t resource_id,
532 const fna_vres_id_t vres,
533 const struct timespec new_budget,
534 const struct timespec new_period);
538 ///////////////////////////////////////////////////////////////////
539 // SEND RECEIVE OPERATIONS
540 ///////////////////////////////////////////////////////////////////
543 * @defgroup fnasendrecv FNA Send and Receive
546 * The following functions are used to send and receive
554 * Similar to previous function but now the sending thread gets blocked
555 * until the message is already sent to the network.
557 * @param[in] endpoint The send endpoint we are sending through. It must
558 * be bound to a virtual resource (resource_id is in the endpoint).
559 * @param[in] msg The message we want to send
560 * @param[in] size The size in bytes of the message
563 * FNA_NO_ERROR: in this case it also means contract accepted \n
564 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
565 * FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
566 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
567 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
568 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
569 * FNA_ERR_TOO_LARGE: if the message is too large for the network protocol \n
570 * FNA_ERR_BUFFER_FULL: if the message has been discarded because
571 * the queue is full (and does not have the policy FNA_QP_OLDEST) \n
575 (const frsh_send_endpoint_t *endpoint,
582 * This operation sends a message stored in msg and of length size
583 * through the given send endpoint. The operation is non-blocking and
584 * returns immediately.
586 * @param[in] endpoint The send endpoint we are sending through. It must
587 * be bound to a virtual resource (resource_id is in the endpoint).
588 * @param[in] msg The message we want to send
589 * @param[in] size The size in bytes of the message
592 * FNA_NO_ERROR: in this case it also means contract accepted \n
593 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
594 * FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
595 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
596 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
597 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
598 * FNA_ERR_TOO_LARGE: if the message is too large for the network protocol \n
599 * FNA_ERR_BUFFER_FULL: if the message has been discarded because
600 * the queue is full (and does not have the policy FNA_QP_OLDEST) \n
604 (const frsh_send_endpoint_t *endpoint,
611 * This operation is used to receive messages from the network with a
612 * blocking behavior (if there are no messages this operation blocks
613 * the calling thread).
615 * When a message is available, it is copied to buffer (up to its size).
616 * The number of bytes copied is returned in received_bytes. The rest
617 * of the bytes of that message will be lost or not depending on the
618 * protocol (FNA_ERR_NO_SPACE will be returned if it is).
620 * The function fails with FNA_ERR_NO_SPACE if the buffersize is
621 * too small for the message received. In this case the message is
624 * Messages arriving at a receiver buffer that is full will be handled
625 * according to the queueing policy of the endpoint (overwrite oldest,
628 * @param[in] endpoint The receive endpoint we are receiving from.
629 * (resource_id is in the endpoint).
630 * @param[out] buffer Buffer for storing the received message
631 * @param[in] buffer_size The size in bytes of this buffer
632 * @param[out] received_bytes The actual number of received bytes
635 * FNA_NO_ERROR: in this case it also means contract accepted \n
636 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
637 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
638 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
639 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
640 * FNA_ERR_NO_SPACE: if the message size is bigger than the
641 * provided buffer. \n
645 (const frsh_receive_endpoint_t *endpoint,
647 const size_t buffer_size,
648 size_t *received_bytes);
651 * fna_receive_async()
653 * This operation is similar to the previous one but it works in a non
654 * blocking (asynchronous) fashion. If no message is available it
655 * returns with error FNA_NO_MESSAGE.
657 * @param[in] endpoint The receive endpoint we are receiving from.
658 * (resource_id is in the endpoint).
659 * @param[out] buffer Buffer for storing the received message
660 * @param[in] buffer_size The size in bytes of this buffer
661 * @param[out] received_bytes The actual number of received bytes
664 * FNA_NO_ERROR: in this case it also means contract accepted \n
665 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
666 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
667 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
668 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
669 * FNA_ERR_NO_SPACE: if the message size is bigger than the
670 * provided buffer. \n
671 * FNA_NO_MESSAGE: if no messages are available in the queue. \n
674 int fna_receive_async
675 (const frsh_receive_endpoint_t *endpoint,
677 const size_t buffer_size,
678 size_t *received_bytes);
681 * fna_send_endpoint_get_status()
683 * This function tells the number of messages still pending in the
684 * endpoint queue, whether the network is up or down with some
685 * optional information which is protocol_dependent.
687 * @param[in] endpoint The send endpoint (resource_id is in the endpoint).
688 * @param[out] number_of_pending_messages The number of pending messages
689 * @param[out] network_status How is the network (up, down..)
690 * @param[out] protocol_status Protocol dependent status info
693 * FNA_NO_ERROR: in this case it also means contract accepted \n
694 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
695 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
696 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
697 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
700 int fna_send_endpoint_get_status(const frsh_send_endpoint_t *endpoint,
701 int *number_of_pending_messages,
702 frsh_endpoint_network_status *network_status,
703 frsh_protocol_status_t *protocol_status);
706 * fna_receive_endpoint_create()
708 * This operation creates a receive endpoint associated with a
709 * undirectional stream within a network interface of the node.
711 * Receiving endpoints are not bound to any network vres, this is
712 * because don't originate any traffic.
714 * Note that the protocol address is not needed for reception because
715 * it can be determined internally by FRSH based on the network_id.
717 * Note also that messages may come from diferent originators.
719 * @param[in] resource_id Id of the network from which we listen.
720 * @param[in] stream_id Id of the stream within the network.
721 * @param[in] queueing_info Buffering information(queue size and
723 * @param[in] protocol_info Extra protocol info opaque for the
725 * @param[out] endpoint Placeholder for the endpoint object.
728 * FNA_NO_ERROR: in this case it also means contract accepted \n
729 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
730 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
731 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
732 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
734 int fna_receive_endpoint_create
735 (const frsh_resource_id_t resource_id,
736 const frsh_stream_id_t stream_id,
737 const frsh_endpoint_queueing_info_t queueing_info,
738 const frsh_protocol_info_t protocol_info,
739 frsh_receive_endpoint_t *endpoint);
742 * fna_receive_endpoint_get_pending_messages
744 * This function tells the number of messages still pending in the
745 * endpoint queue, whether the network is up or down and some optional
746 * information which is protocol dependent.
748 * @param[in] endpoint The receive endpoint (resource_id is in the endpoint).
749 * @param[out] number_of_pending_messages The number of pending messages
750 * @param[out] network_status How is the network (up, down..)
751 * @param[out] protocol_status Protocol dependent status info
754 * FNA_NO_ERROR: in this case it also means contract accepted \n
755 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
756 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
757 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
758 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
761 int fna_receive_endpoint_get_status
762 (const frsh_receive_endpoint_t *endpoint,
763 int *number_of_pending_messages,
764 frsh_endpoint_network_status *network_status,
765 frsh_protocol_status_t *protocol_status);
769 //////////////////////////////////////////////////////////////////////
770 // NETWORK CONFIGURATION FUNCTIONS
771 //////////////////////////////////////////////////////////////////////
774 * @defgroup frshfnaconfig FNA Network Configuration
777 * These functions are needed to set/get some network dependent values
783 * fna_message_get_tx_time()
785 * This operation gives the physical transmission time that it takes to
786 * send a message of the nbytes size through the network designated by
787 * resource_id, not including any network overheads (fragmentation in packets,
788 * headers, retransmissions,...).
790 * It is be used by the application to calculate the minimum and
791 * maximum budgets used in the preparation of network contracts.
792 * (Note that in the negotiation overheads must be taken into account)
794 * @param[in] resource_id The network we want the tx time from.
795 * @param[in] nbytes Number of bytes of the message
796 * @param[out] tx_time The transmission time for nbytes (without overheads)
799 * FNA_NO_ERROR: in this case it also means contract accepted \n
800 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
801 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
802 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
803 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL or nbytes is bigger than
804 * the maximum message size \n
807 int fna_message_get_tx_time
808 (const frsh_resource_id_t resource_id,
810 struct timespec *tx_time);
813 * fna_message_get_max_size()
815 * This operation gives the maximum number of bytes that can be sent
816 * in a single message through the network designated by resource_id.
817 * If the application needs to send bigger messages it will have to
818 * split them. Some protocols like TCP/IP are capable of sending large
819 * messages (and use fragmentation internally) but other protocols doesn't
820 * provide fragmentation features so the maximum size will be the MTU itself.
822 * It is be used by the application to calculate the minimum and
823 * maximum budgets used in the preparation of network contracts.
825 * @param[in] resource_id The network we want the tx time from.
826 * @param[out] max_size The maximum number of bytes for each message
829 * FNA_NO_ERROR: in this case it also means contract accepted \n
830 * FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
831 * FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
832 * FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
833 * FNA_ERR_BAD_ARGUMENT: if pointers are NULL or nbytes is bigger than
834 * the maximum message size \n
837 int fna_message_get_max_size
838 (const frsh_resource_id_t resource_id,