bridge_loop_avoidance.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) B.A.T.M.A.N. contributors:
  3. *
  4. * Simon Wunderlich
  5. */
  6. #ifndef _NET_BATMAN_ADV_BLA_H_
  7. #define _NET_BATMAN_ADV_BLA_H_
  8. #include "main.h"
  9. #include <linux/compiler.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/netlink.h>
  12. #include <linux/skbuff.h>
  13. #include <linux/stddef.h>
  14. #include <linux/types.h>
  15. /**
  16. * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
  17. * detect frame sent by bridge loop avoidance
  18. * @mac: mac address to check
  19. *
  20. * Return: true if the it looks like a loop detect frame
  21. * (mac starts with BA:BE), false otherwise
  22. */
  23. static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
  24. {
  25. if (mac[0] == 0xba && mac[1] == 0xbe)
  26. return true;
  27. return false;
  28. }
  29. #ifdef CONFIG_BATMAN_ADV_BLA
  30. bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  31. unsigned short vid, int packet_type);
  32. bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
  33. unsigned short vid);
  34. bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  35. struct batadv_orig_node *orig_node,
  36. int hdr_size);
  37. int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
  38. int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
  39. bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
  40. unsigned short vid);
  41. bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  42. struct sk_buff *skb);
  43. void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  44. struct batadv_hard_iface *primary_if,
  45. struct batadv_hard_iface *oldif);
  46. void batadv_bla_status_update(struct net_device *net_dev);
  47. int batadv_bla_init(struct batadv_priv *bat_priv);
  48. void batadv_bla_free(struct batadv_priv *bat_priv);
  49. #ifdef CONFIG_BATMAN_ADV_DAT
  50. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  51. unsigned short vid);
  52. #endif
  53. #define BATADV_BLA_CRC_INIT 0
  54. #else /* ifdef CONFIG_BATMAN_ADV_BLA */
  55. static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
  56. struct sk_buff *skb, unsigned short vid,
  57. int packet_type)
  58. {
  59. return false;
  60. }
  61. static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
  62. struct sk_buff *skb, unsigned short vid)
  63. {
  64. return false;
  65. }
  66. static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
  67. struct batadv_orig_node *orig_node,
  68. int hdr_size)
  69. {
  70. return false;
  71. }
  72. static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
  73. u8 *orig, unsigned short vid)
  74. {
  75. return false;
  76. }
  77. static inline bool
  78. batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
  79. struct sk_buff *skb)
  80. {
  81. return false;
  82. }
  83. static inline void
  84. batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
  85. struct batadv_hard_iface *primary_if,
  86. struct batadv_hard_iface *oldif)
  87. {
  88. }
  89. static inline int batadv_bla_init(struct batadv_priv *bat_priv)
  90. {
  91. return 1;
  92. }
  93. static inline void batadv_bla_free(struct batadv_priv *bat_priv)
  94. {
  95. }
  96. static inline int batadv_bla_claim_dump(struct sk_buff *msg,
  97. struct netlink_callback *cb)
  98. {
  99. return -EOPNOTSUPP;
  100. }
  101. static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
  102. struct netlink_callback *cb)
  103. {
  104. return -EOPNOTSUPP;
  105. }
  106. static inline
  107. bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
  108. unsigned short vid)
  109. {
  110. return true;
  111. }
  112. #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
  113. #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */