printf(",\"protocols\":[");
for (framenum = 1; framenum <= cfile.count; framenum++)
- sharkd_dissect_request(framenum, (framenum != 1) ? 1 : 0, framenum - 1, &sharkd_session_process_analyse_cb, 0, 0, 0, &analyser);
+ sharkd_dissect_request(framenum, (framenum != 1) ? 1 : 0, framenum - 1, &sharkd_session_process_analyse_cb, SHARKD_DISSECT_FLAG_NULL, &analyser);
printf("]");
if (analyser.first_time)
}
static void
-sharkd_session_process_frame_cb_tree(epan_dissect_t *edt, proto_tree *tree, tvbuff_t **tvbs)
+sharkd_session_process_frame_cb_tree(epan_dissect_t *edt, proto_tree *tree, tvbuff_t **tvbs, gboolean display_hidden)
{
proto_node *node;
const char *sepa = "";
if (!finfo)
continue;
- /* XXX, for now always skip hidden */
- if (FI_GET_FLAG(finfo, FI_HIDDEN))
+ if (!display_hidden && FI_GET_FLAG(finfo, FI_HIDDEN))
continue;
printf("%s{", sepa);
}
}
+ if (FI_GET_FLAG(finfo, FI_GENERATED))
+ {
+ printf(",\"g\":true");
+ }
+
+ if (FI_GET_FLAG(finfo, FI_HIDDEN))
+ {
+ printf(",\"v\":true");
+ }
+
if (FI_GET_FLAG(finfo, PI_SEVERITY_MASK))
{
const char *severity = try_val_to_str(FI_GET_FLAG(finfo, PI_SEVERITY_MASK), expert_severity_vals);
if (finfo->tree_type != -1)
printf(",\"e\":%d", finfo->tree_type);
printf(",\"n\":");
- sharkd_session_process_frame_cb_tree(edt, (proto_tree *) node, tvbs);
+ sharkd_session_process_frame_cb_tree(edt, (proto_tree *) node, tvbs, display_hidden);
}
printf("}");
return FALSE;
}
+struct sharkd_frame_request_data
+{
+ gboolean display_hidden;
+};
+
static void
sharkd_session_process_frame_cb(epan_dissect_t *edt, proto_tree *tree, struct epan_column_info *cinfo, const GSList *data_src, void *data)
{
frame_data *fdata = pi->fd;
const char *pkt_comment = NULL;
- (void) data;
-
+ const struct sharkd_frame_request_data * const req_data = (const struct sharkd_frame_request_data * const) data;
+ const gboolean display_hidden = (req_data) ? req_data->display_hidden : FALSE;
printf("{");
printf("\"err\":0");
tvbs[count] = NULL;
}
- sharkd_session_process_frame_cb_tree(edt, tree, tvbs);
+ sharkd_session_process_frame_cb_tree(edt, tree, tvbs, display_hidden);
g_free(tvbs);
}
printf("]");
}
+ if (fdata->flags.ignored)
+ printf(",\"i\":true");
+
+ if (fdata->flags.marked)
+ printf(",\"m\":true");
+
+ if (fdata->color_filter)
+ {
+ printf(",\"bg\":\"%x\"", color_t_to_rgb(&fdata->color_filter->bg_color));
+ printf(",\"fg\":\"%x\"", color_t_to_rgb(&fdata->color_filter->fg_color));
+ }
+
if (data_src)
{
struct data_source *src = (struct data_source *) data_src->data;
* (o) prev_frame - previously displayed frame number
* (o) proto - set if output frame tree
* (o) columns - set if output frame columns
+ * (o) color - set if output color-filter bg/fg
* (o) bytes - set if output frame bytes
+ * (o) hidden - set if output hidden tree fields
*
* Output object with attributes:
* (m) err - 0 if succeed
* ds- data src index
* url - only for t:'url', url
* fnum - only for t:'framenum', frame number
+ * g - if field is generated by Wireshark
+ * v - if field is hidden
*
* (o) col - array of column data
* (o) bytes - base64 of frame bytes
* (o) fol - array of follow filters:
* [0] - protocol
* [1] - filter string
+ * (o) i - if frame is ignored
+ * (o) m - if frame is marked
+ * (o) bg - color filter - background color in hex
+ * (o) fg - color filter - foreground color in hex
*/
static void
sharkd_session_process_frame(char *buf, const jsmntok_t *tokens, int count)
const char *tok_frame = json_find_attr(buf, tokens, count, "frame");
const char *tok_ref_frame = json_find_attr(buf, tokens, count, "ref_frame");
const char *tok_prev_frame = json_find_attr(buf, tokens, count, "prev_frame");
- int tok_proto = (json_find_attr(buf, tokens, count, "proto") != NULL);
- int tok_bytes = (json_find_attr(buf, tokens, count, "bytes") != NULL);
- int tok_columns = (json_find_attr(buf, tokens, count, "columns") != NULL);
-
guint32 framenum, ref_frame_num, prev_dis_num;
+ guint32 dissect_flags = SHARKD_DISSECT_FLAG_NULL;
+ if (json_find_attr(buf, tokens, count, "proto") != NULL)
+ dissect_flags |= SHARKD_DISSECT_FLAG_PROTO_TREE;
+ if (json_find_attr(buf, tokens, count, "bytes") != NULL)
+ dissect_flags |= SHARKD_DISSECT_FLAG_BYTES;
+ if (json_find_attr(buf, tokens, count, "columns") != NULL)
+ dissect_flags |= SHARKD_DISSECT_FLAG_COLUMNS;
+ if (json_find_attr(buf, tokens, count, "color") != NULL)
+ dissect_flags |= SHARKD_DISSECT_FLAG_COLOR;
if (!tok_frame || !ws_strtou32(tok_frame, NULL, &framenum) || framenum == 0)
return;
if (tok_prev_frame && (!ws_strtou32(tok_prev_frame, NULL, &prev_dis_num) || prev_dis_num >= framenum))
return;
- sharkd_dissect_request(framenum, ref_frame_num, prev_dis_num, &sharkd_session_process_frame_cb, tok_bytes, tok_columns, tok_proto, NULL);
+ struct sharkd_frame_request_data req_data;
+ req_data.display_hidden = (json_find_attr(buf, tokens, count, "v") != NULL);
+
+ sharkd_dissect_request(framenum, ref_frame_num, prev_dis_num, &sharkd_session_process_frame_cb, dissect_flags, &req_data);
}
/**