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"
60static void _nl_init nl_debug_init(
void)
64 if ((nldbg = getenv(
"NLDBG"))) {
65 long level = strtol(nldbg, &end, 0);
70 nl_debug_dp.
dp_fd = stderr;
74int __nl_read_num_str_file(
const char *path,
int (*cb)(
long,
const char *))
79 fd = fopen(path,
"re");
81 return -nl_syserr2nlerr(errno);
83 while (fgets(buf,
sizeof(buf), fd)) {
88 if (*buf ==
'#' || *buf ==
'\n' || *buf ==
'\r')
91 num = strtol(buf, &end, 0);
97 if (num == LONG_MIN || num == LONG_MAX) {
102 while (*end ==
' ' || *end ==
'\t')
105 goodlen = strcspn(end,
"#\r\n\t ");
131int nl_getprotobyname(
const char *name)
133 const struct protoent *result;
135#if HAVE_DECL_GETPROTOBYNAME_R
136 struct protoent result_buf;
140 r = getprotobyname_r(name, &result_buf, buf,
sizeof(buf),
141 (
struct protoent **)&result);
142 if (r != 0 || result != &result_buf)
145 result = getprotobyname(name);
151 if (result->p_proto < 0 || result->p_proto > UINT8_MAX)
153 return (uint8_t)result->p_proto;
156bool nl_getprotobynumber(
int proto,
char *out_name,
size_t name_len)
158 const struct protoent *result;
160#if HAVE_DECL_GETPROTOBYNUMBER_R
161 struct protoent result_buf;
165 r = getprotobynumber_r(proto, &result_buf, buf,
sizeof(buf),
166 (
struct protoent **)&result);
167 if (r != 0 || result != &result_buf)
170 result = getprotobynumber(proto);
176 if (strlen(result->p_name) >= name_len)
178 strcpy(out_name, result->p_name);
182const char *nl_strerror_l(
int err)
185#ifdef HAVE_STRERROR_L
186 int errno_save = errno;
187 locale_t loc = newlocale(LC_MESSAGES_MASK,
"", (locale_t)0);
189 if (loc == (locale_t)0) {
191 loc = newlocale(LC_MESSAGES_MASK,
192 "POSIX", (locale_t)0);
194 if (loc != (locale_t)0) {
195 buf = strerror_l(err, loc);
198 buf =
"newlocale() failed";
227 if (l >= 1099511627776LL) {
229 return ((
double) l) / 1099511627776LL;
230 }
else if (l >= 1073741824) {
232 return ((
double) l) / 1073741824;
233 }
else if (l >= 1048576) {
235 return ((
double) l) / 1048576;
236 }
else if (l >= 1024) {
238 return ((
double) l) / 1024;
258 if (l >= 1000000000000ULL) {
260 return ((
double) l) / 1000000000000ULL;
263 if (l >= 1000000000) {
265 return ((
double) l) / 1000000000;
270 return ((
double) l) / 1000000;
275 return ((
double) l) / 1000;
282int nl_rate2str(
unsigned long long rate,
int type,
char *buf,
size_t len)
300 return snprintf(buf, len,
"%.2f%s/s", frac, unit);
317 return ((
double) l) / 1000000;
318 }
else if (l >= 1000) {
320 return ((
double) l) / 1000;
353 long l = strtol(str, &p, 0);
358 if (!strcasecmp(p,
"kb") || !strcasecmp(p,
"k"))
360 else if (!strcasecmp(p,
"gb") || !strcasecmp(p,
"g"))
362 else if (!strcasecmp(p,
"gbit"))
364 else if (!strcasecmp(p,
"mb") || !strcasecmp(p,
"m"))
366 else if (!strcasecmp(p,
"mbit"))
368 else if (!strcasecmp(p,
"kbit"))
370 else if (!strcasecmp(p,
"bit"))
372 else if (strcasecmp(p,
"b") != 0)
383 { 1024. * 1024. * 1024. * 1024. * 1024.,
"EiB" },
384 { 1024. * 1024. * 1024. * 1024.,
"TiB" },
385 { 1024. * 1024. * 1024.,
"GiB" },
386 { 1024. * 1024.,
"MiB" },
418 snprintf(buf, len,
"0B");
422 for (i = 0; i < ARRAY_SIZE(size_units); i++) {
423 if (size >= size_units[i].limit) {
424 snprintf(buf, len,
"%.2g%s",
425 (
double) size / size_units[i].limit,
450 double d = strtod(str, &p);
458 if (d > 1.0f || d < 0.0f)
461 if (*p && strcmp(p,
"%") != 0)
478static uint32_t user_hz = USER_HZ;
479static uint32_t psched_hz = USER_HZ;
481static double ticks_per_usec = 1.0f;
492static void get_psched_settings(
void)
494 char name[FILENAME_MAX];
497 static volatile int initialized = 0;
501 if (initialized == 1)
506 if (initialized == 1)
509 if ((ev = getenv(
"HZ"))) {
510 long hz = strtol(ev, NULL, 0);
512 if (LONG_MIN != hz && LONG_MAX != hz) {
519 user_hz = sysconf(_SC_CLK_TCK);
523 if ((ev = getenv(
"TICKS_PER_USEC"))) {
524 double t = strtod(ev, NULL);
528 if ((ev = getenv(
"PROC_NET_PSCHED")))
529 snprintf(name,
sizeof(name),
"%s", ev);
530 else if ((ev = getenv(
"PROC_ROOT")))
531 snprintf(name,
sizeof(name),
"%s/net/psched", ev);
533 _nl_strncpy_assert(name,
"/proc/net/psched",
sizeof(name));
535 if ((fd = fopen(name,
"re"))) {
536 unsigned int ns_per_usec, ns_per_tick, nom, denom;
538 if (fscanf(fd,
"%08x %08x %08x %08x",
539 &ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
540 NL_DBG(1,
"Fatal error: can not read psched settings from \"%s\". " \
541 "Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
542 "environment variables\n", name);
546 ticks_per_usec = (double) ns_per_usec /
547 (
double) ns_per_tick;
566 get_psched_settings();
575 get_psched_settings();
586 get_psched_settings();
587 return us * ticks_per_usec;
598 get_psched_settings();
599 return ticks / ticks_per_usec;
602int nl_str2msec(
const char *str, uint64_t *result)
604 uint64_t total = 0, l;
609 l = strtoul(str, &p, 0);
613 plen = strcspn(p,
" \t");
617 else if (!strncasecmp(p,
"sec", plen))
619 else if (!strncasecmp(p,
"min", plen))
620 total += (l * 1000*60);
621 else if (!strncasecmp(p,
"hour", plen))
622 total += (l * 1000*60*60);
623 else if (!strncasecmp(p,
"day", plen))
624 total += (l * 1000*60*60*24);
631 }
while (*str && *p);
654 static const char *units[5] = {
"d",
"h",
"m",
"s",
"msec"};
655 char *
const buf_orig = buf;
658 snprintf(buf, len,
"0msec");
662#define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit
670 for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
674 l = snprintf(buf, len,
"%s%" PRIu64
"%s",
675 (buf==buf_orig) ?
"" :
" ", split[i], units[i]);
690static const struct trans_tbl nlfamilies[] = {
691 __ADD(NETLINK_ROUTE,route),
692 __ADD(NETLINK_USERSOCK,usersock),
693 __ADD(NETLINK_FIREWALL,firewall),
694 __ADD(NETLINK_INET_DIAG,inetdiag),
695 __ADD(NETLINK_NFLOG,nflog),
696 __ADD(NETLINK_XFRM,xfrm),
697 __ADD(NETLINK_SELINUX,selinux),
698 __ADD(NETLINK_ISCSI,iscsi),
699 __ADD(NETLINK_AUDIT,audit),
700 __ADD(NETLINK_FIB_LOOKUP,fib_lookup),
701 __ADD(NETLINK_CONNECTOR,connector),
702 __ADD(NETLINK_NETFILTER,netfilter),
703 __ADD(NETLINK_IP6_FW,ip6_fw),
704 __ADD(NETLINK_DNRTMSG,dnrtmsg),
705 __ADD(NETLINK_KOBJECT_UEVENT,kobject_uevent),
706 __ADD(NETLINK_GENERIC,generic),
707 __ADD(NETLINK_SCSITRANSPORT,scsitransport),
708 __ADD(NETLINK_ECRYPTFS,ecryptfs),
709 __ADD(NETLINK_RDMA,rdma),
710 __ADD(NETLINK_CRYPTO,crypto),
713char * nl_nlfamily2str(
int family,
char *buf,
size_t size)
715 return __type2str(family, buf, size, nlfamilies,
716 ARRAY_SIZE(nlfamilies));
719int nl_str2nlfamily(
const char *name)
721 return __str2type(name, nlfamilies, ARRAY_SIZE(nlfamilies));
733static const struct trans_tbl llprotos[] = {
735 __ADD(ARPHRD_NETROM,netrom),
736 __ADD(ARPHRD_ETHER,ether),
737 __ADD(ARPHRD_EETHER,eether),
738 __ADD(ARPHRD_AX25,ax25),
739 __ADD(ARPHRD_PRONET,pronet),
740 __ADD(ARPHRD_CHAOS,chaos),
741 __ADD(ARPHRD_IEEE802,ieee802),
742 __ADD(ARPHRD_ARCNET,arcnet),
743 __ADD(ARPHRD_APPLETLK,atalk),
744 __ADD(ARPHRD_DLCI,dlci),
745 __ADD(ARPHRD_ATM,atm),
746 __ADD(ARPHRD_METRICOM,metricom),
747 __ADD(ARPHRD_IEEE1394,ieee1394),
748 __ADD(ARPHRD_EUI64,eui64),
749 __ADD(ARPHRD_INFINIBAND,infiniband),
750 __ADD(ARPHRD_SLIP,slip),
751 __ADD(ARPHRD_CSLIP,cslip),
752 __ADD(ARPHRD_SLIP6,slip6),
753 __ADD(ARPHRD_CSLIP6,cslip6),
754 __ADD(ARPHRD_RSRVD,rsrvd),
755 __ADD(ARPHRD_ADAPT,adapt),
756 __ADD(ARPHRD_ROSE,rose),
757 __ADD(ARPHRD_X25,x25),
758 __ADD(ARPHRD_HWX25,hwx25),
759 __ADD(ARPHRD_CAN,can),
760 __ADD(ARPHRD_PPP,ppp),
761 __ADD(ARPHRD_CISCO,cisco),
762 __ADD(ARPHRD_HDLC,hdlc),
763 __ADD(ARPHRD_LAPB,lapb),
764 __ADD(ARPHRD_DDCMP,ddcmp),
765 __ADD(ARPHRD_RAWHDLC,rawhdlc),
766 __ADD(ARPHRD_TUNNEL,ipip),
767 __ADD(ARPHRD_TUNNEL6,tunnel6),
768 __ADD(ARPHRD_FRAD,frad),
769 __ADD(ARPHRD_SKIP,skip),
770 __ADD(ARPHRD_LOOPBACK,loopback),
771 __ADD(ARPHRD_LOCALTLK,localtlk),
772 __ADD(ARPHRD_FDDI,fddi),
773 __ADD(ARPHRD_BIF,bif),
774 __ADD(ARPHRD_SIT,sit),
775 __ADD(ARPHRD_IPDDP,ip/ddp),
776 __ADD(ARPHRD_IPGRE,gre),
777 __ADD(ARPHRD_PIMREG,pimreg),
778 __ADD(ARPHRD_HIPPI,hippi),
779 __ADD(ARPHRD_ASH,ash),
780 __ADD(ARPHRD_ECONET,econet),
781 __ADD(ARPHRD_IRDA,irda),
782 __ADD(ARPHRD_FCPP,fcpp),
783 __ADD(ARPHRD_FCAL,fcal),
784 __ADD(ARPHRD_FCPL,fcpl),
785 __ADD(ARPHRD_FCFABRIC,fcfb_0),
786 __ADD(ARPHRD_FCFABRIC+1,fcfb_1),
787 __ADD(ARPHRD_FCFABRIC+2,fcfb_2),
788 __ADD(ARPHRD_FCFABRIC+3,fcfb_3),
789 __ADD(ARPHRD_FCFABRIC+4,fcfb_4),
790 __ADD(ARPHRD_FCFABRIC+5,fcfb_5),
791 __ADD(ARPHRD_FCFABRIC+6,fcfb_6),
792 __ADD(ARPHRD_FCFABRIC+7,fcfb_7),
793 __ADD(ARPHRD_FCFABRIC+8,fcfb_8),
794 __ADD(ARPHRD_FCFABRIC+9,fcfb_9),
795 __ADD(ARPHRD_FCFABRIC+10,fcfb_10),
796 __ADD(ARPHRD_FCFABRIC+11,fcfb_11),
797 __ADD(ARPHRD_FCFABRIC+12,fcfb_12),
798 __ADD(ARPHRD_IEEE802_TR,tr),
799 __ADD(ARPHRD_IEEE80211,ieee802.11),
800 __ADD(ARPHRD_IEEE80211_PRISM,ieee802.11_prism),
801 __ADD(ARPHRD_IEEE80211_RADIOTAP,ieee802.11_radiotap),
802 __ADD(ARPHRD_IEEE802154,ieee802.15.4),
803 __ADD(ARPHRD_IEEE802154_MONITOR,ieee802.15.4_monitor),
804 __ADD(ARPHRD_PHONET,phonet),
805 __ADD(ARPHRD_PHONET_PIPE,phonet_pipe),
806 __ADD(ARPHRD_CAIF,caif),
807 __ADD(ARPHRD_IP6GRE,ip6gre),
808 __ADD(ARPHRD_NETLINK,netlink),
809 __ADD(ARPHRD_6LOWPAN,6lowpan),
810 __ADD(ARPHRD_VOID,
void),
811 __ADD(ARPHRD_NONE,nohdr),
814char * nl_llproto2str(
int llproto,
char *buf,
size_t len)
816 return __type2str(llproto, buf, len, llprotos, ARRAY_SIZE(llprotos));
819int nl_str2llproto(
const char *name)
821 return __str2type(name, llprotos, ARRAY_SIZE(llprotos));
832static const struct trans_tbl ether_protos[] = {
833 __ADD(ETH_P_LOOP,loop),
834 __ADD(ETH_P_PUP,pup),
835 __ADD(ETH_P_PUPAT,pupat),
837 __ADD(ETH_P_X25,x25),
838 __ADD(ETH_P_ARP,arp),
839 __ADD(ETH_P_BPQ,bpq),
840 __ADD(ETH_P_IEEEPUP,ieeepup),
841 __ADD(ETH_P_IEEEPUPAT,ieeepupat),
842 __ADD(ETH_P_DEC,dec),
843 __ADD(ETH_P_DNA_DL,dna_dl),
844 __ADD(ETH_P_DNA_RC,dna_rc),
845 __ADD(ETH_P_DNA_RT,dna_rt),
846 __ADD(ETH_P_LAT,lat),
847 __ADD(ETH_P_DIAG,diag),
848 __ADD(ETH_P_CUST,cust),
849 __ADD(ETH_P_SCA,sca),
850 __ADD(ETH_P_TEB,teb),
851 __ADD(ETH_P_RARP,rarp),
852 __ADD(ETH_P_ATALK,atalk),
853 __ADD(ETH_P_AARP,aarp),
855 __ADD(ETH_P_8021Q,802.1q),
857 __ADD(ETH_P_IPX,ipx),
858 __ADD(ETH_P_IPV6,ipv6),
859 __ADD(ETH_P_PAUSE,pause),
860 __ADD(ETH_P_SLOW,slow),
862 __ADD(ETH_P_WCCP,wccp),
864 __ADD(ETH_P_PPP_DISC,ppp_disc),
865 __ADD(ETH_P_PPP_SES,ppp_ses),
866 __ADD(ETH_P_MPLS_UC,mpls_uc),
867 __ADD(ETH_P_MPLS_MC,mpls_mc),
868 __ADD(ETH_P_ATMMPOA,atmmpoa),
869 __ADD(ETH_P_LINK_CTL,link_ctl),
870 __ADD(ETH_P_ATMFATE,atmfate),
871 __ADD(ETH_P_PAE,pae),
872 __ADD(ETH_P_AOE,aoe),
873 __ADD(ETH_P_TIPC,tipc),
874 __ADD(ETH_P_1588,ieee1588),
875 __ADD(ETH_P_FCOE,fcoe),
876 __ADD(ETH_P_FIP,fip),
877 __ADD(ETH_P_EDSA,edsa),
878 __ADD(ETH_P_EDP2,edp2),
879 __ADD(ETH_P_802_3,802.3),
880 __ADD(ETH_P_AX25,ax25),
881 __ADD(ETH_P_ALL,all),
882 __ADD(ETH_P_802_2,802.2),
883 __ADD(ETH_P_SNAP,snap),
884 __ADD(ETH_P_DDCMP,ddcmp),
885 __ADD(ETH_P_WAN_PPP,wan_ppp),
886 __ADD(ETH_P_PPP_MP,ppp_mp),
887 __ADD(ETH_P_LOCALTALK,localtalk),
888 __ADD(ETH_P_CAN,can),
889 __ADD(ETH_P_PPPTALK,ppptalk),
890 __ADD(ETH_P_TR_802_2,tr_802.2),
891 __ADD(ETH_P_MOBITEX,mobitex),
892 __ADD(ETH_P_CONTROL,control),
893 __ADD(ETH_P_IRDA,irda),
894 __ADD(ETH_P_ECONET,econet),
895 __ADD(ETH_P_HDLC,hdlc),
896 __ADD(ETH_P_ARCNET,arcnet),
897 __ADD(ETH_P_DSA,dsa),
898 __ADD(ETH_P_TRAILER,trailer),
899 __ADD(ETH_P_PHONET,phonet),
900 __ADD(ETH_P_IEEE802154,ieee802154),
901 __ADD(ETH_P_CAIF,caif),
904char *nl_ether_proto2str(
int eproto,
char *buf,
size_t len)
906 return __type2str(eproto, buf, len, ether_protos,
907 ARRAY_SIZE(ether_protos));
910int nl_str2ether_proto(
const char *name)
912 return __str2type(name, ether_protos, ARRAY_SIZE(ether_protos));
922char *nl_ip_proto2str(
int proto,
char *buf,
size_t len)
924 if (nl_getprotobynumber(proto, buf, len))
927 snprintf(buf, len,
"0x%x", proto);
931int nl_str2ip_proto(
const char *name)
940 p = nl_getprotobyname(name);
944 l = strtoul(name, &end, 0);
945 if (name == end || *end !=
'\0' || l > (
unsigned long)INT_MAX)
946 return -NLE_OBJ_NOTFOUND;
974 for (i = 0; i < params->
dp_prefix; i++) {
976 fprintf(params->
dp_fd,
" ");
978 strncat(params->
dp_buf,
" ",
980 strlen(params->
dp_buf) - 1);
985 params->
dp_nl_cb(params, params->dp_line);
988static void dump_one(
struct nl_dump_params *parms,
const char *fmt,
992 vfprintf(parms->
dp_fd, fmt, args);
995 if (vasprintf(&buf, fmt, args) >= 0) {
997 parms->
dp_cb(parms, buf);
999 strncat(parms->
dp_buf, buf,
1001 strlen(parms->
dp_buf) - 1);
1021 va_start(args, fmt);
1022 dump_one(params, fmt, args);
1026void nl_dump_line(
struct nl_dump_params *parms,
const char *fmt, ...)
1032 va_start(args, fmt);
1033 dump_one(parms, fmt, args);
1042int __trans_list_add(
int i,
const char *a,
struct nl_list_head *head)
1044 struct trans_list *tl;
1046 tl = calloc(1,
sizeof(*tl));
1053 nl_list_add_tail(&tl->list, head);
1060 struct trans_list *tl, *next;
1062 nl_list_for_each_entry_safe(tl, next, head, list) {
1067 nl_init_list_head(head);
1070char *__type2str(
int type,
char *buf,
size_t len,
1071 const struct trans_tbl *tbl,
size_t tbl_len)
1074 for (i = 0; i < tbl_len; i++) {
1075 if (tbl[i].i == type) {
1076 snprintf(buf, len,
"%s", tbl[i].a);
1081 snprintf(buf, len,
"0x%x", type);
1085char *__list_type2str(
int type,
char *buf,
size_t len,
1088 struct trans_list *tl;
1090 nl_list_for_each_entry(tl, head, list) {
1091 if (tl->i == type) {
1092 snprintf(buf, len,
"%s", tl->a);
1097 snprintf(buf, len,
"0x%x", type);
1101char *__flags2str(
int flags,
char *buf,
size_t len,
1102 const struct trans_tbl *tbl,
size_t tbl_len)
1107 memset(buf, 0, len);
1109 for (i = 0; i < tbl_len; i++) {
1110 if (tbl[i].i & tmp) {
1112 strncat(buf, tbl[i].a, len - strlen(buf) - 1);
1114 strncat(buf,
",", len - strlen(buf) - 1);
1121int __str2type(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1130 for (i = 0; i < tbl_len; i++)
1131 if (!strcasecmp(tbl[i].a, buf))
1134 l = strtoul(buf, &end, 0);
1135 if (l == ULONG_MAX || *end !=
'\0')
1136 return -NLE_OBJ_NOTFOUND;
1141int __list_str2type(
const char *buf,
struct nl_list_head *head)
1143 struct trans_list *tl;
1150 nl_list_for_each_entry(tl, head, list) {
1151 if (!strcasecmp(tl->a, buf))
1155 l = strtoul(buf, &end, 0);
1156 if (l == ULONG_MAX || *end !=
'\0')
1157 return -NLE_OBJ_NOTFOUND;
1162int __str2flags(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1167 char *p = (
char *) buf, *t;
1174 len = t ? t - p : strlen(p);
1175 for (i = 0; i < tbl_len; i++)
1176 if (len == strlen(tbl[i].a) &&
1177 !strncasecmp(tbl[i].a, p, len))
1189void dump_from_ops(
struct nl_object *obj,
struct nl_dump_params *params)
1193 if (type < 0 || type > NL_DUMP_MAX)
1196 params->dp_line = 0;
1203 dp_dump_line(params, 0,
"%s ",
1204 nl_cache_mngt_type2name(obj->ce_ops,
1205 obj->ce_ops->co_protocol,
1212 if (obj->ce_ops->oo_dump[type])
1213 obj->ce_ops->oo_dump[type](obj, params);
1235int nl_has_capability (
int capability)
1237 static const uint8_t caps[ ( NL_CAPABILITY_MAX + 7 ) / 8 ] = {
1238#define _NL_ASSERT(expr) ( 0 * sizeof(struct { unsigned int x: ( (!!(expr)) ? 1 : -1 ); }) )
1239#define _NL_SETV(i, r, v) \
1240 ( _NL_ASSERT( (v) == 0 || (i) * 8 + (r) == (v) - 1 ) + \
1241 ( (v) == 0 ? 0 : (1 << (r)) ) )
1242#define _NL_SET(i, v0, v1, v2, v3, v4, v5, v6, v7) \
1244 _NL_SETV((i), 0, (v0)) | _NL_SETV((i), 4, (v4)) | \
1245 _NL_SETV((i), 1, (v1)) | _NL_SETV((i), 5, (v5)) | \
1246 _NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \
1247 _NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) )
1249 NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE,
1250 NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE,
1251 NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
1252 NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
1253 NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
1254 NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
1255 NL_CAPABILITY_VERSION_3_2_26,
1256 NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK),
1258 NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE,
1259 NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX,
1260 NL_CAPABILITY_VERSION_3_2_27,
1261 NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE,
1262 NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE,
1263 NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR,
1264 NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE,
1265 NL_CAPABILITY_NL_OBJECT_DIFF64),
1267 NL_CAPABILITY_XFRM_SA_KEY_SIZE,
1268 NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
1269 NL_CAPABILITY_VERSION_3_2_28,
1270 NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
1271 NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
1272 NL_CAPABILITY_XFRM_SEC_CTX_LEN,
1273 NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE,
1274 NL_CAPABILITY_NL_RECVMSGS_PEEK_BY_DEFAULT),
1276 NL_CAPABILITY_VERSION_3_2_29,
1277 NL_CAPABILITY_XFRM_SP_SEC_CTX_LEN,
1278 NL_CAPABILITY_VERSION_3_3_0,
1279 NL_CAPABILITY_VERSION_3_4_0,
1280 NL_CAPABILITY_ROUTE_FIX_VLAN_SET_EGRESS_MAP,
1281 NL_CAPABILITY_VERSION_3_5_0,
1282 NL_CAPABILITY_NL_OBJECT_IDENTICAL_PARTIAL,
1283 NL_CAPABILITY_VERSION_3_6_0),
1285 NL_CAPABILITY_VERSION_3_7_0,
1286 NL_CAPABILITY_VERSION_3_8_0,
1287 NL_CAPABILITY_VERSION_3_9_0,
1312 if (capability <= 0 || capability > NL_CAPABILITY_MAX)
1315 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.