ndisc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #ifndef _NDISC_H
  2. #define _NDISC_H
  3. /*
  4. * ICMP codes for neighbour discovery messages
  5. */
  6. #define NDISC_ROUTER_SOLICITATION 133
  7. #define NDISC_ROUTER_ADVERTISEMENT 134
  8. #define NDISC_NEIGHBOUR_SOLICITATION 135
  9. #define NDISC_NEIGHBOUR_ADVERTISEMENT 136
  10. #define NDISC_REDIRECT 137
  11. /*
  12. * ndisc options
  13. */
  14. enum {
  15. __ND_OPT_PREFIX_INFO_END = 0,
  16. ND_OPT_SOURCE_LL_ADDR = 1, /* RFC2461 */
  17. ND_OPT_TARGET_LL_ADDR = 2, /* RFC2461 */
  18. ND_OPT_PREFIX_INFO = 3, /* RFC2461 */
  19. ND_OPT_REDIRECT_HDR = 4, /* RFC2461 */
  20. ND_OPT_MTU = 5, /* RFC2461 */
  21. __ND_OPT_MAX
  22. };
  23. #define MAX_RTR_SOLICITATION_DELAY HZ
  24. #define ND_REACHABLE_TIME (30*HZ)
  25. #define ND_RETRANS_TIMER HZ
  26. #define ND_MIN_RANDOM_FACTOR (1/2)
  27. #define ND_MAX_RANDOM_FACTOR (3/2)
  28. #ifdef __KERNEL__
  29. #include <linux/config.h>
  30. #include <linux/compiler.h>
  31. #include <linux/icmpv6.h>
  32. #include <linux/in6.h>
  33. #include <linux/types.h>
  34. #include <net/neighbour.h>
  35. struct ctl_table;
  36. struct file;
  37. struct inet6_dev;
  38. struct net_device;
  39. struct net_proto_family;
  40. struct sk_buff;
  41. extern struct neigh_table nd_tbl;
  42. struct nd_msg {
  43. struct icmp6hdr icmph;
  44. struct in6_addr target;
  45. __u8 opt[0];
  46. };
  47. struct rs_msg {
  48. struct icmp6hdr icmph;
  49. __u8 opt[0];
  50. };
  51. struct ra_msg {
  52. struct icmp6hdr icmph;
  53. __u32 reachable_time;
  54. __u32 retrans_timer;
  55. };
  56. struct nd_opt_hdr {
  57. __u8 nd_opt_type;
  58. __u8 nd_opt_len;
  59. } __attribute__((__packed__));
  60. extern int ndisc_init(struct net_proto_family *ops);
  61. extern void ndisc_cleanup(void);
  62. extern int ndisc_rcv(struct sk_buff *skb);
  63. extern void ndisc_send_ns(struct net_device *dev,
  64. struct neighbour *neigh,
  65. struct in6_addr *solicit,
  66. struct in6_addr *daddr,
  67. struct in6_addr *saddr);
  68. extern void ndisc_send_rs(struct net_device *dev,
  69. struct in6_addr *saddr,
  70. struct in6_addr *daddr);
  71. extern void ndisc_forwarding_on(void);
  72. extern void ndisc_forwarding_off(void);
  73. extern void ndisc_send_redirect(struct sk_buff *skb,
  74. struct neighbour *neigh,
  75. struct in6_addr *target);
  76. extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir);
  77. struct rt6_info * dflt_rt_lookup(void);
  78. /*
  79. * IGMP
  80. */
  81. extern int igmp6_init(struct net_proto_family *ops);
  82. extern void igmp6_cleanup(void);
  83. extern int igmp6_event_query(struct sk_buff *skb);
  84. extern int igmp6_event_report(struct sk_buff *skb);
  85. extern void igmp6_cleanup(void);
  86. #ifdef CONFIG_SYSCTL
  87. extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,
  88. int write,
  89. struct file * filp,
  90. void __user *buffer,
  91. size_t *lenp,
  92. loff_t *ppos);
  93. #endif
  94. extern void inet6_ifinfo_notify(int event,
  95. struct inet6_dev *idev);
  96. static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, struct in6_addr *addr)
  97. {
  98. if (dev)
  99. return __neigh_lookup(&nd_tbl, addr, dev, 1);
  100. return NULL;
  101. }
  102. #endif /* __KERNEL__ */
  103. #endif