]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_frescan/frescan_bwres_fna.c
changes to use the FRSH FSA module to do the analysis and spare capacity. TODO: finis...
[frescor/fna.git] / src_frescan / frescan_bwres_fna.c
index 103bce09b3728d6d7b048111ec30346a14c10b29..24c82e7c6fa35883025a9b442a8bda6cf2cdeab8 100644 (file)
  *
  * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
  *
+ * @license
+ *
+ * -----------------------------------------------------------------------
+ *  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+ *
+ *    Universidad de Cantabria,              SPAIN
+ *    University of York,                    UK
+ *    Scuola Superiore Sant'Anna,            ITALY
+ *    Kaiserslautern University,             GERMANY
+ *    Univ. Politécnica  Valencia,           SPAIN
+ *    Czech Technical University in Prague,  CZECH REPUBLIC
+ *    ENEA                                   SWEDEN
+ *    Thales Communication S.A.              FRANCE
+ *    Visual Tools S.A.                      SPAIN
+ *    Rapita Systems Ltd                     UK
+ *    Evidence                               ITALY
+ *
+ *    See http://www.frescor.org for a link to partners' websites
+ *
+ *           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.
+ *
+ *  This file is part of FRESCAN
+ *
+ *  FRESCAN 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.
+ *
+ *  FRESCAN  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
+ *  distributed  with  FRESCAN;  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, including FRESCAN header files in a file,
+ * instantiating FRESCAN generics or templates, or linking other files
+ * with FRESCAN 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.
+ * -----------------------------------------------------------------------
+ *
  */
 
 #include <math.h> /* ceil */
 
 #include "frsh.h" /* frsh_resource_id_t, .. */
 #include "frescan.h" /* frescan_init, ... */
-#include "frescan_data.h" /* frescan_contract_t, ... */
 #include "frescan_bwres.h" /* frescan_bwres_init, ... */
 #include "fna.h" /* fna_vres_id_t, fna_endpoint_data_t */
-
-#undef ERROR
-#include "frescan_debug.h" /* DEBUG, ERROR */
+#include "frescan_debug.h" /* DEBUG, FRESCAN_ERROR */
 
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
@@ -61,12 +108,12 @@ int frescan_fna_init(const frsh_resource_id_t resource_id)
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "Initializing FRESCAN\n");
 
         ret = frescan_init(&init_params);
-        if (ret != 0) ERROR ("could not init FRESCAN");
+        if (ret != 0) FRESCAN_ERROR ("could not init FRESCAN");
 
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "Initializing BWRES\n");
 
         ret = frescan_bwres_init(init_params.net);
-        if (ret != 0) ERROR ("could not init BWRES");
+        if (ret != 0) FRESCAN_ERROR ("could not init BWRES");
 
         return 0;
 }
@@ -116,24 +163,10 @@ int frescan_fna_contract_negotiate
         int ret;
         bool accepted;
         frescan_ss_t ss;
-        frescan_contract_t frescan_contract;
-
-        DEBUG(FRESCAN_FNA_ENABLE_DEBUG,
-              "frsh contract->frescan contract\n");
-
-        // NOTE: budget is stored as number of can frames in tv_sec
-        frescan_contract.min_values.budget = contract->budget_min.tv_sec;
-        frescan_contract.min_values.period = contract->period_max;
-
-        frescan_contract.max_values.budget = contract->budget_max.tv_sec;
-        frescan_contract.max_values.period = contract->period_min;
-
-        // TODO: put 0 if we want the sa module to assign the prios
-        frescan_contract.prio = contract->preemption_level;
 
         DEBUG(FRESCAN_FNA_ENABLE_DEBUG, "calling frescan_bwres_negotiate\n");
         ret = frescan_bwres_negotiate((frescan_network_t)resource_id,
-                                       &frescan_contract,
+                                       contract,
                                        &ss,
                                        &accepted);
         if (ret != 0) return -1;
@@ -183,7 +216,7 @@ int frescan_fna_contract_renegotiate_sync
                  const fna_vres_id_t vres,
                  const frsh_contract_t *new_contract)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -235,7 +268,7 @@ int frescan_fna_contract_renegotiate_async
                  frsh_signal_t signal_to_notify,
                  frsh_signal_info_t signal_info)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -272,7 +305,7 @@ int frescan_fna_vres_get_renegotiation_status
                  const fna_vres_id_t vres,
                  frsh_renegotiation_status_t *renegotiation_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -301,7 +334,7 @@ int frescan_fna_vres_destroy
                 (const frsh_resource_id_t resource_id,
                  const fna_vres_id_t vres)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -331,7 +364,7 @@ int frescan_fna_vres_get_contract
                  const fna_vres_id_t vres,
                  frsh_contract_t *contract)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -360,7 +393,7 @@ int frescan_fna_vres_get_usage
                  const fna_vres_id_t vres,
                  struct timespec *usage)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -390,7 +423,7 @@ int frescan_fna_vres_get_remaining_budget
                  const fna_vres_id_t vres,
                  struct timespec *remaining_budget)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -422,7 +455,7 @@ int frescan_fna_vres_get_budget_and_period
                  struct timespec *budget,
                  struct timespec *period)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -470,7 +503,7 @@ int frescan_fna_resource_get_capacity
                  const int importance,
                  uint32_t *capacity)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -498,7 +531,7 @@ int frescan_fna_resource_get_total_weight
                  const int importance,
                  int *total_weight)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -533,7 +566,7 @@ int frescan_fna_vres_decrease_capacity
                  const struct timespec new_budget,
                  const struct timespec new_period)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -569,7 +602,7 @@ int frescan_fna_send_sync
                  const void *msg,
                  const size_t size)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -618,7 +651,7 @@ int frescan_fna_send_async
 
         ret = frescan_send(&params, (uint8_t *)msg, size);
         if (ret != 0) {
-                ERROR ("could not send message\n");
+                FRESCAN_ERROR ("could not send message\n");
                 return -1;
         }
 
@@ -686,7 +719,7 @@ int frescan_fna_receive_sync
                            received_bytes, &frescan_from, &prio);
 
         if (ret != 0) {
-                ERROR ("error while receiving message");
+                FRESCAN_ERROR ("error while receiving message");
                 return -1;
         }
 
@@ -731,7 +764,7 @@ int frescan_fna_receive_async
                  size_t *received_bytes,
                  frsh_network_address_t *from)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -761,7 +794,7 @@ int frescan_fna_send_endpoint_get_status
                  frsh_endpoint_network_status_t *network_status,
                  frsh_protocol_status_t *protocol_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -816,7 +849,7 @@ int frescan_fna_receive_endpoint_get_status
                  frsh_endpoint_network_status_t *network_status,
                  frsh_protocol_status_t *protocol_status)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }
 
@@ -856,7 +889,7 @@ int frescan_fna_network_get_max_message_size
                  const frsh_network_address_t destination,
                  size_t *max_size)
 {
-        ERROR("not implemented\n");
+        FRESCAN_ERROR("not implemented\n");
         return -1;
 }