21#include <netlink-private/netlink.h>
22#include <netlink-private/utils.h>
23#include <netlink/netlink.h>
24#include <netlink/utils.h>
25#include <linux/socket.h>
55static void __init nl_debug_init(
void)
59 if ((nldbg = getenv(
"NLDBG"))) {
60 long level = strtol(nldbg, &end, 0);
65 nl_debug_dp.
dp_fd = stderr;
69int __nl_read_num_str_file(
const char *path,
int (*cb)(
long,
const char *))
74 fd = fopen(path,
"re");
76 return -nl_syserr2nlerr(errno);
78 while (fgets(buf,
sizeof(buf), fd)) {
83 if (*buf ==
'#' || *buf ==
'\n' || *buf ==
'\r')
86 num = strtol(buf, &end, 0);
92 if (num == LONG_MIN || num == LONG_MAX) {
97 while (*end ==
' ' || *end ==
'\t')
100 goodlen = strcspn(end,
"#\r\n\t ");
120const char *nl_strerror_l(
int err)
123#ifdef HAVE_STRERROR_L
124 int errno_save = errno;
125 locale_t loc = newlocale(LC_MESSAGES_MASK,
"", (locale_t)0);
127 if (loc == (locale_t)0) {
129 loc = newlocale(LC_MESSAGES_MASK,
130 "POSIX", (locale_t)0);
132 if (loc != (locale_t)0) {
133 buf = strerror_l(err, loc);
136 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;
220int 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)
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)
416static uint32_t user_hz = USER_HZ;
417static uint32_t psched_hz = USER_HZ;
419static double ticks_per_usec = 1.0f;
430static void get_psched_settings(
void)
432 char name[FILENAME_MAX];
435 static volatile int initialized = 0;
439 if (initialized == 1)
444 if (initialized == 1)
447 if ((ev = getenv(
"HZ"))) {
448 long hz = strtol(ev, NULL, 0);
450 if (LONG_MIN != hz && LONG_MAX != hz) {
457 user_hz = sysconf(_SC_CLK_TCK);
461 if ((ev = getenv(
"TICKS_PER_USEC"))) {
462 double t = strtod(ev, NULL);
466 if ((ev = getenv(
"PROC_NET_PSCHED")))
467 snprintf(name,
sizeof(name),
"%s", ev);
468 else if ((ev = getenv(
"PROC_ROOT")))
469 snprintf(name,
sizeof(name),
"%s/net/psched", ev);
471 _nl_strncpy_assert(name,
"/proc/net/psched",
sizeof(name));
473 if ((fd = fopen(name,
"re"))) {
474 unsigned int ns_per_usec, ns_per_tick, nom, denom;
476 if (fscanf(fd,
"%08x %08x %08x %08x",
477 &ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
478 NL_DBG(1,
"Fatal error: can not read psched settings from \"%s\". " \
479 "Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
480 "environment variables\n", name);
484 ticks_per_usec = (double) ns_per_usec /
485 (
double) ns_per_tick;
504 get_psched_settings();
513 get_psched_settings();
524 get_psched_settings();
525 return us * ticks_per_usec;
536 get_psched_settings();
537 return ticks / ticks_per_usec;
540int nl_str2msec(
const char *str, uint64_t *result)
542 uint64_t total = 0, l;
547 l = strtoul(str, &p, 0);
551 plen = strcspn(p,
" \t");
555 else if (!strncasecmp(p,
"sec", plen))
557 else if (!strncasecmp(p,
"min", plen))
558 total += (l * 1000*60);
559 else if (!strncasecmp(p,
"hour", plen))
560 total += (l * 1000*60*60);
561 else if (!strncasecmp(p,
"day", plen))
562 total += (l * 1000*60*60*24);
569 }
while (*str && *p);
592 static const char *units[5] = {
"d",
"h",
"m",
"s",
"msec"};
593 char *
const buf_orig = buf;
596 snprintf(buf, len,
"0msec");
600#define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit
608 for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
612 l = snprintf(buf, len,
"%s%" PRIu64
"%s",
613 (buf==buf_orig) ?
"" :
" ", split[i], units[i]);
628static const struct trans_tbl nlfamilies[] = {
629 __ADD(NETLINK_ROUTE,route),
630 __ADD(NETLINK_USERSOCK,usersock),
631 __ADD(NETLINK_FIREWALL,firewall),
632 __ADD(NETLINK_INET_DIAG,inetdiag),
633 __ADD(NETLINK_NFLOG,nflog),
634 __ADD(NETLINK_XFRM,xfrm),
635 __ADD(NETLINK_SELINUX,selinux),
636 __ADD(NETLINK_ISCSI,iscsi),
637 __ADD(NETLINK_AUDIT,audit),
638 __ADD(NETLINK_FIB_LOOKUP,fib_lookup),
639 __ADD(NETLINK_CONNECTOR,connector),
640 __ADD(NETLINK_NETFILTER,netfilter),
641 __ADD(NETLINK_IP6_FW,ip6_fw),
642 __ADD(NETLINK_DNRTMSG,dnrtmsg),
643 __ADD(NETLINK_KOBJECT_UEVENT,kobject_uevent),
644 __ADD(NETLINK_GENERIC,generic),
645 __ADD(NETLINK_SCSITRANSPORT,scsitransport),
646 __ADD(NETLINK_ECRYPTFS,ecryptfs),
647 __ADD(NETLINK_RDMA,rdma),
648 __ADD(NETLINK_CRYPTO,crypto),
651char * nl_nlfamily2str(
int family,
char *buf,
size_t size)
653 return __type2str(family, buf, size, nlfamilies,
654 ARRAY_SIZE(nlfamilies));
657int nl_str2nlfamily(
const char *name)
659 return __str2type(name, nlfamilies, ARRAY_SIZE(nlfamilies));
671static const struct trans_tbl llprotos[] = {
673 __ADD(ARPHRD_NETROM,netrom),
674 __ADD(ARPHRD_ETHER,ether),
675 __ADD(ARPHRD_EETHER,eether),
676 __ADD(ARPHRD_AX25,ax25),
677 __ADD(ARPHRD_PRONET,pronet),
678 __ADD(ARPHRD_CHAOS,chaos),
679 __ADD(ARPHRD_IEEE802,ieee802),
680 __ADD(ARPHRD_ARCNET,arcnet),
681 __ADD(ARPHRD_APPLETLK,atalk),
682 __ADD(ARPHRD_DLCI,dlci),
683 __ADD(ARPHRD_ATM,atm),
684 __ADD(ARPHRD_METRICOM,metricom),
685 __ADD(ARPHRD_IEEE1394,ieee1394),
686 __ADD(ARPHRD_EUI64,eui64),
687 __ADD(ARPHRD_INFINIBAND,infiniband),
688 __ADD(ARPHRD_SLIP,slip),
689 __ADD(ARPHRD_CSLIP,cslip),
690 __ADD(ARPHRD_SLIP6,slip6),
691 __ADD(ARPHRD_CSLIP6,cslip6),
692 __ADD(ARPHRD_RSRVD,rsrvd),
693 __ADD(ARPHRD_ADAPT,adapt),
694 __ADD(ARPHRD_ROSE,rose),
695 __ADD(ARPHRD_X25,x25),
696 __ADD(ARPHRD_HWX25,hwx25),
697 __ADD(ARPHRD_CAN,can),
698 __ADD(ARPHRD_PPP,ppp),
699 __ADD(ARPHRD_CISCO,cisco),
700 __ADD(ARPHRD_HDLC,hdlc),
701 __ADD(ARPHRD_LAPB,lapb),
702 __ADD(ARPHRD_DDCMP,ddcmp),
703 __ADD(ARPHRD_RAWHDLC,rawhdlc),
704 __ADD(ARPHRD_TUNNEL,ipip),
705 __ADD(ARPHRD_TUNNEL6,tunnel6),
706 __ADD(ARPHRD_FRAD,frad),
707 __ADD(ARPHRD_SKIP,skip),
708 __ADD(ARPHRD_LOOPBACK,loopback),
709 __ADD(ARPHRD_LOCALTLK,localtlk),
710 __ADD(ARPHRD_FDDI,fddi),
711 __ADD(ARPHRD_BIF,bif),
712 __ADD(ARPHRD_SIT,sit),
713 __ADD(ARPHRD_IPDDP,ip/ddp),
714 __ADD(ARPHRD_IPGRE,gre),
715 __ADD(ARPHRD_PIMREG,pimreg),
716 __ADD(ARPHRD_HIPPI,hippi),
717 __ADD(ARPHRD_ASH,ash),
718 __ADD(ARPHRD_ECONET,econet),
719 __ADD(ARPHRD_IRDA,irda),
720 __ADD(ARPHRD_FCPP,fcpp),
721 __ADD(ARPHRD_FCAL,fcal),
722 __ADD(ARPHRD_FCPL,fcpl),
723 __ADD(ARPHRD_FCFABRIC,fcfb_0),
724 __ADD(ARPHRD_FCFABRIC+1,fcfb_1),
725 __ADD(ARPHRD_FCFABRIC+2,fcfb_2),
726 __ADD(ARPHRD_FCFABRIC+3,fcfb_3),
727 __ADD(ARPHRD_FCFABRIC+4,fcfb_4),
728 __ADD(ARPHRD_FCFABRIC+5,fcfb_5),
729 __ADD(ARPHRD_FCFABRIC+6,fcfb_6),
730 __ADD(ARPHRD_FCFABRIC+7,fcfb_7),
731 __ADD(ARPHRD_FCFABRIC+8,fcfb_8),
732 __ADD(ARPHRD_FCFABRIC+9,fcfb_9),
733 __ADD(ARPHRD_FCFABRIC+10,fcfb_10),
734 __ADD(ARPHRD_FCFABRIC+11,fcfb_11),
735 __ADD(ARPHRD_FCFABRIC+12,fcfb_12),
736 __ADD(ARPHRD_IEEE802_TR,tr),
737 __ADD(ARPHRD_IEEE80211,ieee802.11),
738 __ADD(ARPHRD_IEEE80211_PRISM,ieee802.11_prism),
739 __ADD(ARPHRD_IEEE80211_RADIOTAP,ieee802.11_radiotap),
740 __ADD(ARPHRD_IEEE802154,ieee802.15.4),
741 __ADD(ARPHRD_IEEE802154_MONITOR,ieee802.15.4_monitor),
742 __ADD(ARPHRD_PHONET,phonet),
743 __ADD(ARPHRD_PHONET_PIPE,phonet_pipe),
744 __ADD(ARPHRD_CAIF,caif),
745 __ADD(ARPHRD_IP6GRE,ip6gre),
746 __ADD(ARPHRD_NETLINK,netlink),
747 __ADD(ARPHRD_6LOWPAN,6lowpan),
748 __ADD(ARPHRD_VOID,
void),
749 __ADD(ARPHRD_NONE,nohdr),
752char * nl_llproto2str(
int llproto,
char *buf,
size_t len)
754 return __type2str(llproto, buf, len, llprotos, ARRAY_SIZE(llprotos));
757int nl_str2llproto(
const char *name)
759 return __str2type(name, llprotos, ARRAY_SIZE(llprotos));
770static const struct trans_tbl ether_protos[] = {
771 __ADD(ETH_P_LOOP,loop),
772 __ADD(ETH_P_PUP,pup),
773 __ADD(ETH_P_PUPAT,pupat),
775 __ADD(ETH_P_X25,x25),
776 __ADD(ETH_P_ARP,arp),
777 __ADD(ETH_P_BPQ,bpq),
778 __ADD(ETH_P_IEEEPUP,ieeepup),
779 __ADD(ETH_P_IEEEPUPAT,ieeepupat),
780 __ADD(ETH_P_DEC,dec),
781 __ADD(ETH_P_DNA_DL,dna_dl),
782 __ADD(ETH_P_DNA_RC,dna_rc),
783 __ADD(ETH_P_DNA_RT,dna_rt),
784 __ADD(ETH_P_LAT,lat),
785 __ADD(ETH_P_DIAG,diag),
786 __ADD(ETH_P_CUST,cust),
787 __ADD(ETH_P_SCA,sca),
788 __ADD(ETH_P_TEB,teb),
789 __ADD(ETH_P_RARP,rarp),
790 __ADD(ETH_P_ATALK,atalk),
791 __ADD(ETH_P_AARP,aarp),
793 __ADD(ETH_P_8021Q,802.1q),
795 __ADD(ETH_P_IPX,ipx),
796 __ADD(ETH_P_IPV6,ipv6),
797 __ADD(ETH_P_PAUSE,pause),
798 __ADD(ETH_P_SLOW,slow),
800 __ADD(ETH_P_WCCP,wccp),
802 __ADD(ETH_P_PPP_DISC,ppp_disc),
803 __ADD(ETH_P_PPP_SES,ppp_ses),
804 __ADD(ETH_P_MPLS_UC,mpls_uc),
805 __ADD(ETH_P_MPLS_MC,mpls_mc),
806 __ADD(ETH_P_ATMMPOA,atmmpoa),
807 __ADD(ETH_P_LINK_CTL,link_ctl),
808 __ADD(ETH_P_ATMFATE,atmfate),
809 __ADD(ETH_P_PAE,pae),
810 __ADD(ETH_P_AOE,aoe),
811 __ADD(ETH_P_TIPC,tipc),
812 __ADD(ETH_P_1588,ieee1588),
813 __ADD(ETH_P_FCOE,fcoe),
814 __ADD(ETH_P_FIP,fip),
815 __ADD(ETH_P_EDSA,edsa),
816 __ADD(ETH_P_EDP2,edp2),
817 __ADD(ETH_P_802_3,802.3),
818 __ADD(ETH_P_AX25,ax25),
819 __ADD(ETH_P_ALL,all),
820 __ADD(ETH_P_802_2,802.2),
821 __ADD(ETH_P_SNAP,snap),
822 __ADD(ETH_P_DDCMP,ddcmp),
823 __ADD(ETH_P_WAN_PPP,wan_ppp),
824 __ADD(ETH_P_PPP_MP,ppp_mp),
825 __ADD(ETH_P_LOCALTALK,localtalk),
826 __ADD(ETH_P_CAN,can),
827 __ADD(ETH_P_PPPTALK,ppptalk),
828 __ADD(ETH_P_TR_802_2,tr_802.2),
829 __ADD(ETH_P_MOBITEX,mobitex),
830 __ADD(ETH_P_CONTROL,control),
831 __ADD(ETH_P_IRDA,irda),
832 __ADD(ETH_P_ECONET,econet),
833 __ADD(ETH_P_HDLC,hdlc),
834 __ADD(ETH_P_ARCNET,arcnet),
835 __ADD(ETH_P_DSA,dsa),
836 __ADD(ETH_P_TRAILER,trailer),
837 __ADD(ETH_P_PHONET,phonet),
838 __ADD(ETH_P_IEEE802154,ieee802154),
839 __ADD(ETH_P_CAIF,caif),
842char *nl_ether_proto2str(
int eproto,
char *buf,
size_t len)
844 return __type2str(eproto, buf, len, ether_protos,
845 ARRAY_SIZE(ether_protos));
848int nl_str2ether_proto(
const char *name)
850 return __str2type(name, ether_protos, ARRAY_SIZE(ether_protos));
860char *nl_ip_proto2str(
int proto,
char *buf,
size_t len)
862 struct protoent *p = getprotobynumber(proto);
865 snprintf(buf, len,
"%s", p->p_name);
869 snprintf(buf, len,
"0x%x", proto);
873int nl_str2ip_proto(
const char *name)
875 struct protoent *p = getprotobyname(name);
882 l = strtoul(name, &end, 0);
883 if (l == ULONG_MAX || *end !=
'\0')
884 return -NLE_OBJ_NOTFOUND;
912 for (i = 0; i < params->
dp_prefix; i++) {
914 fprintf(params->
dp_fd,
" ");
916 strncat(params->
dp_buf,
" ",
918 strlen(params->
dp_buf) - 1);
923 params->
dp_nl_cb(params, params->dp_line);
926static void dump_one(
struct nl_dump_params *parms,
const char *fmt,
930 vfprintf(parms->
dp_fd, fmt, args);
933 if (vasprintf(&buf, fmt, args) >= 0) {
935 parms->
dp_cb(parms, buf);
937 strncat(parms->
dp_buf, buf,
939 strlen(parms->
dp_buf) - 1);
960 dump_one(params, fmt, args);
964void nl_dump_line(
struct nl_dump_params *parms,
const char *fmt, ...)
971 dump_one(parms, fmt, args);
980int __trans_list_add(
int i,
const char *a,
struct nl_list_head *head)
982 struct trans_list *tl;
984 tl = calloc(1,
sizeof(*tl));
991 nl_list_add_tail(&tl->list, head);
998 struct trans_list *tl, *next;
1000 nl_list_for_each_entry_safe(tl, next, head, list) {
1005 nl_init_list_head(head);
1008char *__type2str(
int type,
char *buf,
size_t len,
1009 const struct trans_tbl *tbl,
size_t tbl_len)
1012 for (i = 0; i < tbl_len; i++) {
1013 if (tbl[i].i == type) {
1014 snprintf(buf, len,
"%s", tbl[i].a);
1019 snprintf(buf, len,
"0x%x", type);
1023char *__list_type2str(
int type,
char *buf,
size_t len,
1026 struct trans_list *tl;
1028 nl_list_for_each_entry(tl, head, list) {
1029 if (tl->i == type) {
1030 snprintf(buf, len,
"%s", tl->a);
1035 snprintf(buf, len,
"0x%x", type);
1039char *__flags2str(
int flags,
char *buf,
size_t len,
1040 const struct trans_tbl *tbl,
size_t tbl_len)
1045 memset(buf, 0, len);
1047 for (i = 0; i < tbl_len; i++) {
1048 if (tbl[i].i & tmp) {
1050 strncat(buf, tbl[i].a, len - strlen(buf) - 1);
1052 strncat(buf,
",", len - strlen(buf) - 1);
1059int __str2type(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1068 for (i = 0; i < tbl_len; i++)
1069 if (!strcasecmp(tbl[i].a, buf))
1072 l = strtoul(buf, &end, 0);
1073 if (l == ULONG_MAX || *end !=
'\0')
1074 return -NLE_OBJ_NOTFOUND;
1079int __list_str2type(
const char *buf,
struct nl_list_head *head)
1081 struct trans_list *tl;
1088 nl_list_for_each_entry(tl, head, list) {
1089 if (!strcasecmp(tl->a, buf))
1093 l = strtoul(buf, &end, 0);
1094 if (l == ULONG_MAX || *end !=
'\0')
1095 return -NLE_OBJ_NOTFOUND;
1100int __str2flags(
const char *buf,
const struct trans_tbl *tbl,
size_t tbl_len)
1105 char *p = (
char *) buf, *t;
1112 len = t ? t - p : strlen(p);
1113 for (i = 0; i < tbl_len; i++)
1114 if (len == strlen(tbl[i].a) &&
1115 !strncasecmp(tbl[i].a, p, len))
1127void dump_from_ops(
struct nl_object *obj,
struct nl_dump_params *params)
1131 if (type < 0 || type > NL_DUMP_MAX)
1134 params->dp_line = 0;
1141 dp_dump_line(params, 0,
"%s ",
1142 nl_cache_mngt_type2name(obj->ce_ops,
1143 obj->ce_ops->co_protocol,
1150 if (obj->ce_ops->oo_dump[type])
1151 obj->ce_ops->oo_dump[type](obj, params);
1173int nl_has_capability (
int capability)
1175 static const uint8_t caps[ ( NL_CAPABILITY_MAX + 7 ) / 8 ] = {
1176#define _NL_ASSERT(expr) ( 0 * sizeof(struct { unsigned int x: ( (!!(expr)) ? 1 : -1 ); }) )
1177#define _NL_SETV(i, r, v) \
1178 ( _NL_ASSERT( (v) == 0 || (i) * 8 + (r) == (v) - 1 ) + \
1179 ( (v) == 0 ? 0 : (1 << (r)) ) )
1180#define _NL_SET(i, v0, v1, v2, v3, v4, v5, v6, v7) \
1182 _NL_SETV((i), 0, (v0)) | _NL_SETV((i), 4, (v4)) | \
1183 _NL_SETV((i), 1, (v1)) | _NL_SETV((i), 5, (v5)) | \
1184 _NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \
1185 _NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) )
1187 NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE,
1188 NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE,
1189 NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
1190 NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
1191 NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
1192 NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
1193 NL_CAPABILITY_VERSION_3_2_26,
1194 NL_CAPABILITY_NL_RECV_FAIL_TRUNC_NO_PEEK),
1196 NL_CAPABILITY_LINK_BUILD_CHANGE_REQUEST_SET_CHANGE,
1197 NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX,
1198 NL_CAPABILITY_VERSION_3_2_27,
1199 NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE,
1200 NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE,
1201 NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR,
1202 NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE,
1203 NL_CAPABILITY_NL_OBJECT_DIFF64),
1205 NL_CAPABILITY_XFRM_SA_KEY_SIZE,
1206 NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
1207 NL_CAPABILITY_VERSION_3_2_28,
1208 NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
1209 NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
1210 NL_CAPABILITY_XFRM_SEC_CTX_LEN,
1211 NL_CAPABILITY_LINK_BUILD_ADD_REQUEST_SET_CHANGE,
1212 NL_CAPABILITY_NL_RECVMSGS_PEEK_BY_DEFAULT),
1214 NL_CAPABILITY_VERSION_3_2_29,
1215 NL_CAPABILITY_XFRM_SP_SEC_CTX_LEN,
1216 NL_CAPABILITY_VERSION_3_3_0,
1217 NL_CAPABILITY_VERSION_3_4_0,
1218 NL_CAPABILITY_ROUTE_FIX_VLAN_SET_EGRESS_MAP,
1219 NL_CAPABILITY_VERSION_3_5_0,
1220 NL_CAPABILITY_NL_OBJECT_IDENTICAL_PARTIAL,
1221 NL_CAPABILITY_VERSION_3_6_0),
1223 NL_CAPABILITY_VERSION_3_7_0,
1250 if (capability <= 0 || capability > NL_CAPABILITY_MAX)
1253 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.