]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_rtep/rtep_fna_c.c
restore the configuration flags and add a CONNECTED flag
[frescor/fna.git] / src_rtep / rtep_fna_c.c
index e442dbb6dce27896e953454c7196f1b3fc036411..a208a9afa70d0cc00b5b27f6e739caf7edc5699f 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.
 // -----------------------------------------------------------------------
 
 //==============================================
 #include "rtep.h" // for rtep_adainit, rtep_valid_multicast_id, ..
 #include "rtep_bandwith_reservation.h" // for rtep_bwres_*
 #include "rtep_fna.h" // function prototypes
+#include "fadt_freelist.h"
 
-#include "frsh_freelist.h"
-
-#if 1
+#if 0
 #include <stdio.h>
 #define DEBUG(x,args...) printf("%s: " x, __func__ , ##args)
 #else
@@ -85,7 +78,7 @@
 
 // TODO: add a mutex for concurrent access if necessary
 static rtep_bwres_vres_t rtep_vres_list[MAX_N_RTEP_BWRES_VRES];
-static frsh_freelist_t rtep_vres_freelist;
+static fadt_freelist_t rtep_vres_freelist;
 
 //////////////////////////////////////////////////////////////////////
 //           INITIALIZATION
@@ -110,18 +103,22 @@ static frsh_freelist_t rtep_vres_freelist;
  **/
 int rtep_fna_init(const frsh_resource_id_t resource_id)
 {
-    int err = 0;
+        int err = 0;
+
+        DEBUG("calling rtep_adainit\n");
 
-    DEBUG("starting rtep\n");
+        // init Ada bindings
+        rtep_adainit();
 
-    // init Ada bindings
-    rtep_adainit();
+        DEBUG("calling freelist_init\n");
 
-    // initialize the freelist to handle the rtep_vres
-    err = frsh_freelist_init(&rtep_vres_freelist, MAX_N_RTEP_BWRES_VRES);
-    if (err != 0) return -1;
+        // initialize the freelist to handle the rtep_vres
+        err = fadt_freelist_init(&rtep_vres_freelist, NULL, MAX_N_RTEP_BWRES_VRES);
+        if (err != 0) return -1;
 
-    return rtep_bwres_init();
+        DEBUG("calling rtep_bwres_init\n");
+
+        return rtep_bwres_init();
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -162,43 +159,46 @@ int rtep_fna_init(const frsh_resource_id_t resource_id)
  *
  **/
 int rtep_fna_contract_negotiate
-      (const frsh_resource_id_t resource_id,
-       const frsh_contract_t *contract,
-       fna_vres_id_t *vres)
+                (const frsh_resource_id_t resource_id,
+                 const frsh_contract_t *contract,
+                 fna_vres_id_t *vres)
 {
-    rtep_bwres_contract_t rtep_contract;
-    int accepted;
-    int pos;
-
-    // convert FRSH contract to RTEP BWRES contract
-    rtep_contract.period_max = contract->period_max;
-    rtep_contract.deadline = contract->deadline;
-    rtep_contract.prio = contract->preemption_level;
-    // in RTEP BWRES, budget is given in number of packets. We do a little trick
-    // in the function bytes_to_network_budget to use a the field tv_sec from
-    // the timespec in frsh_contract to store the budget in bytes directly
-    rtep_contract.budget_min = contract->budget_min.tv_sec;
-
-    // allocate a free internal vres.
-    pos = frsh_freelist_alloc(&rtep_vres_freelist);
-
-    if (pos < 0) {
-        return -1;
-    }
-
-    DEBUG("calling rtep_bwres_contract_negotiate\n");
-    // negotiate the contract
-    accepted = rtep_bwres_contract_negotiate
-                    (&rtep_contract, &rtep_vres_list[pos]);
-
-    // if accepted assign the vres, if not deallocate the rtep_vres
-    if (accepted == 0) {
-        *vres = (fna_vres_id_t)pos;
-    } else {
-        frsh_freelist_free(&rtep_vres_freelist, pos);
-    }
-
-    return accepted;
+        rtep_bwres_contract_t rtep_contract;
+        int accepted;
+        int pos;
+
+         // convert FRSH contract to RTEP BWRES contract
+        rtep_contract.period_max = contract->period_max;
+        rtep_contract.deadline = contract->deadline;
+        rtep_contract.prio = contract->preemption_level;
+        // in RTEP BWRES, budget is given in number of packets. We do a little trick
+        // in the function bytes_to_network_budget to use a the field tv_sec from
+        // the timespec in frsh_contract to store the budget in bytes directly
+        rtep_contract.budget_min = contract->budget_min.tv_sec;
+
+        // allocate a free internal vres.
+        pos = fadt_freelist_alloc(&rtep_vres_freelist);
+
+        if (pos < 0) {
+                DEBUG("not enough resources\n");
+                return -1;
+        }
+
+        DEBUG("calling rtep_bwres_contract_negotiate\n");
+        // negotiate the contract
+        accepted = rtep_bwres_contract_negotiate
+                        (&rtep_contract, &rtep_vres_list[pos]);
+
+        // if accepted assign the vres, if not deallocate the rtep_vres
+        if (accepted == 0) {
+                DEBUG("contract accepted\n");
+                *vres = (fna_vres_id_t)pos;
+        } else {
+                DEBUG("contract not accepted\n");
+                fadt_freelist_free(&rtep_vres_freelist, pos);
+        }
+
+        return accepted;
 }
 
 /**
@@ -232,28 +232,28 @@ int rtep_fna_contract_negotiate
  *
  **/
 int rtep_fna_contract_renegotiate_sync
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       const frsh_contract_t *new_contract)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 const frsh_contract_t *new_contract)
 {
-    rtep_bwres_contract_t rtep_contract;
-    int accepted;
-    int pos = (int) vres;
-
-    // convert FRSH contract to RTEP BWRES contract
-    rtep_contract.period_max = new_contract->period_max;
-    rtep_contract.deadline = new_contract->deadline;
-    rtep_contract.prio = new_contract->preemption_level;
-    // in RTEP BWRES, budget is given in number of packets. We do a little trick
-    // in the function bytes_to_network_budget to use a the field tv_sec from
-    // the timespec in frsh_contract to store the budget in bytes directly
-    rtep_contract.budget_min = new_contract->budget_min.tv_sec;
-
-    // renegotiate the contract
-    accepted = rtep_bwres_contract_renegotiate_sync
-            (&rtep_vres_list[pos], &rtep_contract);
-
-    return accepted;
+        rtep_bwres_contract_t rtep_contract;
+        int accepted;
+        int pos = (int) vres;
+
+        // convert FRSH contract to RTEP BWRES contract
+        rtep_contract.period_max = new_contract->period_max;
+        rtep_contract.deadline = new_contract->deadline;
+        rtep_contract.prio = new_contract->preemption_level;
+        // in RTEP BWRES, budget is given in number of packets. We do a little trick
+        // in the function bytes_to_network_budget to use a the field tv_sec from
+        // the timespec in frsh_contract to store the budget in bytes directly
+        rtep_contract.budget_min = new_contract->budget_min.tv_sec;
+
+        // renegotiate the contract
+        accepted = rtep_bwres_contract_renegotiate_sync
+                        (&rtep_vres_list[pos], &rtep_contract);
+
+        return accepted;
 }
 
 /**
@@ -298,13 +298,13 @@ int rtep_fna_contract_renegotiate_sync
  *
  **/
 int rtep_fna_contract_renegotiate_async
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       const frsh_contract_t *new_contract,
-       frsh_signal_t signal_to_notify,
-       frsh_signal_info_t signal_info)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 const frsh_contract_t *new_contract,
+                 frsh_signal_t signal_to_notify,
+                 frsh_signal_info_t signal_info)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -336,11 +336,11 @@ int rtep_fna_contract_renegotiate_async
  *
  **/
 int rtep_fna_vres_get_renegotiation_status
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       frsh_renegotiation_status_t *renegotiation_status)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 frsh_renegotiation_status_t *renegotiation_status)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -365,21 +365,22 @@ int rtep_fna_vres_get_renegotiation_status
  *
  **/
 int rtep_fna_vres_destroy
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres)
 {
-    int err = 0;
-    int pos = (int) vres;
+        int err = 0;
+        int pos = (int) vres;
 
-    // cancel de negotiated contract (the function spread results among nodes)
-    err = rtep_bwres_vres_destroy (&rtep_vres_list[pos]);
-    if (err != 0) return -1;
+        // cancel de negotiated contract (the function spread results
+        // among nodes)
+        err = rtep_bwres_vres_destroy (&rtep_vres_list[pos]);
+        if (err != 0) return -1;
 
-    // free the element in the rtep_vres list
-    err = frsh_freelist_free(&rtep_vres_freelist, pos);
-    if (err != 0) return -1;
+        // free the element in the rtep_vres list
+        err = fadt_freelist_free(&rtep_vres_freelist, pos);
+        if (err != 0) return -1;
 
-    return 0;
+        return 0;
 }
 
 /**
@@ -404,11 +405,11 @@ int rtep_fna_vres_destroy
  *
  **/
 int rtep_fna_vres_get_contract
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       frsh_contract_t *contract)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 frsh_contract_t *contract)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -432,11 +433,11 @@ int rtep_fna_vres_get_contract
  *
  **/
 int rtep_fna_vres_get_usage
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       struct timespec *usage)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 struct timespec *usage)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -461,11 +462,11 @@ int rtep_fna_vres_get_usage
  *
  **/
 int rtep_fna_vres_get_remaining_budget
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       struct timespec *remaining_budget)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 struct timespec *remaining_budget)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -491,12 +492,12 @@ int rtep_fna_vres_get_remaining_budget
  *
  **/
 int rtep_fna_vres_get_budget_and_period
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       struct timespec *budget,
-       struct timespec *period)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 struct timespec *budget,
+                 struct timespec *period)
 {
-   return 0;
+        return 0;
 }
 
 /*@}*/
