[NETNS][IPV6] rt6_info - make rt6_info accessed as a pointer
[linux-2.6.git] / include / net / ip6_route.h
1 #ifndef _NET_IP6_ROUTE_H
2 #define _NET_IP6_ROUTE_H
3
4 #define IP6_RT_PRIO_USER        1024
5 #define IP6_RT_PRIO_ADDRCONF    256
6 #define IP6_RT_PRIO_KERN        512
7
8 struct route_info {
9         __u8                    type;
10         __u8                    length;
11         __u8                    prefix_len;
12 #if defined(__BIG_ENDIAN_BITFIELD)
13         __u8                    reserved_h:3,
14                                 route_pref:2,
15                                 reserved_l:3;
16 #elif defined(__LITTLE_ENDIAN_BITFIELD)
17         __u8                    reserved_l:3,
18                                 route_pref:2,
19                                 reserved_h:3;
20 #endif
21         __be32                  lifetime;
22         __u8                    prefix[0];      /* 0,8 or 16 */
23 };
24
25 #ifdef __KERNEL__
26
27 #include <net/flow.h>
28 #include <net/ip6_fib.h>
29 #include <net/sock.h>
30 #include <linux/ip.h>
31 #include <linux/ipv6.h>
32
33 #define RT6_LOOKUP_F_IFACE      0x1
34 #define RT6_LOOKUP_F_REACHABLE  0x2
35 #define RT6_LOOKUP_F_HAS_SADDR  0x4
36
37 extern struct rt6_info  *ip6_null_entry;
38
39 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
40 extern struct rt6_info  *ip6_prohibit_entry;
41 extern struct rt6_info  *ip6_blk_hole_entry;
42 #endif
43
44 extern void                     ip6_route_input(struct sk_buff *skb);
45
46 extern struct dst_entry *       ip6_route_output(struct sock *sk,
47                                                  struct flowi *fl);
48
49 extern int                      ip6_route_init(void);
50 extern void                     ip6_route_cleanup(void);
51
52 extern int                      ipv6_route_ioctl(struct net *net,
53                                                  unsigned int cmd,
54                                                  void __user *arg);
55
56 extern int                      ip6_route_add(struct fib6_config *cfg);
57 extern int                      ip6_ins_rt(struct rt6_info *);
58 extern int                      ip6_del_rt(struct rt6_info *);
59
60 extern int                      ip6_rt_addr_add(struct in6_addr *addr,
61                                                 struct net_device *dev,
62                                                 int anycast);
63
64 extern int                      ip6_rt_addr_del(struct in6_addr *addr,
65                                                 struct net_device *dev);
66
67 extern void                     rt6_sndmsg(int type, struct in6_addr *dst,
68                                            struct in6_addr *src,
69                                            struct in6_addr *gw,
70                                            struct net_device *dev, 
71                                            int dstlen, int srclen,
72                                            int metric, __u32 flags);
73
74 extern struct rt6_info          *rt6_lookup(struct net *net,
75                                             struct in6_addr *daddr,
76                                             struct in6_addr *saddr,
77                                             int oif, int flags);
78
79 extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
80                                          struct neighbour *neigh,
81                                          struct in6_addr *addr);
82 extern int icmp6_dst_gc(int *more);
83
84 extern void fib6_force_start_gc(struct net *net);
85
86 extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
87                                            const struct in6_addr *addr,
88                                            int anycast);
89
90 /*
91  *      support functions for ND
92  *
93  */
94 extern struct rt6_info *        rt6_get_dflt_router(struct in6_addr *addr,
95                                                     struct net_device *dev);
96 extern struct rt6_info *        rt6_add_dflt_router(struct in6_addr *gwaddr,
97                                                     struct net_device *dev,
98                                                     unsigned int pref);
99
100 extern void                     rt6_purge_dflt_routers(struct net *net);
101
102 extern int                      rt6_route_rcv(struct net_device *dev,
103                                               u8 *opt, int len,
104                                               struct in6_addr *gwaddr);
105
106 extern void                     rt6_redirect(struct in6_addr *dest,
107                                              struct in6_addr *src,
108                                              struct in6_addr *saddr,
109                                              struct neighbour *neigh,
110                                              u8 *lladdr,
111                                              int on_link);
112
113 extern void                     rt6_pmtu_discovery(struct in6_addr *daddr,
114                                                    struct in6_addr *saddr,
115                                                    struct net_device *dev,
116                                                    u32 pmtu);
117
118 struct netlink_callback;
119
120 struct rt6_rtnl_dump_arg
121 {
122         struct sk_buff *skb;
123         struct netlink_callback *cb;
124 };
125
126 extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
127 extern void rt6_ifdown(struct net *net, struct net_device *dev);
128 extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
129
130 extern rwlock_t rt6_lock;
131
132 /*
133  *      Store a destination cache entry in a socket
134  */
135 static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst,
136                                    struct in6_addr *daddr, struct in6_addr *saddr)
137 {
138         struct ipv6_pinfo *np = inet6_sk(sk);
139         struct rt6_info *rt = (struct rt6_info *) dst;
140
141         sk_setup_caps(sk, dst);
142         np->daddr_cache = daddr;
143 #ifdef CONFIG_IPV6_SUBTREES
144         np->saddr_cache = saddr;
145 #endif
146         np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
147 }
148
149 static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
150                                  struct in6_addr *daddr, struct in6_addr *saddr)
151 {
152         write_lock(&sk->sk_dst_lock);
153         __ip6_dst_store(sk, dst, daddr, saddr);
154         write_unlock(&sk->sk_dst_lock);
155 }
156
157 static inline int ipv6_unicast_destination(struct sk_buff *skb)
158 {
159         struct rt6_info *rt = (struct rt6_info *) skb->dst;
160
161         return rt->rt6i_flags & RTF_LOCAL;
162 }
163
164 #endif
165 #endif