diff options
author | Susant Sahani <susant@redhat.com> | 2014-03-07 20:38:02 +0530 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-07 17:39:04 +0100 |
commit | 4e9e7f1836b0c8f612f2beb3447d6144f9244d26 (patch) | |
tree | ca2332f80683c69d3ce01cb31ff90b79397089c9 /src/libsystemd/sd-rtnl/rtnl-message.c | |
parent | b2cdc6664ef6b56e47d38649d69b9943d9f9f5d0 (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.c | 45 |
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); |