1 /* packet-slimp3.c 2 * Routines for SliMP3 protocol dissection 3 * 4 * Ashok Narayanan <ashokn@cisco.com> 5 * 6 * Adds support for the data packet protocol for the SliMP3 7 * See www.slimdevices.com for details. foo(void)8 * 9 * Wireshark - Network traffic analyzer 10 * By Gerald Combs <gerald@wireshark.org> 11 * Copyright 1998 Gerald Combs 12 * 13 * SPDX-License-Identifier: GPL-2.0-or-later 14 */ 15 16 #include "config.h" 17 18 #include <epan/packet.h> 19 #include <epan/to_str.h> 20 21 void proto_register_slimp3(void); 22 void proto_reg_handoff_slimp3(void); 23 24 static int proto_slimp3 = -1; 25 static int hf_slimp3_opcode = -1; 26 static int hf_slimp3_control = -1; 27 static int hf_slimp3_uptime = -1; 28 static int hf_slimp3_code_id = -1; 29 static int hf_slimp3_code_bits = -1; 30 static int hf_slimp3_infrared_slimp3 = -1; 31 static int hf_slimp3_infrared_jvc = -1; 32 static int hf_slimp3_infrared = -1; 33 static int hf_slimp3_device_id = -1; 34 static int hf_slimp3_fw_rev = -1; 35 static int hf_slimp3_data_offset = -1; 36 static int hf_slimp3_data_command = -1; 37 static int hf_slimp3_data_write_pointer = -1; 38 static int hf_slimp3_data_sequence = -1; 39 static int hf_slimp3_disc_rsp_server_ip = -1; 40 static int hf_slimp3_disc_rsp_server_port = -1; 41 static int hf_slimp3_data_ack_write_pointer = -1; 42 static int hf_slimp3_data_ack_read_pointer = -1; 43 static int hf_slimp3_data_ack_sequence = -1; 44 static int hf_slimp3_data_req_offset = -1; 45 /* Generated from convert_proto_tree_add_text.pl */ 46 static int hf_slimp3_display_delay = -1; 47 static int hf_slimp3_display_string = -1; 48 static int hf_slimp3_display_command = -1; 49 static int hf_slimp3_display_unknown = -1; 50 static int hf_slimp3_hello_response_client_server = -1; 51 static int hf_slimp3_hello_request_server_client = -1; 52 static int hf_slimp3_i2c_response_client_server = -1; 53 static int hf_slimp3_i2c_request_server_client = -1; 54 static int hf_slimp3_data_length = -1; 55 static int hf_slimp3_data_data = -1; 56 57 static gint ett_slimp3 = -1; 58 59 #define UDP_PORT_SLIMP3_V1 1069 /* Not IANA registered */ 60 #define UDP_PORT_SLIMP3_V2 3483 61 #define UDP_PORT_SLIMP3_RANGE "1069,3483" 62 63 #define SLIMP3_IR 'i' 64 #define SLIMP3_CONTROL 's' 65 #define SLIMP3_HELLO 'h' 66 #define SLIMP3_DATA 'm' 67 #define SLIMP3_DATA_REQ 'r' 68 #define SLIMP3_DISPLAY 'l' 69 #define SLIMP3_I2C '2' 70 #define SLIMP3_DISC_REQ 'd' 71 #define SLIMP3_DISC_RSP 'D' 72 #define SLIMP3_DATA_ACK 'a' 73 74 static const value_string slimp3_opcode_vals[] = { 75 { SLIMP3_IR, "Infrared Remote Code" }, 76 { SLIMP3_CONTROL, "Stream Control" }, 77 { SLIMP3_DATA, "MPEG Data" }, 78 { SLIMP3_DATA_REQ, "Data Request" }, 79 { SLIMP3_HELLO, "Hello" }, 80 { SLIMP3_DISPLAY, "Display" }, 81 { SLIMP3_I2C, "I2C" }, 82 { SLIMP3_DISC_REQ, "Discovery Request" }, 83 { SLIMP3_DISC_RSP, "Discovery Response" }, 84 { SLIMP3_DATA_ACK, "Ack" }, 85 { 0, NULL } 86 }; 87 88 /* IR remote control types */ 89 static const value_string slimp3_ir_types[] = { 90 { 0x02, "SLIMP3" }, 91 { 0xff, "JVC DVD Player" }, 92 93 { 0, NULL } 94 }; 95 96 /* IR codes for the custom SLIMP3 remote control */ 97 static const value_string slimp3_ir_codes_slimp3[] = { 98 { 0x768900ff, "voldown" }, 99 { 0x768904fb, "brightness" }, 100 { 0x768908f7, "2" }, 101 { 0x768910ef, "play" }, 102 { 0x768920df, "pause" }, 103 { 0x768928d7, "6" }, 104 { 0x768938c7, "repeat" }, 105 { 0x768940bf, "power" }, 106 { 0x768948b7, "4" }, 107 { 0x768958a7, "search" }, 108 { 0x7689609f, "add" }, 109 { 0x76896897, "8" }, 110 { 0x76897887, "now_playing" }, 111 { 0x7689807f, "volup" }, 112 { 0x76898877, "3" }, 113 { 0x7689906f, "arrow_left" }, 114 { 0x76899867, "0" }, 115 { 0x7689a05f, "fwd" }, 116 { 0x7689a857, "7" }, 117 { 0x7689b04f, "arrow_down" }, 118 { 0x7689b847, "sleep" }, 119 { 0x7689c03f, "rew" }, 120 { 0x7689c837, "5" }, 121 { 0x7689d02f, "arrow_right" }, 122 { 0x7689d827, "shuffle" }, 123 { 0x7689e01f, "arrow_up" }, 124 { 0x7689e817, "9" }, 125 { 0x7689f00f, "1" }, 126 { 0x7689f807, "size" }, 127 128 { 0, NULL } 129 }; 130 static value_string_ext slimp3_ir_codes_slimp3_ext = VALUE_STRING_EXT_INIT(slimp3_ir_codes_slimp3); 131 132 /* IR codes for the JVC remote control */ 133 static const value_string slimp3_ir_codes_jvc[] = { 134 { 0xf786, "One" }, 135 { 0xf746, "Two" }, 136 { 0xf7c6, "Three" }, 137 { 0xf726, "Four" }, 138 { 0xf7a6, "Five" }, 139 { 0xf766, "Six" }, 140 { 0xf7e6, "Seven" }, 141 { 0xf716, "Eight" }, 142 { 0xf796, "Nine" }, 143 { 0xf776, "Ten" }, 144 145 { 0xf7f6, "Picture-In-Picture" }, 146 /* { 0xf7XX, "Enter" }, */ 147 { 0xf70e, "Back" }, 148 { 0xf732, "Play" }, 149 { 0xf76e, "Forward" }, 150 { 0xf743, "Record" }, 151 { 0xf7c2, "Stop" }, 152 { 0xf7b2, "Pause" }, 153 /* { 0xf7XX, "TV/Video" }, */ 154 { 0xf703, "Display" }, 155 { 0xf7b3, "Sleep" }, 156 { 0xf7b6, "Guide" }, 157 { 0xf70b, "Up" }, 158 { 0xf74b, "Left" }, 159 { 0xf7cb, "Right" }, 160 { 0xf78b, "Down" }, 161 { 0xf783, "Menu" }, 162 { 0xf72b, "OK" }, 163 { 0xf778, "Volume Up" }, 164 { 0xf7f8, "Volume Down" }, 165 { 0xf70d, "Channel Up" }, 166 { 0xf78d, "Channel Down" }, 167 /* { 0xf7XX, "Mute" }, */ 168 { 0xf7ab, "Recall" }, 169 { 0xf702, "Power" }, 170 171 { 0, NULL } 172 }; 173 174 175 static const value_string slimp3_display_commands[] = { 176 { 0x1, "Clear Display"}, 177 { 0x2, "Cursor to 1st Line Home"}, 178 179 { 0x4, "Mode: Decrement Address, Shift Cursor"}, 180 { 0x5, "Mode: Decrement Address, Shift Display"}, 181 { 0x6, "Mode: Increment Address, Shift Cursor"}, 182 { 0x7, "Mode: Increment Address, Shift Display"}, 183 184 { 0x8, "Display Off"}, 185 { 0xd, "Display On, With Blinking"}, 186 { 0xe, "Display On, With Cursor"}, 187 { 0xf, "Display On, With Cursor And Blinking"}, 188 189 { 0x10, "Move Cursor Left"}, 190 { 0x14, "Move Cursor Right"}, 191 { 0x18, "Shift Display Left"}, 192 { 0x1b, "Shift Display Right"}, 193 194 { 0x30, "Set (8-bit)"}, 195 { 0x20, "Set (4-bit)"}, 196 197 { 0xa0, "Cursor to Top Right"}, 198 { 0xc0, "Cursor to 2nd Line Home"}, 199 200 { 0, NULL}, 201 }; 202 203 static const value_string slimp3_display_fset8[] = { 204 { 0x0, "Brightness 100%"}, 205 { 0x1, "Brightness 75%"}, 206 { 0x2, "Brightness 50%"}, 207 { 0x3, "Brightness 25%"}, 208 209 { 0, NULL }, 210 }; 211 212 static const value_string slimp3_stream_control[] = { 213 { 1, "Reset buffer, Start New Stream"}, 214 { 2, "Pause Playback"}, 215 { 4, "Resume Playback"}, 216 { 0, NULL }, 217 }; 218 219 220 static const value_string slimp3_mpg_control[] = { 221 { 0, "Go"}, /* Run the decoder */ 222 { 1, "Stop"}, /* Halt decoder but don't reset rptr */ 223 { 3, "Reset"}, /* Halt decoder and reset rptr */ 224 225 { 0, NULL } 226 }; 227 228 #define MAX_LCD_STR_LEN 128 229 static int 230 dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) 231 { 232 const char *opcode_str; 233 proto_tree *slimp3_tree; 234 proto_item *ti; 235 gint i1; 236 gint offset = 0; 237 guint16 opcode; 238 guchar lcd_char; 239 char lcd_str[MAX_LCD_STR_LEN + 1]; 240 int to_server = FALSE; 241 int old_protocol = FALSE; 242 address tmp_addr; 243 gboolean in_str; 244 int lcd_strlen; 245 246 /* 247 * If it doesn't begin with a known opcode, reject it, so that 248 * traffic that happens to be do or from one of our ports 249 * doesn't get misidentified as SliMP3 traffic. 250 */ 251 if (!tvb_bytes_exist(tvb, offset, 1)) 252 return 0; /* not even an opcode */ 253 opcode = tvb_get_guint8(tvb, offset); 254 opcode_str = try_val_to_str(opcode, slimp3_opcode_vals); 255 if (opcode_str == NULL) 256 return 0; 257 258 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3"); 259 col_add_str(pinfo->cinfo, COL_INFO, opcode_str); 260 261 ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, ENC_NA); 262 slimp3_tree = proto_item_add_subtree(ti, ett_slimp3); 263 264 proto_tree_add_uint(slimp3_tree, hf_slimp3_opcode, tvb, 265 offset, 1, opcode); 266 267 /* The new protocol (v1.3 and later) uses an IANA-assigned port number. 268 * It usually uses the same number for both sizes of the conversation, so 269 * the port numbers can't always be used to determine client and server. 270 * The new protocol places the clients MAC address in the packet, so that 271 * is used to identify packets originating at the client. 272 */ 273 if ((pinfo->destport == UDP_PORT_SLIMP3_V2) && (pinfo->srcport == UDP_PORT_SLIMP3_V2)) { 274 set_address_tvb(&tmp_addr, AT_ETHER, 6, tvb, offset+12); 275 to_server = addresses_equal(&tmp_addr, &pinfo->dl_src); 276 } 277 else if (pinfo->destport == UDP_PORT_SLIMP3_V2) { 278 to_server = TRUE; 279 } 280 else if (pinfo->srcport == UDP_PORT_SLIMP3_V2) { 281 to_server = FALSE; 282 } 283 if (pinfo->destport == UDP_PORT_SLIMP3_V1) { 284 to_server = TRUE; 285 old_protocol = TRUE; 286 } 287 else if (pinfo->srcport == UDP_PORT_SLIMP3_V1) { 288 to_server = FALSE; 289 old_protocol = TRUE; 290 } 291 292 switch (opcode) { 293 294 case SLIMP3_IR: 295 /* IR code 296 * 297 * [0] 'i' as in "IR" 298 * [1] 0x00 299 * [2..5] player's time since startup in ticks @625 KHz 300 * [6] IR code id, ff=JVC, 02=SLIMP3 301 * [7] number of meaningful bits - 16 for JVC, 32 for SLIMP3 302 * [8..11] the 32-bit IR code 303 * [12..17] reserved 304 */ 305 if (tree) { 306 i1 = tvb_get_ntohl(tvb, offset+2); 307 proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_uptime, tvb, offset+2, 4, i1, 308 "%u sec (%u ticks)", i1/625000, i1); 309 310 proto_tree_add_item(slimp3_tree, hf_slimp3_code_id, tvb, offset+6, 1, ENC_BIG_ENDIAN); 311 proto_tree_add_item(slimp3_tree, hf_slimp3_code_bits, tvb, offset+7, 1, ENC_BIG_ENDIAN); 312 313 i1 = tvb_get_ntohl(tvb, offset+8); 314 /* Check the code to figure out which remote is being used. */ 315 if (tvb_get_guint8(tvb, offset+6) == 0x02 && 316 tvb_get_guint8(tvb, offset+7) == 32) { 317 /* This is the custom SLIMP3 remote. */ 318 proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_slimp3, tvb, offset+8, 4, ENC_BIG_ENDIAN); 319 col_append_fstr(pinfo->cinfo, COL_INFO, ", SLIMP3: %s", 320 val_to_str_ext(i1, &slimp3_ir_codes_slimp3_ext, "Unknown (0x%0x)")); 321 } 322 else if (tvb_get_guint8(tvb, offset+6) == 0xff && 323 tvb_get_guint8(tvb, offset+7) == 16) { 324 /* This is a JVC DVD player remote */ 325 proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_jvc, tvb, offset+8, 4, ENC_BIG_ENDIAN); 326 col_append_fstr(pinfo->cinfo, COL_INFO, ", JVC: %s", 327 val_to_str(i1, slimp3_ir_codes_jvc, "Unknown (0x%0x)")); 328 } else { 329 /* Unknown code; just write it */ 330 proto_tree_add_item(slimp3_tree, hf_slimp3_infrared, tvb, offset+8, 4, ENC_BIG_ENDIAN); 331 col_append_fstr(pinfo->cinfo, COL_INFO, ", 0x%0x", i1); 332 } 333 } 334 break; 335 336 case SLIMP3_DISPLAY: 337 if (tree) { 338 guint8 value; 339 340 /* Loop through the commands */ 341 i1 = 18; 342 in_str = FALSE; 343 lcd_strlen = 0; 344 while (i1 < tvb_reported_length_remaining(tvb, offset)) { 345 switch(tvb_get_guint8(tvb, offset + i1)) { 346 case 0: 347 in_str = FALSE; 348 lcd_strlen = 0; 349 proto_tree_add_item(slimp3_tree, hf_slimp3_display_delay, tvb, offset + i1, 2, ENC_NA); 350 i1 += 2; 351 break; 352 case 3: 353 lcd_char = tvb_get_guint8(tvb, offset + i1 + 1); 354 if (!g_ascii_isprint(lcd_char)) 355 lcd_char = '.'; 356 if (ti && in_str) { 357 lcd_strlen += 2; 358 proto_item_append_text(ti, "%c", lcd_char); 359 proto_item_set_len(ti, lcd_strlen); 360 } else { 361 ti = proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_display_string, tvb, offset + i1, 2, 362 lcd_char, "%c", lcd_char); 363 in_str = TRUE; 364 lcd_strlen = 2; 365 } 366 i1 += 2; 367 break; 368 369 case 2: 370 in_str = FALSE; 371 lcd_strlen = 0; 372 value = tvb_get_guint8(tvb, offset + i1 + 1); 373 ti = proto_tree_add_uint(slimp3_tree, hf_slimp3_display_command, tvb, offset + i1, 2, value); 374 if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) { 375 proto_item_append_text(ti, ": %s", 376 val_to_str(tvb_get_guint8(tvb, offset + i1 + 2), 377 slimp3_display_fset8, 378 "Unknown (0x%0x)")); 379 i1 += 2; 380 } 381 i1 += 2; 382 break; 383 384 default: 385 proto_tree_add_item(slimp3_tree, hf_slimp3_display_unknown, tvb, offset + i1, 2, ENC_NA); 386 i1 += 2; 387 break; 388 } 389 } 390 } 391 392 i1 = 18; 393 lcd_strlen = 0; 394 while (tvb_offset_exists(tvb, offset + i1) && 395 lcd_strlen < MAX_LCD_STR_LEN) { 396 switch (tvb_get_guint8(tvb, offset + i1)) { 397 398 case 0: 399 lcd_str[lcd_strlen++] = '.'; 400 break; 401 402 case 2: 403 lcd_str[lcd_strlen++] = '|'; 404 if (tvb_offset_exists(tvb, offset + i1 + 1) && 405 (tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) 406 i1 += 2; 407 break; 408 409 case 3: 410 if (tvb_offset_exists(tvb, offset + i1 + 1)) { 411 if ((lcd_strlen < 1) || 412 (lcd_str[lcd_strlen-1] != ' ') || 413 (tvb_get_guint8(tvb, offset + i1 + 1) != ' ')) { 414 lcd_char = tvb_get_guint8(tvb, offset + i1 + 1); 415 lcd_str[lcd_strlen++] = g_ascii_isprint(lcd_char) ? lcd_char : '.'; 416 } 417 } 418 } 419 420 i1 += 2; 421 } 422 lcd_str[lcd_strlen] = '\0'; 423 if (lcd_strlen > 0) 424 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", lcd_str); 425 break; 426 427 case SLIMP3_CONTROL: 428 proto_tree_add_item(slimp3_tree, hf_slimp3_control, tvb, offset+1, 1, ENC_BIG_ENDIAN); 429 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", 430 val_to_str(tvb_get_guint8(tvb, offset+1), 431 slimp3_stream_control, "Unknown (0x%0x)")); 432 break; 433 434 case SLIMP3_HELLO: 435 if (tree) { 436 if (to_server) { 437 guint8 fw_ver; 438 /* Hello response; client->server */ 439 proto_tree_add_item(slimp3_tree, hf_slimp3_hello_response_client_server, tvb, offset, 1, ENC_NA); 440 proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN); 441 fw_ver = tvb_get_guint8(tvb, offset+2); 442 proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver, 443 "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver); 444 } else { 445 /* Hello request; server->client */ 446 proto_tree_add_item(slimp3_tree, hf_slimp3_hello_request_server_client, tvb, offset, 1, ENC_NA); 447 } 448 } 449 break; 450 451 case SLIMP3_I2C: 452 if (to_server) { 453 /* Hello response; client->server */ 454 proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_response_client_server, tvb, offset, -1, ENC_NA); 455 col_append_str(pinfo->cinfo, COL_INFO, ", Response"); 456 } else { 457 /* Hello request; server->client */ 458 proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_request_server_client, tvb, offset, -1, ENC_NA); 459 col_append_str(pinfo->cinfo, COL_INFO, ", Request"); 460 } 461 break; 462 463 case SLIMP3_DATA_REQ: 464 proto_tree_add_item(slimp3_tree, hf_slimp3_data_req_offset, tvb, offset+2, 2, ENC_BIG_ENDIAN); 465 col_append_fstr(pinfo->cinfo, COL_INFO, ", Offset: %u bytes", 466 tvb_get_ntohs(tvb, offset+2)*2); 467 break; 468 469 case SLIMP3_DATA: 470 /* MPEG data (v1.3 and later) 471 * 472 * [0] 'm' 473 * [1..5] reserved 474 * [6..7] Write pointer (in words) 475 * [8..9] reserved 476 * [10..11] Sequence number 477 * [12..17] reserved 478 * [18..] MPEG data 479 */ 480 if (old_protocol) { 481 guint offset_buffer; 482 proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1, 483 NULL, "Length: %d bytes", 484 tvb_reported_length_remaining(tvb, offset+18)); 485 offset_buffer = tvb_get_ntohs(tvb, offset+2) * 2; 486 proto_tree_add_uint(slimp3_tree, hf_slimp3_data_offset, tvb, offset+2, 2, offset_buffer); 487 488 col_append_fstr(pinfo->cinfo, COL_INFO, 489 ", Length: %d bytes, Offset: %u bytes.", 490 tvb_reported_length_remaining(tvb, offset+18), 491 offset_buffer); 492 } 493 else { 494 guint write_pointer; 495 proto_tree_add_item(slimp3_tree, hf_slimp3_data_command, tvb, offset+1, 1, ENC_BIG_ENDIAN); 496 proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1, 497 NULL, "Length: %d bytes", 498 tvb_reported_length_remaining(tvb, offset+18)); 499 write_pointer = tvb_get_ntohs(tvb, offset+6) * 2; 500 proto_tree_add_uint(slimp3_tree, hf_slimp3_data_write_pointer, tvb, offset+6, 2, write_pointer); 501 proto_tree_add_item(slimp3_tree, hf_slimp3_data_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN); 502 503 col_append_fstr(pinfo->cinfo, COL_INFO, 504 ", %s, %d bytes at %u, Sequence: %u", 505 val_to_str(tvb_get_guint8(tvb, offset+1), 506 slimp3_mpg_control, "Unknown (0x%0x)"), 507 tvb_reported_length_remaining(tvb, offset+18), 508 write_pointer, 509 tvb_get_ntohs(tvb, offset+10)); 510 } 511 break; 512 513 case SLIMP3_DISC_REQ: 514 { 515 guint8 fw_ver; 516 proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN); 517 fw_ver = tvb_get_guint8(tvb, offset+2); 518 proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver, 519 "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver); 520 col_append_fstr(pinfo->cinfo, COL_INFO, ", Device ID: %u. Firmware: %u.%u", 521 tvb_get_guint8(tvb, offset+1), fw_ver>>4, fw_ver & 0xf); 522 } 523 break; 524 525 case SLIMP3_DISC_RSP: 526 if (tree) { 527 proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_ip, tvb, offset+2, 4, ENC_BIG_ENDIAN); 528 proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_port, tvb, offset+6, 2, ENC_BIG_ENDIAN); 529 } 530 531 col_append_fstr(pinfo->cinfo, COL_INFO, ", Server Address: %s. Server Port: %u", 532 tvb_ip_to_str(pinfo->pool, tvb, offset+2), 533 tvb_get_ntohs(tvb, offset + 6)); 534 break; 535 536 case SLIMP3_DATA_ACK: 537 /* Acknowledge MPEG data 538 * 539 * [0] 'a' 540 * [1..5] 541 * [6..7] Write pointer (in words) 542 * [8..9] Read pointer (in words) 543 * [10..11] Sequence number 544 * [12..17] client MAC address (v1.3 and later) 545 */ 546 if (tree) { 547 guint pointer; 548 549 pointer = tvb_get_ntohs(tvb, offset+6) * 2; 550 proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_write_pointer, tvb, offset+6, 2, pointer); 551 pointer = tvb_get_ntohs(tvb, offset+8) * 2; 552 proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_read_pointer, tvb, offset+8, 2, pointer); 553 proto_tree_add_item(slimp3_tree, hf_slimp3_data_ack_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN); 554 } 555 556 col_append_fstr(pinfo->cinfo, COL_INFO, ", Sequence: %u", 557 tvb_get_ntohs(tvb, offset+10)); 558 break; 559 560 default: 561 if (tree) { 562 proto_tree_add_item(slimp3_tree, hf_slimp3_data_data, tvb, offset, -1, ENC_NA); 563 } 564 break; 565 } 566 567 return tvb_reported_length(tvb); 568 } 569 570 void 571 proto_register_slimp3(void) 572 { 573 static hf_register_info hf[] = { 574 { &hf_slimp3_opcode, 575 { "Opcode", "slimp3.opcode", 576 FT_UINT8, BASE_DEC, VALS(slimp3_opcode_vals), 0x0, 577 "SLIMP3 message type", HFILL }}, 578 579 { &hf_slimp3_control, 580 { "Control Packet", "slimp3.control", 581 FT_UINT8, BASE_DEC, VALS(slimp3_stream_control), 0x0, 582 "SLIMP3 control", HFILL }}, 583 584 { &hf_slimp3_uptime, 585 { "Uptime", "slimp3.uptime", 586 FT_UINT32, BASE_DEC, NULL, 0x0, 587 NULL, HFILL }}, 588 589 { &hf_slimp3_code_id, 590 { "Code identifier", "slimp3.code_id", 591 FT_UINT8, BASE_DEC, VALS(slimp3_ir_types), 0x0, 592 NULL, HFILL }}, 593 594 { &hf_slimp3_code_bits, 595 { "Code bits", "slimp3.code_bits", 596 FT_UINT8, BASE_DEC, NULL, 0x0, 597 NULL, HFILL }}, 598 599 { &hf_slimp3_infrared_slimp3, 600 { "Infrared Code", "slimp3.infrared", 601 FT_UINT32, BASE_HEX | BASE_EXT_STRING, &slimp3_ir_codes_slimp3_ext, 0x0, 602 NULL, HFILL }}, 603 604 { &hf_slimp3_infrared_jvc, 605 { "Infrared Code", "slimp3.infrared", 606 FT_UINT32, BASE_HEX, VALS(slimp3_ir_codes_jvc), 0x0, 607 NULL, HFILL }}, 608 609 { &hf_slimp3_infrared, 610 { "Infrared Code", "slimp3.infrared", 611 FT_UINT32, BASE_HEX, NULL, 0x0, 612 NULL, HFILL }}, 613 614 { &hf_slimp3_device_id, 615 { "Device ID", "slimp3.device_id", 616 FT_UINT8, BASE_DEC, NULL, 0x0, 617 NULL, HFILL }}, 618 619 { &hf_slimp3_fw_rev, 620 { "Firmware Revision", "slimp3.fw_rev", 621 FT_UINT8, BASE_HEX, NULL, 0x0, 622 NULL, HFILL }}, 623 624 { &hf_slimp3_data_offset, 625 { "Buffer offset", "slimp3.data.offset", 626 FT_UINT16, BASE_DEC, NULL, 0x0, 627 NULL, HFILL }}, 628 629 { &hf_slimp3_data_command, 630 { "Command", "slimp3.data.command", 631 FT_UINT8, BASE_HEX, VALS(slimp3_mpg_control), 0x0, 632 NULL, HFILL }}, 633 634 { &hf_slimp3_data_write_pointer, 635 { "Write Pointer", "slimp3.data.write_pointer", 636 FT_UINT16, BASE_DEC, NULL, 0x0, 637 NULL, HFILL }}, 638 639 { &hf_slimp3_data_sequence, 640 { "Sequence", "slimp3.data.sequence", 641 FT_UINT16, BASE_DEC, NULL, 0x0, 642 NULL, HFILL }}, 643 644 { &hf_slimp3_disc_rsp_server_ip, 645 { "Server Address", "slimp3.disc_rsp.server_ip", 646 FT_IPv4, BASE_NONE, NULL, 0x0, 647 NULL, HFILL }}, 648 649 { &hf_slimp3_disc_rsp_server_port, 650 { "Server Port", "slimp3.disc_rsp.server_port", 651 FT_UINT16, BASE_DEC, NULL, 0x0, 652 NULL, HFILL }}, 653 654 { &hf_slimp3_data_ack_write_pointer, 655 { "Write Pointer", "slimp3.data_ack.write_pointer", 656 FT_UINT16, BASE_DEC, NULL, 0x0, 657 NULL, HFILL }}, 658 659 { &hf_slimp3_data_ack_read_pointer, 660 { "Read Pointer", "slimp3.data_ack.read_pointer", 661 FT_UINT16, BASE_DEC, NULL, 0x0, 662 NULL, HFILL }}, 663 664 { &hf_slimp3_data_ack_sequence, 665 { "Sequence", "slimp3.data_ack.sequence", 666 FT_UINT16, BASE_DEC, NULL, 0x0, 667 NULL, HFILL }}, 668 669 { &hf_slimp3_data_req_offset, 670 { "Requested offset", "slimp3.data_req.offset", 671 FT_UINT16, BASE_DEC, NULL, 0x0, 672 NULL, HFILL }}, 673 674 /* Generated from convert_proto_tree_add_text.pl */ 675 { &hf_slimp3_display_delay, { "Delay", "slimp3.display_delay", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }}, 676 { &hf_slimp3_display_string, { "String", "slimp3.display_string", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, 677 { &hf_slimp3_display_command, { "Command", "slimp3.display_command", FT_UINT8, BASE_DEC, VALS(slimp3_display_commands), 0x0, NULL, HFILL }}, 678 { &hf_slimp3_display_unknown, { "Unknown", "slimp3.display_unknown", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, 679 { &hf_slimp3_hello_response_client_server, { "Hello Response (Client --> Server)", "slimp3.hello_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 680 { &hf_slimp3_hello_request_server_client, { "Hello Request (Server --> Client)", "slimp3.hello_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 681 { &hf_slimp3_i2c_response_client_server, { "I2C Response (Client --> Server)", "slimp3.i2c_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 682 { &hf_slimp3_i2c_request_server_client, { "I2C Request (Server --> Client)", "slimp3.i2c_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 683 { &hf_slimp3_data_length, { "Length", "slimp3.data.length", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 684 { &hf_slimp3_data_data, { "Data", "slimp3.data.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, 685 }; 686 687 static gint *ett[] = { 688 &ett_slimp3, 689 }; 690 691 proto_slimp3 = proto_register_protocol("SliMP3 Communication Protocol", "SliMP3", "slimp3"); 692 proto_register_field_array(proto_slimp3, hf, array_length(hf)); 693 proto_register_subtree_array(ett, array_length(ett)); 694 } 695 696 void 697 proto_reg_handoff_slimp3(void) 698 { 699 dissector_handle_t slimp3_handle; 700 701 slimp3_handle = create_dissector_handle(dissect_slimp3, proto_slimp3); 702 dissector_add_uint_range_with_preference("udp.port", UDP_PORT_SLIMP3_RANGE, slimp3_handle); 703 } 704 705 /* 706 * Editor modelines 707 * 708 * Local Variables: 709 * c-basic-offset: 4 710 * tab-width: 8 711 * indent-tabs-mode: nil 712 * End: 713 * 714 * ex: set shiftwidth=4 tabstop=8 expandtab: 715 * :indentSize=4:tabSize=8:noTabs=true: 716 */ 717