aboutsummaryrefslogtreecommitdiffstats
path: root/packet-wsp.c
blob: 7e215bb709b2c777689e5f0da2d114d3e0673112 (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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
/* packet-wsp.c
 *
 * Routines to dissect WSP component of WAP traffic.
 *
 * $Id: packet-wsp.c,v 1.73 2003/07/29 21:30:32 guy Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1998 Gerald Combs
 *
 * WAP dissector based on original work by Ben Fowler
 * Updated by Neil Hunter <neil.hunter@energis-squared.com>
 * WTLS support by Alexandre P. Ferreira (Splice IP)
 * Openwave header support by Dermot Bradley <dermot.bradley@openwave.com>
 *
 * 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.
 */

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

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

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif

#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/ipv6-utils.h>
#include <epan/conversation.h>
#include "packet-wap.h"
#include "packet-wsp.h"

/* File scoped variables for the protocol and registered fields */
static int proto_wsp 					= HF_EMPTY;

/* These fields used by fixed part of header */
static int hf_wsp_header_tid				= HF_EMPTY;
static int hf_wsp_header_pdu_type			= HF_EMPTY;
static int hf_wsp_version_major				= HF_EMPTY;
static int hf_wsp_version_minor				= HF_EMPTY;
static int hf_wsp_capability_length			= HF_EMPTY;
static int hf_wsp_capabilities_section			= HF_EMPTY;
static int hf_wsp_capabilities_client_SDU		= HF_EMPTY;
static int hf_wsp_capabilities_server_SDU		= HF_EMPTY;
static int hf_wsp_capabilities_protocol_opt		= HF_EMPTY;
static int hf_wsp_capabilities_method_MOR		= HF_EMPTY;
static int hf_wsp_capabilities_push_MOR			= HF_EMPTY;
static int hf_wsp_capabilities_extended_methods		= HF_EMPTY;
static int hf_wsp_capabilities_header_code_pages	= HF_EMPTY;
static int hf_wsp_capabilities_aliases			= HF_EMPTY;
static int hf_wsp_header_uri_len			= HF_EMPTY;
static int hf_wsp_header_uri				= HF_EMPTY;
static int hf_wsp_server_session_id			= HF_EMPTY;
static int hf_wsp_header_status				= HF_EMPTY;
static int hf_wsp_header_length				= HF_EMPTY;
static int hf_wsp_headers_section			= HF_EMPTY;
static int hf_wsp_header				= HF_EMPTY;
static int hf_wsp_content_type				= HF_EMPTY;
static int hf_wsp_content_type_str			= HF_EMPTY;
static int hf_wsp_parameter_well_known_charset		= HF_EMPTY;
static int hf_wsp_parameter_type			= HF_EMPTY;
static int hf_wsp_parameter_name			= HF_EMPTY;
static int hf_wsp_parameter_filename			= HF_EMPTY;
static int hf_wsp_parameter_start			= HF_EMPTY;
static int hf_wsp_parameter_start_info			= HF_EMPTY;
static int hf_wsp_parameter_comment			= HF_EMPTY;
static int hf_wsp_parameter_domain			= HF_EMPTY;
static int hf_wsp_parameter_path			= HF_EMPTY;
static int hf_wsp_parameter_sec			= HF_EMPTY;
static int hf_wsp_parameter_mac			= HF_EMPTY;
static int hf_wsp_parameter_upart_type			= HF_EMPTY;
static int hf_wsp_parameter_upart_type_value		= HF_EMPTY;
static int hf_wsp_reply_data				= HF_EMPTY;
static int hf_wsp_post_data				= HF_EMPTY;
static int hf_wsp_push_data				= HF_EMPTY;
static int hf_wsp_multipart_data			= HF_EMPTY;
static int hf_wsp_mpart					= HF_EMPTY;

static int hf_wsp_header_shift_code			= HF_EMPTY;
static int hf_wsp_header_accept				= HF_EMPTY;
static int hf_wsp_header_accept_str			= HF_EMPTY;
static int hf_wsp_header_accept_application		= HF_EMPTY;
static int hf_wsp_header_accept_application_str		= HF_EMPTY;
static int hf_wsp_header_accept_charset			= HF_EMPTY;
static int hf_wsp_header_accept_charset_str		= HF_EMPTY;
static int hf_wsp_header_accept_language		= HF_EMPTY;
static int hf_wsp_header_accept_language_str		= HF_EMPTY;
static int hf_wsp_header_accept_ranges			= HF_EMPTY;
static int hf_wsp_header_accept_ranges_str		= HF_EMPTY;
static int hf_wsp_header_cache_control			= HF_EMPTY;
static int hf_wsp_header_cache_control_str		= HF_EMPTY;
static int hf_wsp_header_cache_control_field_name	= HF_EMPTY;
static int hf_wsp_header_connection			= HF_EMPTY;
static int hf_wsp_header_connection_str			= HF_EMPTY;
static int hf_wsp_header_cache_control_field_name_str	= HF_EMPTY;
static int hf_wsp_header_content_length			= HF_EMPTY;
static int hf_wsp_header_age				= HF_EMPTY;
static int hf_wsp_header_bearer_indication		= HF_EMPTY;
static int hf_wsp_header_date				= HF_EMPTY;
static int hf_wsp_header_etag				= HF_EMPTY;
static int hf_wsp_header_expires			= HF_EMPTY;
static int hf_wsp_header_last_modified			= HF_EMPTY;
static int hf_wsp_header_location			= HF_EMPTY;
static int hf_wsp_header_if_modified_since		= HF_EMPTY;
static int hf_wsp_header_profile			= HF_EMPTY;
static int hf_wsp_header_pragma				= HF_EMPTY;
static int hf_wsp_header_proxy_authenticate				= HF_EMPTY;
static int hf_wsp_header_www_authenticate				= HF_EMPTY;
static int hf_wsp_header_proxy_authorization			= HF_EMPTY;
static int hf_wsp_header_proxy_authorization_scheme		= HF_EMPTY;
static int hf_wsp_header_proxy_authorization_user_id	= HF_EMPTY;
static int hf_wsp_header_proxy_authorization_password	= HF_EMPTY;
static int hf_wsp_header_authorization					= HF_EMPTY;
static int hf_wsp_header_authorization_scheme			= HF_EMPTY;
static int hf_wsp_header_authorization_user_id			= HF_EMPTY;
static int hf_wsp_header_authorization_password			= HF_EMPTY;
static int hf_wsp_header_server				= HF_EMPTY;
static int hf_wsp_header_user_agent			= HF_EMPTY;
static int hf_wsp_header_warning			= HF_EMPTY;
static int hf_wsp_header_warning_code			= HF_EMPTY;
static int hf_wsp_header_warning_agent			= HF_EMPTY;
static int hf_wsp_header_warning_text			= HF_EMPTY;
static int hf_wsp_header_application_header		= HF_EMPTY;
static int hf_wsp_header_application_value		= HF_EMPTY;
static int hf_wsp_header_x_wap_tod			= HF_EMPTY;
static int hf_wsp_header_content_ID			= HF_EMPTY;
static int hf_wsp_header_transfer_encoding		= HF_EMPTY;
static int hf_wsp_header_transfer_encoding_str		= HF_EMPTY;
static int hf_wsp_header_via				= HF_EMPTY;
static int hf_wsp_header_wap_application_id		= HF_EMPTY;
static int hf_wsp_header_wap_application_id_str		= HF_EMPTY;


/* Openwave-specific WSP headers */
static int hf_wsp_header_openwave_proxy_push_addr	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_push_accept	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_push_seq	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_notify		= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_operator_domain	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_home_page	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_has_color	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_num_softkeys	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_softkey_size	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_screen_chars	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_screen_pixels	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_em_size	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_screen_depth	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_immed_alert	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_net_ask		= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_uplink_version	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_tod		= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_ba_enable	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_ba_realm	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_redirect_enable	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_request_uri	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_redirect_status	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_trans_charset	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_trans_charset_str	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_linger		= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_client_id	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_enable_trust	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_trust_old	= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_trust		= HF_EMPTY;
static int hf_wsp_header_openwave_proxy_bookmark	= HF_EMPTY;
static int hf_wsp_header_openwave_devcap_gui		= HF_EMPTY;


static int hf_wsp_redirect_flags			= HF_EMPTY;
static int hf_wsp_redirect_permanent			= HF_EMPTY;
static int hf_wsp_redirect_reuse_security_session	= HF_EMPTY;
static int hf_wsp_redirect_afl				= HF_EMPTY;
static int hf_wsp_redirect_afl_bearer_type_included	= HF_EMPTY;
static int hf_wsp_redirect_afl_port_number_included	= HF_EMPTY;
static int hf_wsp_redirect_afl_address_len		= HF_EMPTY;
static int hf_wsp_redirect_bearer_type			= HF_EMPTY;
static int hf_wsp_redirect_port_num			= HF_EMPTY;
static int hf_wsp_redirect_ipv4_addr			= HF_EMPTY;
static int hf_wsp_redirect_ipv6_addr			= HF_EMPTY;
static int hf_wsp_redirect_addr				= HF_EMPTY;

/* Initialize the subtree pointers */
static gint ett_wsp 					= ETT_EMPTY;
static gint ett_content_type_parameters			= ETT_EMPTY;
static gint ett_header 					= ETT_EMPTY;
static gint ett_headers					= ETT_EMPTY;
static gint ett_header_warning				= ETT_EMPTY;
static gint ett_header_cache_control_parameters		= ETT_EMPTY;
static gint ett_header_cache_control_field_names	= ETT_EMPTY;
static gint ett_capabilities				= ETT_EMPTY;
static gint ett_post					= ETT_EMPTY;
static gint ett_content_type				= ETT_EMPTY;
static gint ett_redirect_flags				= ETT_EMPTY;
static gint ett_redirect_afl				= ETT_EMPTY;
static gint ett_multiparts				= ETT_EMPTY;
static gint ett_mpartlist				= ETT_EMPTY;
static gint ett_header_credentials			= ETT_EMPTY;

/* Handle for WSP-over-UDP dissector */
static dissector_handle_t wsp_fromudp_handle;

/* Handle for WTP-over-UDP dissector */
static dissector_handle_t wtp_fromudp_handle;

/* Handle for WBXML dissector */
static dissector_handle_t wbxml_handle;

static const value_string vals_pdu_type[] = {
	{ 0x00, "Reserved" },
	{ 0x01, "Connect" },
	{ 0x02, "ConnectReply" },
	{ 0x03, "Redirect" },
	{ 0x04, "Reply" },
	{ 0x05, "Disconnect" },
	{ 0x06, "Push" },
	{ 0x07, "ConfirmedPush" },
	{ 0x08, "Suspend" },
	{ 0x09, "Resume" },

	/* 0x10 - 0x3F Unassigned */

	{ 0x40, "Get" },
	{ 0x41, "Options" },
	{ 0x42, "Head" },
	{ 0x43, "Delete" },
	{ 0x44, "Trace" },

	/* 0x45 - 0x4F Unassigned (Get PDU) */
	/* 0x50 - 0x5F Extended method (Get PDU) */
	{ 0x50, "Extended Get Method 0"},
	{ 0x51, "Extended Get Method 1"},
	{ 0x52, "Extended Get Method 2"},
	{ 0x53, "Extended Get Method 3"},
	{ 0x54, "Extended Get Method 4"},
	{ 0x55, "Extended Get Method 5"},
	{ 0x56, "Extended Get Method 6"},
	{ 0x57, "Extended Get Method 7"},
	{ 0x58, "Extended Get Method 8"},
	{ 0x59, "Extended Get Method 9"},
	{ 0x5A, "Extended Get Method 10"},
	{ 0x5B, "Extended Get Method 11"},
	{ 0x5C, "Extended Get Method 12"},
	{ 0x5D, "Extended Get Method 13"},
	{ 0x5E, "Extended Get Method 14"},
	{ 0x5F, "Extended Get Method 15"},

	{ 0x60, "Post" },
	{ 0x61, "Put" },

	/* 0x62 - 0x6F Unassigned (Post PDU) */
	/* 0x70 - 0x7F Extended method (Post PDU) */
	{ 0x70, "Extended Post Method 0"},
	{ 0x71, "Extended Post Method 1"},
	{ 0x72, "Extended Post Method 2"},
	{ 0x73, "Extended Post Method 3"},
	{ 0x74, "Extended Post Method 4"},
	{ 0x75, "Extended Post Method 5"},
	{ 0x76, "Extended Post Method 6"},
	{ 0x77, "Extended Post Method 7"},
	{ 0x78, "Extended Post Method 8"},
	{ 0x79, "Extended Post Method 9"},
	{ 0x7A, "Extended Post Method 10"},
	{ 0x7B, "Extended Post Method 11"},
	{ 0x7C, "Extended Post Method 12"},
	{ 0x7D, "Extended Post Method 13"},
	{ 0x7E, "Extended Post Method 14"},
	{ 0x7F, "Extended Post Method 15"},

	/* 0x80 - 0xFF Reserved */

	{ 0x00, NULL }

};

static const value_string vals_status[] = {
	/* 0x00 - 0x0F Reserved */

	{ 0x10, "Continue" },
	{ 0x11, "Switching Protocols" },

	{ 0x20, "OK" },
	{ 0x21, "Created" },
	{ 0x22, "Accepted" },
	{ 0x23, "Non-Authoritative Information" },
	{ 0x24, "No Content" },
	{ 0x25, "Reset Content" },
	{ 0x26, "Partial Content" },

	{ 0x30, "Multiple Choices" },
	{ 0x31, "Moved Permanently" },
	{ 0x32, "Moved Temporarily" },
	{ 0x33, "See Other" },
	{ 0x34, "Not Modified" },
	{ 0x35, "Use Proxy" },
	{ 0x37, "Temporary Redirect" },

	{ 0x40, "Bad Request" },
	{ 0x41, "Unauthorised" },
	{ 0x42, "Payment Required" },
	{ 0x43, "Forbidden" },
	{ 0x44, "Not Found" },
	{ 0x45, "Method Not Allowed" },
	{ 0x46, "Not Acceptable" },
	{ 0x47, "Proxy Authentication Required" },
	{ 0x48, "Request Timeout" },
	{ 0x49, "Conflict" },
	{ 0x4A, "Gone" },
	{ 0x4B, "Length Required" },
	{ 0x4C, "Precondition Failed" },
	{ 0x4D, "Request Entity Too Large" },
	{ 0x4E, "Request-URI Too Large" },
	{ 0x4F, "Unsupported Media Type" },
	{ 0x50, "Requested Range Not Satisfiable" },
	{ 0x51, "Expectation Failed" },

	{ 0x60, "Internal Server Error" },
	{ 0x61, "Not Implemented" },
	{ 0x62, "Bad Gateway" },
	{ 0x63, "Service Unavailable" },
	{ 0x64, "Gateway Timeout" },
	{ 0x65, "HTTP Version Not Supported" },

	{ 0x00, NULL }
};

const value_string vals_wsp_reason_codes[] = {
	{ 0xE0, "Protocol Error (Illegal PDU)" },
	{ 0xE1, "Session disconnected" },
	{ 0xE2, "Session suspended" },
	{ 0xE3, "Session resumed" },
	{ 0xE4, "Peer congested" },
	{ 0xE5, "Session connect failed" },
	{ 0xE6, "Maximum receive unit size exceeded" },
	{ 0xE7, "Maximum outstanding requests exceeded" },
	{ 0xE8, "Peer request" },
	{ 0xE9, "Network error" },
	{ 0xEA, "User request" },
	{ 0xEB, "No specific cause, no retries" },
	{ 0xEC, "Push message cannot be delivered" },
	{ 0xED, "Push message discarded" },
	{ 0xEE, "Content type cannot be processed" },
};

/*
 * Field names.
 */
#define FN_ACCEPT		0x00
#define FN_ACCEPT_CHARSET_DEP	0x01	/* encoding version 1.1, deprecated */
#define FN_ACCEPT_ENCODING_DEP	0x02	/* encoding version 1.1, deprecated */
#define FN_ACCEPT_LANGUAGE	0x03
#define FN_ACCEPT_RANGES	0x04
#define FN_AGE			0x05
#define FN_ALLOW		0x06
#define FN_AUTHORIZATION	0x07
#define FN_CACHE_CONTROL_DEP	0x08	/* encoding version 1.1, deprecated */
#define FN_CONNECTION		0x09
#define FN_CONTENT_BASE		0x0A
#define FN_CONTENT_ENCODING	0x0B
#define FN_CONTENT_LANGUAGE	0x0C
#define FN_CONTENT_LENGTH	0x0D
#define FN_CONTENT_LOCATION	0x0E
#define FN_CONTENT_MD5		0x0F
#define FN_CONTENT_RANGE_DEP	0x10	/* encoding version 1.1, deprecated */
#define FN_CONTENT_TYPE		0x11
#define FN_DATE			0x12
#define FN_ETAG			0x13
#define FN_EXPIRES		0x14
#define FN_FROM			0x15
#define FN_HOST			0x16
#define FN_IF_MODIFIED_SINCE	0x17
#define FN_IF_MATCH		0x18
#define FN_IF_NONE_MATCH	0x19
#define FN_IF_RANGE		0x1A
#define FN_IF_UNMODIFIED_SINCE	0x1B
#define FN_LOCATION		0x1C
#define FN_LAST_MODIFIED	0x1D
#define FN_MAX_FORWARDS		0x1E
#define FN_PRAGMA		0x1F
#define FN_PROXY_AUTHENTICATE	0x20
#define FN_PROXY_AUTHORIZATION	0x21
#define FN_PUBLIC		0x22
#define FN_RANGE		0x23
#define FN_REFERER		0x24
#define FN_RETRY_AFTER		0x25
#define FN_SERVER		0x26
#define FN_TRANSFER_ENCODING	0x27
#define FN_UPGRADE		0x28
#define FN_USER_AGENT		0x29
#define FN_VARY			0x2A
#define FN_VIA			0x2B
#define FN_WARNING		0x2C
#define FN_WWW_AUTHENTICATE	0x2D
#define FN_CONTENT_DISPOSITION	0x2E
#define FN_X_WAP_APPLICATION_ID	0x2F
#define FN_X_WAP_CONTENT_URI	0x30
#define FN_X_WAP_INITIATOR_URI	0x31
#define FN_ACCEPT_APPLICATION	0x32
#define FN_BEARER_INDICATION	0x33
#define FN_PUSH_FLAG		0x34
#define FN_PROFILE		0x35
#define FN_PROFILE_DIFF		0x36
#define FN_PROFILE_WARNING	0x37
#define FN_EXPECT		0x38
#define FN_TE			0x39
#define FN_TRAILER		0x3A
#define FN_ACCEPT_CHARSET	0x3B	/* encoding version 1.3 */
#define FN_ACCEPT_ENCODING	0x3C	/* encoding version 1.3 */
#define FN_CACHE_CONTROL	0x3D	/* encoding version 1.3 */
#define FN_CONTENT_RANGE	0x3E	/* encoding version 1.3 */
#define FN_X_WAP_TOD		0x3F
#define FN_CONTENT_ID		0x40
#define FN_SET_COOKIE		0x41
#define FN_COOKIE		0x42
#define FN_ENCODING_VERSION	0x43
#define FN_PROFILE_WARNING14	0x44	/* encoding version 1.4 */
#define FN_CONTENT_DISPOSITION14	0x45	/* encoding version 1.4 */
#define FN_X_WAP_SECURITY	0x46
#define FN_CACHE_CONTROL14	0x47	/* encoding version 1.4 */


/*
 * Openwave field names.
 */
#define FN_OPENWAVE_PROXY_PUSH_ADDR		0x00
#define FN_OPENWAVE_PROXY_PUSH_ACCEPT		0x01
#define FN_OPENWAVE_PROXY_PUSH_SEQ		0x02
#define FN_OPENWAVE_PROXY_NOTIFY		0x03
#define FN_OPENWAVE_PROXY_OPERATOR_DOMAIN	0x04
#define FN_OPENWAVE_PROXY_HOME_PAGE		0x05
#define FN_OPENWAVE_DEVCAP_HAS_COLOR		0x06
#define FN_OPENWAVE_DEVCAP_NUM_SOFTKEYS		0x07
#define FN_OPENWAVE_DEVCAP_SOFTKEY_SIZE		0x08
#define FN_OPENWAVE_DEVCAP_SCREEN_CHARS		0x09
#define FN_OPENWAVE_DEVCAP_SCREEN_PIXELS	0x0A
#define FN_OPENWAVE_DEVCAP_EM_SIZE		0x0B
#define FN_OPENWAVE_DEVCAP_SCREEN_DEPTH		0x0C
#define FN_OPENWAVE_DEVCAP_IMMED_ALERT		0x0D
#define FN_OPENWAVE_PROXY_NET_ASK		0x0E
#define FN_OPENWAVE_PROXY_UPLINK_VERSION	0x0F
#define FN_OPENWAVE_PROXY_TOD			0x10
#define FN_OPENWAVE_PROXY_BA_ENABLE		0x11
#define FN_OPENWAVE_PROXY_BA_REALM		0x12
#define FN_OPENWAVE_PROXY_REDIRECT_ENABLE	0x13
#define FN_OPENWAVE_PROXY_REQUEST_URI		0x14
#define FN_OPENWAVE_PROXY_REDIRECT_STATUS	0x15
#define FN_OPENWAVE_PROXY_TRANS_CHARSET		0x16
#define FN_OPENWAVE_PROXY_LINGER		0x17
#define FN_OPENWAVE_PROXY_CLIENT_ID		0x18
#define FN_OPENWAVE_PROXY_ENABLE_TRUST		0x19
#define FN_OPENWAVE_PROXY_TRUST_OLD		0x1A
#define FN_OPENWAVE_PROXY_TRUST			0x20
#define FN_OPENWAVE_PROXY_BOOKMARK		0x21
#define FN_OPENWAVE_DEVCAP_GUI			0x22

static const value_string vals_openwave_field_names[] = {
	{ FN_OPENWAVE_PROXY_PUSH_ADDR,         "x-up-proxy-push-addr" },
	{ FN_OPENWAVE_PROXY_PUSH_ACCEPT,       "x-up-proxy-push-accept" },
	{ FN_OPENWAVE_PROXY_PUSH_SEQ,          "x-up-proxy-seq" },
	{ FN_OPENWAVE_PROXY_NOTIFY,            "x-up-proxy-notify" },
	{ FN_OPENWAVE_PROXY_OPERATOR_DOMAIN,   "x-up-proxy-operator-domain" },
	{ FN_OPENWAVE_PROXY_HOME_PAGE,         "x-up-proxy-home-page" },
	{ FN_OPENWAVE_DEVCAP_HAS_COLOR,        "x-up-devcap-has-color" },
	{ FN_OPENWAVE_DEVCAP_NUM_SOFTKEYS,     "x-up-devcap-num-softkeys" },
	{ FN_OPENWAVE_DEVCAP_SOFTKEY_SIZE,     "x-up-devcap-softkey-size" },
	{ FN_OPENWAVE_DEVCAP_SCREEN_CHARS,     "x-up-devcap-screen-chars" },
	{ FN_OPENWAVE_DEVCAP_SCREEN_PIXELS,    "x-up-devcap-screen-pixels" },
	{ FN_OPENWAVE_DEVCAP_EM_SIZE,          "x-up-devcap-em-size" },
	{ FN_OPENWAVE_DEVCAP_SCREEN_DEPTH,     "x-up-devcap-screen-depth" },
	{ FN_OPENWAVE_DEVCAP_IMMED_ALERT,      "x-up-devcap-immed-alert" },
	{ FN_OPENWAVE_PROXY_NET_ASK,           "x-up-proxy-net-ask" },
	{ FN_OPENWAVE_PROXY_UPLINK_VERSION,    "x-up-proxy-uplink-version" },
	{ FN_OPENWAVE_PROXY_TOD,               "x-up-proxy-tod" },
	{ FN_OPENWAVE_PROXY_BA_ENABLE,         "x-up-proxy-ba-enable" },
	{ FN_OPENWAVE_PROXY_BA_REALM,          "x-up-proxy-ba-realm" },
	{ FN_OPENWAVE_PROXY_REDIRECT_ENABLE,   "x-up-proxy-redirect-enable" },
	{ FN_OPENWAVE_PROXY_REQUEST_URI,       "x-up-proxy-request-uri" },
	{ FN_OPENWAVE_PROXY_REDIRECT_STATUS,   "x-up-proxy-redirect-status" },
	{ FN_OPENWAVE_PROXY_TRANS_CHARSET,     "x-up-proxy-trans-charset" },
	{ FN_OPENWAVE_PROXY_LINGER,            "x-up-proxy-linger" },
	{ FN_OPENWAVE_PROXY_CLIENT_ID,         "x-up-proxy-client-id" },
	{ FN_OPENWAVE_PROXY_ENABLE_TRUST,      "x-up-proxy-enable-trust" },
	{ FN_OPENWAVE_PROXY_TRUST_OLD,         "x-up-proxy-trust-old" },
	{ FN_OPENWAVE_PROXY_TRUST,             "x-up-proxy-trust" },
	{ FN_OPENWAVE_PROXY_BOOKMARK,          "x-up-proxy-bookmark" },
	{ FN_OPENWAVE_DEVCAP_GUI,              "x-up-devcap-gui" },
	{ 0,                                   NULL }
};


static const value_string vals_field_names[] = {
	{ FN_ACCEPT,               "Accept" },
	{ FN_ACCEPT_CHARSET_DEP,   "Accept-Charset (encoding 1.1)" },
	{ FN_ACCEPT_ENCODING_DEP,  "Accept-Encoding (encoding 1.1)" },
	{ FN_ACCEPT_LANGUAGE,      "Accept-Language" },
	{ FN_ACCEPT_RANGES,        "Accept-Ranges" },
	{ FN_AGE,                  "Age" },
	{ FN_ALLOW,                "Allow" },
	{ FN_AUTHORIZATION,        "Authorization" },
	{ FN_CACHE_CONTROL_DEP,    "Cache-Control (encoding 1.1)" },
	{ FN_CONNECTION,           "Connection" },
	{ FN_CONTENT_BASE,         "Content-Base" },
	{ FN_CONTENT_ENCODING,     "Content-Encoding" },
	{ FN_CONTENT_LANGUAGE,     "Content-Language" },
	{ FN_CONTENT_LENGTH,       "Content-Length" },
	{ FN_CONTENT_LOCATION,     "Content-Location" },
	{ FN_CONTENT_MD5,          "Content-MD5" },
	{ FN_CONTENT_RANGE_DEP,    "Content-Range (encoding 1.1)" },
	{ FN_CONTENT_TYPE,         "Content-Type" },
	{ FN_DATE,                 "Date" },
	{ FN_ETAG,                 "Etag" },
	{ FN_EXPIRES,              "Expires" },
	{ FN_FROM,                 "From" },
	{ FN_HOST,                 "Host" },
	{ FN_IF_MODIFIED_SINCE,    "If-Modified-Since" },
	{ FN_IF_MATCH,             "If-Match" },
	{ FN_IF_NONE_MATCH,        "If-None-Match" },
	{ FN_IF_RANGE,             "If-Range" },
	{ FN_IF_UNMODIFIED_SINCE,  "If-Unmodified-Since" },
	{ FN_LOCATION,             "Location" },
	{ FN_LAST_MODIFIED,        "Last-Modified" },
	{ FN_MAX_FORWARDS,         "Max-Forwards" },
	{ FN_PRAGMA,               "Pragma" },
	{ FN_PROXY_AUTHENTICATE,   "Proxy-Authenticate" },
	{ FN_PROXY_AUTHORIZATION,  "Proxy-Authorization" },
	{ FN_PUBLIC,               "Public" },
	{ FN_RANGE,                "Range" },
	{ FN_REFERER,              "Referer" },
	{ FN_RETRY_AFTER,          "Retry-After" },
	{ FN_SERVER,               "Server" },
	{ FN_TRANSFER_ENCODING,    "Transfer-Encoding" },
	{ FN_UPGRADE,              "Upgrade" },
	{ FN_USER_AGENT,           "User-Agent" },
	{ FN_VARY,                 "Vary" },
	{ FN_VIA,                  "Via" },
	{ FN_WARNING,              "Warning" },
	{ FN_WWW_AUTHENTICATE,     "WWW-Authenticate" },
	{ FN_CONTENT_DISPOSITION,  "Content-Disposition" },
	{ FN_X_WAP_APPLICATION_ID, "X-Wap-Application-ID" },
	{ FN_X_WAP_CONTENT_URI,    "X-Wap-Content-URI" },
	{ FN_X_WAP_INITIATOR_URI,  "X-Wap-Initiator-URI" },
	{ FN_ACCEPT_APPLICATION,   "Accept-Application" },
	{ FN_BEARER_INDICATION,    "Bearer-Indication" },
	{ FN_PUSH_FLAG,            "Push-Flag" },
	{ FN_PROFILE,              "Profile" },
	{ FN_PROFILE_DIFF,         "Profile-Diff" },
	{ FN_PROFILE_WARNING,      "Profile-Warning" },
	{ FN_EXPECT,               "Expect" },
	{ FN_TE,                   "TE" },
	{ FN_TRAILER,              "Trailer" },
	{ FN_ACCEPT_CHARSET,       "Accept-Charset" },
	{ FN_ACCEPT_ENCODING,      "Accept-Encoding" },
	{ FN_CACHE_CONTROL,        "Cache-Control" },
	{ FN_CONTENT_RANGE,        "Content-Range" },
	{ FN_X_WAP_TOD,            "X-Wap-Tod" },
	{ FN_CONTENT_ID,           "Content-ID" },
	{ FN_SET_COOKIE,           "Set-Cookie" },
	{ FN_COOKIE,               "Cookie" },
	{ FN_ENCODING_VERSION,     "Encoding-Version" },
	{ FN_PROFILE_WARNING14,    "Profile-Warning (encoding 1.4)" },
	{ FN_CONTENT_DISPOSITION14,"Content-Disposition (encoding 1.4)" },
	{ FN_X_WAP_SECURITY,       "X-WAP-Security" },
	{ FN_CACHE_CONTROL14,      "Cache-Control (encoding 1.4)" },
	{ 0,                       NULL }
};

/*
 * Bearer types (from the WDP specification).
 */
#define BT_IPv4			0x00
#define BT_IPv6			0x01
#define BT_GSM_USSD		0x02
#define BT_GSM_SMS		0x03
#define BT_ANSI_136_GUTS	0x04
#define BT_IS_95_SMS		0x05
#define BT_IS_95_CSD		0x06
#define BT_IS_95_PACKET_DATA	0x07
#define BT_ANSI_136_CSD		0x08
#define BT_ANSI_136_PACKET_DATA	0x09
#define BT_GSM_CSD		0x0A
#define BT_GSM_GPRS		0x0B
#define BT_GSM_USSD_IPv4	0x0C
#define BT_AMPS_CDPD		0x0D
#define BT_PDC_CSD		0x0E
#define BT_PDC_PACKET_DATA	0x0F
#define BT_IDEN_SMS		0x10
#define BT_IDEN_CSD		0x11
#define BT_IDEN_PACKET_DATA	0x12
#define BT_PAGING_FLEX		0x13
#define BT_PHS_SMS		0x14
#define BT_PHS_CSD		0x15
#define BT_GSM_USSD_GSM_SC	0x16
#define BT_TETRA_SDS_ITSI	0x17
#define BT_TETRA_SDS_MSISDN	0x18
#define BT_TETRA_PACKET_DATA	0x19
#define BT_PAGING_REFLEX	0x1A
#define BT_GSM_USSD_MSISDN	0x1B
#define BT_MOBITEX_MPAK		0x1C
#define BT_ANSI_136_GHOST	0x1D

static const value_string vals_bearer_types[] = {
	{ BT_IPv4,                 "IPv4" },
	{ BT_IPv6,                 "IPv6" },
	{ BT_GSM_USSD,             "GSM USSD" },
	{ BT_GSM_SMS,              "GSM SMS" },
	{ BT_ANSI_136_GUTS,        "ANSI-136 GUTS/R-Data" },
	{ BT_IS_95_SMS,            "IS-95 CDMA SMS" },
	{ BT_IS_95_CSD,            "IS-95 CDMA CSD" },
	{ BT_IS_95_PACKET_DATA,    "IS-95 CDMA Packet data" },
	{ BT_ANSI_136_CSD,         "ANSI-136 CSD" },
	{ BT_ANSI_136_PACKET_DATA, "ANSI-136 Packet data" },
	{ BT_GSM_CSD,              "GSM CSD" },
	{ BT_GSM_GPRS,             "GSM GPRS" },
	{ BT_GSM_USSD_IPv4,        "GSM USSD (IPv4 addresses)" },
	{ BT_AMPS_CDPD,            "AMPS CDPD" },
	{ BT_PDC_CSD,              "PDC CSD" },
	{ BT_PDC_PACKET_DATA,      "PDC Packet data" },
	{ BT_IDEN_SMS,             "IDEN SMS" },
	{ BT_IDEN_CSD,             "IDEN CSD" },
	{ BT_IDEN_PACKET_DATA,     "IDEN Packet data" },
	{ BT_PAGING_FLEX,          "Paging network FLEX(TM)" },
	{ BT_PHS_SMS,              "PHS SMS" },
	{ BT_PHS_CSD,              "PHS CSD" },
	{ BT_GSM_USSD_GSM_SC,      "GSM USSD (GSM Service Code addresses)" },
	{ BT_TETRA_SDS_ITSI,       "TETRA SDS (ITSI addresses)" },
	{ BT_TETRA_SDS_MSISDN,     "TETRA SDS (MSISDN addresses)" },
	{ BT_TETRA_PACKET_DATA,    "TETRA Packet data" },
	{ BT_PAGING_REFLEX,        "Paging network ReFLEX(TM)" },
	{ BT_GSM_USSD_MSISDN,      "GSM USSD (MSISDN addresses)" },
	{ BT_MOBITEX_MPAK,         "Mobitex MPAK" },
	{ BT_ANSI_136_GHOST,       "ANSI-136 GHOST/R-Data" },
	{ 0,                       NULL }
};

static const value_string vals_content_types[] = {
	{ 0x00, "*/*" },
	{ 0x01, "text/*" },
	{ 0x02, "text/html" },
	{ 0x03, "text/plain" },
	{ 0x04, "text/x-hdml" },
	{ 0x05, "text/x-ttml" },
	{ 0x06, "text/x-vCalendar" },
	{ 0x07, "text/x-vCard" },
	{ 0x08, "text/vnd.wap.wml" },
	{ 0x09, "text/vnd.wap.wmlscript" },
	{ 0x0A, "text/vnd.wap.channel" },
	{ 0x0B, "Multipart/*" },
	{ 0x0C, "Multipart/mixed" },
	{ 0x0D, "Multipart/form-data" },
	{ 0x0E, "Multipart/byteranges" },
	{ 0x0F, "Multipart/alternative" },
	{ 0x10, "application/*" },
	{ 0x11, "application/java-vm" },
	{ 0x12, "application/x-www-form-urlencoded" },
	{ 0x13, "application/x-hdmlc" },
	{ 0x14, "application/vnd.wap.wmlc" },
	{ 0x15, "application/vnd.wap.wmlscriptc" },
	{ 0x16, "application/vnd.wap.channelc" },
	{ 0x17, "application/vnd.wap.uaprof" },
	{ 0x18, "application/vnd.wap.wtls-ca-certificate" },
	{ 0x19, "application/vnd.wap.wtls-user-certificate" },
	{ 0x1A, "application/x-x509-ca-cert" },
	{ 0x1B, "application/x-x509-user-cert" },
	{ 0x1C, "image/*" },
	{ 0x1D, "image/gif" },
	{ 0x1E, "image/jpeg" },
	{ 0x1F, "image/tiff" },
	{ 0x20, "image/png" },
	{ 0x21, "image/vnd.wap.wbmp" },
	{ 0x22, "application/vnd.wap.multipart.*" },
	{ 0x23, "application/vnd.wap.multipart.mixed" },
	{ 0x24, "application/vnd.wap.multipart.form-data" },
	{ 0x25, "application/vnd.wap.multipart.byteranges" },
	{ 0x26, "application/vnd.wap.multipart.alternative" },
	{ 0x27, "application/xml" },
	{ 0x28, "text/xml" },
	{ 0x29, "application/vnd.wap.wbxml" },
	{ 0x2A, "application/x-x968-cross-cert" },
	{ 0x2B, "application/x-x968-ca-cert" },
	{ 0x2C, "application/x-x968-user-cert" },
	{ 0x2D, "text/vnd.wap.si" },
	{ 0x2E, "application/vnd.wap.sic" },
	{ 0x2F, "text/vnd.wap.sl" },
	{ 0x30, "application/vnd.wap.slc" },
	{ 0x31, "text/vnd.wap.co" },
	{ 0x32, "application/vnd.wap.coc" },
	{ 0x33, "application/vnd.wap.multipart.related" },
	{ 0x34, "application/vnd.wap.sia" },
	{ 0x35, "text/vnd.wap.connectivity-xml" },
	{ 0x36, "application/vnd.wap.connectivity-wbxml" },
	{ 0x37, "application/pkcs7-mime" },
	{ 0x38, "application/vnd.wap.hashed-certificate" },
	{ 0x39, "application/vnd.wap.signed-certificate" },
	{ 0x3A, "application/vnd.wap.cert-response" },
	{ 0x3B, "application/xhtml+xml" },
	{ 0x3C, "application/wml+xml" },
	{ 0x3D, "text/css" },
	{ 0x3E, "application/vnd.wap.mms-message" },
	{ 0x3F, "application/vnd.wap.rollover-certificate" },
	{ 0x201, "application/vnd.uplanet.cachop-wbxml" },
	{ 0x202, "application/vnd.uplanet.signal" },
	{ 0x203, "application/vnd.uplanet.alert-wbxml" },
	{ 0x204, "application/vnd.uplanet.list-wbxml" },
	{ 0x205, "application/vnd.uplanet.listcmd-wbxml" },
	{ 0x206, "application/vnd.uplanet.channel-wbxml" },
	{ 0x207, "application/vnd.uplanet.provisioning-status-uri" },
	{ 0x208, "x-wap.multipart/vnd.uplanet.header-set" },
	{ 0x209, "application/vnd.uplanet.bearer-choice-wbxml" },
	{ 0x20A, "application/vnd.phonecom.mmc-wbxml" },
	{ 0x20B, "application/vnd.nokia.syncset+wbxml" },
	{ 0x00, NULL }
};

static const value_string vals_languages[] = {
	{ 0x01, "Afar (aa)" },
	{ 0x02, "Abkhazian (ab)" },
	{ 0x03, "Afrikaans (af)" },
	{ 0x04, "Amharic (am)" },
	{ 0x05, "Arabic (ar)" },
	{ 0x06, "Assamese (as)" },
	{ 0x07, "Aymara (ay)" },
	{ 0x08, "Azerbaijani (az)" },
	{ 0x09, "Bashkir (ba)" },
	{ 0x0A, "Byelorussian (be)" },
	{ 0x0B, "Bulgarian (bg)" },
	{ 0x0C, "Bihari (bh)" },
	{ 0x0D, "Bislama (bi)" },
	{ 0x0E, "Bengali; Bangla (bn)" },
	{ 0x0F, "Tibetan (bo)" },
	{ 0x10, "Breton (br)" },
	{ 0x11, "Catalan (ca)" },
	{ 0x12, "Corsican (co)" },
	{ 0x13, "Czech (cs)" },
	{ 0x14, "Welsh (cy)" },
	{ 0x15, "Danish (da)" },
	{ 0x16, "German (de)" },
	{ 0x17, "Bhutani (dz)" },
	{ 0x18, "Greek (el)" },
	{ 0x19, "English (en)" },
	{ 0x1A, "Esperanto (eo)" },
	{ 0x1B, "Spanish (es)" },
	{ 0x1C, "Estonian (et)" },
	{ 0x1D, "Basque (eu)" },
	{ 0x1E, "Persian (fa)" },
	{ 0x1F, "Finnish (fi)" },
	{ 0x20, "Fiji (fj)" },
	{ 0x21, "Urdu (ur)" },
	{ 0x22, "French (fr)" },
	{ 0x23, "Uzbek (uz)" },
	{ 0x24, "Irish (ga)" },
	{ 0x25, "Scots Gaelic (gd)" },
	{ 0x26, "Galician (gl)" },
	{ 0x27, "Guarani (gn)" },
	{ 0x28, "Gujarati (gu)" },
	{ 0x29, "Hausa (ha)" },
	{ 0x2A, "Hebrew (formerly iw) (he)" },
	{ 0x2B, "Hindi (hi)" },
	{ 0x2C, "Croatian (hr)" },
	{ 0x2D, "Hungarian (hu)" },
	{ 0x2E, "Armenian (hy)" },
	{ 0x2F, "Vietnamese (vi)" },
	{ 0x30, "Indonesian (formerly in) (id)" },
	{ 0x31, "Wolof (wo)" },
	{ 0x32, "Xhosa (xh)" },
	{ 0x33, "Icelandic (is)" },
	{ 0x34, "Italian (it)" },
	{ 0x35, "Yoruba (yo)" },
	{ 0x36, "Japanese (ja)" },
	{ 0x37, "Javanese (jw)" },
	{ 0x38, "Georgian (ka)" },
	{ 0x39, "Kazakh (kk)" },
	{ 0x3A, "Zhuang (za)" },
	{ 0x3B, "Cambodian (km)" },
	{ 0x3C, "Kannada (kn)" },
	{ 0x3D, "Korean (ko)" },
	{ 0x3E, "Kashmiri (ks)" },
	{ 0x3F, "Kurdish (ku)" },
	{ 0x40, "Kirghiz (ky)" },
	{ 0x41, "Chinese (zh)" },
	{ 0x42, "Lingala (ln)" },
	{ 0x43, "Laothian (lo)" },
	{ 0x44, "Lithuanian (lt)" },
	{ 0x45, "Latvian, Lettish (lv)" },
	{ 0x46, "Malagasy (mg)" },
	{ 0x47, "Maori (mi)" },
	{ 0x48, "Macedonian (mk)" },
	{ 0x49, "Malayalam (ml)" },
	{ 0x4A, "Mongolian (mn)" },
	{ 0x4B, "Moldavian (mo)" },
	{ 0x4C, "Marathi (mr)" },
	{ 0x4D, "Malay (ms)" },
	{ 0x4E, "Maltese (mt)" },
	{ 0x4F, "Burmese (my)" },
	{ 0x50, "Ukrainian (uk)" },
	{ 0x51, "Nepali (ne)" },
	{ 0x52, "Dutch (nl)" },
	{ 0x53, "Norwegian (no)" },
	{ 0x54, "Occitan (oc)" },
	{ 0x55, "(Afan) Oromo (om)" },
	{ 0x56, "Oriya (or)" },
	{ 0x57, "Punjabi (pa)" },
	{ 0x58, "Polish (po)" },
	{ 0x59, "Pashto, Pushto (ps)" },
	{ 0x5A, "Portuguese (pt)" },
	{ 0x5B, "Quechua (qu)" },
	{ 0x5C, "Zulu (zu)" },
	{ 0x5D, "Kirundi (rn)" },
	{ 0x5E, "Romanian (ro)" },
	{ 0x5F, "Russian (ru)" },
	{ 0x60, "Kinyarwanda (rw)" },
	{ 0x61, "Sanskrit (sa)" },
	{ 0x62, "Sindhi (sd)" },
	{ 0x63, "Sangho (sg)" },
	{ 0x64, "Serbo-Croatian (sh)" },
	{ 0x65, "Sinhalese (si)" },
	{ 0x66, "Slovak (sk)" },
	{ 0x67, "Slovenian (sl)" },
	{ 0x68, "Samoan (sm)" },
	{ 0x69, "Shona (sn)" },
	{ 0x6A, "Somali (so)" },
	{ 0x6B, "Albanian (sq)" },
	{ 0x6C, "Serbian (sr)" },
	{ 0x6D, "Siswati (ss)" },
	{ 0x6E, "Sesotho (st)" },
	{ 0x6F, "Sundanese (su)" },
	{ 0x70, "Swedish (sv)" },
	{ 0x71, "Swahili (sw)" },
	{ 0x72, "Tamil (ta)" },
	{ 0x73, "Telugu (te)" },
	{ 0x74, "Tajik (tg)" },
	{ 0x75, "Thai (th)" },
	{ 0x76, "Tigrinya (ti)" },
	{ 0x77, "Turkmen (tk)" },
	{ 0x78, "Tagalog (tl)" },
	{ 0x79, "Setswana (tn)" },
	{ 0x7A, "Tonga (to)" },
	{ 0x7B, "Turkish (tr)" },
	{ 0x7C, "Tsonga (ts)" },
	{ 0x7D, "Tatar (tt)" },
	{ 0x7E, "Twi (tw)" },
	{ 0x7F, "Uighur (ug)" },
	{ 0x81, "Nauru (na)" },
	{ 0x82, "Faeroese (fo)" },
	{ 0x83, "Frisian (fy)" },
	{ 0x84, "Interlingua (ia)" },
	{ 0x85, "Volapuk (vo)" },
	{ 0x86, "Interlingue (ie)" },
	{ 0x87, "Inupiak (ik)" },
	{ 0x88, "Yiddish (formerly ji) (yi)" },
	{ 0x89, "Inuktitut (iu)" },
	{ 0x8A, "Greenlandic (kl)" },
	{ 0x8B, "Latin (la)" },
	{ 0x8C, "Rhaeto-Romance (rm)" },
	{ 0x00, NULL }
};

static const value_string vals_accept_ranges[] = {
	{ 0x00, "None" },
	{ 0x01, "Bytes" },
	{ 0x00, NULL }
};

#define NO_CACHE		0x00
#define NO_STORE		0x01
#define MAX_AGE			0x02
#define MAX_STALE		0x03
#define MIN_FRESH		0x04
#define ONLY_IF_CACHED		0x05
#define PUBLIC			0x06
#define PRIVATE			0x07
#define NO_TRANSFORM		0x08
#define MUST_REVALIDATE		0x09
#define PROXY_REVALIDATE	0x0A
#define S_MAXAGE		0x0B

static const value_string vals_cache_control[] = {
	{ NO_CACHE,         "No-cache" },
	{ NO_STORE,         "No-store" },
	{ MAX_AGE,          "Max-age" },
	{ MAX_STALE,        "Max-stale" },
	{ MIN_FRESH,        "Min-fresh" },
	{ ONLY_IF_CACHED,   "Only-if-cached" },
	{ PUBLIC,           "Public" },
	{ PRIVATE,          "Private" },
	{ NO_TRANSFORM,     "No-transform" },
	{ MUST_REVALIDATE,  "Must-revalidate" },
	{ PROXY_REVALIDATE, "Proxy-revalidate" },
	{ S_MAXAGE,         "S-max-age" },
	{ 0x00,             NULL }
};

static const value_string vals_connection[] = {
	{ 0x00, "Close" },
	{ 0x00, NULL }
};

static const value_string vals_transfer_encoding[] = {
	{ 0x00, "Chunked" },
	{ 0x00, NULL }
};


/* Parameters and well-known encodings */
static const value_string vals_wsp_parameter_sec[] = {
	{ 0x00,	"NETWPIN" },
	{ 0x01,	"USERPIN" },
	{ 0x02,	"USERNETWPIN" },
	{ 0x03,	"USERPINMAC" },

	{ 0x00, NULL }
};

/* Warning codes and mappings */
static const value_string vals_wsp_warning_code[] = {
	{ 10, "110 Response is stale" },
	{ 11, "111 Revalidation failed" },
	{ 12, "112 Disconnected operation" },
	{ 13, "113 Heuristic expiration" },
	{ 14, "214 Transformation applied" },
	{ 99, "199/299 Miscellaneous warning" },

	{ 0, NULL }
};

static const value_string vals_wsp_warning_code_short[] = {
	{ 10, "110" },
	{ 11, "111" },
	{ 12, "112" },
	{ 13, "113" },
	{ 14, "214" },
	{ 99, "199/299" },

	{ 0, NULL }
};


/*
 * Redirect flags.
 */
#define PERMANENT_REDIRECT	0x80
#define REUSE_SECURITY_SESSION	0x40

/*
 * Redirect address flags and length.
 */
#define BEARER_TYPE_INCLUDED	0x80
#define PORT_NUMBER_INCLUDED	0x40
#define ADDRESS_LEN		0x3f

static const true_false_string yes_no_truth = {
	"Yes" ,
	"No"
};

/*
 * Windows appears to define DELETE.
 */
#ifdef DELETE
#undef DELETE
#endif

enum {
	RESERVED		= 0x00,
	CONNECT			= 0x01,
	CONNECTREPLY		= 0x02,
	REDIRECT		= 0x03,			/* No sample data */
	REPLY			= 0x04,
	DISCONNECT		= 0x05,
	PUSH			= 0x06,			/* No sample data */
	CONFIRMEDPUSH		= 0x07,			/* No sample data */
	SUSPEND			= 0x08,			/* No sample data */
	RESUME			= 0x09,			/* No sample data */

	GET			= 0x40,
	OPTIONS			= 0x41,			/* No sample data */
	HEAD			= 0x42,			/* No sample data */
	DELETE			= 0x43,			/* No sample data */
	TRACE			= 0x44,			/* No sample data */

	POST			= 0x60,
	PUT			= 0x61,			/* No sample data */
};

#define VAL_STRING_SIZE 200

typedef enum {
	VALUE_LEN_SUPPLIED,
	VALUE_IS_TEXT_STRING,
	VALUE_IN_LEN,
} value_type_t;

static dissector_table_t wsp_dissector_table;
static heur_dissector_list_t heur_subdissector_list;

static void add_uri (proto_tree *, packet_info *, tvbuff_t *, guint, guint);
static void add_headers (proto_tree *, tvbuff_t *);
static int add_well_known_header (proto_tree *, tvbuff_t *, int, guint8);
static int add_unknown_header (proto_tree *, tvbuff_t *, int, guint8);
static int add_application_header (proto_tree *, tvbuff_t *, int);
static void add_accept_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_accept_xxx_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, int, const value_string *,
    const char *);
static void add_accept_ranges_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_cache_control_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static int add_cache_control_field_name (proto_tree *, tvbuff_t *, int, guint);
static void add_connection_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_content_type_value (proto_tree *, tvbuff_t *, int, int,
    tvbuff_t *, value_type_t, int, int, int, guint *, const char **);
static void add_wap_application_id_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_integer_value_header_common (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8, const value_string *);
static void add_integer_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);
static void add_string_value_header_common (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8, const value_string *);
static void add_string_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);
static void add_quoted_string_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);
static void add_date_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);
static int add_parameter (proto_tree *, tvbuff_t *, int);
static int add_untyped_parameter (proto_tree *, tvbuff_t *, int, int);
static int add_parameter_charset (proto_tree *, tvbuff_t *, int, int);
static int add_constrained_encoding (proto_tree *, tvbuff_t *, int, int);
static int add_parameter_type (proto_tree *, tvbuff_t *, int, int);
static int add_parameter_text (proto_tree *, tvbuff_t *, int, int, int, const char *);
static void add_post_variable (proto_tree *, tvbuff_t *, guint, guint, guint, guint);
static void add_multipart_data (proto_tree *, tvbuff_t *);
static void add_pragma_header (proto_tree *, tvbuff_t *, int, tvbuff_t *,
    value_type_t, int);
