Explicitly export the root type-system to the type-system callers. This
avoids treating NULL as root, which for one really looks backwards (NULL
is usually a leaf, not root), and secondly prevents us from properly
debugging calling into non-nested types.
Also rename the root to "type_system_root". Once we support more than
rtnl, well will have to revisit that, anyway.
size_t size;
int r;
- r = type_system_get_type(NULL, &nl_type, type);
+ r = type_system_get_type(&type_system_root, &nl_type, type);
if (r < 0)
return r;
assert(m->hdr);
- r = type_system_get_type(NULL, &nl_type, m->hdr->nlmsg_type);
+ r = type_system_get_type(&type_system_root, &nl_type, m->hdr->nlmsg_type);
if (r < 0)
return r;
[RTM_GETNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) },
};
-const NLTypeSystem rtnl_type_system = {
+const NLTypeSystem type_system_root = {
.count = ELEMENTSOF(rtnl_types),
.types = rtnl_types,
};
const NLType *nl_type;
assert(ret);
-
- if (!type_system)
- type_system = &rtnl_type_system;
-
+ assert(type_system);
assert(type_system->types);
if (type >= type_system->count)
const NLTypeSystem *type_systems;
};
+extern const NLTypeSystem type_system_root;
+
uint16_t type_get_type(const NLType *type);
size_t type_get_size(const NLType *type);
void type_get_type_system(const NLType *type, const NLTypeSystem **ret);