11#include "nl-default.h"
13#include <netlink/netlink.h>
14#include <netlink/utils.h>
15#include <netlink/route/rtnl.h>
17#include "nl-priv-dynamic-core/nl-core.h"
41 struct rtgenmsg gmsg = {
42 .rtgen_family = family,
47 return err >= 0 ? 0 : err;
57static const struct trans_tbl rtntypes[] = {
58 __ADD(RTN_UNSPEC,unspec),
59 __ADD(RTN_UNICAST,unicast),
60 __ADD(RTN_LOCAL,local),
61 __ADD(RTN_BROADCAST,broadcast),
62 __ADD(RTN_ANYCAST,anycast),
63 __ADD(RTN_MULTICAST,multicast),
64 __ADD(RTN_BLACKHOLE,blackhole),
65 __ADD(RTN_UNREACHABLE,unreachable),
66 __ADD(RTN_PROHIBIT,prohibit),
67 __ADD(RTN_THROW,
throw),
69 __ADD(RTN_XRESOLVE,xresolve),
72char *nl_rtntype2str(
int type,
char *buf,
size_t size)
74 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
77int nl_str2rtntype(
const char *name)
79 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
89static const struct trans_tbl scopes[] = {
97char *rtnl_scope2str(
int scope,
char *buf,
size_t size)
99 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
102int rtnl_str2scope(
const char *name)
104 return __str2type(name, scopes, ARRAY_SIZE(scopes));
114char * rtnl_realms2str(uint32_t realms,
char *buf,
size_t len)
119 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.