2 * Routines for Blubster/Piolet Manolito Protocol dissection
3 * Copyright 2003-2004, Jeff Connelly <shellreef+mp2p@gmail.com>
5 * Official home page: http://openlito.sourceforge.net/
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include <epan/expert.h>
19 void proto_register_manolito(void);
20 void proto_reg_handoff_manolito(void);
22 static dissector_handle_t manolito_handle
;
24 #define MANOLITO_PORT 41170 /* Not IANA registered */
26 static int proto_manolito
;
28 static int hf_manolito_checksum
;
29 static int hf_manolito_seqno
;
30 static int hf_manolito_src
;
31 static int hf_manolito_dest
;
32 static int hf_manolito_options_short
;
33 static int hf_manolito_options
;
34 static int hf_manolito_string
;
35 static int hf_manolito_integer
;
37 static int ett_manolito
;
39 static expert_field ei_manolito_type
;
41 #define MANOLITO_STRING 1
42 #define MANOLITO_INTEGER 0
44 static const value_string field_longname
[] = {
46 { 0x4252, "Bit Rate" },
47 { 0x434b, "Checksum" },
48 { 0x434e, "Client Name" },
49 { 0x4356, "Client Version" },
50 { 0x4643, "Frequency" },
51 { 0x464c, "File Length" },
52 { 0x464e, "Filename" },
54 { 0x4944, "Identification" },
55 { 0x4d45, "Message" },
56 { 0x4e43, "Num. Connections" },
57 { 0x4e49, "Network ID" },
58 { 0x4e4e, "Nickname" },
60 { 0x5346, "Shared Files" },
61 { 0x534b, "Shared Kilobytes" },
62 { 0x534c, "Song Length (s)" },
64 { 0x564c, "Velocity" },
67 static value_string_ext field_longname_ext
= VALUE_STRING_EXT_INIT(field_longname
);
71 dissect_manolito(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* dissector_data _U_
)
75 proto_tree
*manolito_tree
;
76 char *packet_type
= NULL
;
78 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MANOLITO");
80 ti
= proto_tree_add_item(tree
, proto_manolito
, tvb
, offset
, -1, ENC_NA
);
82 manolito_tree
= proto_item_add_subtree(ti
, ett_manolito
);
84 /* MANOLITO packet header (network byte order) */
85 proto_tree_add_checksum(manolito_tree
, tvb
, offset
, hf_manolito_checksum
,
86 -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
88 proto_tree_add_item(manolito_tree
,
89 hf_manolito_seqno
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
91 proto_tree_add_item(manolito_tree
,
92 hf_manolito_src
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
94 proto_tree_add_item(manolito_tree
,
95 hf_manolito_dest
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
98 if (tvb_reported_length_remaining(tvb
, offset
) == 3) {
99 proto_tree_add_item(manolito_tree
,
100 hf_manolito_options_short
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
102 col_set_str(pinfo
->cinfo
, COL_INFO
, "Ping (truncated)");
106 proto_tree_add_item(manolito_tree
,
107 hf_manolito_options
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
110 if (tvb_reported_length_remaining(tvb
, offset
) == 0) {
111 col_set_str(pinfo
->cinfo
, COL_INFO
, "Ping");
115 /* fields format: 2-byte name, optional NULL, 1-byte lenlen, */
116 /* that many bytes(len or data), for NI,CN,VL is len, more */
117 /* (that many bytes) data follows; else is raw data. */
120 uint16_t field_name
; /* 16-bit field name */
121 uint8_t dtype
; /* data-type */
122 uint8_t length
; /* length */
123 int start
; /* field starting location */
124 uint8_t *field_name_str
;
128 /* 2-byte field name */
129 field_name
= tvb_get_ntohs(tvb
, offset
);
130 field_name_str
= tvb_get_string_enc(pinfo
->pool
, tvb
, offset
, 2, ENC_ASCII
);
132 /* Identify the packet based on existing fields */
133 /* Maybe using the options fields is a better idea...*/
134 if (field_name
== 0x434b) /* CK */
135 packet_type
= "Search Hit";
136 if (field_name
== 0x4e43) /* NC */
137 packet_type
= "User Information";
138 if (field_name
== 0x464e) /* FN - if only field */
139 packet_type
= "Search Query";
140 if (field_name
== 0x4944) /* ID ?? search by CK? */
141 packet_type
= "Search Query (by hash)";
142 if (field_name
== 0x5054) /* PT */
143 packet_type
= "Download Request";
144 if (field_name
== 0x4d45) /* ME */
145 packet_type
= "Chat";
149 /* 1-byte data type */
150 dtype
= tvb_get_uint8(tvb
, offset
);
152 length
= tvb_get_uint8(tvb
, offset
);
155 if (dtype
== MANOLITO_STRING
) {
158 str
= tvb_get_string_enc(pinfo
->pool
, tvb
, offset
, length
, ENC_ASCII
);
159 proto_tree_add_string_format(manolito_tree
, hf_manolito_string
, tvb
, start
,
160 4+length
, str
, "%s (%s): %s",
162 val_to_str_ext_const(field_name
, &field_longname_ext
, "unknown"),
166 else if (dtype
== MANOLITO_INTEGER
) {
170 /* integers can be up to 5 bytes */
174 n
= tvb_get_ntoh40(tvb
, offset
);
177 n
= tvb_get_ntohl(tvb
, offset
);
180 n
= tvb_get_ntoh24(tvb
, offset
);
183 n
= tvb_get_ntohs(tvb
, offset
);
186 n
= tvb_get_uint8(tvb
, offset
);
194 proto_tree_add_uint64_format(manolito_tree
, hf_manolito_integer
, tvb
, start
,
195 4+length
, n
, "%s (%s): %" PRIu64
,
197 val_to_str_ext_const(field_name
, &field_longname_ext
, "unknown"),
201 /* XXX - expert info */
206 proto_tree_add_expert_format(manolito_tree
, pinfo
, &ei_manolito_type
,
207 tvb
, start
, offset
- start
, "Unknown type %d", dtype
);
210 } while(tvb_reported_length_remaining(tvb
, offset
));
213 col_set_str(pinfo
->cinfo
, COL_INFO
, packet_type
);
220 proto_register_manolito(void)
222 static hf_register_info hf
[] = {
223 { &hf_manolito_checksum
,
224 { "Checksum", "manolito.checksum",
225 FT_UINT32
, BASE_HEX
, NULL
, 0,
226 "Checksum used for verifying integrity", HFILL
}
228 { &hf_manolito_seqno
,
229 { "Sequence Number", "manolito.seqno",
230 FT_UINT32
, BASE_HEX
, NULL
, 0,
231 "Incremental sequence number", HFILL
}
234 { "Forwarded IP Address", "manolito.src",
235 FT_IPv4
, BASE_NONE
, NULL
, 0,
236 "Host packet was forwarded from (or 0)", HFILL
}
239 { "Destination IP Address", "manolito.dest",
240 FT_IPv4
, BASE_NONE
, NULL
, 0,
241 "Destination IPv4 address", HFILL
}
243 { &hf_manolito_options_short
,
244 { "Options", "manolito.options",
245 FT_UINT24
, BASE_HEX
, NULL
, 0,
246 "Packet-dependent data", HFILL
}
248 { &hf_manolito_options
,
249 { "Options", "manolito.options",
250 FT_UINT32
, BASE_HEX
, NULL
, 0,
251 "Packet-dependent data", HFILL
}
253 { &hf_manolito_string
,
254 { "String field", "manolito.string",
255 FT_STRING
, BASE_NONE
, NULL
, 0,
258 { &hf_manolito_integer
,
259 { "Integer field", "manolito.integer",
260 FT_UINT40
, BASE_DEC
, NULL
, 0,
265 static int *ett
[] = {
269 static ei_register_info ei
[] = {
270 { &ei_manolito_type
, { "manolito.type.unknown", PI_PROTOCOL
, PI_WARN
, "Unknown type", EXPFILL
}},
273 expert_module_t
* expert_manolito
;
275 proto_manolito
= proto_register_protocol("Blubster/Piolet MANOLITO Protocol", "Manolito", "manolito");
277 proto_register_field_array(proto_manolito
, hf
, array_length(hf
));
278 proto_register_subtree_array(ett
, array_length(ett
));
279 expert_manolito
= expert_register_protocol(proto_manolito
);
280 expert_register_field_array(expert_manolito
, ei
, array_length(ei
));
282 manolito_handle
= register_dissector("manolito", dissect_manolito
, proto_manolito
);
287 proto_reg_handoff_manolito(void)
289 dissector_add_uint_with_preference("udp.port", MANOLITO_PORT
, manolito_handle
);
293 * Editor modelines - https://www.wireshark.org/tools/modelines.html
298 * indent-tabs-mode: t
301 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
302 * :indentSize=8:tabSize=8:noTabs=false: