]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - fwp/lib/frsh_fwp/fwp_fna.c
Convert debug messages to uLUt and fix #include dependencies
[frescor/fwp.git] / fwp / lib / frsh_fwp / fwp_fna.c
index c7892cef33ab1b3ebb2bd2b572f9724ec5a9feb9..2cd477a909842751fa3a6262c27b5fdee886fdf2 100644 (file)
@@ -1,3 +1,48 @@
+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* 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 FWP (Frescor WLAN Protocol)                     */
+/*                                                                       */
+/* FWP 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.  FWP 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 FWP; see file       */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
+/* Cambridge, MA 02139, USA.                                             */
+/*                                                                       */
+/* As a special exception, including FWP header files in a file,         */
+/* instantiating FWP generics or templates, or linking other files       */
+/* with FWP 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 <fna.h>
 #include <fres_vres.h>
 #include <frsh_forb.h>
@@ -5,6 +50,8 @@
 #include "fwp_vres.h"
 #include "fwp.h"
 #include "fwp_res.h"
+#include "fwp_utils.h"
+#include "fwp_debug.h"
 
 int fwp_fna_init(const frsh_resource_id_t resource_id)
 {
@@ -13,21 +60,21 @@ int fwp_fna_init(const frsh_resource_id_t resource_id)
        if ((rv = fwp_init()))
                return rv;
 
-       return frs_fwp_init(frsh_forb_global.orb, frsh_forb_global.fcb,
-                               &frsh_forb_global.sch_executor);
+       return fra_fwp_init();
 }
 
 int fwp_fna_network_budget_to_bytes(const frsh_resource_id_t resource_id,
                        const frsh_rel_time_t *budget, size_t *nbytes)
 {
-       *nbytes = budget->tv_sec;
+       *nbytes = budget->tv_nsec;
        return 0;       
 }
 
 int fwp_fna_network_bytes_to_budget(const frsh_resource_id_t resource_id,
                        const size_t nbytes, frsh_rel_time_t *budget)
 {
-       budget->tv_sec = nbytes;
+       budget->tv_nsec = nbytes;
+       budget->tv_sec = 0;
        return 0;
 }
 
@@ -42,10 +89,8 @@ int fwp_fna_send_endpoint_created(fna_endpoint_data_t  *endpoint)
        port = (unsigned int) endpoint->stream_id;
        attr = (fwp_endpoint_attr_t*) endpoint->endpoint_protocol_info.send.body; 
        rv = fwp_send_endpoint_create(node, port, attr, &fwp_epoint);
-       if (rv)
-               return rv;
        endpoint->protocol_info.body = fwp_epoint;
-       return 0;
+       return rv;
 }
 
 int fwp_fna_receive_endpoint_created(fna_endpoint_data_t  *endpoint)
@@ -65,6 +110,7 @@ int fwp_fna_receive_endpoint_created(fna_endpoint_data_t  *endpoint)
        endpoint->protocol_info.body = fwp_epoint;
        fwp_endpoint_get_params(fwp_epoint, &node, &port, attr);
        endpoint->stream_id = port;
+       FWP_DEBUG("PORT= %d\n", port);
 
        return 0;
 }
@@ -149,9 +195,11 @@ int fwp_fna_receive_sync(const fna_endpoint_data_t *endpoint, void *buffer,
        len = fwp_recv(fwp_epoint, buffer, buffer_size, &from_addr, flags);
        if (len < 0) 
                return len;
-       
-       *received_bytes = len;
-       *from = from_addr;
+
+       if (received_bytes)
+               *received_bytes = len;
+       if (from)
+               *from = from_addr;
        
        return 0;
 }
@@ -169,9 +217,11 @@ int fwp_fna_receive_async(const fna_endpoint_data_t *endpoint, void *buffer,
        len = fwp_recv(fwp_epoint, buffer, buffer_size, &from_addr, flags);
        if (len < 0) 
                return len;
-       
-       *received_bytes = len;
-       *from = from_addr;
+
+       if (received_bytes)
+               *received_bytes = len;
+       if (from)
+               *from = from_addr;
        
        return 0;
 }