18 #include <netlink-private/netlink.h> 19 #include <netlink/netlink.h> 20 #include <netlink/utils.h> 21 #include <netlink/route/rtnl.h> 45 struct rtgenmsg gmsg = {
46 .rtgen_family = family,
51 return err >= 0 ? 0 : err;
61 static const struct trans_tbl rtntypes[] = {
62 __ADD(RTN_UNSPEC,unspec),
63 __ADD(RTN_UNICAST,unicast),
64 __ADD(RTN_LOCAL,local),
65 __ADD(RTN_BROADCAST,broadcast),
66 __ADD(RTN_ANYCAST,anycast),
67 __ADD(RTN_MULTICAST,multicast),
68 __ADD(RTN_BLACKHOLE,blackhole),
69 __ADD(RTN_UNREACHABLE,unreachable),
70 __ADD(RTN_PROHIBIT,prohibit),
71 __ADD(RTN_THROW,
throw),
73 __ADD(RTN_XRESOLVE,xresolve),
76 char *nl_rtntype2str(
int type,
char *buf,
size_t size)
78 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
81 int nl_str2rtntype(
const char *name)
83 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
93 static const struct trans_tbl scopes[] = {
101 char *rtnl_scope2str(
int scope,
char *buf,
size_t size)
103 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
106 int rtnl_str2scope(
const char *name)
108 return __str2type(name, scopes, ARRAY_SIZE(scopes));
118 char * rtnl_realms2str(uint32_t realms,
char *buf,
size_t len)
123 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.