inetpeer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. {
  15. /* group together avl_left,avl_right,v4daddr to speedup lookups */
  16. struct inet_peer *avl_left, *avl_right;
  17. __be32 v4daddr; /* peer's address */
  18. __u16 avl_height;
  19. __u16 ip_id_count; /* IP ID for the next packet */
  20. struct list_head unused;
  21. __u32 dtime; /* the time of last use of not
  22. * referenced entries */
  23. atomic_t refcnt;
  24. atomic_t rid; /* Frag reception counter */
  25. __u32 tcp_ts;
  26. unsigned long tcp_ts_stamp;
  27. };
  28. void inet_initpeers(void) __init;
  29. /* can be called with or without local BH being disabled */
  30. struct inet_peer *inet_getpeer(__be32 daddr, int create);
  31. /* can be called from BH context or outside */
  32. extern void inet_putpeer(struct inet_peer *p);
  33. extern spinlock_t inet_peer_idlock;
  34. /* can be called with or without local BH being disabled */
  35. static inline __u16 inet_getid(struct inet_peer *p, int more)
  36. {
  37. __u16 id;
  38. spin_lock_bh(&inet_peer_idlock);
  39. id = p->ip_id_count;
  40. p->ip_id_count += 1 + more;
  41. spin_unlock_bh(&inet_peer_idlock);
  42. return id;
  43. }
  44. #endif /* _NET_INETPEER_H */