This source file includes following definitions.
- batadv_bitmap_shift_left
- batadv_bit_get_packet
1
2
3
4
5
6
7 #include "bitarray.h"
8 #include "main.h"
9
10 #include <linux/bitmap.h>
11
12 #include "log.h"
13
14
15 static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
16 {
17 if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
18 return;
19
20 bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE);
21 }
22
23
24
25
26
27
28
29
30
31
32
33
34
35 bool batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
36 s32 seq_num_diff, int set_mark)
37 {
38 struct batadv_priv *bat_priv = priv;
39
40
41
42
43 if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
44 if (set_mark)
45 batadv_set_bit(seq_bits, -seq_num_diff);
46 return false;
47 }
48
49
50
51
52 if (seq_num_diff > 0 && seq_num_diff < BATADV_TQ_LOCAL_WINDOW_SIZE) {
53 batadv_bitmap_shift_left(seq_bits, seq_num_diff);
54
55 if (set_mark)
56 batadv_set_bit(seq_bits, 0);
57 return true;
58 }
59
60
61 if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE &&
62 seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) {
63 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
64 "We missed a lot of packets (%i) !\n",
65 seq_num_diff - 1);
66 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
67 if (set_mark)
68 batadv_set_bit(seq_bits, 0);
69 return true;
70 }
71
72
73
74
75
76
77
78
79
80
81 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
82 "Other host probably restarted!\n");
83
84 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
85 if (set_mark)
86 batadv_set_bit(seq_bits, 0);
87
88 return true;
89 }