summaryrefslogtreecommitdiffstats
path: root/src/isi-ss.c
blob: f37626fcb404299552bac7506947ba949db77d6e (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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/* isi-ss.c
 * Dissector for ISI's Subscriber Services resource
 * Copyright 2010, Sebastian Reichel <sre@ring0.de>
 * Copyright 2010, Tyson Key <tyson.key@gmail.com>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <glib.h>
#include <epan/prefs.h>
#include <epan/packet.h>

#include "packet-isi.h"
#include "isi-ss.h"

#include <epan/dissectors/packet-gsm_sms.h>

static const value_string isi_ss_message_id[] = {
	{0x00, "SS_SERVICE_REQ"},
	{0x01, "SS_SERVICE_COMPLETED_RESP"},
	{0x02, "SS_SERVICE_FAILED_RESP"},
	{0x03, "SS_SERVICE_NOT_SUPPORTED_RESP"},
	{0x04, "SS_GSM_USSD_SEND_REQ"},
	{0x05, "SS_GSM_USSD_SEND_RESP"},
	{0x06, "SS_GSM_USSD_RECEIVE_IND"},
	{0x09, "SS_STATUS_IND"},
	{0x10, "SS_SERVICE_COMPLETED_IND"},
	{0x11, "SS_CANCEL_REQ"},
	{0x12, "SS_CANCEL_RESP"},
	{0x15, "SS_RELEASE_REQ"},
	{0x16, "SS_RELEASE_RESP"},
	{0xF0, "COMMON_MESSAGE"},
};

static const value_string isi_ss_ussd_type[] = {
	{0x01, "SS_GSM_USSD_MT_REPLY"},
	{0x02, "SS_GSM_USSD_COMMAND"},
	{0x03, "SS_GSM_USSD_REQUEST"},
	{0x04, "SS_GSM_USSD_NOTIFY"},
	{0x05, "SS_GSM_USSD_END"},
};

static const value_string isi_ss_subblock[] = {
	{0x00, "SS_FORWARDING"},
	{0x01, "SS_STATUS_RESULT"},
	{0x03, "SS_GSM_PASSWORD"},
	{0x04, "SS_GSM_FORWARDING_INFO"},
	{0x05, "SS_GSM_FORWARDING_FEATURE"},
	{0x08, "SS_GSM_DATA"},
	{0x09, "SS_GSM_BSC_INFO"},
	{0x0B, "SS_GSM_PASSWORD_INFO"},
	{0x0D, "SS_GSM_INDICATE_PASSWORD_ERROR"},
	{0x0E, "SS_GSM_INDICATE_ERROR"},
	{0x2F, "SS_GSM_ADDITIONAL_INFO"},
	{0x32, "SS_GSM_USSD_STRING"},
};

static const value_string isi_ss_operation[] = {
	{0x01, "SS_ACTIVATION"},
	{0x02, "SS_DEACTIVATION"},
	{0x03, "SS_REGISTRATION"},
	{0x04, "SS_ERASURE"},
	{0x05, "SS_INTERROGATION"},
	{0x06, "SS_GSM_PASSWORD_REGISTRATION"},
};

static const value_string isi_ss_service_code[] = {
	{0x00, "SS_ALL_TELE_AND_BEARER"},
	{0x0A, "SS_GSM_ALL_TELE"},
	{0x0B, "SS_GSM_TELEPHONY"},
	{0x0C, "SS_GSM_ALL_DATA_TELE"},
	{0x0D, "SS_GSM_FACSIMILE"},
	{0x10, "SS_GSM_SMS"},
	{0x00, NULL}
};

static const value_string isi_ss_status_indication[] = {
	{0x00, "SS_STATUS_REQUEST_SERVICE_START"},
	{0x01, "SS_STATUS_REQUEST_SERVICE_STOP"},
	{0x02, "SS_GSM_STATUS_REQUEST_USSD_START"},
	{0x03, "SS_GSM_STATUS_REQUEST_USSD_STOP"},
	{0x00, NULL}
};

static const value_string isi_ss_common_message_id[] = {
	{0x01, "COMM_SERVICE_NOT_IDENTIFIED_RESP"},
	{0x12, "COMM_ISI_VERSION_GET_REQ"},
	{0x13, "COMM_ISI_VERSION_GET_RESP"},
	{0x14, "COMM_ISA_ENTITY_NOT_REACHABLE_RESP"},
};

static dissector_handle_t isi_ss_handle;
static void dissect_isi_ss(tvbuff_t *tvb, packet_info *pinfo, proto_item *tree);

static gint32 hf_isi_ss_message_id = -1;
static gint32 hf_isi_ss_ussd_type = -1;
static gint32 hf_isi_ss_subblock_count = -1;
static gint32 hf_isi_ss_subblock = -1;
static gint32 hf_isi_ss_operation = -1;
static gint32 hf_isi_ss_service_code = -1;
static gint32 hf_isi_ss_status_indication = -1;
static gint32 hf_isi_ss_ussd_length = -1;

static gint32 hf_isi_ss_common_message_id = -1;

void proto_reg_handoff_isi_ss(void) {
	static gboolean initialized=FALSE;

	if (!initialized) {
		isi_ss_handle = create_dissector_handle(dissect_isi_ss, proto_isi);
		dissector_add("isi.resource", 0x06, isi_ss_handle);
	}
}

void proto_register_isi_ss(void) {
	static hf_register_info hf[] = {
		{ &hf_isi_ss_message_id,
		  { "Message ID", "isi.ss.msg_id", FT_UINT8, BASE_HEX, isi_ss_message_id, 0x0, "Message ID", HFILL }},
		{ &hf_isi_ss_ussd_type,
		  { "USSD Type", "isi.ss.ussd.type", FT_UINT8, BASE_HEX, isi_ss_ussd_type, 0x0, "USSD Type", HFILL }},
		{ &hf_isi_ss_subblock_count,
		  { "Subblock Count", "isi.ss.subblock_count", FT_UINT8, BASE_DEC, NULL, 0x0, "Subblock Count", HFILL }},
		{ &hf_isi_ss_subblock,
		  { "Subblock", "isi.ss.subblock", FT_UINT8, BASE_HEX, isi_ss_subblock, 0x0, "Subblock", HFILL }},
		{ &hf_isi_ss_operation,
		  { "Operation", "isi.ss.operation", FT_UINT8, BASE_HEX, isi_ss_operation, 0x0, "Operation", HFILL }},
		{ &hf_isi_ss_service_code,
		  { "Service Code", "isi.ss.service_code", FT_UINT8, BASE_HEX, isi_ss_service_code, 0x0, "Service Code", HFILL }},
		{ &hf_isi_ss_status_indication,
		  { "Status Indication", "isi.ss.status_indication", FT_UINT8, BASE_HEX, isi_ss_status_indication, 0x0, "Status Indication", HFILL }},
		{ &hf_isi_ss_ussd_length,
		  { "Length", "isi.ss.ussd.length", FT_UINT8, BASE_DEC, NULL, 0x0, "Length", HFILL }},
		{ &hf_isi_ss_common_message_id,
		  { "Common Message ID", "isi.ss.common.msg_id", FT_UINT8, BASE_HEX, isi_ss_common_message_id, 0x0, "Common Message ID", HFILL }},
	};

	proto_register_field_array(proto_isi, hf, array_length(hf));
	register_dissector("isi.ss", dissect_isi_ss, proto_isi);
}

static void dissect_isi_ss(tvbuff_t *tvb, packet_info *pinfo, proto_item *isitree) {
	proto_item *item = NULL;
	proto_tree *tree = NULL;
	guint8 cmd, code;

	if(isitree) {
		item = proto_tree_add_text(isitree, tvb, 0, -1, "Payload");
		tree = proto_item_add_subtree(item, ett_isi_msg);

		proto_tree_add_item(tree, hf_isi_ss_message_id, tvb, 0, 1, FALSE);
		cmd = tvb_get_guint8(tvb, 0);

		switch(cmd) {
			case 0x00: /* SS_SERVICE_REQ */
				proto_tree_add_item(tree, hf_isi_ss_operation, tvb, 1, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_service_code, tvb, 2, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x05:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Request: Interrogation");
						break;
					case 0x06:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Request: GSM Password Registration");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Request");
						break;
				}
				break;

			case 0x01: /* SS_SERVICE_COMPLETED_RESP */
				proto_tree_add_item(tree, hf_isi_ss_operation, tvb, 1, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_service_code, tvb, 2, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x05:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Completed Response: Interrogation");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Completed Response");
						break;
				}
				break;

			case 0x02: /* SS_SERVICE_FAILED_RESP */
				//proto_tree_add_item(tree, hf_isi_ss_service_type, tvb, 1, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					//case 0x2F:
					//	col_set_str(pinfo->cinfo, COL_INFO, "Network Information Request: Read Home PLMN");
					//	break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Failed Response");
						break;
				}
				break;

			case 0x04: /* SS_GSM_USSD_SEND_REQ */
				proto_tree_add_item(tree, hf_isi_ss_ussd_type, tvb, 1, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_subblock_count, tvb, 2, 1, FALSE);

				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x02: //SS_GSM_USSD_COMMAND
						proto_tree_add_item(tree, hf_isi_ss_subblock, tvb, 3, 1, FALSE);
						col_set_str(pinfo->cinfo, COL_INFO, "GSM USSD Send Command Request");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "GSM USSD Message Send Request");
						break;
				}
				break;

			case 0x05: /* SS_GSM_USSD_SEND_RESP */
				//proto_tree_add_item(tree, hf_isi_ss_service_type, tvb, 1, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					//case 0x2F:
					//	col_set_str(pinfo->cinfo, COL_INFO, "Network Information Request: Read Home PLMN");
					//	break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "GSM USSD Message Send Response");
						break;
				}
				break;

			case 0x06: /* SS_GSM_USSD_RECEIVE_IND */
			  //An unknown Encoding Information byte precedes - see 3GPP TS 23.038 chapter 5
				proto_tree_add_item(tree, hf_isi_ss_ussd_type, tvb, 2, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_ussd_length, tvb, 3, 1, FALSE);

				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x04:



						col_set_str(pinfo->cinfo, COL_INFO, "GSM USSD Message Received Notification");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "GSM USSD Message Received Indication");
						break;
				}
				break;

			case 0x09: /* SS_STATUS_IND */
				proto_tree_add_item(tree, hf_isi_ss_status_indication, tvb, 1, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_subblock_count, tvb, 2, 1, FALSE);
				//proto_tree_add_item(tree, hf_isi_ss_subblock, tvb, 3, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x00:
						col_set_str(pinfo->cinfo, COL_INFO, "Status Indication: Request Service Start");
						break;
					case 0x01:
						col_set_str(pinfo->cinfo, COL_INFO, "Status Indication: Request Service Stop");
						break;
					case 0x02:
						col_set_str(pinfo->cinfo, COL_INFO, "Status Indication: Request USSD Start");
						break;
					case 0x03:
						col_set_str(pinfo->cinfo, COL_INFO, "Status Indication: Request USSD Stop");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "Status Indication");
						break;
				}
				break;

			case 0x10: /* SS_SERVICE_COMPLETED_IND */
				proto_tree_add_item(tree, hf_isi_ss_operation, tvb, 1, 1, FALSE);
				proto_tree_add_item(tree, hf_isi_ss_service_code, tvb, 2, 1, FALSE);
				code = tvb_get_guint8(tvb, 1);
				switch(code) {
					case 0x05:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Completed Indication: Interrogation");
						break;
					default:
						col_set_str(pinfo->cinfo, COL_INFO, "Service Completed Indication");
						break;
				}
				break;

			case 0xF0: /* COMMON_MESSAGE */
				dissect_isi_common("Subscriber Service", tvb, pinfo, tree);
				break;


			default:
				col_set_str(pinfo->cinfo, COL_INFO, "Unknown type");
				break;
		}
	}
}