Blame view

net/batman-adv/distributed-arp-table.h 4.95 KB
7db7d9f36   Sven Eckelmann   batman-adv: Add S...
1
  /* SPDX-License-Identifier: GPL-2.0 */
6b1aea8cf   Sven Eckelmann   batman-adv: Updat...
2
  /* Copyright (C) 2011-2018  B.A.T.M.A.N. contributors:
785ea1144   Antonio Quartulli   batman-adv: Distr...
3
4
5
6
7
8
9
10
11
12
13
14
15
   *
   * Antonio Quartulli
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of version 2 of the GNU General Public
   * License as published by the Free Software Foundation.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
ebf38fb7a   Antonio Quartulli   batman-adv: remov...
16
   * along with this program; if not, see <http://www.gnu.org/licenses/>.
785ea1144   Antonio Quartulli   batman-adv: Distr...
17
   */
a48bcacdb   Antonio Quartulli   batman-adv: prope...
18
19
  #ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
  #define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
785ea1144   Antonio Quartulli   batman-adv: Distr...
20

1e2c2a4fe   Sven Eckelmann   batman-adv: Add r...
21
22
23
24
25
  #include "main.h"
  
  #include <linux/compiler.h>
  #include <linux/netdevice.h>
  #include <linux/types.h>
fec149f5d   Sven Eckelmann   batman-adv: Conve...
26
  #include <uapi/linux/batadv_packet.h>
172244748   Antonio Quartulli   batman-adv: Distr...
27

785ea1144   Antonio Quartulli   batman-adv: Distr...
28
  #include "originator.h"
41aeefcc3   Linus Lüssing   batman-adv: add D...
29
  struct netlink_callback;
1e2c2a4fe   Sven Eckelmann   batman-adv: Add r...
30
31
32
33
  struct seq_file;
  struct sk_buff;
  
  #ifdef CONFIG_BATMAN_ADV_DAT
5c3a0e553   Antonio Quartulli   batman-adv: Distr...
34

ba97abb86   Martin Hundebøll   batman-adv: kerne...
35
  /* BATADV_DAT_ADDR_MAX - maximum address value in the DHT space */
785ea1144   Antonio Quartulli   batman-adv: Distr...
36
  #define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)
17cf0ea45   Marek Lindner   batman-adv: tvlv ...
37
  void batadv_dat_status_update(struct net_device *net_dev);
c384ea3ec   Antonio Quartulli   batman-adv: Distr...
38
39
40
41
42
43
44
45
46
47
  bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
  					   struct sk_buff *skb);
  bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
  					   struct sk_buff *skb, int hdr_size);
  void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
  					 struct sk_buff *skb);
  bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
  					 struct sk_buff *skb, int hdr_size);
  bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
  				      struct batadv_forw_packet *forw_packet);
785ea1144   Antonio Quartulli   batman-adv: Distr...
48
  /**
7e9a8c2ce   Sven Eckelmann   batman-adv: Use p...
49
   * batadv_dat_init_orig_node_addr() - assign a DAT address to the orig_node
785ea1144   Antonio Quartulli   batman-adv: Distr...
50
51
52
53
54
   * @orig_node: the node to assign the DAT address to
   */
  static inline void
  batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
  {
6b5e971a2   Sven Eckelmann   batman-adv: Repla...
55
  	u32 addr;
785ea1144   Antonio Quartulli   batman-adv: Distr...
56
57
58
59
60
61
  
  	addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
  	orig_node->dat_addr = (batadv_dat_addr_t)addr;
  }
  
  /**
7e9a8c2ce   Sven Eckelmann   batman-adv: Use p...
62
   * batadv_dat_init_own_addr() - assign a DAT address to the node itself
785ea1144   Antonio Quartulli   batman-adv: Distr...
63
64
65
66
67
68
69
   * @bat_priv: the bat priv with all the soft interface information
   * @primary_if: a pointer to the primary interface
   */
  static inline void
  batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
  			 struct batadv_hard_iface *primary_if)
  {
6b5e971a2   Sven Eckelmann   batman-adv: Repla...
70
  	u32 addr;
785ea1144   Antonio Quartulli   batman-adv: Distr...
71
72
73
74
75
76
  
  	addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
  				  BATADV_DAT_ADDR_MAX);
  
  	bat_priv->dat.addr = (batadv_dat_addr_t)addr;
  }
