17 #include <netlink-private/netlink.h> 18 #include <netlink/netlink.h> 19 #include <netlink/utils.h> 20 #include <netlink/route/rtnl.h> 44 struct rtgenmsg gmsg = {
45 .rtgen_family = family,
50 return err >= 0 ? 0 : err;
60 static const struct trans_tbl rtntypes[] = {
61 __ADD(RTN_UNSPEC,unspec),
62 __ADD(RTN_UNICAST,unicast),
63 __ADD(RTN_LOCAL,local),
64 __ADD(RTN_BROADCAST,broadcast),
65 __ADD(RTN_ANYCAST,anycast),
66 __ADD(RTN_MULTICAST,multicast),
67 __ADD(RTN_BLACKHOLE,blackhole),
68 __ADD(RTN_UNREACHABLE,unreachable),
69 __ADD(RTN_PROHIBIT,prohibit),
70 __ADD(RTN_THROW,
throw),
72 __ADD(RTN_XRESOLVE,xresolve),
75 char *nl_rtntype2str(
int type,
char *buf,
size_t size)
77 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
80 int nl_str2rtntype(
const char *name)
82 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
92 static const struct trans_tbl scopes[] = {
100 char *rtnl_scope2str(
int scope,
char *buf,
size_t size)
102 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
105 int rtnl_str2scope(
const char *name)
107 return __str2type(name, scopes, ARRAY_SIZE(scopes));
117 char * rtnl_realms2str(uint32_t realms,
char *buf,
size_t len)
122 snprintf(buf, len,
"%d/%d", from, to);
#define RTNL_REALM_TO(realm)
Extract TO realm from a realms field.
#define RTNL_REALM_FROM(realm)
Extract FROM realm from a realms field.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, size_t size)
Construct and transmit a Netlink message.