summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-22 14:16:01 +0100
committerTom Gundersen <teg@jklm.no>2014-01-22 17:56:49 +0100
commit01b36069ccddbed35b82dd3b64af3e522ab305fe (patch)
treec07278e654a1a163d126a352470c109f7aabd5c3 /src/libsystemd/sd-rtnl
parent2c3d81d4a7e3888632537140aae57940159fb39e (diff)
sd-rtnl: add sd_rtnl_message_append_u16()
Diffstat (limited to 'src/libsystemd/sd-rtnl')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index af8f8cf762..d55c3673a3 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -404,6 +404,40 @@ int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const
return 0;
}
+int sd_rtnl_message_append_u16(sd_rtnl_message *m, unsigned short type, uint16_t data) {
+ uint16_t rtm_type;
+ int r;
+
+ assert_return(m, -EINVAL);
+
+ r = sd_rtnl_message_get_type(m, &rtm_type);
+ if (r < 0)
+ return r;
+
+ /* check that the type is correct */
+ switch (rtm_type) {
+ case RTM_NEWLINK:
+ case RTM_SETLINK:
+ case RTM_GETLINK:
+ case RTM_DELLINK:
+ switch (type) {
+ case IFLA_VLAN_ID:
+ break;
+ default:
+ return -ENOTSUP;
+ }
+ break;
+ default:
+ return -ENOTSUP;
+ }
+
+ r = add_rtattr(m, type, &data, sizeof(uint16_t));
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
int sd_rtnl_message_append_u32(sd_rtnl_message *m, unsigned short type, uint32_t data) {
uint16_t rtm_type;
int r;