]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Convert debug messages to uLUt and fix #include dependencies
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 13 Aug 2009 10:59:16 +0000 (12:59 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 13 Aug 2009 10:59:16 +0000 (12:59 +0200)
14 files changed:
fwp/lib/frsh_fwp/fwp_fna.c
fwp/lib/fwp/Makefile.omk
fwp/lib/fwp/fwp.c
fwp/lib/fwp/fwp_debug.h [new file with mode: 0644]
fwp/lib/fwp/fwp_endpoint.c
fwp/lib/fwp/fwp_endpoint.h
fwp/lib/fwp/fwp_utils.c
fwp/lib/fwp/fwp_utils.h
fwp/lib/fwp/fwp_vres.c
fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test1.c
fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c
fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c
fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest2.c
fwp/mngr/fwp_admctrl.c

index c61666ac02a191bf1aa26aefef0ac73753716403..2cd477a909842751fa3a6262c27b5fdee886fdf2 100644 (file)
@@ -50,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)
 {
index d47d69d3ec01768ceed3ef71f1cea9ab903c6ce8..40986554ff4a0b3c3529c3351e1da095bd869132 100644 (file)
@@ -6,4 +6,8 @@ SUBDIRS = tests
 fwp_SOURCES = fwp_utils.c fwp_vres.c fwp_msgb.c fwp_msgq.c fwp_endpoint.c fwp.c
 include_HEADERS= fwp_conf.h fwp_confdefs.h fwp_endpoint.h fwp_vres.h fwp.h fwp_msgb.h\
                        fwp_msgq.h fwp_utils.h
+
+include_HEADERS += fwp_debug.h # This file (and maybe even some        \
+                                others) should not be exported!
+
 lib_LOADLIBES+= pthread rt ulut 
index b4f39b623f6bd00610c4ef500e2b740aea95ad2c..55560a94e24aaa70206b2c0cbf7d4eeb0d8954f6 100644 (file)
 #include "fwp_conf.h"
 #include "fwp_vres.h"
 #include "fwp_utils.h"
+#include <ul_logreg.h>
+#include "fwp_debug.h"
+
+ul_log_domain_t ulogd_fwp = {UL_LOGL_MSG, "fwp"};
+UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_fwo, ulogd_fwp);
 
 int fwp_init()
 {
diff --git a/fwp/lib/fwp/fwp_debug.h b/fwp/lib/fwp/fwp_debug.h
new file mode 100644 (file)
index 0000000..cbbe074
--- /dev/null
@@ -0,0 +1,58 @@
+/**************************************************************************/
+/* ---------------------------------------------------------------------- */
+/* 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.                                    */
+/**************************************************************************/
+
+#ifndef FWP_DEBUG_H
+#define FWP_DEBUG_H
+
+#include <ul_log.h>
+
+extern UL_LOG_CUST(ulogd_fwp);
+
+#define FWP_DEBUG(fmt,args...) ul_logdeb("%s: " fmt, __func__ , ##args)
+#define FWP_ERROR(fmt,args...) ul_logerr("%s: " fmt, __func__ , ##args)
+
+
+#endif
index eb894cf7f717113eb2ebf216c41af56c8a51b3dc..61af6ad5c471b54329d346649ebb206c2783647a 100644 (file)
 #include "fwp_endpoint.h"
 #include "fwp_msgb.h"
 #include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include "fwp_utils.h"
 
 #include <pthread.h>
+#include "fwp_debug.h"
 
 typedef unsigned int fwp_endpoint_id_t;
 
@@ -317,7 +322,7 @@ int fwp_receive_endpoint_create(unsigned int port,
                }
                
                if (listen(fwp_epoint->sockd, fwp_epoint->attr.max_connections)){
-                       perror("Error on listen call\n");
+                       FWP_ERROR("Error on listen call: %s\n", strerror(errno));
                        goto err;
                }
                
@@ -438,7 +443,7 @@ static int fwp_receive_endpoint_accept(fwp_endpoint_t *fwp_epoint)
                        &peer.addrlen);
        
        if (csockd < 0) {
-               perror("Error on accept\n");
+               FWP_ERROR("Error on accept: %s\n", strerror(errno));
                return errno;   
        }               
 
index 71633e54d60257dd765bc0f9d508b9e8ef9ea7cd..addb338ec5b5a8cd0c22797b5b3897334d2e054f 100644 (file)
@@ -72,8 +72,6 @@ struct fwp_endpoint_attr {
        /* queueing policy*/
 } fwp_endpoint_attr_t;
 
