21#include "nl-default.h"
25#include <linux/socket.h>
26#include <linux/if_arp.h>
28#include <netlink/netlink.h>
29#include <netlink/utils.h>
32#include "nl-priv-dynamic-core/object-api.h"
33#include "nl-priv-dynamic-core/nl-core.h"
34#include "nl-aux-core/nl-core.h"
59static void _nl_init nl_debug_init(
void)
63 if (NL_DEBUG && (nldbg = getenv(
"NLDBG"))) {
64 long level = strtol(nldbg, &end, 0);
69 nl_debug_dp.
dp_fd = stderr;
72int __nl_read_num_str_file(
const char *path,
int (*cb)(
long,
const char *))
77 fd = fopen(path,
"re");
79 return -nl_syserr2nlerr(errno);
81 while (fgets(buf,
sizeof(buf), fd)) {
86 if (*buf ==
'#' || *buf ==
'\n' || *buf ==
'\r')
89 num = strtol(buf, &end, 0);
95 if (num == LONG_MIN || num == LONG_MAX) {
100 while (*end ==
' ' || *end ==
'\t')
103 goodlen = strcspn(end,
"#\r\n\t ");
129int nl_getprotobyname(
const char *name)
131 const struct protoent *result;
133#if HAVE_DECL_GETPROTOBYNAME_R
134 struct protoent result_buf;
138 r = getprotobyname_r(name, &result_buf, buf,
sizeof(buf),
139 (
struct protoent **)&result);
140 if (r != 0 || result != &result_buf)
143 result = getprotobyname(name);
149 if (result->p_proto < 0 || result->p_proto > UINT8_MAX)
151 return (uint8_t)result->p_proto;
154bool nl_getprotobynumber(
int proto,
char *out_name,
size_t name_len)
156 const struct protoent *result;
158#if HAVE_DECL_GETPROTOBYNUMBER_R
159 struct protoent result_buf;
163 r = getprotobynumber_r(proto, &result_buf, buf,
sizeof(buf),
164 (
struct protoent **)&result);
165 if (r != 0 || result != &result_buf)
168 result = getprotobynumber(proto);
174 if (strlen(result->p_name) >= name_len)
176 strcpy(out_name, result->p_name);
180const char *nl_strerror_l(
int err)
183#ifdef HAVE_STRERROR_L
184 int errno_save = errno;
185 locale_t loc = newlocale(LC_MESSAGES_MASK,
"", (locale_t)0);
187 if (loc == (locale_t)0) {
189 loc = newlocale(LC_MESSAGES_MASK,
190 "POSIX", (locale_t)0);
192 if (loc != (locale_t)0) {
193 buf = strerror_l(err, loc);
196 buf =
"newlocale() failed";
225 if (l >= 1099511627776LL) {
227 return ((
double) l) / 1099511627776LL;
228 }
else if (l >= 1073741824) {
230 return ((
double) l) / 1073741824;
231 }
else if (l >= 1048576) {
233 return ((
double) l) / 1048576;
234 }
else if (l >= 1024) {
236 return ((
double) l) / 1024;
256 if (l >= 1000000000000ULL) {
258 return ((
double) l) / 1000000000000ULL;
261 if (l >= 1000000000) {
263 return ((
double) l) / 1000000000;
268 return ((
double) l) / 1000000;
273 return ((
double) l) / 1000;
280int nl_rate2str(
unsigned long long rate,
int type,
char *buf,
size_t len)
298 return snprintf(buf, len,
"%.2f%s/s", frac, unit);
315 return ((
double) l) / 1000000;
316 }
else if (l >= 1000) {
318 return ((
double) l) / 1000;
351 long l = strtol(str, &p, 0);
356 if (!strcasecmp(p,
"kb") || !strcasecmp(p,
"k"))
358 else if (!strcasecmp(p,
"gb") || !strcasecmp(p,
"g"))
360 else if (!strcasecmp(p,
"gbit"))
362 else if (!strcasecmp(p,
"mb") || !strcasecmp(p,
"m"))
364 else if (!strcasecmp(p,
"mbit"))
366 else if (!strcasecmp(p,
"kbit"))
368 else if (!strcasecmp(p,
"bit"))
370 else if (strcasecmp(p,
"b") != 0)
381 { 1024. * 1024. * 1024. * 1024. * 1024.,
"EiB" },
382 { 1024. * 1024. * 1024. * 1024.,
"TiB" },
383 { 1024. * 1024. * 1024.,
"GiB" },
384 { 1024. * 1024.,
"MiB" },
416 snprintf(buf, len,
"0B");
420 for (i = 0; i < ARRAY_SIZE(size_units); i++) {
421 if (size >= size_units[i].limit) {
422 snprintf(buf, len,
"%.2g%s",
423 (
double) size / size_units[i].limit,
448 double d = strtod(str, &p);
456 if (d > 1.0f || d < 0.0f)
459 if (*p && strcmp(p,
"%") != 0)
476static uint32_t user_hz = USER_HZ;
477static uint32_t psched_hz = USER_HZ;
479static double ticks_per_usec = 1.0f;
490static void get_psched_settings(
void)
492 char name[FILENAME_MAX];
495 static volatile int initialized = 0;
499 if (initialized == 1)
504 if (initialized == 1)
507 if ((ev = getenv(
"HZ"))) {
508 long hz = strtol(ev, NULL, 0);
510 if (LONG_MIN != hz && LONG_MAX != hz) {
517 user_hz = sysconf(_SC_CLK_TCK);
521 if ((ev = getenv(
"TICKS_PER_USEC"))) {
522 double t = strtod(ev, NULL);
526 if ((ev = getenv(
"PROC_NET_PSCHED")))
527 snprintf(name,
sizeof(name),
"%s", ev);
528 else if ((ev = getenv(
"PROC_ROOT")))
529 snprintf(name,
sizeof(name),
"%s/net/psched", ev);
531 _nl_strncpy_assert(name,
"/proc/net/psched",
sizeof(name));
533 if ((fd = fopen(name,
"re"))) {
534 unsigned int ns_per_usec, ns_per_tick, nom, denom;
536 if (fscanf(fd,
"%08x %08x %08x %08x",
537 &ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
538 NL_DBG(1,
"Fatal error: can not read psched settings from \"%s\". " \
539 "Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
540 "environment variables\n", name);
544 ticks_per_usec = (double) ns_per_usec /
545 (
double) ns_per_tick;
564 get_psched_settings();
573 get_psched_settings();
584 get_psched_settings();
585 return us * ticks_per_usec;
596 get_psched_settings();
597 return ticks / ticks_per_usec;
600int nl_str2msec(
const char *str, uint64_t *result)
602 uint64_t total = 0, l;
607 l = strtoul(str, &p, 0);
611 plen = strcspn(p,
" \t");
615 else if (!strncasecmp(p,
"sec", plen))
617 else if (!strncasecmp(p,
"min", plen))
618 total += (l * 1000*60);
619 else if (!strncasecmp(p,
"hour", plen))
620 total += (l * 1000*60*60);
621 else if (!strncasecmp(p,
"day", plen))
622 total += (l * 1000*60*60*24);
629 }
while (*str && *p);
652 static const char *units[5] = {
"d",
"h",
"m",
"s",
"msec"};
653 char *
const buf_orig = buf;
656 snprintf(buf, len,
"0msec");
660#define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit
668 for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
672 l = snprintf(buf, len,
"%s%" PRIu64
"%s",
673 (buf==buf_orig) ?
"" :
" ", split[i], units[i]);
688static const struct trans_tbl nlfamilies[] = {
689 __ADD(NETLINK_ROUTE,route),
690 __ADD(NETLINK_USERSOCK,usersock),
691 __ADD(NETLINK_FIREWALL,firewall),
692 __ADD(NETLINK_INET_DIAG,inetdiag),
693 __ADD(NETLINK_NFLOG,nflog),
694 __ADD(NETLINK_XFRM,xfrm),
695 __ADD(NETLINK_SELINUX,selinux),
696 __ADD(NETLINK_ISCSI,iscsi),
697 __ADD(NETLINK_AUDIT,audit),
698 __ADD(NETLINK_FIB_LOOKUP,fib_lookup),
699 __ADD(NETLINK_CONNECTOR,connector),
700 __ADD(NETLINK_NETFILTER,netfilter),
701 __ADD(NETLINK_IP6_FW,ip6_fw),
702 __ADD(NETLINK_DNRTMSG,dnrtmsg),
703 __ADD(NETLINK_KOBJECT_UEVENT,kobject_uevent),
704 __ADD(NETLINK_GENERIC,generic),
705 __ADD(NETLINK_SCSITRANSPORT,scsitransport),
706 __ADD(NETLINK_ECRYPTFS,ecryptfs),
707 __ADD(NETLINK_RDMA,rdma),
708 __ADD(NETLINK_CRYPTO,crypto),
711char * nl_nlfamily2str(
int family,
char *buf,
size_t size)
713 return __type2str(family, buf, size, nlfamilies,
714 ARRAY_SIZE(nlfamilies));
717int nl_str2nlfamily(
const char *name)
719 return __str2type(name, nlfamilies, ARRAY_SIZE(nlfamilies));
731static const struct trans_tbl llprotos[] = {
733 __ADD(ARPHRD_NETROM,netrom),
734 __ADD(ARPHRD_ETHER,ether),
735 __ADD(ARPHRD_EETHER,eether),
736 __ADD(ARPHRD_AX25,ax25),
737 __ADD(ARPHRD_PRONET,pronet),
738 __ADD(ARPHRD_CHAOS,chaos),
739 __ADD(ARPHRD_IEEE802,ieee802),
740 __ADD(ARPHRD_ARCNET,arcnet),
741 __ADD(ARPHRD_APPLETLK,atalk),
742 __ADD(ARPHRD_DLCI,dlci),
743 __ADD(ARPHRD_ATM,atm),
744 __ADD(ARPHRD_METRICOM,metricom),
745 __ADD(ARPHRD_IEEE1394,ieee1394),
746 __ADD(ARPHRD_EUI64,eui64),
747 __ADD(ARPHRD_INFINIBAND,infiniband),
748 __ADD(ARPHRD_SLIP,slip),
749 __ADD(ARPHRD_CSLIP,cslip),
750 __ADD(ARPHRD_SLIP6,slip6),
751 __ADD(ARPHRD_CSLIP6,cslip6),
752 __ADD(ARPHRD_RSRVD,rsrvd),
753 __ADD(ARPHRD_ADAPT,adapt),
754 __ADD(ARPHRD_ROSE,rose),
755 __ADD(ARPHRD_X25,x25),
756 __ADD(ARPHRD_HWX25,hwx25),
757 __ADD(ARPHRD_CAN,can),
758 __ADD(ARPHRD_PPP,ppp),
759 __ADD(ARPHRD_CISCO,cisco),
760 __ADD(ARPHRD_HDLC,hdlc),
761 __ADD(ARPHRD_LAPB,lapb),
762 __ADD(ARPHRD_DDCMP,ddcmp),
763 __ADD(ARPHRD_RAWHDLC,rawhdlc),
764 __ADD(ARPHRD_TUNNEL,ipip),
765 __ADD(ARPHRD_TUNNEL6,tunnel6),
766 __ADD(ARPHRD_FRAD,frad),
767 __ADD(ARPHRD_SKIP,skip),
768 __ADD(ARPHRD_LOOPBACK,loopback),
769 __ADD(ARPHRD_LOCALTLK,localtlk),
770 __ADD(ARPHRD_FDDI,fddi),
771 __ADD(ARPHRD_BIF,bif),
772 __ADD(ARPHRD_SIT,sit),
773 __ADD(ARPHRD_IPDDP,ip/ddp),
774 __ADD(ARPHRD_IPGRE,gre),
775 __ADD(ARPHRD_PIMREG,pimreg),
776 __ADD(ARPHRD_HIPPI,hippi),
777 __ADD(ARPHRD_ASH,ash),
778 __ADD(ARPHRD_ECONET,econet),
779 __ADD(ARPHRD_IRDA,irda),
780 __ADD(ARPHRD_FCPP,fcpp),
781 __ADD(ARPHRD_FCAL,fcal),
782 __ADD(ARPHRD_FCPL,fcpl),
783 __ADD(ARPHRD_FCFABRIC,fcfb_0),
784 __ADD(ARPHRD_FCFABRIC+1,fcfb_1),
785 __ADD(ARPHRD_FCFABRIC+2,fcfb_2),
786 __ADD(ARPHRD_FCFABRIC+3,fcfb_3),
787 __ADD(ARPHRD_FCFABRIC+4,fcfb_4),
788 __ADD(ARPHRD_FCFABRIC+5,fcfb_5),
789 __ADD(ARPHRD_FCFABRIC+6,fcfb_6),
790 __ADD(ARPHRD_FCFABRIC+7,fcfb_7),
791 __ADD(ARPHRD_FCFABRIC+8,fcfb_8),
792 __ADD(ARPHRD_FCFABRIC+9,fcfb_9),
793 __ADD(ARPHRD_FCFABRIC+10,fcfb_10),
794 __ADD(ARPHRD_FCFABRIC+11,fcfb_11),
795 __ADD(ARPHRD_FCFABRIC+12,fcfb_12),
796 __ADD(ARPHRD_IEEE802_TR,tr),
797 __ADD(ARPHRD_IEEE80211,ieee802.11),
798 __ADD(ARPHRD_IEEE80211_PRISM,ieee802.11_prism),
799 __ADD(ARPHRD_IEEE80211_RADIOTAP,ieee802.11_radiotap),
800 __ADD(ARPHRD_IEEE802154,ieee802.15.4),
801 __ADD(ARPHRD_IEEE802154_MONITOR,ieee802.15.4_monitor),
802 __ADD(ARPHRD_PHONET,phonet),
803 __ADD(ARPHRD_PHONET_PIPE,phonet_pipe),
804 __ADD(ARPHRD_CAIF,caif),
805 __ADD(ARPHRD_IP6GRE,ip6gre),
806 __ADD(ARPHRD_NETLINK,netlink),
807 __ADD(ARPHRD_6LOWPAN,6lowpan),
808 __ADD(ARPHRD_VOID,
void),
809 __ADD(ARPHRD_NONE,nohdr),
812char * nl_llproto2str(
int llproto,
char *buf,
size_t len)
814 return __type2str(llproto, buf, len, llprotos, ARRAY_SIZE(llprotos));
817int nl_str2llproto(
const char *name)
819 return __str2type(name, llprotos, ARRAY_SIZE(llprotos));
830static const struct trans_tbl ether_protos[] = {
831 __ADD(ETH_P_LOOP,loop),
832 __ADD(ETH_P_PUP,pup),
833 __ADD(ETH_P_PUPAT,pupat),
835 __ADD(ETH_P_X25,x25),
836 __ADD(ETH_P_ARP,arp),
837 __ADD(ETH_P_BPQ,bpq),
838 __ADD(ETH_P_IEEEPUP,ieeepup),
839 __ADD(ETH_P_IEEEPUPAT,ieeepupat),
840 __ADD(ETH_P_DEC,dec),
841 __ADD(ETH_P_DNA_DL,dna_dl),
842 __ADD(ETH_P_DNA_RC,dna_rc),
843 __ADD(ETH_P_DNA_RT,dna_rt),
844 __ADD(ETH_P_LAT,lat),
845 __ADD(ETH_P_DIAG,diag),
846 __ADD(ETH_P_CUST,cust),
847 __ADD(ETH_P_SCA,sca),
848 __ADD(ETH_P_TEB,teb),
849 __ADD(ETH_P_RARP,rarp),
850 __ADD(ETH_P_ATALK,atalk),
851 __ADD(ETH_P_AARP,aarp),
853 __ADD(ETH_P_8021Q,802.1q),
855 __ADD(ETH_P_IPX,ipx),
856 __ADD(ETH_P_IPV6,ipv6),
857 __ADD(ETH_P_PAUSE,pause),
858 __ADD(ETH_P_SLOW,slow),
860 __ADD(ETH_P_WCCP,wccp),
862 __ADD(ETH_P_PPP_DISC,ppp_disc),
863 __ADD(ETH_P_PPP_SES,ppp_ses),
864 __ADD(ETH_P_MPLS_UC,mpls_uc),
865 __ADD(ETH_P_MPLS_MC,mpls_mc),
866 __ADD(ETH_P_ATMMPOA,atmmpoa),
867 __ADD(ETH_P_LINK_CTL,link_ctl),
868 __ADD(ETH_P_ATMFATE,atmfate),
869 __ADD(ETH_P_PAE,pae),
870 __ADD(ETH_P_AOE,aoe),
871 __ADD(ETH_P_TIPC,tipc),
872 __ADD(ETH_P_1588,ieee1588),
873 __ADD(ETH_P_FCOE,fcoe),
874 __ADD(ETH_P_FIP,fip),
875 __ADD(ETH_P_EDSA,edsa),
876 __ADD(ETH_P_EDP2,edp2),
877 __ADD(ETH_P_802_3,802.3),
878 __ADD(ETH_P_AX25,ax25),
879 __ADD(ETH_P_ALL,all),
880 __ADD(ETH_P_802_2,802.2),
881 __ADD(ETH_P_SNAP,snap),
882 __ADD(ETH_P_DDCMP,ddcmp),
883 __ADD(ETH_P_WAN_PPP,wan_ppp),
884 __ADD(ETH_P_PPP_MP,ppp_mp),
885 __ADD(ETH_P_LOCALTALK,localtalk),
886 __ADD(ETH_P_CAN,can),
887 __ADD(ETH_P_PPPTALK,ppptalk),
888 __ADD(ETH_P_TR_802_2,tr_802.2),
889 __ADD(ETH_P_MOBITEX,mobitex),
890 __ADD(ETH_P_CONTROL,control),
891 __ADD(ETH_P_IRDA,irda),
892 __ADD(ETH_P_ECONET,econet),
893 __ADD(ETH_P_HDLC,hdlc),
894 __ADD(ETH_P_ARCNET,arcnet),
895 __ADD(ETH_P_DSA,dsa),
896 __ADD(ETH_P_TRAILER,trailer),
897 __ADD(ETH_P_PHONET,phonet),
898 __ADD(ETH_P_IEEE802154,ieee802154),
899 __ADD(ETH_P_CAIF,caif),
902char *nl_ether_proto2str(
int eproto,
char *buf,
size_t len)
904 return __type2str(eproto, buf, len, ether_protos,
905 ARRAY_SIZE(ether_protos));
908int nl_str2ether_proto(
const char *name)
910 return __str2type(name, ether_protos, ARRAY_SIZE(ether_protos));
920char *nl_ip_proto2str(
int proto,
char *buf,
size_t len)
922 if (nl_getprotobynumber(proto, buf, len))
925 snprintf(buf, len,
"0x%x", proto);
929int nl_str2ip_proto(
const char *name)
938 p = nl_getprotobyname(name);
942 l = strtoul(name, &end, 0);
943 if (name == end || *end !=
'\0' || l > (
unsigned long)INT_MAX)
944 return -NLE_OBJ_NOTFOUND;
972 for (i = 0; i < params->
dp_prefix; i++) {
974 fprintf(params->
dp_fd,
" ");
976 strncat(params->
dp_buf,
" ",
978 strlen(params->
dp_buf) - 1);
983 params->
dp_nl_cb(params, params->dp_line);
986static void dump_one(
struct nl_dump_params *parms,
const char *fmt,
990 vfprintf(parms->
dp_fd, fmt, args);
993 if (vasprintf(&buf, fmt, args) >= 0) {
995 parms->
dp_cb(parms, buf);
997 strncat(parms->
dp_buf, buf,
999 strlen(parms->
dp_buf) - 1);
1019 va_start(args, fmt);
1020 dump_one(params, fmt, args);
1024void nl_dump_line(
struct nl_dump_params *parms,
const char *fmt, ...)
1030 va_start(args, fmt);
1031 dump_one(parms, fmt, args);
1040int __trans_list_add(
int i,
const char *a,
struct nl_list_head *head)
1042 struct trans_list *tl;
1044 tl = calloc(1,
sizeof(*tl));
1051 nl_list_add_tail(&tl->list, head);
1058 struct trans_list *tl, *next;
1060 nl_list_for_each_entry_safe(tl, next, head, list) {
1065 nl_init_list_head(head);
1068char *__type2str(
int type,
char *buf,
size_t len,
1069 const struct trans_tbl *tbl,
size_t tbl_len)
1073 for (i = 0; i < tbl_len; i++) {
1074 if (tbl[i].i == ((uint64_t)type)) {
1075 snprintf(buf, len,
"%s", tbl[i].a);
1080 snprintf(buf, len,
"0x%x", (
unsigned)type);
1084char *__list_type2str(
int type,
char *buf,
size_t len,
1087 struct trans_list *tl;
1089 nl_list_for_each_entry(tl, head, list) {
1090 if (tl->i == type) {
1091 snprintf(buf, len,
"%s", tl->a);
1096 snprintf(buf, len,
"0x%x", type);
1100char *__flags2str(
int flags,
char *buf,
size_t len,
1101 const struct trans_tbl *tbl,
size_t tbl_len)
1106 memset(buf, 0, len);
1108 for (i = 0; i < tbl_len; i++) {
1109 if (tbl[i].i & tmp) {
1111 strncat(buf, tbl[i].a, len - strlen(buf) - 1);
1113 strncat(buf,
",", len - strlen(buf) - 1);
1120int __str2type(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1129 for (i = 0; i < tbl_len; i++)
1130 if (!strcasecmp(tbl[i].a, buf))
1133 l = strtoul(buf, &end, 0);
1134 if (l == ULONG_MAX || *end !=
'\0')
1135 return -NLE_OBJ_NOTFOUND;
1140int __list_str2type(
const char *buf,
struct nl_list_head *head)
1142 struct trans_list *tl;
1149 nl_list_for_each_entry(tl, head, list) {
1150 if (!strcasecmp(tl->a, buf))
1154 l = strtoul(buf, &end, 0);
1155 if (l == ULONG_MAX || *end !=
'\0')
1156 return -NLE_OBJ_NOTFOUND;
1161int __str2flags(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1166 char *p = (
char *) buf, *t;
1173 len = t ? ((size_t)(t - p)) : strlen(p);
1174 for (i = 0; i < tbl_len; i++)
1175 if (len == strlen(tbl[i].a) &&
1176 !strncasecmp(tbl[i].a, p, len))
1188void dump_from_ops(
struct nl_object *obj,
struct nl_dump_params *params)
1192 if (type < 0 || type > NL_DUMP_MAX)
1195 params->dp_line = 0;
1202 dp_dump_line(params, 0,
"%s ",
1203 nl_cache_mngt_type2name(obj->ce_ops,
1204 obj->ce_ops->co_protocol,
1211 if (obj->ce_ops->oo_dump[type])
1212 obj->ce_ops->oo_dump[type](obj, params);
1234int nl_has_capability (
int capability)
1236 static const uint8_t caps[ ( NL_CAPABILITY_MAX + 7 ) / 8 ] = {
1237#define _NL_ASSERT(expr) ( 0 * sizeof(struct { unsigned int x: ( (!!(expr)) ? 1 : -1 ); }) )
1238#define _NL_SETV(i, r, v) \
1239 ( _NL_ASSERT( (v) == 0 || (i) * 8 + (r) == (v) - 1 ) + \
1240 ( (v) == 0 ? 0 : (1 << (r)) ) )
1241#define _NL_SET(i, v0, v1, v2, v3, v4, v5, v6, v7) \
1243 _NL_SETV((i), 0, (v0)) | _NL_SETV((i), 4, (v4)) | \
1244 _NL_SETV((i), 1, (v1)) | _NL_SETV((i), 5, (v5)) | \
1245 _NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \
1246 _NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) )
1248 NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE,
1249 NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE,
1250 NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
1251 NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
1252 NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
1253 NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
1254 NL_CAPABILITY_VERSION_3_2_26,
1255 NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK),
1257 NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE,
1258 NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX,
1259 NL_CAPABILITY_VERSION_3_2_27,
1260 NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE,
1261 NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE,
1262 NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR,
1263 NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE,
1264 NL_CAPABILITY_NL_OBJECT_DIFF64),
1266 NL_CAPABILITY_XFRM_SA_KEY_SIZE,
1267 NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
1268 NL_CAPABILITY_VERSION_3_2_28,
1269 NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
1270 NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
1271 NL_CAPABILITY_XFRM_SEC_CTX_LEN,
1272 NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE,
1273 NL_CAPABILITY_NL_RECVMSGS_PEEK_BY_DEFAULT),
1275 NL_CAPABILITY_VERSION_3_2_29,
1276 NL_CAPABILITY_XFRM_SP_SEC_CTX_LEN,
1277 NL_CAPABILITY_VERSION_3_3_0,
1278 NL_CAPABILITY_VERSION_3_4_0,
1279 NL_CAPABILITY_ROUTE_FIX_VLAN_SET_EGRESS_MAP,
1280 NL_CAPABILITY_VERSION_3_5_0,
1281 NL_CAPABILITY_NL_OBJECT_IDENTICAL_PARTIAL,
1282 NL_CAPABILITY_VERSION_3_6_0),
1284 NL_CAPABILITY_VERSION_3_7_0,
1285 NL_CAPABILITY_VERSION_3_8_0,
1286 NL_CAPABILITY_VERSION_3_9_0,
1287 NL_CAPABILITY_VERSION_3_10_0,
1288 NL_CAPABILITY_VERSION_3_11_0,
1311 if (capability <= 0 || capability > NL_CAPABILITY_MAX)
1314 return (caps[capability / 8] & (1 << (capability % 8))) != 0;
int nl_get_psched_hz(void)
Return the value of packet scheduler HZ.
#define NL_PROB_MAX
Upper probability limit nl_dump_type.
char * nl_size2str(const size_t size, char *buf, const size_t len)
Convert a size toa character string.
double nl_cancel_down_us(uint32_t l, char **unit)
Cancel down a micro second value.
double nl_cancel_down_bits(unsigned long long l, char **unit)
Cancel down a bit counter.
int nl_get_user_hz(void)
Return the value of HZ.
long nl_size2int(const char *str)
Convert a character string to a size.
int nl_debug
Global variable indicating the desired level of debugging output.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
double nl_cancel_down_bytes(unsigned long long l, char **unit)
Cancel down a byte counter.
long nl_prob2int(const char *str)
Convert a character string to a probability.
void nl_new_line(struct nl_dump_params *params)
Handle a new line while dumping.
uint32_t nl_ticks2us(uint32_t ticks)
Convert ticks to micro seconds.
uint32_t nl_us2ticks(uint32_t us)
Convert micro seconds to ticks.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
int dp_pre_dump
PRIVATE Set if a dump was performed prior to the actual dump handler.
void(* dp_cb)(struct nl_dump_params *, char *)
A callback invoked for output.
size_t dp_buflen
Length of the buffer dp_buf.
int dp_prefix
Specifies the number of whitespaces to be put in front of every new line (indentation).
int dp_dump_msgtype
Causes each element to be prefixed with the message type.
char * dp_buf
Alternatively the output may be redirected into a buffer.
enum nl_dump_type dp_type
Specifies the type of dump that is requested.
FILE * dp_fd
File descriptor the dumping output should go to.
void(* dp_nl_cb)(struct nl_dump_params *, int)
A callback invoked for every new line, can be used to customize the indentation.