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
|
/* packet-slsk.c
* Routines for SoulSeek Protocol dissection
* Copyright 2003, Christian Wagner <Christian.Wagner@stud.uni-karlsruhe.de>
* Institute of Telematics - University of Karlsruhe
* part of this work supported by
* Deutsche Forschungsgemeinschaft (DFG) Grant Number FU448/1
*
* SoulSeek Protocol dissector based on protocol descriptions from SoleSeek Project:
* http://cvs.sourceforge.net/viewcvs.py/soleseek/SoleSeek/doc/protocol.html?rev=HEAD
* Updated for SoulSeek client version 151
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <epan/expert.h>
#include "packet-tcp.h"
void proto_register_slsk(void);
void proto_reg_handoff_slsk(void);
static dissector_handle_t slsk_handle;
/* Initialize the protocol and registered fields */
static int proto_slsk = -1;
static int hf_slsk_integer = -1;
static int hf_slsk_string = -1;
static int hf_slsk_byte = -1;
static int hf_slsk_message_length = -1;
static int hf_slsk_message_code = -1;
static int hf_slsk_embedded_message_type = -1;
static int hf_slsk_client_ip = -1;
/* static int hf_slsk_server_ip = -1; */
static int hf_slsk_directory_name = -1;
static int hf_slsk_username = -1;
static int hf_slsk_password = -1;
static int hf_slsk_version = -1;
static int hf_slsk_login_successful = -1;
static int hf_slsk_login_message = -1;
static int hf_slsk_port = -1;
static int hf_slsk_ip = -1;
static int hf_slsk_user_exists = -1;
static int hf_slsk_status_code = -1;
static int hf_slsk_room = -1;
static int hf_slsk_chat_message = -1;
static int hf_slsk_users_in_room = -1;
static int hf_slsk_token = -1;
static int hf_slsk_connection_type = -1;
static int hf_slsk_chat_message_id = -1;
static int hf_slsk_timestamp = -1;
static int hf_slsk_search_text = -1;
static int hf_slsk_folder_count = -1;
static int hf_slsk_file_count = -1;
static int hf_slsk_average_speed = -1;
static int hf_slsk_download_number = -1;
static int hf_slsk_files = -1;
static int hf_slsk_directories = -1;
static int hf_slsk_slotsfull = -1;
static int hf_slsk_place_in_queue = -1;
static int hf_slsk_number_of_rooms = -1;
static int hf_slsk_filename = -1;
static int hf_slsk_filename_ext = -1;
static int hf_slsk_directory = -1;
static int hf_slsk_size = -1;
/* static int hf_slsk_checksum = -1; */
static int hf_slsk_code = -1;
static int hf_slsk_number_of_users = -1;
static int hf_slsk_number_of_days = -1;
static int hf_slsk_transfer_direction = -1;
static int hf_slsk_user_description = -1;
static int hf_slsk_picture_exists = -1;
static int hf_slsk_picture = -1;
/* static int hf_slsk_user_uploads = -1; */
static int hf_slsk_total_uploads = -1;
static int hf_slsk_queued_uploads = -1;
static int hf_slsk_slots_available = -1;
static int hf_slsk_allowed = -1;
static int hf_slsk_compr_packet = -1;
static int hf_slsk_parent_min_speed = -1;
static int hf_slsk_parent_speed_connection_ratio = -1;
static int hf_slsk_seconds_parent_inactivity_before_disconnect = -1;
static int hf_slsk_seconds_server_inactivity_before_disconnect = -1;
static int hf_slsk_nodes_in_cache_before_disconnect = -1;
static int hf_slsk_seconds_before_ping_children = -1;
static int hf_slsk_recommendation = -1;
static int hf_slsk_user = -1;
static int hf_slsk_ranking = -1;
static int hf_slsk_compressed_packet_length = -1;
static int hf_slsk_uncompressed_packet_length = -1;
static int hf_slsk_num_directories = -1;
static int hf_slsk_upload_speed = -1;
static int hf_slsk_in_queue = -1;
static int hf_slsk_num_slotsfull_records = -1;
static int hf_slsk_num_recommendations = -1;
static int hf_slsk_num_files = -1;
static int hf_slsk_num_strings = -1;
static int hf_slsk_file_code = -1;
static int hf_slsk_file_size1 = -1;
static int hf_slsk_file_size2 = -1;
static int hf_slsk_file_num_attributes = -1;
static int hf_slsk_file_attribute_type = -1;
static int hf_slsk_file_attribute_value = -1;
static int hf_slsk_free_upload_slots = -1;
static int hf_slsk_bytes = -1;
static int hf_slsk_same_recommendation = -1;
static int hf_slsk_number_of_priv_users = -1;
static int hf_slsk_num_parent_address = -1;
/* Initialize the subtree pointers */
static gint ett_slsk = -1;
static gint ett_slsk_compr_packet = -1;
static gint ett_slsk_directory = -1;
static gint ett_slsk_file = -1;
static gint ett_slsk_file_attribute = -1;
static gint ett_slsk_user = -1;
static gint ett_slsk_recommendation = -1;
static gint ett_slsk_room = -1;
static gint ett_slsk_string = -1;
static expert_field ei_slsk_unknown_data = EI_INIT;
static expert_field ei_slsk_zlib_decompression_failed = EI_INIT;
static expert_field ei_slsk_decompression_failed = EI_INIT;
#define SLSK_TCP_PORT_RANGE "2234,2240,5534"
/* desegmentation of SoulSeek Message over TCP */
static gboolean slsk_desegment = TRUE;
#ifdef HAVE_ZLIB
static gboolean slsk_decompress = TRUE;
#else
static gboolean slsk_decompress = FALSE;
#endif
static const value_string slsk_tcp_msgs[] = {
{ 1, "Login"},
{ 2, "Set Wait Port"},
{ 3, "Get Peer Address"},
{ 4, "Get Shared File List"},
{ 5, "User Exists / Shared File List"},
{ 7, "Get User Status"},
{ 9, "File Search Result"},
{ 13, "Say ChatRoom"},
{ 14, "Join Room"},
{ 15, "Leave Room / User Info Request"},
{ 16, "User Joined Room / User Info Reply"},
{ 17, "User Left Room"},
{ 18, "Connect To Peer"},
{ 22, "Message User"},
{ 23, "Message User Ack"},
{ 26, "File Search"},
{ 28, "Set Status"},
{ 32, "Ping"},
{ 34, "Update Upload Speed"},
{ 35, "Shared Files & Folders"},
{ 36, "Get User Stats / Folder Contents Request"},
{ 37, "Folder Contents Response"},
{ 40, "Queued Downloads / Transfer Request"},
{ 41, "Transfer Response"},
{ 42, "Placehold Upload"},
{ 43, "Queue Upload"},
{ 44, "Place In Queue"},
{ 46, "Upload Failed"},
{ 50, "Queue Failed / Own Recommendation"},
{ 51, "Add Things I like / Place In Queue Request"},
{ 52, "Remove Things I like"},
{ 54, "Get Recommendations"},
{ 55, "Type 55"},
{ 56, "Get Global Rankings"},
{ 57, "Get User Recommendations"},
{ 58, "Admin Command"},
{ 60, "Place In Line Response"},
{ 62, "Room Added"},
{ 63, "Room Removed"},
{ 64, "Room List"},
{ 65, "Exact File Search"},
{ 66, "Admin Message"},
{ 67, "Global User List"},
{ 68, "Tunneled Message"},
{ 69, "Privileged User List"},
{ 71, "Get Parent List"},
{ 73, "Type 73"},
{ 83, "Parent Min Speed"},
{ 84, "Parent Speed Connection Ratio"},
{ 86, "Parent Inactivity Before Disconnect"},
{ 87, "Server Inactivity Before Disconnect"},
{ 88, "Nodes In Cache Before Disconnect"},
{ 90, "Seconds Before Ping Children"},
{ 91, "Add To Privileged"},
{ 92, "Check Privileges"},
{ 93, "Embedded Message"},
{ 100, "Become Parent"},
{ 102, "Random Parent Addresses"},
{ 103, "Send Wishlist Entry"},
{ 104, "Type 104"},
{ 110, "Get Similar Users"},
{ 111, "Get Recommendations for Item"},
{ 112, "Get Similar Users for Item"},
{ 1001, "Can't Connect To Peer"},
{ 0, NULL }
};
static const value_string slsk_status_codes[] = {
{ -1, "Unknown"},
{ 0, "Offline"},
{ 1, "Away"},
{ 2, "Online"},
{ 0, NULL }
};
static const value_string slsk_transfer_direction[] = {
{ 0, "Download"},
{ 1, "Upload"},
{ 0, NULL }
};
static const value_string slsk_yes_no[] = {
{ 0, "No"},
{ 1, "Yes"},
{ 0, NULL }
};
static const value_string slsk_attr_type[] = {
{ 0, "Bitrate"},
{ 1, "Length"},
{ 2, "VBR"},
{ 0, NULL }
};
static const char* connection_type(char con_type[]) {
if (strlen(con_type) != 1) return "Unknown";
if (con_type[0] == 'D') return "Distributed Search";
if (con_type[0] == 'P') return "Peer Connection"; /* "File Search Result / User Info Request / Get Shared File List" */
if (con_type[0] == 'F') return "File Transfer";
return "Unknown";
}
// NOLINTNEXTLINE(misc-no-recursion)
static gboolean check_slsk_format(tvbuff_t *tvb, packet_info *pinfo, int offset, const char format[]){
/*
* Returns TRUE if tvbuff beginning at offset matches a certain format
* The format is given by an array of characters standing for a special field type
* i - integer (4 bytes)
* b - byte (1 byte)
* s - string (string_length + 4 bytes)
*
* * - can be used at the end of a format to ignore any following bytes
*/
switch ( format[0] ) {
case 'i':
if (tvb_captured_length_remaining(tvb, offset) < 4) return FALSE;
offset += 4;
break;
case 'b':
if (tvb_captured_length_remaining(tvb, offset) < 1) return FALSE;
offset += 1;
break;
case 's':
if (tvb_captured_length_remaining(tvb, offset) < 4) return FALSE;
if (tvb_captured_length_remaining(tvb, offset) < (int)tvb_get_letohl(tvb, offset)+4) return FALSE;
offset += tvb_get_letohl(tvb, offset)+4;
break;
case '*':
return TRUE;
default:
return FALSE;
}
if (format[1] == '\0' ) {
if (tvb_captured_length_remaining(tvb, offset) > 0) /* Checks for additional bytes at the end */
return FALSE;
return TRUE;
}
increment_dissection_depth(pinfo);
gboolean valid = check_slsk_format(tvb, pinfo, offset, &format[1]);
decrement_dissection_depth(pinfo);
return valid;
}
static const char* get_message_type(tvbuff_t *tvb, packet_info *pinfo) {
/*
* Checks if the Message Code is known.
* If unknown checks if the Message Code is stored in a byte.
* Returns the Message Type.
*/
int msg_code = tvb_get_letohl(tvb, 4);
const gchar *message_type = try_val_to_str(msg_code, slsk_tcp_msgs);
if (message_type == NULL) {
if (check_slsk_format(tvb, pinfo, 4, "bisis"))
message_type = "Distributed Search";
else if (check_slsk_format(tvb, pinfo, 4, "bssi"))
message_type = "Peer Init";
else if (check_slsk_format(tvb, pinfo, 4, "bi"))
message_type = "Pierce Fw";
else
message_type = "Unknown";
}
return message_type;
}
static guint get_slsk_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
guint32 msg_len;
msg_len = tvb_get_letohl(tvb, offset);
/* That length doesn't include the length field itself; add that in. */
msg_len += 4;
return msg_len;
}
/* Code to actually dissect the packets */
static int dissect_slsk_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti, *ti_len, *ti_subtree, *ti_subtree2;
proto_tree *slsk_tree, *subtree, *subtree2, *subtree3;
int offset = 0, i, j;
guint32 msg_len, msg_code;
guint8 *str;
int str_len, start_offset, start_offset2;
int comprlen = 0, uncomprlen = 0, uncompr_tvb_offset = 0;
int i2 = 0, j2 = 0;
int i3 = 0, j3 = 0;
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "slsk");
/* This field shows up as the "Info" column in the display */
col_set_str(pinfo->cinfo, COL_INFO, "SoulSeek Message");
col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", get_message_type(tvb, pinfo));
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_slsk, tvb, 0, -1, ENC_NA);
slsk_tree = proto_item_add_subtree(ti, ett_slsk);
/* Continue adding tree items to process the packet here */
ti_len = proto_tree_add_item_ret_uint(slsk_tree, hf_slsk_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &msg_len);
offset += 4;
msg_code = tvb_get_letohl(tvb, offset);
switch (msg_code) {
case 1:
if (check_slsk_format(tvb, pinfo, offset, "issi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Login (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_password, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ibs") || check_slsk_format(tvb, pinfo, offset, "ibsi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Login Reply (Code: %02d)", msg_code);
offset += 4;
i=tvb_get_guint8(tvb, offset);
proto_tree_add_item(slsk_tree, hf_slsk_login_successful, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_login_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
if (i == 1){
proto_tree_add_item(slsk_tree, hf_slsk_client_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
}
break;
case 2:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Set Wait Port (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 3:
if (check_slsk_format(tvb, pinfo, offset, "isii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Peer Address Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Peer Address (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 4:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Shared File List (Code: %02d)", msg_code);
offset += 4;
}
break;
case 5:
if (check_slsk_format(tvb, pinfo, offset, "isb")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Exists Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_user_exists, tvb, offset, 1, ENC_NA);
offset += 1;
}
else if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Exists Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Shared File List (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
proto_tree_add_expert(slsk_tree, pinfo, &ei_slsk_zlib_decompression_failed, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_reported_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "i*")) {
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_directories, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "si*")) {
start_offset = uncompr_tvb_offset;
subtree = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_directory, &ti_subtree, "Directory #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(subtree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i2+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j3);
uncompr_tvb_offset += 4;
for (i3 = 0; i3 < j3; i3++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i3+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree, uncompr_tvb_offset-start_offset);
} else {
break; /* invalid format */
}
}
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 7:
if (check_slsk_format(tvb, pinfo, offset, "isi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Status Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Status (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 9:
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"File Search Result (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
expert_add_info(pinfo, ti, &ei_slsk_decompression_failed);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_captured_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "sii*")) {
proto_tree_add_item_ret_length(slsk_compr_packet_tree, hf_slsk_username, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_NA, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_token, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i2+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_free_upload_slots, uncompr_tvb, uncompr_tvb_offset, 1, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 1;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_upload_speed, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_in_queue, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 13:
if (check_slsk_format(tvb, pinfo, offset, "isss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Say ChatRoom (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "iss")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Say ChatRoom (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 14:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Join/Add Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Join Room User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "iiiii*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 20, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_slotsfull_records, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 15:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server & Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Leave Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Info Request (Code: %02d)", msg_code);
offset += 4;
}
break;
case 16:
if (check_slsk_format(tvb, pinfo, offset, "issiiiiiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Joined Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_total_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "isbiib") || check_slsk_format(tvb, pinfo, offset, "isbsiib")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Info Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user_description, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_picture_exists, tvb, offset, 1, ENC_NA);
offset += 1;
if ( tvb_get_guint8(tvb, offset -1 ) == 1 ) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_picture, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
proto_tree_add_item(slsk_tree, hf_slsk_total_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_queued_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_slots_available, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 17:
if (check_slsk_format(tvb, pinfo, offset, "iss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Left Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 18:
if (check_slsk_format(tvb, pinfo, offset, "iiss")) {
/* Client-to-Server */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
}
else if (check_slsk_format(tvb, pinfo, offset, "issiii")) {
/* Server-to-Client */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 22:
if (check_slsk_format(tvb, pinfo, offset, "iss")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Send (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "iiiss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Receive (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_chat_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 23:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Receive Ack (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_chat_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 26:
if (check_slsk_format(tvb, pinfo, offset, "iis")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 28:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Set Status (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 32:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Ping (Code: %02d)", msg_code);
offset += 4;
}
break;
case 34:
if (check_slsk_format(tvb, pinfo, offset, "isi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Update Upload Speed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 35:
if (check_slsk_format(tvb, pinfo, offset, "iii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Shared Files & Folders (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_folder_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_file_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 36:
if (check_slsk_format(tvb, pinfo, offset, "isiiiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Stats Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Client */
/* Client-to-Server: send after login successful */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Stats (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "iis")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Folder Contents Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 37:
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Folder Contents Response (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
proto_tree_add_expert(slsk_tree, pinfo, &ei_slsk_zlib_decompression_failed, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_captured_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "isi*")) {
guint32 len;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_token, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(slsk_compr_packet_tree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &len);
uncompr_tvb_offset += len;
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_directories, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "si*")) {
start_offset = uncompr_tvb_offset;
subtree = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_directory, &ti_subtree, "Directory #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(subtree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i2+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j3);
uncompr_tvb_offset += 4;
for (i3 = 0; i3 < j3; i3++) {
if (check_slsk_format(uncompr_tvb, pinfo, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i3+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree, uncompr_tvb_offset-start_offset);
} else {
break; /* invalid format */
}
}
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 40:
if (check_slsk_format(tvb, pinfo, offset, "isi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queued Downloads (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "iiis") || check_slsk_format(tvb, pinfo, offset, "iiisii")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Transfer Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_transfer_direction, tvb, offset, 4, ENC_LITTLE_ENDIAN, &i);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
if (i == 1){
proto_tree_add_item(slsk_tree, hf_slsk_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
break;
case 41:
if (check_slsk_format(tvb, pinfo, offset, "iibs") || check_slsk_format(tvb, pinfo, offset, "iibii") || check_slsk_format(tvb, pinfo, offset, "iib")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Transfer Response (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
i = tvb_get_guint8(tvb, offset);
proto_tree_add_item(slsk_tree, hf_slsk_allowed, tvb, offset, 1, ENC_NA);
offset += 1;
if ( i == 1 ) {
if ( tvb_reported_length_remaining(tvb, offset) == 8 ) {
proto_tree_add_item(slsk_tree, hf_slsk_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
} else {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
break;
case 42:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Placehold Upload (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 43:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queue Upload (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 44:
if (check_slsk_format(tvb, pinfo, offset, "isi")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Place In Queue (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_place_in_queue, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 46:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Upload Failed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 50:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Make Own Recommendation (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Remove Own Recommendation (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "iss")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queue Failed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 51:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server: "Add Things I like" */
/* Client-to-Client: "Place In Queue Request" */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Add Things I like / Place In Queue Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 52:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Remove Things I like (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 54:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 55:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 55 (Code: %02d)", msg_code);
offset += 4;
}
break;
case 56:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Global Rankings (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Global Rankings Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 57:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Recommendations (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Recommendations Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 58:
if (check_slsk_format(tvb, pinfo, offset, "isi*")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Admin Command (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_strings, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_string, &ti_subtree, "String #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 60:
if (check_slsk_format(tvb, pinfo, offset, "isii")) {
/* Client-to-Server & Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Place In Line Response (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_place_in_queue, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 62:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room Added (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 63:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room Removed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 64:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_rooms, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_room, &ti_subtree, "Room #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_room, &ti_subtree, "Room #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 65:
if (check_slsk_format(tvb, pinfo, offset, "isissiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Exact File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_bytes, tvb, offset, 16, ENC_NA);
offset += 12;
}
else if (check_slsk_format(tvb, pinfo, offset, "iissiiib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Exact File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_bytes, tvb, offset, 13, ENC_NA);
offset += 13;
}
break;
case 66:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Admin Message (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 67:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Global User List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi*")) { /* same as case 14 */
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Global User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "iiiii*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 20, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_slotsfull_records, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 68:
if (check_slsk_format(tvb, pinfo, offset, "isiiiis")) {
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Tunneled Message (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 69:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Privileged User List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Privileged User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_priv_users, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
}
break;
case 71:
if (check_slsk_format(tvb, pinfo, offset, "ib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Parent List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_byte, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 73:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 73 (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 83:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Min Speed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_parent_min_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 84:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Speed Connection Ratio (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_parent_speed_connection_ratio, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 86:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Inactivity Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_parent_inactivity_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 87:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Server Inactivity Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_server_inactivity_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 88:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Nodes In Cache Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_nodes_in_cache_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 90:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Seconds Before Ping Children (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_before_ping_children, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 91:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Add To Privileged (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 92:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Check Privileges (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Check Privileges Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_number_of_days, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 93:
if (check_slsk_format(tvb, pinfo, offset, "ibisis")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Embedded Message (Code: %02d)", msg_code);
offset += 4;
if ( tvb_get_guint8(tvb, offset) == 3 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_embedded_message_type, tvb, offset, 1, msg_code,
"Distributed Search (Byte: %d)", 3);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
break;
case 100:
if (check_slsk_format(tvb, pinfo, offset, "ib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Become Parent (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_byte, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 102:
if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Random Parent Addresses (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_parent_address, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "sii*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
break;
case 103:
if (check_slsk_format(tvb, pinfo, offset, "iis")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Send Wishlist Entry (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 104:
if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 104 (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 110:
if (check_slsk_format(tvb, pinfo, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_users, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, &ti_subtree, "User #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_same_recommendation, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 111:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations for Item (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations for Item Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 112:
if (check_slsk_format(tvb, pinfo, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users for Item (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users for Item Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, pinfo, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
}
break;
case 1001:
if (check_slsk_format(tvb, pinfo, offset, "iis")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Can't Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, pinfo, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Can't Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
default:
if (check_slsk_format(tvb, pinfo, offset, "bisis")) {
if ( tvb_get_guint8(tvb, offset) == 3 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Distributed Search (Byte: %d)", 3);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
else if (check_slsk_format(tvb, pinfo, offset, "bssi")) {
if ( tvb_get_guint8(tvb, offset) == 1 ){
/* Client-to-Client */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Peer Init (Byte: %d)", 1);
offset += 1;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
else if (check_slsk_format(tvb, pinfo, offset, "bi")) {
if ( tvb_get_guint8(tvb, offset) == 0 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Pierce Fw (Byte: %d)", 0);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
else {
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Unknown (Code: %02d)", msg_code);
offset += 4;
}
break;
}
if(offset < (int)msg_len){
expert_add_info(pinfo, ti_len, &ei_slsk_unknown_data);
}
return tvb_captured_length(tvb);
}
static int dissect_slsk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, slsk_desegment, 4, get_slsk_pdu_len, dissect_slsk_pdu, data);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_slsk(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_slsk_integer,
{ "Integer", "slsk.integer",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_string,
{ "String", "slsk.string",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_byte,
{ "Byte", "slsk.byte",
FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_message_length,
{ "Message Length", "slsk.message.length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_message_code,
{ "Message Type", "slsk.message.code",
FT_UINT32, BASE_DEC, NULL, 0, "Message Code with type string", HFILL } },
{ &hf_slsk_embedded_message_type,
{ "Embedded Message Type", "slsk.embedded_message.code",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_client_ip,
{ "Client IP", "slsk.client.ip",
FT_IPv4, BASE_NONE, NULL, 0, "Client IP Address", HFILL } },
#if 0
{ &hf_slsk_server_ip,
{ "SoulSeek Server IP", "slsk.server.ip",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_directory_name,
{ "Directory name", "slsk.directory_name",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_username,
{ "Username", "slsk.username",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_password,
{ "Password", "slsk.password",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_version,
{ "Version", "slsk.version",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_login_successful,
{ "Login successful", "slsk.login.successful",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_login_message,
{ "Login Message", "slsk.login.message",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_port,
{ "Port Number", "slsk.port.number",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_ip,
{ "IP Address", "slsk.ip.address",
FT_IPv4, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_user_exists,
{ "User exists", "slsk.user.exists",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_status_code,
{ "Status Code", "slsk.status.code",
FT_UINT32, BASE_DEC, VALS(slsk_status_codes), 0, NULL, HFILL } },
{ &hf_slsk_room,
{ "Room", "slsk.room",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_chat_message,
{ "Chat Message", "slsk.chat.message",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_users_in_room,
{ "Users in Room", "slsk.room.users",
FT_INT32, BASE_DEC, NULL, 0, "Number of Users in Room", HFILL } },
{ &hf_slsk_token,
{ "Token", "slsk.token",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_connection_type,
{ "Connection Type", "slsk.connection.type",
FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_chat_message_id,
{ "Chat Message ID", "slsk.chat.message.id",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_timestamp,
{ "Timestamp", "slsk.timestamp",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_search_text,
{ "Search Text", "slsk.search.text",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_folder_count,
{ "Folder Count", "slsk.folder.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_count,
{ "File Count", "slsk.file.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_average_speed,
{ "Average Speed", "slsk.average.speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_download_number,
{ "Download Number", "slsk.download.number",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_files,
{ "Files", "slsk.files",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_directories,
{ "Directories", "slsk.directories",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_slotsfull,
{ "Slots full", "slsk.slots.full",
FT_UINT32, BASE_DEC, NULL, 0, "Upload Slots Full", HFILL } },
{ &hf_slsk_place_in_queue,
{ "Place in Queue", "slsk.queue.place",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_rooms,
{ "Number of Rooms", "slsk.room.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_filename,
{ "Filename", "slsk.filename",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_filename_ext,
{ "Filename ext", "slsk.filename_ext",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_directory,
{ "Directory", "slsk.directory",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_size,
{ "Size", "slsk.size",
FT_UINT32, BASE_DEC, NULL, 0, "File Size", HFILL } },
#if 0
{ &hf_slsk_checksum,
{ "Checksum", "slsk.checksum",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_code,
{ "Code", "slsk.code",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_users,
{ "Number of Users", "slsk.user.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_days,
{ "Number of Days", "slsk.day.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_transfer_direction,
{ "Transfer Direction", "slsk.transfer.direction",
FT_INT32, BASE_DEC, VALS(slsk_transfer_direction), 0, NULL, HFILL } },
{ &hf_slsk_user_description,
{ "User Description", "slsk.user.description",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_picture_exists,
{ "Picture exists", "slsk.user.picture.exists",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, "User has a picture", HFILL } },
{ &hf_slsk_picture,
{ "User Picture", "slsk.user.picture",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
#if 0
{ &hf_slsk_user_uploads,
{ "User uploads", "slsk.uploads.user",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_total_uploads,
{ "Total uploads allowed", "slsk.uploads.total",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_queued_uploads,
{ "Queued uploads", "slsk.uploads.queued",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_slots_available,
{ "Upload Slots available", "slsk.uploads.available",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_allowed,
{ "Download allowed", "slsk.user.allowed",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_compr_packet,
{ "zlib compressed packet", "slsk.compr.packet",
FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_parent_min_speed,
{ "Parent Min Speed", "slsk.parent.min.speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_parent_speed_connection_ratio,
{ "Parent Speed Connection Ratio", "slsk.parent.speed.connection.ratio",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_parent_inactivity_before_disconnect,
{ "Seconds Parent Inactivity Before Disconnect", "slsk.seconds.parent.inactivity.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_server_inactivity_before_disconnect,
{ "Seconds Server Inactivity Before Disconnect", "slsk.seconds.server.inactivity.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_nodes_in_cache_before_disconnect,
{ "Nodes In Cache Before Disconnect", "slsk.nodes.in.cache.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_before_ping_children,
{ "Seconds Before Ping Children", "slsk.seconds.before.ping.children",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_recommendation,
{ "Recommendation", "slsk.recommendation",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_user,
{ "User", "slsk.user",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_ranking,
{ "Ranking", "slsk.ranking",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_compressed_packet_length,
{ "Compressed packet length", "slsk.compressed_packet_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_uncompressed_packet_length,
{ "Uncompressed packet length", "slsk.uncompressed_packet_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_directories,
{ "Number of directories", "slsk.num_directories",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_upload_speed,
{ "Upload speed", "slsk.upload_speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_in_queue,
{ "In Queue", "slsk.in_queue",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_slotsfull_records,
{ "Number of Slotsfull Records", "slsk.num_slotsfull_records",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_recommendations,
{ "Number of Recommendations", "slsk.num_recommendations",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_files,
{ "Number of Files", "slsk.num_files",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_strings,
{ "Number of strings", "slsk.num_strings",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_code,
{ "Code", "slsk.file_code",
FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_size1,
{ "Size1", "slsk.file_size1",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_size2,
{ "Size2", "slsk.file_size2",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_num_attributes,
{ "Number of attributes", "slsk.file_num_attributes",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_attribute_type,
{ "File attribute type", "slsk.file_attribute_type",
FT_UINT32, BASE_DEC, VALS(slsk_attr_type), 0, NULL, HFILL } },
{ &hf_slsk_file_attribute_value,
{ "File attribute value", "slsk.file_attribute_value",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_free_upload_slots,
{ "Free upload slots", "slsk.free_upload_slots",
FT_UINT32, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_bytes,
{ "Bytes", "slsk.bytes",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_same_recommendation,
{ "Same Recommendation", "slsk.same_recommendation",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_priv_users,
{ "Number of Privileged Users", "slsk.priv_user.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_parent_address,
{ "Number of Parent Addresses", "slsk.parent_addr.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_slsk,
&ett_slsk_compr_packet,
&ett_slsk_directory,
&ett_slsk_file,
&ett_slsk_file_attribute,
&ett_slsk_user,
&ett_slsk_recommendation,
&ett_slsk_room,
&ett_slsk_string,
};
static ei_register_info ei[] = {
{ &ei_slsk_unknown_data, { "slsk.unknown_data", PI_UNDECODED, PI_WARN, "Unknown Data (not interpreted)", EXPFILL }},
{ &ei_slsk_zlib_decompression_failed, { "slsk.zlib_decompression_failed", PI_PROTOCOL, PI_WARN, "zlib compressed packet failed to decompress", EXPFILL }},
{ &ei_slsk_decompression_failed, { "slsk.decompression_failed", PI_PROTOCOL, PI_WARN, "decompression failed", EXPFILL }},
};
module_t *slsk_module;
expert_module_t* expert_slsk;
/* Registers the protocol name and description */
proto_slsk = proto_register_protocol("SoulSeek Protocol", "SoulSeek", "slsk");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_slsk, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_slsk = expert_register_protocol(proto_slsk);
expert_register_field_array(expert_slsk, ei, array_length(ei));
/* Register the dissector handle */
slsk_handle = register_dissector("slsk", dissect_slsk, proto_slsk);
/* Registers the options in the menu preferences */
slsk_module = prefs_register_protocol(proto_slsk, NULL);
prefs_register_bool_preference(slsk_module, "desegment",
"Reassemble SoulSeek messages spanning multiple TCP segments",
"Whether the SoulSeek dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&slsk_desegment);
#ifdef HAVE_ZLIB
prefs_register_bool_preference(slsk_module, "decompress",
"Decompress zlib compressed packets inside SoulSeek messages",
"Whether the SoulSeek dissector should decompress all zlib compressed packets inside messages",
&slsk_decompress);
#endif
}
void
proto_reg_handoff_slsk(void)
{
dissector_add_uint_range_with_preference("tcp.port", SLSK_TCP_PORT_RANGE, slsk_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|