summaryrefslogtreecommitdiff
path: root/gssm/src/lib/rr_decode.cc
blob: 312c883cccd458a8c4b9c251aff5fd24b74b52da (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
// $Id: rr_decode.cc,v 1.1.1.1 2007-06-01 04:26:57 jl Exp $

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static char *pd_string(unsigned char pd) {

	switch(pd) {
		case 0:
			return "group call control";
		case 1:
			return "broadcast call control";
		case 2:
			return "reserved (PDSS1 in earlier phases)";
		case 3:
			return "call control; call related SS messages";
		case 4:
			return "GPRS Transparent Transport Protocol (GTTP)";
		case 5:
			return "mobility management messages";
		case 6:
			return "radio resources management messages";
		case 8:
			return "GPRS mobility management messages";
		case 9:
			return "SMS messages";
		case 10:
			return "GPRS session management messages";
		case 11:
			return "non-call related SS messages";
		case 12:
			return "location services";
		case 14:
			return "reserved for extension of the PD";
		case 15:
			return "reserved for tests procedures";
		default:
			return "unknown PD";
	}
}


static char *message_type_rrm_string(unsigned char mt) {

	switch(mt) {
		case 0x3c:
			return "channel establishment message: RR "
			   "initialization request";
		case 0x3b:
			return "channel establishment message: aditional "
			   "assignment";
		case 0x3f:
			return "channel establishment message: immediate "
			   "assignment";
		case 0x39:
			return "channel establishment message: immediate "
			   "assignment extended";
		case 0x3a:
			return "channel establishment message: immediate "
			   "assignment reject";

		case 0x35:
			return "ciphering message: ciphering mode command";
		case 0x32:
			return "ciphering message: ciphering mode complete";

		case 0x30:
			return "configuration change message: configuration "
			   "change command";
		case 0x31:
			return "configuration change message: configuration "
			   "change acknowledgement";
		case 0x33:
			return "configuration change message: configuration "
			   "change reject";

		case 0x2e:
			return "handover message: assignment command";
		case 0x29:
			return "handover message: assignment complete";
		case 0x2f:
			return "handover message: assignment failure";
		case 0x2b:
			return "handover message: handover command";
		case 0x2c:
			return "handover message: handover complete";
		case 0x28:
			return "handover message: handover failure";
		case 0x2d:
			return "handover message: physical information";

		case 0x08:
			return "RR-cell change order";

		case 0x23:
			return "PDCH assignment command";

		case 0x0d:
			return "channel release message: channel release";
		case 0x0a:
			return "channel release message: partial release";
		case 0x0f:
			return "channel release message: partial release "
			   "complete";

		case 0x21:
			return "paging and notification message: paging "
			   "request type 1";
		case 0x22:
			return "paging and notification message: paging "
			   "request type 2";
		case 0x24:
			return "paging and notification message: paging "
			   "request type 3";
		case 0x27:
			return "paging and notification message: paging "
			   "response";
		case 0x20:
			return "paging and notification message: "
			   "notification / NCH";
		case 0x25:
			return "paging and notification message: "
			   "notification / FACCH";
		case 0x26:
			return "paging and notification message: "
			   "notification response";

		case 0x0b:
			return "reserved";

		case 0x18:
			return "system information message: type 8";
		case 0x19:
			return "system information message: type 1";
		case 0x1a:
			return "system information message: type 2";
		case 0x1b:
			return "system information message: type 3";
		case 0x1c:
			return "system information message: type 4";
		case 0x1d:
			return "system information message: type 5";
		case 0x1e:
			return "system information message: type 6";
		case 0x1f:
			return "system information message: type 7";
		case 0x02:
			return "system information message: type 2bis";
		case 0x03:
			return "system information message: type 2ter";
		case 0x05:
			return "system information message: type 5bis";
		case 0x06:
			return "system information message: type 5ter";
		case 0x04:
			return "system information message: type 9";
		case 0x00:
			return "system information message: type 13";
		case 0x3d:
			return "system information message: type 16";
		case 0x3e:
			return "system information message: type 17";

		case 0x10:
			return "miscellaneous message: channel mode modify";
		case 0x12:
			return "miscellaneous message: RR status";
		case 0x17:
			return "miscellaneous message: channel mode modify "
			   "acknowledge";
		case 0x14:
			return "miscellaneous message: frequency redefinition";
		case 0x15:
			return "miscellaneous message: measurement report";
		case 0x16:
			return "miscellaneous message: classmark change";
		case 0x13:
			return "miscellaneous message: classmark enquiry";
		case 0x36:
			return "miscellaneous message: extended measurement "
			   "report";
		case 0x37:
			return "miscellaneous message: extended measurement "
			   "order";
		case 0x34:
			return "miscellaneous message: GPRS suspension request";

		case 0x09:
			return "VGCS uplink control message: uplink grant";
		case 0x0e:
			return "VGCS uplink control message: uplink release";
		case 0x0c:
			return "VGCS uplink control message: uplink free";
		case 0x2a:
			return "VGCS uplink control message: uplink busy";
		case 0x11:
			return "VGCS uplink control message: talker indication";

		case 0x38:
			return "application message: application information";

		default:
			return "unknown radio resource management message "
			   "type";
	}
}


void display_l3(unsigned char *buf, unsigned int buflen) {

	printf("(%d) PD: %s: (%2.2x) %s\n", buflen, pd_string(buf[0] & 0xf),
	   buf[1], message_type_rrm_string(buf[1]));
}


void display_ns_l3(unsigned char *data, unsigned int datalen) {

        int len;

	// bit 1 == 1, bit 2 == 0
	if((data[0] & 3) != 1) {
		fprintf(stderr, "error: display_ns_l3: pseudo-length reserved "
		   "bits bad (%2.2x)\n", data[0] & 3);
		return;
	}
        len = data[0] >> 2;
	if(datalen < len) {
		fprintf(stderr, "error: display_ns_l3: bad data length "
		   "(%d < %d)\n", datalen, len);
		return;
	}

	printf("L3 length: %d\n", len);
	display_l3(data + 1, datalen - 1);
}
personal git repositories of Harald Welte. Your mileage may vary