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> 33 #ifdef HAVE_STRERROR_L 61 static void __init nl_debug_init(
void)
65 if ((nldbg = getenv(
"NLDBG"))) {
66 long level = strtol(nldbg, &end, 0);
71 nl_debug_dp.
dp_fd = stderr;
75 int __nl_read_num_str_file(
const char *path,
int (*cb)(
long,
const char *))
80 fd = fopen(path,
"re");
82 return -nl_syserr2nlerr(errno);
84 while (fgets(buf,
sizeof(buf), fd)) {
89 if (*buf ==
'#' || *buf ==
'\n' || *buf ==
'\r')
92 num = strtol(buf, &end, 0);
98 if (num == LONG_MIN || num == LONG_MAX) {
103 while (*end ==
' ' || *end ==
'\t')
106 goodlen = strcspn(end,
"#\r\n\t ");
126 const char *nl_strerror_l(
int err)
129 #ifdef HAVE_STRERROR_L 130 int errno_save = errno;
131 locale_t loc = newlocale(LC_MESSAGES_MASK,
"", (locale_t)0);
133 if (loc == (locale_t)0) {
135 loc = newlocale(LC_MESSAGES_MASK,
136 "POSIX", (locale_t)0);
138 if (loc != (locale_t)0) {
139 buf = strerror_l(err, loc);
142 buf =
"newlocale() failed";
171 if (l >= 1099511627776LL) {
173 return ((
double) l) / 1099511627776LL;
174 }
else if (l >= 1073741824) {
176 return ((
double) l) / 1073741824;
177 }
else if (l >= 1048576) {
179 return ((
double) l) / 1048576;
180 }
else if (l >= 1024) {
182 return ((
double) l) / 1024;
202 if (l >= 1000000000000ULL) {
204 return ((
double) l) / 1000000000000ULL;
207 if (l >= 1000000000) {
209 return ((
double) l) / 1000000000;
214 return ((
double) l) / 1000000;
219 return ((
double) l) / 1000;
226 int nl_rate2str(
unsigned long long rate,
int type,
char *buf,
size_t len)
244 return snprintf(buf, len,
"%.2f%s/s", frac, unit);
261 return ((
double) l) / 1000000;
262 }
else if (l >= 1000) {
264 return ((
double) l) / 1000;
297 long l = strtol(str, &p, 0);
302 if (!strcasecmp(p,
"kb") || !strcasecmp(p,
"k"))
304 else if (!strcasecmp(p,
"gb") || !strcasecmp(p,
"g"))
306 else if (!strcasecmp(p,
"gbit"))
308 else if (!strcasecmp(p,
"mb") || !strcasecmp(p,
"m"))
310 else if (!strcasecmp(p,
"mbit"))
312 else if (!strcasecmp(p,
"kbit"))
314 else if (!strcasecmp(p,
"bit"))
316 else if (strcasecmp(p,
"b") != 0)
323 static const struct {
327 { 1024. * 1024. * 1024. * 1024. * 1024.,
"EiB" },
328 { 1024. * 1024. * 1024. * 1024.,
"TiB" },
329 { 1024. * 1024. * 1024.,
"GiB" },
330 { 1024. * 1024.,
"MiB" },
362 snprintf(buf, len,
"0B");
366 for (i = 0; i < ARRAY_SIZE(size_units); i++) {
367 if (size >= size_units[i].limit) {
368 snprintf(buf, len,
"%.2g%s",
369 (
double) size / size_units[i].limit,
394 double d = strtod(str, &p);
402 if (d > 1.0f || d < 0.0f)
405 if (*p && strcmp(p,
"%") != 0)
422 static uint32_t user_hz = USER_HZ;
423 static uint32_t psched_hz = USER_HZ;
425 static double ticks_per_usec = 1.0f;
436 static void get_psched_settings(
void)
438 char name[FILENAME_MAX];
441 static volatile int initialized = 0;
445 if (initialized == 1)
450 if (initialized == 1)
453 if ((ev = getenv(
"HZ"))) {
454 long hz = strtol(ev, NULL, 0);
456 if (LONG_MIN != hz && LONG_MAX != hz) {
463 user_hz = sysconf(_SC_CLK_TCK);
467 if ((ev = getenv(
"TICKS_PER_USEC"))) {
468 double t = strtod(ev, NULL);
472 if ((ev = getenv(
"PROC_NET_PSCHED")))
473 snprintf(name,
sizeof(name),
"%s", ev);
474 else if ((ev = getenv(
"PROC_ROOT")))
475 snprintf(name,
sizeof(name),
"%s/net/psched", ev);
477 strncpy(name,
"/proc/net/psched",
sizeof(name) - 1);
479 if ((fd = fopen(name,
"re"))) {
480 unsigned int ns_per_usec, ns_per_tick, nom, denom;
482 if (fscanf(fd,
"%08x %08x %08x %08x",
483 &ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
484 NL_DBG(1,
"Fatal error: can not read psched settings from \"%s\". " \
485 "Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
486 "environment variables\n", name);
490 ticks_per_usec = (double) ns_per_usec /
491 (
double) ns_per_tick;
510 get_psched_settings();
519 get_psched_settings();
530 get_psched_settings();
531 return us * ticks_per_usec;
542 get_psched_settings();
543 return ticks / ticks_per_usec;
546 int nl_str2msec(
const char *str, uint64_t *result)
548 uint64_t total = 0, l;
553 l = strtoul(str, &p, 0);
557 plen = strcspn(p,
" \t");
561 else if (!strncasecmp(p,
"sec", plen))
563 else if (!strncasecmp(p,
"min", plen))
564 total += (l * 1000*60);
565 else if (!strncasecmp(p,
"hour", plen))
566 total += (l * 1000*60*60);
567 else if (!strncasecmp(p,
"day", plen))
568 total += (l * 1000*60*60*24);
575 }
while (*str && *p);
598 static const char *units[5] = {
"d",
"h",
"m",
"s",
"msec"};
599 char *
const buf_orig = buf;
602 snprintf(buf, len,
"0msec");
606 #define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit 614 for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
618 l = snprintf(buf, len,
"%s%" PRIu64
"%s",
619 (buf==buf_orig) ?
"" :
" ", split[i], units[i]);
634 static const struct trans_tbl nlfamilies[] = {
635 __ADD(NETLINK_ROUTE,route),
636 __ADD(NETLINK_USERSOCK,usersock),
637 __ADD(NETLINK_FIREWALL,firewall),
638 __ADD(NETLINK_INET_DIAG,inetdiag),
639 __ADD(NETLINK_NFLOG,nflog),
640 __ADD(NETLINK_XFRM,xfrm),
641 __ADD(NETLINK_SELINUX,selinux),
642 __ADD(NETLINK_ISCSI,iscsi),
643 __ADD(NETLINK_AUDIT,audit),
644 __ADD(NETLINK_FIB_LOOKUP,fib_lookup),
645 __ADD(NETLINK_CONNECTOR,connector),
646 __ADD(NETLINK_NETFILTER,netfilter),
647 __ADD(NETLINK_IP6_FW,ip6_fw),
648 __ADD(NETLINK_DNRTMSG,dnrtmsg),
649 __ADD(NETLINK_KOBJECT_UEVENT,kobject_uevent),
650 __ADD(NETLINK_GENERIC,
generic),
651 __ADD(NETLINK_SCSITRANSPORT,scsitransport),
652 __ADD(NETLINK_ECRYPTFS,ecryptfs),
653 __ADD(NETLINK_RDMA,rdma),
654 __ADD(NETLINK_CRYPTO,crypto),
657 char * nl_nlfamily2str(
int family,
char *buf,
size_t size)
659 return __type2str(family, buf, size, nlfamilies,
660 ARRAY_SIZE(nlfamilies));
663 int nl_str2nlfamily(
const char *name)
665 return __str2type(name, nlfamilies, ARRAY_SIZE(nlfamilies));
677 static const struct trans_tbl llprotos[] = {
679 __ADD(ARPHRD_NETROM,netrom),
680 __ADD(ARPHRD_ETHER,ether),
681 __ADD(ARPHRD_EETHER,eether),
682 __ADD(ARPHRD_AX25,ax25),
683 __ADD(ARPHRD_PRONET,pronet),
684 __ADD(ARPHRD_CHAOS,chaos),
685 __ADD(ARPHRD_IEEE802,ieee802),
686 __ADD(ARPHRD_ARCNET,arcnet),
687 __ADD(ARPHRD_APPLETLK,atalk),
688 __ADD(ARPHRD_DLCI,dlci),
689 __ADD(ARPHRD_ATM,atm),
690 __ADD(ARPHRD_METRICOM,metricom),
691 __ADD(ARPHRD_IEEE1394,ieee1394),
692 __ADD(ARPHRD_EUI64,eui64),
693 __ADD(ARPHRD_INFINIBAND,infiniband),
694 __ADD(ARPHRD_SLIP,slip),
695 __ADD(ARPHRD_CSLIP,cslip),
696 __ADD(ARPHRD_SLIP6,slip6),
697 __ADD(ARPHRD_CSLIP6,cslip6),
698 __ADD(ARPHRD_RSRVD,rsrvd),
699 __ADD(ARPHRD_ADAPT,adapt),
700 __ADD(ARPHRD_ROSE,rose),
701 __ADD(ARPHRD_X25,x25),
702 __ADD(ARPHRD_HWX25,hwx25),
703 __ADD(ARPHRD_CAN,can),
704 __ADD(ARPHRD_PPP,ppp),
705 __ADD(ARPHRD_CISCO,cisco),
706 __ADD(ARPHRD_HDLC,hdlc),
707 __ADD(ARPHRD_LAPB,lapb),
708 __ADD(ARPHRD_DDCMP,ddcmp),
709 __ADD(ARPHRD_RAWHDLC,rawhdlc),
710 __ADD(ARPHRD_TUNNEL,ipip),
711 __ADD(ARPHRD_TUNNEL6,tunnel6),
712 __ADD(ARPHRD_FRAD,frad),
713 __ADD(ARPHRD_SKIP,skip),
714 __ADD(ARPHRD_LOOPBACK,loopback),
715 __ADD(ARPHRD_LOCALTLK,localtlk),
716 __ADD(ARPHRD_FDDI,fddi),
717 __ADD(ARPHRD_BIF,bif),
718 __ADD(ARPHRD_SIT,sit),
719 __ADD(ARPHRD_IPDDP,ip/ddp),
720 __ADD(ARPHRD_IPGRE,gre),
721 __ADD(ARPHRD_PIMREG,pimreg),
722 __ADD(ARPHRD_HIPPI,hippi),
723 __ADD(ARPHRD_ASH,ash),
724 __ADD(ARPHRD_ECONET,econet),
725 __ADD(ARPHRD_IRDA,irda),
726 __ADD(ARPHRD_FCPP,fcpp),
727 __ADD(ARPHRD_FCAL,fcal),
728 __ADD(ARPHRD_FCPL,fcpl),
729 __ADD(ARPHRD_FCFABRIC,fcfb_0),
730 __ADD(ARPHRD_FCFABRIC+1,fcfb_1),
731 __ADD(ARPHRD_FCFABRIC+2,fcfb_2),
732 __ADD(ARPHRD_FCFABRIC+3,fcfb_3),
733 __ADD(ARPHRD_FCFABRIC+4,fcfb_4),
734 __ADD(ARPHRD_FCFABRIC+5,fcfb_5),
735 __ADD(ARPHRD_FCFABRIC+6,fcfb_6),
736 __ADD(ARPHRD_FCFABRIC+7,fcfb_7),
737 __ADD(ARPHRD_FCFABRIC+8,fcfb_8),
738 __ADD(ARPHRD_FCFABRIC+9,fcfb_9),
739 __ADD(ARPHRD_FCFABRIC+10,fcfb_10),
740 __ADD(ARPHRD_FCFABRIC+11,fcfb_11),
741 __ADD(ARPHRD_FCFABRIC+12,fcfb_12),
742 __ADD(ARPHRD_IEEE802_TR,tr),
743 __ADD(ARPHRD_IEEE80211,ieee802.11),
744 __ADD(ARPHRD_IEEE80211_PRISM,ieee802.11_prism),
745 __ADD(ARPHRD_IEEE80211_RADIOTAP,ieee802.11_radiotap),
746 __ADD(ARPHRD_IEEE802154,ieee802.15.4),
747 __ADD(ARPHRD_IEEE802154_MONITOR,ieee802.15.4_monitor),
748 __ADD(ARPHRD_PHONET,phonet),
749 __ADD(ARPHRD_PHONET_PIPE,phonet_pipe),
750 __ADD(ARPHRD_CAIF,caif),
751 __ADD(ARPHRD_IP6GRE,ip6gre),
752 __ADD(ARPHRD_NETLINK,netlink),
753 __ADD(ARPHRD_6LOWPAN,6lowpan),
754 __ADD(ARPHRD_VOID,
void),
755 __ADD(ARPHRD_NONE,nohdr),
758 char * nl_llproto2str(
int llproto,
char *buf,
size_t len)
760 return __type2str(llproto, buf, len, llprotos, ARRAY_SIZE(llprotos));
763 int nl_str2llproto(
const char *name)
765 return __str2type(name, llprotos, ARRAY_SIZE(llprotos));
776 static const struct trans_tbl ether_protos[] = {
777 __ADD(ETH_P_LOOP,loop),
778 __ADD(ETH_P_PUP,pup),
779 __ADD(ETH_P_PUPAT,pupat),
781 __ADD(ETH_P_X25,x25),
782 __ADD(ETH_P_ARP,arp),
783 __ADD(ETH_P_BPQ,bpq),
784 __ADD(ETH_P_IEEEPUP,ieeepup),
785 __ADD(ETH_P_IEEEPUPAT,ieeepupat),
786 __ADD(ETH_P_DEC,dec),
787 __ADD(ETH_P_DNA_DL,dna_dl),
788 __ADD(ETH_P_DNA_RC,dna_rc),
789 __ADD(ETH_P_DNA_RT,dna_rt),
790 __ADD(ETH_P_LAT,lat),
791 __ADD(ETH_P_DIAG,diag),
792 __ADD(ETH_P_CUST,cust),
793 __ADD(ETH_P_SCA,sca),
794 __ADD(ETH_P_TEB,teb),
795 __ADD(ETH_P_RARP,rarp),
796 __ADD(ETH_P_ATALK,atalk),
797 __ADD(ETH_P_AARP,aarp),
799 __ADD(ETH_P_8021Q,802.1q),
801 __ADD(ETH_P_IPX,ipx),
802 __ADD(ETH_P_IPV6,ipv6),
803 __ADD(ETH_P_PAUSE,pause),
804 __ADD(ETH_P_SLOW,slow),
806 __ADD(ETH_P_WCCP,wccp),
808 __ADD(ETH_P_PPP_DISC,ppp_disc),
809 __ADD(ETH_P_PPP_SES,ppp_ses),
810 __ADD(ETH_P_MPLS_UC,mpls_uc),
811 __ADD(ETH_P_MPLS_MC,mpls_mc),
812 __ADD(ETH_P_ATMMPOA,atmmpoa),
813 __ADD(ETH_P_LINK_CTL,link_ctl),
814 __ADD(ETH_P_ATMFATE,atmfate),
815 __ADD(ETH_P_PAE,pae),
816 __ADD(ETH_P_AOE,aoe),
817 __ADD(ETH_P_TIPC,tipc),
818 __ADD(ETH_P_1588,ieee1588),
819 __ADD(ETH_P_FCOE,fcoe),
820 __ADD(ETH_P_FIP,fip),
821 __ADD(ETH_P_EDSA,edsa),
822 __ADD(ETH_P_EDP2,edp2),
823 __ADD(ETH_P_802_3,802.3),
824 __ADD(ETH_P_AX25,ax25),
825 __ADD(ETH_P_ALL,all),
826 __ADD(ETH_P_802_2,802.2),
827 __ADD(ETH_P_SNAP,snap),
828 __ADD(ETH_P_DDCMP,ddcmp),
829 __ADD(ETH_P_WAN_PPP,wan_ppp),
830 __ADD(ETH_P_PPP_MP,ppp_mp),
831 __ADD(ETH_P_LOCALTALK,localtalk),
832 __ADD(ETH_P_CAN,can),
833 __ADD(ETH_P_PPPTALK,ppptalk),
834 __ADD(ETH_P_TR_802_2,tr_802.2),
835 __ADD(ETH_P_MOBITEX,mobitex),
836 __ADD(ETH_P_CONTROL,control),
837 __ADD(ETH_P_IRDA,irda),
838 __ADD(ETH_P_ECONET,econet),
839 __ADD(ETH_P_HDLC,hdlc),
840 __ADD(ETH_P_ARCNET,arcnet),
841 __ADD(ETH_P_DSA,dsa),
842 __ADD(ETH_P_TRAILER,trailer),
843 __ADD(ETH_P_PHONET,phonet),
844 __ADD(ETH_P_IEEE802154,ieee802154),
845 __ADD(ETH_P_CAIF,caif),
848 char *nl_ether_proto2str(
int eproto,
char *buf,
size_t len)
850 return __type2str(eproto, buf, len, ether_protos,
851 ARRAY_SIZE(ether_protos));
854 int nl_str2ether_proto(
const char *name)
856 return __str2type(name, ether_protos, ARRAY_SIZE(ether_protos));
866 char *nl_ip_proto2str(
int proto,
char *buf,
size_t len)
868 struct protoent *p = getprotobynumber(proto);
871 snprintf(buf, len,
"%s", p->p_name);
875 snprintf(buf, len,
"0x%x", proto);
879 int nl_str2ip_proto(
const char *name)
881 struct protoent *p = getprotobyname(name);
888 l = strtoul(name, &end, 0);
889 if (l == ULONG_MAX || *end !=
'\0')
890 return -NLE_OBJ_NOTFOUND;
918 for (i = 0; i < params->
dp_prefix; i++) {
920 fprintf(params->
dp_fd,
" ");
922 strncat(params->
dp_buf,
" ",
924 strlen(params->
dp_buf) - 1);
929 params->
dp_nl_cb(params, params->dp_line);
932 static void dump_one(
struct nl_dump_params *parms,
const char *fmt,
936 vfprintf(parms->
dp_fd, fmt, args);
939 if (vasprintf(&buf, fmt, args) >= 0) {
941 parms->
dp_cb(parms, buf);
943 strncat(parms->
dp_buf, buf,
945 strlen(parms->
dp_buf) - 1);
966 dump_one(params, fmt, args);
970 void nl_dump_line(
struct nl_dump_params *parms,
const char *fmt, ...)
977 dump_one(parms, fmt, args);
986 int __trans_list_add(
int i,
const char *a,
struct nl_list_head *head)
988 struct trans_list *tl;
990 tl = calloc(1,
sizeof(*tl));
997 nl_list_add_tail(&tl->list, head);
1004 struct trans_list *tl, *next;
1006 nl_list_for_each_entry_safe(tl, next, head, list) {
1011 nl_init_list_head(head);
1014 char *__type2str(
int type,
char *buf,
size_t len,
1015 const struct trans_tbl *tbl,
size_t tbl_len)
1018 for (i = 0; i < tbl_len; i++) {
1019 if (tbl[i].i == type) {
1020 snprintf(buf, len,
"%s", tbl[i].a);
1025 snprintf(buf, len,
"0x%x", type);
1029 char *__list_type2str(
int type,
char *buf,
size_t len,
1032 struct trans_list *tl;
1034 nl_list_for_each_entry(tl, head, list) {
1035 if (tl->i == type) {
1036 snprintf(buf, len,
"%s", tl->a);
1041 snprintf(buf, len,
"0x%x", type);
1045 char *__flags2str(
int flags,
char *buf,
size_t len,
1046 const struct trans_tbl *tbl,
size_t tbl_len)
1051 memset(buf, 0, len);
1053 for (i = 0; i < tbl_len; i++) {
1054 if (tbl[i].i & tmp) {
1056 strncat(buf, tbl[i].a, len - strlen(buf) - 1);
1058 strncat(buf,
",", len - strlen(buf) - 1);
1065 int __str2type(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1074 for (i = 0; i < tbl_len; i++)
1075 if (!strcasecmp(tbl[i].a, buf))
1078 l = strtoul(buf, &end, 0);
1079 if (l == ULONG_MAX || *end !=
'\0')
1080 return -NLE_OBJ_NOTFOUND;
1085 int __list_str2type(
const char *buf,
struct nl_list_head *head)
1087 struct trans_list *tl;
1094 nl_list_for_each_entry(tl, head, list) {
1095 if (!strcasecmp(tl->a, buf))
1099 l = strtoul(buf, &end, 0);
1100 if (l == ULONG_MAX || *end !=
'\0')
1101 return -NLE_OBJ_NOTFOUND;
1106 int __str2flags(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1111 char *p = (
char *) buf, *t;
1118 len = t ? t - p : strlen(p);
1119 for (i = 0; i < tbl_len; i++)
1120 if (len == strlen(tbl[i].a) &&
1121 !strncasecmp(tbl[i].a, p, len))
1133 void dump_from_ops(
struct nl_object *obj,
struct nl_dump_params *params)
1137 if (type < 0 || type > NL_DUMP_MAX)
1140 params->dp_line = 0;
1147 dp_dump_line(params, 0,
"%s ",
1148 nl_cache_mngt_type2name(obj->ce_ops,
1149 obj->ce_ops->co_protocol,
1156 if (obj->ce_ops->oo_dump[type])
1157 obj->ce_ops->oo_dump[type](obj, params);
1179 int nl_has_capability (
int capability)
1181 static const uint8_t caps[ ( NL_CAPABILITY_MAX + 7 ) / 8 ] = {
1182 #define _NL_ASSERT(expr) ( 0 * sizeof(struct { unsigned int x: ( (!!(expr)) ? 1 : -1 ); }) ) 1183 #define _NL_SETV(i, r, v) \ 1184 ( _NL_ASSERT( (v) == 0 || (i) * 8 + (r) == (v) - 1 ) + \ 1185 ( (v) == 0 ? 0 : (1 << (r)) ) ) 1186 #define _NL_SET(i, v0, v1, v2, v3, v4, v5, v6, v7) \ 1188 _NL_SETV((i), 0, (v0)) | _NL_SETV((i), 4, (v4)) | \ 1189 _NL_SETV((i), 1, (v1)) | _NL_SETV((i), 5, (v5)) | \ 1190 _NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \ 1191 _NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) ) 1194 NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE,
1195 NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
1196 NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
1197 NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
1198 NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
1199 NL_CAPABILITY_VERSION_3_2_26,
1200 NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK),
1202 NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE,
1203 NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX,
1204 NL_CAPABILITY_VERSION_3_2_27,
1205 NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE,
1206 NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE,
1207 NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR,
1208 NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE,
1209 NL_CAPABILITY_NL_OBJECT_DIFF64),
1211 NL_CAPABILITY_XFRM_SA_KEY_SIZE,
1212 NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
1213 NL_CAPABILITY_VERSION_3_2_28,
1214 NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
1215 NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
1216 NL_CAPABILITY_XFRM_SEC_CTX_LEN,
1217 NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE,
1218 NL_CAPABILITY_NL_RECVMSGS_PEEK_BY_DEFAULT),
1220 NL_CAPABILITY_VERSION_3_2_29,
1221 NL_CAPABILITY_XFRM_SP_SEC_CTX_LEN,
1222 NL_CAPABILITY_VERSION_3_3_0,
1223 NL_CAPABILITY_VERSION_3_4_0,
1247 if (capability <= 0 || capability > NL_CAPABILITY_MAX)
1250 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.