-/*TODO: extract FWP_DEBUG from fwp_utils.h */
-#include "fwp_utils.h"
 #include "fwp_vres.h"
 
 int fwp_endpoint_get_params(fwp_endpoint_d_t epointd, unsigned int *node, 
index 83f61066e8cec445a7f828de594e83eeb39ffa59..69cf356b0c096c47cd7dbdd9984b1cacd65321c9 100644 (file)
 /**************************************************************************/
 #include "fwp_utils.h"
 
+#include <unistd.h>
 #include <sched.h>
 /*#include <stdlib.h>*/
+#include "fwp_debug.h"
+#include <errno.h>
 
 /*const int prio_to_ac[8] = {2,3,3,2,1,1,0,0};
 const unsigned int ac_to_tos[4] = {224,160,96,64};
index 7098c5b9deceb15ba0e0e1661c3b4b8536a4925c..bf20ec5f5fb5409b158aba0834ca6e961a527b52 100644 (file)
 #ifndef _FWP_UTILS_H
 #define _FWP_UTILS_H
 
-#include <time.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
 #include <fwp_msgb.h>
 
 #define Kbit 1000
@@ -71,20 +63,6 @@ extern const unsigned int ac_to_tos[4];
 extern const char *ac_to_text[4];
 */
 
-#define DEBUG
-
-/* TODO: Introduce multilevel debugging massages and printf-like
- * debugging function. */
-
-#ifdef DEBUG
-#define FWP_DEBUG(fmt,args...) printf("fwp: %s: " fmt, __func__ , ##args)
-#define FWP_ERROR(fmt,args...) fprintf(stderr, "fwp: %s: " fmt, __func__ , ##args)
-
-#else
-#define FWP_DEBUG(fmt,args...)
-#define FWP_ERROR(fmt,args...)
-#endif
-
 static inline ssize_t
 _fwp_sendto(int s, const void *buf, size_t len, int flags,
            const fwp_sockaddr_t *sockaddr)
index e4a04569abde23d6c0c17a6f1a30ef20e8289c09..94de6ffb77ba163d2a477ed530495e42dab86edc 100644 (file)
 
 #include "fwp_msgq.h"
 #include "fwp_endpoint.h"
+#include "fwp_debug.h"
 
 #include <string.h>
+#include <errno.h>
+#include <stdlib.h>
 
 static void* fwp_vres_tx_thread(void *_vres);
 
index 123fcc891f9b2cf33f2d81844a4ac825e70bb386..d0294ce0e65cd32a262dfa08bf341f28d0730c8b 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <arpa/inet.h>
 
 int main()
 {
index 9f377dbe52fa113ba435e14011346d18c2d914fc..6af7623720c2a63009d8d98fb52158cf9e5caba1 100644 (file)
@@ -17,6 +17,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <pthread.h>
+#include <arpa/inet.h>
 
 #define MSGN 2
 
@@ -29,13 +30,13 @@ void* receiver(void* arg)
        char buffer[30];
        fwp_addr_t from;
        
-       FWP_DEBUG("Creating receive endpoint\n");
+       printf("Creating receive endpoint\n");
        if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
                perror("Error while creating receive endpoint\n");
                return NULL;
        }
                
-       FWP_DEBUG("Receive endpoint created \n");
+       printf("Receive endpoint created \n");
        for (i = 0; i < MSGN; i++) {
                if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), &from,
                         0)) < 0) {
@@ -97,9 +98,9 @@ int main()
        fwp_send_endpoint_bind(sepoint_d1, vres_d1);
        
        fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
-       FWP_DEBUG("Sent msg1\n");
+       printf("Sent msg1\n");
        fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
-       FWP_DEBUG("Sent msg2\n");
+       printf("Sent msg2\n");
        
        pthread_join(thread, (void**) NULL);    
        /*if (fwp_vres_destroy(vres_d1) < 0) {
index 0ac9cdc296dec1f7182f686ff7a98d7c5071f889..fee130f3ed38829a9a0765fb4a4e9ee1301e6d0b 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <arpa/inet.h>
+#include <time.h>
 
 #define  NUM  10000
 
@@ -77,8 +79,8 @@ int main()
                fwp_send(sepoint_d1, msg1, sizeof(msg1), 0);
                
                clock_gettime(CLOCK_MONOTONIC, &sendtime);
-               FWP_DEBUG("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
-                               sendtime.tv_nsec);
+               printf("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
+                      sendtime.tv_nsec);
                
                if ((len = fwp_recv(repoint_d, buffer, sizeof(buffer), &from, 0)) < 0) {
                        perror("Error while receiving data");
index 22c5838f5a1d234c70a54b584bbe0e9ce793ba98..fd7c190ff6ca9f98f9e4aea6a7be48648f7fa82e 100644 (file)
 #include <errno.h>
 #include <stdio.h>
 #include <pthread.h>
+#include <unistd.h>
+
+#include <arpa/inet.h>
+#include <fwp_utils.h>
 
 #define  NUM  20
 #define  PORT 65111
@@ -108,8 +112,8 @@ void* receiver()
                        else printf("Received - %s\n", buffer);
                
                clock_gettime(CLOCK_MONOTONIC, &recvtime);
-               FWP_DEBUG("Received %d: sec = %ld nsec = %ld \n", count, 
-                               recvtime.tv_sec, recvtime.tv_nsec);
+               printf("Received %d: sec = %ld nsec = %ld \n", count, 
+                      recvtime.tv_sec, recvtime.tv_nsec);
        }
 
        exit_flag = 1;
index e42809afd233424e4a1d23688c471a4ac301fb4a..ee410b20bbbe57ff0f93da50e9fecc5f1e535857 100644 (file)
@@ -49,6 +49,7 @@
 #include "fwp_admctrl.h"
 #include <ul_log.h>
 #include <ul_logreg.h>
+#include "fwp_utils.h"
 
 UL_LOG_CUST(ulogd_fwp_admctrl);
 ul_log_domain_t ulogd_fwp_admctrl = {UL_LOGL_MSG, "fwp_admctrl"};