static void add_transfer_encoding_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_warning_header (proto_tree *, tvbuff_t *, int, tvbuff_t *,
    value_type_t, int);
static void add_accept_application_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int);
static void add_credentials_value_header (proto_tree *tree,
		tvbuff_t *header_buff, int headerLen, tvbuff_t *value_buff,
		value_type_t valueType, int valueLen,
		int hf_main, int hf_scheme, int hf_basic_user_id, int hf_basic_password);
static void add_capabilities (proto_tree *tree, tvbuff_t *tvb, int type);
static void add_capability_vals(tvbuff_t *, gboolean, int, guint, guint, char *, size_t);
static value_type_t get_value_type_len (tvbuff_t *, int, guint *, int *, int *);
static guint get_uintvar (tvbuff_t *, guint, guint);
static gint get_integer (tvbuff_t *, guint, guint, value_type_t, guint *);

static int add_well_known_openwave_header (proto_tree *, tvbuff_t *, int, guint8);
static void add_openwave_integer_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);
static void add_openwave_string_value_header (proto_tree *, tvbuff_t *, int,
    tvbuff_t *, value_type_t, int, int, guint8);


/* Code to actually dissect the packets */
static void
dissect_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo,
    proto_tree *tree, dissector_handle_t dissector_handle)
{
	guint8 flags;
	proto_item *ti;
	proto_tree *flags_tree;
	guint8 bearer_type;
	guint8 address_flags_len;
	int address_len;
	proto_tree *atf_tree;
	guint16 port_num;
	guint32 address_ipv4;
	struct e_in6_addr address_ipv6;
	address redir_address;
	conversation_t *conv;

	flags = tvb_get_guint8 (tvb, offset);
	if (tree) {
		ti = proto_tree_add_uint (tree, hf_wsp_redirect_flags,
		    tvb, offset, 1, flags);
		flags_tree = proto_item_add_subtree (ti, ett_redirect_flags);
		proto_tree_add_boolean (flags_tree, hf_wsp_redirect_permanent,
		    tvb, offset, 1, flags);
		proto_tree_add_boolean (flags_tree, hf_wsp_redirect_reuse_security_session,
		    tvb, offset, 1, flags);
	}
	offset++;
	while (tvb_reported_length_remaining (tvb, offset) > 0) {
		address_flags_len = tvb_get_guint8 (tvb, offset);
		if (tree) {
			ti = proto_tree_add_uint (tree, hf_wsp_redirect_afl,
			    tvb, offset, 1, address_flags_len);
			atf_tree = proto_item_add_subtree (ti, ett_redirect_afl);
			proto_tree_add_boolean (atf_tree, hf_wsp_redirect_afl_bearer_type_included,
			    tvb, offset, 1, address_flags_len);
			proto_tree_add_boolean (atf_tree, hf_wsp_redirect_afl_port_number_included,
			    tvb, offset, 1, address_flags_len);
			proto_tree_add_uint (atf_tree, hf_wsp_redirect_afl_address_len,
			    tvb, offset, 1, address_flags_len);
		}
		offset++;
		if (address_flags_len & BEARER_TYPE_INCLUDED) {
			bearer_type = tvb_get_guint8 (tvb, offset);
			if (tree) {
				proto_tree_add_uint (tree, hf_wsp_redirect_bearer_type,
				    tvb, offset, 1, bearer_type);
			}
			offset++;
		} else
			bearer_type = 0x00;	/* XXX */
		if (address_flags_len & PORT_NUMBER_INCLUDED) {
			port_num = tvb_get_ntohs (tvb, offset);
			if (tree) {
				proto_tree_add_uint (tree, hf_wsp_redirect_port_num,
				    tvb, offset, 2, port_num);
			}
			offset += 2;
		} else {
			/*
			 * Redirecting to the same server port number as was
			 * being used, i.e. the source port number of this
			 * redirect.
			 */
			port_num = pinfo->srcport;
		}
		address_len = address_flags_len & ADDRESS_LEN;
		if (!(address_flags_len & BEARER_TYPE_INCLUDED)) {
			/*
			 * We don't have the bearer type in the message,
			 * so we don't know the address type.
			 * (It's the same bearer type as the original
			 * connection.)
			 */
			goto unknown_address_type;
		}

		/*
		 * We know the bearer type, so we know the address type.
		 */
		switch (bearer_type) {

		case BT_IPv4:
		case BT_IS_95_CSD:
		case BT_IS_95_PACKET_DATA:
		case BT_ANSI_136_CSD:
		case BT_ANSI_136_PACKET_DATA:
		case BT_GSM_CSD:
		case BT_GSM_GPRS:
		case BT_GSM_USSD_IPv4:
		case BT_AMPS_CDPD:
		case BT_PDC_CSD:
		case BT_PDC_PACKET_DATA:
		case BT_IDEN_CSD:
		case BT_IDEN_PACKET_DATA:
		case BT_PHS_CSD:
		case BT_TETRA_PACKET_DATA:
			/*
			 * IPv4.
			 */
			if (address_len != 4) {
				/*
				 * Say what?
				 */
				goto unknown_address_type;
			}
			tvb_memcpy(tvb, (guint8 *)&address_ipv4, offset, 4);
			if (tree) {
				proto_tree_add_ipv4 (tree,
				    hf_wsp_redirect_ipv4_addr,
				    tvb, offset, 4, address_ipv4);
			}

			/*
			 * Create a conversation so that the
			 * redirected session will be dissected
			 * as WAP.
			 */
			redir_address.type = AT_IPv4;
			redir_address.len = 4;
			redir_address.data = (const guint8 *)&address_ipv4;
			conv = find_conversation(&redir_address, &pinfo->dst,
			    PT_UDP, port_num, 0, NO_PORT_B);
			if (conv == NULL) {
				conv = conversation_new(&redir_address,
				    &pinfo->dst, PT_UDP, port_num, 0, NO_PORT2);
			}
			conversation_set_dissector(conv, dissector_handle);
			break;

		case BT_IPv6:
			/*
			 * IPv6.
			 */
			if (address_len != 16) {
				/*
				 * Say what?
				 */
				goto unknown_address_type;
			}
			tvb_memcpy(tvb, (guint8 *)&address_ipv6, offset, 16);
			if (tree) {
				proto_tree_add_ipv6 (tree,
				    hf_wsp_redirect_ipv6_addr,
				    tvb, offset, 16, (guint8 *)&address_ipv6);
			}

			/*
			 * Create a conversation so that the
			 * redirected session will be dissected
			 * as WAP.
			 */
			redir_address.type = AT_IPv6;
			redir_address.len = 16;
			redir_address.data = (const guint8 *)&address_ipv4;
			conv = find_conversation(&redir_address, &pinfo->dst,
			    PT_UDP, port_num, 0, NO_PORT_B);
			if (conv == NULL) {
				conv = conversation_new(&redir_address,
				    &pinfo->dst, PT_UDP, port_num, 0, NO_PORT2);
			}
			conversation_set_dissector(conv, dissector_handle);
			break;

		unknown_address_type:
		default:
			if (address_len != 0) {
				if (tree) {
					proto_tree_add_item (tree,
					    hf_wsp_redirect_addr,
					    tvb, offset, address_len,
					    bo_little_endian);
				}
			}
			break;
		}
		offset += address_len;
	}
}

static void
dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
    dissector_handle_t dissector_handle, gboolean is_connectionless)
{
	int offset = 0;

	guint8 pdut;
	guint8 reply_status;
	guint count = 0;
	guint value = 0;
	guint uriLength = 0;
	guint uriStart = 0;
	guint capabilityLength = 0;
	guint capabilityStart = 0;
	guint headersLength = 0;
	guint headerLength = 0;
	guint headerStart = 0;
	guint nextOffset = 0;
	guint contentTypeStart = 0;
	guint contentType = 0;
	const char *contentTypeStr;
	tvbuff_t *tmp_tvb;

/* Set up structures we will need to add the protocol subtree and manage it */
	proto_item *ti;
	proto_tree *wsp_tree = NULL;
/*	proto_tree *wsp_header_fixed; */

/* This field shows up as the "Info" column in the display; you should make
   it, if possible, summarize what's in the packet, so that a user looking
   at the list of packets can tell what type of packet it is. */

	/* Connection-less mode has a TID first */
	if (is_connectionless)
	{
		offset++;
	};

	/* Find the PDU type */
	pdut = tvb_get_guint8 (tvb, offset);

	/* Develop the string to put in the Info column */
	if (check_col(pinfo->cinfo, COL_INFO))
	{
		col_append_fstr(pinfo->cinfo, COL_INFO, "WSP %s",
			val_to_str (pdut, vals_pdu_type, "Unknown PDU type (0x%02x)"));
	};

/* In the interest of speed, if "tree" is NULL, don't do any work not
   necessary to generate protocol tree items. */
	if (tree) {
		ti = proto_tree_add_item(tree, proto_wsp, tvb, 0, -1,
		    bo_little_endian);
		wsp_tree = proto_item_add_subtree(ti, ett_wsp);

/* Code to process the packet goes here */
/*
		wsp_header_fixed = proto_item_add_subtree(ti, ett_header );
*/

		/* Add common items: only TID and PDU Type */

		/* If this is connectionless, then the TID Field is always first */
		if (is_connectionless)
		{
			ti = proto_tree_add_item (wsp_tree, hf_wsp_header_tid,tvb,
				0,1,bo_little_endian);
		}

		ti = proto_tree_add_item(
				wsp_tree, 		/* tree */
				hf_wsp_header_pdu_type, /* id */
				tvb,
				offset, 		/* start of high light */
				1,			/* length of high light */
				bo_little_endian	/* value */
		     );
	}
	offset++;

	/* Map extended methods to the main method now the Column info has been written;
	 * this way we can dissect the extended method PDUs. */
	if ((pdut >= 0x50) && (pdut <= 0x5F))
		pdut = GET;
	else if ((pdut >= 0x70) && (pdut <= 0x7F))
		pdut = POST;

	switch (pdut)
	{
		case CONNECT:
		case CONNECTREPLY:
		case RESUME:
			if (tree) {
				if (pdut == CONNECT)
				{
					ti = proto_tree_add_item (wsp_tree, hf_wsp_version_major,tvb,offset,1,bo_little_endian);
					ti = proto_tree_add_item (wsp_tree, hf_wsp_version_minor,tvb,offset,1,bo_little_endian);
					offset++;
				} else {
					count = 0;	/* Initialise count */
					value = tvb_get_guintvar (tvb, offset, &count);
					ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
					offset += count;
				}
				capabilityStart = offset;
				count = 0;	/* Initialise count */
				capabilityLength = tvb_get_guintvar (tvb, offset, &count);
				offset += count;
				ti = proto_tree_add_uint (wsp_tree, hf_wsp_capability_length,tvb,capabilityStart,count,capabilityLength);

				if (pdut != RESUME)
				{
					count = 0;	/* Initialise count */
					headerLength = tvb_get_guintvar (tvb, offset, &count);
					ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,offset,count,headerLength);
					offset += count;
					capabilityStart = offset;
					headerStart = capabilityStart + capabilityLength;
				} else {
						/* Resume computes the headerlength by remaining bytes */
					capabilityStart = offset;
					headerStart = capabilityStart + capabilityLength;
					headerLength = tvb_reported_length_remaining (tvb, headerStart);
				}
				if (capabilityLength > 0)
				{
					tmp_tvb = tvb_new_subset (tvb, offset, capabilityLength, capabilityLength);
					add_capabilities (wsp_tree, tmp_tvb, pdut);
					offset += capabilityLength;
				}

				if (headerLength > 0)
				{
					tmp_tvb = tvb_new_subset (tvb, offset, headerLength, headerLength);
					add_headers (wsp_tree, tmp_tvb);
				}
			}

			break;

		case REDIRECT:
			dissect_redirect(tvb, offset, pinfo, wsp_tree,
			  dissector_handle);
			break;

		case DISCONNECT:
		case SUSPEND:
			if (tree) {
				count = 0;	/* Initialise count */
				value = tvb_get_guintvar (tvb, offset, &count);
				ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
			}
			break;

		case GET:
			count = 0;	/* Initialise count */
				/* Length of URI and size of URILen field */
			value = tvb_get_guintvar (tvb, offset, &count);
			nextOffset = offset + count;
			add_uri (wsp_tree, pinfo, tvb, offset, nextOffset);
			if (tree) {
				offset += (value+count); /* VERIFY */
				tmp_tvb = tvb_new_subset (tvb, offset, -1, -1);
				add_headers (wsp_tree, tmp_tvb);
			}
			break;

		case POST:
			uriStart = offset;
			count = 0;	/* Initialise count */
			uriLength = tvb_get_guintvar (tvb, offset, &count);
			headerStart = uriStart+count;
			count = 0;	/* Initialise count */
			headersLength = tvb_get_guintvar (tvb, headerStart, &count);
			offset = headerStart + count;

			add_uri (wsp_tree, pinfo, tvb, uriStart, offset);
			if (tree) {
				offset += uriLength;

				ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,headersLength);

				if (headersLength == 0)
					break;

				contentTypeStart = offset;
				nextOffset = add_content_type (wsp_tree,
				    tvb, offset, &contentType,
				    &contentTypeStr);

				/* Add headers subtree that will hold the headers fields */
				/* Runs from nextOffset for headersLength-(length of content-type field)*/
				headerLength = headersLength-(nextOffset-contentTypeStart);
				if (headerLength > 0)
				{
					tmp_tvb = tvb_new_subset (tvb, nextOffset, headerLength, headerLength);
					add_headers (wsp_tree, tmp_tvb);
				}
				offset = nextOffset+headerLength;
			}
			/* POST data - First check whether a subdissector exists for the content type */
			if (tvb_reported_length_remaining(tvb, headerStart + count + uriLength + headersLength) > 0)
			{
				tmp_tvb = tvb_new_subset (tvb, headerStart + count + uriLength + headersLength, -1, -1);
				/* Try finding a dissector for the content first, then fallback */
				if (!dissector_try_port(wsp_dissector_table, contentType, tmp_tvb, pinfo, tree))
					if (!dissector_try_heuristic(heur_subdissector_list, tmp_tvb, pinfo, tree))
						if (tree) /* Only display if needed */
							add_post_data (wsp_tree, tmp_tvb, contentType, contentTypeStr);
			}
			break;

		case REPLY:
			count = 0;	/* Initialise count */
			headersLength = tvb_get_guintvar (tvb, offset+1, &count);
			headerStart = offset + count + 1;
			if (tree) {
				reply_status = tvb_get_guint8(tvb, offset);
				ti = proto_tree_add_item (wsp_tree, hf_wsp_header_status,tvb,offset,1,bo_little_endian);
				if (check_col(pinfo->cinfo, COL_INFO))
				{ /* Append status code to INFO column */
					col_append_fstr(pinfo->cinfo, COL_INFO, ": \"0x%02x %s\"", reply_status,
							val_to_str (reply_status, vals_status, "Unknown response status (0x%02x)"));
				}
				nextOffset = offset + 1 + count;
				ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,offset+1,count,headersLength);

				if (headersLength == 0)
					break;

				contentTypeStart = nextOffset;
				nextOffset = add_content_type (wsp_tree,
				    tvb, nextOffset, &contentType,
				    &contentTypeStr);

				/* Add headers subtree that will hold the headers fields */
				/* Runs from nextOffset for headersLength-(length of content-type field)*/
				headerLength = headersLength-(nextOffset-contentTypeStart);
				if (headerLength > 0)
				{
					tmp_tvb = tvb_new_subset (tvb, nextOffset, headerLength, headerLength);
					add_headers (wsp_tree, tmp_tvb);
				}
				offset += count+headersLength+1;
			}
			/* REPLY data - First check whether a subdissector exists for the content type */
			if (tvb_reported_length_remaining(tvb, headerStart + headersLength) > 0)
			{
				tmp_tvb = tvb_new_subset (tvb, headerStart + headersLength, -1, -1);
				/* Try finding a dissector for the content first, then fallback */
				if (!dissector_try_port(wsp_dissector_table, contentType, tmp_tvb, pinfo, tree))
					if (!dissector_try_heuristic(heur_subdissector_list, tmp_tvb, pinfo, tree))
						if (tree) /* Only display if needed */
							ti = proto_tree_add_item (wsp_tree, hf_wsp_reply_data,
									tmp_tvb, 0, -1, bo_little_endian);
			}
			break;

		case PUSH:
		case CONFIRMEDPUSH:
			count = 0;	/* Initialise count */
			headersLength = tvb_get_guintvar (tvb, offset, &count);
			headerStart = offset + count;

			if (tree) {
				ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,offset,count,headersLength);

				if (headersLength == 0)
					break;

				offset += count;
				contentTypeStart = offset;
				nextOffset = add_content_type (wsp_tree,
				    tvb, offset, &contentType,
				    &contentTypeStr);

				/* Add headers subtree that will hold the headers fields */
				/* Runs from nextOffset for headersLength-(length of content-type field)*/
				headerLength = headersLength-(nextOffset-contentTypeStart);
				if (headerLength > 0)
				{
					tmp_tvb = tvb_new_subset (tvb, nextOffset, headerLength, headerLength);
					add_headers (wsp_tree, tmp_tvb);
				}
				offset += headersLength;
			}
			/* PUSH data - First check whether a subdissector exists for the content type */
			if (tvb_reported_length_remaining(tvb, headerStart + headersLength) > 0)
			{
				tmp_tvb = tvb_new_subset (tvb, headerStart + headersLength, -1, -1);
				/* Try finding a dissector for the content first, then fallback */
				if (!dissector_try_port(wsp_dissector_table, contentType, tmp_tvb, pinfo, tree))
					if (!dissector_try_heuristic(heur_subdissector_list, tmp_tvb, pinfo, tree))
						if (tree) /* Only display if needed */
							ti = proto_tree_add_item (wsp_tree, hf_wsp_push_data,
									tmp_tvb, 0, -1, bo_little_endian);
			}
			break;

	}
}

/*
 * Called directly from UDP.
 * Put "WSP" into the "Protocol" column.
 */
static void
dissect_wsp_fromudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "WSP" );
	if (check_col(pinfo->cinfo, COL_INFO))
		col_clear(pinfo->cinfo, COL_INFO);

	dissect_wsp_common(tvb, pinfo, tree, wsp_fromudp_handle, TRUE);
}

/*
 * Called from a higher-level WAP dissector, in connection-oriented mode.
 * Leave the "Protocol" column alone - the dissector calling us should
 * have set it.
 */
static void
dissect_wsp_fromwap_co(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	/*
	 * XXX - what about WTLS->WTP->WSP?
	 */
	dissect_wsp_common(tvb, pinfo, tree, wtp_fromudp_handle, FALSE);
}

/*
 * Called from a higher-level WAP dissector, in connectionless mode.
 * Leave the "Protocol" column alone - the dissector calling us should
 * have set it.
 */
static void
dissect_wsp_fromwap_cl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	/*
	 * XXX - what about WTLS->WSP?
	 */
	if (check_col(pinfo->cinfo, COL_INFO))
	{
		col_clear(pinfo->cinfo, COL_INFO);
	}
	dissect_wsp_common(tvb, pinfo, tree, wtp_fromudp_handle, TRUE);
}

static void
add_uri (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, guint URILenOffset, guint URIOffset)
{
	proto_item *ti;

	guint count = 0;
	guint uriLen = tvb_get_guintvar (tvb, URILenOffset, &count);

	if (tree)
		ti = proto_tree_add_uint (tree, hf_wsp_header_uri_len,tvb,URILenOffset,count,uriLen);

	tvb_ensure_bytes_exist(tvb, URIOffset, uriLen);
	if (tree)
		ti = proto_tree_add_item (tree, hf_wsp_header_uri,tvb,URIOffset,uriLen,bo_little_endian);
	if (check_col(pinfo->cinfo, COL_INFO)) {
		col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
		    tvb_format_text (tvb, URIOffset, uriLen));
	}
}

static void
add_headers (proto_tree *tree, tvbuff_t *tvb)
{
	proto_item *ti;
	proto_tree *wsp_headers;
	guint offset = 0;
	guint headersLen = tvb_reported_length (tvb);
	guint headerStart = 0;
	guint peek = 0;
	guint pageCode = 1;

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: Offset is %d, size is %d\n", offset, headersLen);
#endif

	/* End of buffer */
	if (headersLen <= 0)
	{
		return;
	}

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: Headers to process\n");
#endif

	ti = proto_tree_add_item (tree, hf_wsp_headers_section,tvb,offset,headersLen,bo_little_endian);
	wsp_headers = proto_item_add_subtree( ti, ett_headers );

	/* Parse Headers */

	while (offset < headersLen)
	{
		/* Loop round each header */
		headerStart = offset;
		peek = tvb_get_guint8 (tvb, headerStart);

		if (peek < 32)		/* Short-cut shift delimiter */
		{
			pageCode = peek;
			proto_tree_add_uint (wsp_headers,
			    hf_wsp_header_shift_code, tvb, offset, 1,
			    pageCode);
			offset += 1;
			continue;
		}
		else if (peek == 0x7F)	/* Shift delimiter */
		{
			pageCode = tvb_get_guint8(tvb, offset+1);
			proto_tree_add_uint (wsp_headers,
			    hf_wsp_header_shift_code, tvb, offset, 2,
			    pageCode);
			offset += 2;
			continue;
		}
		else if (peek < 127)
		{
#ifdef DEBUG
			fprintf (stderr, "dissect_wsp: header: application-header start %d (0x%02X)\n", peek, peek);
#endif
			/*
			 * Token-text, followed by Application-specific-value.
			 */
			offset = add_application_header (wsp_headers, tvb,
			    headerStart);
		}
		else if (peek & 0x80)
		{
#ifdef DEBUG
			fprintf (stderr, "dissect_wsp: header: well-known %d (0x%02X)\n", peek, peek);
#endif
			/*
			 * Well-known-header; the lower 7 bits of "peek"
			 * are the header code.
			 */
			switch (pageCode) {
			case 1:
				offset = add_well_known_header (wsp_headers,
				    tvb, headerStart, peek & 0x7F);
				break;

			case 2:
			case 16:
				offset = add_well_known_openwave_header (wsp_headers,
				    tvb, headerStart, peek & 0x7F);
				break;

			default:
				offset = add_unknown_header (wsp_headers,
				    tvb, headerStart, peek & 0x7F);
				break;
			}
		}
	}
}

static int
add_well_known_header (proto_tree *tree, tvbuff_t *tvb, int offset,
    guint8 headerType)
{
	int headerStart;
	value_type_t valueType;
	int headerLen;
	guint valueLen;
	int valueStart;
	tvbuff_t *header_buff;
	tvbuff_t *value_buff;

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: Got header 0x%02x\n", headerType);
#endif
	headerStart = offset;

	/*
	 * Skip the Short-Integer header type.
	 */
	offset++;

	/*
	 * Get the value type and length (or, if the type is VALUE_IN_LEN,
	 * meaning the value is a Short-integer, get the value type
	 * and the value itself).
	 */
	valueType = get_value_type_len (tvb, offset, &valueLen,
	    &valueStart, &offset);
	headerLen = offset - headerStart;

	/*
	 * Get a tvbuff for the entire header.
	 * XXX - cut the actual length short so that it doesn't run
	 * past the actual length of tvb.
	 */
	header_buff = tvb_new_subset (tvb, headerStart, headerLen,
	    headerLen);

	/*
	 * If the value wasn't in the length, get a tvbuff for the value.
	 * XXX - can valueLen be 0?
	 * XXX - cut the actual length short so that it doesn't run
	 * past the actual length of tvb.
	 */
	if (valueType != VALUE_IN_LEN) {
		value_buff = tvb_new_subset (tvb, valueStart, valueLen,
		    valueLen);
	} else {
		/*
		 * XXX - when the last dissector is tvbuffified,
		 * so that NULL is no longer a valid tvb pointer
		 * value in "proto_tree_add" calls, just
		 * set "value_buff" to NULL.
		 *
		 * XXX - can we already do that?  I.e., will that
		 * cause us always to crash if we mistakenly try
		 * to fetch the value of a VALUE_IN_LEN item?
		 */
		value_buff = tvb_new_subset (tvb, headerStart, 0, 0);
	}

	switch (headerType) {

	case FN_ACCEPT:			/* Accept */
		add_accept_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_ACCEPT_CHARSET_DEP:	/* Accept-Charset */
		/*
		 * XXX - should both encoding versions 1.1 and
		 * 1.3 be handled this way?
		 */
		add_accept_xxx_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_accept_charset,
		    hf_wsp_header_accept_charset_str,
		    vals_character_sets, "Unknown charset (0x%04x)");
		break;

	case FN_ACCEPT_LANGUAGE:	/* Accept-Language */
		add_accept_xxx_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_accept_language,
		    hf_wsp_header_accept_language_str,
		    vals_languages, "Unknown language (0x%04x)");
		break;

	case FN_ACCEPT_RANGES:		/* Accept-Ranges */
		add_accept_ranges_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_AGE:			/* Age */
		add_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_age,
		    headerType);
		break;

	case FN_CACHE_CONTROL_DEP:	/* Cache-Control */
	case FN_CACHE_CONTROL:
	case FN_CACHE_CONTROL14:
		/*
		 * XXX - is the only difference in the three different
		 * versions (1.1, 1.3, 1.4) really only S_MAXAGE?
		 */
		add_cache_control_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_CONNECTION:	/* Connection */
		add_connection_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_CONTENT_LENGTH:		/* Content-Length */
		add_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_content_length,
		    headerType);
		break;

	case FN_DATE:			/* Date */
		add_date_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_date, headerType);
		break;

	case FN_ETAG:			/* Etag */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_etag, headerType);
		break;

	case FN_EXPIRES:		/* Expires */
		add_date_value_header (tree, header_buff, headerLen,
		    value_buff,	valueType, valueLen,
		    hf_wsp_header_expires, headerType);
		break;

	case FN_IF_MODIFIED_SINCE:	/* If-Modified-Since */
		add_date_value_header (tree, header_buff, headerLen,
		    value_buff,	valueType, valueLen,
		    hf_wsp_header_if_modified_since, headerType);
		break;

	case FN_LOCATION:		/* Location */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_location, headerType);
		break;

	case FN_LAST_MODIFIED:		/* Last-Modified */
		add_date_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_last_modified, headerType);
		break;

	case FN_PRAGMA:			/* Pragma */
		add_pragma_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_SERVER:			/* Server */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_server, headerType);
		break;

	case FN_TRANSFER_ENCODING:	/* Transfer-Encoding */
		add_transfer_encoding_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_USER_AGENT:		/* User-Agent */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_user_agent, headerType);
		break;

	case FN_VIA:			/* Via */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_via, headerType);
		break;

	case FN_WARNING:		/* Warning */
		add_warning_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_ACCEPT_APPLICATION:	/* Accept-Application */
		add_accept_application_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_BEARER_INDICATION:	/* Bearer-Indication */
		add_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_bearer_indication, headerType);
		break;

	case FN_PROFILE:		/* Profile */
		add_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_profile, headerType);
		break;

	case FN_X_WAP_APPLICATION_ID:	/* X-Wap-Application-Id */
		add_wap_application_id_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_CONTENT_ID:		/* Content-ID	*/
		add_quoted_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_content_ID, headerType);
		break;
	
	case FN_AUTHORIZATION: /* Authorization */
		add_credentials_value_header (tree, header_buff, headerLen,
				value_buff, valueType, valueLen,
				hf_wsp_header_authorization,
				hf_wsp_header_authorization_scheme,
				hf_wsp_header_authorization_user_id,
				hf_wsp_header_authorization_password);
		break;

	case FN_PROXY_AUTHORIZATION: /* Proxy-Authorization */
		add_credentials_value_header (tree, header_buff, headerLen,
				value_buff, valueType, valueLen,
				hf_wsp_header_proxy_authorization,
				hf_wsp_header_proxy_authorization_scheme,
				hf_wsp_header_proxy_authorization_user_id,
				hf_wsp_header_proxy_authorization_password);
		break;

	case FN_WWW_AUTHENTICATE: /* WWW-Authenticate */
	case FN_PROXY_AUTHENTICATE: /* Proxy-Authenticate */


	default:
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Undecoded Header: %s",
		    val_to_str (headerType, vals_field_names, "Unknown (0x%02X)"));
		break;
	}
	return offset;
}


static int
add_well_known_openwave_header (proto_tree *tree, tvbuff_t *tvb, int offset,
    guint8 headerType)
{
	int headerStart;
	value_type_t valueType;
	int headerLen;
	guint valueLen;
	int valueStart;
	tvbuff_t *header_buff;
	tvbuff_t *value_buff;

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: Got Openwave header 0x%02x\n", headerType);
#endif
	headerStart = offset;

	/*
	 * Skip the Short-Integer header type.
	 */
	offset++;

	/*
	 * Get the value type and length (or, if the type is VALUE_IN_LEN,
	 * meaning the value is a Short-integer, get the value type
	 * and the value itself).
	 */
	valueType = get_value_type_len (tvb, offset, &valueLen,
	    &valueStart, &offset);
	headerLen = offset - headerStart;

	/*
	 * Get a tvbuff for the entire header.
	 * XXX - cut the actual length short so that it doesn't run
	 * past the actual length of tvb.
	 */
	header_buff = tvb_new_subset (tvb, headerStart, headerLen,
	    headerLen);

	/*
	 * If the value wasn't in the length, get a tvbuff for the value.
	 * XXX - can valueLen be 0?
	 * XXX - cut the actual length short so that it doesn't run
	 * past the actual length of tvb.
	 */
	if (valueType != VALUE_IN_LEN) {
		value_buff = tvb_new_subset (tvb, valueStart, valueLen,
		    valueLen);
	} else {
		/*
		 * XXX - when the last dissector is tvbuffified,
		 * so that NULL is no longer a valid tvb pointer
		 * value in "proto_tree_add" calls, just
		 * set "value_buff" to NULL.
		 *
		 * XXX - can we already do that?  I.e., will that
		 * cause us always to crash if we mistakenly try
		 * to fetch the value of a VALUE_IN_LEN item?
		 */
		value_buff = tvb_new_subset (tvb, headerStart, 0, 0);
	}

	switch (headerType) {

/*	case FN_OPENWAVE_PROXY_PUSH_ADDR:	/ x-up-proxy-push-addr */
/*		add_openwave_push_address_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen); */
/*		break; */

	case FN_OPENWAVE_PROXY_PUSH_ACCEPT:	/* x-up-proxy-push-accept */
		add_accept_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen);
		break;

	case FN_OPENWAVE_PROXY_PUSH_SEQ:	/* x-up-proxy-push-seq */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_push_seq,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_NOTIFY:		/* x-up-proxy-notify */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_notify,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_OPERATOR_DOMAIN:	/* x-up-proxy-operator-domain */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_operator_domain, headerType);
		break;

	case FN_OPENWAVE_PROXY_HOME_PAGE:	/* x-up-proxy-home-page */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_home_page, headerType);
		break;

	case FN_OPENWAVE_DEVCAP_HAS_COLOR:	/* x-up-devcap-has-color */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_has_color,
		    headerType);
		break;

	case FN_OPENWAVE_DEVCAP_NUM_SOFTKEYS:	/* x-up-devcap-num-softkeys */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_num_softkeys,
		    headerType);
		break;

	case FN_OPENWAVE_DEVCAP_SOFTKEY_SIZE:	/* x-up-devcap-softkey-size */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_softkey_size,
		    headerType);
		break;

/*	case FN_OPENWAVE_DEVCAP_SCREEN_CHARS:	/ x-up-devcap-screen-chars */
/*		add_openwave_integer_value_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_screen_chars, */
/*		    headerType); */
/*		break; */

