chiark / gitweb /
sd-event: fix typo
[elogind.git] / src / libsystemd / sd-rtnl / rtnl-types.c
index 4ef698a7f5f19d57db623bcb74824fb40b79a2dd..557dc59455c8e5e3af7f9e1394242aa34ddd0836 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stddef.h>
 #include <stdint.h>
 #include <sys/socket.h>
 #include <linux/netlink.h>
@@ -265,6 +264,33 @@ static const NLTypeSystemUnion rtnl_prot_info_type_system_union = {
         .match_type = NL_MATCH_PROTOCOL,
 };
 
+static const struct NLType rtnl_af_spec_inet6_types[IFLA_INET6_MAX + 1] = {
+        [IFLA_INET6_FLAGS]              = { .type = NLA_U32 },
+/*
+        IFLA_INET6_CONF,
+        IFLA_INET6_STATS,
+        IFLA_INET6_MCAST,
+        IFLA_INET6_CACHEINFO,
+        IFLA_INET6_ICMP6STATS,
+*/
+        [IFLA_INET6_TOKEN]              = { .type = NLA_IN_ADDR },
+        [IFLA_INET6_ADDR_GEN_MODE]      = { .type = NLA_U8 },
+};
+
+static const NLTypeSystem rtnl_af_spec_inet6_type_system = {
+        .max = ELEMENTSOF(rtnl_af_spec_inet6_types) - 1,
+        .types = rtnl_af_spec_inet6_types,
+};
+
+static const NLType rtnl_af_spec_types[AF_MAX + 1] = {
+        [AF_INET6] =    { .type = NLA_NESTED, .type_system = &rtnl_af_spec_inet6_type_system },
+};
+
+static const NLTypeSystem rtnl_af_spec_type_system = {
+        .max = ELEMENTSOF(rtnl_af_spec_types) - 1,
+        .types = rtnl_af_spec_types,
+};
+
 static const NLType rtnl_link_types[IFLA_MAX + 1 ] = {
         [IFLA_ADDRESS]          = { .type = NLA_ETHER_ADDR, },
         [IFLA_BROADCAST]        = { .type = NLA_ETHER_ADDR, },
@@ -298,7 +324,9 @@ static const NLType rtnl_link_types[IFLA_MAX + 1 ] = {
         [IFLA_STATS64],
         [IFLA_VF_PORTS]         = { .type = NLA_NESTED },
         [IFLA_PORT_SELF]        = { .type = NLA_NESTED },
-        [IFLA_AF_SPEC]          = { .type = NLA_NESTED },
+*/
+        [IFLA_AF_SPEC]          = { .type = NLA_NESTED, .type_system = &rtnl_af_spec_type_system },
+/*
         [IFLA_VF_PORTS],
         [IFLA_PORT_SELF],
         [IFLA_AF_SPEC],
@@ -437,8 +465,7 @@ int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSys
         if (r < 0)
                 return r;
 
-        assert_return(nl_type->type == NLA_NESTED, -EINVAL);
-
+        assert(nl_type->type == NLA_NESTED);
         assert(nl_type->type_system);
 
         *ret = nl_type->type_system;
@@ -456,8 +483,7 @@ int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLT
         if (r < 0)
                 return r;
 
-        assert_return(nl_type->type == NLA_UNION, -EINVAL);
-
+        assert(nl_type->type == NLA_UNION);
         assert(nl_type->type_system_union);
 
         *ret = nl_type->type_system_union;
@@ -469,7 +495,7 @@ int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union
         int type;
 
         assert(type_system_union);
-        assert_return(type_system_union->match_type == NL_MATCH_SIBLING, -EINVAL);
+        assert(type_system_union->match_type == NL_MATCH_SIBLING);
         assert(type_system_union->lookup);
         assert(type_system_union->type_systems);
         assert(ret);
@@ -491,16 +517,14 @@ int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_sys
 
         assert(type_system_union);
         assert(type_system_union->type_systems);
+        assert(type_system_union->match_type == NL_MATCH_PROTOCOL);
         assert(ret);
-        assert_return(type_system_union->match_type == NL_MATCH_PROTOCOL, -EINVAL);
-        assert_return(protocol < type_system_union->num, -EINVAL);
 
         if (protocol >= type_system_union->num)
                 return -ENOTSUP;
 
         type_system = &type_system_union->type_systems[protocol];
-
-        if (!type_system)
+        if (type_system->max == 0)
                 return -ENOTSUP;
 
         *ret = type_system;