Merge tag 'iommu-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux/fpc-iii.git] / net / batman-adv / distributed-arp-table.h
blobe980fb45693aee29f94bc4a13cb9b8091d5466db
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2011-2020 B.A.T.M.A.N. contributors:
4 * Antonio Quartulli
5 */
7 #ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
8 #define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
10 #include "main.h"
12 #include <linux/compiler.h>
13 #include <linux/netdevice.h>
14 #include <linux/netlink.h>
15 #include <linux/skbuff.h>
16 #include <linux/types.h>
17 #include <uapi/linux/batadv_packet.h>
19 #include "originator.h"
21 #ifdef CONFIG_BATMAN_ADV_DAT
23 /* BATADV_DAT_ADDR_MAX - maximum address value in the DHT space */
24 #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 void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
36 struct sk_buff *skb,
37 __be16 proto,
38 unsigned short vid);
39 void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
40 struct sk_buff *skb, int hdr_size);
41 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
42 struct batadv_forw_packet *forw_packet);
44 /**
45 * batadv_dat_init_orig_node_addr() - assign a DAT address to the orig_node
46 * @orig_node: the node to assign the DAT address to
48 static inline void
49 batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
51 u32 addr;
53 addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
54 orig_node->dat_addr = (batadv_dat_addr_t)addr;
57 /**
58 * batadv_dat_init_own_addr() - assign a DAT address to the node itself
59 * @bat_priv: the bat priv with all the soft interface information
60 * @primary_if: a pointer to the primary interface
62 static inline void
63 batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
64 struct batadv_hard_iface *primary_if)
66 u32 addr;
68 addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
69 BATADV_DAT_ADDR_MAX);
71 bat_priv->dat.addr = (batadv_dat_addr_t)addr;
74 int batadv_dat_init(struct batadv_priv *bat_priv);
75 void batadv_dat_free(struct batadv_priv *bat_priv);
76 int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb);
78 /**
79 * batadv_dat_inc_counter() - increment the correct DAT packet counter
80 * @bat_priv: the bat priv with all the soft interface information
81 * @subtype: the 4addr subtype of the packet to be counted
83 * Updates the ethtool statistics for the received packet if it is a DAT subtype
85 static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
86 u8 subtype)
88 switch (subtype) {
89 case BATADV_P_DAT_DHT_GET:
90 batadv_inc_counter(bat_priv,
91 BATADV_CNT_DAT_GET_RX);
92 break;
93 case BATADV_P_DAT_DHT_PUT:
94 batadv_inc_counter(bat_priv,
95 BATADV_CNT_DAT_PUT_RX);
96 break;
100 #else
102 static inline void batadv_dat_status_update(struct net_device *net_dev)
106 static inline bool
107 batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
108 struct sk_buff *skb)
110 return false;
113 static inline bool
114 batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
115 struct sk_buff *skb, int hdr_size)
117 return false;
120 static inline bool
121 batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
122 struct sk_buff *skb)
124 return false;
127 static inline bool
128 batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
129 struct sk_buff *skb, int hdr_size)
131 return false;
134 static inline void
135 batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
136 struct sk_buff *skb, __be16 proto,
137 unsigned short vid)
141 static inline void
142 batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
143 struct sk_buff *skb, int hdr_size)
147 static inline bool
148 batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
149 struct batadv_forw_packet *forw_packet)
151 return false;
154 static inline void
155 batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
159 static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
160 struct batadv_hard_iface *iface)
164 static inline int batadv_dat_init(struct batadv_priv *bat_priv)
166 return 0;
169 static inline void batadv_dat_free(struct batadv_priv *bat_priv)
173 static inline int
174 batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
176 return -EOPNOTSUPP;
179 static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
180 u8 subtype)
184 #endif /* CONFIG_BATMAN_ADV_DAT */
186 #endif /* _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_ */