/*	case FN_OPENWAVE_DEVCAP_SCREEN_PIXELS:	/ x-up-devcap-screen-pixels */
/*		add_openwave_integer_value_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_screen_pixels, */
/*		    headerType); */
/*		break; */

/*	case FN_OPENWAVE_DEVCAP_EM_SIZE:	/ x-up-devcap-em-size */
/*		add_openwave_integer_value_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_em_size, */
/*		    headerType); */
/*		break; */

	case FN_OPENWAVE_DEVCAP_SCREEN_DEPTH:	/* x-up-devcap-screen-depth */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_screen_depth,
		    headerType);
		break;

	case FN_OPENWAVE_DEVCAP_IMMED_ALERT:	/* x-up-devcap-immed-alert */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_immed_alert,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_NET_ASK:		/* x-up-proxy-net-ask */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_net_ask,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_UPLINK_VERSION:		/* x-up-proxy-uplink-version */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_uplink_version, headerType);
		break;

	case FN_OPENWAVE_PROXY_TOD:		/* x-up-proxy-tod */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_tod, headerType);
		break;

	case FN_OPENWAVE_PROXY_BA_ENABLE:		/* x-up-proxy-ba-enable */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_ba_enable, headerType);
		break;

	case FN_OPENWAVE_PROXY_BA_REALM:		/* x-up-proxy-ba-realm */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_ba_realm, headerType);
		break;

	case FN_OPENWAVE_PROXY_REDIRECT_ENABLE:		/* x-up-proxy-redirect-enable */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_redirect_enable, headerType);
		break;

	case FN_OPENWAVE_PROXY_REQUEST_URI:		/* x-up-proxy-request-uri */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_request_uri, headerType);
		break;

/*	case FN_OPENWAVE_PROXY_REDIRECT_STATUS:		/ x-up-proxy-redirect-status */
/*		add_openwave_integer_value_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_redirect_status, */
/*		    headerType); */
/*		break; */

	case FN_OPENWAVE_PROXY_TRANS_CHARSET:		/* x-up-proxy-trans-charset */
		add_accept_xxx_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_trans_charset,
		    hf_wsp_header_openwave_proxy_trans_charset_str,
		    vals_character_sets, "Unknown charset (%u)");
		break;

	case FN_OPENWAVE_PROXY_LINGER:			/* x-up-proxy-linger */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_linger,
		    headerType);
		break;

/*	case FN_OPENWAVE_PROXY_CLIENT_ID:		/ x-up-proxy-client-id */
/*		add_openwave_string_value_header (tree, header_buff, headerLen, */
/*		    value_buff, valueType, valueLen, */
/*		    hf_wsp_header_openwave_proxy_client_id, headerType); */
/*		break; */

	case FN_OPENWAVE_PROXY_ENABLE_TRUST:		/* x-up-proxy-enable-trust */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_enable_trust,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_TRUST_OLD:		/* x-up-proxy-trust old value */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_trust_old,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_TRUST:			/* x-up-proxy-trust */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_proxy_trust,
		    headerType);
		break;

	case FN_OPENWAVE_PROXY_BOOKMARK:		/* x-up-proxy-bookmark */
		add_openwave_string_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen,
		    hf_wsp_header_openwave_proxy_bookmark, headerType);
		break;

	case FN_OPENWAVE_DEVCAP_GUI:			/* x-up-devcap-gui */
		add_openwave_integer_value_header (tree, header_buff, headerLen,
		    value_buff, valueType, valueLen, hf_wsp_header_openwave_devcap_gui,
		    headerType);
		break;

	default:
	        proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Undecoded Openwave Header: %s",
		    val_to_str (headerType, vals_openwave_field_names, "Unknown (0x%02X)"));
		break;
	}
	return offset;
}

/* *********
static void
add_openwave_push_address_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{

	???

}
********* */

static int
add_unknown_header (proto_tree *tree, tvbuff_t *tvb, int offset,
    guint8 headerType)
{
	int headerStart;
	int valueStart;
	value_type_t valueType;
	int headerLen;
	guint valueLen;
	int valueOffset;

	headerStart = offset;

	/*
	 * Skip the Short-Integer header type.
	 */
	offset++;

	valueStart = offset;

	/*
	 * Get the value type and length (or, if the type is VALUE_IN_LEN,
	 * meaning the value is a Short-integer, get the value type
	 * and the value itself).
	 */
	valueType = get_value_type_len (tvb, valueStart, &valueLen,
	    &valueOffset, &offset);
	headerLen = offset - headerStart;

	proto_tree_add_text (tree, tvb, headerStart, headerLen,
		       "Undecoded Header (0x%02X)", headerType);
	return offset;
}

static int
add_application_header (proto_tree *tree, tvbuff_t *tvb, int offset)
{
	int startOffset;
	guint tokenSize;
	const guint8 *token;
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint secs;
	nstime_t timeValue;
	int asvOffset;
	guint stringSize;

	startOffset = offset;
	tokenSize = tvb_strsize (tvb, startOffset);
	token = tvb_get_ptr (tvb, startOffset, tokenSize);
	offset += tokenSize;

	/*
	 * Special case header "X-WAP.TOD" that is sometimes followed
	 * by a 4-byte date value.
	 *
	 * XXX - according to the 4-May-2000 WSP spec, X-Wap-Tod is
	 * encoded as a well known header, with a code of 0x3F.
	 */
	if (tokenSize == 10 && strncasecmp ("x-wap.tod", token, 9) == 0)
	{
		valueType = get_value_type_len (tvb, offset,
		    &subvalueLen, &subvalueOffset, &offset);
		if (get_integer (tvb, subvalueOffset, subvalueLen,
		    valueType, &secs) == 0)
		{
			/*
			 * Fill in the "struct timeval", and add it to the
			 * protocol tree.
			 * Note: this will succeed even if it's a Short-integer.
			 * A Short-integer would work, but, as the time values
			 * are UNIX seconds-since-the-Epoch value, and as
			 * there weren't WAP phones or Web servers back in
			 * late 1969/early 1970, they're unlikely to be used.
			 */
			timeValue.secs = secs;
			timeValue.nsecs = 0;
			proto_tree_add_time (tree, hf_wsp_header_x_wap_tod,
			    tvb, startOffset, offset - startOffset, &timeValue);
		}
		else
		{
			proto_tree_add_text (tree, tvb, startOffset,
			    offset - startOffset,
			    "%s: invalid date value", token);
		}
	}
	else
	{
		asvOffset = offset;
		stringSize = tvb_strsize (tvb, asvOffset);
		offset += stringSize;
		proto_tree_add_text (tree, tvb, startOffset,
		    offset - startOffset,
		    "%s: %s", token,
		    tvb_get_ptr (tvb, asvOffset, stringSize));
	}
	return offset;
}

static void
add_accept_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	guint contentType;
	const char *contentTypeStr;

	add_content_type_value (tree, header_buff, 0, headerLen, value_buff,
	    valueType, valueLen, hf_wsp_header_accept,
	    hf_wsp_header_accept_str, &contentType, &contentTypeStr);
}

static void
add_accept_xxx_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_numeric, int hf_string,
    const value_string *vals, const char *unknown_tag)
{
	int offset = 0;
	int subvalueLen;
	int subvalueOffset;
	guint value = 0;
	char valString[VAL_STRING_SIZE];
	const char *valMatch;
	guint peek;
	double q_value = 1.0;

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Constrained-{charset,language} (Short-Integer).
		 */
		proto_tree_add_uint (tree, hf_numeric,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Constrained-{charset,language} (text, i.e.
		 * Extension-Media).
		 */
		proto_tree_add_string (tree, hf_string,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (valueLen == 0) {
		/*
		 * Any-{charset,language}.
		 */
		proto_tree_add_string (tree, hf_string,
			header_buff, 0, headerLen,
			"*");
		return;
	}

	/*
	 * Accept-{charset,language}-general-form; Value-length, followed
	 * by Well-known-{charset,language} or {Token-text,Text-string},
	 * possibly followed by a Q-value.
	 *
	 * Get Value-length.
	 */
	valueType = get_value_type_len (value_buff, 0, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * {Token-text,Text-string}.
		 */
		valMatch =
		    tvb_get_ptr (value_buff, subvalueOffset, subvalueLen);
		proto_tree_add_string (tree, hf_string,
			value_buff, 0, valueLen, valMatch);
	} else {
		/*
		 * Well-known-{charset,langugage}; starts with an
		 * Integer-value.
		 */
		if (get_integer (value_buff, subvalueOffset, subvalueLen,
		    valueType, &value) < 0)
		{
			valMatch = "Invalid integer";
		}
		else
		{
			valMatch = val_to_str(value, vals, unknown_tag);
		}
	}

	/* Any remaining data relates to Q-value */
	if (offset < valueLen)
	{
		peek = tvb_get_guintvar (value_buff, offset, NULL);
		if (peek <= 100) {
			peek = (peek - 1) * 10;
		}
		else {
			peek -= 100;
		}
		q_value = peek/1000.0;
	}

	/* Build string including Q-value if present */
	if (q_value == 1.0)			/* Default */
	{
		snprintf (valString, VAL_STRING_SIZE, "%s", valMatch);
	}
	else
	{
		snprintf (valString, VAL_STRING_SIZE, "%s; Q=%5.3f", valMatch, q_value);
	}
	/* Add string to tree */
	
	proto_tree_add_string (tree, hf_string,
	    header_buff, 0, headerLen, valString);
}

static void
add_accept_ranges_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Must be 0 (None) or 1 (Bytes) (the 8th bit was stripped
		 * off).
		 */
		proto_tree_add_uint (tree, hf_wsp_header_accept_ranges,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Token-text.
		 */
		proto_tree_add_string (tree, hf_wsp_header_accept_ranges_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * Not valid.
	 */
	fprintf(stderr, "dissect_wsp: Accept-Ranges is neither None, Bytes, nor Token-text\n");
	return;
}

static void
add_cache_control_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	int offset = 0;
	int subvalueLen;
	int subvalueOffset;
	guint value;
	proto_item *ti;
	proto_tree *parameter_tree;
	proto_tree *field_names_tree;
	guint delta_secs;

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * No-cache, No-store, Max-age, Max-stale, Min-fresh,
		 * Only-if-cached, Public, Private, No-transform,
		 * Must-revalidate, Proxy-revalidate, or S-maxage.
		 */
		proto_tree_add_uint (tree, hf_wsp_header_cache_control,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Cache-extension.
		 */
		proto_tree_add_string (tree, hf_wsp_header_cache_control_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * Value-length Cache-directive.
	 * Get first field of Cache-directive.
	 */
	valueType = get_value_type_len (value_buff, offset, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Cache-extension Parameter.
		 */
		ti = proto_tree_add_string (tree, hf_wsp_header_cache_control_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		parameter_tree = proto_item_add_subtree (ti,
		    ett_header_cache_control_parameters);

		/*
		 * Process the rest of the value as parameters.
		 */
		while (tvb_reported_length_remaining (value_buff, offset) > 0) {
			offset = add_parameter (parameter_tree, value_buff,
			    offset);
		}
		return;
	}
	if (get_integer (value_buff, subvalueOffset, subvalueLen, valueType,
	    &value) < 0)
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Cache-Control Cache-directive value");
	}
	else
	{
		switch (value) {

		case NO_CACHE:
		case PRIVATE:
			/*
			 * Loop, processing Field-names.
			 */
			ti = proto_tree_add_uint (tree,
			    hf_wsp_header_cache_control,
			    header_buff, 0, headerLen,
			    value);
			field_names_tree = proto_item_add_subtree (ti,
			    ett_header_cache_control_field_names);
			while (tvb_reported_length_remaining (value_buff, offset)
			    > 0) {
				offset = add_cache_control_field_name (tree,
			    	    value_buff, offset, value);
			}
			break;

		case MAX_AGE:
		case MAX_STALE:
		case MIN_FRESH:
		case S_MAXAGE:
			/*
			 * Get Delta-second-value.
			 */
			valueType = get_value_type_len (value_buff, offset,
			    &subvalueLen, &subvalueOffset, &offset);
			if (get_integer (value_buff, subvalueOffset,
			    subvalueLen, valueType, &delta_secs) < 0)
			{
				proto_tree_add_text (tree,
				    header_buff, 0, headerLen,
				    "Invalid Cache-Control %s Delta-second-value",
				    match_strval (value, vals_cache_control));
			}
			else
			{
				proto_tree_add_uint_format (tree,
				    hf_wsp_header_cache_control,
				    header_buff, 0, headerLen,
				    value,
				    "Cache-Control: %s %u secs",
				    match_strval (value, vals_cache_control),
				    delta_secs);
			}
			break;

		default:
			/*
			 * This should not happen, but handle it anyway.
			 */
			proto_tree_add_uint (tree,
			    hf_wsp_header_cache_control,
			    header_buff, 0, headerLen,
			    value);
			break;
		}
	}
}

static int
add_cache_control_field_name (proto_tree *tree, tvbuff_t *value_buff,
    int offset, guint cache_control_value)
{
	value_type_t valueType;
	int startOffset;
	int subvalueLen;
	int subvalueOffset;

	startOffset = offset;
	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Token-text.
		 */
		proto_tree_add_item (tree,
		    hf_wsp_header_cache_control_field_name_str,
		    value_buff, startOffset, offset - startOffset,
		    bo_little_endian);
	}
	else if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Short-integer Field-name.
		 */
		proto_tree_add_uint (tree,
		    hf_wsp_header_cache_control_field_name,
		    value_buff, startOffset, offset - startOffset,
		    subvalueLen);
	}
	else
	{
		/*
		 * Long-integer - illegal.
		 */
		proto_tree_add_text (tree,
		    value_buff, startOffset, offset - startOffset,
		    "Invalid Cache-Control %s Field-name",
		    match_strval (cache_control_value, vals_cache_control));
	}
	return offset;
}

static void
add_connection_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	int offset = 0;

	if (valueType == VALUE_LEN_SUPPLIED)
	{
		/*
		 * Invalid.
		 */
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Connection value");
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Token-text.
		 */
		proto_tree_add_string (tree,
		    hf_wsp_header_connection_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (valueLen == 0) {
		/*
		 * Close.
		 */
		proto_tree_add_uint (tree, hf_wsp_header_connection,
		    header_buff, offset, headerLen, valueLen);
		return;
	}

	/*
	 * Invalid.
	 */
	proto_tree_add_text (tree, header_buff, 0, headerLen,
	    "Invalid Connection value");
}

static void
add_pragma_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	int offset = 0;
	int subvalueLen;
	int subvalueOffset;

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Invalid.
		 */
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Pragma");
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Invalid?
		 */
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Pragma");
		return;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (valueLen == 0) {
		/*
		 * No-cache.
		 */
		proto_tree_add_string (tree, hf_wsp_header_pragma,
		    header_buff, 0, headerLen, "No-cache");
		return;
	}

	/*
	 * Value-length, followed by Parameter.
	 *
	 * Get Value-length.
	 */
	valueType = get_value_type_len (value_buff, 0, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Parameter - a text string.
		 */
		proto_tree_add_string (tree, hf_wsp_header_pragma,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, subvalueOffset, subvalueLen));
	} else {
		/*
		 * Parameter - numeric; illegal?
		 */
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Pragma");
	}
}

static void
add_transfer_encoding_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	int offset = 0;

	if (valueType == VALUE_LEN_SUPPLIED)
	{
		/*
		 * Invalid.
		 */
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid Transfer-Encoding value");
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Token-text.
		 */
		proto_tree_add_string (tree,
		    hf_wsp_header_transfer_encoding_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (valueLen == 0) {
		/*
		 * Chunked.
		 */
		proto_tree_add_uint (tree, hf_wsp_header_transfer_encoding,
		    header_buff, offset, headerLen, valueLen);
		return;
	}

	/*
	 * Invalid.
	 */
	proto_tree_add_text (tree, header_buff, 0, headerLen,
	    "Invalid Transfer Encoding value");
}

static void
add_warning_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	int offset = 0;
	proto_item *ti;
	proto_tree *warning_tree;
	int subvalueLen;
	int subvalueOffset;
	guint8 code;

	/*
	 * Put the items under a header.
	 * XXX - make the text of the item summarize the elements.
	 */
	ti = proto_tree_add_item (tree, hf_wsp_header_warning,
	    header_buff, 0, headerLen, bo_little_endian);
	warning_tree = proto_item_add_subtree(ti, ett_header_warning);

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Warn-code (Short-integer).
		 */
		proto_tree_add_uint (warning_tree, hf_wsp_header_warning_code,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		proto_item_append_text (ti, ": %s", match_strval(valueLen, vals_wsp_warning_code));
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Invalid.
		 */
		proto_tree_add_text (warning_tree, header_buff, 0, headerLen,
		    "Invalid Warning (all text)");
		return;
	}

	/*
	 * Warning-value; Warn-code, followed by Warn-agent, followed by
	 * Warn-text.
	 */
	/*
	 * Get Short-integer Warn-code.
	 */
	valueType = get_value_type_len (value_buff, offset, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType != VALUE_IN_LEN)
	{
		/*
		 * Not a Short-integer.
		 */
		proto_tree_add_text (warning_tree, value_buff, subvalueOffset,
		    subvalueLen, "Invalid Warn-code (not a Short-integer)");
		return;
	}
	code = subvalueLen;
	proto_tree_add_uint (warning_tree, hf_wsp_header_warning_code,
	    value_buff, subvalueOffset, 1,
	    subvalueLen);	/* subvalueLen is the value */

	/*
	 * Warn-agent; must be text.
	 */
	valueType = get_value_type_len (value_buff, offset, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType != VALUE_IS_TEXT_STRING)
	{
		/*
		 * Not text.
		 */
		proto_tree_add_text (warning_tree, value_buff, subvalueOffset,
		    subvalueLen, "Invalid Warn-agent (not a text string)");
		return;
	}
	proto_tree_add_item (warning_tree,
		hf_wsp_header_warning_agent,
		value_buff, subvalueOffset, subvalueLen, bo_little_endian);

	/*
	 * Warn-text; must be text.
	 */
	valueType = get_value_type_len (value_buff, offset, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType != VALUE_IS_TEXT_STRING)
	{
		/*
		 * Not text.
		 */
		proto_tree_add_text (warning_tree, value_buff, subvalueOffset,
		    subvalueLen, "Invalid Warn-text (not a text string)");
		return;
	}
	proto_tree_add_item (warning_tree,
		hf_wsp_header_warning_text,
		value_buff, subvalueOffset, subvalueLen, bo_little_endian);
	/* Now create the summary warning header */
	proto_item_append_text (ti, ": %s %s",
			val_to_str (code, vals_wsp_warning_code_short, "%u"),
			tvb_get_ptr (value_buff, subvalueOffset, subvalueLen));
}

static void
add_accept_application_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	guint value;

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Application-id-value; numeric, so it's App-assigned-code.
		 */
		proto_tree_add_uint (tree, hf_wsp_header_accept_application,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Uri-value.
		 */
		proto_tree_add_string (tree, hf_wsp_header_accept_application_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (valueLen == 0) {
		/*
		 * Any-application.
		 */
		proto_tree_add_string (tree, hf_wsp_header_accept_application_str,
			header_buff, 0, headerLen,
			"*");
		return;
	}

	/*
	 * Integer-value, hence App-assigned-code.
	 */
	if (get_integer (value_buff, 0, valueLen, valueType, &value) < 0)
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
			"Invalid Accept-Application App-assigned-code");
	}
	else
	{
		proto_tree_add_uint (tree, hf_wsp_header_accept_application,
		    header_buff, 0, headerLen, value);
	}
}

static void
add_wap_application_id_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen)
{
	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Must application-id (the 8th bit was stripped off).
		 */
		proto_tree_add_uint (tree, hf_wsp_header_wap_application_id,
		    header_buff, 0, headerLen,
		    valueLen);	/* valueLen is the value */
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Token-text.
		 */
		proto_tree_add_string (tree, hf_wsp_header_wap_application_id_str,
		    header_buff, 0, headerLen,
		    tvb_get_ptr (value_buff, 0, valueLen));
		return;
	}

	/*
	 * Not valid.
	 */
	fprintf(stderr, "dissect_wsp: Suprising format of X-Wap-Application-Id\n");
	return;
}

