Merge branch 'i2c-mux/for-next' of https://github.com/peda-r/i2c-mux into i2c/for...
[linux-2.6-block.git] / net / batman-adv / originator.h
CommitLineData
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 29struct netlink_callback;
1e2c2a4f 30struct seq_file;
85cf8c85 31struct sk_buff;
1e2c2a4f 32
4b426b10 33bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
56303d34
SE
34int batadv_originator_init(struct batadv_priv *bat_priv);
35void batadv_originator_free(struct batadv_priv *bat_priv);
36void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
5d967310 37void batadv_orig_node_put(struct batadv_orig_node *orig_node);
bbad0a5e 38struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
6b5e971a 39 const u8 *addr);
cef63419
ML
40struct batadv_hardif_neigh_node *
41batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
42 const u8 *neigh_addr);
43void
accadc35 44batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh);
56303d34 45struct batadv_neigh_node *
6f0a6b5e
ML
46batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
47 struct batadv_hard_iface *hard_iface,
48 const u8 *neigh_addr);
25bb2509 49void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node);
56303d34 50struct batadv_neigh_node *
7351a482
SW
51batadv_orig_router_get(struct batadv_orig_node *orig_node,
52 const struct batadv_hard_iface *if_outgoing);
89652331
SW
53struct batadv_neigh_ifinfo *
54batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
55 struct batadv_hard_iface *if_outgoing);
56struct batadv_neigh_ifinfo *
57batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
58 struct batadv_hard_iface *if_outgoing);
044fa3ae 59void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo);
7351a482 60
85cf8c85 61int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
7587405a
ML
62int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset);
63
7351a482
SW
64struct batadv_orig_ifinfo *
65batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
66 struct batadv_hard_iface *if_outgoing);
67struct batadv_orig_ifinfo *
68batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
69 struct batadv_hard_iface *if_outgoing);
35f94779 70void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo);
7351a482 71
7d211efc 72int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
85cf8c85 73int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
cb1c92ec 74int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
56303d34 75int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
f22e0893 76 unsigned int max_if_num);
56303d34 77int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
f22e0893 78 unsigned int max_if_num);
7ea7b4a1
AQ
79struct batadv_orig_node_vlan *
80batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
81 unsigned short vid);
82struct batadv_orig_node_vlan *
83batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
84 unsigned short vid);
21754e25 85void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
c6c8fea2 86
e57acf8e
SE
87/**
88 * batadv_choose_orig() - Return the index of the orig entry in the hash table
89 * @data: mac address of the originator node
90 * @size: the size of the hash table
91 *
92 * Return: the hash index where the object represented by @data should be
93 * stored at.
9cfc7bd6 94 */
6b5e971a 95static inline u32 batadv_choose_orig(const void *data, u32 size)
c6c8fea2 96{
6b5e971a 97 u32 hash = 0;
c6c8fea2 98
36fd61cb 99 hash = jhash(data, ETH_ALEN, hash);
c6c8fea2
SE
100 return hash % size;
101}
102
3326afe6
DV
103struct batadv_orig_node *
104batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
7aadf889 105
c6c8fea2 106#endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */