Commit c558e9fc authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller

ndisc: Move ndisc_opt_addr_space() to include/net/ndisc.h.

This also makes ndisc_opt_addr_data() and ndisc_fill_addr_option()
use ndisc_opt_addr_space().
Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 315ff09d
...@@ -127,13 +127,19 @@ static int ndisc_addr_option_pad(unsigned short type) ...@@ -127,13 +127,19 @@ static int ndisc_addr_option_pad(unsigned short type)
} }
} }
static inline int ndisc_opt_addr_space(struct net_device *dev)
{
return NDISC_OPT_SPACE(dev->addr_len +
ndisc_addr_option_pad(dev->type));
}
static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p, static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
struct net_device *dev) struct net_device *dev)
{ {
u8 *lladdr = (u8 *)(p + 1); u8 *lladdr = (u8 *)(p + 1);
int lladdrlen = p->nd_opt_len << 3; int lladdrlen = p->nd_opt_len << 3;
int prepad = ndisc_addr_option_pad(dev->type); int prepad = ndisc_addr_option_pad(dev->type);
if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len + prepad)) if (lladdrlen != ndisc_opt_addr_space(dev))
return NULL; return NULL;
return lladdr + prepad; return lladdr + prepad;
} }
......
...@@ -143,17 +143,12 @@ struct neigh_table nd_tbl = { ...@@ -143,17 +143,12 @@ struct neigh_table nd_tbl = {
.gc_thresh3 = 1024, .gc_thresh3 = 1024,
}; };
static inline int ndisc_opt_addr_space(struct net_device *dev)
{
return NDISC_OPT_SPACE(dev->addr_len + ndisc_addr_option_pad(dev->type));
}
static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data, static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data,
struct net_device *dev) struct net_device *dev)
{ {
int pad = ndisc_addr_option_pad(dev->type); int pad = ndisc_addr_option_pad(dev->type);
int data_len = dev->addr_len; int data_len = dev->addr_len;
int space = NDISC_OPT_SPACE(data_len + pad); int space = ndisc_opt_addr_space(dev);
opt[0] = type; opt[0] = type;
opt[1] = space>>3; opt[1] = space>>3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment