* better
[mascara-docs.git] / i386 / linux-2.3.21 / include / net / dst.h
blob79a3cd392592448206ab41f4f206e3ea0c2ab47e
1 /*
2 * net/dst.h Protocol independent destination cache definitions.
4 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
6 */
8 #ifndef _NET_DST_H
9 #define _NET_DST_H
11 #include <linux/config.h>
12 #include <net/neighbour.h>
15 * 0 - no debugging messages
16 * 1 - rare events and bugs (default)
17 * 2 - trace mode.
19 #define RT_CACHE_DEBUG 0
21 #define DST_GC_MIN (1*HZ)
22 #define DST_GC_INC (5*HZ)
23 #define DST_GC_MAX (120*HZ)
25 struct sk_buff;
27 struct dst_entry
29 struct dst_entry *next;
30 atomic_t __refcnt; /* client references */
31 int __use;
32 struct net_device *dev;
33 int obsolete;
34 unsigned long lastuse;
35 unsigned long expires;
36 unsigned mxlock;
37 unsigned pmtu;
38 unsigned window;
39 unsigned rtt;
40 unsigned rttvar;
41 unsigned ssthresh;
42 unsigned cwnd;
43 unsigned advmss;
44 unsigned long rate_last; /* rate limiting for ICMP */
45 unsigned long rate_tokens;
47 int error;
49 struct neighbour *neighbour;
50 struct hh_cache *hh;
52 int (*input)(struct sk_buff*);
53 int (*output)(struct sk_buff*);
55 #ifdef CONFIG_NET_CLS_ROUTE
56 __u32 tclassid;
57 #endif
59 struct dst_ops *ops;
61 char info[0];
65 struct dst_ops
67 unsigned short family;
68 unsigned short protocol;
69 unsigned gc_thresh;
71 int (*gc)(void);
72 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
73 struct dst_entry * (*reroute)(struct dst_entry *,
74 struct sk_buff *);
75 void (*destroy)(struct dst_entry *);
76 struct dst_entry * (*negative_advice)(struct dst_entry *);
77 void (*link_failure)(struct sk_buff *);
78 int entry_size;
80 atomic_t entries;
81 kmem_cache_t *kmem_cachep;
84 #ifdef __KERNEL__
86 extern __inline__ void dst_hold(struct dst_entry * dst)
88 atomic_inc(&dst->__refcnt);
91 extern __inline__
92 struct dst_entry * dst_clone(struct dst_entry * dst)
94 if (dst)
95 atomic_inc(&dst->__refcnt);
96 return dst;
99 extern __inline__
100 void dst_release(struct dst_entry * dst)
102 if (dst)
103 atomic_dec(&dst->__refcnt);
106 extern void * dst_alloc(struct dst_ops * ops);
107 extern void __dst_free(struct dst_entry * dst);
108 extern void dst_destroy(struct dst_entry * dst);
110 extern __inline__
111 void dst_free(struct dst_entry * dst)
113 if (dst->obsolete > 1)
114 return;
115 if (!atomic_read(&dst->__refcnt)) {
116 dst_destroy(dst);
117 return;
119 __dst_free(dst);
122 extern __inline__ void dst_confirm(struct dst_entry *dst)
124 if (dst)
125 neigh_confirm(dst->neighbour);
128 extern __inline__ void dst_negative_advice(struct dst_entry **dst_p)
130 struct dst_entry * dst = *dst_p;
131 if (dst && dst->ops->negative_advice)
132 *dst_p = dst->ops->negative_advice(dst);
135 extern __inline__ void dst_link_failure(struct sk_buff *skb)
137 struct dst_entry * dst = skb->dst;
138 if (dst && dst->ops && dst->ops->link_failure)
139 dst->ops->link_failure(skb);
142 extern __inline__ void dst_set_expires(struct dst_entry *dst, int timeout)
144 unsigned long expires = jiffies + timeout;
146 if (expires == 0)
147 expires = 1;
149 if (dst->expires == 0 || (long)(dst->expires - expires) > 0)
150 dst->expires = expires;
153 extern void dst_init(void);
155 #endif
157 #endif /* _NET_DST_H */