1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2013-2019  B.A.T.M.A.N. contributors:
3  *
4  * Martin Hundebøll <martin@hundeboll.net>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _NET_BATMAN_ADV_FRAGMENTATION_H_
20 #define _NET_BATMAN_ADV_FRAGMENTATION_H_
21 
22 #include "main.h"
23 
24 #include <linux/compiler.h>
25 #include <linux/list.h>
26 #include <linux/stddef.h>
27 #include <linux/types.h>
28 
29 struct sk_buff;
30 
31 void batadv_frag_purge_orig(struct batadv_orig_node *orig,
32 			    bool (*check_cb)(struct batadv_frag_table_entry *));
33 bool batadv_frag_skb_fwd(struct sk_buff *skb,
34 			 struct batadv_hard_iface *recv_if,
35 			 struct batadv_orig_node *orig_node_src);
36 bool batadv_frag_skb_buffer(struct sk_buff **skb,
37 			    struct batadv_orig_node *orig_node);
38 int batadv_frag_send_packet(struct sk_buff *skb,
39 			    struct batadv_orig_node *orig_node,
40 			    struct batadv_neigh_node *neigh_node);
41 
42 /**
43  * batadv_frag_check_entry() - check if a list of fragments has timed out
44  * @frags_entry: table entry to check
45  *
46  * Return: true if the frags entry has timed out, false otherwise.
47  */
48 static inline bool
49 batadv_frag_check_entry(struct batadv_frag_table_entry *frags_entry)
50 {
51 	if (!hlist_empty(&frags_entry->fragment_list) &&
52 	    batadv_has_timed_out(frags_entry->timestamp, BATADV_FRAG_TIMEOUT))
53 		return true;
54 	return false;
55 }
56 
57 #endif /* _NET_BATMAN_ADV_FRAGMENTATION_H_ */
58