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 12f610b74bSDavid S. Miller static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) 13f610b74bSDavid S. Miller { 14b14f243aSPavel Emelyanov u32 val = key ^ hash32_ptr(dev); 15f610b74bSDavid S. Miller 16f610b74bSDavid S. Miller return val * hash_rnd; 17f610b74bSDavid S. Miller } 18f610b74bSDavid S. Miller 19a263b309SDavid S. Miller static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) 203769cffbSDavid Miller { 21a263b309SDavid S. Miller struct neigh_hash_table *nht = rcu_dereference_bh(arp_tbl.nht); 223769cffbSDavid Miller struct neighbour *n; 233769cffbSDavid Miller u32 hash_val; 243769cffbSDavid Miller 252c2aba6cSDavid S. Miller hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); 263769cffbSDavid Miller for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); 273769cffbSDavid Miller n != NULL; 283769cffbSDavid Miller n = rcu_dereference_bh(n->next)) { 29a263b309SDavid S. Miller if (n->dev == dev && *(u32 *)n->primary_key == key) 30a263b309SDavid S. Miller return n; 31a263b309SDavid S. Miller } 32a263b309SDavid S. Miller 33a263b309SDavid S. Miller return NULL; 34a263b309SDavid S. Miller } 35a263b309SDavid S. Miller 36a263b309SDavid S. Miller static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) 37a263b309SDavid S. Miller { 38a263b309SDavid S. Miller struct neighbour *n; 39a263b309SDavid S. Miller 40a263b309SDavid S. Miller rcu_read_lock_bh(); 41a263b309SDavid S. Miller n = __ipv4_neigh_lookup_noref(dev, key); 42a263b309SDavid S. Miller if (n && !atomic_inc_not_zero(&n->refcnt)) 433769cffbSDavid Miller n = NULL; 443769cffbSDavid Miller rcu_read_unlock_bh(); 453769cffbSDavid Miller 463769cffbSDavid Miller return n; 473769cffbSDavid Miller } 483769cffbSDavid Miller 49*90972b22SJoe Perches void arp_init(void); 50*90972b22SJoe Perches int arp_find(unsigned char *haddr, struct sk_buff *skb); 51*90972b22SJoe Perches int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg); 52*90972b22SJoe Perches void arp_send(int type, int ptype, __be32 dest_ip, 53ed9bad06SAl Viro struct net_device *dev, __be32 src_ip, 54abfdf1c4SJan Engelhardt const unsigned char *dest_hw, 55abfdf1c4SJan Engelhardt const unsigned char *src_hw, const unsigned char *th); 56*90972b22SJoe Perches int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); 57*90972b22SJoe Perches void arp_ifdown(struct net_device *dev); 581da177e4SLinus Torvalds 59*90972b22SJoe Perches struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, 60ed9bad06SAl Viro struct net_device *dev, __be32 src_ip, 61abfdf1c4SJan Engelhardt const unsigned char *dest_hw, 62abfdf1c4SJan Engelhardt const unsigned char *src_hw, 63abfdf1c4SJan Engelhardt const unsigned char *target_hw); 64*90972b22SJoe Perches void arp_xmit(struct sk_buff *skb); 65545ecdc3SMaxim Levitsky int arp_invalidate(struct net_device *dev, __be32 ip); 661da177e4SLinus Torvalds 671da177e4SLinus Torvalds #endif /* _ARP_H */ 68