Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
packet-h248-template.h
1 /* packet-h248.h
2  * Definitions for H.248/MEGACO packet dissection
3  *
4  * Ronnie Sahlberg 2004
5  * Luis Ontanon 2005
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * SPDX-License-Identifier: GPL-2.0-or-later
12  */
13 
14 #ifndef PACKET_H248_H
15 #define PACKET_H248_H
16 
17 #include "ws_symbol_export.h"
18 
19 #include <epan/packet.h>
20 #include <epan/expert.h>
21 #include <wsutil/nstime.h>
22 
23 /* Gateway Control Protocol -- Context Tracking */
24 
25 typedef struct _gcp_hf_ett_t {
26  struct {
27  int ctx;
28  int ctx_cmd;
29  int ctx_term;
30  int ctx_term_type;
31  int ctx_term_bir;
32  int ctx_term_nsap;
33  } hf;
34 
35  struct {
36  gint ctx;
37  gint ctx_cmds;
38  gint ctx_terms;
39  gint ctx_term;
40  } ett;
41 } gcp_hf_ett_t;
42 
43 #define NULL_CONTEXT 0
44 #define CHOOSE_CONTEXT 0xFFFFFFFE
45 #define ALL_CONTEXTS 0xFFFFFFFF
46 
47 
48 typedef enum {
49  GCP_CMD_NONE,
50  GCP_CMD_ADD_REQ,
51  GCP_CMD_MOVE_REQ,
52  GCP_CMD_MOD_REQ,
53  GCP_CMD_SUB_REQ,
54  GCP_CMD_AUDITCAP_REQ,
55  GCP_CMD_AUDITVAL_REQ,
56  GCP_CMD_NOTIFY_REQ,
57  GCP_CMD_SVCCHG_REQ,
58  GCP_CMD_TOPOLOGY_REQ,
59  GCP_CMD_CTX_ATTR_AUDIT_REQ,
60  GCP_CMD_OTHER_REQ,
61  GCP_CMD_ADD_REPLY,
62  GCP_CMD_MOVE_REPLY,
63  GCP_CMD_MOD_REPLY,
64  GCP_CMD_SUB_REPLY,
65  GCP_CMD_AUDITCAP_REPLY,
66  GCP_CMD_AUDITVAL_REPLY,
67  GCP_CMD_NOTIFY_REPLY,
68  GCP_CMD_SVCCHG_REPLY,
69  GCP_CMD_TOPOLOGY_REPLY,
70  GCP_CMD_REPLY
71 } gcp_cmd_type_t;
72 
73 typedef enum {
74  GCP_TRX_NONE,
75  GCP_TRX_REQUEST,
76  GCP_TRX_PENDING,
77  GCP_TRX_REPLY,
78  GCP_TRX_ACK
79 } gcp_trx_type_t;
80 
81 
82 typedef struct _gcp_msg_t {
83  guint32 lo_addr;
84  guint32 hi_addr;
85  guint32 framenum;
86  nstime_t frametime;
87  struct _gcp_trx_msg_t* trxs;
88  gboolean committed;
89 } gcp_msg_t;
90 
91 typedef struct _gcp_trx_msg_t {
92  struct _gcp_trx_t* trx;
93  struct _gcp_trx_msg_t* next;
94  struct _gcp_trx_msg_t* last;
96 
97 typedef struct _gcp_cmd_msg_t {
98  struct _gcp_cmd_t* cmd;
99  struct _gcp_cmd_msg_t* next;
100  struct _gcp_cmd_msg_t* last;
101 } gcp_cmd_msg_t;
102 
103 typedef struct _gcp_trx_t {
104  gcp_msg_t* initial;
105  guint32 id;
106  gcp_trx_type_t type;
107  guint pendings;
108  struct _gcp_cmd_msg_t* cmds;
109  struct _gcp_trx_ctx_t* ctxs;
110  guint error;
111 } gcp_trx_t;
112 
113 #define GCP_TERM_TYPE_UNKNOWN 0
114 #define GCP_TERM_TYPE_AAL1 1
115 #define GCP_TERM_TYPE_AAL2 2
116 #define GCP_TERM_TYPE_AAL1_STRUCT 3
117 #define GCP_TERM_TYPE_IP_RTP 4
118 #define GCP_TERM_TYPE_TDM 5
119 
120 typedef enum _gcp_wildcard_t {
121  GCP_WILDCARD_NONE,
122  GCP_WILDCARD_CHOOSE,
123  GCP_WILDCARD_ALL
124 } gcp_wildcard_t;
125 
126 typedef struct _gcp_term_t {
127  const gchar* str;
128 
129  const guint8* buffer;
130  guint len;
131 
132  guint type;
133  gchar* bir;
134  gchar* nsap;
135 
136  gcp_msg_t* start;
137 
138 } gcp_term_t;
139 
140 typedef struct _gcp_terms_t {
141  gcp_term_t* term;
142  struct _gcp_terms_t* next;
143  struct _gcp_terms_t* last;
144 } gcp_terms_t;
145 
146 typedef struct _gcp_cmd_t {
147  guint offset;
148  const gchar* str;
149  gcp_cmd_type_t type;
150  gcp_terms_t terms;
151  struct _gcp_msg_t* msg;
152  struct _gcp_trx_t* trx;
153  struct _gcp_ctx_t* ctx;
154  guint error;
155 } gcp_cmd_t;
156 
157 
158 typedef struct _gcp_ctx_t {
159  gcp_msg_t* initial;
160  guint32 id;
161  struct _gcp_cmd_msg_t* cmds;
162  struct _gcp_ctx_t* prev;
163  gcp_terms_t terms;
164 } gcp_ctx_t;
165 
166 extern gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean persistent);
167 extern gcp_trx_t* gcp_trx(gcp_msg_t* m ,guint32 t_id , gcp_trx_type_t type, gboolean persistent);
168 extern gcp_ctx_t* gcp_ctx(gcp_msg_t* m, gcp_trx_t* t, guint32 c_id, gboolean persistent);
169 extern gcp_cmd_t* gcp_cmd(gcp_msg_t* m, gcp_trx_t* t, gcp_ctx_t* c, gcp_cmd_type_t type, guint offset, gboolean persistent);
170 extern gcp_term_t* gcp_cmd_add_term(gcp_msg_t* m, gcp_trx_t* tr, gcp_cmd_t* c, gcp_term_t* t, gcp_wildcard_t wildcard, gboolean persistent);
171 extern void gcp_analyze_msg(proto_tree* gcp_tree, packet_info* pinfo, tvbuff_t* gcp_tvb, gcp_msg_t* m, gcp_hf_ett_t* ids, expert_field* command_err);
172 
173 #define GCP_ETT_ARR_ELEMS(gi) &(gi.ett.ctx),&(gi.ett.ctx_cmds),&(gi.ett.ctx_terms),&(gi.ett.ctx_term)
174 
175 #define GCP_HF_ARR_ELEMS(n,gi) \
176  { &(gi.hf.ctx), { "Context", n ".ctx", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL }}, \
177  { &(gi.hf.ctx_term), { "Termination", n ".ctx.term", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
178  { &(gi.hf.ctx_term_type), { "Type", n ".ctx.term.type", FT_UINT32, BASE_HEX, VALS(gcp_term_types), 0, NULL, HFILL }}, \
179  { &(gi.hf.ctx_term_bir), { "BIR", n ".ctx.term.bir", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
180  { &(gi.hf.ctx_term_nsap), { "NSAP", n ".ctx.term.nsap", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
181  { &(gi.hf.ctx_cmd), { "Command in Frame", n ".ctx.cmd", FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }}
182 
183 WS_DLL_PUBLIC const value_string gcp_cmd_type[];
184 WS_DLL_PUBLIC const value_string gcp_term_types[];
185 
186 extern const gchar* gcp_msg_to_str(gcp_msg_t* m, gboolean persistent);
187 
188 #define gcp_cmd_set_error(c,e) (c->error = e)
189 #define gcp_trx_set_error(t,e) (t->error = e)
190 
191 /* END Gateway Control Protocol -- Context Tracking */
192 
193 typedef struct _h248_curr_info_t h248_curr_info_t;
194 
195 typedef void (*h248_pkg_param_dissector_t)(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, int hfid, h248_curr_info_t*, void*);
196 
197 extern void h248_param_bytes_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
198 extern void h248_param_uint_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
199 WS_DLL_PUBLIC void h248_param_ber_integer(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
200 extern void h248_param_ber_octetstring(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
201 extern void h248_param_ber_boolean(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
202 extern void external_dissector(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* dissector_handle);
203 extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl);
204 extern void h248_param_external_dissector(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl);
205 
206 typedef enum {
207  ADD_PKG, /* add package at registration ONLY if no matching package ID */
208  REPLACE_PKG, /* replace/add package at registration */
209  MERGE_PKG_HIGH, /* merge h248_package_t at registration favor new package */
210  MERGE_PKG_LOW /* merge h248_package_t at registration favor current package */
211 } pkg_reg_action;
212 
213 typedef struct _h248_pkg_param_t {
214  guint32 id;
215  int* hfid;
216  h248_pkg_param_dissector_t dissector;
217  void* data;
219 
220 typedef struct _h248_pkg_sig_t {
221  guint32 id;
222  int* hfid;
223  gint* ett;
224  const h248_pkg_param_t* parameters;
225  const value_string* param_names;
227 
228 typedef struct _h248_pkg_evt_t {
229  guint32 id;
230  int* hfid;
231  gint* ett;
232  const h248_pkg_param_t* parameters;
233  const value_string* param_names;
235 
236 typedef struct _h248_pkg_stat_t {
237  guint32 id;
238  int* hfid;
239  gint* ett;
240  const h248_pkg_param_t* parameters;
241  const value_string* param_names;
243 
244 typedef struct _h248_package_t {
245  guint32 id;
246  int* hfid;
247  gint* ett;
249  const value_string* signal_names;
250  const value_string* event_names;
251  const value_string* stats_names;
252  const h248_pkg_param_t* properties;
253  const h248_pkg_sig_t* signals;
254  const h248_pkg_evt_t* events;
255  const h248_pkg_stat_t* statistics;
257 
258 typedef struct _save_h248_package_t {
259  h248_package_t *pkg;
260  gboolean is_default;
262 
264  gcp_ctx_t* ctx;
265  gcp_trx_t* trx;
266  gcp_msg_t* msg;
267  gcp_term_t* term;
268  gcp_cmd_t* cmd;
269  const h248_package_t* pkg;
270  const h248_pkg_evt_t* evt;
271  const h248_pkg_sig_t* sig;
272  const h248_pkg_stat_t* stat;
273  const h248_pkg_param_t* par;
274 };
275 
276 typedef struct h248_term_info {
277  guint8 wild_card;
278  gchar *str;
280 
281 WS_DLL_PUBLIC
282 void h248_register_package(h248_package_t* pkg, pkg_reg_action reg_action);
283 
284 #endif /* PACKET_H248_H */
Definition: packet-h248-template.h:244
Definition: packet-h248-template.h:158
Definition: packet-h248-template.h:82
Definition: packet_info.h:44
Definition: packet-h248-template.h:213
Definition: packet-h248-template.h:258
Definition: packet-h248-template.h:146
Definition: packet-h248-template.h:228
Definition: packet-h248-template.h:126
Definition: packet-h248-template.h:140
Definition: packet-h248-template.h:263
Definition: tvbuff-int.h:35
Definition: packet-h248-template.h:25
Definition: packet.c:659
Definition: nstime.h:27
Definition: packet-h248-template.h:220
gint * ett
Definition: packet-h248-template.h:247
guint32 id
Definition: packet-h248-template.h:245
Definition: expert.h:37
Definition: packet-h248-template.h:91
Definition: packet-h248-template.h:276
Definition: packet-h248-template.h:97
Definition: mcast_stream.h:30
Definition: value_string.h:24
int * hfid
Definition: packet-h248-template.h:246
Definition: proto.h:759
const value_string * param_names
Definition: packet-h248-template.h:248
Definition: packet-h248-template.h:236
Definition: packet-h248-template.h:103