From 44caa5e7dfa2160f7d644d003de2718fd3ca2ee6 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Wed, 5 Mar 2014 20:43:25 +0530 Subject: sd-rtnl:introduce table-based lookup and typesafe read() functions This patch introduces new netlink attribute parsing logic which is table based lookup and sd_rtnl_message_read_* methods for reading attributes. By doing this user does not have to loop for the attribute values . Only providing the attribute type it gets the attribute values which is optimized and sd_rtnl_message_read_* methods are simplified. --- src/libsystemd/sd-rtnl/rtnl-internal.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/libsystemd/sd-rtnl/rtnl-internal.h') diff --git a/src/libsystemd/sd-rtnl/rtnl-internal.h b/src/libsystemd/sd-rtnl/rtnl-internal.h index 0667be5838..0c17d94c59 100644 --- a/src/libsystemd/sd-rtnl/rtnl-internal.h +++ b/src/libsystemd/sd-rtnl/rtnl-internal.h @@ -94,7 +94,8 @@ struct sd_rtnl_message { size_t container_offsets[RTNL_CONTAINER_DEPTH]; /* offset from hdr to each container's start */ unsigned n_containers; /* number of containers */ size_t next_rta_offset; /* offset from hdr to next rta */ - + size_t *rta_offset_tb; + unsigned short rta_tb_size; bool sealed:1; }; @@ -103,6 +104,14 @@ int message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, size_t initial_size); int socket_write_message(sd_rtnl *nl, sd_rtnl_message *m); int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret); +int rtnl_message_read_internal(sd_rtnl_message *m, unsigned short type, void **data); +int rtnl_message_parse(sd_rtnl_message *m, + size_t **rta_offset_tb, + unsigned short *rta_tb_size, + int max, + struct rtattr *rta, + unsigned int rt_len); + /* Make sure callbacks don't destroy the rtnl connection */ #define RTNL_DONT_DESTROY(rtnl) \ _cleanup_rtnl_unref_ _unused_ sd_rtnl *_dont_destroy_##rtnl = sd_rtnl_ref(rtnl) -- cgit v1.2.3-54-g00ecf