bridge_loop_avoidance.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* Copyright (C) 2011-2017 B.A.T.M.A.N. contributors:
  2. *
  3. * Simon Wunderlich
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2 of the GNU General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _NET_BATMAN_ADV_BLA_H_
  18. #define _NET_BATMAN_ADV_BLA_H_
  19. #include "main.h"
  20. #include <linux/compiler.h>
  21. #include <linux/stddef.h>
  22. #include <linux/types.h>
  23. struct net_device;
  24. struct netlink_callback;
  25. struct seq_file;
  26. struct sk_buff;
  27. /**
  28. * batadv_bla_is_loopdetect_mac - check if the mac address is from a loop detect
  29. * frame sent by bridge loop avoidance
  30. * @mac: mac address to check
  31. *
  32. * Return: true if the it looks like a loop detect frame
  33. * (mac starts with BA:BE), false otherwise
  34. */
  35. static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
  36. {
  37. if (mac[0] == 0xba && mac[1] == 0xbe)
  38. return true;
  39. return false;
  40. }
  41. #ifdef CONFIG_BATMAN_ADV_BLA
  42. bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  43. unsigned short vid, bool is_bcast);
  44. bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  45. unsigned short vid);
  46. bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  47. struct batadv_orig_node *orig_node,
  48. int hdr_size);
  49. int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
  50. int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
  51. int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
  52. void *offset);
  53. int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
  54. bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
  55. unsigned short vid);
  56. bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  57. struct sk_buff *skb);
  58. void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  59. struct batadv_hard_iface *primary_if,
  60. struct batadv_hard_iface *oldif);
  61. void batadv_bla_status_update(struct net_device *net_dev);
  62. int batadv_bla_init(struct batadv_priv *bat_priv);
  63. void batadv_bla_free(struct batadv_priv *bat_priv);
  64. int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
  65. #ifdef CONFIG_BATMAN_ADV_DAT
  66. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  67. unsigned short vid);
  68. #endif
  69. #define BATADV_BLA_CRC_INIT 0
  70. #else /* ifdef CONFIG_BATMAN_ADV_BLA */
  71. static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
  72. struct sk_buff *skb, unsigned short vid,
  73. bool is_bcast)
  74. {
  75. return false;
  76. }
  77. static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
  78. struct sk_buff *skb, unsigned short vid)
  79. {
  80. return false;
  81. }
  82. static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  83. struct batadv_orig_node *orig_node,
  84. int hdr_size)
  85. {
  86. return false;
  87. }
  88. static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
  89. void *offset)
  90. {
  91. return 0;
  92. }
  93. static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
  94. void *offset)
  95. {
  96. return 0;
  97. }
  98. static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
  99. u8 *orig, unsigned short vid)
  100. {
  101. return false;
  102. }
  103. static inline bool
  104. batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  105. struct sk_buff *skb)
  106. {
  107. return false;
  108. }
  109. static inline void
  110. batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  111. struct batadv_hard_iface *primary_if,
  112. struct batadv_hard_iface *oldif)
  113. {
  114. }
  115. static inline int batadv_bla_init(struct batadv_priv *bat_priv)
  116. {
  117. return 1;
  118. }
  119. static inline void batadv_bla_free(struct batadv_priv *bat_priv)
  120. {
  121. }
  122. static inline int batadv_bla_claim_dump(struct sk_buff *msg,
  123. struct netlink_callback *cb)
  124. {
  125. return -EOPNOTSUPP;
  126. }
  127. static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
  128. struct netlink_callback *cb)
  129. {
  130. return -EOPNOTSUPP;
  131. }
  132. static inline
  133. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  134. unsigned short vid)
  135. {
  136. return true;
  137. }
  138. #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
  139. #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */