bridge_loop_avoidance.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2011-2018 B.A.T.M.A.N. contributors:
  3. *
  4. * 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_BLA_H_
  19. #define _NET_BATMAN_ADV_BLA_H_
  20. #include "main.h"
  21. #include <linux/compiler.h>
  22. #include <linux/stddef.h>
  23. #include <linux/types.h>
  24. struct net_device;
  25. struct netlink_callback;
  26. struct seq_file;
  27. struct sk_buff;
  28. /**
  29. * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
  30. * detect frame sent by bridge loop avoidance
  31. * @mac: mac address to check
  32. *
  33. * Return: true if the it looks like a loop detect frame
  34. * (mac starts with BA:BE), false otherwise
  35. */
  36. static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
  37. {
  38. if (mac[0] == 0xba && mac[1] == 0xbe)
  39. return true;
  40. return false;
  41. }
  42. #ifdef CONFIG_BATMAN_ADV_BLA
  43. bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  44. unsigned short vid, bool is_bcast);
  45. bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  46. unsigned short vid);
  47. bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  48. struct batadv_orig_node *orig_node,
  49. int hdr_size);
  50. int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
  51. int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
  52. int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
  53. void *offset);
  54. int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
  55. bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
  56. unsigned short vid);
  57. bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  58. struct sk_buff *skb);
  59. void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  60. struct batadv_hard_iface *primary_if,
  61. struct batadv_hard_iface *oldif);
  62. void batadv_bla_status_update(struct net_device *net_dev);
  63. int batadv_bla_init(struct batadv_priv *bat_priv);
  64. void batadv_bla_free(struct batadv_priv *bat_priv);
  65. int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
  66. #ifdef CONFIG_BATMAN_ADV_DAT
  67. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  68. unsigned short vid);
  69. #endif
  70. #define BATADV_BLA_CRC_INIT 0
  71. #else /* ifdef CONFIG_BATMAN_ADV_BLA */
  72. static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
  73. struct sk_buff *skb, unsigned short vid,
  74. bool is_bcast)
  75. {
  76. return false;
  77. }
  78. static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
  79. struct sk_buff *skb, unsigned short vid)
  80. {
  81. return false;
  82. }
  83. static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  84. struct batadv_orig_node *orig_node,
  85. int hdr_size)
  86. {
  87. return false;
  88. }
  89. static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
  90. void *offset)
  91. {
  92. return 0;
  93. }
  94. static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
  95. void *offset)
  96. {
  97. return 0;
  98. }
  99. static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
  100. u8 *orig, unsigned short vid)
  101. {
  102. return false;
  103. }
  104. static inline bool
  105. batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  106. struct sk_buff *skb)
  107. {
  108. return false;
  109. }
  110. static inline void
  111. batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  112. struct batadv_hard_iface *primary_if,
  113. struct batadv_hard_iface *oldif)
  114. {
  115. }
  116. static inline int batadv_bla_init(struct batadv_priv *bat_priv)
  117. {
  118. return 1;
  119. }
  120. static inline void batadv_bla_free(struct batadv_priv *bat_priv)
  121. {
  122. }
  123. static inline int batadv_bla_claim_dump(struct sk_buff *msg,
  124. struct netlink_callback *cb)
  125. {
  126. return -EOPNOTSUPP;
  127. }
  128. static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
  129. struct netlink_callback *cb)
  130. {
  131. return -EOPNOTSUPP;
  132. }
  133. static inline
  134. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  135. unsigned short vid)
  136. {
  137. return true;
  138. }
  139. #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
  140. #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */