]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - include/fna.h
use rel_time type instead of timespec
[frescor/fna.git] / include / fna.h
index 9229fb4a3575126e9a26ef11c27c935e89612bb0..cea2b442f8842cfb552cb16b5f5860556c066a67 100644 (file)
@@ -1,11 +1,11 @@
-// -----------------------------------------------------------------------
-//  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
 //
 //    Universidad de Cantabria,              SPAIN
 //    University of York,                    UK
 //    Scuola Superiore Sant'Anna,            ITALY
 //    Kaiserslautern University,             GERMANY
-//    Univ. Politécnica  Valencia,           SPAIN
+//    Univ. Politecnica  Valencia,           SPAIN
 //    Czech Technical University in Prague,  CZECH REPUBLIC
 //    ENEA                                   SWEDEN
 //    Thales Communication S.A.              FRANCE
@@ -13,9 +13,9 @@
 //    Rapita Systems Ltd                     UK
 //    Evidence                               ITALY
 //
-//    See http://www.frescor.org for a link to partners' websites
+//    See http://www.frescor.org
 //
-//           FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
 //        in part by the European Union Sixth Framework Programme
 //        The European Union is not liable of any use that may be
 //        made of this code.
 //                       Universidad de Cantabria, SPAIN
 //                       University of York, UK
 //
-//   FSF API web pages: http://marte.unican.es/fsf/docs
-//                      http://shark.sssup.it/contrib/first/docs/
-//
-//  This file is part of FRSH API
-//
-//  FRSH API is free software; you can  redistribute it and/or  modify
-//  it under the terms of  the GNU General Public License as published by
-//  the Free Software Foundation;  either  version 2, or (at  your option)
-//  any later version.
+// This file is part of FNA (Frescor Network Adaptation)
 //
-//  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
-//  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
-//  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
-//  General Public License for more details.
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
 //
-//  You should have  received a  copy of  the  GNU  General Public License
-//  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
-//  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
-//  02111-1307, USA.
-//
-//  As a special exception, if you include this header file into source
-//  files to be compiled, this header file does not by itself cause
-//  the resulting executable to be covered by the GNU General Public
-//  License.  This exception does not however invalidate any other
-//  reasons why the executable file might be covered by the GNU General
-//  Public License.
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
 // -----------------------------------------------------------------------
 
 //==============================================
 #ifndef _FNA_H_
 #define _FNA_H_
 
-#include "frsh_core_types.h" /* for frsh_resource_id_t, frsh_contract_t, etc */
-#include "fna_error.h" /* for ERROR constants */
-#include <stdint.h> /* for uint32_t, UINT32_MAX */
+/* for frsh_resource_id_t, frsh_contract_t, for frsh_network_address_t,
+   frsh_stream_id_t, ... */
+#include "frsh.h"
+/* for timespec */
+#include <time.h>
+/* for ERROR constants */
+// #include "fna_error.h"
+/* for uint32_t, UINT32_MAX */
+#include <stdint.h>
 
 /**
  * @defgroup fna FNA Private Interface
@@ -88,6 +88,7 @@
  *
  **/
 
+
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
 //////////////////////////////////////////////////////////////////////
  * could be able to handle several networks at the same time)
  *
  * @return
- *   FNA_NO_ERROR \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_ALREADY_INITIALIZED:
  *      if the function has already been called before (with success) \n
  *
  **/
-int fna_init(const frsh_resource_id_t resource_id);
+typedef int fna_init_t(const frsh_resource_id_t resource_id);
 
 /*@}*/
 
@@ -139,13 +140,12 @@ int fna_init(const frsh_resource_id_t resource_id);
 /**
  * fna_vres_id_t
  *
- * Internal virtual resource id. The type fna_vres_id_t is a pointer to void.
- * The FRSH layer will keep a map between the frsh_vres_id_t, this
- * pointer and the resource_id. This pointer could be used as the ID
- * itself using casting, or as internal pointer to any structure.
+ * Internal virtual resource id. In the current implementation it is a 16 bits
+ * value (up to 65536 vres) so it can be integrated easily with the
+ * frsh_vres_id_t type (see frsh_internal_data.h)
  *
  **/
