originator.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2007-2018 B.A.T.M.A.N. contributors:
  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
  16. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef _NET_BATMAN_ADV_ORIGINATOR_H_
  19. #define _NET_BATMAN_ADV_ORIGINATOR_H_
  20. #include "main.h"
  21. #include <linux/compiler.h>
  22. #include <linux/if_ether.h>
  23. #include <linux/jhash.h>
  24. #include <linux/types.h>
  25. struct netlink_callback;
  26. struct seq_file;
  27. struct sk_buff;
  28. bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
  29. int batadv_originator_init(struct batadv_priv *bat_priv);
  30. void batadv_originator_free(struct batadv_priv *bat_priv);
  31. void batadv_purge_orig_ref(struct batadv_priv *bat_priv);
  32. void batadv_orig_node_put(struct batadv_orig_node *orig_node);
  33. struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
  34. const u8 *addr);
  35. struct batadv_hardif_neigh_node *
  36. batadv_hardif_neigh_get(const struct batadv_hard_iface *hard_iface,
  37. const u8 *neigh_addr);
  38. void
  39. batadv_hardif_neigh_put(struct batadv_hardif_neigh_node *hardif_neigh);
  40. struct batadv_neigh_node *
  41. batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node,
  42. struct batadv_hard_iface *hard_iface,
  43. const u8 *neigh_addr);
  44. void batadv_neigh_node_put(struct batadv_neigh_node *neigh_node);
  45. struct batadv_neigh_node *
  46. batadv_orig_router_get(struct batadv_orig_node *orig_node,
  47. const struct batadv_hard_iface *if_outgoing);
  48. struct batadv_neigh_ifinfo *
  49. batadv_neigh_ifinfo_new(struct batadv_neigh_node *neigh,
  50. struct batadv_hard_iface *if_outgoing);
  51. struct batadv_neigh_ifinfo *
  52. batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh,
  53. struct batadv_hard_iface *if_outgoing);
  54. void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo);
  55. int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb);
  56. int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset);
  57. struct batadv_orig_ifinfo *
  58. batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node,
  59. struct batadv_hard_iface *if_outgoing);
  60. struct batadv_orig_ifinfo *
  61. batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
  62. struct batadv_hard_iface *if_outgoing);
  63. void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo);
  64. int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
  65. int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb);
  66. int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
  67. int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
  68. unsigned int max_if_num);
  69. int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
  70. unsigned int max_if_num);
  71. struct batadv_orig_node_vlan *
  72. batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
  73. unsigned short vid);
  74. struct batadv_orig_node_vlan *
  75. batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
  76. unsigned short vid);
  77. void batadv_orig_node_vlan_put(struct batadv_orig_node_vlan *orig_vlan);
  78. /**
  79. * batadv_choose_orig() - Return the index of the orig entry in the hash table
  80. * @data: mac address of the originator node
  81. * @size: the size of the hash table
  82. *
  83. * Return: the hash index where the object represented by @data should be
  84. * stored at.
  85. */
  86. static inline u32 batadv_choose_orig(const void *data, u32 size)
  87. {
  88. u32 hash = 0;
  89. hash = jhash(data, ETH_ALEN, hash);
  90. return hash % size;
  91. }
  92. struct batadv_orig_node *
  93. batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
  94. #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */