]>
Commit | Line | Data |
---|---|---|
7db7d9f3 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
6b1aea8c | 2 | /* Copyright (C) 2007-2018 B.A.T.M.A.N. contributors: |
c6c8fea2 SE |
3 | * |
4 | * Marek Lindner, Simon Wunderlich | |
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 | |
ebf38fb7 | 16 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
c6c8fea2 SE |
17 | */ |
18 | ||
19 | #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_ | |
20 | #define _NET_BATMAN_ADV_ORIGINATOR_H_ | |
21 | ||
1e2c2a4f SE |
22 | #include "main.h" |
23 | ||
1e2c2a4f SE |
24 | #include <linux/compiler.h> |
25 | #include <linux/if_ether.h> | |
26 | #include <linux/jhash.h> | |
1e2c2a4f SE |
27 | #include <linux/types.h> |
28 | ||
85cf8c85 | 29 | struct netlink_callback; |
1e2c2a4f | 30 | struct seq_file; |
85cf8c85 | 31 | struct sk_buff; |
1e2c2a4f | 32 | |
4b426b10 | 33 | bool batadv_compare_orig(const struct hlist_node *node, const void *data2); |
56303d34 SE |
34 | int batadv_originator_init(struct batadv_priv *bat_priv); |
35 | void batadv_originator_free(struct batadv_priv *bat_priv); | |
36 | void batadv_purge_orig_ref(struct batadv_priv *bat_priv); | |
5d967310 | 37 | void batadv_orig_node_put(struct batadv_orig_node *orig_node); |
bbad0a5e | 38 | struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, |
6b5e971a | 39 | const u8 *addr); |
cef63419 ML |
40 | struct batadv_hardif_neigh_node * |
41 | batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface, | |
42 | const u8 *neigh_addr); | |
43 | void | |
accadc35 | 44 | batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh); |
56303d34 | 45 | struct batadv_neigh_node * |
6f0a6b5e ML |
46 | batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, |
47 | struct batadv_hard_iface *hard_iface, | |
48 | const u8 *neigh_addr); | |
25bb2509 | 49 | void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node); |
56303d34 | 50 | struct batadv_neigh_node * |
7351a482 SW |
51 | batadv_orig_router_get(struct batadv_orig_node *orig_node, |
52 | const struct batadv_hard_iface *if_outgoing); | |
89652331 SW |
53 | struct batadv_neigh_ifinfo * |
54 | batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh, | |
55 | struct batadv_hard_iface *if_outgoing); | |
56 | struct batadv_neigh_ifinfo * | |
57 | batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh, | |
58 | struct batadv_hard_iface *if_outgoing); | |
044fa3ae | 59 | void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo); |
7351a482 | 60 | |
85cf8c85 | 61 | int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb); |
7587405a ML |
62 | int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset); |
63 | ||
7351a482 SW |
64 | struct batadv_orig_ifinfo * |
65 | batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node, | |
66 | struct batadv_hard_iface *if_outgoing); | |
67 | struct batadv_orig_ifinfo * | |
68 | batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, | |
69 | struct batadv_hard_iface *if_outgoing); | |
35f94779 | 70 | void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo); |
7351a482 | 71 | |
7d211efc | 72 | int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); |
85cf8c85 | 73 | int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb); |
cb1c92ec | 74 | int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); |
7ea7b4a1 AQ |
75 | struct batadv_orig_node_vlan * |
76 | batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, | |
77 | unsigned short vid); | |
78 | struct batadv_orig_node_vlan * | |
79 | batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, | |
80 | unsigned short vid); | |
21754e25 | 81 | void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan); |
c6c8fea2 | 82 | |
e57acf8e SE |
83 | /** |
84 | * batadv_choose_orig() - Return the index of the orig entry in the hash table | |
85 | * @data: mac address of the originator node | |
86 | * @size: the size of the hash table | |
87 | * | |
88 | * Return: the hash index where the object represented by @data should be | |
89 | * stored at. | |
9cfc7bd6 | 90 | */ |
6b5e971a | 91 | static inline u32 batadv_choose_orig(const void *data, u32 size) |
c6c8fea2 | 92 | { |
6b5e971a | 93 | u32 hash = 0; |
c6c8fea2 | 94 | |
36fd61cb | 95 | hash = jhash(data, ETH_ALEN, hash); |
c6c8fea2 SE |
96 | return hash % size; |
97 | } | |
98 | ||
3326afe6 DV |
99 | struct batadv_orig_node * |
100 | batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data); | |
7aadf889 | 101 | |
c6c8fea2 | 102 | #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */ |