Path: blob/master/net/batman-adv/distributed-arp-table.h
26278 views
/* SPDX-License-Identifier: GPL-2.0 */1/* Copyright (C) B.A.T.M.A.N. contributors:2*3* Antonio Quartulli4*/56#ifndef _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_7#define _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_89#include "main.h"1011#include <linux/compiler.h>12#include <linux/netdevice.h>13#include <linux/netlink.h>14#include <linux/skbuff.h>15#include <linux/types.h>16#include <uapi/linux/batadv_packet.h>1718#include "originator.h"1920#ifdef CONFIG_BATMAN_ADV_DAT2122/* BATADV_DAT_ADDR_MAX - maximum address value in the DHT space */23#define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0)2425void batadv_dat_status_update(struct net_device *net_dev);26bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,27struct sk_buff *skb);28bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,29struct sk_buff *skb, int hdr_size);30void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,31struct sk_buff *skb);32bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,33struct sk_buff *skb, int hdr_size);34void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,35struct sk_buff *skb,36__be16 proto,37unsigned short vid);38void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,39struct sk_buff *skb, int hdr_size);40bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,41struct batadv_forw_packet *forw_packet);4243/**44* batadv_dat_init_orig_node_addr() - assign a DAT address to the orig_node45* @orig_node: the node to assign the DAT address to46*/47static inline void48batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)49{50u32 addr;5152addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX);53orig_node->dat_addr = (batadv_dat_addr_t)addr;54}5556/**57* batadv_dat_init_own_addr() - assign a DAT address to the node itself58* @bat_priv: the bat priv with all the mesh interface information59* @primary_if: a pointer to the primary interface60*/61static inline void62batadv_dat_init_own_addr(struct batadv_priv *bat_priv,63struct batadv_hard_iface *primary_if)64{65u32 addr;6667addr = batadv_choose_orig(primary_if->net_dev->dev_addr,68BATADV_DAT_ADDR_MAX);6970bat_priv->dat.addr = (batadv_dat_addr_t)addr;71}7273int batadv_dat_init(struct batadv_priv *bat_priv);74void batadv_dat_free(struct batadv_priv *bat_priv);75int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb);7677/**78* batadv_dat_inc_counter() - increment the correct DAT packet counter79* @bat_priv: the bat priv with all the mesh interface information80* @subtype: the 4addr subtype of the packet to be counted81*82* Updates the ethtool statistics for the received packet if it is a DAT subtype83*/84static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,85u8 subtype)86{87switch (subtype) {88case BATADV_P_DAT_DHT_GET:89batadv_inc_counter(bat_priv,90BATADV_CNT_DAT_GET_RX);91break;92case BATADV_P_DAT_DHT_PUT:93batadv_inc_counter(bat_priv,94BATADV_CNT_DAT_PUT_RX);95break;96}97}9899#else100101static inline void batadv_dat_status_update(struct net_device *net_dev)102{103}104105static inline bool106batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,107struct sk_buff *skb)108{109return false;110}111112static inline bool113batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,114struct sk_buff *skb, int hdr_size)115{116return false;117}118119static inline bool120batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,121struct sk_buff *skb)122{123return false;124}125126static inline bool127batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,128struct sk_buff *skb, int hdr_size)129{130return false;131}132133static inline void134batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,135struct sk_buff *skb, __be16 proto,136unsigned short vid)137{138}139140static inline void141batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,142struct sk_buff *skb, int hdr_size)143{144}145146static inline bool147batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,148struct batadv_forw_packet *forw_packet)149{150return false;151}152153static inline void154batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node)155{156}157158static inline void batadv_dat_init_own_addr(struct batadv_priv *bat_priv,159struct batadv_hard_iface *iface)160{161}162163static inline int batadv_dat_init(struct batadv_priv *bat_priv)164{165return 0;166}167168static inline void batadv_dat_free(struct batadv_priv *bat_priv)169{170}171172static inline int173batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)174{175return -EOPNOTSUPP;176}177178static inline void batadv_dat_inc_counter(struct batadv_priv *bat_priv,179u8 subtype)180{181}182183#endif /* CONFIG_BATMAN_ADV_DAT */184185#endif /* _NET_BATMAN_ADV_DISTRIBUTED_ARP_TABLE_H_ */186187188