arp.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* linux/net/inet/arp.h */
  2. #ifndef _ARP_H
  3. #define _ARP_H
  4. #include <linux/if_arp.h>
  5. #include <net/neighbour.h>
  6. extern struct neigh_table arp_tbl;
  7. static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
  8. {
  9. u32 val = key ^ dev->ifindex;
  10. return val * hash_rnd;
  11. }
  12. static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key)
  13. {
  14. struct neigh_hash_table *nht;
  15. struct neighbour *n;
  16. u32 hash_val;
  17. rcu_read_lock_bh();
  18. nht = rcu_dereference_bh(arp_tbl.nht);
  19. hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift);
  20. for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
  21. n != NULL;
  22. n = rcu_dereference_bh(n->next)) {
  23. if (n->dev == dev && *(u32 *)n->primary_key == key) {
  24. if (!atomic_inc_not_zero(&n->refcnt))
  25. n = NULL;
  26. break;
  27. }
  28. }
  29. rcu_read_unlock_bh();
  30. return n;
  31. }
  32. extern void arp_init(void);
  33. extern int arp_find(unsigned char *haddr, struct sk_buff *skb);
  34. extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
  35. extern void arp_send(int type, int ptype, __be32 dest_ip,
  36. struct net_device *dev, __be32 src_ip,
  37. const unsigned char *dest_hw,
  38. const unsigned char *src_hw, const unsigned char *th);
  39. extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
  40. extern void arp_ifdown(struct net_device *dev);
  41. extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
  42. struct net_device *dev, __be32 src_ip,
  43. const unsigned char *dest_hw,
  44. const unsigned char *src_hw,
  45. const unsigned char *target_hw);
  46. extern void arp_xmit(struct sk_buff *skb);
  47. int arp_invalidate(struct net_device *dev, __be32 ip);
  48. #endif /* _ARP_H */