/* All flags are unset */
babel_ifp->bucket_time = babel_now.tv_sec;
babel_ifp->bucket = BUCKET_TOKENS_MAX;
- babel_ifp->hello_seqno = (frr_weak_random() & 0xFFFF);
+ babel_ifp->hello_seqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_ifp->rtt_decay = BABEL_DEFAULT_RTT_DECAY;
babel_ifp->rtt_min = BABEL_DEFAULT_RTT_MIN;
babel_ifp->rtt_max = BABEL_DEFAULT_RTT_MAX;
making these inits have sense. */
static void babel_init_routing_process(struct event *thread)
{
- myseqno = (frr_weak_random() & 0xFFFF);
+ myseqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_get_myid();
babel_load_state_file();
debugf(BABEL_DEBUG_COMMON, "My ID is : %s.", format_eui64(myid));
#if (defined NO_DEBUG)
#define printIfMin(a,b,c,d)
#else
-#define printIfMin(a, b, c, d) \
- if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) { \
+#define printIfMin(a, b, c, d) \
+ if (unlikely(CHECK_FLAG(debug, BABEL_DEBUG_TIMEOUT))) { \
printIfMin(a, b, c, d); \
}
have_src_prefix = 1;
} else {
debugf(BABEL_DEBUG_COMMON,"Received unknown%s Route Request sub-TLV %d.",
- ((type & 0x80) != 0) ? " mandatory" : "", type);
- if((type & 0x80) != 0)
+ (CHECK_FLAG(type, 0x80) != 0) ? " mandatory" : "", type);
+ if(CHECK_FLAG(type, 0x80) != 0)
return -1;
}
else
rc = -1;
if(rc < 0) {
- if(message[3] & 0x80)
+ if(CHECK_FLAG(message[3], 0x80))
have_v4_prefix = have_v6_prefix = 0;
goto fail;
}
plen = message[4] + (message[2] == 1 ? 96 : 0);
- if(message[3] & 0x80) {
+ if(CHECK_FLAG(message[3], 0x80)) {
if(message[2] == 1) {
memcpy(v4_prefix, prefix, 16);
have_v4_prefix = 1;
have_v6_prefix = 1;
}
}
- if(message[3] & 0x40) {
+ if(CHECK_FLAG(message[3], 0x40)) {
if(message[2] == 1) {
memset(router_id, 0, 4);
memcpy(router_id + 4, prefix + 12, 4);
goto fail;
}
debugf(BABEL_DEBUG_COMMON,"Received update%s%s for %s from %s on %s.",
- (message[3] & 0x80) ? "/prefix" : "",
- (message[3] & 0x40) ? "/id" : "",
+ ((CHECK_FLAG(message[3], 0x80)) ? "/prefix" : ""),
+ ((CHECK_FLAG(message[3], 0x40)) ? "/id" : ""),
format_prefix(prefix, plen),
format_address(from), ifp->name);
babel_ifp->hello_seqno, interval, ifp->name);
start_message(ifp, MESSAGE_HELLO,
- (babel_ifp->flags & BABEL_IF_TIMESTAMPS) ? 12 : 6);
+ (CHECK_FLAG(babel_ifp->flags, BABEL_IF_TIMESTAMPS) ? 12 : 6));
babel_ifp->buffered_hello = babel_ifp->buffered - 2;
accumulate_short(ifp, 0);
accumulate_short(ifp, babel_ifp->hello_seqno);
memset(ret, 0, 16);
memcpy(ret, prefix, plen / 8);
if(plen % 8 != 0)
- ret[plen / 8] =
- (prefix[plen / 8] & ((0xFF << (8 - (plen % 8))) & 0xFF));
+ ret[plen / 8] = CHECK_FLAG(prefix[plen / 8],
+ CHECK_FLAG((0xFF << (8 - (plen % 8))), 0xFF));
return ret;
}
{
return
(plen >= 8 && prefix[0] == 0xFF) ||
- (plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
+ (plen >= 10 && prefix[0] == 0xFE &&
+ (CHECK_FLAG(prefix[1], 0xC0) == 0x80)) ||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
(prefix[15] == 0 || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
- (plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
+ (plen >= 100 && CHECK_FLAG(prefix[12], 0xE0) == 0xE0)));
}
int
if(s1 == s2)
return 0;
else
- return ((s2 - s1) & 0x8000) ? 1 : -1;
+ return (CHECK_FLAG((s2 - s1), 0x8000)) ? 1 : -1;
}
static inline short
seqno_minus(unsigned short s1, unsigned short s2)
{
- return (short)((s1 - s2) & 0xFFFF);
+ return (short)(CHECK_FLAG((s1 - s2), 0xFFFF));
}
static inline unsigned short
seqno_plus(unsigned short s, int plus)
{
- return ((s + plus) & 0xFFFF);
+ return CHECK_FLAG((s + plus), 0xFFFF);
}
/* Returns a time in microseconds on 32 bits (thus modulo 2^32,
#define debugf(level, ...) \
do { \
- if (unlikely(debug & level)) \
+ if (unlikely(CHECK_FLAG(debug, level))) \
zlog_debug(__VA_ARGS__); \
} while (0)