Make nl.c:nl_rtattr_parse() use the standard NLMSG_* and RTA_* macros.
It's easier to verify correct behavior this way.
This commit is contained in:
parent
268e88dc24
commit
8416d5a633
11
ndhc/nl.c
11
ndhc/nl.c
@ -81,13 +81,10 @@ void nl_attr_parse(const struct nlmsghdr *nlh, size_t offset,
|
|||||||
void nl_rtattr_parse(const struct nlmsghdr *nlh, size_t offset,
|
void nl_rtattr_parse(const struct nlmsghdr *nlh, size_t offset,
|
||||||
nl_rtattr_parse_fn workfn, void *data)
|
nl_rtattr_parse_fn workfn, void *data)
|
||||||
{
|
{
|
||||||
struct rtattr *attr;
|
struct rtattr *attr =
|
||||||
for (attr = (struct rtattr *)
|
(struct rtattr *)((char *)NLMSG_DATA(nlh) + NLMSG_ALIGN(offset));
|
||||||
((char *)nlh + NLMSG_HDRLEN + NLMSG_ALIGN(offset));
|
size_t rtlen = nlh->nlmsg_len - NLMSG_HDRLEN - NLMSG_ALIGN(offset);
|
||||||
rtattr_ok(attr, (char *)nlh + NLMSG_ALIGN(nlh->nlmsg_len) -
|
for (; RTA_OK(attr, rtlen); attr = RTA_NEXT(attr, rtlen)) {
|
||||||
(char *)attr);
|
|
||||||
attr = (struct rtattr *)((char *)attr + NLMSG_ALIGN(attr->rta_len)))
|
|
||||||
{
|
|
||||||
if (workfn(attr, attr->rta_type, data) < 0)
|
if (workfn(attr, attr->rta_type, data) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,6 @@ static inline int nl_attr_ok(const struct nlattr *attr, size_t len)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int rtattr_ok(const struct rtattr *attr, size_t len)
|
|
||||||
{
|
|
||||||
return RTA_OK(attr, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline size_t nlattr_get_len(const struct nlattr *attr)
|
static inline size_t nlattr_get_len(const struct nlattr *attr)
|
||||||
{
|
{
|
||||||
return attr->nla_len;
|
return attr->nla_len;
|
||||||
|
Loading…
Reference in New Issue
Block a user