1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2007-2019  B.A.T.M.A.N. contributors:
3  *
4  * Marek Lindner, Simon Wunderlich, Antonio Quartulli
5  */
6 
7 #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
8 #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
9 
10 #include "main.h"
11 
12 #include <linux/types.h>
13 
14 struct netlink_callback;
15 struct net_device;
16 struct seq_file;
17 struct sk_buff;
18 
19 int batadv_tt_init(struct batadv_priv *bat_priv);
20 bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
21 			 unsigned short vid, int ifindex, u32 mark);
22 u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
23 			   const u8 *addr, unsigned short vid,
24 			   const char *message, bool roaming);
25 int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
26 int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
27 int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb);
28 int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
29 void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
30 			       struct batadv_orig_node *orig_node,
31 			       s32 match_vid, const char *message);
32 struct batadv_tt_global_entry *
33 batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
34 			   unsigned short vid);
35 void batadv_tt_global_entry_put(struct batadv_tt_global_entry *tt_global_entry);
36 int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
37 				const u8 *addr, unsigned short vid);
38 struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
39 						  const u8 *src, const u8 *addr,
40 						  unsigned short vid);
41 void batadv_tt_free(struct batadv_priv *bat_priv);
42 bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
43 			 unsigned short vid);
44 bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
45 			   unsigned short vid);
46 void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
47 bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
48 					u8 *addr, unsigned short vid);
49 bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
50 				       u8 *addr, unsigned short vid);
51 void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface);
52 bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
53 					  struct batadv_orig_node *orig_node,
54 					  const unsigned char *addr,
55 					  unsigned short vid);
56 bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
57 				  const u8 *addr, unsigned short vid);
58 
59 int batadv_tt_cache_init(void);
60 void batadv_tt_cache_destroy(void);
61 
62 #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
63