ip6_route.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. struct netlink_skb_parms *req);
  34. extern int ip6_ins_rt(struct rt6_info *,
  35. struct nlmsghdr *,
  36. void *rtattr,
  37. struct netlink_skb_parms *req);
  38. extern int ip6_del_rt(struct rt6_info *,
  39. struct nlmsghdr *,
  40. void *rtattr,
  41. struct netlink_skb_parms *req);
  42. extern int ip6_rt_addr_add(struct in6_addr *addr,
  43. struct net_device *dev,
  44. int anycast);
  45. extern int ip6_rt_addr_del(struct in6_addr *addr,
  46. struct net_device *dev);
  47. extern void rt6_sndmsg(int type, struct in6_addr *dst,
  48. struct in6_addr *src,
  49. struct in6_addr *gw,
  50. struct net_device *dev,
  51. int dstlen, int srclen,
  52. int metric, __u32 flags);
  53. extern struct rt6_info *rt6_lookup(struct in6_addr *daddr,
  54. struct in6_addr *saddr,
  55. int oif, int flags);
  56. extern struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
  57. struct neighbour *neigh,
  58. struct in6_addr *addr,
  59. int (*output)(struct sk_buff *));
  60. extern int ndisc_dst_gc(int *more);
  61. extern void fib6_force_start_gc(void);
  62. extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
  63. const struct in6_addr *addr,
  64. int anycast);
  65. /*
  66. * support functions for ND
  67. *
  68. */
  69. extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr,
  70. struct net_device *dev);
  71. extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
  72. struct net_device *dev);
  73. extern void rt6_purge_dflt_routers(void);
  74. extern void rt6_reset_dflt_pointer(struct rt6_info *rt);
  75. extern void rt6_redirect(struct in6_addr *dest,
  76. struct in6_addr *saddr,
  77. struct neighbour *neigh,
  78. u8 *lladdr,
  79. int on_link);
  80. extern void rt6_pmtu_discovery(struct in6_addr *daddr,
  81. struct in6_addr *saddr,
  82. struct net_device *dev,
  83. u32 pmtu);
  84. struct nlmsghdr;
  85. struct netlink_callback;
  86. extern int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb);
  87. extern int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  88. extern int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  89. extern int inet6_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg);
  90. extern void rt6_ifdown(struct net_device *dev);
  91. extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
  92. extern rwlock_t rt6_lock;
  93. /*
  94. * Store a destination cache entry in a socket
  95. */
  96. static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
  97. struct in6_addr *daddr)
  98. {
  99. struct ipv6_pinfo *np = inet6_sk(sk);
  100. struct rt6_info *rt = (struct rt6_info *) dst;
  101. write_lock(&sk->sk_dst_lock);
  102. __sk_dst_set(sk, dst);
  103. np->daddr_cache = daddr;
  104. np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
  105. write_unlock(&sk->sk_dst_lock);
  106. }
  107. static inline int ipv6_unicast_destination(struct sk_buff *skb)
  108. {
  109. struct rt6_info *rt = (struct rt6_info *) skb->dst;
  110. return rt->rt6i_flags & RTF_LOCAL;
  111. }
  112. #endif
  113. #endif