xref: /openbmc/linux/net/batman-adv/translation-table.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
17db7d9f3SSven Eckelmann /* SPDX-License-Identifier: GPL-2.0 */
2cfa55c6dSSven Eckelmann /* Copyright (C) B.A.T.M.A.N. contributors:
3c6c8fea2SSven Eckelmann  *
435c133a0SAntonio Quartulli  * Marek Lindner, Simon Wunderlich, Antonio Quartulli
5c6c8fea2SSven Eckelmann  */
6c6c8fea2SSven Eckelmann 
7c6c8fea2SSven Eckelmann #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
8c6c8fea2SSven Eckelmann #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
9c6c8fea2SSven Eckelmann 
101e2c2a4fSSven Eckelmann #include "main.h"
111e2c2a4fSSven Eckelmann 
12*6340dcbdSSven Eckelmann #include <linux/kref.h>
1368a600deSSven Eckelmann #include <linux/netdevice.h>
1468a600deSSven Eckelmann #include <linux/netlink.h>
1568a600deSSven Eckelmann #include <linux/skbuff.h>
161e2c2a4fSSven Eckelmann #include <linux/types.h>
171e2c2a4fSSven Eckelmann 
1856303d34SSven Eckelmann int batadv_tt_init(struct batadv_priv *bat_priv);
196b5e971aSSven Eckelmann bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
206b5e971aSSven Eckelmann 			 unsigned short vid, int ifindex, u32 mark);
216b5e971aSSven Eckelmann u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
226b5e971aSSven Eckelmann 			   const u8 *addr, unsigned short vid,
23c018ad3dSAntonio Quartulli 			   const char *message, bool roaming);
24d34f0550SMatthias Schiffer int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb);
25d34f0550SMatthias Schiffer int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
2656303d34SSven Eckelmann void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
2756303d34SSven Eckelmann 			       struct batadv_orig_node *orig_node,
286b5e971aSSven Eckelmann 			       s32 match_vid, const char *message);
2932e72744SLinus Lüssing struct batadv_tt_global_entry *
3032e72744SLinus Lüssing batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
3132e72744SLinus Lüssing 			   unsigned short vid);
32*6340dcbdSSven Eckelmann void batadv_tt_global_entry_release(struct kref *ref);
331d8ab8d3SLinus Lüssing int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
346b5e971aSSven Eckelmann 				const u8 *addr, unsigned short vid);
3556303d34SSven Eckelmann struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
366b5e971aSSven Eckelmann 						  const u8 *src, const u8 *addr,
37c018ad3dSAntonio Quartulli 						  unsigned short vid);
3856303d34SSven Eckelmann void batadv_tt_free(struct batadv_priv *bat_priv);
396b5e971aSSven Eckelmann bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
40c018ad3dSAntonio Quartulli 			 unsigned short vid);
416b5e971aSSven Eckelmann bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
426b5e971aSSven Eckelmann 			   unsigned short vid);
43e1bf0c14SMarek Lindner void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
4456303d34SSven Eckelmann bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
456b5e971aSSven Eckelmann 					u8 *addr, unsigned short vid);
467c1fd91dSAntonio Quartulli bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
476b5e971aSSven Eckelmann 				       u8 *addr, unsigned short vid);
48a19d3d85SMarek Lindner void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface);
4930cfd02bSAntonio Quartulli bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
5030cfd02bSAntonio Quartulli 					  struct batadv_orig_node *orig_node,
51c018ad3dSAntonio Quartulli 					  const unsigned char *addr,
52c018ad3dSAntonio Quartulli 					  unsigned short vid);
5342cb0befSAntonio Quartulli bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
546b5e971aSSven Eckelmann 				  const u8 *addr, unsigned short vid);
55c6c8fea2SSven Eckelmann 
5686452f81SSven Eckelmann int batadv_tt_cache_init(void);
5786452f81SSven Eckelmann void batadv_tt_cache_destroy(void);
5886452f81SSven Eckelmann 
59*6340dcbdSSven Eckelmann /**
60*6340dcbdSSven Eckelmann  * batadv_tt_global_entry_put() - decrement the tt_global_entry refcounter and
61*6340dcbdSSven Eckelmann  *  possibly release it
62*6340dcbdSSven Eckelmann  * @tt_global_entry: tt_global_entry to be free'd
63*6340dcbdSSven Eckelmann  */
64*6340dcbdSSven Eckelmann static inline void
batadv_tt_global_entry_put(struct batadv_tt_global_entry * tt_global_entry)65*6340dcbdSSven Eckelmann batadv_tt_global_entry_put(struct batadv_tt_global_entry *tt_global_entry)
66*6340dcbdSSven Eckelmann {
67*6340dcbdSSven Eckelmann 	if (!tt_global_entry)
68*6340dcbdSSven Eckelmann 		return;
69*6340dcbdSSven Eckelmann 
70*6340dcbdSSven Eckelmann 	kref_put(&tt_global_entry->common.refcount,
71*6340dcbdSSven Eckelmann 		 batadv_tt_global_entry_release);
72*6340dcbdSSven Eckelmann }
73*6340dcbdSSven Eckelmann 
74c6c8fea2SSven Eckelmann #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
75