11#include <netlink-private/netlink.h>
12#include <netlink/netlink.h>
13#include <netlink/utils.h>
14#include <netlink/route/rtnl.h>
38 struct rtgenmsg gmsg = {
39 .rtgen_family = family,
44 return err >= 0 ? 0 : err;
54static const struct trans_tbl rtntypes[] = {
55 __ADD(RTN_UNSPEC,unspec),
56 __ADD(RTN_UNICAST,unicast),
57 __ADD(RTN_LOCAL,local),
58 __ADD(RTN_BROADCAST,broadcast),
59 __ADD(RTN_ANYCAST,anycast),
60 __ADD(RTN_MULTICAST,multicast),
61 __ADD(RTN_BLACKHOLE,blackhole),
62 __ADD(RTN_UNREACHABLE,unreachable),
63 __ADD(RTN_PROHIBIT,prohibit),
64 __ADD(RTN_THROW,
throw),
66 __ADD(RTN_XRESOLVE,xresolve),
69char *nl_rtntype2str(
int type,
char *buf,
size_t size)
71 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
74int nl_str2rtntype(
const char *name)
76 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
86static const struct trans_tbl scopes[] = {
94char *rtnl_scope2str(
int scope,
char *buf,
size_t size)
96 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
99int rtnl_str2scope(
const char *name)
101 return __str2type(name, scopes, ARRAY_SIZE(scopes));
111char * rtnl_realms2str(uint32_t realms,
char *buf,
size_t len)
116 snprintf(buf, len,
"%d/%d", from, to);
#define RTNL_REALM_TO(realm)
Extract TO realm from a realms field.
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
Send routing netlink request message.
#define RTNL_REALM_FROM(realm)
Extract FROM realm from a realms field.
int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf, size_t size)
Construct and transmit a Netlink message.