print_color_##type_name(t, COLOR_NONE, key, fmt, value); \
}
_PRINT_FUNC(int, int);
+_PRINT_FUNC(s64, int64_t);
_PRINT_FUNC(bool, bool);
_PRINT_FUNC(null, const char*);
_PRINT_FUNC(string, const char*);
-_PRINT_FUNC(uint, uint64_t);
+_PRINT_FUNC(uint, unsigned int);
+_PRINT_FUNC(u64, uint64_t);
_PRINT_FUNC(hu, unsigned short);
_PRINT_FUNC(hex, unsigned int);
_PRINT_FUNC(0xhex, unsigned int);
+_PRINT_FUNC(luint, unsigned long int);
_PRINT_FUNC(lluint, unsigned long long int);
_PRINT_FUNC(float, double);
#undef _PRINT_FUNC
void jsonw_bool(json_writer_t *self, bool value);
void jsonw_float(json_writer_t *self, double number);
void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
-void jsonw_uint(json_writer_t *self, uint64_t number);
+void jsonw_uint(json_writer_t *self, unsigned int number);
+void jsonw_u64(json_writer_t *self, uint64_t number);
void jsonw_xint(json_writer_t *self, uint64_t number);
void jsonw_hu(json_writer_t *self, unsigned short number);
-void jsonw_int(json_writer_t *self, int64_t number);
+void jsonw_int(json_writer_t *self, int number);
+void jsonw_s64(json_writer_t *self, int64_t number);
void jsonw_null(json_writer_t *self);
+void jsonw_luint(json_writer_t *self, unsigned long int num);
void jsonw_lluint(json_writer_t *self, unsigned long long int num);
/* Useful Combinations of name and value */
void jsonw_string_field(json_writer_t *self, const char *prop, const char *val);
void jsonw_bool_field(json_writer_t *self, const char *prop, bool value);
void jsonw_float_field(json_writer_t *self, const char *prop, double num);
-void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num);
+void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num);
+void jsonw_u64_field(json_writer_t *self, const char *prop, uint64_t num);
void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num);
void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
-void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num);
+void jsonw_int_field(json_writer_t *self, const char *prop, int num);
+void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num);
void jsonw_null_field(json_writer_t *self, const char *prop);
+void jsonw_luint_field(json_writer_t *self, const char *prop,
+ unsigned long int num);
void jsonw_lluint_field(json_writer_t *self, const char *prop,
unsigned long long int num);
void jsonw_float_field_fmt(json_writer_t *self, const char *prop,
/* RX stats */
open_json_object("rx");
- print_uint(PRINT_JSON, "bytes", NULL,
+ print_u64(PRINT_JSON, "bytes", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_RX_BYTES]));
- print_uint(PRINT_JSON, "packets", NULL,
+ print_u64(PRINT_JSON, "packets", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_RX_PACKETS]));
- print_uint(PRINT_JSON, "multicast", NULL,
+ print_u64(PRINT_JSON, "multicast", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_MULTICAST]));
- print_uint(PRINT_JSON, "broadcast", NULL,
+ print_u64(PRINT_JSON, "broadcast", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_BROADCAST]));
close_json_object();
/* TX stats */
open_json_object("tx");
- print_uint(PRINT_JSON, "tx_bytes", NULL,
+ print_u64(PRINT_JSON, "tx_bytes", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_TX_BYTES]));
- print_uint(PRINT_JSON, "tx_packets", NULL,
+ print_u64(PRINT_JSON, "tx_packets", NULL,
rta_getattr_u64(vf[IFLA_VF_STATS_TX_PACKETS]));
close_json_object();
close_json_object();
/* RX stats */
open_json_object("rx");
- print_uint(PRINT_JSON, "bytes", NULL, s->rx_bytes);
- print_uint(PRINT_JSON, "packets", NULL, s->rx_packets);
- print_uint(PRINT_JSON, "errors", NULL, s->rx_errors);
- print_uint(PRINT_JSON, "dropped", NULL, s->rx_dropped);
- print_uint(PRINT_JSON, "over_errors", NULL, s->rx_over_errors);
- print_uint(PRINT_JSON, "multicast", NULL, s->multicast);
+ print_u64(PRINT_JSON, "bytes", NULL, s->rx_bytes);
+ print_u64(PRINT_JSON, "packets", NULL, s->rx_packets);
+ print_u64(PRINT_JSON, "errors", NULL, s->rx_errors);
+ print_u64(PRINT_JSON, "dropped", NULL, s->rx_dropped);
+ print_u64(PRINT_JSON, "over_errors", NULL, s->rx_over_errors);
+ print_u64(PRINT_JSON, "multicast", NULL, s->multicast);
if (s->rx_compressed)
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"compressed", NULL, s->rx_compressed);
/* RX error stats */
if (show_stats > 1) {
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"length_errors",
NULL, s->rx_length_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"crc_errors",
NULL, s->rx_crc_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"frame_errors",
NULL, s->rx_frame_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"fifo_errors",
NULL, s->rx_fifo_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"missed_errors",
NULL, s->rx_missed_errors);
if (s->rx_nohandler)
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"nohandler", NULL, s->rx_nohandler);
}
close_json_object();
/* TX stats */
open_json_object("tx");
- print_uint(PRINT_JSON, "bytes", NULL, s->tx_bytes);
- print_uint(PRINT_JSON, "packets", NULL, s->tx_packets);
- print_uint(PRINT_JSON, "errors", NULL, s->tx_errors);
- print_uint(PRINT_JSON, "dropped", NULL, s->tx_dropped);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON, "bytes", NULL, s->tx_bytes);
+ print_u64(PRINT_JSON, "packets", NULL, s->tx_packets);
+ print_u64(PRINT_JSON, "errors", NULL, s->tx_errors);
+ print_u64(PRINT_JSON, "dropped", NULL, s->tx_dropped);
+ print_u64(PRINT_JSON,
"carrier_errors",
NULL, s->tx_carrier_errors);
- print_uint(PRINT_JSON, "collisions", NULL, s->collisions);
+ print_u64(PRINT_JSON, "collisions", NULL, s->collisions);
if (s->tx_compressed)
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"compressed", NULL, s->tx_compressed);
/* TX error stats */
if (show_stats > 1) {
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"aborted_errors",
NULL, s->tx_aborted_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"fifo_errors",
NULL, s->tx_fifo_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"window_errors",
NULL, s->tx_window_errors);
- print_uint(PRINT_JSON,
+ print_u64(PRINT_JSON,
"heartbeat_errors",
NULL, s->tx_heartbeat_errors);
if (carrier_changes)
- print_uint(PRINT_JSON, "carrier_changes", NULL,
+ print_u64(PRINT_JSON, "carrier_changes", NULL,
rta_getattr_u32(carrier_changes));
}
}
}
-static __u64 getattr_uint(struct rtattr *stat)
+static __u64 getattr_u64(struct rtattr *stat)
{
switch (RTA_PAYLOAD(stat)) {
case sizeof(__u64):
pad = strlen(names[i]) + 1;
if (stats[i])
- printf("%*llu", pad, getattr_uint(stats[i]));
+ printf("%*llu", pad, getattr_u64(stats[i]));
else
printf("%*c", pad, '-');
}
if (!names[i] || !stats[i])
continue;
- print_uint(PRINT_JSON, names[i],
- NULL, getattr_uint(stats[i]));
+ print_u64(PRINT_JSON, names[i],
+ NULL, getattr_u64(stats[i]));
}
}
struct rta_mfc_stats *mfcs = RTA_DATA(tb[RTA_MFC_STATS]);
print_string(PRINT_FP, NULL, "%s", _SL_);
- print_uint(PRINT_ANY, "packets", " %"PRIu64" packets,",
+ print_u64(PRINT_ANY, "packets", " %"PRIu64" packets,",
mfcs->mfcs_packets);
- print_uint(PRINT_ANY, "bytes", " %"PRIu64" bytes", mfcs->mfcs_bytes);
+ print_u64(PRINT_ANY, "bytes", " %"PRIu64" bytes", mfcs->mfcs_bytes);
if (mfcs->mfcs_wrong_if)
- print_uint(PRINT_ANY, "wrong_if",
+ print_u64(PRINT_ANY, "wrong_if",
", %"PRIu64" arrived on wrong iif.",
mfcs->mfcs_wrong_if);
}
if (tpb[NDTPA_REACHABLE_TIME]) {
__u64 reachable = rta_getattr_u64(tpb[NDTPA_REACHABLE_TIME]);
- print_uint(PRINT_ANY, "reachable",
+ print_u64(PRINT_ANY, "reachable",
"reachable %llu ", reachable);
}
__u64 breachable
= rta_getattr_u64(tpb[NDTPA_BASE_REACHABLE_TIME]);
- print_uint(PRINT_ANY, "base_reachable",
+ print_u64(PRINT_ANY, "base_reachable",
"base_reachable %llu ", breachable);
}
if (tpb[NDTPA_RETRANS_TIME]) {
__u64 retrans = rta_getattr_u64(tpb[NDTPA_RETRANS_TIME]);
- print_uint(PRINT_ANY, "retrans", "retrans %llu ", retrans);
+ print_u64(PRINT_ANY, "retrans", "retrans %llu ", retrans);
}
print_string(PRINT_FP, NULL, "%s ", _SL_);
if (tpb[NDTPA_GC_STALETIME]) {
__u64 gc_stale = rta_getattr_u64(tpb[NDTPA_GC_STALETIME]);
- print_uint(PRINT_ANY, "gc_stale", "gc_stale %llu ", gc_stale);
+ print_u64(PRINT_ANY, "gc_stale", "gc_stale %llu ", gc_stale);
}
if (tpb[NDTPA_DELAY_PROBE_TIME]) {
__u64 delay_probe
= rta_getattr_u64(tpb[NDTPA_DELAY_PROBE_TIME]);
- print_uint(PRINT_ANY, "delay_probe",
+ print_u64(PRINT_ANY, "delay_probe",
"delay_probe %llu ", delay_probe);
}
if (tpb[NDTPA_ANYCAST_DELAY]) {
__u64 anycast_delay = rta_getattr_u64(tpb[NDTPA_ANYCAST_DELAY]);
- print_uint(PRINT_ANY, "anycast_delay",
+ print_u64(PRINT_ANY, "anycast_delay",
"anycast_delay %llu ", anycast_delay);
}
if (tpb[NDTPA_PROXY_DELAY]) {
__u64 proxy_delay = rta_getattr_u64(tpb[NDTPA_PROXY_DELAY]);
- print_uint(PRINT_ANY, "proxy_delay",
+ print_u64(PRINT_ANY, "proxy_delay",
"proxy_delay %llu ", proxy_delay);
}
if (tpb[NDTPA_LOCKTIME]) {
__u64 locktime = rta_getattr_u64(tpb[NDTPA_LOCKTIME]);
- print_uint(PRINT_ANY, "locktime", "locktime %llu ", locktime);
+ print_u64(PRINT_ANY, "locktime", "locktime %llu ", locktime);
}
print_string(PRINT_FP, NULL, "%s", _SL_);
print_string(PRINT_FP, NULL, " stats ", NULL);
- print_uint(PRINT_ANY, "allocs", "allocs %llu ", ndts->ndts_allocs);
- print_uint(PRINT_ANY, "destroys", "destroys %llu ",
+ print_u64(PRINT_ANY, "allocs", "allocs %llu ", ndts->ndts_allocs);
+ print_u64(PRINT_ANY, "destroys", "destroys %llu ",
ndts->ndts_destroys);
- print_uint(PRINT_ANY, "hash_grows", "hash_grows %llu ",
+ print_u64(PRINT_ANY, "hash_grows", "hash_grows %llu ",
ndts->ndts_hash_grows);
print_string(PRINT_FP, NULL, "%s ", _SL_);
- print_uint(PRINT_ANY, "res_failed", "res_failed %llu ",
+ print_u64(PRINT_ANY, "res_failed", "res_failed %llu ",
ndts->ndts_res_failed);
- print_uint(PRINT_ANY, "lookups", "lookups %llu ", ndts->ndts_lookups);
- print_uint(PRINT_ANY, "hits", "hits %llu ", ndts->ndts_hits);
+ print_u64(PRINT_ANY, "lookups", "lookups %llu ", ndts->ndts_lookups);
+ print_u64(PRINT_ANY, "hits", "hits %llu ", ndts->ndts_hits);
print_string(PRINT_FP, NULL, "%s ", _SL_);
- print_uint(PRINT_ANY, "rcv_probes_mcast", "rcv_probes_mcast %llu ",
+ print_u64(PRINT_ANY, "rcv_probes_mcast", "rcv_probes_mcast %llu ",
ndts->ndts_rcv_probes_mcast);
- print_uint(PRINT_ANY, "rcv_probes_ucast", "rcv_probes_ucast %llu ",
+ print_u64(PRINT_ANY, "rcv_probes_ucast", "rcv_probes_ucast %llu ",
ndts->ndts_rcv_probes_ucast);
print_string(PRINT_FP, NULL, "%s ", _SL_);
- print_uint(PRINT_ANY, "periodic_gc_runs", "periodic_gc_runs %llu ",
+ print_u64(PRINT_ANY, "periodic_gc_runs", "periodic_gc_runs %llu ",
ndts->ndts_periodic_gc_runs);
- print_uint(PRINT_ANY, "forced_gc_runs", "forced_gc_runs %llu ",
+ print_u64(PRINT_ANY, "forced_gc_runs", "forced_gc_runs %llu ",
ndts->ndts_forced_gc_runs);
print_string(PRINT_FP, NULL, "%s", _SL_);
if (tb[NDTA_GC_INTERVAL]) {
__u64 gc_int = rta_getattr_u64(tb[NDTA_GC_INTERVAL]);
- print_uint(PRINT_ANY, "gc_interval", "gc_int %llu ", gc_int);
+ print_u64(PRINT_ANY, "gc_interval", "gc_int %llu ", gc_int);
}
if (ret)
parse_rtattr_nested(tb, LWTUNNEL_IP_MAX, encap);
if (tb[LWTUNNEL_IP_ID])
- print_uint(PRINT_ANY, "id", "id %llu ",
+ print_u64(PRINT_ANY, "id", "id %llu ",
ntohll(rta_getattr_u64(tb[LWTUNNEL_IP_ID])));
if (tb[LWTUNNEL_IP_SRC])
parse_rtattr_nested(tb, LWTUNNEL_IP6_MAX, encap);
if (tb[LWTUNNEL_IP6_ID])
- print_uint(PRINT_ANY, "id", "id %llu ",
+ print_u64(PRINT_ANY, "id", "id %llu ",
ntohll(rta_getattr_u64(tb[LWTUNNEL_IP6_ID])));
if (tb[LWTUNNEL_IP6_SRC])
rt_addr_n2a_rta(AF_INET6, tb[LWTUNNEL_IP6_DST]));
if (tb[LWTUNNEL_IP6_HOPLIMIT])
- print_uint(PRINT_ANY, "hoplimit",
+ print_u64(PRINT_ANY, "hoplimit",
"hoplimit %u ",
rta_getattr_u8(tb[LWTUNNEL_IP6_HOPLIMIT]));
"ifname", "%s:", name);
print_flags(flags);
if (owner != -1)
- print_uint(PRINT_ANY, "user",
+ print_u64(PRINT_ANY, "user",
" user %ld", owner);
if (group != -1)
- print_uint(PRINT_ANY, "group",
+ print_u64(PRINT_ANY, "group",
" group %ld", group);
if (show_details) {
print_uint(PRINT_JSON, name, NULL, val);
print_string(PRINT_FP, NULL, " %s ", name);
- print_uint(PRINT_FP, NULL, "%lu", val);
+ print_uint(PRINT_FP, NULL, "%u", val);
}
if (rtt) {
print_float(PRINT_JSON, "rtt", NULL,
(double)rtt / usec_per_sec);
- print_uint(PRINT_FP, NULL,
+ print_u64(PRINT_FP, NULL,
" rtt %luus", rtt);
}
if (rttvar) {
print_float(PRINT_JSON, "rttvar", NULL,
(double) rttvar / usec_per_sec);
- print_uint(PRINT_FP, NULL,
+ print_u64(PRINT_FP, NULL,
" rttvar %luus", rttvar);
}
}
} \
}
_PRINT_FUNC(int, int);
+_PRINT_FUNC(s64, int64_t);
_PRINT_FUNC(hu, unsigned short);
-_PRINT_FUNC(uint, uint64_t);
+_PRINT_FUNC(uint, unsigned int);
+_PRINT_FUNC(u64, uint64_t);
+_PRINT_FUNC(luint, unsigned long int);
_PRINT_FUNC(lluint, unsigned long long int);
_PRINT_FUNC(float, double);
#undef _PRINT_FUNC
jsonw_printf(self, "%hu", num);
}
-void jsonw_uint(json_writer_t *self, uint64_t num)
+void jsonw_uint(json_writer_t *self, unsigned int num)
+{
+ jsonw_printf(self, "%u", num);
+}
+
+void jsonw_u64(json_writer_t *self, uint64_t num)
{
jsonw_printf(self, "%"PRIu64, num);
}
jsonw_printf(self, "%"PRIx64, num);
}
+void jsonw_luint(json_writer_t *self, unsigned long int num)
+{
+ jsonw_printf(self, "%lu", num);
+}
+
void jsonw_lluint(json_writer_t *self, unsigned long long int num)
{
jsonw_printf(self, "%llu", num);
}
-void jsonw_int(json_writer_t *self, int64_t num)
+void jsonw_int(json_writer_t *self, int num)
+{
+ jsonw_printf(self, "%d", num);
+}
+
+void jsonw_s64(json_writer_t *self, int64_t num)
{
jsonw_printf(self, "%"PRId64, num);
}
jsonw_float_fmt(self, fmt, val);
}
-void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num)
+void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num)
{
jsonw_name(self, prop);
jsonw_uint(self, num);
}
+void jsonw_u64_field(json_writer_t *self, const char *prop, uint64_t num)
+{
+ jsonw_name(self, prop);
+ jsonw_u64(self, num);
+}
+
void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num)
{
jsonw_name(self, prop);
jsonw_hu(self, num);
}
+void jsonw_luint_field(json_writer_t *self,
+ const char *prop,
+ unsigned long int num)
+{
+ jsonw_name(self, prop);
+ jsonw_luint(self, num);
+}
+
void jsonw_lluint_field(json_writer_t *self,
const char *prop,
unsigned long long int num)
jsonw_lluint(self, num);
}
-void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num)
+void jsonw_int_field(json_writer_t *self, const char *prop, int num)
{
jsonw_name(self, prop);
jsonw_int(self, num);
}
+void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num)
+{
+ jsonw_name(self, prop);
+ jsonw_s64(self, num);
+}
+
void jsonw_null_field(json_writer_t *self, const char *prop)
{
jsonw_name(self, prop);