diff options
author | Tom Gundersen <teg@jklm.no> | 2014-03-26 19:25:01 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-28 19:11:59 +0100 |
commit | d8e538ecd9e62f841242f07e3df5c835c1ba6313 (patch) | |
tree | 0fba56485f73d01a985ed4afaff83cffa19068d2 /src/libsystemd/sd-rtnl/rtnl-internal.h | |
parent | 9f5bbfe354c52cd9e28cca32c35596b73e8d738b (diff) |
sd-rtnl: rework rtnl type system
Use a static table with all the typing information, rather than repeated
switch statements. This should make it a lot simpler to add new types.
We need to keep all the type info to be able to create containers
without exposing their implementation details to the users of the library.
As a freebee we verify the types of appended/read attributes.
The API is extended to nicely deal with unions of container types.
Diffstat (limited to 'src/libsystemd/sd-rtnl/rtnl-internal.h')
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-internal.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-internal.h b/src/libsystemd/sd-rtnl/rtnl-internal.h index 21a270aecd..8aa2300835 100644 --- a/src/libsystemd/sd-rtnl/rtnl-internal.h +++ b/src/libsystemd/sd-rtnl/rtnl-internal.h @@ -29,6 +29,8 @@ #include "sd-rtnl.h" +#include "rtnl-types.h" + #define RTNL_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC)) #define RTNL_WQUEUE_MAX 1024 @@ -91,6 +93,7 @@ struct sd_rtnl_message { sd_rtnl *rtnl; struct nlmsghdr *hdr; + const struct NLTypeSystem *(container_type_system[RTNL_CONTAINER_DEPTH]); /* the type of the container and all its parents */ 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 */ @@ -99,7 +102,7 @@ struct sd_rtnl_message { bool sealed:1; }; -int message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, size_t initial_size); +int message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t type); int socket_write_message(sd_rtnl *nl, sd_rtnl_message *m); int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret); |