00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef _ROUTE_H
00025
#define _ROUTE_H
00026
00027
#include <linux/config.h>
00028
#include <net/dst.h>
00029
#include <net/inetpeer.h>
00030
#include <linux/in_route.h>
00031
#include <linux/rtnetlink.h>
00032
#include <linux/route.h>
00033
#include <linux/ip.h>
00034
#include <linux/cache.h>
00035
00036
#ifndef __KERNEL__
00037
#warning This file is not supposed to be used outside of kernel.
00038
#endif
00039
00040 #define RTO_ONLINK 0x01
00041
00042 #define RTO_CONN 0
00043
00044
00045
00046 #define RT_CONN_FLAGS(sk) (RT_TOS(sk->protinfo.af_inet.tos) | sk->localroute)
00047
00048 struct rt_key
00049 {
00050 __u32
dst;
00051 __u32
src;
00052 int iif;
00053 int oif;
00054
#ifdef CONFIG_IP_ROUTE_FWMARK
00055
__u32 fwmark;
00056
#endif
00057 __u8
tos;
00058 __u8
scope;
00059 };
00060
00061
struct inet_peer;
00062 struct rtable
00063 {
00064
union
00065
{
00066 struct dst_entry dst;
00067 struct rtable *
rt_next;
00068 } u;
00069
00070 unsigned rt_flags;
00071 unsigned rt_type;
00072
00073 __u32
rt_dst;
00074 __u32
rt_src;
00075 int rt_iif;
00076
00077
00078 __u32
rt_gateway;
00079
00080
00081 struct rt_key key;
00082
00083
00084 __u32
rt_spec_dst;
00085 struct inet_peer *
peer;
00086
00087
#ifdef CONFIG_IP_ROUTE_NAT
00088
__u32 rt_src_map;
00089 __u32 rt_dst_map;
00090
#endif
00091
};
00092
00093 struct ip_rt_acct
00094 {
00095 __u32
o_bytes;
00096 __u32
o_packets;
00097 __u32
i_bytes;
00098 __u32
i_packets;
00099 };
00100
00101 struct rt_cache_stat
00102 {
00103 unsigned int in_hit;
00104 unsigned int in_slow_tot;
00105 unsigned int in_slow_mc;
00106 unsigned int in_no_route;
00107 unsigned int in_brd;
00108 unsigned int in_martian_dst;
00109 unsigned int in_martian_src;
00110 unsigned int out_hit;
00111 unsigned int out_slow_tot;
00112 unsigned int out_slow_mc;
00113 unsigned int gc_total;
00114 unsigned int gc_ignored;
00115 unsigned int gc_goal_miss;
00116 unsigned int gc_dst_overflow;
00117 unsigned int in_hlist_search;
00118 unsigned int out_hlist_search;
00119 }
____cacheline_aligned_in_smp;
00120
00121
extern struct ip_rt_acct *
ip_rt_acct;
00122
00123
struct in_device;
00124
extern void ip_rt_init(
void);
00125
extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw,
00126 u32 src, u8 tos,
struct net_device *dev);
00127
extern void ip_rt_advice(
struct rtable **rp,
int advice);
00128
extern void rt_cache_flush(
int how);
00129
extern int ip_route_output_key(
struct rtable **,
const struct rt_key *key);
00130
extern int ip_route_input(
struct sk_buff*, u32 dst, u32 src, u8 tos,
struct net_device *devin);
00131
extern unsigned short ip_rt_frag_needed(
struct iphdr *iph,
unsigned short new_mtu);
00132
extern void ip_rt_update_pmtu(
struct dst_entry *dst,
unsigned mtu);
00133
extern void ip_rt_send_redirect(
struct sk_buff *skb);
00134
00135
extern unsigned inet_addr_type(u32 addr);
00136
extern void ip_rt_multicast_event(
struct in_device *);
00137
extern int ip_rt_ioctl(
unsigned int cmd,
void *arg);
00138
extern void ip_rt_get_source(u8 *src,
struct rtable *rt);
00139
extern int ip_rt_dump(
struct sk_buff *skb,
struct netlink_callback *cb);
00140
00141
00142 static inline int ip_route_output(
struct rtable **rp,
00143 u32 daddr, u32 saddr, u32 tos,
int oif)
00144 {
00145
struct rt_key key = { dst:daddr, src:saddr, oif:oif, tos:tos };
00146
00147
return ip_route_output_key(rp, &key);
00148 }
00149
00150
00151 static inline void ip_rt_put(
struct rtable * rt)
00152 {
00153
if (rt)
00154
dst_release(&rt->
u.dst);
00155 }
00156
00157 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
00158
00159
extern __u8
ip_tos2prio[16];
00160
00161 static inline char rt_tos2priority(u8 tos)
00162 {
00163
return ip_tos2prio[
IPTOS_TOS(tos)>>1];
00164 }
00165
00166 static inline int ip_route_connect(
struct rtable **rp, u32 dst, u32 src, u32 tos,
int oif)
00167 {
00168
int err;
00169 err =
ip_route_output(rp, dst, src, tos, oif);
00170
if (err || (dst && src))
00171
return err;
00172 dst = (*rp)->rt_dst;
00173 src = (*rp)->rt_src;
00174
ip_rt_put(*rp);
00175 *rp = NULL;
00176
return ip_route_output(rp, dst, src, tos, oif);
00177 }
00178
00179
extern void rt_bind_peer(
struct rtable *rt,
int create);
00180
00181 static inline struct inet_peer *
rt_get_peer(
struct rtable *rt)
00182 {
00183
if (rt->
peer)
00184
return rt->
peer;
00185
00186
rt_bind_peer(rt, 0);
00187
return rt->
peer;
00188 }
00189
00190
#endif