diff options
author | Tom Gundersen <teg@jklm.no> | 2013-11-13 23:18:20 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-11-14 14:32:48 +0100 |
commit | e16bcf986e3e2da2e01afc96f264edfc7bb00d1a (patch) | |
tree | b6908953b2fe630af11e53480eb405054e296634 /src/libsystemd-rtnl/rtnl-message.c | |
parent | 24710f6d2fbe25282fd96a8f869b7e4a9c3b50d8 (diff) |
rtnl: add call_async and call_async_cancel
They work in the same way as the sd-bus equivalents.
Diffstat (limited to 'src/libsystemd-rtnl/rtnl-message.c')
-rw-r--r-- | src/libsystemd-rtnl/rtnl-message.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libsystemd-rtnl/rtnl-message.c b/src/libsystemd-rtnl/rtnl-message.c index f7ff0a0148..1ce6862668 100644 --- a/src/libsystemd-rtnl/rtnl-message.c +++ b/src/libsystemd-rtnl/rtnl-message.c @@ -68,6 +68,27 @@ static int message_new(sd_rtnl_message **ret, size_t initial_size) { return 0; } +int message_new_synthetic_error(int error, uint32_t serial, sd_rtnl_message **ret) { + struct nlmsgerr *err; + int r; + + assert(error <= 0); + + r = message_new(ret, NLMSG_SPACE(sizeof(struct nlmsgerr))); + if (r < 0) + return r; + + (*ret)->hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct nlmsgerr)); + (*ret)->hdr->nlmsg_type = NLMSG_ERROR; + (*ret)->hdr->nlmsg_seq = serial; + + err = NLMSG_DATA((*ret)->hdr); + + err->error = error; + + return 0; +} + int sd_rtnl_message_route_new(uint16_t nlmsg_type, unsigned char rtm_family, unsigned char rtm_dst_len, unsigned char rtm_src_len, unsigned char rtm_tos, unsigned char rtm_table, @@ -373,10 +394,10 @@ uint32_t message_get_serial(sd_rtnl_message *m) { return m->hdr->nlmsg_seq; } -int message_get_errno(sd_rtnl_message *m) { +int sd_rtnl_message_get_errno(sd_rtnl_message *m) { struct nlmsgerr *err; - assert(m); + assert_return(m, -EINVAL); if (m->hdr->nlmsg_type != NLMSG_ERROR) return 0; |