inetpeer.h 1.3 KB

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