-typedef void *fna_vres_id_t;
+typedef uint16_t fna_vres_id_t;
 
 /**
  * fna_contract_negotiate()
@@ -170,7 +170,7 @@ typedef void *fna_vres_id_t;
  * @param[out] vres The internal virtual resource id
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors (in this case it also means contract accepted) \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_TOO_MANY_VRES: if there is no space for more vres \n
  *   FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
@@ -180,7 +180,7 @@ typedef void *fna_vres_id_t;
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_contract_negotiate
+typedef int fna_contract_negotiate_t
    (const frsh_resource_id_t resource_id,
     const frsh_contract_t *contract,
     fna_vres_id_t *vres);
@@ -205,7 +205,7 @@ int fna_contract_negotiate
  * @param[in] new_contract The new contract
  *
  *  @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors (in this case it also means contract accepted) \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
@@ -215,7 +215,7 @@ int fna_contract_negotiate
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_contract_renegotiate_sync
+typedef int fna_contract_renegotiate_sync_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     const frsh_contract_t *new_contract);
@@ -251,7 +251,7 @@ int fna_contract_renegotiate_sync
  * This parameter will be ignored if signal_to_notify == FRSH_NULL_SIGNAL.
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_CONTRACT_ID_ALREADY_EXISTS: contract_id is not unique \n
@@ -261,7 +261,7 @@ int fna_contract_renegotiate_sync
  *      NULL nor a valid POSIX signal \n
  *
  **/
-int fna_contract_renegotiate_async
+typedef int fna_contract_renegotiate_async_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     const frsh_contract_t *new_contract,
@@ -288,7 +288,7 @@ int fna_contract_renegotiate_async
  * FRSH_RS_NOT_REQUESTED)
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -296,7 +296,7 @@ int fna_contract_renegotiate_async
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_vres_get_renegotiation_status
+typedef int fna_vres_get_renegotiation_status_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     frsh_renegotiation_status_t *renegotiation_status);
@@ -314,7 +314,7 @@ int fna_vres_get_renegotiation_status
  * @param[in] vres The internal virtual resource id to destroy
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -322,7 +322,7 @@ int fna_vres_get_renegotiation_status
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_vres_destroy
+typedef int fna_vres_destroy_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres);
 
@@ -339,7 +339,7 @@ int fna_vres_destroy
  * @param[out] contract  The contract parameters that we want
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -347,7 +347,7 @@ int fna_vres_destroy
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_vres_get_contract
+typedef int fna_vres_get_contract_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     frsh_contract_t *contract);
@@ -364,7 +364,7 @@ int fna_vres_get_contract
  * @param[out] usage  Execution time spent by this vres
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -372,7 +372,7 @@ int fna_vres_get_contract
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_vres_get_usage
+typedef int fna_vres_get_usage_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     struct timespec *usage);
@@ -390,7 +390,7 @@ int fna_vres_get_usage
  * @param[out] remaining_budget  The remaining budget for this period
  *
  *  @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -398,7 +398,7 @@ int fna_vres_get_usage
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_vres_get_remaining_budget
+typedef int fna_vres_get_remaining_budget_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     struct timespec *remaining_budget);
@@ -417,7 +417,7 @@ int fna_vres_get_remaining_budget
  * @param[out] period  The period associated to vres
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -425,7 +425,7 @@ int fna_vres_get_remaining_budget
  *   FNA_ERR_BAD_ARGUMENT: if both pointers are NULL \n
  *
  **/
-int fna_vres_get_budget_and_period
+typedef int fna_vres_get_budget_and_period_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     struct timespec *budget,
@@ -463,14 +463,14 @@ int fna_vres_get_budget_and_period
  * @param[out] capacity The spare capacity for that importance level
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_resource_get_capacity
+typedef int fna_resource_get_capacity_t
    (const frsh_resource_id_t resource_id,
     const int importance,
     uint32_t *capacity);
@@ -487,14 +487,14 @@ int fna_resource_get_capacity
  * @param[out] total_weight The total weight for that importance level
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_resource_get_total_weight
+typedef int fna_resource_get_total_weight_t
    (const frsh_resource_id_t resource_id,
     const int importance,
     int *total_weight);
@@ -514,7 +514,7 @@ int fna_resource_get_total_weight
  * @param[in] new_period The new Period
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_CONTRACTED_VRES: if the vres is not contracted \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -524,7 +524,7 @@ int fna_resource_get_total_weight
  *      contract \n
  *
  **/
