@@ -47,3 +47,5 @@ bool netlink_parse_ext_ack_error(const struct nlmsghdr *nlmsg,
uint32_t *out_error_offset);
int netlink_message_reserve_header(struct l_netlink_message *message,
size_t header_len, void **out_header);
+struct l_netlink_message *netlink_message_from_nlmsg(
+ const struct nlmsghdr *nlmsg);
@@ -781,6 +781,17 @@ LIB_EXPORT struct l_netlink_message *l_netlink_message_new(uint16_t type,
return l_netlink_message_new_sized(type, flags, 256 - NLMSG_HDRLEN);
}
+struct l_netlink_message *netlink_message_from_nlmsg(
+ const struct nlmsghdr *nlmsg)
+{
+ struct l_netlink_message *message = l_new(struct l_netlink_message, 1);
+
+ message->hdr = l_memdup(nlmsg, nlmsg->nlmsg_len);
+ message->size = nlmsg->nlmsg_len;
+
+ return l_netlink_message_ref(message);
+}
+
LIB_EXPORT struct l_netlink_message *l_netlink_message_ref(
struct l_netlink_message *message)
{