@@ -13,6 +13,10 @@ struct mnlu_gen_socket {
int mnlu_gen_socket_open(struct mnlu_gen_socket *nlg, const char *family_name,
uint8_t version);
void mnlu_gen_socket_close(struct mnlu_gen_socket *nlg);
+struct nlmsghdr *
+_mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
+ uint8_t cmd, uint16_t flags,
+ uint32_t id, uint8_t version);
struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
uint8_t cmd, uint16_t flags);
int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh,
@@ -23,5 +27,7 @@ struct nlmsghdr *mnlu_msg_prepare(void *buf, uint32_t nlmsg_type, uint16_t flags
void *extra_header, size_t extra_header_size);
int mnlu_socket_recv_run(struct mnl_socket *nl, unsigned int seq, void *buf, size_t buf_size,
mnl_cb_t cb, void *data);
+int mnlu_gen_socket_recv_run(struct mnlu_gen_socket *nlg, mnl_cb_t cb,
+ void *data);
#endif /* __MNL_UTILS_H__ */
@@ -196,19 +196,28 @@ void mnlu_gen_socket_close(struct mnlu_gen_socket *nlg)
free(nlg->buf);
}
-struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
- uint8_t cmd, uint16_t flags)
+struct nlmsghdr *
+_mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
+ uint8_t cmd, uint16_t flags,
+ uint32_t id, uint8_t version)
{
struct genlmsghdr hdr = {};
struct nlmsghdr *nlh;
hdr.cmd = cmd;
- hdr.version = nlg->version;
- nlh = mnlu_msg_prepare(nlg->buf, nlg->family, flags, &hdr, sizeof(hdr));
+ hdr.version = version;
+ nlh = mnlu_msg_prepare(nlg->buf, id, flags, &hdr, sizeof(hdr));
nlg->seq = nlh->nlmsg_seq;
return nlh;
}
+struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
+ uint8_t cmd, uint16_t flags)
+{
+ return _mnlu_gen_socket_cmd_prepare(nlg, cmd, flags, nlg->family,
+ nlg->version);
+}
+
int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh,
mnl_cb_t data_cb, void *data)
{
@@ -229,3 +238,11 @@ int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *n
}
return 0;
}
+
+int mnlu_gen_socket_recv_run(struct mnlu_gen_socket *nlg, mnl_cb_t cb,
+ void *data)
+{
+ return mnlu_socket_recv_run(nlg->nl, nlg->seq, nlg->buf,
+ MNL_SOCKET_BUFFER_SIZE,
+ cb, data);
+}