diff options
Diffstat (limited to 'bgpd/bgp_engine.h')
-rw-r--r-- | bgpd/bgp_engine.h | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/bgpd/bgp_engine.h b/bgpd/bgp_engine.h index ceec1b2f..821d8127 100644 --- a/bgpd/bgp_engine.h +++ b/bgpd/bgp_engine.h @@ -22,23 +22,45 @@ #ifndef _QUAGGA_BGP_ENGINE_H #define _QUAGGA_BGP_ENGINE_H +#include "lib/misc.h" + #include "bgpd/bgpd.h" #include "lib/mqueue.h" #include "lib/qpnexus.h" #include "lib/log.h" -#ifndef Inline -#define Inline static inline +/*============================================================================== + * BGP_ENGINE_DEBUG setting + * + * Set to 1 if defined, but blank. + * Set to QDEBUG if not defined. + * + * Force to 0 if BGP_ENGINE_NO_DEBUG is defined and not zero. + * + * So: defaults to same as QDEBUG, but no matter what QDEBUG is set to: + * + * * can set BGP_ENGINE_DEBUG == 0 to turn off debug + * * or set BGP_ENGINE_DEBUG != 0 to turn on debug + * * or set BGP_ENGINE_NO_DEBUG != to force debug off + */ +#ifdef BGP_ENGINE_DEBUG /* If defined, make it 1 or 0 */ +# if IS_BLANK_OPTION(BGP_ENGINE_DEBUG) +# undef BGP_ENGINE_DEBUG +# define BGP_ENGINE_DEBUG 1 +# endif +#else /* If not defined, follow QDEBUG */ +# define BGP_ENGINE_DEBUG QDEBUG #endif -enum { qdebug = -#ifdef QDEBUG - 1 -#else - 0 +#ifdef BGP_ENGINE_NO_DEBUG /* Override, if defined */ +# if IS_NOT_ZERO_OPTION(BGP_ENGINE_NO_DEBUG) +# undef BGP_ENGINE_DEBUG +# define BGP_ENGINE_DEBUG 0 +# endif #endif -}; + +enum { bgp_engine_debug = BGP_ENGINE_DEBUG } ; /*============================================================================== * @@ -70,7 +92,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) ++stats->count ; - qpt_mutex_lock(&mq->mutex) ; + qpt_mutex_lock(mq->mutex) ; if (mq->count > stats->max) stats->max = mq->count ; @@ -81,7 +103,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) if (stats->count < 1000) { - qpt_mutex_unlock(&mq->mutex) ; + qpt_mutex_unlock(mq->mutex) ; return ; } ; @@ -96,7 +118,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) assert(my_count == mq->count) ; - qpt_mutex_unlock(&mq->mutex) ; + qpt_mutex_unlock(mq->mutex) ; average = stats->total * 1000 ; average = (average / stats->count) + 5 ; @@ -119,10 +141,10 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) /* Send given message to the BGP Engine -- priority/ordinary */ Inline void -bgp_to_bgp_engine(mqueue_block mqb, enum mqb_rank priority) +bgp_to_bgp_engine(mqueue_block mqb, mqb_rank_b priority) { mqueue_enqueue(bgp_nexus->queue, mqb, priority) ; - if (qdebug) + if (bgp_engine_debug) bgp_queue_logging("BGP Engine", bgp_nexus->queue, &bgp_engine_queue_stats) ; } ; @@ -133,10 +155,10 @@ bgp_to_bgp_engine(mqueue_block mqb, enum mqb_rank priority) /* Send given message to the Routing Engine -- priority/ordinary */ Inline void -bgp_to_routing_engine(mqueue_block mqb, enum mqb_rank priority) +bgp_to_routing_engine(mqueue_block mqb, mqb_rank_b priority) { mqueue_enqueue(routing_nexus->queue, mqb, priority) ; - if (qdebug) + if (bgp_engine_debug) bgp_queue_logging("Routing Engine", routing_nexus->queue, &routing_engine_queue_stats) ; } ; |