diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2017-03-26 17:06:04 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-04-15 22:51:25 +0000 |
commit | c7e32fb09ca7d25ee86aeb3f627a4e5db450922b (patch) | |
tree | b2f76f72332f9ef3ac196a41b56485b53fb32f15 /sharkd_session.c | |
parent | b9edacecaf90f9151972e1f4cb1003c12032b799 (diff) |
sharkd: support for limits in sending information about rows (columns).
Suboptimal, but still much better than sending columns
for whole capture file. webshark by defaults requests for 120 rows.
Change-Id: I96188e0d2bc4539a57e5061c7784f8c44f318393
Reviewed-on: https://code.wireshark.org/review/20715
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'sharkd_session.c')
-rw-r--r-- | sharkd_session.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sharkd_session.c b/sharkd_session.c index 5c3a8a285d..e406b706fe 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -658,7 +658,8 @@ sharkd_session_process_analyse(void) * * Input: * (o) filter - filter to be used - * (o) range - packet range to be used [TODO] + * (o) skip=N - skip N frames + * (o) limit=N - show only N frames * * Output array of frames with attributes: * (m) c - array of column data @@ -672,13 +673,18 @@ static void sharkd_session_process_frames(const char *buf, const jsmntok_t *tokens, int count) { const char *tok_filter = json_find_attr(buf, tokens, count, "filter"); + const char *tok_skip = json_find_attr(buf, tokens, count, "skip"); + const char *tok_limit = json_find_attr(buf, tokens, count, "limit"); const guint8 *filter_data = NULL; const char *frame_sepa = ""; - unsigned int framenum; int col; + guint32 framenum; + guint32 skip; + guint32 limit; + column_info *cinfo = &cfile.cinfo; if (tok_filter) @@ -688,6 +694,20 @@ sharkd_session_process_frames(const char *buf, const jsmntok_t *tokens, int coun return; } + skip = 0; + if (tok_skip) + { + if (!ws_strtou32(tok_skip, NULL, &skip)) + return; + } + + limit = 0; + if (tok_limit) + { + if (!ws_strtou32(tok_limit, NULL, &limit)) + return; + } + printf("["); for (framenum = 1; framenum <= cfile.count; framenum++) { @@ -696,6 +716,12 @@ sharkd_session_process_frames(const char *buf, const jsmntok_t *tokens, int coun if (filter_data && !(filter_data[framenum / 8] & (1 << (framenum % 8)))) continue; + if (skip) + { + skip--; + continue; + } + sharkd_dissect_columns(framenum, cinfo, (fdata->color_filter == NULL)); printf("%s{\"c\":[", frame_sepa); @@ -724,6 +750,9 @@ sharkd_session_process_frames(const char *buf, const jsmntok_t *tokens, int coun printf("}"); frame_sepa = ","; + + if (limit && --limit == 0) + break; } printf("]\n"); |