inetpeer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. __u32 avl_height;
  18. struct list_head unused;
  19. __u32 dtime; /* the time of last use of not
  20. * referenced entries */
  21. atomic_t refcnt;
  22. atomic_t rid; /* Frag reception counter */
  23. atomic_t ip_id_count; /* IP ID for the next packet */
  24. __u32 tcp_ts;
  25. __u32 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. /* can be called with or without local BH being disabled */
  33. static inline __u16 inet_getid(struct inet_peer *p, int more)
  34. {
  35. more++;
  36. return atomic_add_return(more, &p->ip_id_count) - more;
  37. }
  38. #endif /* _NET_INETPEER_H */