Import patch ipxfrm-20040707_2.diff
(Logical change 1.53)
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 4beeca6..cb67a20 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -30,13 +30,13 @@
close(rth->fd);
}
-int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
+int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol)
{
int addr_len;
memset(rth, 0, sizeof(rth));
- rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ rth->fd = socket(AF_NETLINK, SOCK_RAW, protocol);
if (rth->fd < 0) {
perror("Cannot open netlink socket");
return -1;
@@ -67,6 +67,11 @@
return 0;
}
+int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
+{
+ return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
+}
+
int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
{
struct {
@@ -521,3 +526,16 @@
fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len);
return 0;
}
+
+int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len)
+{
+ int i = 0;
+ while (RTA_OK(rta, len)) {
+ if (rta->rta_type <= max)
+ tb[i++] = rta;
+ rta = RTA_NEXT(rta,len);
+ }
+ if (len)
+ fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len);
+ return i;
+}