summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-h248.h
blob: ef7d395e09b185848bd467aa96337524262c021a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/* Do not modify this file. Changes will be overwritten.                      */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler       */
/* packet-h248.h                                                              */
/* asn2wrs.py -b -L -p h248 -c ./h248.cnf -s ./packet-h248-template -D . -O ../.. h248v3.asn h248v1support.asn */

/* packet-h248.h
 * Definitions for H.248/MEGACO packet dissection
 *
 * Ronnie Sahlberg 2004
 * Luis Ontanon 2005
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef PACKET_H248_H
#define PACKET_H248_H

#include "ws_symbol_export.h"

#include <epan/packet.h>
#include <epan/expert.h>
#include <wsutil/nstime.h>

/* Gateway Control Protocol -- Context Tracking */

typedef struct _gcp_hf_ett_t {
	struct {
		int ctx;
		int ctx_cmd;
		int ctx_term;
		int ctx_term_type;
		int ctx_term_bir;
		int ctx_term_nsap;
	} hf;

	struct {
		gint ctx;
		gint ctx_cmds;
		gint ctx_terms;
		gint ctx_term;
	} ett;
} gcp_hf_ett_t;

#define NULL_CONTEXT 0
#define CHOOSE_CONTEXT 0xFFFFFFFE
#define ALL_CONTEXTS 0xFFFFFFFF


typedef enum {
	GCP_CMD_NONE,
	GCP_CMD_ADD_REQ,
	GCP_CMD_MOVE_REQ,
	GCP_CMD_MOD_REQ,
	GCP_CMD_SUB_REQ,
	GCP_CMD_AUDITCAP_REQ,
	GCP_CMD_AUDITVAL_REQ,
	GCP_CMD_NOTIFY_REQ,
	GCP_CMD_SVCCHG_REQ,
	GCP_CMD_TOPOLOGY_REQ,
	GCP_CMD_CTX_ATTR_AUDIT_REQ,
	GCP_CMD_OTHER_REQ,
	GCP_CMD_ADD_REPLY,
	GCP_CMD_MOVE_REPLY,
	GCP_CMD_MOD_REPLY,
	GCP_CMD_SUB_REPLY,
	GCP_CMD_AUDITCAP_REPLY,
	GCP_CMD_AUDITVAL_REPLY,
	GCP_CMD_NOTIFY_REPLY,
	GCP_CMD_SVCCHG_REPLY,
	GCP_CMD_TOPOLOGY_REPLY,
	GCP_CMD_REPLY
} gcp_cmd_type_t;

typedef enum {
	GCP_TRX_NONE,
	GCP_TRX_REQUEST,
	GCP_TRX_PENDING,
	GCP_TRX_REPLY,
	GCP_TRX_ACK
} gcp_trx_type_t;


typedef struct _gcp_msg_t {
	guint32 lo_addr;
	guint32 hi_addr;
	guint32 framenum;
	nstime_t frametime;
	struct _gcp_trx_msg_t* trxs;
	gboolean committed;
} gcp_msg_t;

typedef struct _gcp_trx_msg_t {
	struct _gcp_trx_t* trx;
	struct _gcp_trx_msg_t* next;
	struct _gcp_trx_msg_t* last;
} gcp_trx_msg_t;

typedef struct _gcp_cmd_msg_t {
	struct _gcp_cmd_t* cmd;
	struct _gcp_cmd_msg_t* next;
	struct _gcp_cmd_msg_t* last;
} gcp_cmd_msg_t;

typedef struct _gcp_trx_t {
	gcp_msg_t* initial;
	guint32 id;
	gcp_trx_type_t type;
	guint pendings;
	struct _gcp_cmd_msg_t* cmds;
	struct _gcp_trx_ctx_t* ctxs;
	guint error;
} gcp_trx_t;

#define GCP_TERM_TYPE_UNKNOWN 0
#define GCP_TERM_TYPE_AAL1 1
#define GCP_TERM_TYPE_AAL2 2
#define GCP_TERM_TYPE_AAL1_STRUCT 3
#define GCP_TERM_TYPE_IP_RTP 4
#define GCP_TERM_TYPE_TDM 5

typedef enum _gcp_wildcard_t {
	GCP_WILDCARD_NONE,
	GCP_WILDCARD_CHOOSE,
	GCP_WILDCARD_ALL
} gcp_wildcard_t;

typedef struct _gcp_term_t {
	const gchar* str;

	const guint8* buffer;
	guint len;

	guint type;
	gchar* bir;
	gchar* nsap;

	gcp_msg_t* start;

} gcp_term_t;

typedef struct _gcp_terms_t {
	gcp_term_t* term;
	struct _gcp_terms_t* next;
	struct _gcp_terms_t* last;
} gcp_terms_t;

typedef struct _gcp_cmd_t {
	guint offset;
	const gchar* str;
	gcp_cmd_type_t type;
	gcp_terms_t terms;
	struct _gcp_msg_t* msg;
	struct _gcp_trx_t* trx;
	struct _gcp_ctx_t* ctx;
	guint error;
} gcp_cmd_t;


