aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-12-26 14:14:27 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-12-26 14:14:27 +0100
commit2eb56c0a4c9a83e753ce20dc77dcdbc569f5235e (patch)
tree77594512e8eb1ed7fe6230ccf50064cf313341e6
parent4c55896032aa4d816f280f2d91029e0b3db2dde7 (diff)
abisip-find -l: sort by IP
-rw-r--r--src/ipaccess/abisip-find.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ipaccess/abisip-find.c b/src/ipaccess/abisip-find.c
index df866f0bf..e5e12810c 100644
--- a/src/ipaccess/abisip-find.c
+++ b/src/ipaccess/abisip-find.c
@@ -267,14 +267,33 @@ static char *parse_response(void *ctx, unsigned char *buf, int len)
if (cmdline_opts.format_json)
out = talloc_asprintf_append(out,"{ ");
+ // write IP first, to sort by IP
+ cur = buf;
while (cur < buf + len) {
t_len = *cur++;
t_tag = *cur++;
- if (cmdline_opts.format_json)
- out = talloc_asprintf_append(out, "\"%s\": \"%s\", ", idtag_name(t_tag), cur);
- else
- out = talloc_asprintf_append(out, "%s='%s' ", idtag_name(t_tag), cur);
+ if (t_tag == IPAC_IDTAG_IPADDR) {
+ if (cmdline_opts.format_json)
+ out = talloc_asprintf_append(out, "\"%s\": \"%s\", ", idtag_name(t_tag), cur);
+ else
+ out = talloc_asprintf_append(out, "%s='%s' ", idtag_name(t_tag), cur);
+ }
+
+ cur += t_len;
+ }
+
+ cur = buf;
+ while (cur < buf + len) {
+ t_len = *cur++;
+ t_tag = *cur++;
+
+ if (t_tag != IPAC_IDTAG_IPADDR) {
+ if (cmdline_opts.format_json)
+ out = talloc_asprintf_append(out, "\"%s\": \"%s\", ", idtag_name(t_tag), cur);
+ else
+ out = talloc_asprintf_append(out, "%s='%s' ", idtag_name(t_tag), cur);
+ }
cur += t_len;
}