output: add separate first_ip and last_ip to json and mustach outputs

This give greater liberty to people who are using these formats to do what
ever they need to.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-09 09:55:11 +00:00
parent 7d9a5b5561
commit 74fdf90980
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
3 changed files with 11 additions and 1 deletions

View file

@ -84,6 +84,14 @@ static int must_put_range(void *closure, const char *name, int escape
ntop_ipaddr(&e->range_p->last_ip));
return 0;
}
if (!strcmp(name, "first_ip")) {
fprintf(file, "%s", ntop_ipaddr(&e->range_p->first_ip));
return 0;
}
if (!strcmp(name, "last_ip")) {
fprintf(file, "%s", ntop_ipaddr(&e->range_p->last_ip));
return 0;
}
if (!strcmp(name, "used")) {
fprintf(file, "%g", e->range_p->count);
return 0;

View file

@ -497,6 +497,8 @@ static int output_json(const int print_mac_addreses)
fprintf(outfile, "\"range\":\"%s", ntop_ipaddr(&range_p->first_ip));
fprintf(outfile, " - %s\", ", ntop_ipaddr(&range_p->last_ip));
fprintf(outfile, "\"first_ip\":\"%s\", ", ntop_ipaddr(&range_p->first_ip));
fprintf(outfile, "\"last_ip\":\"%s\", ", ntop_ipaddr(&range_p->last_ip));
fprintf(outfile, "\"defined\":%g, ", oh.range_size);
fprintf(outfile, "\"used\":%g, ", range_p->count);
fprintf(outfile, "\"touched\":%g, ", range_p->touched);