summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@redhat.com>2014-02-04 14:19:20 +0530
committerTom Gundersen <teg@jklm.no>2014-02-05 00:07:29 +0100
commit7b1796403ae1ed0c3299867874cc82ed3ed413a6 (patch)
treebd2a5a3bf9699e89a6dd003b527d99c70b53510a /src
parentd002827b03d78e31503a6b706ad4b4049ebf9a07 (diff)
Added attribute support for sd-rtnl
Added sd_rtnl_message_append_u8 and few attribute support in sd_rtnl_message_append_u32 IFLA_GROUP, IFLA_TXQLEN, IFLA_NUM_TX_QUEUES, IFLA_NUM_RX_QUEUES
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c42
-rw-r--r--src/systemd/sd-rtnl.h1
2 files changed, 43 insertions, 0 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 87ad68234..39ef25ef9 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -410,6 +410,44 @@ int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const
return 0;
}
+int sd_rtnl_message_append_u8(sd_rtnl_message *m, unsigned short type, uint8_t data) {
+ uint16_t rtm_type;
+ int r;
+
+ assert_return(m, -EINVAL);
+ assert_return(!m->sealed, -EPERM);
+
+ r = sd_rtnl_message_get_type(m, &rtm_type);
+ if (r < 0)
+ return r;
+
+ switch (rtm_type) {
+ case RTM_NEWLINK:
+ case RTM_SETLINK:
+ case RTM_GETLINK:
+ case RTM_DELLINK:
+ switch (type) {
+ case IFLA_CARRIER:
+ case IFLA_OPERSTATE:
+ case IFLA_LINKMODE:
+ break;
+ default:
+ return -ENOTSUP;
+ }
+
+ break;
+ default:
+ return -ENOTSUP;
+ }
+
+ r = add_rtattr(m, type, &data, sizeof(uint8_t));
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+
int sd_rtnl_message_append_u16(sd_rtnl_message *m, unsigned short type, uint16_t data) {
uint16_t rtm_type;
int r;
@@ -467,6 +505,10 @@ int sd_rtnl_message_append_u32(sd_rtnl_message *m, unsigned short type, uint32_t
case IFLA_MASTER:
case IFLA_MTU:
case IFLA_LINK:
+ case IFLA_GROUP:
+ case IFLA_TXQLEN:
+ case IFLA_NUM_TX_QUEUES:
+ case IFLA_NUM_RX_QUEUES:
break;
default:
return -ENOTSUP;
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index c54533392..c162878e4 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -95,6 +95,7 @@ int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags);
int sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char prefixlen);
int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const char *data);
+int sd_rtnl_message_append_u8(sd_rtnl_message *m, unsigned short type, uint8_t data);
int sd_rtnl_message_append_u16(sd_rtnl_message *m, unsigned short type, uint16_t data);
int sd_rtnl_message_append_u32(sd_rtnl_message *m, unsigned short type, uint32_t data);
int sd_rtnl_message_append_in_addr(sd_rtnl_message *m, unsigned short type, const struct in_addr *data);