@@ -539,11 +540,11 @@ int rtep_fna_vres_get_budget_and_period
  *
  **/
 int rtep_fna_resource_get_capacity
-      (const frsh_resource_id_t resource_id,
-       const int importance,
-       uint32_t *capacity)
+                (const frsh_resource_id_t resource_id,
+                 const int importance,
+                 uint32_t *capacity)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -566,11 +567,11 @@ int rtep_fna_resource_get_capacity
  *
  **/
 int rtep_fna_resource_get_total_weight
-      (const frsh_resource_id_t resource_id,
-       const int importance,
-       int *total_weight)
+                (const frsh_resource_id_t resource_id,
+                 const int importance,
+                 int *total_weight)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -599,12 +600,12 @@ int rtep_fna_resource_get_total_weight
  *
  **/
 int rtep_fna_vres_decrease_capacity
-      (const frsh_resource_id_t resource_id,
-       const fna_vres_id_t vres,
-       const struct timespec new_budget,
-       const struct timespec new_period)
+                (const frsh_resource_id_t resource_id,
+                 const fna_vres_id_t vres,
+                 const struct timespec new_budget,
+                 const struct timespec new_period)
 {
-   return 0;
+        return 0;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -635,11 +636,23 @@ int rtep_fna_vres_decrease_capacity
  *
  **/
 int rtep_fna_send_sync
-   (const fna_endpoint_data_t *endpoint,
-    const void *msg,
-    const size_t size)
+                (const fna_endpoint_data_t *endpoint,
+                 const void *msg,
+                 const size_t size)
 {
-   return 0;
+        DEBUG("dest: %d, chan: %d, size: %d, server: %d\n",
+              endpoint->destination, endpoint->stream_id, size,
+              rtep_vres_list[endpoint->vres].server_id);
+
+        // TODO: check errors
+        rtep_server_send_info
+                        ((rtep_station_id_t) endpoint->destination,
+                         (rtep_channel_t) endpoint->stream_id,
+                         (uint8_t *) msg,
+                         size,
+                         rtep_vres_list[endpoint->vres].server_id,
+                         1); // blocking
+        return 0;
 }
 
 /**
@@ -667,23 +680,23 @@ int rtep_fna_send_sync
  *
  **/
 int rtep_fna_send_async
-   (const fna_endpoint_data_t *endpoint,
-    const void *msg,
-    const size_t size)
+                (const fna_endpoint_data_t *endpoint,
+                 const void *msg,
+                 const size_t size)
 {
-    DEBUG("dest: %d, chan: %d, size: %d, server: %d\n",
-          endpoint->destination, endpoint->stream_id, size,
-          rtep_vres_list[endpoint->vres].server_id);
-
-    // TODO: check errors
-    rtep_server_send_info
-            ((rtep_station_id_t) endpoint->destination,
-             (rtep_channel_t) endpoint->stream_id,
-             (uint8_t *) msg,
-             size,
-             rtep_vres_list[endpoint->vres].server_id,
-             0); // not blocking
-    return 0;
+        DEBUG("dest: %d, chan: %d, size: %d, server: %d\n",
+              endpoint->destination, endpoint->stream_id, size,
+              rtep_vres_list[endpoint->vres].server_id);
+
+        // TODO: check errors
+        rtep_server_send_info
+                        ((rtep_station_id_t) endpoint->destination,
+                          (rtep_channel_t) endpoint->stream_id,
+                          (uint8_t *) msg,
+                          size,
+                          rtep_vres_list[endpoint->vres].server_id,
+                          0); // not blocking
+        return 0;
 }
 
 /**
@@ -724,29 +737,31 @@ int rtep_fna_send_async
  *
  **/
 int rtep_fna_receive_sync
-      (const fna_endpoint_data_t *endpoint,
-       void *buffer,
-       const size_t buffer_size,
-       size_t *received_bytes,
-       frsh_network_address_t *from)
+                (const fna_endpoint_data_t *endpoint,
+                 void *buffer,
+                 const size_t buffer_size,
+                 size_t *received_bytes,
+                 frsh_network_address_t *from)
 {
-    rtep_priority_t prio;
-    rtep_station_id_t rtep_from;
+        rtep_priority_t prio;
+        rtep_station_id_t rtep_from;
+        rtep_channel_t chan = (rtep_channel_t) endpoint->stream_id;
 
-    // TODO: checks for errors
-    rtep_recv_info
-            (&rtep_from,
-             (rtep_channel_t) endpoint->stream_id,
-             (uint8_t *) buffer,
-             buffer_size,
-             received_bytes,
-             &prio);
+        // TODO: checks for errors
+        rtep_recv_info
+                        (&rtep_from,
+                          chan,
+                          (uint8_t *) buffer,
+                          buffer_size,
+                          received_bytes,
+                          &prio);
 
-    *from = rtep_from;
+        *from = rtep_from;
 
-    DEBUG(" %u bytes, from %u, prio %u\n", *received_bytes, rtep_from, prio);
+        DEBUG(" %u bytes, from %u, prio %u\n",
+              *received_bytes, rtep_from, prio);
 
-    return 0;
+        return 0;
 }
 
 /**
@@ -775,13 +790,13 @@ int rtep_fna_receive_sync
  *
  **/
 int rtep_fna_receive_async
-      (const fna_endpoint_data_t *endpoint,
-       void *buffer,
-       const size_t buffer_size,
-       size_t *received_bytes,
-       frsh_network_address_t *from)
+                (const fna_endpoint_data_t *endpoint,
+                 void *buffer,
+                 const size_t buffer_size,
+                 size_t *received_bytes,
+                 frsh_network_address_t *from)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -805,12 +820,12 @@ int rtep_fna_receive_async
  *
  **/
 int rtep_fna_send_endpoint_get_status
-   (const fna_endpoint_data_t *endpoint,
-    int *number_of_pending_messages,
-    frsh_endpoint_network_status_t *network_status,
-    frsh_protocol_status_t *protocol_status)
+                (const fna_endpoint_data_t *endpoint,
+                 int *number_of_pending_messages,
+                 frsh_endpoint_network_status_t *network_status,
+                 frsh_protocol_status_t *protocol_status)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -832,9 +847,9 @@ int rtep_fna_send_endpoint_get_status
  *   FNA_ERR_BAD_ARGUMENT: if pointers are NULL \n
  **/
 int rtep_fna_receive_endpoint_created
-      (const fna_endpoint_data_t *endpoint)
+                (fna_endpoint_data_t *endpoint)
 {
-   return 0;
+        return 0;
 }
 
 /**
@@ -858,12 +873,12 @@ int rtep_fna_receive_endpoint_created
  *
  **/
 int rtep_fna_receive_endpoint_get_status
-      (const fna_endpoint_data_t *endpoint,
-       int *number_of_pending_messages,
-       frsh_endpoint_network_status_t *network_status,
-       frsh_protocol_status_t *protocol_status)
+                (const fna_endpoint_data_t *endpoint,
+                 int *number_of_pending_messages,
+                 frsh_endpoint_network_status_t *network_status,
+                 frsh_protocol_status_t *protocol_status)
 {
-   return 0;
+        return 0;
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -898,23 +913,23 @@ int rtep_fna_receive_endpoint_get_status
  *
  **/
 int rtep_fna_network_get_max_message_size
-      (const frsh_resource_id_t resource_id,
-       const frsh_network_address_t destination,
-       size_t *max_size)
+                (const frsh_resource_id_t resource_id,
+                 const frsh_network_address_t destination,
+                 size_t *max_size)
 {
-    int is_multicast;
-
-    if (max_size == NULL) {
-        return -1;
-    }
-
-    is_multicast = rtep_valid_multicast_id ((rtep_station_id_t) destination);
-    if (is_multicast) {
-        *max_size = MULTICAST_MTU;
-    } else {
-        *max_size = MAX_RTEP_MTU;
-    }
-    return 0;
+        int is_multicast;
+
+        if (max_size == NULL) {
+                return -1;
+        }
+
+        is_multicast = rtep_valid_multicast_id((rtep_station_id_t) destination);
+        if (is_multicast) {
+                *max_size = MULTICAST_MTU;
+        } else {
+                *max_size = MAX_RTEP_MTU;
+        }
+        return 0;
 }
 
 /**
@@ -939,23 +954,23 @@ int rtep_fna_network_get_max_message_size
  *
  **/
 int rtep_fna_network_bytes_to_budget
-      (const frsh_resource_id_t resource_id,
-       const size_t nbytes,
-       struct timespec *budget)
+                (const frsh_resource_id_t resource_id,
+                 const size_t nbytes,
+                 struct timespec *budget)
 {
-    int number_of_packets;
-
-    if (budget == NULL || nbytes < 0) {
-        return -1;
-    }
-
-   // we measure the budget in number of RTEP packets of maximum size
-    number_of_packets = nbytes / MAX_RTEP_MTU + 1;
-   // we store the budget in number of packets instead of in time. We
-   // use a field in the timespec structure.
-    budget->tv_sec = number_of_packets;
-    DEBUG("bytes: %d -> budget: %d\n", nbytes, budget->tv_sec);
-    return 0;
+        int number_of_packets;
+
+        if (budget == NULL || nbytes < 0) {
+                return -1;
+        }
+
+        // we measure the budget in number of RTEP packets of maximum size
+        number_of_packets = nbytes / MAX_RTEP_MTU + 1;
+        // we store the budget in number of packets instead of in time. We
+        // use a field in the timespec structure.
+        budget->tv_sec = number_of_packets;
+        DEBUG("bytes: %d -> budget: %d\n", nbytes, budget->tv_sec);
+        return 0;
 }
 
 /**
@@ -979,18 +994,18 @@ int rtep_fna_network_bytes_to_budget
  *
  **/
 int rtep_fna_network_budget_to_bytes
-      (const frsh_resource_id_t resource_id,
-       const struct timespec *budget,
-       size_t *nbytes)
+                (const frsh_resource_id_t resource_id,
+                 const struct timespec *budget,
+                 size_t *nbytes)
 {
-    int number_of_packets;
-
-    if (budget == NULL || nbytes == NULL) {
-        return -1;
-    }
-    number_of_packets = budget->tv_sec;
-    *nbytes = number_of_packets * MAX_RTEP_MTU;
-    return 0;
+        int number_of_packets;
+
+        if (budget == NULL || nbytes == NULL) {
+                return -1;
+        }
+        number_of_packets = budget->tv_sec;
+        *nbytes = number_of_packets * MAX_RTEP_MTU;
+        return 0;
 }
 
 /**
@@ -1022,52 +1037,43 @@ int rtep_fna_network_budget_to_bytes
  *
  **/
 int rtep_fna_network_get_min_eff_budget
-      (const frsh_resource_id_t resource_id,
-       struct timespec *budget)
+                (const frsh_resource_id_t resource_id,
+                 struct timespec *budget)
 {
-   if (budget == NULL) {
-      return -1;
-   }
-   budget->tv_sec = 1;
-   return 0;
+        if (budget == NULL) {
+                return -1;
+        }
+        budget->tv_sec = 1;
+        return 0;
 }
 
 // GLOBAL variable to install the network protocol in FRESCOR
 
 fna_operations_t rtep_fna_operations = {
-    .fna_init = rtep_fna_init,
-    .fna_contract_negotiate = rtep_fna_contract_negotiate,
-    .fna_contract_renegotiate_sync = rtep_fna_contract_renegotiate_sync,
-    .fna_contract_renegotiate_async = rtep_fna_contract_renegotiate_async,
-    .fna_vres_get_renegotiation_status = rtep_fna_vres_get_renegotiation_status,
-    .fna_vres_destroy = rtep_fna_vres_destroy,
-    .fna_vres_get_contract = rtep_fna_vres_get_contract,
-    .fna_vres_get_usage = rtep_fna_vres_get_usage,
-    .fna_vres_get_remaining_budget = rtep_fna_vres_get_remaining_budget,
-    .fna_vres_get_budget_and_period = rtep_fna_vres_get_budget_and_period,
-    .fna_resource_get_capacity = rtep_fna_resource_get_capacity,
-    .fna_resource_get_total_weight = rtep_fna_resource_get_total_weight,
-    .fna_vres_decrease_capacity = rtep_fna_vres_decrease_capacity,
-    .fna_send_sync = rtep_fna_send_sync,
-    .fna_send_async = rtep_fna_send_async,
-    .fna_receive_sync = rtep_fna_receive_sync,
-    .fna_receive_async = rtep_fna_receive_async,
-    .fna_send_endpoint_get_status = rtep_fna_send_endpoint_get_status,
-    .fna_receive_endpoint_created = rtep_fna_receive_endpoint_created,
-    .fna_receive_endpoint_get_status = rtep_fna_receive_endpoint_get_status,
-    .fna_network_get_max_message_size = rtep_fna_network_get_max_message_size,
-    .fna_network_bytes_to_budget = rtep_fna_network_bytes_to_budget,
-    .fna_network_budget_to_bytes = rtep_fna_network_budget_to_bytes,
-    .fna_network_get_min_eff_budget = rtep_fna_network_get_min_eff_budget
-};
-
-// TODO: move this out of here
-
-#include "fna_configuration.h"
-
-fna_operations_t  *fna_operations[FNA_MAX_NETWORKS] = {
-    &rtep_fna_operations, // resource_id 0 (default) --> RTEP
-    NULL, // resource_id 1
-    NULL, // resource_id 2
-    NULL  // resource_id 3
+#ifdef CONFIG_FNA_RTEP_CONNECTED
+        .fna_init = rtep_fna_init,
+        .fna_contract_negotiate = rtep_fna_contract_negotiate,
+        .fna_contract_renegotiate_sync = rtep_fna_contract_renegotiate_sync,
+        .fna_contract_renegotiate_async = rtep_fna_contract_renegotiate_async,
+        .fna_vres_get_renegotiation_status = rtep_fna_vres_get_renegotiation_status,
+        .fna_vres_destroy = rtep_fna_vres_destroy,
+        .fna_vres_get_contract = rtep_fna_vres_get_contract,
+        .fna_vres_get_usage = rtep_fna_vres_get_usage,
+        .fna_vres_get_remaining_budget = rtep_fna_vres_get_remaining_budget,
+        .fna_vres_get_budget_and_period = rtep_fna_vres_get_budget_and_period,
+        .fna_resource_get_capacity = rtep_fna_resource_get_capacity,
+        .fna_resource_get_total_weight = rtep_fna_resource_get_total_weight,
+        .fna_vres_decrease_capacity = rtep_fna_vres_decrease_capacity,
+        .fna_send_sync = rtep_fna_send_sync,
+        .fna_send_async = rtep_fna_send_async,
+        .fna_receive_sync = rtep_fna_receive_sync,
+        .fna_receive_async = rtep_fna_receive_async,
+        .fna_send_endpoint_get_status = rtep_fna_send_endpoint_get_status,
+        .fna_receive_endpoint_created = rtep_fna_receive_endpoint_created,
+        .fna_receive_endpoint_get_status = rtep_fna_receive_endpoint_get_status,
+#endif
+        .fna_network_get_max_message_size = rtep_fna_network_get_max_message_size,
+        .fna_network_bytes_to_budget = rtep_fna_network_bytes_to_budget,
+        .fna_network_budget_to_bytes = rtep_fna_network_budget_to_bytes,
+        .fna_network_get_min_eff_budget = rtep_fna_network_get_min_eff_budget
 };