27 #include <netlink-private/netlink.h> 28 #include <netlink-private/utils.h> 29 #include <netlink/netlink.h> 30 #include <netlink/utils.h> 31 #include <linux/socket.h> 59 static void __init nl_debug_init(
void)
63 if ((nldbg = getenv(
"NLDBG"))) {
64 long level = strtol(nldbg, &end, 0);
69 nl_debug_dp.
dp_fd = stderr;
73 int __nl_read_num_str_file(
const char *path,
int (*cb)(
long,
const char *))
78 fd = fopen(path,
"r");
80 return -nl_syserr2nlerr(errno);
82 while (fgets(buf,
sizeof(buf), fd)) {
87 if (*buf ==
'#' || *buf ==
'\n' || *buf ==
'\r')
90 num = strtol(buf, &end, 0);
96 if (num == LONG_MIN || num == LONG_MAX) {
101 while (*end ==
' ' || *end ==
'\t')
104 goodlen = strcspn(end,
"#\r\n\t ");
124 const char *nl_strerror_l(
int err)
126 int errno_save = errno;
127 locale_t loc = newlocale(LC_MESSAGES_MASK,
"", (locale_t)0);
130 if (loc == (locale_t)0) {
132 loc = newlocale(LC_MESSAGES_MASK,
133 "POSIX", (locale_t)0);
135 if (loc != (locale_t)0) {
136 buf = strerror_l(err, loc);
139 buf =
"newlocale() failed";
165 if (l >= 1099511627776LL) {
167 return ((
double) l) / 1099511627776LL;
168 }
else if (l >= 1073741824) {
170 return ((
double) l) / 1073741824;
171 }
else if (l >= 1048576) {
173 return ((
double) l) / 1048576;
174 }
else if (l >= 1024) {
176 return ((
double) l) / 1024;
196 if (l >= 1000000000000ULL) {
198 return ((
double) l) / 1000000000000ULL;
201 if (l >= 1000000000) {
203 return ((
double) l) / 1000000000;
208 return ((
double) l) / 1000000;
213 return ((
double) l) / 1000;
220 int nl_rate2str(
unsigned long long rate,
int type,
char *buf,
size_t len)
238 return snprintf(buf, len,
"%.2f%s/s", frac, unit);
255 return ((
double) l) / 1000000;
256 }
else if (l >= 1000) {
258 return ((
double) l) / 1000;
291 long l = strtol(str, &p, 0);
296 if (!strcasecmp(p,
"kb") || !strcasecmp(p,
"k"))
298 else if (!strcasecmp(p,
"gb") || !strcasecmp(p,
"g"))
300 else if (!strcasecmp(p,
"gbit"))
302 else if (!strcasecmp(p,
"mb") || !strcasecmp(p,
"m"))
304 else if (!strcasecmp(p,
"mbit"))
306 else if (!strcasecmp(p,
"kbit"))
308 else if (!strcasecmp(p,
"bit"))
310 else if (strcasecmp(p,
"b") != 0)
317 static const struct {
321 { 1024. * 1024. * 1024. * 1024. * 1024.,
"EiB" },
322 { 1024. * 1024. * 1024. * 1024.,
"TiB" },
323 { 1024. * 1024. * 1024.,
"GiB" },
324 { 1024. * 1024.,
"MiB" },
356 snprintf(buf, len,
"0B");
360 for (i = 0; i < ARRAY_SIZE(size_units); i++) {
361 if (size >= size_units[i].limit) {
362 snprintf(buf, len,
"%.2g%s",
363 (
double) size / size_units[i].limit,
388 double d = strtod(str, &p);
396 if (d > 1.0f || d < 0.0f)
399 if (*p && strcmp(p,
"%") != 0)
416 static uint32_t user_hz = USER_HZ;
417 static uint32_t psched_hz = USER_HZ;
419 static double ticks_per_usec = 1.0f;
430 static void __init get_psched_settings(
void)
432 char name[FILENAME_MAX];
437 long hz = strtol(getenv(
"HZ"), NULL, 0);
439 if (LONG_MIN != hz && LONG_MAX != hz) {
446 user_hz = sysconf(_SC_CLK_TCK);
450 if (getenv(
"TICKS_PER_USEC")) {
451 double t = strtod(getenv(
"TICKS_PER_USEC"), NULL);
455 if (getenv(
"PROC_NET_PSCHED"))
456 snprintf(name,
sizeof(name),
"%s", getenv(
"PROC_NET_PSCHED"));
457 else if (getenv(
"PROC_ROOT"))
458 snprintf(name,
sizeof(name),
"%s/net/psched",
459 getenv(
"PROC_ROOT"));
461 strncpy(name,
"/proc/net/psched",
sizeof(name) - 1);
463 if ((fd = fopen(name,
"r"))) {
464 unsigned int ns_per_usec, ns_per_tick, nom, denom;
466 if (fscanf(fd,
"%08x %08x %08x %08x",
467 &ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
468 NL_DBG(1,
"Fatal error: can not read psched settings from \"%s\". " \
469 "Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
470 "environment variables\n", name);
474 ticks_per_usec = (double) ns_per_usec /
475 (
double) ns_per_tick;
509 return us * ticks_per_usec;
520 return ticks / ticks_per_usec;
523 int nl_str2msec(
const char *str, uint64_t *result)
525 uint64_t total = 0, l;
530 l = strtoul(str, &p, 0);
534 plen = strcspn(p,
" \t");
538 else if (!strncasecmp(p,
"sec", plen))
540 else if (!strncasecmp(p,
"min", plen))
541 total += (l * 1000*60);
542 else if (!strncasecmp(p,
"hour", plen))
543 total += (l * 1000*60*60);
544 else if (!strncasecmp(p,
"day", plen))
545 total += (l * 1000*60*60*24);
552 }
while (*str && *p);
575 static const char *units[5] = {
"d",
"h",
"m",
"s",
"msec"};
576 char *
const buf_orig = buf;
579 snprintf(buf, len,
"0msec");
583 #define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit 591 for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
595 l = snprintf(buf, len,
"%s%" PRIu64
"%s",
596 (buf==buf_orig) ?
"" :
" ", split[i], units[i]);
611 static const struct trans_tbl nlfamilies[] = {
612 __ADD(NETLINK_ROUTE,route),
613 __ADD(NETLINK_USERSOCK,usersock),
614 __ADD(NETLINK_FIREWALL,firewall),
615 __ADD(NETLINK_INET_DIAG,inetdiag),
616 __ADD(NETLINK_NFLOG,nflog),
617 __ADD(NETLINK_XFRM,xfrm),
618 __ADD(NETLINK_SELINUX,selinux),
619 __ADD(NETLINK_ISCSI,iscsi),
620 __ADD(NETLINK_AUDIT,audit),
621 __ADD(NETLINK_FIB_LOOKUP,fib_lookup),
622 __ADD(NETLINK_CONNECTOR,connector),
623 __ADD(NETLINK_NETFILTER,netfilter),
624 __ADD(NETLINK_IP6_FW,ip6_fw),
625 __ADD(NETLINK_DNRTMSG,dnrtmsg),
626 __ADD(NETLINK_KOBJECT_UEVENT,kobject_uevent),
627 __ADD(NETLINK_GENERIC,
generic),
628 __ADD(NETLINK_SCSITRANSPORT,scsitransport),
629 __ADD(NETLINK_ECRYPTFS,ecryptfs),
630 __ADD(NETLINK_RDMA,rdma),
631 __ADD(NETLINK_CRYPTO,crypto),
634 char * nl_nlfamily2str(
int family,
char *buf,
size_t size)
636 return __type2str(family, buf, size, nlfamilies,
637 ARRAY_SIZE(nlfamilies));
640 int nl_str2nlfamily(
const char *name)
642 return __str2type(name, nlfamilies, ARRAY_SIZE(nlfamilies));
654 static const struct trans_tbl llprotos[] = {
656 __ADD(ARPHRD_NETROM,netrom),
657 __ADD(ARPHRD_ETHER,ether),
658 __ADD(ARPHRD_EETHER,eether),
659 __ADD(ARPHRD_AX25,ax25),
660 __ADD(ARPHRD_PRONET,pronet),
661 __ADD(ARPHRD_CHAOS,chaos),
662 __ADD(ARPHRD_IEEE802,ieee802),
663 __ADD(ARPHRD_ARCNET,arcnet),
664 __ADD(ARPHRD_APPLETLK,atalk),
665 __ADD(ARPHRD_DLCI,dlci),
666 __ADD(ARPHRD_ATM,atm),
667 __ADD(ARPHRD_METRICOM,metricom),
668 __ADD(ARPHRD_IEEE1394,ieee1394),
669 __ADD(ARPHRD_EUI64,eui64),
670 __ADD(ARPHRD_INFINIBAND,infiniband),
671 __ADD(ARPHRD_SLIP,slip),
672 __ADD(ARPHRD_CSLIP,cslip),
673 __ADD(ARPHRD_SLIP6,slip6),
674 __ADD(ARPHRD_CSLIP6,cslip6),
675 __ADD(ARPHRD_RSRVD,rsrvd),
676 __ADD(ARPHRD_ADAPT,adapt),
677 __ADD(ARPHRD_ROSE,rose),
678 __ADD(ARPHRD_X25,x25),
679 __ADD(ARPHRD_HWX25,hwx25),
680 __ADD(ARPHRD_CAN,can),
681 __ADD(ARPHRD_PPP,ppp),
682 __ADD(ARPHRD_CISCO,cisco),
683 __ADD(ARPHRD_HDLC,hdlc),
684 __ADD(ARPHRD_LAPB,lapb),
685 __ADD(ARPHRD_DDCMP,ddcmp),
686 __ADD(ARPHRD_RAWHDLC,rawhdlc),
687 __ADD(ARPHRD_TUNNEL,ipip),
688 __ADD(ARPHRD_TUNNEL6,tunnel6),
689 __ADD(ARPHRD_FRAD,frad),
690 __ADD(ARPHRD_SKIP,skip),
691 __ADD(ARPHRD_LOOPBACK,loopback),
692 __ADD(ARPHRD_LOCALTLK,localtlk),
693 __ADD(ARPHRD_FDDI,fddi),
694 __ADD(ARPHRD_BIF,bif),
695 __ADD(ARPHRD_SIT,sit),
696 __ADD(ARPHRD_IPDDP,ip/ddp),
697 __ADD(ARPHRD_IPGRE,gre),
698 __ADD(ARPHRD_PIMREG,pimreg),
699 __ADD(ARPHRD_HIPPI,hippi),
700 __ADD(ARPHRD_ASH,ash),
701 __ADD(ARPHRD_ECONET,econet),
702 __ADD(ARPHRD_IRDA,irda),
703 __ADD(ARPHRD_FCPP,fcpp),
704 __ADD(ARPHRD_FCAL,fcal),
705 __ADD(ARPHRD_FCPL,fcpl),
706 __ADD(ARPHRD_FCFABRIC,fcfb_0),
707 __ADD(ARPHRD_FCFABRIC+1,fcfb_1),
708 __ADD(ARPHRD_FCFABRIC+2,fcfb_2),
709 __ADD(ARPHRD_FCFABRIC+3,fcfb_3),
710 __ADD(ARPHRD_FCFABRIC+4,fcfb_4),
711 __ADD(ARPHRD_FCFABRIC+5,fcfb_5),
712 __ADD(ARPHRD_FCFABRIC+6,fcfb_6),
713 __ADD(ARPHRD_FCFABRIC+7,fcfb_7),
714 __ADD(ARPHRD_FCFABRIC+8,fcfb_8),
715 __ADD(ARPHRD_FCFABRIC+9,fcfb_9),
716 __ADD(ARPHRD_FCFABRIC+10,fcfb_10),
717 __ADD(ARPHRD_FCFABRIC+11,fcfb_11),
718 __ADD(ARPHRD_FCFABRIC+12,fcfb_12),
719 __ADD(ARPHRD_IEEE802_TR,tr),
720 __ADD(ARPHRD_IEEE80211,ieee802.11),
721 __ADD(ARPHRD_IEEE80211_PRISM,ieee802.11_prism),
722 __ADD(ARPHRD_IEEE80211_RADIOTAP,ieee802.11_radiotap),
723 __ADD(ARPHRD_IEEE802154,ieee802.15.4),
724 __ADD(ARPHRD_IEEE802154_MONITOR,ieee802.15.4_monitor),
725 __ADD(ARPHRD_PHONET,phonet),
726 __ADD(ARPHRD_PHONET_PIPE,phonet_pipe),
727 __ADD(ARPHRD_CAIF,caif),
728 __ADD(ARPHRD_IP6GRE,ip6gre),
729 __ADD(ARPHRD_NETLINK,netlink),
730 __ADD(ARPHRD_6LOWPAN,6lowpan),
731 __ADD(ARPHRD_VOID,
void),
732 __ADD(ARPHRD_NONE,nohdr),
735 char * nl_llproto2str(
int llproto,
char *buf,
size_t len)
737 return __type2str(llproto, buf, len, llprotos, ARRAY_SIZE(llprotos));
740 int nl_str2llproto(
const char *name)
742 return __str2type(name, llprotos, ARRAY_SIZE(llprotos));
753 static const struct trans_tbl ether_protos[] = {
754 __ADD(ETH_P_LOOP,loop),
755 __ADD(ETH_P_PUP,pup),
756 __ADD(ETH_P_PUPAT,pupat),
758 __ADD(ETH_P_X25,x25),
759 __ADD(ETH_P_ARP,arp),
760 __ADD(ETH_P_BPQ,bpq),
761 __ADD(ETH_P_IEEEPUP,ieeepup),
762 __ADD(ETH_P_IEEEPUPAT,ieeepupat),
763 __ADD(ETH_P_DEC,dec),
764 __ADD(ETH_P_DNA_DL,dna_dl),
765 __ADD(ETH_P_DNA_RC,dna_rc),
766 __ADD(ETH_P_DNA_RT,dna_rt),
767 __ADD(ETH_P_LAT,lat),
768 __ADD(ETH_P_DIAG,diag),
769 __ADD(ETH_P_CUST,cust),
770 __ADD(ETH_P_SCA,sca),
771 __ADD(ETH_P_TEB,teb),
772 __ADD(ETH_P_RARP,rarp),
773 __ADD(ETH_P_ATALK,atalk),
774 __ADD(ETH_P_AARP,aarp),
776 __ADD(ETH_P_8021Q,802.1q),
778 __ADD(ETH_P_IPX,ipx),
779 __ADD(ETH_P_IPV6,ipv6),
780 __ADD(ETH_P_PAUSE,pause),
781 __ADD(ETH_P_SLOW,slow),
783 __ADD(ETH_P_WCCP,wccp),
785 __ADD(ETH_P_PPP_DISC,ppp_disc),
786 __ADD(ETH_P_PPP_SES,ppp_ses),
787 __ADD(ETH_P_MPLS_UC,mpls_uc),
788 __ADD(ETH_P_MPLS_MC,mpls_mc),
789 __ADD(ETH_P_ATMMPOA,atmmpoa),
790 __ADD(ETH_P_LINK_CTL,link_ctl),
791 __ADD(ETH_P_ATMFATE,atmfate),
792 __ADD(ETH_P_PAE,pae),
793 __ADD(ETH_P_AOE,aoe),
794 __ADD(ETH_P_TIPC,tipc),
795 __ADD(ETH_P_1588,ieee1588),
796 __ADD(ETH_P_FCOE,fcoe),
797 __ADD(ETH_P_FIP,fip),
798 __ADD(ETH_P_EDSA,edsa),
799 __ADD(ETH_P_EDP2,edp2),
800 __ADD(ETH_P_802_3,802.3),
801 __ADD(ETH_P_AX25,ax25),
802 __ADD(ETH_P_ALL,all),
803 __ADD(ETH_P_802_2,802.2),
804 __ADD(ETH_P_SNAP,snap),
805 __ADD(ETH_P_DDCMP,ddcmp),
806 __ADD(ETH_P_WAN_PPP,wan_ppp),
807 __ADD(ETH_P_PPP_MP,ppp_mp),
808 __ADD(ETH_P_LOCALTALK,localtalk),
809 __ADD(ETH_P_CAN,can),
810 __ADD(ETH_P_PPPTALK,ppptalk),
811 __ADD(ETH_P_TR_802_2,tr_802.2),
812 __ADD(ETH_P_MOBITEX,mobitex),
813 __ADD(ETH_P_CONTROL,control),
814 __ADD(ETH_P_IRDA,irda),
815 __ADD(ETH_P_ECONET,econet),
816 __ADD(ETH_P_HDLC,hdlc),
817 __ADD(ETH_P_ARCNET,arcnet),
818 __ADD(ETH_P_DSA,dsa),
819 __ADD(ETH_P_TRAILER,trailer),
820 __ADD(ETH_P_PHONET,phonet),
821 __ADD(ETH_P_IEEE802154,ieee802154),
822 __ADD(ETH_P_CAIF,caif),
825 char *nl_ether_proto2str(
int eproto,
char *buf,
size_t len)
827 return __type2str(eproto, buf, len, ether_protos,
828 ARRAY_SIZE(ether_protos));
831 int nl_str2ether_proto(
const char *name)
833 return __str2type(name, ether_protos, ARRAY_SIZE(ether_protos));
843 char *nl_ip_proto2str(
int proto,
char *buf,
size_t len)
845 struct protoent *p = getprotobynumber(proto);
848 snprintf(buf, len,
"%s", p->p_name);
852 snprintf(buf, len,
"0x%x", proto);
856 int nl_str2ip_proto(
const char *name)
858 struct protoent *p = getprotobyname(name);
865 l = strtoul(name, &end, 0);
866 if (l == ULONG_MAX || *end !=
'\0')
867 return -NLE_OBJ_NOTFOUND;
895 for (i = 0; i < params->
dp_prefix; i++) {
897 fprintf(params->
dp_fd,
" ");
899 strncat(params->
dp_buf,
" ",
901 strlen(params->
dp_buf) - 1);
906 params->
dp_nl_cb(params, params->dp_line);
909 static void dump_one(
struct nl_dump_params *parms,
const char *fmt,
913 vfprintf(parms->
dp_fd, fmt, args);
916 if (vasprintf(&buf, fmt, args) >= 0) {
918 parms->
dp_cb(parms, buf);
920 strncat(parms->
dp_buf, buf,
922 strlen(parms->
dp_buf) - 1);
943 dump_one(params, fmt, args);
947 void nl_dump_line(
struct nl_dump_params *parms,
const char *fmt, ...)
954 dump_one(parms, fmt, args);
963 int __trans_list_add(
int i,
const char *a,
struct nl_list_head *head)
965 struct trans_list *tl;
967 tl = calloc(1,
sizeof(*tl));
974 nl_list_add_tail(&tl->list, head);
981 struct trans_list *tl, *next;
983 nl_list_for_each_entry_safe(tl, next, head, list) {
988 nl_init_list_head(head);
991 char *__type2str(
int type,
char *buf,
size_t len,
992 const struct trans_tbl *tbl,
size_t tbl_len)
995 for (i = 0; i < tbl_len; i++) {
996 if (tbl[i].i == type) {
997 snprintf(buf, len,
"%s", tbl[i].a);
1002 snprintf(buf, len,
"0x%x", type);
1006 char *__list_type2str(
int type,
char *buf,
size_t len,
1009 struct trans_list *tl;
1011 nl_list_for_each_entry(tl, head, list) {
1012 if (tl->i == type) {
1013 snprintf(buf, len,
"%s", tl->a);
1018 snprintf(buf, len,
"0x%x", type);
1022 char *__flags2str(
int flags,
char *buf,
size_t len,
1023 const struct trans_tbl *tbl,
size_t tbl_len)
1028 memset(buf, 0, len);
1030 for (i = 0; i < tbl_len; i++) {
1031 if (tbl[i].i & tmp) {
1033 strncat(buf, tbl[i].a, len - strlen(buf) - 1);
1035 strncat(buf,
",", len - strlen(buf) - 1);
1042 int __str2type(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1051 for (i = 0; i < tbl_len; i++)
1052 if (!strcasecmp(tbl[i].a, buf))
1055 l = strtoul(buf, &end, 0);
1056 if (l == ULONG_MAX || *end !=
'\0')
1057 return -NLE_OBJ_NOTFOUND;
1062 int __list_str2type(
const char *buf,
struct nl_list_head *head)
1064 struct trans_list *tl;
1071 nl_list_for_each_entry(tl, head, list) {
1072 if (!strcasecmp(tl->a, buf))
1076 l = strtoul(buf, &end, 0);
1077 if (l == ULONG_MAX || *end !=
'\0')
1078 return -NLE_OBJ_NOTFOUND;
1083 int __str2flags(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1088 char *p = (
char *) buf, *t;
1095 len = t ? t - p : strlen(p);
1096 for (i = 0; i < tbl_len; i++)
1097 if (len == strlen(tbl[i].a) &&
1098 !strncasecmp(tbl[i].a, p, len))
1110 void dump_from_ops(
struct nl_object *obj,
struct nl_dump_params *params)
1114 if (type < 0 || type > NL_DUMP_MAX)
1117 params->dp_line = 0;
1124 dp_dump_line(params, 0,
"%s ",
1125 nl_cache_mngt_type2name(obj->ce_ops,
1126 obj->ce_ops->co_protocol,
1133 if (obj->ce_ops->oo_dump[type])
1134 obj->ce_ops->oo_dump[type](obj, params);
1156 int nl_has_capability (
int capability)
1158 static const uint8_t caps[ ( NL_CAPABILITY_MAX + 7 ) / 8 ] = {
1159 #define _NL_ASSERT(expr) ( 0 * sizeof(struct { unsigned int x: ( (!!(expr)) ? 1 : -1 ); }) ) 1160 #define _NL_SETV(i, r, v) \ 1161 ( _NL_ASSERT( (v) == 0 || (i) * 8 + (r) == (v) - 1 ) + \ 1162 ( (v) == 0 ? 0 : (1 << (r)) ) ) 1163 #define _NL_SET(i, v0, v1, v2, v3, v4, v5, v6, v7) \ 1165 _NL_SETV((i), 0, (v0)) | _NL_SETV((i), 4, (v4)) | \ 1166 _NL_SETV((i), 1, (v1)) | _NL_SETV((i), 5, (v5)) | \ 1167 _NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \ 1168 _NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) ) 1171 NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE,
1172 NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
1173 NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
1174 NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
1175 NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
1176 NL_CAPABILITY_VERSION_3_2_26,
1177 NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK),
1179 NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE,
1180 NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX,
1181 NL_CAPABILITY_VERSION_3_2_27,
1182 NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE,
1183 NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE,
1184 NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR,
1185 NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE,
1186 NL_CAPABILITY_NL_OBJECT_DIFF64),
1188 NL_CAPABILITY_XFRM_SA_KEY_SIZE,
1189 NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
1190 NL_CAPABILITY_VERSION_3_2_28,
1191 NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
1192 NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
1193 NL_CAPABILITY_XFRM_SEC_CTX_LEN,
1194 NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE,
1195 NL_CAPABILITY_NL_RECVMSGS_PEEK_BY_DEFAULT),
1197 NL_CAPABILITY_VERSION_3_2_29,
1224 if (capability <= 0 || capability > NL_CAPABILITY_MAX)
1227 return (caps[capability / 8] & (1 << (capability % 8))) != 0;
int nl_get_user_hz(void)
Return the value of HZ.
void nl_new_line(struct nl_dump_params *params)
Handle a new line while dumping.
char * dp_buf
Alternatively the output may be redirected into a buffer.
FILE * dp_fd
File descriptor the dumping output should go to.
void(* dp_cb)(struct nl_dump_params *, char *)
A callback invoked for output.
long nl_size2int(const char *str)
Convert a character string to a size.
double nl_cancel_down_bits(unsigned long long l, char **unit)
Cancel down a bit counter.
enum nl_dump_type dp_type
Specifies the type of dump that is requested.
char * nl_msec2str(uint64_t msec, char *buf, size_t len)
Convert milliseconds to a character string.
#define NL_PROB_MAX
Upper probability limit nl_dump_type.
Dump all attributes but no statistics.
char * nl_size2str(const size_t size, char *buf, const size_t len)
Convert a size toa character string.
void(* dp_nl_cb)(struct nl_dump_params *, int)
A callback invoked for every new line, can be used to customize the indentation.
rtnl_route_build_msg() no longer guesses the route scope if explicitly set to RT_SCOPE_NOWHERE.
double nl_cancel_down_bytes(unsigned long long l, char **unit)
Cancel down a byte counter.
int dp_pre_dump
PRIVATE Set if a dump was performed prior to the actual dump handler.
double nl_cancel_down_us(uint32_t l, char **unit)
Cancel down a micro second value.
int nl_get_psched_hz(void)
Return the value of packet scheduler HZ.
uint32_t nl_ticks2us(uint32_t ticks)
Convert ticks to micro seconds.
long nl_prob2int(const char *str)
Convert a character string to a probability.
int dp_prefix
Specifies the number of whitespaces to be put in front of every new line (indentation).
uint32_t nl_us2ticks(uint32_t us)
Convert micro seconds to ticks.
size_t dp_buflen
Length of the buffer dp_buf.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
int nl_debug
Global variable indicating the desired level of debugging output.
int dp_dump_msgtype
Causes each element to be prefixed with the message type.