@@ -34,15 +34,13 @@ find_neighbour_nocreate(const unsigned char *address, struct interface *ifp)
34
34
{
35
35
struct neighbour * neigh ;
36
36
FOR_ALL_NEIGHBOURS (neigh ) {
37
- if (memcmp (address , neigh -> address , 16 ) == 0 &&
38
- neigh -> ifp == ifp )
37
+ if (memcmp (address , neigh -> address , 16 ) == 0 && neigh -> ifp == ifp )
39
38
return neigh ;
40
39
}
41
40
return NULL ;
42
41
}
43
42
44
- void
45
- flush_neighbour (struct neighbour * neigh )
43
+ void flush_neighbour (struct neighbour * neigh )
46
44
{
47
45
debugf (BABEL_DEBUG_COMMON ,"Flushing neighbour %s (reach 0x%04x)" ,
48
46
format_address (neigh -> address ), neigh -> reach );
@@ -102,8 +100,7 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
102
100
}
103
101
104
102
/* Recompute a neighbour's rxcost. Return true if anything changed. */
105
- int
106
- update_neighbour (struct neighbour * neigh , int hello , int hello_interval )
103
+ int update_neighbour (struct neighbour * neigh , int hello , int hello_interval )
107
104
{
108
105
int missed_hellos ;
109
106
int rc = 0 ;
@@ -160,26 +157,26 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
160
157
if (hello >= 0 ) {
161
158
neigh -> hello_seqno = hello ;
162
159
neigh -> reach >>= 1 ;
163
- neigh -> reach |= 0x8000 ;
164
- if ((neigh -> reach & 0xFC00 ) != 0xFC00 )
160
+ SET_FLAG ( neigh -> reach , 0x8000 ) ;
161
+ if (CHECK_FLAG (neigh -> reach , 0xFC00 ) != 0xFC00 )
165
162
rc = 1 ;
166
163
}
167
164
168
165
/* Make sure to give neighbours some feedback early after association */
169
- if ((neigh -> reach & 0xBF00 ) == 0x8000 ) {
166
+ if (CHECK_FLAG (neigh -> reach , 0xBF00 ) == 0x8000 ) {
170
167
/* A new neighbour */
171
168
send_hello (neigh -> ifp );
172
169
} else {
173
170
/* Don't send hellos, in order to avoid a positive feedback loop. */
174
- int a = (neigh -> reach & 0xC000 );
175
- int b = (neigh -> reach & 0x3000 );
171
+ int a = CHECK_FLAG (neigh -> reach , 0xC000 );
172
+ int b = CHECK_FLAG (neigh -> reach , 0x3000 );
176
173
if ((a == 0xC000 && b == 0 ) || (a == 0 && b == 0x3000 )) {
177
174
/* Reachability is either 1100 or 0011 */
178
175
send_self_update (neigh -> ifp );
179
176
}
180
177
}
181
178
182
- if ((neigh -> reach & 0xFC00 ) == 0xC000 ) {
179
+ if (CHECK_FLAG (neigh -> reach , 0xFC00 ) == 0xC000 ) {
183
180
/* This is a newish neighbour, let's request a full route dump.
184
181
We ought to avoid this when the network is dense */
185
182
send_unicast_request (neigh , NULL , 0 );
@@ -188,8 +185,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
188
185
return rc ;
189
186
}
190
187
191
- static int
192
- reset_txcost (struct neighbour * neigh )
188
+ static int reset_txcost (struct neighbour * neigh )
193
189
{
194
190
unsigned delay ;
195
191
@@ -199,9 +195,8 @@ reset_txcost(struct neighbour *neigh)
199
195
return 0 ;
200
196
201
197
/* If we're losing a lot of packets, we probably lost an IHU too */
202
- if (delay >= 180000 || (neigh -> reach & 0xFFF0 ) == 0 ||
203
- (neigh -> ihu_interval > 0 &&
204
- delay >= neigh -> ihu_interval * 10U * 10U )) {
198
+ if (delay >= 180000 || CHECK_FLAG (neigh -> reach , 0xFFF0 ) == 0 ||
199
+ (neigh -> ihu_interval > 0 && delay >= neigh -> ihu_interval * 10U * 10U )) {
205
200
neigh -> txcost = INFINITY ;
206
201
neigh -> ihu_time = babel_now ;
207
202
return 1 ;
@@ -210,14 +205,12 @@ reset_txcost(struct neighbour *neigh)
210
205
return 0 ;
211
206
}
212
207
213
- unsigned
214
- neighbour_txcost (struct neighbour * neigh )
208
+ unsigned neighbour_txcost (struct neighbour * neigh )
215
209
{
216
210
return neigh -> txcost ;
217
211
}
218
212
219
- unsigned
220
- check_neighbours (void )
213
+ unsigned check_neighbours (void )
221
214
{
222
215
struct neighbour * neigh ;
223
216
int changed , rc ;
@@ -253,21 +246,20 @@ check_neighbours(void)
253
246
return msecs ;
254
247
}
255
248
256
- unsigned
257
- neighbour_rxcost (struct neighbour * neigh )
249
+ unsigned neighbour_rxcost (struct neighbour * neigh )
258
250
{
259
251
unsigned delay ;
260
252
unsigned short reach = neigh -> reach ;
261
253
262
254
delay = timeval_minus_msec (& babel_now , & neigh -> hello_time );
263
255
264
- if ((reach & 0xFFF0 ) == 0 || delay >= 180000 ) {
256
+ if (CHECK_FLAG (reach , 0xFFF0 ) == 0 || delay >= 180000 ) {
265
257
return INFINITY ;
266
- } else if ( babel_get_if_nfo (neigh -> ifp )-> flags & BABEL_IF_LQ ) {
258
+ } else if ( CHECK_FLAG ( babel_get_if_nfo (neigh -> ifp )-> flags , BABEL_IF_LQ ) ) {
267
259
int sreach =
268
- ((reach & 0x8000 ) >> 2 ) +
269
- ((reach & 0x4000 ) >> 1 ) +
270
- (reach & 0x3FFF );
260
+ (CHECK_FLAG (reach , 0x8000 ) >> 2 ) +
261
+ (CHECK_FLAG (reach , 0x4000 ) >> 1 ) +
262
+ CHECK_FLAG (reach , 0x3FFF );
271
263
/* 0 <= sreach <= 0x7FFF */
272
264
int cost = (0x8000 * babel_get_if_nfo (neigh -> ifp )-> cost ) / (sreach + 1 );
273
265
/* cost >= interface->cost */
@@ -276,19 +268,18 @@ neighbour_rxcost(struct neighbour *neigh)
276
268
return MIN (cost , INFINITY );
277
269
} else {
278
270
/* To lose one hello is a misfortune, to lose two is carelessness. */
279
- if ( (reach & 0xC000 ) == 0xC000 )
271
+ if ( CHECK_FLAG (reach , 0xC000 ) == 0xC000 )
280
272
return babel_get_if_nfo (neigh -> ifp )-> cost ;
281
- else if ( (reach & 0xC000 ) == 0 )
273
+ else if ( CHECK_FLAG (reach , 0xC000 ) == 0 )
282
274
return INFINITY ;
283
- else if ( (reach & 0x2000 ))
275
+ else if ( CHECK_FLAG (reach , 0x2000 ))
284
276
return babel_get_if_nfo (neigh -> ifp )-> cost ;
285
277
else
286
278
return INFINITY ;
287
279
}
288
280
}
289
281
290
- unsigned
291
- neighbour_rttcost (struct neighbour * neigh )
282
+ unsigned neighbour_rttcost (struct neighbour * neigh )
292
283
{
293
284
struct interface * ifp = neigh -> ifp ;
294
285
babel_interface_nfo * babel_ifp = babel_get_if_nfo (ifp );
@@ -304,15 +295,14 @@ neighbour_rttcost(struct neighbour *neigh)
304
295
(unsigned long long )babel_ifp -> max_rtt_penalty *
305
296
(neigh -> rtt - babel_ifp -> rtt_min ) /
306
297
(babel_ifp -> rtt_max - babel_ifp -> rtt_min );
307
- assert ((tmp & 0x7FFFFFFF ) == tmp );
298
+ assert (CHECK_FLAG (tmp , 0x7FFFFFFF ) == tmp );
308
299
return tmp ;
309
300
} else {
310
301
return babel_ifp -> max_rtt_penalty ;
311
302
}
312
303
}
313
304
314
- unsigned
315
- neighbour_cost (struct neighbour * neigh )
305
+ unsigned neighbour_cost (struct neighbour * neigh )
316
306
{
317
307
unsigned a , b , cost ;
318
308
@@ -328,7 +318,7 @@ neighbour_cost(struct neighbour *neigh)
328
318
if (b >= INFINITY )
329
319
return INFINITY ;
330
320
331
- if (! (babel_get_if_nfo (neigh -> ifp )-> flags & BABEL_IF_LQ )
321
+ if (! CHECK_FLAG (babel_get_if_nfo (neigh -> ifp )-> flags , BABEL_IF_LQ )
332
322
|| (a < 256 && b < 256 )) {
333
323
cost = a ;
334
324
} else {
@@ -347,8 +337,7 @@ neighbour_cost(struct neighbour *neigh)
347
337
return MIN (cost , INFINITY );
348
338
}
349
339
350
- int
351
- valid_rtt (struct neighbour * neigh )
340
+ int valid_rtt (struct neighbour * neigh )
352
341
{
353
342
return (timeval_minus_msec (& babel_now , & neigh -> rtt_time ) < 180000 ) ? 1 : 0 ;
354
343
}
0 commit comments