distributed-arp-table.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* Copyright (C) 2011-2013 B.A.T.M.A.N. contributors:
  2. *
  3. * Antonio Quartulli
  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, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA
  18. */
  19. #ifndef _NET_BATMAN_ADV_ARP_H_
  20. #define _NET_BATMAN_ADV_ARP_H_
  21. #ifdef CONFIG_BATMAN_ADV_DAT
  22. #include "types.h"
  23. #include "originator.h"
  24. #include <linux/if_arp.h>
  25. #define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)
  26. void batadv_dat_status_update(struct net_device *net_dev);
  27. bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
  28. struct sk_buff *skb);
  29. bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
  30. struct sk_buff *skb, int hdr_size);
  31. void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
  32. struct sk_buff *skb);
  33. bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
  34. struct sk_buff *skb, int hdr_size);
  35. bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
  36. struct batadv_forw_packet *forw_packet);
  37. /**
  38. * batadv_dat_init_orig_node_addr - assign a DAT address to the orig_node
  39. * @orig_node: the node to assign the DAT address to
  40. */
  41. static inline void
  42. batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
  43. {
  44. uint32_t addr;
  45. addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
  46. orig_node->dat_addr = (batadv_dat_addr_t)addr;
  47. }
  48. /**
  49. * batadv_dat_init_own_addr - assign a DAT address to the node itself
  50. * @bat_priv: the bat priv with all the soft interface information
  51. * @primary_if: a pointer to the primary interface
  52. */
  53. static inline void
  54. batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
  55. struct batadv_hard_iface *primary_if)
  56. {
  57. uint32_t addr;
  58. addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
  59. BATADV_DAT_ADDR_MAX);
  60. bat_priv->dat.addr = (batadv_dat_addr_t)addr;
  61. }
  62. int batadv_dat_init(struct batadv_priv *bat_priv);
  63. void batadv_dat_free(struct batadv_priv *bat_priv);
  64. int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset);
  65. /**
  66. * batadv_dat_inc_counter - increment the correct DAT packet counter
  67. * @bat_priv: the bat priv with all the soft interface information
  68. * @subtype: the 4addr subtype of the packet to be counted
  69. *
  70. * Updates the ethtool statistics for the received packet if it is a DAT subtype
  71. */
  72. static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
  73. uint8_t subtype)
  74. {
  75. switch (subtype) {
  76. case BATADV_P_DAT_DHT_GET:
  77. batadv_inc_counter(bat_priv,
  78. BATADV_CNT_DAT_GET_RX);
  79. break;
  80. case BATADV_P_DAT_DHT_PUT:
  81. batadv_inc_counter(bat_priv,
  82. BATADV_CNT_DAT_PUT_RX);
  83. break;
  84. }
  85. }
  86. #else
  87. static inline void batadv_dat_status_update(struct net_device *net_dev)
  88. {
  89. }
  90. static inline bool
  91. batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
  92. struct sk_buff *skb)
  93. {
  94. return false;
  95. }
  96. static inline bool
  97. batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
  98. struct sk_buff *skb, int hdr_size)
  99. {
  100. return false;
  101. }
  102. static inline bool
  103. batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
  104. struct sk_buff *skb)
  105. {
  106. return false;
  107. }
  108. static inline bool
  109. batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
  110. struct sk_buff *skb, int hdr_size)
  111. {
  112. return false;
  113. }
  114. static inline bool
  115. batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
  116. struct batadv_forw_packet *forw_packet)
  117. {
  118. return false;
  119. }
  120. static inline void
  121. batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
  122. {
  123. }
  124. static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
  125. struct batadv_hard_iface *iface)
  126. {
  127. }
  128. static inline void batadv_arp_change_timeout(struct net_device *soft_iface,
  129. const char *name)
  130. {
  131. }
  132. static inline int batadv_dat_init(struct batadv_priv *bat_priv)
  133. {
  134. return 0;
  135. }
  136. static inline void batadv_dat_free(struct batadv_priv *bat_priv)
  137. {
  138. }
  139. static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
  140. uint8_t subtype)
  141. {
  142. }
  143. #endif /* CONFIG_BATMAN_ADV_DAT */
  144. #endif /* _NET_BATMAN_ADV_ARP_H_ */