2017-11-19 15:05:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-12-31 23:59:59 +01:00
|
|
|
/* Copyright (C) 2011-2019 B.A.T.M.A.N. contributors:
|
2011-11-23 11:35:44 +01:00
|
|
|
*
|
|
|
|
* Antonio Quartulli
|
|
|
|
*/
|
|
|
|
|
2013-10-13 23:02:45 +02:00
|
|
|
#ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
|
|
|
|
#define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_
|
2011-11-23 11:35:44 +01:00
|
|
|
|
2015-04-17 19:40:28 +02:00
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/netdevice.h>
|
2019-05-24 20:11:17 +02:00
|
|
|
#include <linux/netlink.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/skbuff.h>
|
2015-04-17 19:40:28 +02:00
|
|
|
#include <linux/types.h>
|
2017-12-21 10:17:41 +01:00
|
|
|
#include <uapi/linux/batadv_packet.h>
|
2011-11-06 12:23:55 +01:00
|
|
|
|
2011-11-23 11:35:44 +01:00
|
|
|
#include "originator.h"
|
|
|
|
|
2015-04-17 19:40:28 +02:00
|
|
|
#ifdef CONFIG_BATMAN_ADV_DAT
|
2011-06-02 12:29:51 +02:00
|
|
|
|
2014-07-15 09:41:07 +02:00
|
|
|
/* BATADV_DAT_ADDR_MAX - maximum address value in the DHT space */
|
2011-11-23 11:35:44 +01:00
|
|
|
#define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)
|
|
|
|
|
2013-04-23 15:39:59 +02:00
|
|
|
void batadv_dat_status_update(struct net_device *net_dev);
|
2011-06-26 03:37:18 +02:00
|
|
|
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);
|
2018-12-30 16:52:53 +01:00
|
|
|
void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
|
|
|
|
struct sk_buff *skb,
|
|
|
|
__be16 proto,
|
|
|
|
unsigned short vid);
|
|
|
|
void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
|
|
|
|
struct sk_buff *skb, int hdr_size);
|
2011-06-26 03:37:18 +02:00
|
|
|
bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
|
|
|
|
struct batadv_forw_packet *forw_packet);
|
|
|
|
|
2011-11-23 11:35:44 +01:00
|
|
|
/**
|
2017-12-02 19:51:47 +01:00
|
|
|
* batadv_dat_init_orig_node_addr() - assign a DAT address to the orig_node
|
2011-11-23 11:35:44 +01:00
|
|
|
* @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)
|
|
|
|
{
|
2015-05-26 18:34:26 +02:00
|
|
|
u32 addr;
|
2011-11-23 11:35:44 +01:00
|
|
|
|
|
|
|
addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);
|
|
|
|
orig_node->dat_addr = (batadv_dat_addr_t)addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-02 19:51:47 +01:00
|
|
|
* batadv_dat_init_own_addr() - assign a DAT address to the node itself
|
2011-11-23 11:35:44 +01:00
|
|
|
* @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)
|
|
|
|
{
|
2015-05-26 18:34:26 +02:00
|
|
|
u32 addr;
|
2011-11-23 11:35:44 +01:00
|
|
|
|
|
|
|
addr = batadv_choose_orig(primary_if->net_dev->dev_addr,
|
|
|
|
BATADV_DAT_ADDR_MAX);
|
|
|
|
|
|
|
|
bat_priv->dat.addr = (batadv_dat_addr_t)addr;
|
|
|
|
}
|
|
|
|
|
2012-06-30 20:01:19 +02:00
|
|
|
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);
|
2018-03-13 11:41:12 +01:00
|
|
|
int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb);
|
2012-06-30 20:01:19 +02:00
|
|
|
|
2012-04-20 17:02:45 +02:00
|
|
|
/**
|
2017-12-02 19:51:47 +01:00
|
|
|
* batadv_dat_inc_counter() - increment the correct DAT packet counter
|
2012-04-20 17:02:45 +02:00
|
|
|
* @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,
|
2015-05-26 18:34:26 +02:00
|
|
|
u8 subtype)
|
2012-04-20 17:02:45 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-06 12:23:55 +01:00
|
|
|
#else
|
|
|
|
|
2013-04-23 15:39:59 +02:00
|
|
|
static inline void batadv_dat_status_update(struct net_device *net_dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-06 12:23:55 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-12-30 16:52:53 +01:00
|
|
|
static inline void
|
|
|
|
batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
|
|
|
|
struct sk_buff *skb, __be16 proto,
|
|
|
|
unsigned short vid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
|
|
|
|
struct sk_buff *skb, int hdr_size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-06 12:23:55 +01:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-13 11:41:12 +01:00
|
|
|
static inline int
|
|
|
|
batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2012-04-20 17:02:45 +02:00
|
|
|
static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,
|
2015-05-26 18:34:26 +02:00
|
|
|
u8 subtype)
|
2012-04-20 17:02:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-06 12:23:55 +01:00
|
|
|
#endif /* CONFIG_BATMAN_ADV_DAT */
|
|
|
|
|
2013-10-13 23:02:45 +02:00
|
|
|
#endif /* _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_ */
|