static void
add_credentials_value_header (proto_tree *tree, tvbuff_t *header_buff,
		int headerLen, tvbuff_t *value_buff, value_type_t valueType,
		int valueLen _U_ ,
		int hf_main, int hf_scheme,
		int hf_basic_user_id, int hf_basic_password)
{
	char *s;
	guint32 i, sLen;
	proto_item *ti;
	proto_tree *basic_tree;

	ti = proto_tree_add_item (tree, hf_main, header_buff, 0, headerLen,
			bo_little_endian);
	if (valueType == VALUE_LEN_SUPPLIED)
	{
		if (tvb_get_guint8 (value_buff, 0) == 0x80)
		{ /* Basic */
			basic_tree = proto_item_add_subtree(ti, ett_header_credentials);
			proto_tree_add_string (basic_tree, hf_scheme,
					value_buff, 0, 1, "Basic" );
			proto_item_append_text (ti, ": Basic");
			/* Now process the Basic Cookie consisting of User-Id and Password */
			i = 1;
			while (tvb_get_guint8(value_buff, i))
				i++; /* Count length of 1st string */
			/* We reached End of String at offset = i.
			 * Get the user id including trailing '\0' (end - start + 1) */
			s = (char *) tvb_get_ptr(value_buff, 1, i - 1 + 1);
			proto_tree_add_string (basic_tree, hf_basic_user_id,
					value_buff, 1, i - 1 + 1, s );
			proto_item_append_text (ti, "; user-id='%s'", s);
			sLen = ++i; /* Move to 1st byte of password string */

			while (tvb_get_guint8(value_buff, i))
				i++; /* Count length of 2nd string */
			/* We reached End of String at offset = i.
			 * Get the password including trailing '\0' (end - start + 1) */
			s = (char *) tvb_get_ptr(value_buff, sLen, i - sLen + 1);
			proto_tree_add_string (basic_tree, hf_basic_password,
					value_buff, sLen, i - sLen + 1, s );
			proto_item_append_text (ti, "; password='%s'", s);
		}
		else
		{ /* TODO: Authentication-scheme *Auth-param */
			proto_item_append_text (ti, ": (General format not yet decoded)");
		}
	}
	else
	{
		proto_item_append_text (ti, ": (Invalid header value format)");
	}
	return;
}

static void
add_capabilities (proto_tree *tree, tvbuff_t *tvb, int type)
{
	proto_item *ti;
	proto_tree *wsp_capabilities;
	guint offset = 0;
	guint offsetStr = 0;
	guint capabilitiesLen = tvb_reported_length (tvb);
	guint capabilitiesStart = 0;
	guint peek = 0;
	guint length = 0;
	guint value = 0;
	guint i;
	int ret;
	char valString[VAL_STRING_SIZE];

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: Offset is %d, size is %d\n", offset, capabilitiesLen);
#endif

	/* End of buffer */
	if (capabilitiesLen <= 0)
	{
		fprintf (stderr, "dissect_wsp: Capabilities = 0\n");
		return;
	}

#ifdef DEBUG
	fprintf (stderr, "dissect_wsp: capabilities to process\n");
#endif

	ti = proto_tree_add_item (tree, hf_wsp_capabilities_section,tvb,offset,capabilitiesLen,bo_little_endian);
	wsp_capabilities = proto_item_add_subtree( ti, ett_capabilities );

	/* Parse Headers */

	while (offset < capabilitiesLen)
	{
		/* Loop round each header */
		capabilitiesStart = offset;
		length = tvb_get_guint8 (tvb, capabilitiesStart);

		if (length >= 127)		/* length */
		{
#ifdef DEBUG
			fprintf (stderr, "dissect_wsp: capabilities length invalid %d\n",length);
#endif
			offset+=length;
			continue;
		}
		offset++;
		peek = tvb_get_guint8 (tvb, offset);
		offset++;
		switch (peek & 0x7f)
		{
			case 0x00 : /* Client-SDU-Size */
				value = get_uintvar (tvb, offset, length+capabilitiesStart+1);
				proto_tree_add_uint (wsp_capabilities, hf_wsp_capabilities_client_SDU, tvb, capabilitiesStart, length+1, value);
				break;
			case 0x01 : /* Server-SDU-Size */
				value = get_uintvar (tvb, offset, length+capabilitiesStart+1);
				proto_tree_add_uint (wsp_capabilities, hf_wsp_capabilities_server_SDU, tvb, capabilitiesStart, length+1, value);
				break;
			case 0x02 : /* Protocol Options */
				value = get_uintvar (tvb, offset, length+capabilitiesStart+1);
				i = 0;
				valString[0]=0;
				if (value & 0x80)
				{
					ret = snprintf(valString+i,VAL_STRING_SIZE-i,"%s","(Confirmed push facility) ");
					if (ret == -1 || (unsigned int) ret >= VAL_STRING_SIZE-i) {
						/*
						 * We've been truncated
						 */
						goto add_string;
					}
					i += ret;
				}
				if (value & 0x40)
				{
					if (i >= 200) {
						/* No more room. */
						goto add_string;
					}
					ret = snprintf(valString+i,VAL_STRING_SIZE-i,"%s","(Push facility) ");
					if (ret == -1 || (unsigned int) ret >= VAL_STRING_SIZE-i) {
						/*
						 * We've been truncated
						 */
						goto add_string;
					}
					i += ret;
				}
				if (value & 0x20)
				{
					if (i >= 200) {
						/* No more room. */
						goto add_string;
					}
					ret = snprintf(valString+i,VAL_STRING_SIZE-i,"%s","(Session resume facility) ");
					if (ret == -1 || (unsigned int) ret >= VAL_STRING_SIZE-i) {
						/*
						 * We've been truncated
						 */
						goto add_string;
					}
					i += ret;
				}
				if (value & 0x10)
				{
					if (i >= VAL_STRING_SIZE) {
						/* No more room. */
						goto add_string;
					}
					ret = snprintf(valString+i,VAL_STRING_SIZE-i,"%s","(Acknowledgement headers) ");
					if (ret == -1 || (unsigned int) ret >= VAL_STRING_SIZE-i) {
						/*
						 * We've been truncated
						 */
						goto add_string;
					}
					i += ret;
				}
			add_string:
				valString[VAL_STRING_SIZE-1] = '\0';
				proto_tree_add_string(wsp_capabilities, hf_wsp_capabilities_protocol_opt, tvb, capabilitiesStart, length+1, valString);
				break;
			case 0x03 : /* Method-MOR */
				value = tvb_get_guint8(tvb, offset);
				proto_tree_add_uint (wsp_capabilities, hf_wsp_capabilities_method_MOR, tvb, capabilitiesStart, length+1, value);
				break;
			case 0x04 : /* Push-MOR */
				value = tvb_get_guint8(tvb, offset);
				proto_tree_add_uint (wsp_capabilities, hf_wsp_capabilities_push_MOR, tvb, capabilitiesStart, length+1, value);
				break;
				break;
			case 0x05 : /* Extended Methods */
				offsetStr = offset;
				offset++;
				add_capability_vals(tvb, (type == CONNECT),
				    offsetStr, length, capabilitiesStart,
				    valString, sizeof valString);
				proto_tree_add_string(wsp_capabilities, hf_wsp_capabilities_extended_methods, tvb, capabilitiesStart, length+1, valString);
				break;
			case 0x06 : /* Header Code Pages */
				offsetStr = offset;
				offset++;
				add_capability_vals(tvb, (type == CONNECT),
				    offsetStr, length, capabilitiesStart,
				    valString, sizeof valString);
				proto_tree_add_string(wsp_capabilities, hf_wsp_capabilities_header_code_pages, tvb, capabilitiesStart, length+1, valString);
				break;
			case 0x07 : /* Aliases */
				break;
			default:
				proto_tree_add_text (wsp_capabilities, tvb , capabilitiesStart, length+1,
				       "Undecoded Header (0x%02X)", peek & 0x7F);
				break;
		}
		offset=capabilitiesStart+length+1;
	}
}

static void
add_capability_vals(tvbuff_t *tvb, gboolean add_string, int offsetStr,
    guint length, guint capabilitiesStart, char *valString,
    size_t valStringSize)
{
	guint i;
	int ret;
	guint value;
	guint8 c;

	i = 0;
	while ((offsetStr-capabilitiesStart) <= length)
	{
		value = tvb_get_guint8(tvb, offsetStr);
		if (i >= valStringSize) {
			/* No more room. */
			break;
		}
		if (add_string)
		{
			ret = snprintf(valString+i,valStringSize-i,
			    "(0x%02x - ",value);
		}
		else
		{
			ret = snprintf(valString+i,valStringSize-i,"(0x%02x) ",
			    value);
		}
		if (ret == -1 || (unsigned int) ret >= valStringSize-i) {
			/*
			 * We've been truncated.
			 */
			break;
		}
		i += ret;
		offsetStr++;
		if (add_string)
		{
			for (;(c = tvb_get_guint8(tvb, offsetStr))
			    && i < valStringSize - 1; i++,offsetStr++)
				valString[i] = c;
			offsetStr++;
			if (i < valStringSize - 2) {
				valString[i++] = ')';
				valString[i++] = ' ';
			}
		}
	}
	valString[i] = '\0';
}

static value_type_t
get_value_type_len (tvbuff_t *tvb, int offset, guint *valueLen,
    int *valueOffset, int *nextOffset)
{
	guint8 peek;
	guint32 len;
	guint count;

	/* Get value part of header */
	peek = tvb_get_guint8 (tvb, offset);
	if (peek <= 30)
	{
		/*
		 * The value follows "peek", and is "peek" octets long.
		 */
#ifdef DEBUG
		fprintf (stderr, "dissect_wsp: Looking for %d octets\n", peek);
#endif
		len = peek;
		*valueLen = len;	/* Length of value */
		offset++;		/* Skip the length */
		*valueOffset = offset;	/* Offset of value */
		offset += len;		/* Skip the value */
		*nextOffset = offset;	/* Offset after value */
		return VALUE_LEN_SUPPLIED;
	}
	else if (peek == 31)
	{
		/*
		 * A uintvar giving the length of the value follows
		 * "peek", and the value follows that.
		 */
#ifdef DEBUG
		fprintf (stderr, "dissect_wsp: Looking for uintvar octets\n");
#endif
		offset++;		/* Skip the uintvar indicator */
		count = 0;		/* Initialise count */
		len = tvb_get_guintvar (tvb, offset, &count);
		*valueLen = len;	/* Length of value */
		offset += count;	/* Skip the length */
		*valueOffset = offset;	/* Offset of value */
		offset += len;		/* Skip the value */
		*nextOffset = offset;	/* Offset after value */
		return VALUE_LEN_SUPPLIED;
	}
	else if (peek <= 127)
	{
		/*
		 * The value is a NUL-terminated string, and "peek"
		 * is the first octet of the string.
		 */
#ifdef DEBUG
		fprintf (stderr, "dissect_wsp: Looking for NUL-terminated string\n");
#endif
		len = tvb_strsize (tvb, offset);
		*valueLen = len;	/* Length of value */
		*valueOffset = offset;	/* Offset of value */
		offset += len;		/* Skip the value */
		*nextOffset = offset;	/* Offset after value */
		return VALUE_IS_TEXT_STRING;
	}
	else
	{
		/*
		 * "peek", with the 8th bit stripped off, is the value.
		 */
#ifdef DEBUG
		fprintf (stderr, "dissect_wsp: Value is %d\n", (peek & 0x7F));
#endif
		*valueLen = peek & 0x7F; /* Return the value itself */
		*valueOffset = offset;	/* Offset of value */
		offset++;		/* Skip the value */
		*nextOffset = offset;	/* Offset after value */
		return VALUE_IN_LEN;
	}
}

static guint
get_uintvar (tvbuff_t *tvb, guint offset, guint offsetEnd)
{
	guint value = 0;
	guint octet;

	do
	{
       		octet = tvb_get_guint8 (tvb, offset);
		offset++;
		value <<= 7;
		value += octet & 0x7f;
	}
	while ((offsetEnd > offset) && (octet & 0x80));
	return value;
}

static void
add_content_type_value (proto_tree *tree, tvbuff_t *header_buff,
    int headerOffset, int headerLen, tvbuff_t *value_buff,
    value_type_t valueType, int valueLen, int hf_numeric, int hf_string,
    guint *contentTypep, const char **contentTypeStrp)
{
	proto_item *ti;
	proto_tree *parameter_tree;
	const char *contentTypeStr;
	int offset;
	int subvalueLen;
	int subvalueOffset;
	guint value;

	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Constrained-media (Short-Integer).
		 */
		proto_tree_add_uint (tree, hf_numeric,
		    header_buff, headerOffset, headerLen,
		    valueLen);	/* valueLen is the value */

		/*
		 * Return the numerical value, and a null string value
		 * indicating that the value is numerical.
		 */
		*contentTypep = valueLen;
		*contentTypeStrp = NULL;
		return;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Constrained-media (text, i.e. Extension-Media).
		 */
		contentTypeStr = tvb_get_ptr (value_buff, 0, valueLen);
		proto_tree_add_string (tree, hf_string,
		    header_buff, headerOffset, headerLen,
		    contentTypeStr);

		/*
		 * Return the string value, and set the numerical value
		 * to 0 (as it shouldn't be used).
		 */
		*contentTypep = 0;
		*contentTypeStrp = contentTypeStr;
		return;
	}

	/*
	 * Content-general-form; Value-length, followed by Media-range,
	 * followed by optional Accept-parameters.
	 *
	 * Get Value-length.
	 */
	valueType = get_value_type_len (value_buff, 0, &subvalueLen,
	    &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Extension-Media; value is a string.
		 */
		contentTypeStr =
		    tvb_get_ptr (value_buff, subvalueOffset, subvalueLen);
		ti = proto_tree_add_string (tree, hf_string, header_buff,
		    headerOffset, headerLen, contentTypeStr);

		/*
		 * Return the string value, and set the numerical value
		 * to 0 (as it shouldn't be used).
		 */
		*contentTypep = 0;
		*contentTypeStrp = contentTypeStr;
	}
	else
	{
		/*
		 * Well-known-media; value is an Integer.
		 */
		if (get_integer (value_buff, subvalueOffset, subvalueLen,
		    valueType, &value) < 0)
		{
			proto_tree_add_text (tree, header_buff,
			    headerOffset, headerLen,
			    "Invalid integer for Well-known-media");

			/*
			 * Content type is invalid.
			 * Don't try to parse the rest of the value.
			 */
			*contentTypep = 0;
			*contentTypeStrp = NULL;
			return;
		}
		ti = proto_tree_add_uint (tree, hf_numeric,
		    header_buff, headerOffset, headerLen, value);

		/*
		 * Return the numerical value, and a null string value
		 * indicating that the value is numerical.
		 */
		*contentTypep = value;
		*contentTypeStrp = NULL;
	}

	/*
	 * Process the rest of the value as parameters.
	 */
	parameter_tree = proto_item_add_subtree(ti,
	    ett_content_type_parameters);
	while (tvb_reported_length_remaining (value_buff, offset) > 0)
		offset = add_parameter (parameter_tree, value_buff, offset);
}

guint
add_content_type (proto_tree *tree, tvbuff_t *tvb, guint offset,
    guint *contentTypep, const char **contentTypeStrp)
{
	int valueStart;
	value_type_t valueType;
	int valueTypeLen;
	guint valueLen;
	int valueOffset;
	tvbuff_t *value_buff;

	valueStart = offset;

	/*
	 * Get the value type and length (or, if the type is VALUE_IN_LEN,
	 * meaning the value is a Short-integer, get the value type
	 * and the value itself).
	 */
	valueType = get_value_type_len (tvb, valueStart, &valueLen,
	    &valueOffset, &offset);
	valueTypeLen = offset - valueStart;

	/*
	 * Get a tvbuff for the value.
	 * XXX - can valueLen be 0?
	 * XXX - cut the actual length short so that it doesn't run
	 * past the actual length of tvb.
	 */
	if (valueType != VALUE_IN_LEN) {
		value_buff = tvb_new_subset (tvb, valueOffset, valueLen,
		    valueLen);
	} else {
		/*
		 * XXX - when the last dissector is tvbuffified,
		 * so that NULL is no longer a valid tvb pointer
		 * value in "proto_tree_add" calls, just
		 * set "value_buff" to NULL.
		 *
		 * XXX - can we already do that?  I.e., will that
		 * cause us always to crash if we mistakenly try
		 * to fetch the value of a VALUE_IN_LEN item?
		 */
		value_buff = tvb_new_subset (tvb, valueStart, 0, 0);
	}

	add_content_type_value (tree, tvb, valueStart, valueTypeLen, value_buff,
	    valueType, valueLen, hf_wsp_content_type,
	    hf_wsp_content_type_str, contentTypep, contentTypeStrp);

	return offset;
}

static void
add_integer_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_numeric, guint8 headerType)
{
	add_integer_value_header_common (tree, header_buff, headerLen,
	    value_buff, valueType, valueLen, hf_numeric, headerType,
	    vals_field_names);
}

static void
add_openwave_integer_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_numeric, guint8 headerType)
{
	add_integer_value_header_common (tree, header_buff, headerLen,
	    value_buff, valueType, valueLen, hf_numeric, headerType,
	    vals_openwave_field_names);
}

static void
add_integer_value_header_common (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_numeric, guint8 headerType,
    const value_string *vals)
{
	guint value;

	if (get_integer (value_buff, 0, valueLen, valueType, &value) < 0)
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid %s integer value",
		    match_strval (headerType, vals));
	}
	else
	{
		proto_tree_add_uint (tree, hf_numeric,
		    header_buff, 0, headerLen, value);
	}
}

static void
add_string_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_string, guint8 headerType)
{
	add_string_value_header_common (tree, header_buff, headerLen,
	    value_buff, valueType, valueLen, hf_string, headerType,
	    vals_field_names);
}

static void
add_openwave_string_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_string, guint8 headerType)
{
	add_string_value_header_common (tree, header_buff, headerLen,
	    value_buff, valueType, valueLen, hf_string, headerType,
	    vals_openwave_field_names);
}

static void
add_string_value_header_common (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_string, guint8 headerType,
    const value_string *vals)
{
	if (valueType != VALUE_IS_TEXT_STRING)
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid %s string value",
		    match_strval (headerType, vals));
	}
	else
	{
		proto_tree_add_string (tree, hf_string, header_buff,
			0, headerLen, tvb_get_ptr (value_buff, 0, valueLen));
	}
}

static void
add_quoted_string_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_string, guint8 headerType)
{
	if (valueType != VALUE_IS_TEXT_STRING)
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid %s quoted string value",
		    match_strval (headerType, vals_field_names));
	}
	else
	{
		proto_tree_add_string (tree, hf_string, header_buff,
			0, headerLen, tvb_get_ptr (value_buff, 1, valueLen - 1));
	}
}

/* Utility function to add a date value to the protocol tree */
static void
add_date_value_header (proto_tree *tree, tvbuff_t *header_buff,
    int headerLen, tvbuff_t *value_buff, value_type_t valueType,
    int valueLen, int hf_time, guint8 headerType)
{
	guint secs;
	nstime_t timeValue;

	/* Attempt to get the date value from the buffer */
	if (get_integer (value_buff, 0, valueLen, valueType, &secs) == 0)
	{
		/*
		 * Fill in the "struct timeval", and add it to the
		 * protocol tree.
		 * Note: this will succeed even if it's a Short-integer.
		 * A Short-integer would work, but, as the time values
		 * are UNIX seconds-since-the-Epoch value, and as
		 * there weren't WAP phones or Web servers back in
		 * late 1969/early 1970, they're unlikely to be used.
		 */
		timeValue.secs = secs;
		timeValue.nsecs = 0;
		proto_tree_add_time (tree, hf_time, header_buff, 0,
			headerLen, &timeValue);
	}
	else
	{
		proto_tree_add_text (tree, header_buff, 0, headerLen,
		    "Invalid %s date value",
		    match_strval (headerType, vals_field_names));
	}
}