2f1dfbe18   Antonio Quartulli   batman-adv: Distr...
77
78
79
  int batadv_dat_init(struct batadv_priv *bat_priv);
  void batadv_dat_free(struct batadv_priv *bat_priv);
  int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset);
41aeefcc3   Linus Lüssing   batman-adv: add D...
80
  int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb);
2f1dfbe18   Antonio Quartulli   batman-adv: Distr...
81

4046b24af   Martin Hundebøll   batman-adv: Add g...
82
  /**
7e9a8c2ce   Sven Eckelmann   batman-adv: Use p...
83
   * batadv_dat_inc_counter() - increment the correct DAT packet counter
4046b24af   Martin Hundebøll   batman-adv: Add g...
84
85
86
87
88
89
   * @bat_priv: the bat priv with all the soft interface information
   * @subtype: the 4addr subtype of the packet to be counted
   *
   * Updates the ethtool statistics for the received packet if it is a DAT subtype
   */
  static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
6b5e971a2   Sven Eckelmann   batman-adv: Repla...
90
  					  u8 subtype)
4046b24af   Martin Hundebøll   batman-adv: Add g...
91
92
93
94
95
96
97
98
99
100
101
102
  {
  	switch (subtype) {
  	case BATADV_P_DAT_DHT_GET:
  		batadv_inc_counter(bat_priv,
  				   BATADV_CNT_DAT_GET_RX);
  		break;
  	case BATADV_P_DAT_DHT_PUT:
  		batadv_inc_counter(bat_priv,
  				   BATADV_CNT_DAT_PUT_RX);
  		break;
  	}
  }
172244748   Antonio Quartulli   batman-adv: Distr...
103
  #else
17cf0ea45   Marek Lindner   batman-adv: tvlv ...
104
105
106
  static inline void batadv_dat_status_update(struct net_device *net_dev)
  {
  }
172244748   Antonio Quartulli   batman-adv: Distr...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  static inline bool
  batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
  				      struct sk_buff *skb)
  {
  	return false;
  }
  
  static inline bool
  batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
  				      struct sk_buff *skb, int hdr_size)
  {
  	return false;
  }
  
  static inline bool
  batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
  				    struct sk_buff *skb)
  {
  	return false;
  }
  
  static inline bool
  batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
  				    struct sk_buff *skb, int hdr_size)
  {
  	return false;
  }
  
  static inline bool
  batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
  				 struct batadv_forw_packet *forw_packet)
  {
  	return false;
  }
  
  static inline void
  batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
  {
  }
  
  static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
  					    struct batadv_hard_iface *iface)
  {
  }
  
  static inline void batadv_arp_change_timeout(struct net_device *soft_iface,
  					     const char *name)
  {
  }
  
  static inline int batadv_dat_init(struct batadv_priv *bat_priv)
  {
  	return 0;
  }
  
  static inline void batadv_dat_free(struct batadv_priv *bat_priv)
  {
  }
41aeefcc3   Linus Lüssing   batman-adv: add D...
165
166
167
168
169
  static inline int
  batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
  {
  	return -EOPNOTSUPP;
  }
4046b24af   Martin Hundebøll   batman-adv: Add g...
170
  static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
6b5e971a2   Sven Eckelmann   batman-adv: Repla...
171
  					  u8 subtype)
4046b24af   Martin Hundebøll   batman-adv: Add g...
172
173
  {
  }
172244748   Antonio Quartulli   batman-adv: Distr...
174
  #endif /* CONFIG_BATMAN_ADV_DAT */
a48bcacdb   Antonio Quartulli   batman-adv: prope...
175
  #endif /* _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_ */