3 * Utility routines for WAP dissectors
5 * $Id: packet-wap.c,v 1.7 2002/08/28 21:00:37 jmayer Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * WAP dissector based on original work by Ben Fowler
12 * Updated by Neil Hunter <neil.hunter@energis-squared.com>
13 * WTLS support by Alexandre P. Ferreira (Splice IP)
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include <epan/packet.h>
36 #include "packet-wap.h"
39 * Accessor to retrieve variable length int as used in WAP protocol.
40 * The value is encoded in the lower 7 bits. If the top bit is set, then the
41 * value continues into the next byte.
42 * The octetCount parameter holds the number of bytes read in order to return
43 * the final value. Can be pre-initialised to start at offset+count.
46 tvb_get_guintvar (tvbuff_t *tvb, guint offset, guint *octetCount)
53 if (octetCount != NULL)
56 fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=NULL\n", offset);
58 /* counter = *octetCount; */
63 fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=%d\n", offset, *octetCount);
69 value<<=7; /* Value only exists in 7 of the 8 bits */
70 octet = tvb_get_guint8 (tvb, offset+counter);
72 value += (octet & 0x7F);
73 cont = (octet & 0x80);
75 fprintf (stderr, "dissect_wsp: octet is %d (0x%02x), count=%d, value=%d, cont=%d\n", octet, octet, counter, value, cont);
79 if (octetCount != NULL)
81 *octetCount = counter;
83 fprintf (stderr, "dissect_wsp: Leaving tvb_get_guintvar count=%d\n", *octetCount);
90 const value_string vals_character_sets[] = {
91 { 0x0000, "hz-gb-2312" },
92 { 0x0003, "us-ascii" },
93 { 0x0004, "iso-8859-1" },
94 { 0x0005, "iso-8859-2" },
95 { 0x0006, "iso-8859-3" },
96 { 0x0007, "iso-8859-4" },
97 { 0x0008, "iso-8859-5" },
98 { 0x0009, "iso-8859-6" },
99 { 0x000A, "iso-8859-7" },
100 { 0x000B, "iso-8859-8" },
101 { 0x000C, "iso-8859-9" },
102 { 0x000D, "iso-8859-10" },
103 { 0x000E, "iso_6937-2-add" },
104 { 0x000F, "jis_x0201" },
105 { 0x0010, "jis_encoding" },
106 { 0x0011, "shift_jis" },
107 { 0x0012, "euc-jp" },
108 { 0x0013, "extended_unix_code_fixed_width_for_japanese" },
109 { 0x0014, "bs_4730" },
110 { 0x0015, "sen_850200_c" },
113 { 0x0018, "din_66003" },
114 { 0x0019, "ns_4551-1" },
115 { 0x001A, "nf_z_62-010" },
116 { 0x001B, "iso-10646-utf-1" },
117 { 0x001C, "iso_646.basic:1983" },
118 { 0x001D, "invariant" },
119 { 0x001E, "iso_646.irv:1983" },
120 { 0x001F, "nats-sefi" },
121 { 0x0020, "nats-sefi-add" },
122 { 0x0021, "nats-dano" },
123 { 0x0022, "nats-dano-add" },
124 { 0x0023, "sen_850200_b" },
125 { 0x0024, "ks_c_5601-1987" },
126 { 0x0025, "iso-2022-kr" },
127 { 0x0026, "euc-kr" },
128 { 0x0027, "iso-2022-jp" },
129 { 0x0028, "iso-2022-jp-2" },
130 { 0x0029, "jis_c6220-1969-jp" },
131 { 0x002A, "jis_c6220-1969-ro" },
133 { 0x002C, "greek7-old" },
134 { 0x002D, "latin-greek" },
135 { 0x002E, "nf_z_62-010_(1973)" },
136 { 0x002F, "latin-greek-1" },
137 { 0x0030, "iso_5427" },
138 { 0x0031, "jis_c6226-1978" },
139 { 0x0032, "bs_viewdata" },
141 { 0x0034, "inis-8" },
142 { 0x0035, "inis-cyrillic" },
143 { 0x0036, "iso_5427:1981" },
144 { 0x0037, "iso_5428:1980" },
145 { 0x0038, "gb_1988-80" },
146 { 0x0039, "gb_2312-80" },
147 { 0x003A, "ns_4551-2" },
148 { 0x003B, "videotex-suppl" },
151 { 0x003E, "msz_7795.3" },
152 { 0x003F, "jis_c6226-1983" },
153 { 0x0040, "greek7" },
154 { 0x0041, "asmo_449" },
155 { 0x0042, "iso-ir-90" },
156 { 0x0043, "jis_c6229-1984-a" },
157 { 0x0044, "jis_c6229-1984-b" },
158 { 0x0045, "jis_c6229-1984-b-add" },
159 { 0x0046, "jis_c6229-1984-hand" },
160 { 0x0047, "jis_c6229-1984-hand-add" },
161 { 0x0048, "jis_c6229-1984-kana" },
162 { 0x0049, "iso_2033-1983" },
163 { 0x004A, "ansi_x3.110-1983" },
164 { 0x004B, "t.61-7bit" },
165 { 0x004C, "t.61-8bit" },
166 { 0x004D, "ecma-cyrillic" },
167 { 0x004E, "csa_z243.4-1985-1" },
168 { 0x004F, "csa_z243.4-1985-2" },
169 { 0x0050, "csa_z243.4-1985-gr" },
170 { 0x0051, "iso_8859-6-e" },
171 { 0x0052, "iso_8859-6-i" },
172 { 0x0053, "t.101-g2" },
173 { 0x0054, "iso_8859-8-e" },
174 { 0x0055, "iso_8859-8-i" },
175 { 0x0056, "csn_369103" },
176 { 0x0057, "jus_i.b1.002" },
177 { 0x0058, "iec_p27-1" },
178 { 0x0059, "jus_i.b1.003-serb" },
179 { 0x005A, "jus_i.b1.003-mac" },
180 { 0x005B, "greek-ccitt" },
181 { 0x005C, "nc_nc00-10:81" },
182 { 0x005D, "iso_6937-2-25" },
183 { 0x005E, "gost_19768-74" },
184 { 0x005F, "iso_8859-supp" },
185 { 0x0060, "iso_10367-box" },
186 { 0x0061, "latin-lap" },
187 { 0x0062, "jis_x0212-1990" },
188 { 0x0063, "ds_2089" },
191 { 0x0066, "ksc5636" },
192 { 0x0067, "unicode-1-1-utf-7" },
193 { 0x0068, "iso-2022-cn" },
194 { 0x0069, "iso-2022-cn-ext" },
196 { 0x006D, "iso-8859-13" },
197 { 0x006E, "iso-8859-14" },
198 { 0x006F, "iso-8859-15" },
199 { 0x03E8, "iso-10646-ucs-2" },
200 { 0x03E9, "iso-10646-ucs-4" },
201 { 0x03EA, "iso-10646-ucs-basic" },
202 { 0x03EB, "iso-10646-j-1" },
203 { 0x03EB, "iso-10646-unicode-latin1" },
204 { 0x03ED, "iso-unicode-ibm-1261" },
205 { 0x03EE, "iso-unicode-ibm-1268" },
206 { 0x03EF, "iso-unicode-ibm-1276" },
207 { 0x03F0, "iso-unicode-ibm-1264" },
208 { 0x03F1, "iso-unicode-ibm-1265" },
209 { 0x03F2, "unicode-1-1" },
212 { 0x03F5, "utf-16be" },
213 { 0x03F6, "utf-16le" },
214 { 0x03F7, "utf-16" },
215 { 0x07D0, "iso-8859-1-windows-3.0-latin-1" },
216 { 0x07D1, "iso-8859-1-windows-3.1-latin-1" },
217 { 0x07D2, "iso-8859-2-windows-latin-2" },
218 { 0x07D3, "iso-8859-9-windows-latin-5" },
219 { 0x07D4, "hp-roman8" },
220 { 0x07D5, "adobe-standard-encoding" },
221 { 0x07D6, "ventura-us" },
222 { 0x07D7, "ventura-international" },
223 { 0x07D8, "dec-mcs" },
224 { 0x07D9, "ibm850" },
225 { 0x07DA, "ibm852" },
226 { 0x07DB, "ibm437" },
227 { 0x07DC, "pc8-danish-norwegian" },
228 { 0x07DD, "ibm862" },
229 { 0x07DE, "pc8-turkish" },
230 { 0x07DF, "ibm-symbols" },
231 { 0x07E0, "ibm-thai" },
232 { 0x07E1, "hp-legal" },
233 { 0x07E2, "hp-pi-font" },
234 { 0x07E3, "hp-math8" },
235 { 0x07E4, "adobe-symbol-encoding" },
236 { 0x07E5, "hp-desktop" },
237 { 0x07E6, "ventura-math" },
238 { 0x07E7, "microsoft-publishing" },
239 { 0x07E8, "windows-31j" },
240 { 0x07E9, "gb2312" },
242 { 0x07EB, "macintosh" },
243 { 0x07EC, "ibm037" },
244 { 0x07ED, "ibm038" },
245 { 0x07EE, "ibm273" },
246 { 0x07EF, "ibm274" },
247 { 0x07F0, "ibm275" },
248 { 0x07F1, "ibm277" },
249 { 0x07F2, "ibm278" },
250 { 0x07F3, "ibm280" },
251 { 0x07F4, "ibm281" },
252 { 0x07F5, "ibm284" },
253 { 0x07F6, "ibm285" },
254 { 0x07F7, "ibm290" },
255 { 0x07F8, "ibm297" },
256 { 0x07F9, "ibm420" },
257 { 0x07FA, "ibm423" },
258 { 0x07FB, "ibm424" },
259 { 0x07FC, "ibm500" },
260 { 0x07FD, "ibm851" },
261 { 0x07FE, "ibm855" },
262 { 0x07FF, "ibm857" },
263 { 0x0800, "ibm860" },
264 { 0x0801, "ibm861" },
265 { 0x0802, "ibm863" },
266 { 0x0803, "ibm864" },
267 { 0x0804, "ibm865" },
268 { 0x0805, "ibm868" },
269 { 0x0806, "ibm869" },
270 { 0x0807, "ibm870" },
271 { 0x0808, "ibm871" },
272 { 0x0809, "ibm880" },
273 { 0x080A, "ibm891" },
274 { 0x080B, "ibm903" },
275 { 0x080C, "ibm904" },
276 { 0x080D, "ibm905" },
277 { 0x080E, "ibm918" },
278 { 0x080F, "ibm1026" },
279 { 0x0810, "ebcdic-at-de" },
280 { 0x0811, "ebcdic-at-de-a" },
281 { 0x0812, "ebcdic-ca-fr" },
282 { 0x0813, "ebcdic-dk-no" },
283 { 0x0814, "ebcdic-dk-no-a" },
284 { 0x0815, "ebcdic-fi-se" },
285 { 0x0816, "ebcdic-fi-se-a" },
286 { 0x0817, "ebcdic-fr" },
287 { 0x0818, "ebcdic-it" },
288 { 0x0819, "ebcdic-pt" },
289 { 0x081A, "ebcdic-es" },
290 { 0x081B, "ebcdic-es-a" },
291 { 0x081C, "ebcdic-es-s" },
292 { 0x081D, "ebcdic-uk" },
293 { 0x081E, "ebcdic-us" },
294 { 0x081F, "unknown-8bit" },
295 { 0x0820, "mnemonic" },
297 { 0x0822, "viscii" },
299 { 0x0824, "koi8-r" },
300 { 0x0826, "ibm866" },
301 { 0x0827, "ibm775" },
302 { 0x0828, "koi8-u" },
303 { 0x0829, "ibm00858" },
304 { 0x082A, "ibm00924" },
305 { 0x082B, "ibm01140" },
306 { 0x082C, "ibm01141" },
307 { 0x082D, "ibm01142" },
308 { 0x082E, "ibm01143" },
309 { 0x082F, "ibm01144" },
310 { 0x0830, "ibm01145" },
311 { 0x0831, "ibm01146" },
312 { 0x0832, "ibm01147" },
313 { 0x0833, "ibm01148" },
314 { 0x0834, "ibm01149" },
315 { 0x0835, "big5-hkscs" },
316 { 0x08CA, "windows-1250" },
317 { 0x08CB, "windows-1251" },
318 { 0x08CC, "windows-1252" },
319 { 0x08CD, "windows-1253" },
320 { 0x08CE, "windows-1254" },
321 { 0x08CF, "windows-1255" },
322 { 0x08D0, "windows-1256" },
323 { 0x08D1, "windows-1257" },
324 { 0x08D2, "windows-1258" },
325 { 0x08D3, "tis-620" },
326 { 0x0080, "Any" }, /* Special Case */