Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-json.h
1/* packet-json.h
2 * Routines for JSON dissection
3 * References:
4 * RFC 4627: https://tools.ietf.org/html/rfc4627
5 * Website: http://json.org/
6 *
7 * Copyright 2010, Jakub Zawadzki <darkjames-ws@darkjames.pl>
8 *
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 */
15
16#ifndef _PACKET_JSON_H
17#define _PACKET_JSON_H
18
19#include <wsutil/wsjson.h>
20
21/* XXX - This should probably be a string or custom dissector table */
22extern GHashTable *json_header_fields_hash;
23
24/* json data decoding function
25 */
26typedef void(*json_data_decoder_func)(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo, int offset, int len, const char* key_str);
27
28/* Array of functions to dissect IEs
29*/
30typedef struct _json_ie {
31 json_data_decoder_func json_data_decoder;
32} json_ie_t;
33
34/* A struct to hold the hf and callback function stored in a hastable with the json key as key.
35 * If the callback is null NULL the filter will be used useful to create filterable items in json.
36 * XXX Todo: Implement hte UAT from the http dissector to enable the users to create filters? and/or
37 * read config from file, similar to Diameter(filter only)?
38 */
39typedef struct {
40 int *hf_id;
41 json_data_decoder_func json_data_decoder;
43
44typedef struct _json_key {
45 int offset;
46 int len;
47 char* key_str;
48 bool use_compact;
49} json_key_t;
50
51/* A struct holding data to be passed to the heuristic dissectors registered
52 * in the "json" heuristic table.
53 *
54 * It carries the parsed form of the JSON data so that a subdissector does not
55 * have to parse it again: the jsmn token array built for the JSON+ form
56 * is handed over as is.
57 *
58 * Token offsets are relative to the start of the JSON data, which is also
59 * offset 0 of the tvbuff passed to the heuristic dissector, so they can be
60 * used directly as tvbuff offsets.
61 */
62typedef struct _json_heur_data {
63 /* media_content_info_t * or NULL if not available */
64 void *content_info;
65
66 /* Pointer to the raw JSON. Not NULL terminated: use the token offsets. */
67 const char *buf;
68
69 /* jsmn token array, NULL when the JSON could not be parsed. */
70 jsmntok_t *tokens;
71 int num_tokens;
72} json_heur_data_t;
73
74#endif /* _PACKET_JSON_H */
75
76/*
77 * Editor modelines - https://www.wireshark.org/tools/modelines.html
78 *
79 * Local variables:
80 * c-basic-offset: 4
81 * tab-width: 8
82 * indent-tabs-mode: nil
83 * End:
84 *
85 * vi: set shiftwidth=4 tabstop=8 expandtab:
86 * :indentSize=4:tabSize=8:noTabs=true:
87 */
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
Definition packet-json.h:62
Definition packet-json.h:30
Definition packet-json.h:44
Definition jsmn.h:69
Definition packet-json.h:39