rtnl-types.c revision 86bbe5bfbc0bf213e9d3fafbe6c64d59b9fc90ea
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stddef.h>
#include <stdint.h>
#include <linux/rtnetlink.h>
#include <linux/if_bridge.h>
#include <linux/if_tunnel.h>
#include "macro.h"
#include "util.h"
#include "rtnl-types.h"
#include "missing.h"
static const NLTypeSystem rtnl_link_type_system;
[VETH_INFO_PEER] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
};
};
/*
[IFLA_BRIDGE_VLAN_INFO] = { .type = NLA_BINARY,
.len = sizeof(struct bridge_vlan_info), },
*/
};
/*
[IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
[IFLA_VLAN_EGRESS_QOS] = { .type = NLA_NESTED },
[IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED },
*/
};
};
#ifdef IFLA_BOND_MIIMON
/*
[IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED },
*/
/*
[IFLA_BOND_AD_INFO] = { .type = NLA_NESTED },
*/
#endif
};
};
};
};
/* these strings must match the .kind entries in the kernel */
static const char* const nl_union_link_info_data_table[_NL_UNION_LINK_INFO_DATA_MAX] = {
[NL_UNION_LINK_INFO_DATA_BOND] = "bond",
[NL_UNION_LINK_INFO_DATA_BRIDGE] = "bridge",
[NL_UNION_LINK_INFO_DATA_VLAN] = "vlan",
[NL_UNION_LINK_INFO_DATA_VETH] = "veth",
[NL_UNION_LINK_INFO_DATA_DUMMY] = "dummy",
[NL_UNION_LINK_INFO_DATA_MACVLAN] = "macvlan",
[NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan",
[NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip",
[NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre",
[NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = "sit",
[NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = "vti",
};
};
static const NLTypeSystemUnion rtnl_link_info_data_type_system_union = {
.match = IFLA_INFO_KIND,
};
[IFLA_INFO_DATA] = { .type = NLA_UNION, .type_system_union = &rtnl_link_info_data_type_system_union},
/*
[IFLA_INFO_XSTATS],
[IFLA_INFO_SLAVE_KIND] = { .type = NLA_STRING },
[IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED },
*/
};
static const NLTypeSystem rtnl_link_info_type_system = {
};
/*
[IFLA_QDISC],
[IFLA_STATS],
[IFLA_COST],
[IFLA_PRIORITY],
*/
/*
[IFLA_WIRELESS],
[IFLA_PROTINFO],
*/
/*
[IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
*/
/*
[IFLA_NUM_VF],
[IFLA_VFINFO_LIST] = {. type = NLA_NESTED, },
[IFLA_STATS64],
[IFLA_VF_PORTS] = { .type = NLA_NESTED },
[IFLA_PORT_SELF] = { .type = NLA_NESTED },
[IFLA_AF_SPEC] = { .type = NLA_NESTED },
[IFLA_VF_PORTS],
[IFLA_PORT_SELF],
[IFLA_AF_SPEC],
*/
/*
[IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
*/
};
static const NLTypeSystem rtnl_link_type_system = {
.types = rtnl_link_types,
};
/*
[IFA_ANYCAST],
[IFA_MULTICAST],
*/
#ifdef IFA_FLAGS
#endif
};
static const NLTypeSystem rtnl_address_type_system = {
};
/*
[RTA_METRICS] = { .type = NLA_NESTED },
[RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
*/
/*
RTA_CACHEINFO,
RTA_TABLE,
RTA_MARK,
RTA_MFC_STATS,
*/
};
static const NLTypeSystem rtnl_route_type_system = {
};
[RTM_NEWLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
[RTM_DELLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
[RTM_GETLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
[RTM_SETLINK] = { .type = NLA_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
[RTM_NEWADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
[RTM_DELADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
[RTM_GETADDR] = { .type = NLA_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) },
[RTM_NEWROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
[RTM_DELROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
[RTM_GETROUTE] = { .type = NLA_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) },
};
const NLTypeSystem rtnl_type_system = {
.types = rtnl_types,
};
if (!type_system)
return -ENOTSUP;
return -ENOTSUP;
return 0;
}
int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type) {
int r;
if (r < 0)
return r;
return 0;
}
int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type) {
int r;
if (r < 0)
return r;
return 0;
}
int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key) {
int type;
if (type < 0)
return -ENOTSUP;
return 0;
}