diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-12 02:26:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-12 02:39:11 -0400 |
commit | 30f2a5f379d0b4b4e733df138a49e054ebf75ff8 (patch) | |
tree | ddd818a29e28e49b1916d3e9dba62c1272912f5f /include/net/ndisc.h | |
parent | 1f42539d257af671d56d4bdbcf13aef31abff6ef (diff) |
ipv6: Export ndisc option parsing from ndisc.c
This is going to be used internally by the rt6 redirect code.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ndisc.h')
-rw-r--r-- | include/net/ndisc.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/include/net/ndisc.h b/include/net/ndisc.h index c02b6ad3f6c5..96a3b5c03e37 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h | |||
@@ -47,6 +47,8 @@ enum { | |||
47 | #include <linux/icmpv6.h> | 47 | #include <linux/icmpv6.h> |
48 | #include <linux/in6.h> | 48 | #include <linux/in6.h> |
49 | #include <linux/types.h> | 49 | #include <linux/types.h> |
50 | #include <linux/if_arp.h> | ||
51 | #include <linux/netdevice.h> | ||
50 | 52 | ||
51 | #include <net/neighbour.h> | 53 | #include <net/neighbour.h> |
52 | 54 | ||
@@ -80,6 +82,54 @@ struct nd_opt_hdr { | |||
80 | __u8 nd_opt_len; | 82 | __u8 nd_opt_len; |
81 | } __packed; | 83 | } __packed; |
82 | 84 | ||
85 | /* ND options */ | ||
86 | struct ndisc_options { | ||
87 | struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX]; | ||
88 | #ifdef CONFIG_IPV6_ROUTE_INFO | ||
89 | struct nd_opt_hdr *nd_opts_ri; | ||
90 | struct nd_opt_hdr *nd_opts_ri_end; | ||
91 | #endif | ||
92 | struct nd_opt_hdr *nd_useropts; | ||
93 | struct nd_opt_hdr *nd_useropts_end; | ||
94 | }; | ||
95 | |||
96 | #define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR] | ||
97 | #define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR] | ||
98 | #define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO] | ||
99 | #define nd_opts_pi_end nd_opt_array[__ND_OPT_PREFIX_INFO_END] | ||
100 | #define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR] | ||
101 | #define nd_opts_mtu nd_opt_array[ND_OPT_MTU] | ||
102 | |||
103 | #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7) | ||
104 | |||
105 | extern struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, | ||
106 | struct ndisc_options *ndopts); | ||
107 | |||
108 | /* | ||
109 | * Return the padding between the option length and the start of the | ||
110 | * link addr. Currently only IP-over-InfiniBand needs this, although | ||
111 | * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may | ||
112 | * also need a pad of 2. | ||
113 | */ | ||
114 | static int ndisc_addr_option_pad(unsigned short type) | ||
115 | { | ||
116 | switch (type) { | ||
117 | case ARPHRD_INFINIBAND: return 2; | ||
118 | default: return 0; | ||
119 | } | ||
120 | } | ||
121 | |||
122 | static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p, | ||
123 | struct net_device *dev) | ||
124 | { | ||
125 | u8 *lladdr = (u8 *)(p + 1); | ||
126 | int lladdrlen = p->nd_opt_len << 3; | ||
127 | int prepad = ndisc_addr_option_pad(dev->type); | ||
128 | if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len + prepad)) | ||
129 | return NULL; | ||
130 | return lladdr + prepad; | ||
131 | } | ||
132 | |||
83 | static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, __u32 *hash_rnd) | 133 | static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, __u32 *hash_rnd) |
84 | { | 134 | { |
85 | const u32 *p32 = pkey; | 135 | const u32 *p32 = pkey; |