+static int netlink_message_parse(sd_netlink_message *m,
+ size_t **rta_offset_tb,
+ unsigned short *rta_tb_size,
+ int count,
+ struct rtattr *rta,
+ unsigned int rt_len) {
+ unsigned short type;
+ size_t *tb;
+
+ tb = new0(size_t, count);
+ if(!tb)
+ return -ENOMEM;
+
+ *rta_tb_size = count;
+
+ for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
+ type = RTA_TYPE(rta);
+
+ /* if the kernel is newer than the headers we used
+ when building, we ignore out-of-range attributes
+ */
+ if (type >= count)
+ continue;
+
+ if (tb[type])
+ log_debug("rtnl: message parse - overwriting repeated attribute");
+
+ tb[type] = (uint8_t *) rta - (uint8_t *) m->hdr;
+ }
+
+ *rta_offset_tb = tb;
+
+ return 0;
+}
+