]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - include/fna.h
Added FWP to FNA. FNA ops extended for bind, unbind, send_endpoint_created, endpoint_...
[frescor/fna.git] / include / fna.h
index d4bcf100a68180f9f7de12349b45cc8e930d7a61..475e7662ecc4e76bb7965ab79729601bdf1028c5 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.
-//
-//  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.
+// This file is part of FNA (Frescor Network Adaptation)
 //
-//  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.
+// 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.
 //
-//  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_
 
-/* for frsh_resource_id_t, frsh_contract_t, etc */
-#include "frsh_core_types.h"
-/* for frsh_network_address_t, frsh_stream_id_t */
-#include "frsh_distributed_types.h"
+/* 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 */
@@ -95,6 +88,7 @@
  *
  **/
 
+
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
 //////////////////////////////////////////////////////////////////////
  *      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);
 
 /*@}*/
 
@@ -146,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()
@@ -187,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);
@@ -222,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);
@@ -268,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,
@@ -303,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);
@@ -329,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);
 
@@ -354,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);
@@ -379,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);
@@ -405,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);
@@ -432,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,
@@ -477,7 +470,7 @@ int fna_vres_get_budget_and_period
  *   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);
@@ -501,7 +494,7 @@ int fna_resource_get_capacity
  *   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);
@@ -531,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,
@@ -552,7 +545,25 @@ int fna_vres_decrease_capacity
  * @{
  **/
 
-typedef frsh_send_endpoint_t fna_send_endpoint_t;
+typedef enum {
+    FRSH_SEND_ENDPOINT_TYPE,
+    FRSH_RECEIVE_ENDPOINT_TYPE
+} frsh_endpoint_type_t;
+
+typedef struct fna_endpoint_data {
+    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()
@@ -577,8 +588,8 @@ typedef frsh_send_endpoint_t fna_send_endpoint_t;
  *   the queue is full (and does not have the policy FNA_QP_OLDEST) \n
  *
  **/
-int fna_send_sync
-   (const fna_send_endpoint_t *endpoint,
+typedef int fna_send_sync_t
+   (const fna_endpoint_data_t *endpoint,
     const void *msg,
     const size_t size);
 
@@ -606,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 fna_send_endpoint_t *endpoint,
+typedef int fna_send_async_t
+   (const fna_endpoint_data_t *endpoint,
     const void *msg,
     const size_t size);
 
@@ -648,8 +659,8 @@ 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,
@@ -680,8 +691,8 @@ 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,
@@ -707,12 +718,66 @@ int fna_receive_async
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  *
  **/
-int fna_send_endpoint_get_status
-   (const fna_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_send_endpoint_bind_t()
+ *
+ * This operation is a called from frsh_send_endpoint_bind and binds send 
+ * edpoint to vres.
+ *
+ * @param[in] endpoint the endpoint object.
+ * @param[in] vres The internal virtual resource id
+ *
+ * @return
+ *   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
+ **/
+typedef  
+int fna_send_endpoint_bind_t(fna_endpoint_data_t *endpoint, fna_vres_id_t vres);
+
+/**
+ * fna_send_endpoint_unbind_t()
+ *
+ * This operation is a called from frsh_send_endpoint_bind.
+ *
+ * @param[in] endpoint the endpoint object.
+ *
+ * @return
+ *   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
+ **/
+typedef  
+int fna_send_endpoint_unbind_t(fna_endpoint_data_t *endpoint);
+
+/**
+ * fna_send_endpoint_create_callback()
+ *
+ * This operation is a called from frsh_send_endpoint_create with a
+ * send_endpoint structure already filled.
+ *
+ * @param[in] endpoint the endpoint object.
+ *
+ * @return
+ *   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
+ **/
+typedef int fna_send_endpoint_create_callback_t
+   (fna_endpoint_data_t *endpoint);
+
 /**
  * fna_receive_endpoint_create_callback()
  *
@@ -731,8 +796,25 @@ int fna_send_endpoint_get_status
  *   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_callback
-   (const frsh_receive_endpoint_t *endpoint);
+typedef int fna_receive_endpoint_create_callback_t
+   (fna_endpoint_data_t *endpoint);
+
+/**
+ * fna_endpoint_destroy()
+ *
+ * This operation is a called from frsh_send(receive)_endpoint_destroy.
+ *
+ * @param[in] endpoint the endpoint object.
+ *
+ * @return
+ *   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
+ **/
+typedef int fna_endpoint_destroy_t
+   (fna_endpoint_data_t *endpoint);
 
 /**
  * fna_receive_endpoint_get_pending_messages
@@ -754,10 +836,10 @@ int fna_receive_endpoint_create_callback
  *   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);
 
 /*@}*/
@@ -802,7 +884,7 @@ int fna_receive_endpoint_get_status
  *   invalid \n
  *
  **/
-int fna_network_get_max_message_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);
@@ -828,10 +910,10 @@ int fna_network_get_max_message_size
  *   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()
@@ -853,9 +935,9 @@ int fna_network_bytes_to_budget
  *   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);
 
 /**
@@ -886,11 +968,42 @@ int fna_network_budget_to_bytes
  *   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_send_endpoint_bind_t *fna_send_endpoint_bind;
+    fna_send_endpoint_unbind_t *fna_send_endpoint_unbind;
+    fna_endpoint_destroy_t *fna_endpoint_destroy;
+    fna_send_endpoint_create_callback_t *fna_send_endpoint_created;
+    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_