static int
add_parameter (proto_tree *tree, tvbuff_t *value_buff, int offset)
{
	int startOffset;
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint value;

	startOffset = offset;
	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Untyped-parameter.
		 */
		offset = add_untyped_parameter (tree, value_buff, startOffset, offset);
		return offset;
	}

	/*
	 * Well-known-parameter-token.
	 */
	if (get_integer (value_buff, subvalueOffset,
	    subvalueLen, valueType, &value) < 0)
	{
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset,
		    "Invalid Well-known-parameter-token");
		return offset;
	}

	switch (value) {

		case 0x01:	/* WSP 1.1 encoding - Charset: Well-known-charset */
			offset = add_parameter_charset (tree, value_buff, startOffset, offset);
			break;

		case 0x03:	/* WSP 1.1 encoding - Type: Integer-value */
			offset = add_parameter_type (tree, value_buff, startOffset, offset);
			break;

		case 0x05:	/* WSP 1.1 encoding - Name: Text-string */
		case 0x17:	/* WSP 1.4 encoding - Name: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_name, "Name");
			break;

		case 0x06:	/* WSP 1.1 encoding - Filename: Text-string */
		case 0x18:	/* WSP 1.4 encoding - Filename: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_filename, "Filename");
			break;

		case 0x09:	/* WSP 1.2 encoding - Type (special): Constrained-encoding */
			offset = add_constrained_encoding(tree, value_buff, startOffset, offset);
			break;

		case 0x0A:	/* WSP 1.2 encoding - Start: Text-string */
		case 0x19:	/* WSP 1.4 encoding - Start (with multipart/related): Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_start, "Start");
			break;

		case 0x0B:	/* WSP 1.2 encoding - Start-info: Text-string */
		case 0x1A:	/* WSP 1.4 encoding - Start-info (with multipart/related): Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_start_info, "Start-info");
			break;

		case 0x0C:	/* WSP 1.3 encoding - Comment: Text-string */
		case 0x1B:	/* WSP 1.4 encoding - Comment: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_comment, "Comment");
			break;

		case 0x0D:	/* WSP 1.3 encoding - Domain: Text-string */
		case 0x1C:	/* WSP 1.4 encoding - Domain: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_domain, "Domain");
			break;

		case 0x0F:	/* WSP 1.3 encoding - Path: Text-string */
		case 0x1D:	/* WSP 1.4 encoding - Path: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_path, "Path");
			break;

		case 0x11:	/* WSP 1.4 encoding - SEC: Short-integer (OCTET) */
			proto_tree_add_uint (tree, hf_wsp_parameter_sec, value_buff, startOffset, 2,
					tvb_get_guint8 (value_buff, startOffset+1) & 0x7F);
			offset++;
			break;
		
		case 0x12:	/* WSP 1.4 encoding - MAC: Text-value */
			offset = add_parameter_text (tree, value_buff, startOffset, offset,
					    hf_wsp_parameter_mac, "MAC");
			break;
		
		case 0x00:	/* WSP 1.1 encoding - Q: Q-value */
		case 0x02:	/* WSP 1.1 encoding - Level: Version-value */
		case 0x07:	/* WSP 1.1 encoding - Differences: Field-name */
		case 0x08:	/* WSP 1.1 encoding - Padding: Short-integer */
		case 0x0E:	/* WSP 1.3 encoding - Max-Age: Delta-seconds-value */
		case 0x10:	/* WSP 1.3 encoding - Secure: No-value */
		case 0x13:	/* WSP 1.4 encoding - Creation-date: Date-value */
		case 0x14:	/* WSP 1.4 encoding - Modification-date: Date-value */
		case 0x15:	/* WSP 1.4 encoding - Read-date: Date-value */
		case 0x16:	/* WSP 1.4 encoding - Size: Integer-value */
		default:
			break;
	}

	return offset;
}

static int
add_untyped_parameter (proto_tree *tree, tvbuff_t *value_buff, int startOffset,
    int offset)
{
	const guint8 *token;
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint value;
	int vOffset = offset;

	token = tvb_get_ptr (value_buff, startOffset, offset - startOffset);
	/*
	 * Now an Untyped-value; either an Integer-value or a Text-value.
	 */
	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Text-value.
		 */
		if ((offset - vOffset) == 1) {
			/*
			 * No-value.  (stringSize includes the terminating
			 * null byte, so an empty string has a size of 1.)
			 */
			proto_tree_add_text (tree, value_buff, startOffset,
			    offset - startOffset,
			    "%s", token);
			return offset;
		}
		proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset,
		    "%s: %s", token,
		    tvb_get_ptr (value_buff, vOffset, offset - vOffset));
	}
	else
	{
		/*
		 * Integer-value.
		 */
		if (get_integer (value_buff, subvalueOffset, subvalueLen,
		    valueType, &value) == 0)
		{
			proto_tree_add_text (tree, value_buff, startOffset,
			    offset - startOffset,
			    "%s: %u", token, value);
		}
		else
		{
			proto_tree_add_text (tree, value_buff, startOffset,
			    offset - startOffset,
			    "%s: Invalid Integer-value", token);
		}
	}
	return offset;
}

static int
add_parameter_charset (proto_tree *tree, tvbuff_t *value_buff, int startOffset,
    int offset)
{
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint value;

	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Integer-value.
		 */
		proto_tree_add_uint (tree, hf_wsp_parameter_well_known_charset,
		    value_buff, startOffset, offset - startOffset,
		    subvalueLen);	/* subvalueLen is the value */
		return offset;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * Invalid.
		 */
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset, "Invalid Well-known charset");
		return offset;
	}

	/*
	 * First byte had the 8th bit set.
	 */
	if (subvalueLen == 0) {
		/*
		 * Any-charset.
		 * XXX - add this as a field?
		 */
		proto_tree_add_text (tree, value_buff, startOffset,
		    offset- startOffset, "*");
		return offset;
	}

	if (get_integer(value_buff, subvalueOffset, subvalueLen,
	    valueType, &value) == -1) {
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset, "Length %u not handled in Well-known charset",
		        subvalueLen);
	} else {
		proto_tree_add_uint (tree, hf_wsp_parameter_well_known_charset,
		    value_buff, startOffset, offset - startOffset, value);
	}
	return offset;
}

static int
add_constrained_encoding (proto_tree *tree, tvbuff_t *value_buff, int startOffset,
    int offset)
{
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint value;

	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType == VALUE_IN_LEN)
	{
		/*
		 * Integer-value, invalid
		 */
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset, "Invalid multipart type parameter");
		return offset;
	}
	if (valueType == VALUE_IS_TEXT_STRING)
	{
		/*
		 * type-label.
		 */
		proto_tree_add_string (tree, hf_wsp_parameter_upart_type,
		    value_buff, startOffset, offset - startOffset,
		    tvb_get_ptr (value_buff, subvalueOffset, subvalueLen));
		return offset;
	}
	/*
	 * First byte had the 8th bit set.
	 */
	get_integer(value_buff, subvalueOffset, subvalueLen, valueType, &value);
	proto_tree_add_uint (tree, hf_wsp_parameter_upart_type_value,
	    value_buff, startOffset, offset - startOffset, value);
	return offset;
}

static int
add_parameter_type (proto_tree *tree, tvbuff_t *value_buff, int startOffset,
    int offset)
{
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;
	guint value;

	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (get_integer(value_buff, subvalueOffset, subvalueLen,
	    valueType, &value) == -1) {
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset, "Invalid type");
	} else {
		proto_tree_add_uint (tree, hf_wsp_parameter_type, value_buff,
		    startOffset, offset - startOffset, value);
	}
	return offset;
}

static int
add_parameter_text (proto_tree *tree, tvbuff_t *value_buff, int startOffset,
    int offset, int hf_string, const char *paramName)
{
	value_type_t valueType;
	int subvalueLen;
	int subvalueOffset;

	valueType = get_value_type_len (value_buff, offset,
	    &subvalueLen, &subvalueOffset, &offset);
	if (valueType != VALUE_IS_TEXT_STRING) {
	    	proto_tree_add_text (tree, value_buff, startOffset,
		    offset - startOffset, "Invalid %s", paramName);
	} else {
		proto_tree_add_string (tree, hf_string, value_buff,
			    startOffset, offset - startOffset,
			    tvb_get_ptr (value_buff, subvalueOffset, subvalueLen));
	}
	return offset;
}

void
add_post_data (proto_tree *tree, tvbuff_t *tvb, guint contentType,
    const char *contentTypeStr)
{
	guint offset = 0;
	guint variableStart = 0;
	guint variableEnd = 0;
	guint valueStart = 0;
	guint valueEnd = 0;
	guint8 peek = 0;
	proto_item *ti;
	proto_tree *sub_tree;

	/* VERIFY ti = proto_tree_add_item (tree, hf_wsp_post_data,tvb,offset,-1,bo_little_endian); */
	ti = proto_tree_add_item (tree, hf_wsp_post_data,tvb,offset,-1,bo_little_endian);
	sub_tree = proto_item_add_subtree(ti, ett_post);

	if (contentTypeStr == NULL && contentType == 0x12)
	{
		/*
		 * URL Encoded data.
		 * Iterate through post data.
		 */
		for (offset = 0; offset < tvb_reported_length (tvb); offset++)
		{
			peek = tvb_get_guint8 (tvb, offset);
			if (peek == '=')
			{
				variableEnd = offset;
				valueStart = offset+1;
			}
			else if (peek == '&')
			{
				if (variableEnd > 0)
				{
					add_post_variable (sub_tree, tvb, variableStart, variableEnd, valueStart, offset);
				}
				variableStart = offset+1;
				variableEnd = 0;
				valueStart = 0;
				valueEnd = 0;
			}
		}

		/* See if there's outstanding data */
		if (variableEnd > 0)
		{
			add_post_variable (sub_tree, tvb, variableStart, variableEnd, valueStart, offset);
		}
	}
	else if ((contentType == 0x22) || (contentType == 0x23) || (contentType == 0x23) || (contentType == 0x24) ||
		 (contentType == 0x25) || (contentType == 0x26) || (contentType == 0x33))
	{
		add_multipart_data(sub_tree, tvb);
	}
}

static void
add_post_variable (proto_tree *tree, tvbuff_t *tvb, guint variableStart, guint variableEnd, guint valueStart, guint valueEnd)
{
	int variableLength = variableEnd-variableStart;
	int valueLength = 0;
	char *variableBuffer;
	char *valueBuffer;

	variableBuffer = g_malloc (variableLength+1);
	strncpy (variableBuffer, tvb_get_ptr (tvb, variableStart, variableLength), variableLength);
	variableBuffer[variableLength] = 0;

	if (valueEnd < valueStart)
	{
		valueBuffer = g_malloc (1);
		valueBuffer[0] = 0;
		valueEnd = valueStart;
	}
	else
	{
		valueLength = valueEnd-valueStart;
		valueBuffer = g_malloc (valueLength+1);
		strncpy (valueBuffer, tvb_get_ptr (tvb, valueStart, valueLength), valueLength);
		valueBuffer[valueLength] = 0;
	}

	/* Check for variables with no value */
	if (valueStart >= tvb_reported_length (tvb))
	{
		valueStart = tvb_reported_length (tvb);
		valueEnd = valueStart;
	}
	valueLength = valueEnd-valueStart;

	proto_tree_add_text (tree, tvb, variableStart, valueEnd-variableStart, "%s: %s", variableBuffer, valueBuffer);

	g_free (variableBuffer);
	g_free (valueBuffer);
}

static void
add_multipart_data (proto_tree *tree, tvbuff_t *tvb)
{
	int		 offset = 0;
	guint		 nextOffset;
	guint		 nEntries = 0;
	guint		 count;
	guint		 HeadersLen;
	guint		 DataLen;
	guint		 contentType = 0;
	const char	*contentTypeStr;
	tvbuff_t	*tmp_tvb;
	int		 partnr = 1;
	int		 part_start;

	proto_item	*sub_tree = NULL,
			*ti;
	proto_tree	*mpart_tree;

	nEntries = tvb_get_guintvar (tvb, offset, &count);
	offset += count;
	if (nEntries)
	{
		sub_tree = proto_tree_add_text(tree, tvb, offset - count, 0,
					"Multipart body");
		proto_item_add_subtree(sub_tree, ett_mpartlist);
	}
	while (nEntries--)
	{
		part_start = offset;
		HeadersLen = tvb_get_guintvar (tvb, offset, &count);
		offset += count;
		DataLen = tvb_get_guintvar (tvb, offset, &count);
		offset += count;
		ti = proto_tree_add_uint(sub_tree, hf_wsp_mpart, tvb, part_start,
					HeadersLen + DataLen + (offset - part_start), partnr);
		mpart_tree = proto_item_add_subtree(ti, ett_multiparts);
		nextOffset = add_content_type (mpart_tree, tvb, offset, &contentType, &contentTypeStr);
		HeadersLen -= (nextOffset - offset);
		if (HeadersLen > 0)
		{
			tmp_tvb = tvb_new_subset (tvb, nextOffset, HeadersLen, HeadersLen);
			add_headers (mpart_tree, tmp_tvb);
		}
		offset = nextOffset + HeadersLen;
		proto_tree_add_item (mpart_tree, hf_wsp_multipart_data, tvb, offset, DataLen, bo_little_endian);
		offset += DataLen;
		partnr++;
	}
}

static gint
get_integer (tvbuff_t *tvb, guint offset, guint valueLength,
    value_type_t valueType, guint *value)
{
	if (valueType == VALUE_IS_TEXT_STRING) {
		/*
		 * Not valid.
		 */
		return -1;
	}

	if (valueType == VALUE_IN_LEN) {
		/*
		 * Short-integer.
		 */
		*value = valueLength;
		return 0;
	}

	/*
	 * Long-integer.
	 */
	switch (valueLength)
	{
		case 1:
			*value = tvb_get_guint8(tvb, offset);
			break;
		case 2:
			*value = tvb_get_ntohs(tvb, offset);
			break;
		case 3:
		        *value = tvb_get_ntoh24(tvb, offset);
			break;
		case 4:
			*value = tvb_get_ntohl(tvb, offset);
			break;
		default:
		        /* TODO: Need to read peek octets */
		        *value = 0;
		        fprintf (stderr, "dissect_wsp: get_integer size %u NYI\n", valueLength);
	        	break;
	}
	return 0;
}

