summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl/rtnl-message.c
diff options
context:
space:
mode:
authorSusant Sahani <susant@redhat.com>2014-03-07 20:38:02 +0530
committerTom Gundersen <teg@jklm.no>2014-03-07 17:39:04 +0100
commit4e9e7f1836b0c8f612f2beb3447d6144f9244d26 (patch)
treeca2332f80683c69d3ce01cb31ff90b79397089c9 /src/libsystemd/sd-rtnl/rtnl-message.c
parentb2cdc6664ef6b56e47d38649d69b9943d9f9f5d0 (diff)
sd-rtnl: introduce read ether and ip address functions
This patch introduces reading ethernet address and IPV4/IPv6 as well which is based on table based look up. [tomegun: rename read_ether() to read_ether_addr() to match the append function.]
Diffstat (limited to 'src/libsystemd/sd-rtnl/rtnl-message.c')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index dd3a8fb1d2..fca1ff667a 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -876,6 +876,51 @@ int sd_rtnl_message_read_u32(sd_rtnl_message *m, unsigned short type, uint32_t *
return 0;
}
+int sd_rtnl_message_read_ether_addr(sd_rtnl_message *m, unsigned short type, struct ether_addr *data) {
+ int r;
+ void *attr_data;
+
+ assert_return(data, -EINVAL);
+
+ r = rtnl_message_read_internal(m, type, &attr_data);
+ if(r < 0)
+ return r;
+
+ memcpy(data, attr_data, sizeof(struct ether_addr));
+
+ return 0;
+}
+
+int sd_rtnl_message_read_in_addr(sd_rtnl_message *m, unsigned short type, struct in_addr *data) {
+ int r;
+ void *attr_data;
+
+ assert_return(data, -EINVAL);
+
+ r = rtnl_message_read_internal(m, type, &attr_data);
+ if(r < 0)
+ return r;
+
+ memcpy(data, attr_data, sizeof(struct in_addr));
+
+ return 0;
+}
+
+int sd_rtnl_message_read_in6_addr(sd_rtnl_message *m, unsigned short type, struct in6_addr *data) {
+ int r;
+ void *attr_data;
+
+ assert_return(data, -EINVAL);
+
+ r = rtnl_message_read_internal(m, type, &attr_data);
+ if(r < 0)
+ return r;
+
+ memcpy(data, attr_data, sizeof(struct in6_addr));
+
+ return 0;
+}
+
int sd_rtnl_message_exit_container(sd_rtnl_message *m) {
assert_return(m, -EINVAL);
assert_return(m->sealed, -EINVAL);