17db7d9f3SSven Eckelmann /* SPDX-License-Identifier: GPL-2.0 */ 2ac79cbb9SSven Eckelmann /* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: 3c6c8fea2SSven Eckelmann * 4c6c8fea2SSven Eckelmann * Marek Lindner, Simon Wunderlich 5c6c8fea2SSven Eckelmann * 6c6c8fea2SSven Eckelmann * This program is free software; you can redistribute it and/or 7c6c8fea2SSven Eckelmann * modify it under the terms of version 2 of the GNU General Public 8c6c8fea2SSven Eckelmann * License as published by the Free Software Foundation. 9c6c8fea2SSven Eckelmann * 10c6c8fea2SSven Eckelmann * This program is distributed in the hope that it will be useful, but 11c6c8fea2SSven Eckelmann * WITHOUT ANY WARRANTY; without even the implied warranty of 12c6c8fea2SSven Eckelmann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13c6c8fea2SSven Eckelmann * General Public License for more details. 14c6c8fea2SSven Eckelmann * 15c6c8fea2SSven Eckelmann * You should have received a copy of the GNU General Public License 16ebf38fb7SAntonio Quartulli * along with this program; if not, see <http://www.gnu.org/licenses/>. 17c6c8fea2SSven Eckelmann */ 18c6c8fea2SSven Eckelmann 19c6c8fea2SSven Eckelmann #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_ 20c6c8fea2SSven Eckelmann #define _NET_BATMAN_ADV_ORIGINATOR_H_ 21c6c8fea2SSven Eckelmann 221e2c2a4fSSven Eckelmann #include "main.h" 231e2c2a4fSSven Eckelmann 241e2c2a4fSSven Eckelmann #include <linux/compiler.h> 251e2c2a4fSSven Eckelmann #include <linux/if_ether.h> 261e2c2a4fSSven Eckelmann #include <linux/jhash.h> 271e2c2a4fSSven Eckelmann #include <linux/types.h> 281e2c2a4fSSven Eckelmann 2985cf8c85SMatthias Schiffer struct netlink_callback; 301e2c2a4fSSven Eckelmann struct seq_file; 3185cf8c85SMatthias Schiffer struct sk_buff; 321e2c2a4fSSven Eckelmann 334b426b10SSven Eckelmann bool batadv_compare_orig(const struct hlist_node *node, const void *data2); 3456303d34SSven Eckelmann int batadv_originator_init(struct batadv_priv *bat_priv); 3556303d34SSven Eckelmann void batadv_originator_free(struct batadv_priv *bat_priv); 3656303d34SSven Eckelmann void batadv_purge_orig_ref(struct batadv_priv *bat_priv); 375d967310SSven Eckelmann void batadv_orig_node_put(struct batadv_orig_node *orig_node); 38bbad0a5eSAntonio Quartulli struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, 396b5e971aSSven Eckelmann const u8 *addr); 40cef63419SMarek Lindner struct batadv_hardif_neigh_node * 41cef63419SMarek Lindner batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface, 42cef63419SMarek Lindner const u8 *neigh_addr); 43cef63419SMarek Lindner void 44accadc35SSven Eckelmann batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh); 4556303d34SSven Eckelmann struct batadv_neigh_node * 466f0a6b5eSMarek Lindner batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, 473f32f8a6SMarek Lindner struct batadv_hard_iface *hard_iface, 483f32f8a6SMarek Lindner const u8 *neigh_addr); 4925bb2509SSven Eckelmann void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node); 5056303d34SSven Eckelmann struct batadv_neigh_node * 517351a482SSimon Wunderlich batadv_orig_router_get(struct batadv_orig_node *orig_node, 527351a482SSimon Wunderlich const struct batadv_hard_iface *if_outgoing); 5389652331SSimon Wunderlich struct batadv_neigh_ifinfo * 5489652331SSimon Wunderlich batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh, 5589652331SSimon Wunderlich struct batadv_hard_iface *if_outgoing); 5689652331SSimon Wunderlich struct batadv_neigh_ifinfo * 5789652331SSimon Wunderlich batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh, 5889652331SSimon Wunderlich struct batadv_hard_iface *if_outgoing); 59044fa3aeSSven Eckelmann void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo); 607351a482SSimon Wunderlich 6185cf8c85SMatthias Schiffer int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb); 627587405aSMarek Lindner int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset); 637587405aSMarek Lindner 647351a482SSimon Wunderlich struct batadv_orig_ifinfo * 657351a482SSimon Wunderlich batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node, 667351a482SSimon Wunderlich struct batadv_hard_iface *if_outgoing); 677351a482SSimon Wunderlich struct batadv_orig_ifinfo * 687351a482SSimon Wunderlich batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, 697351a482SSimon Wunderlich struct batadv_hard_iface *if_outgoing); 7035f94779SSven Eckelmann void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo); 717351a482SSimon Wunderlich 727d211efcSSven Eckelmann int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); 7385cf8c85SMatthias Schiffer int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb); 74cb1c92ecSSimon Wunderlich int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); 7556303d34SSven Eckelmann int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, 7656303d34SSven Eckelmann int max_if_num); 7756303d34SSven Eckelmann int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, 7856303d34SSven Eckelmann int max_if_num); 797ea7b4a1SAntonio Quartulli struct batadv_orig_node_vlan * 807ea7b4a1SAntonio Quartulli batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, 817ea7b4a1SAntonio Quartulli unsigned short vid); 827ea7b4a1SAntonio Quartulli struct batadv_orig_node_vlan * 837ea7b4a1SAntonio Quartulli batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, 847ea7b4a1SAntonio Quartulli unsigned short vid); 8521754e25SSven Eckelmann void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan); 86c6c8fea2SSven Eckelmann 87*e57acf8eSSven Eckelmann /** 88*e57acf8eSSven Eckelmann * batadv_choose_orig() - Return the index of the orig entry in the hash table 89*e57acf8eSSven Eckelmann * @data: mac address of the originator node 90*e57acf8eSSven Eckelmann * @size: the size of the hash table 91*e57acf8eSSven Eckelmann * 92*e57acf8eSSven Eckelmann * Return: the hash index where the object represented by @data should be 93*e57acf8eSSven Eckelmann * stored at. 949cfc7bd6SSven Eckelmann */ 956b5e971aSSven Eckelmann static inline u32 batadv_choose_orig(const void *data, u32 size) 96c6c8fea2SSven Eckelmann { 976b5e971aSSven Eckelmann u32 hash = 0; 98c6c8fea2SSven Eckelmann 9936fd61cbSSven Eckelmann hash = jhash(data, ETH_ALEN, hash); 100c6c8fea2SSven Eckelmann return hash % size; 101c6c8fea2SSven Eckelmann } 102c6c8fea2SSven Eckelmann 1033326afe6SDenys Vlasenko struct batadv_orig_node * 1043326afe6SDenys Vlasenko batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data); 1057aadf889SMarek Lindner 106c6c8fea2SSven Eckelmann #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */ 107