ip6_route.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef _NET_IP6_ROUTE_H
  2. #define _NET_IP6_ROUTE_H
  3. #define IP6_RT_PRIO_FW 16
  4. #define IP6_RT_PRIO_USER 1024
  5. #define IP6_RT_PRIO_ADDRCONF 256
  6. #define IP6_RT_PRIO_KERN 512
  7. #define IP6_RT_FLOW_MASK 0x00ff
  8. #ifdef __KERNEL__
  9. #include <net/flow.h>
  10. #include <net/ip6_fib.h>
  11. #include <net/sock.h>
  12. #include <linux/tcp.h>
  13. #include <linux/ip.h>
  14. #include <linux/ipv6.h>
  15. struct pol_chain {
  16. int type;
  17. int priority;
  18. struct fib6_node *rules;
  19. struct pol_chain *next;
  20. };
  21. extern struct rt6_info ip6_null_entry;
  22. extern int ip6_rt_gc_interval;
  23. extern void ip6_route_input(struct sk_buff *skb);
  24. extern struct dst_entry * ip6_route_output(struct sock *sk,
  25. struct flowi *fl);
  26. extern int ip6_route_me_harder(struct sk_buff *skb);
  27. extern void ip6_route_init(void);
  28. extern void ip6_route_cleanup(void);
  29. extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg);
  30. extern int ip6_route_add(struct in6_rtmsg *rtmsg,
  31. struct nlmsghdr *,
  32. void *rtattr);
  33. extern int ip6_ins_rt(struct rt6_info *,
  34. struct nlmsghdr *,
  35. void *rtattr);
  36. extern int ip6_del_rt(struct rt6_info *,
  37. struct nlmsghdr *,
  38. void *rtattr);
  39. extern int ip6_rt_addr_add(struct in6_addr *addr,
  40. struct net_device *dev,
  41. int anycast);
  42. extern int ip6_rt_addr_del(struct in6_addr *addr,
  43. struct net_device *dev);
  44. extern void rt6_sndmsg(int type, struct in6_addr *dst,
  45. struct in6_addr *src,
  46. struct in6_addr *gw,
  47. struct net_device *dev,
  48. int dstlen, int srclen,
  49. int metric, __u32 flags);
  50. extern struct rt6_info *rt6_lookup(struct in6_addr *daddr,
  51. struct in6_addr *saddr,
  52. int oif, int flags);
  53. extern struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
  54. struct neighbour *neigh,
  55. struct in6_addr *addr,
  56. int (*output)(struct sk_buff *));
  57. extern int ndisc_dst_gc(int *more);
  58. extern void fib6_force_start_gc(void);
  59. extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
  60. const struct in6_addr *addr,
  61. int anycast);
  62. /*
  63. * support functions for ND
  64. *
  65. */
  66. extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr,
  67. struct net_device *dev);
  68. extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
  69. struct net_device *dev);
  70. extern void rt6_purge_dflt_routers(void);
  71. extern void rt6_reset_dflt_pointer(struct rt6_info *rt);
  72. extern void rt6_redirect(struct in6_addr *dest,
  73. struct in6_addr *saddr,
  74. struct neighbour *neigh,
  75. u8 *lladdr,
  76. int on_link);
  77. extern void rt6_pmtu_discovery(struct in6_addr *daddr,
  78. struct in6_addr *saddr,
  79. struct net_device *dev,
  80. u32 pmtu);
  81. struct nlmsghdr;
  82. struct netlink_callback;
  83. extern int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb);
  84. extern int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  85. extern int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  86. extern int inet6_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  87. extern void rt6_ifdown(struct net_device *dev);
  88. extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
  89. extern rwlock_t rt6_lock;
  90. /*
  91. * Store a destination cache entry in a socket
  92. */
  93. static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
  94. struct in6_addr *daddr)
  95. {
  96. struct ipv6_pinfo *np = inet6_sk(sk);
  97. struct rt6_info *rt = (struct rt6_info *) dst;
  98. write_lock(&sk->sk_dst_lock);
  99. __sk_dst_set(sk, dst);
  100. np->daddr_cache = daddr;
  101. np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
  102. write_unlock(&sk->sk_dst_lock);
  103. }
  104. static inline int ipv6_unicast_destination(struct sk_buff *skb)
  105. {
  106. struct rt6_info *rt = (struct rt6_info *) skb->dst;
  107. return rt->rt6i_flags & RTF_LOCAL;
  108. }
  109. #endif
  110. #endif