^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Marek Lindner, Simon Wunderlich, Antonio Quartulli
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "main.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) int batadv_tt_init(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) unsigned short vid, int ifindex, u32 mark);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) const u8 *addr, unsigned short vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) const char *message, bool roaming);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) s32 match_vid, const char *message);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct batadv_tt_global_entry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void batadv_tt_global_entry_release(struct kref *ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) const u8 *addr, unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) const u8 *src, const u8 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void batadv_tt_free(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u8 *addr, unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) u8 *addr, unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct batadv_orig_node *orig_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) const unsigned char *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) const u8 *addr, unsigned short vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int batadv_tt_cache_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void batadv_tt_cache_destroy(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * batadv_tt_global_entry_put() - decrement the tt_global_entry refcounter and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * possibly release it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @tt_global_entry: tt_global_entry to be free'd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) batadv_tt_global_entry_put(struct batadv_tt_global_entry *tt_global_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (!tt_global_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) kref_put(&tt_global_entry->common.refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) batadv_tt_global_entry_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */