ip6_route.h 3.9 KB

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