summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Ciphery <brett.ciphery@windriver.com>2012-01-29 17:19:00 (GMT)
committerThomas Graf <tgraf@redhat.com>2012-01-30 11:54:29 (GMT)
commita39bb563ab8450d5463540384f4b8abca0d3755e (patch)
tree66460b8f733ef8f4578c7d496f0152db22388575
parent9cbcbca77d53c04dd1592e521c6c5d124acf681c (diff)
downloadlibnl-a39bb563ab8450d5463540384f4b8abca0d3755e.zip
libnl-a39bb563ab8450d5463540384f4b8abca0d3755e.tar.gz
libnl-a39bb563ab8450d5463540384f4b8abca0d3755e.tar.bz2
add new function to provide neighbour event parsing
the neighbour parsing function was previously not accessible, so custom callback functions had to handle the decoding itself. rtnl_neigh_parse is introduced and implemented in much the same way as rtnl_route_parse. Signed-off-by: Brett Ciphery <brett.ciphery@windriver.com> Signed-off-by: Thomas Graf <tgraf@redhat.com>
-rw-r--r--include/netlink/route/neighbour.h2
-rw-r--r--lib/route/neigh.c19
2 files changed, 20 insertions, 1 deletions
diff --git a/include/netlink/route/neighbour.h b/include/netlink/route/neighbour.h
index 698539a..1d1179b 100644
--- a/include/netlink/route/neighbour.h
+++ b/include/netlink/route/neighbour.h
@@ -29,6 +29,8 @@ extern int rtnl_neigh_alloc_cache(struct nl_sock *, struct nl_cache **);
extern struct rtnl_neigh *rtnl_neigh_get(struct nl_cache *, int,
struct nl_addr *);
+extern int rtnl_neigh_parse(struct nlmsghdr *, struct rtnl_neigh **);
+
extern char * rtnl_neigh_state2str(int, char *, size_t);
extern int rtnl_neigh_str2state(const char *);
diff --git a/lib/route/neigh.c b/lib/route/neigh.c
index 7985d34..bb61571 100644
--- a/lib/route/neigh.c
+++ b/lib/route/neigh.c
@@ -254,6 +254,21 @@ static int neigh_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
struct nlmsghdr *n, struct nl_parser_param *pp)
{
struct rtnl_neigh *neigh;
+ int err;
+
+ if ((err = rtnl_neigh_parse(n, &neigh)) < 0)
+ return err;
+
+ err = pp->pp_cb((struct nl_object *) neigh, pp);
+
+ rtnl_neigh_put(neigh);
+ return err;
+}
+
+
+int rtnl_neigh_parse(struct nlmsghdr *n, struct rtnl_neigh **result)
+{
+ struct rtnl_neigh *neigh;
struct nlattr *tb[NDA_MAX + 1];
struct ndmsg *nm;
int err;
@@ -317,7 +332,9 @@ static int neigh_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
neigh->ce_mask |= NEIGH_ATTR_PROBES;
}
- err = pp->pp_cb((struct nl_object *) neigh, pp);
+ *result = neigh;
+ return 0;
+
errout:
rtnl_neigh_put(neigh);
return err;