inetpeer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * INETPEER - A storage for permanent information about peers
  3. *
  4. * Authors: Andrey V. Savochkin <saw@msu.ru>
  5. */
  6. #ifndef _NET_INETPEER_H
  7. #define _NET_INETPEER_H
  8. #include <linux/types.h>
  9. #include <linux/init.h>
  10. #include <linux/jiffies.h>
  11. #include <linux/spinlock.h>
  12. #include <asm/atomic.h>
  13. struct inet_peer {
  14. /* group together avl_left,avl_right,v4daddr to speedup lookups */
  15. struct inet_peer *avl_left, *avl_right;
  16. __be32 v4daddr; /* peer's address */
  17. __u16 avl_height;
  18. __u16 ip_id_count; /* IP ID for the next packet */
  19. struct list_head unused;
  20. __u32 dtime; /* the time of last use of not
  21. * referenced entries */
  22. atomic_t refcnt;
  23. atomic_t rid; /* Frag reception counter */
  24. __u32 tcp_ts;
  25. unsigned long tcp_ts_stamp;
  26. };
  27. void inet_initpeers(void) __init;
  28. /* can be called with or without local BH being disabled */
  29. struct inet_peer *inet_getpeer(__be32 daddr, int create);
  30. /* can be called from BH context or outside */
  31. extern void inet_putpeer(struct inet_peer *p);
  32. extern spinlock_t inet_peer_idlock;
  33. /* can be called with or without local BH being disabled */
  34. static inline __u16 inet_getid(struct inet_peer *p, int more)
  35. {
  36. __u16 id;
  37. spin_lock_bh(&inet_peer_idlock);
  38. id = p->ip_id_count;
  39. p->ip_id_count += 1 + more;
  40. spin_unlock_bh(&inet_peer_idlock);
  41. return id;
  42. }
  43. #endif /* _NET_INETPEER_H */