ip6_route.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef _NET_IP6_ROUTE_H
  2. #define _NET_IP6_ROUTE_H
  3. #define IP6_RT_PRIO_USER 1024
  4. #define IP6_RT_PRIO_ADDRCONF 256
  5. #define IP6_RT_PRIO_KERN 512
  6. struct route_info {
  7. __u8 type;
  8. __u8 length;
  9. __u8 prefix_len;
  10. #if defined(__BIG_ENDIAN_BITFIELD)
  11. __u8 reserved_h:3,
  12. route_pref:2,
  13. reserved_l:3;
  14. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  15. __u8 reserved_l:3,
  16. route_pref:2,
  17. reserved_h:3;
  18. #endif
  19. __be32 lifetime;
  20. __u8 prefix[0]; /* 0,8 or 16 */
  21. };
  22. #ifdef __KERNEL__
  23. #include <net/flow.h>
  24. #include <net/ip6_fib.h>
  25. #include <net/sock.h>
  26. #include <linux/ip.h>
  27. #include <linux/ipv6.h>
  28. #define RT6_LOOKUP_F_IFACE 0x00000001
  29. #define RT6_LOOKUP_F_REACHABLE 0x00000002
  30. #define RT6_LOOKUP_F_HAS_SADDR 0x00000004
  31. #define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008
  32. #define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
  33. #define RT6_LOOKUP_F_SRCPREF_COA 0x00000020
  34. extern void ip6_route_input(struct sk_buff *skb);
  35. extern struct dst_entry * ip6_route_output(struct net *net,
  36. struct sock *sk,
  37. struct flowi *fl);
  38. extern int ip6_route_init(void);
  39. extern void ip6_route_cleanup(void);
  40. extern int ipv6_route_ioctl(struct net *net,
  41. unsigned int cmd,
  42. void __user *arg);
  43. extern int ip6_route_add(struct fib6_config *cfg);
  44. extern int ip6_ins_rt(struct rt6_info *);
  45. extern int ip6_del_rt(struct rt6_info *);
  46. extern struct rt6_info *rt6_lookup(struct net *net,
  47. const struct in6_addr *daddr,
  48. const struct in6_addr *saddr,
  49. int oif, int flags);
  50. extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
  51. struct neighbour *neigh,
  52. const struct in6_addr *addr);
  53. extern int icmp6_dst_gc(void);
  54. extern void fib6_force_start_gc(struct net *net);
  55. extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
  56. const struct in6_addr *addr,
  57. int anycast);
  58. extern int ip6_dst_hoplimit(struct dst_entry *dst);
  59. /*
  60. * support functions for ND
  61. *
  62. */
  63. extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr,
  64. struct net_device *dev);
  65. extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
  66. struct net_device *dev,
  67. unsigned int pref);
  68. extern void rt6_purge_dflt_routers(struct net *net);
  69. extern int rt6_route_rcv(struct net_device *dev,
  70. u8 *opt, int len,
  71. struct in6_addr *gwaddr);
  72. extern void rt6_redirect(struct in6_addr *dest,
  73. struct in6_addr *src,
  74. struct in6_addr *saddr,
  75. struct neighbour *neigh,
  76. u8 *lladdr,
  77. int on_link);
  78. extern void rt6_pmtu_discovery(struct in6_addr *daddr,
  79. struct in6_addr *saddr,
  80. struct net_device *dev,
  81. u32 pmtu);
  82. struct netlink_callback;
  83. struct rt6_rtnl_dump_arg
  84. {
  85. struct sk_buff *skb;
  86. struct netlink_callback *cb;
  87. struct net *net;
  88. };
  89. extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
  90. extern void rt6_ifdown(struct net *net, struct net_device *dev);
  91. extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
  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, struct in6_addr *saddr)
  97. {
  98. struct ipv6_pinfo *np = inet6_sk(sk);
  99. struct rt6_info *rt = (struct rt6_info *) dst;
  100. sk_setup_caps(sk, dst);
  101. np->daddr_cache = daddr;
  102. #ifdef CONFIG_IPV6_SUBTREES
  103. np->saddr_cache = saddr;
  104. #endif
  105. np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
  106. }
  107. static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
  108. struct in6_addr *daddr, struct in6_addr *saddr)
  109. {
  110. write_lock(&sk->sk_dst_lock);
  111. __ip6_dst_store(sk, dst, daddr, saddr);
  112. write_unlock(&sk->sk_dst_lock);
  113. }
  114. static inline int ipv6_unicast_destination(struct sk_buff *skb)
  115. {
  116. struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
  117. return rt->rt6i_flags & RTF_LOCAL;
  118. }
  119. #endif
  120. #endif