1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00

netlink: add typesafe netlink functions

This commit is contained in:
Yu Watanabe 2018-11-29 01:05:32 +09:00
parent 1e26b1dfc7
commit 3365841384

View File

@ -38,3 +38,23 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
int rtnl_log_parse_error(int r);
int rtnl_log_create_error(int r);
#define netlink_call_async(nl, ret_slot, message, callback, destroy_callback, userdata) \
({ \
int (*_callback_)(sd_netlink *, sd_netlink_message *, typeof(userdata)) = callback; \
void (*_destroy_)(typeof(userdata)) = destroy_callback; \
sd_netlink_call_async(nl, ret_slot, message, \
(sd_netlink_message_handler_t) _callback_, \
(sd_netlink_destroy_t) _destroy_, \
userdata, 0, __func__); \
})
#define netlink_add_match(nl, ret_slot, metch, callback, destroy_callback, userdata) \
({ \
int (*_callback_)(sd_netlink *, sd_netlink_message *, typeof(userdata)) = callback; \
void (*_destroy_)(typeof(userdata)) = destroy_callback; \
sd_netlink_add_match(nl, ret_slot, match, \
(sd_netlink_message_handler_t) _callback_, \
(sd_netlink_destroy_t) _destroy_, \
userdata, __func__); \
})