Skip to content

Commit eb0d7b9

Browse files
committed
ping: Print data bytes
data bytes is in original ping, therefore it should be in JSON as well. TODO: IPv4 has more info, but that requires ping_func_set_st *fset pointer - obviously gather_statistics() is not a good place to print the "header" data. Maybe move it to ping_print_packet(), which is used only for non-json code (which is sign of wrong design)? TODO: what would be proper names these "56 (84) data bytes"? Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent 2b6268a commit eb0d7b9

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

ping/ping_common.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,17 @@ int gather_statistics(struct ping_rts *rts, uint8_t *icmph, int icmplen,
834834
uint8_t *cp, *dp;
835835

836836
print_timestamp(rts);
837+
838+
if (rts->opt_json) {
839+
// TODO: improve key name
840+
construct_json(rts, PING_JSON_INT, "data_bytes", rts->datalen);
841+
/*
842+
* FIXME: Add this require either add ping_func_set_st *fset or move into ping_print_packet().
843+
if (fset->ping_data_bytes)
844+
construct_json(rts, PING_JSON_INT, "data_bytes_full", fset->ping_data_bytes(rts));
845+
*/
846+
}
847+
837848
ping_print_int(rts, _("%d bytes "), "bytes", cc);
838849
// TODO: split host IP address and name into separate attributes in JSON?
839850
ping_print_str(rts, _("from %s:"), "host", from);

0 commit comments

Comments
 (0)