17 #include <netlink-private/netlink.h>
18 #include <netlink/netlink.h>
19 #include <netlink/utils.h>
20 #include <netlink/route/rtnl.h>
41 struct rtgenmsg gmsg = {
42 .rtgen_family = family,
55 static const struct trans_tbl rtntypes[] = {
56 __ADD(RTN_UNSPEC,unspec)
57 __ADD(RTN_UNICAST,unicast)
58 __ADD(RTN_LOCAL,local)
59 __ADD(RTN_BROADCAST,broadcast)
60 __ADD(RTN_ANYCAST,anycast)
61 __ADD(RTN_MULTICAST,multicast)
62 __ADD(RTN_BLACKHOLE,blackhole)
63 __ADD(RTN_UNREACHABLE,unreachable)
64 __ADD(RTN_PROHIBIT,prohibit)
65 __ADD(RTN_THROW,throw)
67 __ADD(RTN_XRESOLVE,xresolve)
70 char *nl_rtntype2str(
int type,
char *buf,
size_t size)
72 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
75 int nl_str2rtntype(
const char *name)
77 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
87 static const struct trans_tbl scopes[] = {
95 char *rtnl_scope2str(
int scope,
char *buf,
size_t size)
97 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
100 int rtnl_str2scope(
const char *name)
102 return __str2type(name, scopes, ARRAY_SIZE(scopes));
112 char * rtnl_realms2str(uint32_t realms,
char *buf,
size_t len)
117 snprintf(buf, len,
"%d/%d", from, to);