/* Register the protocol with Ethereal */
void
proto_register_wsp(void)
{

/* Setup list of header fields */
	static hf_register_info hf[] = {
		{ &hf_wsp_header_tid,
			{ 	"Transaction ID",
				"wsp.TID",
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"Transaction ID", HFILL
			}
		},
		{ &hf_wsp_header_pdu_type,
			{ 	"PDU Type",
				"wsp.pdu_type",
				 FT_UINT8, BASE_HEX, VALS( vals_pdu_type ), 0x00,
				"PDU Type", HFILL
			}
		},
		{ &hf_wsp_version_major,
			{ 	"Version (Major)",
				"wsp.version.major",
				 FT_UINT8, BASE_DEC, NULL, 0xF0,
				"Version (Major)", HFILL
			}
		},
		{ &hf_wsp_version_minor,
			{ 	"Version (Minor)",
				"wsp.version.minor",
				 FT_UINT8, BASE_DEC, NULL, 0x0F,
				"Version (Minor)", HFILL
			}
		},
		{ &hf_wsp_capability_length,
			{ 	"Capability Length",
				"wsp.capability.length",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Capability Length", HFILL
			}
		},
		{ &hf_wsp_header_length,
			{ 	"Headers Length",
				"wsp.headers_length",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Headers Length", HFILL
			}
		},
		{ &hf_wsp_capabilities_section,
			{ 	"Capabilities",
				"wsp.capabilities",
				 FT_NONE, BASE_DEC, NULL, 0x00,
				"Capabilities", HFILL
			}
		},
		{ &hf_wsp_headers_section,
			{ 	"Headers",
				"wsp.headers",
				 FT_NONE, BASE_DEC, NULL, 0x00,
				"Headers", HFILL
			}
		},
		{ &hf_wsp_header,
			{ 	"Header",
				"wsp.headers.header",
				 FT_NONE, BASE_DEC, NULL, 0x00,
				"Header", HFILL
			}
		},
		{ &hf_wsp_header_uri_len,
			{ 	"URI Length",
				"wsp.uri_length",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"URI Length", HFILL
			}
		},
		{ &hf_wsp_header_uri,
			{ 	"URI",
				"wsp.uri",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"URI", HFILL
			}
		},
		{ &hf_wsp_server_session_id,
			{ 	"Server Session ID",
				"wsp.server.session_id",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Server Session ID", HFILL
			}
		},
		{ &hf_wsp_header_status,
			{ 	"Status",
				"wsp.reply.status",
				 FT_UINT8, BASE_HEX, VALS( vals_status ), 0x00,
				"Status", HFILL
			}
		},
		{ &hf_wsp_content_type,
			{ 	"Content Type",
				"wsp.content_type.type",
				 FT_UINT8, BASE_HEX, VALS ( vals_content_types ), 0x00,
				"Content Type", HFILL
			}
		},
		{ &hf_wsp_content_type_str,
			{ 	"Content Type",
				"wsp.content_type.type.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Content Type", HFILL
			}
		},
		{ &hf_wsp_parameter_well_known_charset,
			{ 	"Charset",
				"wsp.content_type.parameter.charset",
				 FT_UINT16, BASE_HEX, VALS ( vals_character_sets ), 0x00,
				"Charset", HFILL
			}
		},
		{ &hf_wsp_parameter_type,
			{ 	"Type",
				"wsp.content_type.parameter.type",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Type", HFILL
			}
		},
		{ &hf_wsp_parameter_name,
			{ 	"Name",
				"wsp.content_type.parameter.name",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Name", HFILL
			}
		},
		{ &hf_wsp_parameter_filename,
			{ 	"Filename",
				"wsp.content_type.parameter.filename",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Filename", HFILL
			}
		},
		{ &hf_wsp_parameter_start,
			{ 	"Start",
				"wsp.content_type.parameter.start",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Start", HFILL
			}
		},
		{ &hf_wsp_parameter_start_info,
			{ 	"Start-info",
				"wsp.content_type.parameter.start_info",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Start-info", HFILL
			}
		},
		{ &hf_wsp_parameter_comment,
			{ 	"Comment",
				"wsp.content_type.parameter.comment",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Comment", HFILL
			}
		},
		{ &hf_wsp_parameter_domain,
			{ 	"Domain",
				"wsp.content_type.parameter.domain",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Domain", HFILL
			}
		},
		{ &hf_wsp_parameter_path,
			{ 	"Path",
				"wsp.content_type.parameter.path",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Path", HFILL
			}
		},
		{ &hf_wsp_parameter_sec,
			{ 	"SEC",
				"wsp.content_type.parameter.sec",
				 FT_UINT8, BASE_HEX, VALS (vals_wsp_parameter_sec), 0x00,
				"SEC parameter (Content-Type: application/vnd.wap.connectivity-wbxml)", HFILL
			}
		},
		{ &hf_wsp_parameter_mac,
			{ 	"MAC",
				"wsp.content_type.parameter.mac",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"MAC parameter (Content-Type: application/vnd.wap.connectivity-wbxml)", HFILL
			}
		},
		{ &hf_wsp_parameter_upart_type,
			{ 	"Type",
				"wsp.content_type.parameter.upart.type",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Multipart type", HFILL
			}
		},
		{ &hf_wsp_parameter_upart_type_value,
			{ 	"Type",
				"wsp.content_type.parameter.upart.type.int",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Multipart type (int value)", HFILL
			}
		},
		{ &hf_wsp_reply_data,
			{ 	"Data",
				"wsp.reply.data",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Data", HFILL
			}
		},
		{ &hf_wsp_header_shift_code,
			{ 	"Shift code",
				"wsp.header.shift",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"Header code page shift code", HFILL
			}
		},
		{ &hf_wsp_header_accept,
			{ 	"Accept",
				"wsp.header.accept",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_UINT8, BASE_HEX, VALS ( vals_content_types ), 0x00,
				"Accept", HFILL
			}
		},
		{ &hf_wsp_header_accept_str,
			{ 	"Accept",
				"wsp.header.accept.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Accept", HFILL
			}
		},
		{ &hf_wsp_header_accept_application,
			{ 	"Accept-Application",
				"wsp.header.accept_application",
				 FT_UINT32, BASE_HEX, NULL, 0x00,
				"Accept-Application", HFILL
			}
		},
		{ &hf_wsp_header_accept_application_str,
			{ 	"Accept-Application",
				"wsp.header.accept_application.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Accept-Application", HFILL
			}
		},
		{ &hf_wsp_header_accept_charset,
			{ 	"Accept-Charset",
				"wsp.header.accept_charset",
				 FT_UINT16, BASE_HEX, VALS ( vals_character_sets ), 0x00,
				"Accept-Charset", HFILL
			}
		},
		{ &hf_wsp_header_accept_charset_str,
			{ 	"Accept-Charset",
				"wsp.header.accept_charset.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Accept-Charset", HFILL
			}
		},
		{ &hf_wsp_header_accept_language,
			{ 	"Accept-Language",
				"wsp.header.accept_language",
				 FT_UINT8, BASE_HEX, VALS ( vals_languages ), 0x00,
				"Accept-Language", HFILL
			}
		},
		{ &hf_wsp_header_accept_language_str,
			{ 	"Accept-Language",
				"wsp.header.accept_language.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Accept-Language", HFILL
			}
		},
		{ &hf_wsp_header_accept_ranges,
			{ 	"Accept-Ranges",
				"wsp.header.accept_ranges",
				 FT_UINT8, BASE_HEX, VALS ( vals_accept_ranges ), 0x00,
				"Accept-Ranges", HFILL
			}
		},
		{ &hf_wsp_header_accept_ranges_str,
			{ 	"Accept-Ranges",
				"wsp.header.accept_ranges.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Accept-Ranges", HFILL
			}
		},
		{ &hf_wsp_header_age,
			{ 	"Age",
				"wsp.header.age",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Age", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_push_addr,
			{ 	"x-up-proxy-push-addr",
				"wsp.header.x-up-proxy-push-addr",
				 FT_BYTES, BASE_HEX, NULL, 0x00,
				"The network address and port number that the handset can receive UPNOTIFY pushes on.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_push_accept,
			{ 	"x-up-proxy-push-accept",
				"wsp.header.x-up-proxy-push-accept",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"The content types that the handset can handle when sent via UPNOTIFY pushes.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_push_seq,
			{ 	"x-up-proxy-push-seq",
				"wsp.header.x-up-proxy-push-seq",
				 FT_UINT16, BASE_DEC, NULL, 0x00,
				"Specifies the sequence number of the last UPNOTIFY push sent.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_notify,
			{ 	"x-up-proxy-notify",
				"wsp.header.x-up-proxy-notify",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates to the handset that there are pending UPNOTIFY pushes waiting.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_operator_domain,
			{ 	"x-up-proxy-operator-domain",
				"wsp.header.x-up-proxy-operator-domain",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Indicates the Trusted Provisioning Domain.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_home_page,
			{ 	"x-up-proxy-home-page",
				"wsp.header.x-up-proxy-home-page",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Specifies the server-assigned home page URL.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_has_color,
			{ 	"x-up-devcap-has-color",
				"wsp.header.x-up-devcap-has-color",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the handset supports colour.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_num_softkeys,
			{ 	"x-up-devcap-num-softkeys",
				"wsp.header.x-up-devcap-num-softkeys",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"The number of softkeys that can be displayed on the handset.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_softkey_size,
			{ 	"x-up-devcap-softkey-size",
				"wsp.header.x-up-devcap-softkey-size",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"The number of chars that can be displayed on a softkey label.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_screen_chars,
			{ 	"x-up-devcap-screen-chars",
				"wsp.header.x-up-devcap-screen-chars",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"The height and width of the handset's display in characters.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_screen_pixels,
			{ 	"x-up-devcap-screen-pixels",
				"wsp.header.x-up-devcap-screen-pixels",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"The height and width of the handset's display in pixels.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_em_size,
			{ 	"x-up-devcap-em-size",
				"wsp.header.x-up-devcap-em-size",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"The height and width of an uppercase M in pixels in a handset.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_screen_depth,
			{ 	"x-up-devcap-screen-depth",
				"wsp.header.x-up-devcap-screen-depth",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"The colour/gray depth of the display in bits.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_immed_alert,
			{ 	"x-up-devcap-immed-alert",
				"wsp.header.x-up-devcap-immed-alert",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the handset has support for immediate UPNOTIFY alerts.", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_net_ask,
			{ 	"x-up-proxy-net-ask",
				"wsp.header.x-up-proxy-net-ask",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates to browser if circuit switched call is allowed without user interaction", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_uplink_version,
			{ 	"x-up-proxy-uplink-version",
				"wsp.header.x-up-proxy-uplink-version",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Version of the MAG WAP gateway", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_tod,
			{ 	"x-up-proxy-tod",
				"wsp.header.x-up-proxy-tod",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Time of day", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_ba_enable,
			{ 	"x-up-proxy-ba-enable",
				"wsp.header.x-up-proxy-ba-enable",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the WAP gateway should cache basic authentication details on behalf of the handset", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_ba_realm,
			{ 	"x-up-proxy-ba-realm",
				"wsp.header.x-up-proxy-ba-realm",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Indicates the realm within which basic authentication credentials apply", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_redirect_enable,
			{ 	"x-up-proxy-redirect-enable",
				"wsp.header.x-up-proxy-redirect-enable",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the handset wants the WAP gateway to handle HTTP redirects on its behalf", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_request_uri,
			{ 	"x-up-proxy-request-uri",
				"wsp.header.x-up-proxy-request-uri",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Indicates to the handset that the previous request was redirected to the specified URI", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_redirect_status,
			{ 	"x-up-proxy-redirect-status",
				"wsp.header.x-up-proxy-redirect-status",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Indicates the status of a redirect performed on behalf of a handset", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_trans_charset,
			{ 	"x-up-proxy-trans-charset",
				"wsp.header.x-up-proxy-trans-charset",
				 FT_UINT16, BASE_HEX, VALS ( vals_character_sets ), 0x00,
				"For POSTs indicates the charset encoding of a document", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_trans_charset_str,
			{ 	"x-up-proxy-trans-charset",
				"wsp.header.x-up-proxy-trans-charset.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"For POSTs indicates the charset encoding of a document", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_linger,
			{ 	"x-up-proxy-linger",
				"wsp.header.x-up-proxy-linger",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates the circuit linger time in seconds", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_client_id,
			{ 	"x-up-proxy-client-id",
				"wsp.header.x-up-proxy-client-id",
				 FT_BYTES, BASE_DEC, NULL, 0x00,
				"The ClientId of the handset", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_enable_trust,
			{ 	"x-up-proxy-enable-trust",
				"wsp.header.x-up-proxy-enable-trust",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates whether to enable Trusted Provisioning Domain", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_trust_old,
			{ 	"x-up-proxy-trust-old",
				"wsp.header.x-up-proxy-trust-old",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the content being returned was received from within the Trusted Provisioning Domain", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_trust,
			{ 	"x-up-proxy-trust",
				"wsp.header.x-up-proxy-trust",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the content being returned was received from within the Trusted Provisioning Domain", HFILL
			}
		},
		{ &hf_wsp_header_openwave_proxy_bookmark,
			{ 	"x-up-proxy-bookmark",
				"wsp.header.x-up-proxy-bookmark",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Specifies the URL to use for server-side bookmarks", HFILL
			}
		},
		{ &hf_wsp_header_openwave_devcap_gui,
			{ 	"x-up-devcap-gui",
				"wsp.header.x-up-devcap-gui",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Indicates if the handset has a GUI", HFILL
			}
		},
		{ &hf_wsp_header_bearer_indication,
			/*
			 * XXX - I'm assuming that the bearer indication is
			 * just a bearer type.
			 */
			{ 	"Bearer-indication",
				"wsp.header.bearer_indication",
				 FT_UINT32, BASE_HEX, VALS(vals_bearer_types), 0x00,
				"Bearer-indication", HFILL
			}
		},
		{ &hf_wsp_header_cache_control,
			{ 	"Cache-Control",
				"wsp.header.cache_control",
				 FT_UINT8, BASE_HEX, VALS ( vals_cache_control ), 0x00,
				"Cache-Control", HFILL
			}
		},
		{ &hf_wsp_header_cache_control_str,
			{ 	"Cache-Control",
				"wsp.header.cache_control.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Cache-Control", HFILL
			}
		},
		{ &hf_wsp_header_cache_control_field_name,
			{ 	"Field Name",
				"wsp.header.cache_control.field_name",
				 FT_UINT8, BASE_HEX, VALS ( vals_field_names ), 0x00,
				"Cache-Control field name", HFILL
			}
		},
		{ &hf_wsp_header_cache_control_field_name_str,
			{ 	"Field Name",
				"wsp.header.cache_control.field_name.str",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Cache-Control field name", HFILL
			}
		},
		{ &hf_wsp_header_connection,
			{ 	"Connection",
				"wsp.header.connection",
				 FT_UINT8, BASE_HEX, VALS ( vals_connection ), 0x00,
				"Connection", HFILL
			}
		},
		{ &hf_wsp_header_connection_str,
			{ 	"Connection",
				"wsp.header.connection_str",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Connection", HFILL
			}
		},
		{ &hf_wsp_header_content_length,
			{ 	"Content-Length",
				"wsp.header.content_length",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"Content-Length", HFILL
			}
		},
		{ &hf_wsp_header_date,
			{ 	"Date",
				"wsp.header.date",
				 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
				"Date", HFILL
			}
		},
		{ &hf_wsp_header_etag,
			{ 	"Etag",
				"wsp.header.etag",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Etag", HFILL
			}
		},
		{ &hf_wsp_header_expires,
			{ 	"Expires",
				"wsp.header.expires",
				 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
				"Expires", HFILL
			}
		},
		{ &hf_wsp_header_last_modified,
			{ 	"Last-Modified",
				"wsp.header.last_modified",
				 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
				"Last-Modified", HFILL
			}
		},
		{ &hf_wsp_header_location,
			{ 	"Location",
				"wsp.header.location",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Location", HFILL
			}
		},
		{ &hf_wsp_header_if_modified_since,
			{ 	"If-Modified-Since",
				"wsp.header.if_modified_since",
				 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
				"If-Modified-Since", HFILL
			}
		},
		{ &hf_wsp_header_pragma,
			{ 	"Pragma",
				"wsp.header.pragma",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"pragma", HFILL
			}
		},
		{ &hf_wsp_header_authorization,
			{ 	"Authorization",
				"wsp.header.authorization",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Authorization", HFILL
			}
		},
		{ &hf_wsp_header_authorization_scheme,
			{ 	"Authentication scheme",
				"wsp.header.authorization.scheme",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Authorization: Authentication Scheme", HFILL
			}
		},
		{ &hf_wsp_header_authorization_user_id,
			{ 	"User-ID",
				"wsp.header.authorization.user_id",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Authorization: Basic: User-ID", HFILL
			}
		},
		{ &hf_wsp_header_authorization_password,
			{ 	"Password",
				"wsp.header.authorization.password",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Authorization: Basic: Password", HFILL
			}
		},
		{ &hf_wsp_header_proxy_authorization,
			{ 	"Proxy-Authorization",
				"wsp.header.proxy_authorization",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Proxy-Authorization", HFILL
			}
		},
		{ &hf_wsp_header_proxy_authorization_scheme,
			{ 	"Authentication scheme",
				"wsp.header.proxy_authorization.scheme",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Proxy-Authorization: Authentication Scheme", HFILL
			}
		},
		{ &hf_wsp_header_proxy_authorization_user_id,
			{ 	"User-Id",
				"wsp.header.proxy_authorization.user_id",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Proxy-Authorization: Basic: User-ID", HFILL
			}
		},
		{ &hf_wsp_header_proxy_authorization_password,
			{ 	"Password",
				"wsp.header.proxy_authorization.password",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Proxy-Authorization: Basic: Password", HFILL
			}
		},
		{ &hf_wsp_header_www_authenticate,
			{ 	"WWW-Authenticate",
				"wsp.header.www-authenticate",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Authenticate", HFILL
			}
		},
		{ &hf_wsp_header_proxy_authenticate,
			{ 	"Proxy-Authenticate",
				"wsp.header.proxy_authenticate",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Proxy-Authenticate", HFILL
			}
		},
		{ &hf_wsp_header_profile,
			{ 	"Profile",
				"wsp.header.profile",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Profile", HFILL
			}
		},
		{ &hf_wsp_header_server,
			{ 	"Server",
				"wsp.header.server",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Server", HFILL
			}
		},
		{ &hf_wsp_header_transfer_encoding,
			{ 	"Transfer Encoding",
				"wsp.header.transfer_enc",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_UINT8, BASE_HEX, VALS ( vals_transfer_encoding ), 0x00,
				"Transfer Encoding", HFILL
			}
		},
		{ &hf_wsp_header_transfer_encoding_str,
			{ 	"Transfer Encoding",
				"wsp.header.transfer_enc_str",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Transfer Encoding", HFILL
			}
		},
		{ &hf_wsp_header_user_agent,
			{ 	"User-Agent",
				"wsp.header.user_agent",
				 /*FT_NONE, BASE_DEC, NULL, 0x00,*/
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"User-Agent", HFILL
			}
		},
		{ &hf_wsp_header_via,
			{ 	"Via",
				"wsp.header.via",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Via", HFILL
			}
		},
		{ &hf_wsp_header_wap_application_id,
			{ 	"X-Wap-Application-Id",
				"wsp.header.wap_application_id",
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"WAP application id", HFILL
			}
		},
		{ &hf_wsp_header_wap_application_id_str,
			{ 	"X-Wap-Application-Id",
				"wsp.header.wap_application_id.string",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"WAP application id", HFILL
			}
		},
		{ &hf_wsp_header_warning,
			{ 	"Warning",
				"wsp.header.warning",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Warning", HFILL
			}
		},
		{ &hf_wsp_header_warning_code,
			{ 	"Warning Code",
				"wsp.header.warning.code",
				 FT_UINT8, BASE_DEC, VALS (vals_wsp_warning_code), 0x00,
				"Warning Code", HFILL
			}
		},
		{ &hf_wsp_header_warning_agent,
			{ 	"Warning Agent",
				"wsp.header.warning.agent",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Warning Agent", HFILL
			}
		},
		{ &hf_wsp_header_warning_text,
			{ 	"Warning Text",
				"wsp.header.warning.text",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Warning Text", HFILL
			}
		},
		{ &hf_wsp_header_application_header,
			{ 	"Application Header",
				"wsp.header.application_header",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Application Header", HFILL
			}
		},
		{ &hf_wsp_header_application_value,
			{ 	"Application Header Value",
				"wsp.header.application_header.value",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Application Header Value", HFILL
			}
		},
		{ &hf_wsp_header_content_ID,
			{ 	"Content-ID",
				"wsp.header.content-id",
				 FT_STRING, BASE_NONE, NULL, 0x00,
				"Content-ID", HFILL
			}
		},
		{ &hf_wsp_header_x_wap_tod,
			{ 	"X-WAP.TOD",
				"wsp.header.x_wap_tod",
				 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
				"X-WAP.TOD", HFILL
			}
		},
		{ &hf_wsp_capabilities_client_SDU,
			{	"Client SDU",
				"wsp.capabilities.client_SDU",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Client SDU", HFILL
			}
		},
		{ &hf_wsp_capabilities_server_SDU,
			{	"Server SDU",
				"wsp.capabilities.server_SDU",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Server SDU", HFILL
			}
		},
		{ &hf_wsp_capabilities_protocol_opt,
			{	"Protocol Options",
				"wsp.capabilities.protocol_opt",
				 FT_STRING, BASE_HEX, NULL, 0x00,
				"Protocol Options", HFILL
			}
		},
		{ &hf_wsp_capabilities_method_MOR,
			{	"Method MOR",
				"wsp.capabilities.method_mor",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Method MOR", HFILL
			}
		},
		{ &hf_wsp_capabilities_push_MOR,
			{	"Push MOR",
				"wsp.capabilities.push_mor",
				 FT_UINT8, BASE_DEC, NULL, 0x00,
				"Push MOR", HFILL
			}
		},
		{ &hf_wsp_capabilities_extended_methods,
			{	"Extended Methods",
				"wsp.capabilities.extend_methods",
				 FT_STRING, BASE_HEX, NULL, 0x00,
				"Extended Methods", HFILL
			}
		},
		{ &hf_wsp_capabilities_header_code_pages,
			{	"Header Code Pages",
				"wsp.capabilities.code_pages",
				 FT_STRING, BASE_HEX, NULL, 0x00,
				"Header Code Pages", HFILL
			}
		},
		{ &hf_wsp_capabilities_aliases,
			{	"Aliases",
				"wsp.capabilities.aliases",
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"Aliases", HFILL
			}
		},
		{ &hf_wsp_post_data,
			{ 	"Data (Post)",
				"wsp.post.data",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Post Data", HFILL
			}
		},
		{ &hf_wsp_push_data,
			{ 	"Push Data",
				"wsp.push.data",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"Push Data", HFILL
			}
		},
		{ &hf_wsp_multipart_data,
			{ 	"Data in this part",
				"wsp.multipart.data",
				 FT_NONE, BASE_NONE, NULL, 0x00,
				"The data of 1 MIME-multipart part.", HFILL
			}
		},
		{ &hf_wsp_mpart,
			{ 	"Part",
				"wsp.multipart",
				 FT_UINT32, BASE_DEC, NULL, 0x00,
				"MIME part of multipart data.", HFILL
			}
		},
		{ &hf_wsp_redirect_flags,
			{ 	"Flags",
				"wsp.redirect_flags",
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"Redirect Flags", HFILL
			}
		},
		{ &hf_wsp_redirect_permanent,
			{ 	"Permanent Redirect",
				"wsp.redirect_flags.permanent",
				 FT_BOOLEAN, 8, TFS(&yes_no_truth), PERMANENT_REDIRECT,
				"Permanent Redirect", HFILL
			}
		},
		{ &hf_wsp_redirect_reuse_security_session,
			{ 	"Reuse Security Session",
				"wsp.redirect_flags.reuse_security_session",
				 FT_BOOLEAN, 8, TFS(&yes_no_truth), REUSE_SECURITY_SESSION,
				"Permanent Redirect", HFILL
			}
		},
		{ &hf_wsp_redirect_afl,
			{ 	"Flags/Length",
				"wsp.redirect_afl",
				 FT_UINT8, BASE_HEX, NULL, 0x00,
				"Redirect Address Flags/Length", HFILL
			}
		},
		{ &hf_wsp_redirect_afl_bearer_type_included,
			{ 	"Bearer Type Included",
				"wsp.redirect_afl.bearer_type_included",
				 FT_BOOLEAN, 8, TFS(&yes_no_truth), BEARER_TYPE_INCLUDED,
				"Redirect Address bearer type included", HFILL
			}
		},
		{ &hf_wsp_redirect_afl_port_number_included,
			{ 	"Port Number Included",
				"wsp.redirect_afl.port_number_included",
				 FT_BOOLEAN, 8, TFS(&yes_no_truth), PORT_NUMBER_INCLUDED,
				"Redirect Address port number included", HFILL
			}
		},
		{ &hf_wsp_redirect_afl_address_len,
			{ 	"Address Len",
				"wsp.redirect_afl.address_len",
				 FT_UINT8, BASE_DEC, NULL, ADDRESS_LEN,
				"Redirect Address Length", HFILL
			}
		},
		{ &hf_wsp_redirect_bearer_type,
			{ 	"Bearer Type",
				"wsp.redirect_bearer_type",
				 FT_UINT8, BASE_HEX, VALS(vals_bearer_types), 0x0,
				"Redirect Bearer Type", HFILL
			}
		},
		{ &hf_wsp_redirect_port_num,
			{ 	"Port Number",
				"wsp.redirect_port_num",
				 FT_UINT16, BASE_DEC, NULL, 0x0,
				"Redirect Port Number", HFILL
			}
		},
		{ &hf_wsp_redirect_ipv4_addr,
			{ 	"IP Address",
				"wsp.redirect_ipv4_addr",
				 FT_IPv4, BASE_NONE, NULL, 0x0,
				"Redirect Address (IP)", HFILL
			}
		},
		{ &hf_wsp_redirect_ipv6_addr,
			{ 	"IPv6 Address",
				"wsp.redirect_ipv6_addr",
				 FT_IPv6, BASE_NONE, NULL, 0x0,
				"Redirect Address (IPv6)", HFILL
			}
		},
		{ &hf_wsp_redirect_addr,
			{ 	"Address",
				"wsp.redirect_addr",
				 FT_BYTES, BASE_NONE, NULL, 0x0,
				"Redirect Address", HFILL
			}
		},
	};

/* Setup protocol subtree array */
	static gint *ett[] = {
		&ett_wsp,
		&ett_content_type_parameters,
		&ett_header,
		&ett_headers,
		&ett_header_warning,
		&ett_header_cache_control_parameters,
		&ett_header_cache_control_field_names,
		&ett_capabilities,
		&ett_post,
		&ett_content_type,
		&ett_redirect_flags,
		&ett_redirect_afl,
		&ett_multiparts,
		&ett_mpartlist,
		&ett_header_credentials,
	};

/* Register the protocol name and description */
	proto_wsp = proto_register_protocol(
		"Wireless Session Protocol",   	/* protocol name for use by ethereal */
		"WSP",                          /* short version of name */
		"wap-wsp"                   	/* Abbreviated protocol name, should Match IANA
						    < URL:http://www.isi.edu/in-notes/iana/assignments/port-numbers/ >
						  */
	);

/* Required function calls to register the header fields and subtrees used  */
	proto_register_field_array(proto_wsp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));

	register_dissector("wsp-co", dissect_wsp_fromwap_co, proto_wsp);
	register_dissector("wsp-cl", dissect_wsp_fromwap_cl, proto_wsp);
	wsp_dissector_table = register_dissector_table("wsp.content_type.type",
	    "WSP content type", FT_UINT8, BASE_HEX);
	register_heur_dissector_list("wsp", &heur_subdissector_list);

	wsp_fromudp_handle = create_dissector_handle(dissect_wsp_fromudp,
	    proto_wsp);
};

void
proto_reg_handoff_wsp(void)
{
	/*
	 * Get a handle for the WBXML dissector.
	 */
	wbxml_handle = find_dissector("wbxml");

	/*
	 * And get a handle for the WTP-over-UDP dissector.
	 */
	wtp_fromudp_handle = find_dissector("wtp-udp");

	/* Only connection-less WSP has no previous handler */
	dissector_add("udp.port", UDP_PORT_WSP, wsp_fromudp_handle);
	dissector_add("udp.port", UDP_PORT_WSP_PUSH, wsp_fromudp_handle);

	/* SMPP dissector can also carry WSP */
	dissector_add("smpp.udh.port", UDP_PORT_WSP, wsp_fromudp_handle);
	dissector_add("smpp.udh.port", UDP_PORT_WSP_PUSH, wsp_fromudp_handle);

	/* This dissector is also called from the WTP and WTLS dissectors */
}