blob: 63cc8fd3ff66aea16fcecf9f2adbff03dc4ef63d [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
Olivier Deprez157378f2022-04-04 15:47:50 +02002/* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00003 *
4 * Marek Lindner, Simon Wunderlich, Antonio Quartulli
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00005 */
6
7#ifndef _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
8#define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_
9
10#include "main.h"
11
Olivier Deprez92d4c212022-12-06 15:05:30 +010012#include <linux/kref.h>
David Brazdil0f672f62019-12-10 10:32:29 +000013#include <linux/netdevice.h>
14#include <linux/netlink.h>
15#include <linux/seq_file.h>
16#include <linux/skbuff.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000017#include <linux/types.h>
18
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000019int batadv_tt_init(struct batadv_priv *bat_priv);
20bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
21 unsigned short vid, int ifindex, u32 mark);
22u16 batadv_tt_local_remove(struct batadv_priv *bat_priv,
23 const u8 *addr, unsigned short vid,
24 const char *message, bool roaming);
25int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset);
26int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset);
27int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb);
28int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb);
29void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
30 struct batadv_orig_node *orig_node,
31 s32 match_vid, const char *message);
David Brazdil0f672f62019-12-10 10:32:29 +000032struct batadv_tt_global_entry *
33batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
34 unsigned short vid);
Olivier Deprez92d4c212022-12-06 15:05:30 +010035void batadv_tt_global_entry_release(struct kref *ref);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000036int batadv_tt_global_hash_count(struct batadv_priv *bat_priv,
37 const u8 *addr, unsigned short vid);
38struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
39 const u8 *src, const u8 *addr,
40 unsigned short vid);
41void batadv_tt_free(struct batadv_priv *bat_priv);
42bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
43 unsigned short vid);
44bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
45 unsigned short vid);
46void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
47bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
48 u8 *addr, unsigned short vid);
49bool batadv_tt_local_client_is_roaming(struct batadv_priv *bat_priv,
50 u8 *addr, unsigned short vid);
51void batadv_tt_local_resize_to_mtu(struct net_device *soft_iface);
52bool 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);
56bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
57 const u8 *addr, unsigned short vid);
58
59int batadv_tt_cache_init(void);
60void batadv_tt_cache_destroy(void);
61
Olivier Deprez92d4c212022-12-06 15:05:30 +010062/**
63 * batadv_tt_global_entry_put() - decrement the tt_global_entry refcounter and
64 * possibly release it
65 * @tt_global_entry: tt_global_entry to be free'd
66 */
67static inline void
68batadv_tt_global_entry_put(struct batadv_tt_global_entry *tt_global_entry)
69{
70 if (!tt_global_entry)
71 return;
72
73 kref_put(&tt_global_entry->common.refcount,
74 batadv_tt_global_entry_release);
75}
76
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000077#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */