From: Michal Sojka Date: Thu, 13 Aug 2009 10:59:16 +0000 (+0200) Subject: Convert debug messages to uLUt and fix #include dependencies X-Git-Url: http://rtime.felk.cvut.cz/gitweb/frescor/fwp.git/commitdiff_plain/d28234e93c9c447725265bb184bc89f14efd4209 Convert debug messages to uLUt and fix #include dependencies --- diff --git a/fwp/lib/frsh_fwp/fwp_fna.c b/fwp/lib/frsh_fwp/fwp_fna.c index c61666a..2cd477a 100644 --- a/fwp/lib/frsh_fwp/fwp_fna.c +++ b/fwp/lib/frsh_fwp/fwp_fna.c @@ -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) { diff --git a/fwp/lib/fwp/Makefile.omk b/fwp/lib/fwp/Makefile.omk index d47d69d..4098655 100644 --- a/fwp/lib/fwp/Makefile.omk +++ b/fwp/lib/fwp/Makefile.omk @@ -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 diff --git a/fwp/lib/fwp/fwp.c b/fwp/lib/fwp/fwp.c index b4f39b6..55560a9 100644 --- a/fwp/lib/fwp/fwp.c +++ b/fwp/lib/fwp/fwp.c @@ -46,6 +46,11 @@ #include "fwp_conf.h" #include "fwp_vres.h" #include "fwp_utils.h" +#include +#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 index 0000000..cbbe074 --- /dev/null +++ b/fwp/lib/fwp/fwp_debug.h @@ -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 + +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 diff --git a/fwp/lib/fwp/fwp_endpoint.c b/fwp/lib/fwp/fwp_endpoint.c index eb894cf..61af6ad 100644 --- a/fwp/lib/fwp/fwp_endpoint.c +++ b/fwp/lib/fwp/fwp_endpoint.c @@ -46,8 +46,13 @@ #include "fwp_endpoint.h" #include "fwp_msgb.h" #include +#include +#include +#include +#include "fwp_utils.h" #include +#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; } diff --git a/fwp/lib/fwp/fwp_endpoint.h b/fwp/lib/fwp/fwp_endpoint.h index 71633e5..addb338 100644 --- a/fwp/lib/fwp/fwp_endpoint.h +++ b/fwp/lib/fwp/fwp_endpoint.h @@ -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, diff --git a/fwp/lib/fwp/fwp_utils.c b/fwp/lib/fwp/fwp_utils.c index 83f6106..69cf356 100644 --- a/fwp/lib/fwp/fwp_utils.c +++ b/fwp/lib/fwp/fwp_utils.c @@ -45,8 +45,11 @@ /**************************************************************************/ #include "fwp_utils.h" +#include #include /*#include */ +#include "fwp_debug.h" +#include /*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}; diff --git a/fwp/lib/fwp/fwp_utils.h b/fwp/lib/fwp/fwp_utils.h index 7098c5b..bf20ec5 100644 --- a/fwp/lib/fwp/fwp_utils.h +++ b/fwp/lib/fwp/fwp_utils.h @@ -46,16 +46,8 @@ #ifndef _FWP_UTILS_H #define _FWP_UTILS_H -#include -#include -#include -#include -#include - -#include #include #include -#include #include #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) diff --git a/fwp/lib/fwp/fwp_vres.c b/fwp/lib/fwp/fwp_vres.c index e4a0456..94de6ff 100644 --- a/fwp/lib/fwp/fwp_vres.c +++ b/fwp/lib/fwp/fwp_vres.c @@ -48,8 +48,11 @@ #include "fwp_msgq.h" #include "fwp_endpoint.h" +#include "fwp_debug.h" #include +#include +#include static void* fwp_vres_tx_thread(void *_vres); diff --git a/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test1.c b/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test1.c index 123fcc8..d0294ce 100644 --- a/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test1.c +++ b/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test1.c @@ -16,6 +16,7 @@ #include #include +#include int main() { diff --git a/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c b/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c index 9f377db..6af7623 100644 --- a/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c +++ b/fwp/lib/fwp/tests/fwp_prototest/fwp_sendrecv_test2.c @@ -17,6 +17,7 @@ #include #include #include +#include #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) { diff --git a/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c b/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c index 0ac9cdc..fee130f 100644 --- a/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c +++ b/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c @@ -16,6 +16,8 @@ #include #include +#include +#include #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"); diff --git a/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest2.c b/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest2.c index 22c5838..fd7c190 100644 --- a/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest2.c +++ b/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest2.c @@ -18,6 +18,10 @@ #include #include #include +#include + +#include +#include #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; diff --git a/fwp/mngr/fwp_admctrl.c b/fwp/mngr/fwp_admctrl.c index e42809a..ee410b2 100644 --- a/fwp/mngr/fwp_admctrl.c +++ b/fwp/mngr/fwp_admctrl.c @@ -49,6 +49,7 @@ #include "fwp_admctrl.h" #include #include +#include "fwp_utils.h" UL_LOG_CUST(ulogd_fwp_admctrl); ul_log_domain_t ulogd_fwp_admctrl = {UL_LOGL_MSG, "fwp_admctrl"};