blob: 512a1f99dd75147c7d179d8494bc60748b1f6762 [file] [log] [blame]
Sven Eckelmann7db7d9f2017-11-19 15:05:11 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sven Eckelmann7a79d712018-12-31 23:59:59 +01002/* Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00003 *
4 * Marek Lindner, Simon Wunderlich
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00005 */
6
7#ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
8#define _NET_BATMAN_ADV_ORIGINATOR_H_
9
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020010#include "main.h"
11
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020012#include <linux/compiler.h>
13#include <linux/if_ether.h>
14#include <linux/jhash.h>
Sven Eckelmann68a600d2019-05-24 20:11:17 +020015#include <linux/netlink.h>
16#include <linux/seq_file.h>
17#include <linux/skbuff.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020018#include <linux/types.h>
19
Sven Eckelmann4b426b12016-02-22 21:02:39 +010020bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
Sven Eckelmann56303d32012-06-05 22:31:31 +020021int batadv_originator_init(struct batadv_priv *bat_priv);
22void batadv_originator_free(struct batadv_priv *bat_priv);
23void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
Sven Eckelmann5d967312016-01-17 11:01:09 +010024void batadv_orig_node_put(struct batadv_orig_node *orig_node);
Antonio Quartullibbad0a52013-09-02 12:15:02 +020025struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020026 const u8 *addr);
Marek Lindnercef63412015-08-04 21:09:55 +080027struct batadv_hardif_neigh_node *
28batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
29 const u8 *neigh_addr);
30void
Sven Eckelmannaccadc32016-01-17 11:01:14 +010031batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh);
Sven Eckelmann56303d32012-06-05 22:31:31 +020032struct batadv_neigh_node *
Marek Lindner6f0a6b52016-05-03 01:52:08 +080033batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
34 struct batadv_hard_iface *hard_iface,
35 const u8 *neigh_addr);
Sven Eckelmann25bb2502016-01-17 11:01:11 +010036void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node);
Sven Eckelmann56303d32012-06-05 22:31:31 +020037struct batadv_neigh_node *
Simon Wunderlich7351a4822013-11-13 19:14:47 +010038batadv_orig_router_get(struct batadv_orig_node *orig_node,
39 const struct batadv_hard_iface *if_outgoing);
Simon Wunderlich89652332013-11-13 19:14:46 +010040struct batadv_neigh_ifinfo *
41batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
42 struct batadv_hard_iface *if_outgoing);
43struct batadv_neigh_ifinfo *
44batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
45 struct batadv_hard_iface *if_outgoing);
Sven Eckelmann044fa3a2016-01-17 11:01:12 +010046void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo);
Simon Wunderlich7351a4822013-11-13 19:14:47 +010047
Matthias Schiffer85cf8c82016-07-03 13:31:39 +020048int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
Marek Lindner75874052015-08-04 21:09:57 +080049int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset);
50
Simon Wunderlich7351a4822013-11-13 19:14:47 +010051struct batadv_orig_ifinfo *
52batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
53 struct batadv_hard_iface *if_outgoing);
54struct batadv_orig_ifinfo *
55batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
56 struct batadv_hard_iface *if_outgoing);
Sven Eckelmann35f94772016-01-17 11:01:13 +010057void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo);
Simon Wunderlich7351a4822013-11-13 19:14:47 +010058
Sven Eckelmann7d211ef2012-05-12 02:09:34 +020059int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
Matthias Schiffer85cf8c82016-07-03 13:31:39 +020060int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
Simon Wunderlichcb1c92e2013-11-21 11:52:16 +010061int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
Antonio Quartulli7ea7b4a2013-07-30 22:16:25 +020062struct batadv_orig_node_vlan *
63batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
64 unsigned short vid);
65struct batadv_orig_node_vlan *
66batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
67 unsigned short vid);
Sven Eckelmann21754e22016-01-17 11:01:24 +010068void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000069
Sven Eckelmanne57acf82017-12-02 19:51:52 +010070/**
71 * batadv_choose_orig() - Return the index of the orig entry in the hash table
72 * @data: mac address of the originator node
73 * @size: the size of the hash table
74 *
75 * Return: the hash index where the object represented by @data should be
76 * stored at.
Sven Eckelmann9cfc7bd2012-05-12 02:09:43 +020077 */
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020078static inline u32 batadv_choose_orig(const void *data, u32 size)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000079{
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020080 u32 hash = 0;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000081
Sven Eckelmann36fd61c2015-03-01 09:46:18 +010082 hash = jhash(data, ETH_ALEN, hash);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000083 return hash % size;
84}
85
Denys Vlasenko3326afe2017-11-19 17:59:13 +010086struct batadv_orig_node *
87batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
Marek Lindner7aadf882011-02-18 12:28:09 +000088
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000089#endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */