xref: /openbmc/linux/include/net/arp.h (revision 60395a20ffd74166ea373ea91418d6f98fa7fdfb)
11da177e4SLinus Torvalds /* linux/net/inet/arp.h */
21da177e4SLinus Torvalds #ifndef _ARP_H
31da177e4SLinus Torvalds #define _ARP_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #include <linux/if_arp.h>
6b14f243aSPavel Emelyanov #include <linux/hash.h>
71da177e4SLinus Torvalds #include <net/neighbour.h>
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds extern struct neigh_table arp_tbl;
111da177e4SLinus Torvalds 
12*60395a20SEric W. Biederman static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 *hash_rnd)
13f610b74bSDavid S. Miller {
14*60395a20SEric W. Biederman 	u32 key = *(const u32 *)pkey;
15b14f243aSPavel Emelyanov 	u32 val = key ^ hash32_ptr(dev);
16f610b74bSDavid S. Miller 
17*60395a20SEric W. Biederman 	return val * hash_rnd[0];
18f610b74bSDavid S. Miller }
19f610b74bSDavid S. Miller 
20a263b309SDavid S. Miller static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
213769cffbSDavid Miller {
22*60395a20SEric W. Biederman 	return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);
23a263b309SDavid S. Miller }
24a263b309SDavid S. Miller 
25a263b309SDavid S. Miller static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key)
26a263b309SDavid S. Miller {
27a263b309SDavid S. Miller 	struct neighbour *n;
28a263b309SDavid S. Miller 
29a263b309SDavid S. Miller 	rcu_read_lock_bh();
30a263b309SDavid S. Miller 	n = __ipv4_neigh_lookup_noref(dev, key);
31a263b309SDavid S. Miller 	if (n && !atomic_inc_not_zero(&n->refcnt))
323769cffbSDavid Miller 		n = NULL;
333769cffbSDavid Miller 	rcu_read_unlock_bh();
343769cffbSDavid Miller 
353769cffbSDavid Miller 	return n;
363769cffbSDavid Miller }
373769cffbSDavid Miller 
3890972b22SJoe Perches void arp_init(void);
3990972b22SJoe Perches int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
4090972b22SJoe Perches void arp_send(int type, int ptype, __be32 dest_ip,
41ed9bad06SAl Viro 	      struct net_device *dev, __be32 src_ip,
42abfdf1c4SJan Engelhardt 	      const unsigned char *dest_hw,
43abfdf1c4SJan Engelhardt 	      const unsigned char *src_hw, const unsigned char *th);
4490972b22SJoe Perches int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
4590972b22SJoe Perches void arp_ifdown(struct net_device *dev);
461da177e4SLinus Torvalds 
4790972b22SJoe Perches struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
48ed9bad06SAl Viro 			   struct net_device *dev, __be32 src_ip,
49abfdf1c4SJan Engelhardt 			   const unsigned char *dest_hw,
50abfdf1c4SJan Engelhardt 			   const unsigned char *src_hw,
51abfdf1c4SJan Engelhardt 			   const unsigned char *target_hw);
5290972b22SJoe Perches void arp_xmit(struct sk_buff *skb);
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds #endif	/* _ARP_H */
55