aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-h248_q1950.c
blob: 8852bf9c67ccb14bcb6f58316e89fb04af0e05e8 (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
290
291
292
293
/*
 *  packet-h248_q1950.c
 *  Q.1950 annex A
 *
 *  (c) 2006, Anders Broman <anders.broman@telia.com>
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Ref ITU-T Rec. Q.1950 (12/2002)
 */

#include "packet-h248.h"
#include "packet-isup.h"

#define PNAME  "H.248 Q.1950 Annex A"
#define PSNAME "H248Q1950"
#define PFNAME "h248q1950"

static int proto_q1950 = -1;

/* A.3 Bearer characteristics package */
static int hf_h248_pkg_BCP = -1;
static int hf_h248_pkg_BCP_BNCChar = -1;

static int ett_h248_pkg_BCP = -1;

static gboolean implicit = FALSE;

static const value_string h248_pkg_BCP_parameters[] = {
	{   0x0001, "BNCChar (BNC Characteristics)" },
	{0,     NULL}
};

static const value_string h248_pkg_BCP_props_vals[] = {
	{1,"BNCChar"},
	{0,NULL}
};

/* Properties */
h248_pkg_param_t h248_pkg_BCP_props[] = {
	{ 0x0001, &hf_h248_pkg_BCP_BNCChar, h248_param_ber_integer, &implicit },
	{ 0, NULL, NULL, NULL}
};

/* Packet defenitions */
static h248_package_t h248_pkg_BCP = {
	0x001e,
	&hf_h248_pkg_BCP,
	&ett_h248_pkg_BCP,
	h248_pkg_BCP_props_vals,
	NULL,
	NULL,
	NULL,
	h248_pkg_BCP_props,			/* Properties */
	NULL,						/* signals */
	NULL,						/* events */
	NULL						/* statistics */
};

/* A.4 Bearer Network connection cut-through package */

/* A.5 Bearer Reuse Idle Package  */

/* A.6 Generic bearer connection package 
	Package Name: GB
	Package ID: 0x0021
 */

/* A.7 Bearer control tunnelling package */
static dissector_handle_t sdp_dissector = NULL;

static int hf_h248_pkg_bct = -1;
static int hf_h248_pkg_bct_tind = -1;

static gint ett_h248_pkg_bct = -1;
static gint ett_h248_pkg_bct_tind = -1;

static void dissect_bct_tind_bit(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, int hfid, h248_curr_info_t* i _U_, void* d _U_) {
	tvbuff_t* sdp_tvb = NULL;
	gint8 class;
	gboolean pc;
	gint32 tag;
	
	get_ber_identifier(tvb, 0, &class, &pc, &tag);
	
	/* XXX: is this enough to guess it? */
	if ((tag==BER_UNI_TAG_OCTETSTRING)) {
		dissect_ber_octet_string(FALSE, pinfo, tree, tvb, 0, hfid, &sdp_tvb);
		
		if (sdp_tvb) {
			/* XXX: are we sure it is always sdp? */
			call_dissector(sdp_dissector,sdp_tvb,pinfo,tree);
		}
	} else {
		proto_tree_add_item(tree,hfid,tvb,0,-1,FALSE);
	}
	
}

static h248_pkg_param_t h248_pkg_bct_tind[] = {
	{ 0x0001, &hf_h248_pkg_bct_tind, dissect_bct_tind_bit, &implicit },
	{ 0, NULL, NULL, NULL}
};

/* Events */
static h248_pkg_evt_t h248_pkg_bct_events[] = {
	{ 0x0001, &hf_h248_pkg_bct_tind, &ett_h248_pkg_bct_tind, h248_pkg_bct_tind},
	{ 0, NULL, NULL, NULL}
};


/* Packet defenitions */
static h248_package_t h248_pkg_bct = {
	0x0022,
	&hf_h248_pkg_bct,
	&ett_h248_pkg_bct,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,						/* Properties */
	NULL,						/* signals */
	h248_pkg_bct_events,		/* events */
	NULL						/* statistics */
};

/* A.8 Basic call progress tones generator with directionality */
static int hf_h248_pkg_bcg = -1;
static int hf_h248_pkg_bcg_sig_bdt_par_btd = -1;
static int hf_h248_pkg_bcg_sig_bdt = -1;
static int hf_h248_pkg_bcg_sig_brt = -1;
static int hf_h248_pkg_bcg_sig_bbt = -1;
static int hf_h248_pkg_bcg_sig_bct = -1;
static int hf_h248_pkg_bcg_sig_bsit = -1;
static int hf_h248_pkg_bcg_sig_bwt = -1;
static int hf_h248_pkg_bcg_sig_bpt = -1;
static int hf_h248_pkg_bcg_sig_bcw = -1;
static int hf_h248_pkg_bcg_sig_bcr = -1;
static int hf_h248_pkg_bcg_sig_bpy = -1;

static int ett_h248_pkg_bcg = -1;
static int ett_h248_pkg_bcg_sig_bdt = -1;

static const value_string h248_pkg_bcg_sig_bdt_par_btd_vals[] = {
	{   0x0001, "ext (External)" },
	{   0x0002, "int (Internal)" },
	{   0x0003, "both (Both)" },
	{0,     NULL},
};

static h248_pkg_param_t  h248_pkg_h248_pkg_bcg_sig_bdt_params[] = {
	{ 0x0001, &hf_h248_pkg_bcg_sig_bdt_par_btd, h248_param_ber_integer, &implicit },
	{ 0, NULL, NULL, NULL}
};

static h248_pkg_sig_t h248_pkg_bcg_signals[] = {
	/* All the tones have the same parameters */
	{ 0x0040, &hf_h248_pkg_bcg_sig_bdt, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0041, &hf_h248_pkg_bcg_sig_brt, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0042, &hf_h248_pkg_bcg_sig_bbt, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0043, &hf_h248_pkg_bcg_sig_bct, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0044, &hf_h248_pkg_bcg_sig_bsit, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0045, &hf_h248_pkg_bcg_sig_bwt, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0046, &hf_h248_pkg_bcg_sig_bpt, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0047, &hf_h248_pkg_bcg_sig_bcw, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0048, &hf_h248_pkg_bcg_sig_bcr, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0x0049, &hf_h248_pkg_bcg_sig_bpy, &ett_h248_pkg_bcg_sig_bdt, h248_pkg_h248_pkg_bcg_sig_bdt_params },
	{ 0, NULL, NULL, NULL}
};

/* Packet defenitions */
static h248_package_t h248_pkg_bcg = {
	0x0023,
	&hf_h248_pkg_bcg,
	&ett_h248_pkg_bcg,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,						/* Properties */
	h248_pkg_bcg_signals,		/* signals */
	NULL,						/* events */
	NULL						/* statistics */
};


/* Register dissector */
void proto_register_q1950(void) {
	static hf_register_info hf[] = {
		/* A.3 Bearer characteristics package */
		{ &hf_h248_pkg_BCP,
			{ "BCP (Bearer characteristics package)", "h248.pkg.BCP", 
			FT_BYTES, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_BCP_BNCChar,
			{ "BNCChar (BNC Characteristics)", "h248.pkg.bcp.bncchar", 
			FT_UINT32, BASE_HEX, VALS(bearer_network_connection_characteristics_vals), 0, "BNC Characteristics", HFILL }
		},
		/* A.8 Basic call progress tones generator with directionality */
		{ &hf_h248_pkg_bcg,
			{ "bcg (Basic call progress tones generator with directionality)", "h248.pkg.bcg", 
			FT_BYTES, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bdt_par_btd,
			{ "btd (Tone Direction)", "h248.pkg.bcp.btd", 
			FT_UINT32, BASE_HEX, VALS(h248_pkg_bcg_sig_bdt_par_btd_vals), 0, "btd (Tone Direction)", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bdt,
			{ "bdt (Dial Tone)", "h248.pkg.bcg.bdt", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_brt,
			{ "brt (Ringing tone)", "h248.pkg.bcg.brt", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bbt,
			{ "bbt (Busy tone)", "h248.pkg.bcg.bbt", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bct,
			{ "bct (Congestion tone)", "h248.pkg.bcg.bct", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bsit,
			{ "bsit (Special information tone)", "h248.pkg.bcg.bsit", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bwt,
			{ "bwt (Warning tone)", "h248.pkg.bcg.bwt", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bpt,
			{ "bpt (Payphone recognition tone)", "h248.pkg.bcg.bpt", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bcw,
			{ "bcw (Call waiting tone)", "h248.pkg.bcg.bcw", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bcg_sig_bpy,
			{ "bpy (Pay tone)", "h248.pkg.bcg.bpy", 
			FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &ett_h248_pkg_bct,
			{ "BCT (Bearer Control Tunneling)", "h248.pkg.bct", 
			FT_BYTES, BASE_HEX, NULL, 0, "", HFILL }
		},
		{ &hf_h248_pkg_bct_tind,
			{ "tind (Tunnel INDication)", "h248.pkg.bct.tind", 
				FT_BYTES, BASE_HEX, NULL, 0, "", HFILL }
		},
		
	};

	static gint *ett[] = {
		&ett_h248_pkg_BCP,
		&ett_h248_pkg_bct,
		&ett_h248_pkg_bct_tind
	};
	proto_q1950 = proto_register_protocol(PNAME, PSNAME, PFNAME);

	proto_register_field_array(proto_q1950, hf, array_length(hf));

	proto_register_subtree_array(ett, array_length(ett));
	
	/* Register the packages */
	h248_register_package(&h248_pkg_BCP);
	h248_register_package(&h248_pkg_bcg);
	h248_register_package(&h248_pkg_bct);
}

void proto_reg_handoff_q1950(void) {
	sdp_dissector = find_dissector("sdp");
	
}