-int fna_vres_decrease_capacity
+typedef int fna_vres_decrease_capacity_t
    (const frsh_resource_id_t resource_id,
     const fna_vres_id_t vres,
     const struct timespec new_budget,
@@ -545,6 +545,26 @@ int fna_vres_decrease_capacity
  * @{
  **/
 
+typedef enum {
+    FRSH_SEND_ENDPOINT_TYPE,
+    FRSH_RECEIVE_ENDPOINT_TYPE
+} frsh_endpoint_type_t;
+
+typedef struct {
+    frsh_endpoint_type_t endpoint_type; // send_endpoint or receive_endpoint
+    fna_vres_id_t vres;                 // only for send_endpoints
+    bool is_bound;                      // only for send_endpoints
+    frsh_network_address_t destination; // only for send_endpoints
+    frsh_resource_id_t resource_id;
+    frsh_stream_id_t stream_id;
+    frsh_protocol_info_t protocol_info;
+    frsh_endpoint_queueing_info_t queue_info;
+    union {
+        frsh_send_endpoint_protocol_info_t send;
+        frsh_receive_endpoint_protocol_info_t receive;
+    } endpoint_protocol_info;
+} fna_endpoint_data_t;
+
 /**
  * fna_send_sync()
  *
@@ -557,7 +577,7 @@ int fna_vres_decrease_capacity
  * @param[in] size The size in bytes of the message
  *
  * @returns
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -568,8 +588,8 @@ int fna_vres_decrease_capacity
  *   the queue is full (and does not have the policy FNA_QP_OLDEST) \n
  *
  **/
-int fna_send_sync
-   (const frsh_send_endpoint_t *endpoint,
+typedef int fna_send_sync_t
+   (const fna_endpoint_data_t *endpoint,
     const void *msg,
     const size_t size);
 
@@ -586,7 +606,7 @@ int fna_send_sync
  * @param[in] size The size in bytes of the message
  *
  * @returns
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_BOUND: if endpoint is not bound to a valid vres \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
@@ -597,8 +617,8 @@ int fna_send_sync
  *   the queue is full (and does not have the policy FNA_QP_OLDEST) \n
  *
  **/
-int fna_send_async
-   (const frsh_send_endpoint_t *endpoint,
+typedef int fna_send_async_t
+   (const fna_endpoint_data_t *endpoint,
     const void *msg,
     const size_t size);
 
@@ -627,9 +647,10 @@ int fna_send_async
  * @param[out] buffer Buffer for storing the received message
  * @param[in] buffer_size The size in bytes of this buffer
  * @param[out] received_bytes The actual number of received bytes
+ * @param[out] from Address of the sender node
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
@@ -638,11 +659,12 @@ int fna_send_async
  *      provided buffer. \n
  *
  **/
-int fna_receive_sync
-   (const frsh_receive_endpoint_t *endpoint,
+typedef int fna_receive_sync_t
+   (const fna_endpoint_data_t *endpoint,
     void *buffer,
     const size_t buffer_size,
-    size_t *received_bytes);
+    size_t *received_bytes,
+    frsh_network_address_t *from);
 
 /**
  * fna_receive_async()
@@ -656,9 +678,10 @@ int fna_receive_sync
  * @param[out] buffer Buffer for storing the received message
  * @param[in] buffer_size The size in bytes of this buffer
  * @param[out] received_bytes The actual number of received bytes
+ * @param[out] from Address of the sender node
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
@@ -668,11 +691,12 @@ int fna_receive_sync
  *   FNA_NO_MESSAGE: if no messages are available in the queue. \n
  *
  **/
-int fna_receive_async
-   (const frsh_receive_endpoint_t *endpoint,
+typedef int fna_receive_async_t
+   (const fna_endpoint_data_t *endpoint,
     void *buffer,
     const size_t buffer_size,
-    size_t *received_bytes);
+    size_t *received_bytes,
+    frsh_network_address_t *from);
 
 /**
  * fna_send_endpoint_get_status()
@@ -687,54 +711,39 @@ int fna_receive_async
  * @param[out] protocol_status Protocol dependent status info
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_send_endpoint_get_status
-   (const frsh_send_endpoint_t *endpoint,
+typedef int fna_send_endpoint_get_status_t
+   (const fna_endpoint_data_t *endpoint,
     int *number_of_pending_messages,
-    frsh_endpoint_network_status *network_status,
+    frsh_endpoint_network_status_t *network_status,
     frsh_protocol_status_t *protocol_status);
 
 /**
- * fna_receive_endpoint_create()
+ * fna_receive_endpoint_create_callback()
  *
- * This operation creates a receive endpoint associated with a
- * undirectional stream within a network interface of the node.
+ * This operation is a called from frsh_receive_endpoint_create with a
+ * receive_endpoint structure already filled.
  *
  * Receiving endpoints are not bound to any network vres, this is
  * because don't originate any traffic.
  *
- * Note that the protocol address is not needed for reception because
- * it can be determined internally by FRSH based on the network_id.
- *
- * Note also that messages may come from diferent originators.
- *
- * @param[in] resource_id  Id of the network from which we listen.
- * @param[in] stream_id  Id of the stream within the network.
- * @param[in] queueing_info Buffering information(queue size and
- *                          policy).
- * @param[in] protocol_info Extra protocol info opaque for the
- *                          application.
- * @param[out] endpoint  Placeholder for the endpoint object.
+ * @param[in] endpoint the endpoint object.
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  **/
-int fna_receive_endpoint_create
-   (const frsh_resource_id_t resource_id,
-    const frsh_stream_id_t stream_id,
-    const frsh_endpoint_queueing_info_t queueing_info,
-    const frsh_protocol_info_t protocol_info,
-    frsh_receive_endpoint_t *endpoint);
+typedef int fna_receive_endpoint_create_callback_t
+   (fna_endpoint_data_t *endpoint);
 
 /**
  * fna_receive_endpoint_get_pending_messages
@@ -749,17 +758,17 @@ int fna_receive_endpoint_create
  * @param[out] protocol_status Protocol dependent status info
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
  *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_receive_endpoint_get_status
-   (const frsh_receive_endpoint_t *endpoint,
+typedef int fna_receive_endpoint_get_status_t
+   (const fna_endpoint_data_t *endpoint,
     int *number_of_pending_messages,
-    frsh_endpoint_network_status *network_status,
+    frsh_endpoint_network_status_t *network_status,
     frsh_protocol_status_t *protocol_status);
 
 /*@}*/
@@ -778,7 +787,7 @@ int fna_receive_endpoint_get_status
  **/
 
 /**
- * fna_network_message_get_max_size()
+ * fna_network_get_max_message_size()
  *
  * This operation gives the maximum number of bytes that can be sent
  * at a time through the send function when using the network designated by
@@ -788,22 +797,23 @@ int fna_receive_endpoint_get_status
  * split them.
  *
  * Some protocols, like IP, are capable of sending large messages
- * (and use fragmentation internally) but other protocols doesn't
- * provide fragmentation features.
+ * (and use fragmentation internally) but other protocols don't.
  *
  * @param[in] resource_id The network we want the tx time from.
  * @param[in] destination The destination address
  * @param[out] max_size The maximum number of bytes for each message
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
- *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
- *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
+ *   FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
+ *   a network accessible from the current processing node \n
+ *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL or destination is
+ *   invalid \n
  *
  **/
-int fna_network_message_get_max_size
+typedef int fna_network_get_max_message_size_t
    (const frsh_resource_id_t resource_id,
     const frsh_network_address_t destination,
     size_t *max_size);
@@ -812,25 +822,27 @@ int fna_network_message_get_max_size
  * fna_network_bytes_to_budget()
  *
  * This operation converts a number of bytes into a temporal budget for
- * a specific network. Network overheads are not included here but internally
- * when negotiating a specific contract.
+ * a specific network. Network overheads are not included here but are
+ * considered internally when negotiating a specific contract.
  *
  * @param[in] resource_id The network
  * @param[in] nbytes Number of bytes
  * @param[out] budget The network budget for nbytes
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
- *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
- *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
+ *   FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
+ *   a network accessible from the current processing node \n
+ *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL or nbytes is less
+ *   than zero \n
  *
  **/
-int fna_network_bytes_to_budget
+typedef int fna_network_bytes_to_budget_t
    (const frsh_resource_id_t resource_id,
     const size_t nbytes,
-    struct timespec *budget);
+    frsh_rel_time_t *budget);
 
 /**
  * fna_network_budget_to_bytes()
@@ -843,16 +855,18 @@ int fna_network_bytes_to_budget
  * @param[out] nbytes Number of bytes
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
- *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
- *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
+ *   FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
+ *   a network accessible from the current processing node \n
+ *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL or budget refers to
+ *   an invalid time value \n
  *
  **/
-int fna_network_budget_to_bytes
+typedef int fna_network_budget_to_bytes_t
    (const frsh_resource_id_t resource_id,
-    const struct timespec *budget,
+    const frsh_rel_time_t *budget,
     size_t *nbytes);
 
 /**
@@ -860,33 +874,61 @@ int fna_network_budget_to_bytes
  *
  * This operation gets the minimum effective budget for a network. Each message
  * consumes a contracted budget in "chunks" (i.e: packets) that we call
- * effective budget.
+ * minimum effective budget.
  *
  * A negotiated contract, for N bytes in a period T, means that there is a
  * virtual resource that reserves for the user:
  *
- *         (N bytes)/budget_to_bytes(min_effective_budget) "CHUNKS"
+ *   Ceiling ((N bytes) / budget_to_bytes (min_effective_budget)) "CHUNKS"
  *
  * Note that if the user decides not to send these N bytes at once but, say,
- * one byte at a time, it will consume more "CHUNKS" and the reserved budget
- * will become exhausted before sending all the bytes.
+ * one byte at a time, it will consume one "CHUNK" at a time and the reserved
+ * budget will become exhausted before sending all the bytes.
  *
  * @param[in] resource_id The network
  * @param[out] budget The network budget
  *
  * @return
- *   FNA_NO_ERROR: in this case it also means contract accepted \n
+ *   0 if there are no errors \n
  *   FNA_ERR_INTERNAL_ERROR: protocol dependent internal errors \n
  *   FNA_ERR_NOT_INITIALIZED: if the protocol is not initialized \n
- *   FNA_ERR_RESOURCE_ID_INVALID: if we are not in charge of resource_id \n
+ *   FNA_ERR_RESOURCE_ID_INVALID: if resource id does not represent
+ *   a network accessible from the current processing node \n
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_network_get_min_effective_budget
+typedef int fna_network_get_min_effective_budget_t
    (const frsh_resource_id_t resource_id,
-    struct timespec *budget);
+    frsh_rel_time_t *budget);
 
 /*@}*/
 
+typedef struct {
+    fna_init_t *fna_init;
+    fna_contract_negotiate_t *fna_contract_negotiate;
+    fna_contract_renegotiate_sync_t *fna_contract_renegotiate_sync;
+    fna_contract_renegotiate_async_t *fna_contract_renegotiate_async;
+    fna_vres_get_renegotiation_status_t *fna_vres_get_renegotiation_status;
+    fna_vres_destroy_t *fna_vres_destroy;
+    fna_vres_get_contract_t *fna_vres_get_contract;
+    fna_vres_get_usage_t *fna_vres_get_usage;
+    fna_vres_get_remaining_budget_t *fna_vres_get_remaining_budget;
+    fna_vres_get_budget_and_period_t *fna_vres_get_budget_and_period;
+    fna_resource_get_capacity_t *fna_resource_get_capacity;
+    fna_resource_get_total_weight_t *fna_resource_get_total_weight;
+    fna_vres_decrease_capacity_t *fna_vres_decrease_capacity;
+    fna_send_sync_t *fna_send_sync;
+    fna_send_async_t *fna_send_async;
+    fna_receive_sync_t *fna_receive_sync;
+    fna_receive_async_t *fna_receive_async;
+    fna_send_endpoint_get_status_t *fna_send_endpoint_get_status;
+    fna_receive_endpoint_create_callback_t *fna_receive_endpoint_created;
+    fna_receive_endpoint_get_status_t *fna_receive_endpoint_get_status;
+    fna_network_get_max_message_size_t *fna_network_get_max_message_size;
+    fna_network_bytes_to_budget_t *fna_network_bytes_to_budget;
+    fna_network_budget_to_bytes_t *fna_network_budget_to_bytes;
+    fna_network_get_min_effective_budget_t *fna_network_get_min_eff_budget;
+} fna_operations_t;
+
 #endif // _FNA_H_