ip6_route.h 4.3 KB

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