1 #ifndef _NDISC_H
2 #define _NDISC_H
3
4 /*
5 * ICMP codes for neighbour discovery messages
6 */
7
8 #define NDISC_ROUTER_SOLICITATION 133
9 #define NDISC_ROUTER_ADVERTISEMENT 134
10 #define NDISC_NEIGHBOUR_SOLICITATION 135
11 #define NDISC_NEIGHBOUR_ADVERTISEMENT 136
12 #define NDISC_REDIRECT 137
13
14 /*
15 * ndisc options
16 */
17
18 #define ND_OPT_SOURCE_LL_ADDR 1
19 #define ND_OPT_TARGET_LL_ADDR 2
20 #define ND_OPT_PREFIX_INFO 3
21 #define ND_OPT_REDIRECT_HDR 4
22 #define ND_OPT_MTU 5
23
24 #define MAX_RTR_SOLICITATION_DELAY HZ
25
26 #define ND_REACHABLE_TIME (30*HZ)
27 #define ND_RETRANS_TIMER HZ
28
29 #define ND_MIN_RANDOM_FACTOR (1/2)
30 #define ND_MAX_RANDOM_FACTOR (3/2)
31
32 #ifdef __KERNEL__
33
34 #include <linux/skbuff.h>
35 #include <linux/netdevice.h>
36 #include <linux/icmpv6.h>
37 #include <net/neighbour.h>
38 #include <asm/atomic.h>
39
40 extern struct neigh_table nd_tbl;
41
42 struct nd_msg {
43 struct icmp6hdr icmph;
44 struct in6_addr target;
45 __u8 opt[0];
46 };
47
48 struct ra_msg {
49 struct icmp6hdr icmph;
50 __u32 reachable_time;
51 __u32 retrans_timer;
52 };
53
54 struct nd_opt_hdr {
55 __u8 nd_opt_type;
56 __u8 nd_opt_len;
57 } __attribute__((__packed__));
58
59 struct ndisc_options {
60 struct nd_opt_hdr *nd_opt_array[7];
61 struct nd_opt_hdr *nd_opt_piend;
62 };
63
64 #define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR]
65 #define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR]
66 #define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO]
67 #define nd_opts_pi_end nd_opt_piend
68 #define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR]
69 #define nd_opts_mtu nd_opt_array[ND_OPT_MTU]
70
71 extern struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur, struct nd_opt_hdr *end);
72 extern struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, struct ndisc_options *ndopts);
73
74 extern int ndisc_init(struct net_proto_family *ops);
75
76 extern void ndisc_cleanup(void);
77
78 extern int ndisc_rcv(struct sk_buff *skb);
79
80 extern void ndisc_send_ns(struct net_device *dev,
81 struct neighbour *neigh,
82 struct in6_addr *solicit,
83 struct in6_addr *daddr,
84 struct in6_addr *saddr);
85
86 extern void ndisc_send_rs(struct net_device *dev,
87 struct in6_addr *saddr,
88 struct in6_addr *daddr);
89
90 extern void ndisc_forwarding_on(void);
91 extern void ndisc_forwarding_off(void);
92
93 extern void ndisc_send_redirect(struct sk_buff *skb,
94 struct neighbour *neigh,
95 struct in6_addr *target);
96
97 extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir);
98
99
100 struct rt6_info * dflt_rt_lookup(void);
101
102 /*
103 * IGMP
104 */
105 extern int igmp6_init(struct net_proto_family *ops);
106
107 extern void igmp6_cleanup(void);
108
109 extern int igmp6_event_query(struct sk_buff *skb);
110
111 extern int igmp6_event_report(struct sk_buff *skb);
112
113 extern void igmp6_cleanup(void);
114
ndisc_get_neigh(struct net_device * dev,struct in6_addr * addr)115 static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, struct in6_addr *addr)
116 {
117
118 if (dev)
119 return __neigh_lookup(&nd_tbl, addr, dev, 1);
120
121 return NULL;
122 }
123
124
125 #endif /* __KERNEL__ */
126
127
128 #endif
129