0001
0002
0003
0004
0005
0006
0007 #ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
0008 #define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
0009
0010 #include "main.h"
0011
0012 #include <linux/compiler.h>
0013 #include <linux/netdevice.h>
0014 #include <linux/netlink.h>
0015 #include <linux/skbuff.h>
0016 #include <linux/types.h>
0017 #include <uapi/linux/batadv_packet.h>
0018
0019 #include "originator.h"
0020
0021 #ifdef CONFIG_BATMAN_ADV_DAT
0022
0023
0024 #define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)
0025
0026 void batadv_dat_status_update(struct net_device *net_dev);
0027 bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
0028 struct sk_buff *skb);
0029 bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
0030 struct sk_buff *skb, int hdr_size);
0031 void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
0032 struct sk_buff *skb);
0033 bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
0034 struct sk_buff *skb, int hdr_size);
0035 void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
0036 struct sk_buff *skb,
0037 __be16 proto,
0038 unsigned short vid);
0039 void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
0040 struct sk_buff *skb, int hdr_size);
0041 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
0042 struct batadv_forw_packet *forw_packet);
0043
0044
0045
0046
0047
0048 static inline void
0049 batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
0050 {
0051 u32 addr;
0052
0053 addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
0054 orig_node->dat_addr = (batadv_dat_addr_t)addr;
0055 }
0056
0057
0058
0059
0060
0061
0062 static inline void
0063 batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
0064 struct batadv_hard_iface *primary_if)
0065 {
0066 u32 addr;
0067
0068 addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
0069 BATADV_DAT_ADDR_MAX);
0070
0071 bat_priv->dat.addr = (batadv_dat_addr_t)addr;
0072 }
0073
0074 int batadv_dat_init(struct batadv_priv *bat_priv);
0075 void batadv_dat_free(struct batadv_priv *bat_priv);
0076 int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb);
0077
0078
0079
0080
0081
0082
0083
0084
0085 static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
0086 u8 subtype)
0087 {
0088 switch (subtype) {
0089 case BATADV_P_DAT_DHT_GET:
0090 batadv_inc_counter(bat_priv,
0091 BATADV_CNT_DAT_GET_RX);
0092 break;
0093 case BATADV_P_DAT_DHT_PUT:
0094 batadv_inc_counter(bat_priv,
0095 BATADV_CNT_DAT_PUT_RX);
0096 break;
0097 }
0098 }
0099
0100 #else
0101
0102 static inline void batadv_dat_status_update(struct net_device *net_dev)
0103 {
0104 }
0105
0106 static inline bool
0107 batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
0108 struct sk_buff *skb)
0109 {
0110 return false;
0111 }
0112
0113 static inline bool
0114 batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
0115 struct sk_buff *skb, int hdr_size)
0116 {
0117 return false;
0118 }
0119
0120 static inline bool
0121 batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
0122 struct sk_buff *skb)
0123 {
0124 return false;
0125 }
0126
0127 static inline bool
0128 batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
0129 struct sk_buff *skb, int hdr_size)
0130 {
0131 return false;
0132 }
0133
0134 static inline void
0135 batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
0136 struct sk_buff *skb, __be16 proto,
0137 unsigned short vid)
0138 {
0139 }
0140
0141 static inline void
0142 batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
0143 struct sk_buff *skb, int hdr_size)
0144 {
0145 }
0146
0147 static inline bool
0148 batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
0149 struct batadv_forw_packet *forw_packet)
0150 {
0151 return false;
0152 }
0153
0154 static inline void
0155 batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)
0156 {
0157 }
0158
0159 static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv,
0160 struct batadv_hard_iface *iface)
0161 {
0162 }
0163
0164 static inline int batadv_dat_init(struct batadv_priv *bat_priv)
0165 {
0166 return 0;
0167 }
0168
0169 static inline void batadv_dat_free(struct batadv_priv *bat_priv)
0170 {
0171 }
0172
0173 static inline int
0174 batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
0175 {
0176 return -EOPNOTSUPP;
0177 }
0178
0179 static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
0180 u8 subtype)
0181 {
0182 }
0183
0184 #endif
0185
0186 #endif