typedef struct _gcp_ctx_t {
	gcp_msg_t* initial;
	guint32 id;
	struct _gcp_cmd_msg_t* cmds;
	struct _gcp_ctx_t* prev;
	gcp_terms_t terms;
} gcp_ctx_t;

extern gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean persistent);
extern gcp_trx_t* gcp_trx(gcp_msg_t* m ,guint32 t_id , gcp_trx_type_t type, packet_info *pinfo, gboolean persistent);
extern gcp_ctx_t* gcp_ctx(gcp_msg_t* m, gcp_trx_t* t, guint32 c_id, packet_info *pinfo, gboolean persistent);
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, packet_info *pinfo, gboolean persistent);
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, packet_info *pinfo, gboolean persistent);
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);

#define GCP_ETT_ARR_ELEMS(gi)     &(gi.ett.ctx),&(gi.ett.ctx_cmds),&(gi.ett.ctx_terms),&(gi.ett.ctx_term)

#define GCP_HF_ARR_ELEMS(n,gi) \
	{ &(gi.hf.ctx), { "Context", n ".ctx", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL }}, \
	{ &(gi.hf.ctx_term), { "Termination", n ".ctx.term", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
	{ &(gi.hf.ctx_term_type), { "Type", n ".ctx.term.type", FT_UINT32, BASE_HEX, VALS(gcp_term_types), 0, NULL, HFILL }}, \
	{ &(gi.hf.ctx_term_bir), { "BIR", n ".ctx.term.bir", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
	{ &(gi.hf.ctx_term_nsap), { "NSAP", n ".ctx.term.nsap", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, \
	{ &(gi.hf.ctx_cmd), { "Command in Frame", n ".ctx.cmd", FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }}

WS_DLL_PUBLIC const value_string gcp_cmd_type[];
WS_DLL_PUBLIC const value_string gcp_term_types[];

extern const gchar* gcp_msg_to_str(gcp_msg_t* m, wmem_allocator_t *scope, gboolean persistent);

#define gcp_cmd_set_error(c,e) (c->error = e)
#define gcp_trx_set_error(t,e) (t->error = e)

/* END Gateway Control Protocol -- Context Tracking */

typedef struct _h248_curr_info_t h248_curr_info_t;

typedef void (*h248_pkg_param_dissector_t)(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, int hfid, h248_curr_info_t*, void*);

extern void h248_param_bytes_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
extern void h248_param_uint_item(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
WS_DLL_PUBLIC void h248_param_ber_integer(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
extern void h248_param_ber_octetstring(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
extern void h248_param_ber_boolean(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* ignored);
extern void external_dissector(proto_tree*, tvbuff_t*, packet_info* , int, h248_curr_info_t*,void* dissector_handle);
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);
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);

typedef enum {
	ADD_PKG,	/* add package at registration ONLY if no matching package ID */
	REPLACE_PKG,	/* replace/add package at registration */
	MERGE_PKG_HIGH,		/* merge h248_package_t at registration favor new package */
	MERGE_PKG_LOW		/* merge h248_package_t at registration favor current package */
} pkg_reg_action;

typedef struct _h248_pkg_param_t {
	guint32 id;
	int* hfid;
	h248_pkg_param_dissector_t dissector;
	void* data;
} h248_pkg_param_t;

typedef struct _h248_pkg_sig_t {
	guint32 id;
	int* hfid;
	gint* ett;
	const h248_pkg_param_t* parameters;
	const value_string* param_names;
} h248_pkg_sig_t;

typedef struct _h248_pkg_evt_t {
	guint32 id;
	int* hfid;
	gint* ett;
	const h248_pkg_param_t* parameters;
	const value_string* param_names;
} h248_pkg_evt_t;

typedef struct _h248_pkg_stat_t {
	guint32 id;
	int* hfid;
	gint* ett;
	const h248_pkg_param_t* parameters;
	const value_string* param_names;
} h248_pkg_stat_t;

typedef struct _h248_package_t {
	guint32 id;                            /**< Package ID */
	int* hfid;                             /**< hfid that will display the package name */
	gint* ett;                             /**< The ett for this item */
	const value_string* param_names;       /**< The parameter names, Value 00000 should be the package name */
	const value_string* signal_names;
	const value_string* event_names;
	const value_string* stats_names;
	const h248_pkg_param_t* properties;
	const h248_pkg_sig_t* signals;
	const h248_pkg_evt_t* events;
	const h248_pkg_stat_t* statistics;
} h248_package_t;

typedef struct _save_h248_package_t {
	h248_package_t *pkg;
	gboolean is_default;
} s_h248_package_t;

struct _h248_curr_info_t {
	gcp_ctx_t* ctx;
	gcp_trx_t* trx;
	gcp_msg_t* msg;
	gcp_term_t* term;
	gcp_cmd_t* cmd;
	const h248_package_t* pkg;
	const h248_pkg_evt_t* evt;
	const h248_pkg_sig_t* sig;
	const h248_pkg_stat_t* stat;
	const h248_pkg_param_t* par;
};

typedef struct h248_term_info {
	guint8 wild_card;
	gchar *str;
} h248_term_info_t;

WS_DLL_PUBLIC
void h248_register_package(h248_package_t* pkg, pkg_reg_action reg_action);

#endif  /* PACKET_H248_H */