summaryrefslogtreecommitdiff
path: root/net/batman-adv/bitarray.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/bitarray.c')
-rw-r--r--net/batman-adv/bitarray.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c
index 973982414d58..2c49b2711650 100644
--- a/net/batman-adv/bitarray.c
+++ b/net/batman-adv/bitarray.c
@@ -1,29 +1,18 @@
-/* Copyright (C) 2006-2013 B.A.T.M.A.N. contributors:
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) B.A.T.M.A.N. contributors:
*
* Simon Wunderlich, Marek Lindner
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA
*/
-#include "main.h"
#include "bitarray.h"
+#include "main.h"
+
+#include <linux/bitmap.h>
-#include <linux/bitops.h>
+#include "log.h"
/* shift the packet array by n places. */
-static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
+static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
{
if (n <= 0 || n >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return;
@@ -31,15 +20,20 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, int32_t n)
bitmap_shift_left(seq_bits, seq_bits, n, BATADV_TQ_LOCAL_WINDOW_SIZE);
}
-
-/* receive and process one packet within the sequence number window.
+/**
+ * batadv_bit_get_packet() - receive and process one packet within the sequence
+ * number window
+ * @priv: the bat priv with all the mesh interface information
+ * @seq_bits: pointer to the sequence number receive packet
+ * @seq_num_diff: difference between the current/received sequence number and
+ * the last sequence number
+ * @set_mark: whether this packet should be marked in seq_bits
*
- * returns:
- * 1 if the window was moved (either new or very old)
- * 0 if the window was not moved/shifted.
+ * Return: true if the window was moved (either new or very old),
+ * false if the window was not moved/shifted.
*/
-int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
- int32_t seq_num_diff, int set_mark)
+bool batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
+ s32 seq_num_diff, int set_mark)
{
struct batadv_priv *bat_priv = priv;
@@ -49,7 +43,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
if (set_mark)
batadv_set_bit(seq_bits, -seq_num_diff);
- return 0;
+ return false;
}
/* sequence number is slightly newer, so we shift the window and
@@ -60,7 +54,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if (set_mark)
batadv_set_bit(seq_bits, 0);
- return 1;
+ return true;
}
/* sequence number is much newer, probably missed a lot of packets */
@@ -72,7 +66,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
if (set_mark)
batadv_set_bit(seq_bits, 0);
- return 1;
+ return true;
}
/* received a much older packet. The other host either restarted
@@ -91,5 +85,5 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
if (set_mark)
batadv_set_bit(seq_bits, 0);
- return 1;
+ return true;
}