MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-wap.c
blob36456a75adb892b888188bdd1508e0ced2d18959
1 /* packet-wap.c
3 * Utility routines for WAP dissectors
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "config.h"
32 #include <glib.h>
33 #include <epan/packet.h>
34 #include "packet-wap.h"
37 * Accessor to retrieve variable length int as used in WAP protocol.
38 * The value is encoded in the lower 7 bits. If the top bit is set, then the
39 * value continues into the next byte.
40 * The octetCount parameter holds the number of bytes read in order to return
41 * the final value. Can be pre-initialised to start at offset+count.
43 guint
44 tvb_get_guintvar (tvbuff_t *tvb, guint offset, guint *octetCount)
46 guint value = 0;
47 guint octet;
48 guint counter = 0;
49 char cont = 1;
51 #ifdef DEBUG
52 if (octetCount != NULL)
54 fprintf (stderr, "dissect_wap: Starting tvb_get_guintvar at offset %d, count=%d\n", offset, *octetCount);
55 /* counter = *octetCount; */
57 else
59 fprintf (stderr, "dissect_wap: Starting tvb_get_guintvar at offset %d, count=NULL\n", offset);
61 #endif
63 while (cont != 0)
65 value <<= 7; /* Value only exists in 7 of the 8 bits */
66 octet = tvb_get_guint8 (tvb, offset+counter);
67 counter += 1;
68 value += (octet & 0x7F);
69 cont = (octet & 0x80);
70 #ifdef DEBUG
71 fprintf (stderr, "dissect_wap: computing: octet is %d (0x%02x), count=%d, value=%d, cont=%d\n",
72 octet, octet, counter, value, cont);
73 #endif
76 if (octetCount != NULL)
78 *octetCount = counter;
79 #ifdef DEBUG
80 fprintf (stderr, "dissect_wap: Leaving tvb_get_guintvar count=%d, value=%u\n", *octetCount, value);
81 #endif
84 return (value);
87 /* See http://www.iana.org/assignments/character-sets for the MIBenum mapping */
88 /* Updated from 10/04/2012 version */
89 static const value_string wap_mib_enum_vals_character_sets[] = {
90 { 0, "*" },
91 { 3, "US-ASCII" },
92 { 4, "ISO-8859-1" },
93 { 5, "ISO-8859-2" },
94 { 6, "ISO-8859-3" },
95 { 7, "ISO-8859-4" },
96 { 8, "ISO-8859-5" },
97 { 9, "ISO-8859-6" },
98 { 10, "ISO-8859-7" },
99 { 11, "ISO-8859-8" },
100 { 12, "ISO-8859-9" },
101 { 13, "ISO-8859-10" },
102 { 14, "ISO_6937-2-add" },
103 { 15, "JIS_X0201" },
104 { 16, "JIS_Encoding" },
105 { 17, "Shift_JIS" },
106 { 18, "EUC-JP" },
107 { 19, "Extended_UNIX_Code_Fixed_Width_for_Japanese" },
108 { 20, "BS_4730" },
109 { 21, "SEN_850200_C" },
110 { 22, "IT" },
111 { 23, "ES" },
112 { 24, "DIN_66003" },
113 { 25, "NS_4551-1" },
114 { 26, "NF_Z_62-010" },
115 { 27, "ISO-10646-UTF-1" },
116 { 28, "ISO_646.basic:1983" },
117 { 29, "INVARIANT" },
118 { 30, "ISO_646.irv:1983" },
119 { 31, "NATS-SEFI" },
120 { 32, "NATS-SEFI-ADD" },
121 { 33, "NATS-DANO" },
122 { 34, "NATS-DANO-ADD" },
123 { 35, "SEN_850200_B" },
124 { 36, "KS_C_5601-1987" },
125 { 37, "ISO-2022-KR" },
126 { 38, "EUC-KR" },
127 { 39, "ISO-2022-JP" },
128 { 40, "ISO-2022-JP-2" },
129 { 41, "JIS_C6220-1969-jp" },
130 { 42, "JIS_C6220-1969-ro" },
131 { 43, "PT" },
132 { 44, "greek7-old" },
133 { 45, "latin-greek" },
134 { 46, "NF_Z_62-010_(1973)" },
135 { 47, "Latin-greek-1" },
136 { 48, "ISO_5427" },
137 { 49, "JIS_C6226-1978" },
138 { 50, "BS_viewdata" },
139 { 51, "INIS" },
140 { 52, "INIS-8" },
141 { 53, "INIS-cyrillic" },
142 { 54, "ISO_5427:1981" },
143 { 55, "ISO_5428:1980" },
144 { 56, "GB_1988-80" },
145 { 57, "GB_2312-80" },
146 { 58, "NS_4551-2" },
147 { 59, "videotex-suppl" },
148 { 60, "PT2" },
149 { 61, "ES2" },
150 { 62, "MSZ_7795.3" },
151 { 63, "JIS_C6226-1983" },
152 { 64, "greek7" },
153 { 65, "ASMO_449" },
154 { 66, "iso-ir-90" },
155 { 67, "JIS_C6229-1984-a" },
156 { 68, "JIS_C6229-1984-b" },
157 { 69, "JIS_C6229-1984-b-add" },
158 { 70, "JIS_C6229-1984-hand" },
159 { 71, "JIS_C6229-1984-hand-add" },
160 { 72, "JIS_C6229-1984-kana" },
161 { 73, "ISO_2033-1983" },
162 { 74, "ANSI_X3.110-1983" },
163 { 75, "T.61-7bit" },
164 { 76, "T.61-8bit" },
165 { 77, "ECMA-cyrillic" },
166 { 78, "CSA_Z243.4-1985-1" },
167 { 79, "CSA_Z243.4-1985-2" },
168 { 80, "CSA_Z243.4-1985-gr" },
169 { 81, "ISO-8859-6-E" },
170 { 82, "ISO-8859-6-I" },
171 { 83, "T.101-G2" },
172 { 84, "ISO-8859-8-E" },
173 { 85, "ISO-8859-8-I" },
174 { 86, "CSN_369103" },
175 { 87, "JUS_I.B1.002" },
176 { 88, "IEC_P27-1" },
177 { 89, "JUS_I.B1.003-serb" },
178 { 90, "JUS_I.B1.003-mac" },
179 { 91, "greek-ccitt" },
180 { 92, "NC_NC00-10:81" },
181 { 93, "ISO_6937-2-25" },
182 { 94, "GOST_19768-74" },
183 { 95, "ISO_8859-supp" },
184 { 96, "ISO_10367-box" },
185 { 97, "latin-lap" },
186 { 98, "JIS_X0212-1990" },
187 { 99, "DS_2089" },
188 { 100, "us-dk" },
189 { 101, "dk-us" },
190 { 102, "KSC5636" },
191 { 103, "UNICODE-1-1-UTF-7" },
192 { 104, "ISO-2022-CN" },
193 { 105, "ISO-2022-CN-EXT" },
194 { 106, "UTF-8" },
195 { 109, "ISO-8859-13" },
196 { 110, "ISO-8859-14" },
197 { 111, "ISO-8859-15" },
198 { 112, "ISO-8859-16" },
199 { 113, "GBK" },
200 { 114, "GB18030" },
201 { 115, "OSD_EBCDIC_DF04_15" },
202 { 116, "OSD_EBCDIC_DF03_IRV" },
203 { 117, "OSD_EBCDIC_DF04_1" },
204 { 118, "ISO-11548-1" },
205 { 119, "KZ-1048" },
207 { 1000, "ISO-10646-UCS-2" },
208 { 1001, "ISO-10646-UCS-4" },
209 { 1002, "ISO-10646-UCS-Basic" },
210 { 1003, "ISO-10646-Unicode-Latin1" },
211 { 1004, "ISO-10646-J-1" },
212 { 1005, "ISO-Unicode-IBM-1261" },
213 { 1006, "ISO-Unicode-IBM-1268" },
214 { 1007, "ISO-Unicode-IBM-1276" },
215 { 1008, "ISO-Unicode-IBM-1264" },
216 { 1009, "ISO-Unicode-IBM-1265" },
217 { 1010, "UNICODE-1-1" },
218 { 1011, "SCSU" },
219 { 1012, "UTF-7" },
220 { 1013, "UTF-16BE" },
221 { 1014, "UTF-16LE" },
222 { 1015, "UTF-16" },
223 { 1016, "CESU-8" },
224 { 1017, "UTF-32" },
225 { 1018, "UTF-32BE" },
226 { 1019, "UTF-32LE" },
227 { 1020, "BOCU-1" },
229 { 2000, "ISO-8859-1-Windows-3.0-Latin-1" },
230 { 2001, "ISO-8859-1-Windows-3.1-Latin-1" },
231 { 2002, "ISO-8859-2-Windows-Latin-2" },
232 { 2003, "ISO-8859-9-Windows-Latin-5" },
233 { 2004, "hp-roman8" },
234 { 2005, "Adobe-Standard-Encoding" },
235 { 2006, "Ventura-US" },
236 { 2007, "Ventura-International" },
237 { 2008, "DEC-MCS" },
238 { 2009, "IBM850" },
239 { 2010, "IBM852" },
240 { 2011, "IBM437" },
241 { 2012, "PC8-Danish-Norwegian" },
242 { 2013, "IBM862" },
243 { 2014, "PC8-Turkish" },
244 { 2015, "IBM-Symbols" },
245 { 2016, "IBM-Thai" },
246 { 2017, "HP-Legal" },
247 { 2018, "HP-Pi-font" },
248 { 2019, "HP-Math8" },
249 { 2020, "Adobe-Symbol-Encoding" },
250 { 2021, "HP-DeskTop" },
251 { 2022, "Ventura-Math" },
252 { 2023, "Microsoft-Publishing" },
253 { 2024, "Windows-31J" },
254 { 2025, "GB2312" },
255 { 2026, "Big5" },
256 { 2027, "macintosh" },
257 { 2028, "IBM037" },
258 { 2029, "IBM038" },
259 { 2030, "IBM273" },
260 { 2031, "IBM274" },
261 { 2032, "IBM275" },
262 { 2033, "IBM277" },
263 { 2034, "IBM278" },
264 { 2035, "IBM280" },
265 { 2036, "IBM281" },
266 { 2037, "IBM284" },
267 { 2038, "IBM285" },
268 { 2039, "IBM290" },
269 { 2040, "IBM297" },
270 { 2041, "IBM420" },
271 { 2042, "IBM423" },
272 { 2043, "IBM424" },
273 { 2044, "IBM500" },
274 { 2045, "IBM851" },
275 { 2046, "IBM855" },
276 { 2047, "IBM857" },
277 { 2048, "IBM860" },
278 { 2049, "IBM861" },
279 { 2050, "IBM863" },
280 { 2051, "IBM864" },
281 { 2052, "IBM865" },
282 { 2053, "IBM868" },
283 { 2054, "IBM869" },
284 { 2055, "IBM870" },
285 { 2056, "IBM871" },
286 { 2057, "IBM880" },
287 { 2058, "IBM891" },
288 { 2059, "IBM903" },
289 { 2060, "IBM904" },
290 { 2061, "IBM905" },
291 { 2062, "IBM918" },
292 { 2063, "IBM1026" },
293 { 2064, "EBCDIC-AT-DE" },
294 { 2065, "EBCDIC-AT-DE-A" },
295 { 2066, "EBCDIC-CA-FR" },
296 { 2067, "EBCDIC-DK-NO" },
297 { 2068, "EBCDIC-DK-NO-A" },
298 { 2069, "EBCDIC-FI-SE" },
299 { 2070, "EBCDIC-FI-SE-A" },
300 { 2071, "EBCDIC-FR" },
301 { 2072, "EBCDIC-IT" },
302 { 2073, "EBCDIC-PT" },
303 { 2074, "EBCDIC-ES" },
304 { 2075, "EBCDIC-ES-A" },
305 { 2076, "EBCDIC-ES-S" },
306 { 2077, "EBCDIC-UK" },
307 { 2078, "EBCDIC-US" },
308 { 2079, "UNKNOWN-8BIT" },
309 { 2080, "MNEMONIC" },
310 { 2081, "MNEM" },
311 { 2082, "VISCII" },
312 { 2083, "VIQR" },
313 { 2084, "KOI8-R" },
314 { 2085, "HZ-GB-2312" },
315 { 2086, "IBM866" },
316 { 2087, "IBM775" },
317 { 2088, "KOI8-U" },
318 { 2089, "IBM00858" },
319 { 2090, "IBM00924" },
320 { 2091, "IBM01140" },
321 { 2092, "IBM01141" },
322 { 2093, "IBM01142" },
323 { 2094, "IBM01143" },
324 { 2095, "IBM01144" },
325 { 2096, "IBM01145" },
326 { 2097, "IBM01146" },
327 { 2098, "IBM01147" },
328 { 2099, "IBM01148" },
329 { 2100, "IBM01149" },
330 { 2101, "Big5-HKSCS" },
331 { 2102, "IBM1047" },
332 { 2103, "PTCP154" },
333 { 2104, "Amiga-1251" },
334 { 2105, "KOI7-switched" },
335 { 2106, "BRF" },
336 { 2107, "TSCII" },
337 { 2108, "CP51932" },
338 { 2109, "windows-874" },
340 { 2250, "windows-1250" },
341 { 2251, "windows-1251" },
342 { 2252, "windows-1252" },
343 { 2253, "windows-1253" },
344 { 2254, "windows-1254" },
345 { 2255, "windows-1255" },
346 { 2256, "windows-1256" },
347 { 2257, "windows-1257" },
348 { 2258, "windows-1258" },
349 { 2259, "TIS-620" },
350 { 2260, "CP50220" },
351 { 0, NULL }
353 value_string_ext wap_mib_enum_vals_character_sets_ext = VALUE_STRING_EXT_INIT(wap_mib_enum_vals_character_sets);