aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2013-12-12 23:11:04 +0000
committerBill Meier <wmeier@newsguy.com>2013-12-12 23:11:04 +0000
commit37f60fa2d62eeed4a9fc31142fb036cc4ecf1a20 (patch)
treee22c68a294e2d7d0e75d939e265450fd9861378e
parent5db2d622e4fa800d406efe94d0b961bebd60420c (diff)
In one or more of the files:
- Create/use some extended value-strings; - Remove some unneeded initializers; - 'offset++' --> 'offset += 1' for consistency; - Set editor modelines 'tab-width' to 8 (not 4); - tabs --> spaces (to match editor modelines); - Rework/add whitespace. svn path=/trunk/; revision=53998
-rw-r--r--epan/dissectors/packet-slimp3.c1171
-rw-r--r--epan/dissectors/packet-soupbintcp.c26
-rw-r--r--epan/dissectors/packet-ssl-utils.h2
-rw-r--r--epan/dissectors/packet-stun.c904
-rw-r--r--epan/dissectors/packet-tftp.c504
-rw-r--r--epan/dissectors/packet-usb-audio.c42
-rw-r--r--epan/dissectors/packet-vrrp.c100
-rw-r--r--epan/dissectors/packet-websocket.c100
8 files changed, 1426 insertions, 1423 deletions
diff --git a/epan/dissectors/packet-slimp3.c b/epan/dissectors/packet-slimp3.c
index 8ad1f64d0e..519c88eb7a 100644
--- a/epan/dissectors/packet-slimp3.c
+++ b/epan/dissectors/packet-slimp3.c
@@ -65,643 +65,644 @@ static gint ett_slimp3 = -1;
#define UDP_PORT_SLIMP3_V1 1069
#define UDP_PORT_SLIMP3_V2 3483
-#define SLIMP3_IR 'i'
-#define SLIMP3_CONTROL 's'
-#define SLIMP3_HELLO 'h'
-#define SLIMP3_DATA 'm'
-#define SLIMP3_DATA_REQ 'r'
-#define SLIMP3_DISPLAY 'l'
-#define SLIMP3_I2C '2'
-#define SLIMP3_DISC_REQ 'd'
-#define SLIMP3_DISC_RSP 'D'
+#define SLIMP3_IR 'i'
+#define SLIMP3_CONTROL 's'
+#define SLIMP3_HELLO 'h'
+#define SLIMP3_DATA 'm'
+#define SLIMP3_DATA_REQ 'r'
+#define SLIMP3_DISPLAY 'l'
+#define SLIMP3_I2C '2'
+#define SLIMP3_DISC_REQ 'd'
+#define SLIMP3_DISC_RSP 'D'
#define SLIMP3_DATA_ACK 'a'
static const value_string slimp3_opcode_vals[] = {
- { SLIMP3_IR, "Infrared Remote Code" },
- { SLIMP3_CONTROL, "Stream Control" },
- { SLIMP3_DATA, "MPEG Data" },
- { SLIMP3_DATA_REQ, "Data Request" },
- { SLIMP3_HELLO, "Hello" },
- { SLIMP3_DISPLAY, "Display" },
- { SLIMP3_I2C, "I2C" },
- { SLIMP3_DISC_REQ, "Discovery Request" },
- { SLIMP3_DISC_RSP, "Discovery Response" },
- { SLIMP3_DATA_ACK, "Ack" },
- { 0, NULL }
+ { SLIMP3_IR, "Infrared Remote Code" },
+ { SLIMP3_CONTROL, "Stream Control" },
+ { SLIMP3_DATA, "MPEG Data" },
+ { SLIMP3_DATA_REQ, "Data Request" },
+ { SLIMP3_HELLO, "Hello" },
+ { SLIMP3_DISPLAY, "Display" },
+ { SLIMP3_I2C, "I2C" },
+ { SLIMP3_DISC_REQ, "Discovery Request" },
+ { SLIMP3_DISC_RSP, "Discovery Response" },
+ { SLIMP3_DATA_ACK, "Ack" },
+ { 0, NULL }
};
/* IR remote control types */
static const value_string slimp3_ir_types[] = {
- { 0x02, "SLIMP3" },
- { 0xff, "JVC DVD Player" },
+ { 0x02, "SLIMP3" },
+ { 0xff, "JVC DVD Player" },
- { 0, NULL }
+ { 0, NULL }
};
/* IR codes for the custom SLIMP3 remote control */
static const value_string slimp3_ir_codes_slimp3[] = {
- { 0x76899867, "0" },
- { 0x7689f00f, "1" },
- { 0x768908f7, "2" },
- { 0x76898877, "3" },
- { 0x768948b7, "4" },
- { 0x7689c837, "5" },
- { 0x768928d7, "6" },
- { 0x7689a857, "7" },
- { 0x76896897, "8" },
- { 0x7689e817, "9" },
- { 0x7689b04f, "arrow_down" },
- { 0x7689906f, "arrow_left" },
- { 0x7689d02f, "arrow_right" },
- { 0x7689e01f, "arrow_up" },
- { 0x768900ff, "voldown" },
- { 0x7689807f, "volup" },
- { 0x768940bf, "power" },
- { 0x7689c03f, "rew" },
- { 0x768920df, "pause" },
- { 0x7689a05f, "fwd" },
- { 0x7689609f, "add" },
- { 0x768910ef, "play" },
- { 0x768958a7, "search" },
- { 0x7689d827, "shuffle" },
- { 0x768938c7, "repeat" },
- { 0x7689b847, "sleep" },
- { 0x76897887, "now_playing" },
- { 0x7689f807, "size" },
- { 0x768904fb, "brightness" },
-
- { 0, NULL }
+ { 0x768900ff, "voldown" },
+ { 0x768904fb, "brightness" },
+ { 0x768908f7, "2" },
+ { 0x768910ef, "play" },
+ { 0x768920df, "pause" },
+ { 0x768928d7, "6" },
+ { 0x768938c7, "repeat" },
+ { 0x768940bf, "power" },
+ { 0x768948b7, "4" },
+ { 0x768958a7, "search" },
+ { 0x7689609f, "add" },
+ { 0x76896897, "8" },
+ { 0x76897887, "now_playing" },
+ { 0x7689807f, "volup" },
+ { 0x76898877, "3" },
+ { 0x7689906f, "arrow_left" },
+ { 0x76899867, "0" },
+ { 0x7689a05f, "fwd" },
+ { 0x7689a857, "7" },
+ { 0x7689b04f, "arrow_down" },
+ { 0x7689b847, "sleep" },
+ { 0x7689c03f, "rew" },
+ { 0x7689c837, "5" },
+ { 0x7689d02f, "arrow_right" },
+ { 0x7689d827, "shuffle" },
+ { 0x7689e01f, "arrow_up" },
+ { 0x7689e817, "9" },
+ { 0x7689f00f, "1" },
+ { 0x7689f807, "size" },
+
+ { 0, NULL }
};
+static value_string_ext slimp3_ir_codes_slimp3_ext = VALUE_STRING_EXT_INIT(slimp3_ir_codes_slimp3);
/* IR codes for the JVC remote control */
static const value_string slimp3_ir_codes_jvc[] = {
- { 0xf786, "One" },
- { 0xf746, "Two" },
- { 0xf7c6, "Three" },
- { 0xf726, "Four" },
- { 0xf7a6, "Five" },
- { 0xf766, "Six" },
- { 0xf7e6, "Seven" },
- { 0xf716, "Eight" },
- { 0xf796, "Nine" },
- { 0xf776, "Ten" },
-
- { 0xf7f6, "Picture-In-Picture" },
- /* { 0xf7XX, "Enter" }, */
- { 0xf70e, "Back" },
- { 0xf732, "Play" },
- { 0xf76e, "Forward" },
- { 0xf743, "Record" },
- { 0xf7c2, "Stop" },
- { 0xf7b2, "Pause" },
- /* { 0xf7XX, "TV/Video" }, */
- { 0xf703, "Display" },
- { 0xf7b3, "Sleep" },
- { 0xf7b6, "Guide" },
- { 0xf70b, "Up" },
- { 0xf74b, "Left" },
- { 0xf7cb, "Right" },
- { 0xf78b, "Down" },
- { 0xf783, "Menu" },
- { 0xf72b, "OK" },
- { 0xf778, "Volume Up" },
- { 0xf7f8, "Volume Down" },
- { 0xf70d, "Channel Up" },
- { 0xf78d, "Channel Down" },
- /* { 0xf7XX, "Mute" }, */
- { 0xf7ab, "Recall" },
- { 0xf702, "Power" },
-
- { 0, NULL }
+ { 0xf786, "One" },
+ { 0xf746, "Two" },
+ { 0xf7c6, "Three" },
+ { 0xf726, "Four" },
+ { 0xf7a6, "Five" },
+ { 0xf766, "Six" },
+ { 0xf7e6, "Seven" },
+ { 0xf716, "Eight" },
+ { 0xf796, "Nine" },
+ { 0xf776, "Ten" },
+
+ { 0xf7f6, "Picture-In-Picture" },
+ /* { 0xf7XX, "Enter" }, */
+ { 0xf70e, "Back" },
+ { 0xf732, "Play" },
+ { 0xf76e, "Forward" },
+ { 0xf743, "Record" },
+ { 0xf7c2, "Stop" },
+ { 0xf7b2, "Pause" },
+ /* { 0xf7XX, "TV/Video" }, */
+ { 0xf703, "Display" },
+ { 0xf7b3, "Sleep" },
+ { 0xf7b6, "Guide" },
+ { 0xf70b, "Up" },
+ { 0xf74b, "Left" },
+ { 0xf7cb, "Right" },
+ { 0xf78b, "Down" },
+ { 0xf783, "Menu" },
+ { 0xf72b, "OK" },
+ { 0xf778, "Volume Up" },
+ { 0xf7f8, "Volume Down" },
+ { 0xf70d, "Channel Up" },
+ { 0xf78d, "Channel Down" },
+ /* { 0xf7XX, "Mute" }, */
+ { 0xf7ab, "Recall" },
+ { 0xf702, "Power" },
+
+ { 0, NULL }
};
static const value_string slimp3_display_commands[] = {
- { 0x1, "Clear Display"},
- { 0x2, "Cursor to 1st Line Home"},
+ { 0x1, "Clear Display"},
+ { 0x2, "Cursor to 1st Line Home"},
- { 0x4, "Mode: Decrement Address, Shift Cursor"},
- { 0x5, "Mode: Decrement Address, Shift Display"},
- { 0x6, "Mode: Increment Address, Shift Cursor"},
- { 0x7, "Mode: Increment Address, Shift Display"},
+ { 0x4, "Mode: Decrement Address, Shift Cursor"},
+ { 0x5, "Mode: Decrement Address, Shift Display"},
+ { 0x6, "Mode: Increment Address, Shift Cursor"},
+ { 0x7, "Mode: Increment Address, Shift Display"},
- { 0x8, "Display Off"},
- { 0xd, "Display On, With Blinking"},
- { 0xe, "Display On, With Cursor"},
- { 0xf, "Display On, With Cursor And Blinking"},
+ { 0x8, "Display Off"},
+ { 0xd, "Display On, With Blinking"},
+ { 0xe, "Display On, With Cursor"},
+ { 0xf, "Display On, With Cursor And Blinking"},
- { 0x10, "Move Cursor Left"},
- { 0x14, "Move Cursor Right"},
- { 0x18, "Shift Display Left"},
- { 0x1b, "Shift Display Right"},
+ { 0x10, "Move Cursor Left"},
+ { 0x14, "Move Cursor Right"},
+ { 0x18, "Shift Display Left"},
+ { 0x1b, "Shift Display Right"},
- { 0x30, "Set (8-bit)"},
- { 0x20, "Set (4-bit)"},
+ { 0x30, "Set (8-bit)"},
+ { 0x20, "Set (4-bit)"},
- { 0xa0, "Cursor to Top Right"},
- { 0xc0, "Cursor to 2nd Line Home"},
+ { 0xa0, "Cursor to Top Right"},
+ { 0xc0, "Cursor to 2nd Line Home"},
- { 0, NULL},
+ { 0, NULL},
};
static const value_string slimp3_display_fset8[] = {
- { 0x0, "Brightness 100%"},
- { 0x1, "Brightness 75%"},
- { 0x2, "Brightness 50%"},
- { 0x3, "Brightness 25%"},
+ { 0x0, "Brightness 100%"},
+ { 0x1, "Brightness 75%"},
+ { 0x2, "Brightness 50%"},
+ { 0x3, "Brightness 25%"},
- { 0, NULL },
+ { 0, NULL },
};
static const value_string slimp3_stream_control[] = {
- { 1, "Reset buffer, Start New Stream"},
- { 2, "Pause Playback"},
- { 4, "Resume Playback"},
- { 0, NULL },
+ { 1, "Reset buffer, Start New Stream"},
+ { 2, "Pause Playback"},
+ { 4, "Resume Playback"},
+ { 0, NULL },
};
static const value_string slimp3_mpg_control[] = {
- { 0, "Go"}, /* Run the decoder */
- { 1, "Stop"}, /* Halt decoder but don't reset rptr */
- { 3, "Reset"}, /* Halt decoder and reset rptr */
+ { 0, "Go"}, /* Run the decoder */
+ { 1, "Stop"}, /* Halt decoder but don't reset rptr */
+ { 3, "Reset"}, /* Halt decoder and reset rptr */
- { 0, NULL }
+ { 0, NULL }
};
#define MAX_LCD_STR_LEN 128
static int
dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- const char *opcode_str;
- proto_tree *slimp3_tree;
- proto_item *ti;
- gint i1;
- gint offset = 0;
- guint16 opcode;
- guchar lcd_char;
- char lcd_str[MAX_LCD_STR_LEN + 1];
- int to_server = FALSE;
- int old_protocol = FALSE;
- address tmp_addr;
- gboolean in_str;
- int lcd_strlen;
-
- /*
- * If it doesn't begin with a known opcode, reject it, so that
- * traffic that happens to be do or from one of our ports
- * doesn't get misidentified as SliMP3 traffic.
- */
- if (!tvb_bytes_exist(tvb, offset, 1))
- return 0; /* not even an opcode */
- opcode = tvb_get_guint8(tvb, offset);
- opcode_str = try_val_to_str(opcode, slimp3_opcode_vals);
- if (opcode_str == NULL)
- return 0;
-
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3");
- col_add_str(pinfo->cinfo, COL_INFO, opcode_str);
-
- ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, ENC_NA);
- slimp3_tree = proto_item_add_subtree(ti, ett_slimp3);
-
- proto_tree_add_uint(slimp3_tree, hf_slimp3_opcode, tvb,
- offset, 1, opcode);
-
- /* The new protocol (v1.3 and later) uses an IANA-assigned port number.
- * It usually uses the same number for both sizes of the conversation, so
- * the port numbers can't always be used to determine client and server.
- * The new protocol places the clients MAC address in the packet, so that
- * is used to identify packets originating at the client.
- */
- if ((pinfo->destport == UDP_PORT_SLIMP3_V2) && (pinfo->srcport == UDP_PORT_SLIMP3_V2)) {
- TVB_SET_ADDRESS(&tmp_addr, AT_ETHER, tvb, offset+12, 6);
- to_server = ADDRESSES_EQUAL(&tmp_addr, &pinfo->dl_src);
- }
- else if (pinfo->destport == UDP_PORT_SLIMP3_V2) {
- to_server = TRUE;
- }
- else if (pinfo->srcport == UDP_PORT_SLIMP3_V2) {
- to_server = FALSE;
- }
- if (pinfo->destport == UDP_PORT_SLIMP3_V1) {
- to_server = TRUE;
- old_protocol = TRUE;
- }
- else if (pinfo->srcport == UDP_PORT_SLIMP3_V1) {
- to_server = FALSE;
- old_protocol = TRUE;
- }
-
- switch (opcode) {
-
- case SLIMP3_IR:
- /* IR code
- *
- * [0] 'i' as in "IR"
- * [1] 0x00
- * [2..5] player's time since startup in ticks @625 KHz
- * [6] IR code id, ff=JVC, 02=SLIMP3
- * [7] number of meaningful bits - 16 for JVC, 32 for SLIMP3
- * [8..11] the 32-bit IR code
- * [12..17] reserved
- */
- if (tree) {
- i1 = tvb_get_ntohl(tvb, offset+2);
- proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_uptime, tvb, offset+2, 4, i1,
- "%u sec (%u ticks)", i1/625000, i1);
-
- proto_tree_add_item(slimp3_tree, hf_slimp3_code_id, tvb, offset+6, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(slimp3_tree, hf_slimp3_code_bits, tvb, offset+7, 1, ENC_BIG_ENDIAN);
-
- i1 = tvb_get_ntohl(tvb, offset+8);
- /* Check the code to figure out which remote is being used. */
- if (tvb_get_guint8(tvb, offset+6) == 0x02 &&
- tvb_get_guint8(tvb, offset+7) == 32) {
- /* This is the custom SLIMP3 remote. */
- proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_slimp3, tvb, offset+8, 4, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", SLIMP3: %s",
- val_to_str(i1, slimp3_ir_codes_slimp3, "Unknown (0x%0x)"));
- }
- else if (tvb_get_guint8(tvb, offset+6) == 0xff &&
- tvb_get_guint8(tvb, offset+7) == 16) {
- /* This is a JVC DVD player remote */
- proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_jvc, tvb, offset+8, 4, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", JVC: %s",
- val_to_str(i1, slimp3_ir_codes_jvc, "Unknown (0x%0x)"));
- } else {
- /* Unknown code; just write it */
- proto_tree_add_item(slimp3_tree, hf_slimp3_infrared, tvb, offset+8, 4, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", 0x%0x", i1);
- }
- }
- break;
-
- case SLIMP3_DISPLAY:
- if (tree) {
- /* Loop through the commands */
- i1 = 18;
- in_str = FALSE;
- lcd_strlen = 0;
- while (i1 < tvb_reported_length_remaining(tvb, offset)) {
- switch(tvb_get_guint8(tvb, offset + i1)) {
- case 0:
- in_str = FALSE;
- lcd_strlen = 0;
- proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
- "Delay (%u ms)", tvb_get_guint8(tvb, offset + i1 + 1));
- i1 += 2;
- break;
- case 3:
- lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
- if (!isprint(lcd_char))
- lcd_char = '.';
- if (ti && in_str) {
- lcd_strlen += 2;
- proto_item_append_text(ti, "%c", lcd_char);
- proto_item_set_len(ti, lcd_strlen);
- } else {
- ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
- "String: %c", lcd_char);
- in_str = TRUE;
- lcd_strlen = 2;
- }
- i1 += 2;
- break;
-
- case 2:
- in_str = FALSE;
- lcd_strlen = 0;
- ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
- "Command: %s",
- val_to_str(tvb_get_guint8(tvb, offset + i1 + 1),
- slimp3_display_commands,
- "Unknown (0x%0x)"));
- if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) {
- proto_item_append_text(ti, ": %s",
- val_to_str(tvb_get_guint8(tvb, offset + i1 + 2),
- slimp3_display_fset8,
- "Unknown (0x%0x)"));
- i1 += 2;
- }
- i1 += 2;
- break;
-
- default:
- proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
- "Unknown 0x%0x, 0x%0x",
- tvb_get_guint8(tvb, offset + i1),
- tvb_get_guint8(tvb, offset + i1 + 1));
- i1 += 2;
- break;
- }
- }
- }
-
- i1 = 18;
- lcd_strlen = 0;
- while (tvb_offset_exists(tvb, offset + i1) &&
- lcd_strlen < MAX_LCD_STR_LEN) {
- switch (tvb_get_guint8(tvb, offset + i1)) {
-
- case 0:
- lcd_str[lcd_strlen++] = '.';
- break;
-
- case 2:
- lcd_str[lcd_strlen++] = '|';
- if (tvb_offset_exists(tvb, offset + i1 + 1) &&
- (tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30)
- i1 += 2;
- break;
-
- case 3:
- if (tvb_offset_exists(tvb, offset + i1 + 1)) {
- if ((lcd_strlen < 1) ||
- (lcd_str[lcd_strlen-1] != ' ') ||
- (tvb_get_guint8(tvb, offset + i1 + 1) != ' ')) {
- lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
- lcd_str[lcd_strlen++] = isprint(lcd_char) ? lcd_char : '.';
- }
- }
- }
-
- i1 += 2;
- }
- lcd_str[lcd_strlen] = '\0';
- if (lcd_strlen > 0)
- col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", lcd_str);
- break;
-
- case SLIMP3_CONTROL:
- proto_tree_add_item(slimp3_tree, hf_slimp3_control, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
- val_to_str(tvb_get_guint8(tvb, offset+1),
- slimp3_stream_control, "Unknown (0x%0x)"));
- break;
-
- case SLIMP3_HELLO:
- if (tree) {
- if (to_server) {
- guint8 fw_ver;
- /* Hello response; client->server */
- proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Response (Client --> Server)");
- proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- fw_ver = tvb_get_guint8(tvb, offset+2);
- proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
- "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
- } else {
- /* Hello request; server->client */
- proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Request (Server --> Client)");
- }
- }
- break;
-
- case SLIMP3_I2C:
- if (to_server) {
- /* Hello response; client->server */
- proto_tree_add_text(slimp3_tree, tvb, offset, -1,
- "I2C Response (Client --> Server)");
- col_append_str(pinfo->cinfo, COL_INFO, ", Response");
- } else {
- /* Hello request; server->client */
- proto_tree_add_text(slimp3_tree, tvb, offset, -1,
- "I2C Request (Server --> Client)");
- col_append_str(pinfo->cinfo, COL_INFO, ", Request");
- }
- break;
-
- case SLIMP3_DATA_REQ:
- proto_tree_add_item(slimp3_tree, hf_slimp3_data_req_offset, tvb, offset+2, 2, ENC_BIG_ENDIAN);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Offset: %u bytes",
- tvb_get_ntohs(tvb, offset+2)*2);
- break;
-
- case SLIMP3_DATA:
- /* MPEG data (v1.3 and later)
- *
- * [0] 'm'
- * [1..5] reserved
- * [6..7] Write pointer (in words)
- * [8..9] reserved
- * [10..11] Sequence number
- * [12..17] reserved
- * [18..] MPEG data
- */
- if (old_protocol) {
- guint offset_buffer;
- proto_tree_add_text(slimp3_tree, tvb, offset, -1,
- "Length: %d bytes",
- tvb_reported_length_remaining(tvb, offset+18));
- offset_buffer = tvb_get_ntohs(tvb, offset+2) * 2;
- proto_tree_add_uint(slimp3_tree, hf_slimp3_data_offset, tvb, offset+2, 2, offset_buffer);
-
- col_append_fstr(pinfo->cinfo, COL_INFO,
- ", Length: %d bytes, Offset: %u bytes.",
- tvb_reported_length_remaining(tvb, offset+18),
- offset_buffer);
- }
- else {
- guint write_pointer;
- proto_tree_add_item(slimp3_tree, hf_slimp3_data_command, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- proto_tree_add_text(slimp3_tree, tvb, offset, -1,
- "Length: %d bytes",
- tvb_reported_length_remaining(tvb, offset+18));
- write_pointer = tvb_get_ntohs(tvb, offset+6) * 2;
- proto_tree_add_uint(slimp3_tree, hf_slimp3_data_write_pointer, tvb, offset+6, 2, write_pointer);
- proto_tree_add_item(slimp3_tree, hf_slimp3_data_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
-
- col_append_fstr(pinfo->cinfo, COL_INFO,
- ", %s, %d bytes at %u, Sequence: %u",
- val_to_str(tvb_get_guint8(tvb, offset+1),
- slimp3_mpg_control, "Unknown (0x%0x)"),
- tvb_reported_length_remaining(tvb, offset+18),
- write_pointer,
- tvb_get_ntohs(tvb, offset+10));
- }
- break;
-
- case SLIMP3_DISC_REQ:
- {
- guint8 fw_ver;
- proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- fw_ver = tvb_get_guint8(tvb, offset+2);
- proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
- "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Device ID: %u. Firmware: %u.%u",
- tvb_get_guint8(tvb, offset+1), fw_ver>>4, fw_ver & 0xf);
- }
- break;
-
- case SLIMP3_DISC_RSP:
- if (tree) {
- proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_ip, tvb, offset+2, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_port, tvb, offset+6, 2, ENC_BIG_ENDIAN);
- }
-
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Server Address: %s. Server Port: %u",
- tvb_ip_to_str(tvb, offset+2),
- tvb_get_ntohs(tvb, offset + 6));
- break;
-
- case SLIMP3_DATA_ACK:
- /* Acknowledge MPEG data
- *
- * [0] 'a'
- * [1..5]
- * [6..7] Write pointer (in words)
- * [8..9] Read pointer (in words)
- * [10..11] Sequence number
- * [12..17] client MAC address (v1.3 and later)
- */
- if (tree) {
- guint pointer;
-
- pointer = tvb_get_ntohs(tvb, offset+6) * 2;
- proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_write_pointer, tvb, offset+6, 2, pointer);
- pointer = tvb_get_ntohs(tvb, offset+8) * 2;
- proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_read_pointer, tvb, offset+8, 2, pointer);
- proto_tree_add_item(slimp3_tree, hf_slimp3_data_ack_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
- }
-
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Sequence: %u",
- tvb_get_ntohs(tvb, offset+10));
- break;
-
- default:
- if (tree) {
- proto_tree_add_text(slimp3_tree, tvb, offset, -1,
- "Data (%d bytes)", tvb_reported_length_remaining(tvb, offset));
- }
- break;
- }
-
- return tvb_reported_length(tvb);
+ const char *opcode_str;
+ proto_tree *slimp3_tree;
+ proto_item *ti;
+ gint i1;
+ gint offset = 0;
+ guint16 opcode;
+ guchar lcd_char;
+ char lcd_str[MAX_LCD_STR_LEN + 1];
+ int to_server = FALSE;
+ int old_protocol = FALSE;
+ address tmp_addr;
+ gboolean in_str;
+ int lcd_strlen;
+
+ /*
+ * If it doesn't begin with a known opcode, reject it, so that
+ * traffic that happens to be do or from one of our ports
+ * doesn't get misidentified as SliMP3 traffic.
+ */
+ if (!tvb_bytes_exist(tvb, offset, 1))
+ return 0; /* not even an opcode */
+ opcode = tvb_get_guint8(tvb, offset);
+ opcode_str = try_val_to_str(opcode, slimp3_opcode_vals);
+ if (opcode_str == NULL)
+ return 0;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3");
+ col_add_str(pinfo->cinfo, COL_INFO, opcode_str);
+
+ ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, ENC_NA);
+ slimp3_tree = proto_item_add_subtree(ti, ett_slimp3);
+
+ proto_tree_add_uint(slimp3_tree, hf_slimp3_opcode, tvb,
+ offset, 1, opcode);
+
+ /* The new protocol (v1.3 and later) uses an IANA-assigned port number.
+ * It usually uses the same number for both sizes of the conversation, so
+ * the port numbers can't always be used to determine client and server.
+ * The new protocol places the clients MAC address in the packet, so that
+ * is used to identify packets originating at the client.
+ */
+ if ((pinfo->destport == UDP_PORT_SLIMP3_V2) && (pinfo->srcport == UDP_PORT_SLIMP3_V2)) {
+ TVB_SET_ADDRESS(&tmp_addr, AT_ETHER, tvb, offset+12, 6);
+ to_server = ADDRESSES_EQUAL(&tmp_addr, &pinfo->dl_src);
+ }
+ else if (pinfo->destport == UDP_PORT_SLIMP3_V2) {
+ to_server = TRUE;
+ }
+ else if (pinfo->srcport == UDP_PORT_SLIMP3_V2) {
+ to_server = FALSE;
+ }
+ if (pinfo->destport == UDP_PORT_SLIMP3_V1) {
+ to_server = TRUE;
+ old_protocol = TRUE;
+ }
+ else if (pinfo->srcport == UDP_PORT_SLIMP3_V1) {
+ to_server = FALSE;
+ old_protocol = TRUE;
+ }
+
+ switch (opcode) {
+
+ case SLIMP3_IR:
+ /* IR code
+ *
+ * [0] 'i' as in "IR"
+ * [1] 0x00
+ * [2..5] player's time since startup in ticks @625 KHz
+ * [6] IR code id, ff=JVC, 02=SLIMP3
+ * [7] number of meaningful bits - 16 for JVC, 32 for SLIMP3
+ * [8..11] the 32-bit IR code
+ * [12..17] reserved
+ */
+ if (tree) {
+ i1 = tvb_get_ntohl(tvb, offset+2);
+ proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_uptime, tvb, offset+2, 4, i1,
+ "%u sec (%u ticks)", i1/625000, i1);
+
+ proto_tree_add_item(slimp3_tree, hf_slimp3_code_id, tvb, offset+6, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(slimp3_tree, hf_slimp3_code_bits, tvb, offset+7, 1, ENC_BIG_ENDIAN);
+
+ i1 = tvb_get_ntohl(tvb, offset+8);
+ /* Check the code to figure out which remote is being used. */
+ if (tvb_get_guint8(tvb, offset+6) == 0x02 &&
+ tvb_get_guint8(tvb, offset+7) == 32) {
+ /* This is the custom SLIMP3 remote. */
+ proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_slimp3, tvb, offset+8, 4, ENC_BIG_ENDIAN);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", SLIMP3: %s",
+ val_to_str_ext(i1, &slimp3_ir_codes_slimp3_ext, "Unknown (0x%0x)"));
+ }
+ else if (tvb_get_guint8(tvb, offset+6) == 0xff &&
+ tvb_get_guint8(tvb, offset+7) == 16) {
+ /* This is a JVC DVD player remote */
+ proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_jvc, tvb, offset+8, 4, ENC_BIG_ENDIAN);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", JVC: %s",
+ val_to_str(i1, slimp3_ir_codes_jvc, "Unknown (0x%0x)"));
+ } else {
+ /* Unknown code; just write it */
+ proto_tree_add_item(slimp3_tree, hf_slimp3_infrared, tvb, offset+8, 4, ENC_BIG_ENDIAN);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", 0x%0x", i1);
+ }
+ }
+ break;
+
+ case SLIMP3_DISPLAY:
+ if (tree) {
+ /* Loop through the commands */
+ i1 = 18;
+ in_str = FALSE;
+ lcd_strlen = 0;
+ while (i1 < tvb_reported_length_remaining(tvb, offset)) {
+ switch(tvb_get_guint8(tvb, offset + i1)) {
+ case 0:
+ in_str = FALSE;
+ lcd_strlen = 0;
+ proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
+ "Delay (%u ms)", tvb_get_guint8(tvb, offset + i1 + 1));
+ i1 += 2;
+ break;
+ case 3:
+ lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
+ if (!isprint(lcd_char))
+ lcd_char = '.';
+ if (ti && in_str) {
+ lcd_strlen += 2;
+ proto_item_append_text(ti, "%c", lcd_char);
+ proto_item_set_len(ti, lcd_strlen);
+ } else {
+ ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
+ "String: %c", lcd_char);
+ in_str = TRUE;
+ lcd_strlen = 2;
+ }
+ i1 += 2;
+ break;
+
+ case 2:
+ in_str = FALSE;
+ lcd_strlen = 0;
+ ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
+ "Command: %s",
+ val_to_str(tvb_get_guint8(tvb, offset + i1 + 1),
+ slimp3_display_commands,
+ "Unknown (0x%0x)"));
+ if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) {
+ proto_item_append_text(ti, ": %s",
+ val_to_str(tvb_get_guint8(tvb, offset + i1 + 2),
+ slimp3_display_fset8,
+ "Unknown (0x%0x)"));
+ i1 += 2;
+ }
+ i1 += 2;
+ break;
+
+ default:
+ proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
+ "Unknown 0x%0x, 0x%0x",
+ tvb_get_guint8(tvb, offset + i1),
+ tvb_get_guint8(tvb, offset + i1 + 1));
+ i1 += 2;
+ break;
+ }
+ }
+ }
+
+ i1 = 18;
+ lcd_strlen = 0;
+ while (tvb_offset_exists(tvb, offset + i1) &&
+ lcd_strlen < MAX_LCD_STR_LEN) {
+ switch (tvb_get_guint8(tvb, offset + i1)) {
+
+ case 0:
+ lcd_str[lcd_strlen++] = '.';
+ break;
+
+ case 2:
+ lcd_str[lcd_strlen++] = '|';
+ if (tvb_offset_exists(tvb, offset + i1 + 1) &&
+ (tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30)
+ i1 += 2;
+ break;
+
+ case 3:
+ if (tvb_offset_exists(tvb, offset + i1 + 1)) {
+ if ((lcd_strlen < 1) ||
+ (lcd_str[lcd_strlen-1] != ' ') ||
+ (tvb_get_guint8(tvb, offset + i1 + 1) != ' ')) {
+ lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
+ lcd_str[lcd_strlen++] = isprint(lcd_char) ? lcd_char : '.';
+ }
+ }
+ }
+
+ i1 += 2;
+ }
+ lcd_str[lcd_strlen] = '\0';
+ if (lcd_strlen > 0)
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", lcd_str);
+ break;
+
+ case SLIMP3_CONTROL:
+ proto_tree_add_item(slimp3_tree, hf_slimp3_control, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
+ val_to_str(tvb_get_guint8(tvb, offset+1),
+ slimp3_stream_control, "Unknown (0x%0x)"));
+ break;
+
+ case SLIMP3_HELLO:
+ if (tree) {
+ if (to_server) {
+ guint8 fw_ver;
+ /* Hello response; client->server */
+ proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Response (Client --> Server)");
+ proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ fw_ver = tvb_get_guint8(tvb, offset+2);
+ proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
+ "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
+ } else {
+ /* Hello request; server->client */
+ proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Request (Server --> Client)");
+ }
+ }
+ break;
+
+ case SLIMP3_I2C:
+ if (to_server) {
+ /* Hello response; client->server */
+ proto_tree_add_text(slimp3_tree, tvb, offset, -1,
+ "I2C Response (Client --> Server)");
+ col_append_str(pinfo->cinfo, COL_INFO, ", Response");
+ } else {
+ /* Hello request; server->client */
+ proto_tree_add_text(slimp3_tree, tvb, offset, -1,
+ "I2C Request (Server --> Client)");
+ col_append_str(pinfo->cinfo, COL_INFO, ", Request");
+ }
+ break;
+
+ case SLIMP3_DATA_REQ:
+ proto_tree_add_item(slimp3_tree, hf_slimp3_data_req_offset, tvb, offset+2, 2, ENC_BIG_ENDIAN);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Offset: %u bytes",
+ tvb_get_ntohs(tvb, offset+2)*2);
+ break;
+
+ case SLIMP3_DATA:
+ /* MPEG data (v1.3 and later)
+ *
+ * [0] 'm'
+ * [1..5] reserved
+ * [6..7] Write pointer (in words)
+ * [8..9] reserved
+ * [10..11] Sequence number
+ * [12..17] reserved
+ * [18..] MPEG data
+ */
+ if (old_protocol) {
+ guint offset_buffer;
+ proto_tree_add_text(slimp3_tree, tvb, offset, -1,
+ "Length: %d bytes",
+ tvb_reported_length_remaining(tvb, offset+18));
+ offset_buffer = tvb_get_ntohs(tvb, offset+2) * 2;
+ proto_tree_add_uint(slimp3_tree, hf_slimp3_data_offset, tvb, offset+2, 2, offset_buffer);
+
+ col_append_fstr(pinfo->cinfo, COL_INFO,
+ ", Length: %d bytes, Offset: %u bytes.",
+ tvb_reported_length_remaining(tvb, offset+18),
+ offset_buffer);
+ }
+ else {
+ guint write_pointer;
+ proto_tree_add_item(slimp3_tree, hf_slimp3_data_command, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_text(slimp3_tree, tvb, offset, -1,
+ "Length: %d bytes",
+ tvb_reported_length_remaining(tvb, offset+18));
+ write_pointer = tvb_get_ntohs(tvb, offset+6) * 2;
+ proto_tree_add_uint(slimp3_tree, hf_slimp3_data_write_pointer, tvb, offset+6, 2, write_pointer);
+ proto_tree_add_item(slimp3_tree, hf_slimp3_data_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
+
+ col_append_fstr(pinfo->cinfo, COL_INFO,
+ ", %s, %d bytes at %u, Sequence: %u",
+ val_to_str(tvb_get_guint8(tvb, offset+1),
+ slimp3_mpg_control, "Unknown (0x%0x)"),
+ tvb_reported_length_remaining(tvb, offset+18),
+ write_pointer,
+ tvb_get_ntohs(tvb, offset+10));
+ }
+ break;
+
+ case SLIMP3_DISC_REQ:
+ {
+ guint8 fw_ver;
+ proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ fw_ver = tvb_get_guint8(tvb, offset+2);
+ proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
+ "%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Device ID: %u. Firmware: %u.%u",
+ tvb_get_guint8(tvb, offset+1), fw_ver>>4, fw_ver & 0xf);
+ }
+ break;
+
+ case SLIMP3_DISC_RSP:
+ if (tree) {
+ proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_ip, tvb, offset+2, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_port, tvb, offset+6, 2, ENC_BIG_ENDIAN);
+ }
+
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Server Address: %s. Server Port: %u",
+ tvb_ip_to_str(tvb, offset+2),
+ tvb_get_ntohs(tvb, offset + 6));
+ break;
+
+ case SLIMP3_DATA_ACK:
+ /* Acknowledge MPEG data
+ *
+ * [0] 'a'
+ * [1..5]
+ * [6..7] Write pointer (in words)
+ * [8..9] Read pointer (in words)
+ * [10..11] Sequence number
+ * [12..17] client MAC address (v1.3 and later)
+ */
+ if (tree) {
+ guint pointer;
+
+ pointer = tvb_get_ntohs(tvb, offset+6) * 2;
+ proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_write_pointer, tvb, offset+6, 2, pointer);
+ pointer = tvb_get_ntohs(tvb, offset+8) * 2;
+ proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_read_pointer, tvb, offset+8, 2, pointer);
+ proto_tree_add_item(slimp3_tree, hf_slimp3_data_ack_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
+ }
+
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Sequence: %u",
+ tvb_get_ntohs(tvb, offset+10));
+ break;
+
+ default:
+ if (tree) {
+ proto_tree_add_text(slimp3_tree, tvb, offset, -1,
+ "Data (%d bytes)", tvb_reported_length_remaining(tvb, offset));
+ }
+ break;
+ }
+
+ return tvb_reported_length(tvb);
}
void
proto_register_slimp3(void)
{
- static hf_register_info hf[] = {
- { &hf_slimp3_opcode,
- { "Opcode", "slimp3.opcode",
- FT_UINT8, BASE_DEC, VALS(slimp3_opcode_vals), 0x0,
- "SLIMP3 message type", HFILL }},
-
- { &hf_slimp3_control,
- { "Control Packet", "slimp3.control",
- FT_UINT8, BASE_DEC, VALS(slimp3_stream_control), 0x0,
- "SLIMP3 control", HFILL }},
-
- { &hf_slimp3_uptime,
- { "Uptime", "slimp3.uptime",
- FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_code_id,
- { "Code identifier", "slimp3.code_id",
- FT_UINT8, BASE_DEC, VALS(slimp3_ir_types), 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_code_bits,
- { "Code bits", "slimp3.code_bits",
- FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_infrared_slimp3,
- { "Infrared Code", "slimp3.infrared",
- FT_UINT32, BASE_HEX, VALS(slimp3_ir_codes_slimp3), 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_infrared_jvc,
- { "Infrared Code", "slimp3.infrared",
- FT_UINT32, BASE_HEX, VALS(slimp3_ir_codes_jvc), 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_infrared,
- { "Infrared Code", "slimp3.infrared",
- FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_device_id,
- { "Device ID", "slimp3.device_id",
- FT_UINT8, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_fw_rev,
- { "Firmware Revision", "slimp3.fw_rev",
- FT_UINT8, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_offset,
- { "Buffer offset", "slimp3.data.offset",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_command,
- { "Command", "slimp3.data.command",
- FT_UINT8, BASE_HEX, VALS(slimp3_mpg_control), 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_write_pointer,
- { "Write Pointer", "slimp3.data.write_pointer",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_sequence,
- { "Sequence", "slimp3.data.sequence",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_disc_rsp_server_ip,
- { "Server Address", "slimp3.disc_rsp.server_ip",
- FT_IPv4, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_disc_rsp_server_port,
- { "Server Port", "slimp3.disc_rsp.server_port",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_ack_write_pointer,
- { "Write Pointer", "slimp3.data_ack.write_pointer",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_ack_read_pointer,
- { "Read Pointer", "slimp3.data_ack.read_pointer",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_ack_sequence,
- { "Sequence", "slimp3.data_ack.sequence",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_slimp3_data_req_offset,
- { "Requested offset", "slimp3.data_req.offset",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
- };
-
- static gint *ett[] = {
- &ett_slimp3,
- };
-
- proto_slimp3 = proto_register_protocol("SliMP3 Communication Protocol",
- "SliMP3", "slimp3");
- proto_register_field_array(proto_slimp3, hf, array_length(hf));
- proto_register_subtree_array(ett, array_length(ett));
+ static hf_register_info hf[] = {
+ { &hf_slimp3_opcode,
+ { "Opcode", "slimp3.opcode",
+ FT_UINT8, BASE_DEC, VALS(slimp3_opcode_vals), 0x0,
+ "SLIMP3 message type", HFILL }},
+
+ { &hf_slimp3_control,
+ { "Control Packet", "slimp3.control",
+ FT_UINT8, BASE_DEC, VALS(slimp3_stream_control), 0x0,
+ "SLIMP3 control", HFILL }},
+
+ { &hf_slimp3_uptime,
+ { "Uptime", "slimp3.uptime",
+ FT_UINT32, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_code_id,
+ { "Code identifier", "slimp3.code_id",
+ FT_UINT8, BASE_DEC, VALS(slimp3_ir_types), 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_code_bits,
+ { "Code bits", "slimp3.code_bits",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_infrared_slimp3,
+ { "Infrared Code", "slimp3.infrared",
+ FT_UINT32, BASE_HEX | BASE_EXT_STRING, &slimp3_ir_codes_slimp3_ext, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_infrared_jvc,
+ { "Infrared Code", "slimp3.infrared",
+ FT_UINT32, BASE_HEX, VALS(slimp3_ir_codes_jvc), 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_infrared,
+ { "Infrared Code", "slimp3.infrared",
+ FT_UINT32, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_device_id,
+ { "Device ID", "slimp3.device_id",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_fw_rev,
+ { "Firmware Revision", "slimp3.fw_rev",
+ FT_UINT8, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_offset,
+ { "Buffer offset", "slimp3.data.offset",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_command,
+ { "Command", "slimp3.data.command",
+ FT_UINT8, BASE_HEX, VALS(slimp3_mpg_control), 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_write_pointer,
+ { "Write Pointer", "slimp3.data.write_pointer",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_sequence,
+ { "Sequence", "slimp3.data.sequence",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_disc_rsp_server_ip,
+ { "Server Address", "slimp3.disc_rsp.server_ip",
+ FT_IPv4, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_disc_rsp_server_port,
+ { "Server Port", "slimp3.disc_rsp.server_port",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_ack_write_pointer,
+ { "Write Pointer", "slimp3.data_ack.write_pointer",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_ack_read_pointer,
+ { "Read Pointer", "slimp3.data_ack.read_pointer",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_ack_sequence,
+ { "Sequence", "slimp3.data_ack.sequence",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+
+ { &hf_slimp3_data_req_offset,
+ { "Requested offset", "slimp3.data_req.offset",
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ NULL, HFILL }},
+ };
+
+ static gint *ett[] = {
+ &ett_slimp3,
+ };
+
+ proto_slimp3 = proto_register_protocol("SliMP3 Communication Protocol",
+ "SliMP3", "slimp3");
+ proto_register_field_array(proto_slimp3, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_slimp3(void)
{
- dissector_handle_t slimp3_handle;
+ dissector_handle_t slimp3_handle;
- slimp3_handle = new_create_dissector_handle(dissect_slimp3, proto_slimp3);
- dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V1, slimp3_handle);
- dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V2, slimp3_handle);
+ slimp3_handle = new_create_dissector_handle(dissect_slimp3, proto_slimp3);
+ dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V1, slimp3_handle);
+ dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V2, slimp3_handle);
}
/*
@@ -709,10 +710,10 @@ proto_reg_handoff_slimp3(void)
*
* Local Variables:
* c-basic-offset: 4
- * tab-width: 4
+ * tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=4 tabstop=4 expandtab:
- * :indentSize=4:tabSize=4:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/epan/dissectors/packet-soupbintcp.c b/epan/dissectors/packet-soupbintcp.c
index 704c0661fd..ce9f934810 100644
--- a/epan/dissectors/packet-soupbintcp.c
+++ b/epan/dissectors/packet-soupbintcp.c
@@ -180,17 +180,17 @@ dissect_soupbintcp_common(
proto_tree *tree)
{
struct conv_data *conv_data;
- struct pdu_data *pdu_data;
- tvbuff_t *sub_tvb = NULL;
- const char *pkt_name;
- const char *tmp_buf;
- proto_item *ti;
- proto_tree *soupbintcp_tree = NULL;
- conversation_t *conv = NULL;
- guint16 expected_len;
- guint8 pkt_type;
- gint offset = 0;
- guint this_seq = 0, next_seq;
+ struct pdu_data *pdu_data;
+ tvbuff_t *sub_tvb = NULL;
+ const char *pkt_name;
+ const char *tmp_buf;
+ proto_item *ti;
+ proto_tree *soupbintcp_tree = NULL;
+ conversation_t *conv = NULL;
+ guint16 expected_len;
+ guint8 pkt_type;
+ gint offset = 0;
+ guint this_seq = 0, next_seq;
/* Get the 16-bit big-endian SOUP packet length */
expected_len = tvb_get_ntohs(tvb, 0);
@@ -482,10 +482,10 @@ dissect_soupbintcp_tcp(
static void
soupbintcp_prefs(void)
{
- dissector_delete_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle);
+ dissector_delete_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle);
g_free(soupbintcp_range);
soupbintcp_range = range_copy(global_soupbintcp_range);
- dissector_add_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle);
+ dissector_add_uint_range("tcp.port", soupbintcp_range, soupbintcp_handle);
}
diff --git a/epan/dissectors/packet-ssl-utils.h b/epan/dissectors/packet-ssl-utils.h
index d09966fc48..8d802bcd02 100644
--- a/epan/dissectors/packet-ssl-utils.h
+++ b/epan/dissectors/packet-ssl-utils.h
@@ -26,7 +26,7 @@
#ifndef __SSL_UTILS_H_
#define __SSL_UTILS_H_
-#include <stdio.h> /* some APIs we declare take a stdio stream as an argument */
+#include <stdio.h> /* some APIs we declare take a stdio stream as an argument */
#include <glib.h>
#include <epan/packet.h>
diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c
index 596cc244c5..e225157bda 100644
--- a/epan/dissectors/packet-stun.c
+++ b/epan/dissectors/packet-stun.c
@@ -233,17 +233,17 @@ static const value_string methods[] = {
static const value_string attributes[] = {
{MAPPED_ADDRESS , "MAPPED-ADDRESS"},
- {CHANGE_REQUEST , "CHANGE_REQUEST"},
{RESPONSE_ADDRESS , "RESPONSE_ADDRESS"},
- {USERNAME , "USERNAME"},
+ {CHANGE_REQUEST , "CHANGE_REQUEST"},
{SOURCE_ADDRESS , "SOURCE_ADDRESS"},
{CHANGED_ADDRESS , "CHANGED_ADDRESS"},
- {MESSAGE_INTEGRITY , "MESSAGE-INTEGRITY"},
+ {USERNAME , "USERNAME"},
{PASSWORD , "PASSWORD"},
+ {MESSAGE_INTEGRITY , "MESSAGE-INTEGRITY"},
{ERROR_CODE , "ERROR-CODE"},
{UNKNOWN_ATTRIBUTES , "UNKNOWN-ATTRIBUTES"},
- {CHANNEL_NUMBER , "CHANNEL-NUMBER"},
{REFLECTED_FROM , "REFLECTED-FROM"},
+ {CHANNEL_NUMBER , "CHANNEL-NUMBER"},
{LIFETIME , "LIFETIME"},
{BANDWIDTH , "BANDWIDTH"},
{XOR_PEER_ADDRESS , "XOR-PEER-ADDRESS"},
@@ -263,6 +263,7 @@ static const value_string attributes[] = {
{XOR_RESPONSE_TARGET , "XOR-RESPONSE-TARGET"},
{XOR_REFLECTED_FROM , "XOR-REFELECTED-FROM"},
{ICMP , "ICMP"},
+
{SOFTWARE , "SOFTWARE"},
{ALTERNATE_SERVER , "ALTERNATE-SERVER"},
{CACHE_TIMEOUT , "CACHE-TIMEOUT"},
@@ -273,6 +274,7 @@ static const value_string attributes[] = {
{OTHER_ADDRESS , "OTHER-ADDRESS"},
{0x00 , NULL}
};
+static value_string_ext attributes_ext = VALUE_STRING_EXT_INIT(attributes);
static const value_string assignments[] = {
{0x0000, "IETF Review"},
@@ -307,25 +309,25 @@ static const value_string attributes_family[] = {
};
static const value_string error_code[] = {
- {300, "Try Alternate"},/* rfc3489bis-15 */
- {400, "Bad Request"},/* rfc3489bis-15 */
- {401, "Unauthorized"},/* rfc3489bis-15 */
- {420, "Unknown Attribute"},/* rfc3489bis-15 */
- {437, "Allocation Mismatch"},/* turn-07 */
- {438, "Stale Nonce"},/* rfc3489bis-15 */
- {439, "Wrong Credentials"}, /* turn-07 - collision 38=>39 */
- {442, "Unsupported Transport Protocol"},/* turn-07 */
- {440, "Address Family not Supported"}, /* turn-ipv6-04 */
- {481, "Connection does not exist"}, /* nat-behavior-discovery-03 */
- {486, "Allocation Quota Reached"},/* turn-07 */
- {500, "Server Error"},/* rfc3489bis-15 */
- {503, "Service Unavailable"}, /* nat-behavior-discovery-03 */
- {507, "Insufficient Bandwidth Capacity"},/* turn-07 */
- {508, "Insufficient Port Capacity"},/* turn-07 */
+ {300, "Try Alternate"}, /* rfc3489bis-15 */
+ {400, "Bad Request"}, /* rfc3489bis-15 */
+ {401, "Unauthorized"}, /* rfc3489bis-15 */
+ {420, "Unknown Attribute"}, /* rfc3489bis-15 */
+ {437, "Allocation Mismatch"}, /* turn-07 */
+ {438, "Stale Nonce"}, /* rfc3489bis-15 */
+ {439, "Wrong Credentials"}, /* turn-07 - collision 38=>39 */
+ {440, "Address Family not Supported"}, /* turn-ipv6-04 */
+ {442, "Unsupported Transport Protocol"}, /* turn-07 */
+ {481, "Connection does not exist"}, /* nat-behavior-discovery-03 */
+ {486, "Allocation Quota Reached"}, /* turn-07 */
+ {500, "Server Error"}, /* rfc3489bis-15 */
+ {503, "Service Unavailable"}, /* nat-behavior-discovery-03 */
+ {507, "Insufficient Bandwidth Capacity"}, /* turn-07 */
+ {508, "Insufficient Port Capacity"}, /* turn-07 */
{600, "Global Failure"},
{0x00, NULL}
};
-
+static value_string_ext error_code_ext = VALUE_STRING_EXT_INIT(error_code);
static guint
get_stun_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
@@ -439,8 +441,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
* rather weak
*/
if (find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
- pinfo->ptype, pinfo->srcport,
- pinfo->destport, 0) == NULL)
+ pinfo->ptype, pinfo->srcport,
+ pinfo->destport, 0) == NULL)
return 0;
}
@@ -495,7 +497,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
if (!pinfo->fd->flags.visited) {
if ((stun_trans = (stun_transaction_t *)
wmem_tree_lookup32_array(stun_info->transaction_pdus,
- transaction_id_key)) == NULL) {
+ transaction_id_key)) == NULL) {
transaction_id_key[0].length = 3;
transaction_id_key[0].key = transaction_id;
@@ -507,8 +509,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
stun_trans->rep_frame=0;
stun_trans->req_time=pinfo->fd->abs_ts;
wmem_tree_insert32_array(stun_info->transaction_pdus,
- transaction_id_key,
- (void *)stun_trans);
+ transaction_id_key,
+ (void *)stun_trans);
}
if (msg_type_class == REQUEST) {
@@ -526,7 +528,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
}
} else {
stun_trans=(stun_transaction_t *)wmem_tree_lookup32_array(stun_info->transaction_pdus,
- transaction_id_key);
+ transaction_id_key);
}
if (!stun_trans) {
@@ -542,7 +544,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
msg_method_str = val_to_str_const(msg_type_method, methods, "Unknown");
col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
- msg_method_str, msg_class_str);
+ msg_method_str, msg_class_str);
ti = proto_tree_add_item(tree, proto_stun, tvb, 0, -1, ENC_NA);
@@ -554,15 +556,15 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
if (stun_trans->req_frame != pinfo->fd->num) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_duplicate,
- tvb, 0, 0,
- stun_trans->req_frame);
+ tvb, 0, 0,
+ stun_trans->req_frame);
PROTO_ITEM_SET_GENERATED(it);
}
if (stun_trans->rep_frame) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_response_in,
- tvb, 0, 0,
- stun_trans->rep_frame);
+ tvb, 0, 0,
+ stun_trans->rep_frame);
PROTO_ITEM_SET_GENERATED(it);
}
}
@@ -571,8 +573,8 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
if (stun_trans->rep_frame != pinfo->fd->num) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_duplicate,
- tvb, 0, 0,
- stun_trans->rep_frame);
+ tvb, 0, 0,
+ stun_trans->rep_frame);
PROTO_ITEM_SET_GENERATED(it);
}
if (msg_type_class == RESPONSE || msg_type_class == ERROR_RESPONSE) {
@@ -582,7 +584,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
nstime_t ns;
it=proto_tree_add_uint(stun_tree, hf_stun_response_to, tvb, 0, 0,
- stun_trans->req_frame);
+ stun_trans->req_frame);
PROTO_ITEM_SET_GENERATED(it);
nstime_delta(&ns, &pinfo->fd->abs_ts, &stun_trans->req_time);
@@ -594,7 +596,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
}
ti = proto_tree_add_uint_format_value(stun_tree, hf_stun_type, tvb, 0, 2,
- msg_type, "0x%04x (%s %s)", msg_type, msg_method_str, msg_class_str);
+ msg_type, "0x%04x (%s %s)", msg_type, msg_method_str, msg_class_str);
stun_type_tree = proto_item_add_subtree(ti, ett_stun_type);
proto_tree_add_uint(stun_type_tree, hf_stun_type_class, tvb, 0, 2, msg_type);
ti = proto_tree_add_text(stun_type_tree, tvb, 0, 2, "%s (%d)", msg_class_str, msg_type_class);
@@ -604,9 +606,9 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
PROTO_ITEM_SET_GENERATED(ti);
proto_tree_add_uint(stun_type_tree, hf_stun_type_method_assignment, tvb, 0, 2, msg_type);
ti = proto_tree_add_text(stun_type_tree, tvb, 0, 2,
- "%s (%d)",
- val_to_str((msg_type & 0x2000) >> 13, assignments, "Unknown: 0x%x"),
- (msg_type & 0x2000) >> 13);
+ "%s (%d)",
+ val_to_str((msg_type & 0x2000) >> 13, assignments, "Unknown: 0x%x"),
+ (msg_type & 0x2000) >> 13);
PROTO_ITEM_SET_GENERATED(ti);
proto_tree_add_item(stun_tree, hf_stun_length, tvb, 2, 2, ENC_BIG_ENDIAN);
@@ -630,436 +632,436 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
att_length = tvb_get_ntohs(tvb, offset+2); /* Length field in attribute header */
if(att_all_tree){
ti = proto_tree_add_uint_format(att_all_tree, hf_stun_attr,
- tvb, offset, ATTR_HDR_LEN+att_length,
- att_type, "%s", val_to_str_const(att_type, attributes, "Unknown"));
+ tvb, offset, ATTR_HDR_LEN+att_length,
+ att_type, "%s", val_to_str_ext_const(att_type, &attributes_ext, "Unknown"));
att_tree = proto_item_add_subtree(ti, ett_stun_att);
ti = proto_tree_add_uint(att_tree, stun_att_type, tvb,
- offset, 2, att_type);
+ offset, 2, att_type);
att_type_tree = proto_item_add_subtree(ti, ett_stun_att_type);
proto_tree_add_uint(att_type_tree, stun_att_type_comprehension, tvb, offset, 2, att_type);
ti = proto_tree_add_text(att_type_tree, tvb, offset, 2,
- "%s (%d)",
- val_to_str((att_type & 0x8000) >> 15, comprehensions, "Unknown: %d"),
- (att_type & 0x8000) >> 15);
+ "%s (%d)",
+ val_to_str((att_type & 0x8000) >> 15, comprehensions, "Unknown: %d"),
+ (att_type & 0x8000) >> 15);
PROTO_ITEM_SET_GENERATED(ti);
proto_tree_add_uint(att_type_tree, stun_att_type_assignment, tvb, offset, 2, att_type);
ti = proto_tree_add_text(att_type_tree, tvb, offset, 2,
- "%s (%d)",
- val_to_str((att_type & 0x4000) >> 14, assignments, "Unknown: %d"),
- (att_type & 0x4000) >> 14);
+ "%s (%d)",
+ val_to_str((att_type & 0x4000) >> 14, assignments, "Unknown: %d"),
+ (att_type & 0x4000) >> 14);
PROTO_ITEM_SET_GENERATED(ti);
if ((offset+ATTR_HDR_LEN+att_length) > (STUN_HDR_LEN+msg_length)) {
proto_tree_add_uint_format_value(att_tree,
- stun_att_length, tvb, offset+2, 2,
- att_length,
- "%u (bogus, goes past the end of the message)",
- att_length);
+ stun_att_length, tvb, offset+2, 2,
+ att_length,
+ "%u (bogus, goes past the end of the message)",
+ att_length);
break;
}
}
offset += 2;
proto_tree_add_uint(att_tree, stun_att_length, tvb,
- offset, 2, att_length);
+ offset, 2, att_length);
offset += 2;
- switch (att_type) {
-
- /* Deprecated STUN RFC3489 attributes */
- case RESPONSE_ADDRESS:
- case SOURCE_ADDRESS:
- case CHANGED_ADDRESS:
- case REFLECTED_FROM:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (att_length < 2)
- break;
- proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
- switch (tvb_get_guint8(tvb, offset+1))
- {
- case 1:
- if (att_length < 8)
- break;
- proto_tree_add_item(att_tree, stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(att_tree, " (Deprecated): %s:%d", tvb_ip_to_str(tvb, offset+4),tvb_get_ntohs(tvb,offset+2));
-
- break;
-
- case 2:
- if (att_length < 20)
- break;
- proto_tree_add_item(att_tree, stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
- break;
- }
- break;
-
- /* Deprecated STUN RFC3489 attributes */
- case PASSWORD:
- proto_tree_add_item(att_tree, stun_att_password, tvb, offset, att_length, ENC_ASCII|ENC_NA);
- proto_item_append_text(att_tree, " (Deprecated): %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding,
- tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case MAPPED_ADDRESS:
- case ALTERNATE_SERVER:
- case RESPONSE_ORIGIN:
- case OTHER_ADDRESS:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (att_length < 2)
- break;
- proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
- switch (tvb_get_guint8(tvb, offset+1)) {
- case 1:
- if (att_length < 8)
- break;
- proto_tree_add_item(att_tree, stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(att_tree, ": %s:%d", tvb_ip_to_str(tvb,offset+4),tvb_get_ntohs(tvb,offset+2));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " %s: %s:%d",
- val_to_str_const(att_type, attributes, "Unknown"),
- tvb_ip_to_str(tvb,offset+4),
- tvb_get_ntohs(tvb,offset+2)
- );
- break;
-
- case 2:
- if (att_length < 20)
- break;
- proto_tree_add_item(att_tree, stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
- break;
- }
- break;
-
- case CHANGE_REQUEST:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_change_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(att_tree, stun_att_change_port, tvb, offset, 4, ENC_BIG_ENDIAN);
- break;
-
- case USERNAME:
- proto_tree_add_item(att_tree, stun_att_username, tvb, offset, att_length, ENC_ASCII|ENC_NA);
- proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " user: %s",
- tvb_get_string(wmem_packet_scope(), tvb,offset, att_length)
- );
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding,
- tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case MESSAGE_INTEGRITY:
- if (att_length < 20)
- break;
- proto_tree_add_item(att_tree, stun_att_hmac, tvb, offset, att_length, ENC_NA);
- break;
-
- case ERROR_CODE:
- if (att_length < 2)
- break;
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
- if (att_length < 3)
- break;
- proto_tree_add_item(att_tree, stun_att_error_class, tvb, offset+2, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_error_number, tvb, offset+3, 1, ENC_BIG_ENDIAN);
- {
- int human_error_num = tvb_get_guint8(tvb, offset+2) * 100 + tvb_get_guint8(tvb, offset+3);
- proto_item_append_text(
- att_tree,
- " %d (%s)",
- human_error_num, /* human readable error code */
- val_to_str_const(human_error_num, error_code, "*Unknown error code*")
- );
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " error-code: %d (%s)",
- human_error_num,
- val_to_str_const(human_error_num, error_code, "*Unknown error code*")
- );
- }
- if (att_length < 5)
- break;
- proto_tree_add_item(att_tree, stun_att_error_reason, tvb, offset+4, att_length-4, ENC_ASCII|ENC_NA);
-
- proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset+4, att_length-4));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " %s",
- tvb_get_string(wmem_packet_scope(), tvb, offset+4, att_length-4)
- );
-
-
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case UNKNOWN_ATTRIBUTES:
- for (i = 0; i < att_length; i += 2)
- proto_tree_add_item(att_tree, stun_att_unknown, tvb, offset+i, 2, ENC_BIG_ENDIAN);
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case REALM:
- proto_tree_add_item(att_tree, stun_att_realm, tvb, offset, att_length, ENC_ASCII|ENC_NA);
- proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " realm: %s",
- tvb_get_string(wmem_packet_scope(), tvb,offset, att_length)
- );
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case NONCE:
- proto_tree_add_item(att_tree, stun_att_nonce, tvb, offset, att_length, ENC_ASCII|ENC_NA);
- proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
- col_append_str(
- pinfo->cinfo, COL_INFO,
- " with nonce"
- );
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case XOR_MAPPED_ADDRESS:
- case XOR_PEER_ADDRESS:
- case XOR_RELAYED_ADDRESS:
- case XOR_RESPONSE_TARGET:
- case XOR_REFLECTED_FROM:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (att_length < 2)
- break;
- proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_xor_port, tvb, offset+2, 2, ENC_NA);
-
- /* Show the port 'in the clear'
- XOR (host order) transid with (host order) xor-port.
- Add host-order port into tree. */
- ti = proto_tree_add_uint(att_tree, stun_att_port, tvb, offset+2, 2,
- tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16));
- PROTO_ITEM_SET_GENERATED(ti);
-
- if (att_length < 8)
- break;
- switch (tvb_get_guint8(tvb, offset+1)) {
- case 1:
- proto_tree_add_item(att_tree, stun_att_xor_ipv4, tvb, offset+4, 4, ENC_NA);
-
- /* Show the address 'in the clear'.
- XOR (host order) transid with (host order) xor-address.
- Add in network order tree. */
- ti = proto_tree_add_ipv4(att_tree, stun_att_ipv4, tvb, offset+4, 4,
- tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word));
- PROTO_ITEM_SET_GENERATED(ti);
-
- {
- const gchar *ipstr;
- guint32 ip;
- guint16 port;
- ip = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word);
- ipstr = ip_to_str((guint8*)&ip);
- port = tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16);
- proto_item_append_text(att_tree, ": %s:%d", ipstr, port);
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " %s: %s:%d",
- val_to_str_const(att_type, attributes, "Unknown"),
- ipstr,
- port
- );
- }
- break;
-
- case 2:
- if (att_length < 20)
- break;
- proto_tree_add_item(att_tree, stun_att_xor_ipv6, tvb, offset+4, 16, ENC_NA);
- {
- guint32 IPv6[4];
- tvb_get_ipv6(tvb, offset+4, (struct e_in6_addr *)IPv6);
- IPv6[0] = IPv6[0] ^ g_htonl(magic_cookie_first_word);
- IPv6[1] = IPv6[1] ^ g_htonl(transaction_id[0]);
- IPv6[2] = IPv6[2] ^ g_htonl(transaction_id[1]);
- IPv6[3] = IPv6[3] ^ g_htonl(transaction_id[2]);
- ti = proto_tree_add_ipv6(att_tree, stun_att_ipv6, tvb, offset+4, 16,
- (const guint8 *)IPv6);
- PROTO_ITEM_SET_GENERATED(ti);
- }
-
- break;
- }
- break;
-
- case REQUESTED_ADDRESS_TYPE:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_family, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+1, 3, ENC_BIG_ENDIAN);
- break;
- case EVEN_PORT:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_reserve_next, tvb, offset, 1, ENC_BIG_ENDIAN);
- break;
-
- case RESERVATION_TOKEN:
- if (att_length < 8)
- break;
- proto_tree_add_item(att_tree, stun_att_token, tvb, offset, 8, ENC_NA);
- break;
-
- case PRIORITY:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_priority, tvb, offset, 4, ENC_BIG_ENDIAN);
- break;
-
- case PADDING:
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset, att_length, att_length);
- break;
-
- case ICMP:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_icmp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(att_tree, stun_att_icmp_code, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- break;
-
- case SOFTWARE:
- proto_tree_add_item(att_tree, stun_att_software, tvb, offset, att_length, ENC_ASCII|ENC_NA);
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
-
- case CACHE_TIMEOUT:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_cache_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
- break;
-
- case FINGERPRINT:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_crc32, tvb, offset, att_length, ENC_BIG_ENDIAN);
- break;
-
- case ICE_CONTROLLED:
- case ICE_CONTROLLING:
- if (att_length < 8)
- break;
- proto_tree_add_item(att_tree, stun_att_tie_breaker, tvb, offset, 8, ENC_NA);
- break;
-
- case DATA:
- if (att_length > 0) {
- tvbuff_t *next_tvb;
- proto_tree_add_item(att_tree, stun_att_value, tvb, offset, att_length, ENC_NA);
- if (att_length % 4 != 0) {
- guint pad;
- pad = 4-(att_length % 4);
- proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, pad, pad);
- }
-
- next_tvb = tvb_new_subset(tvb, offset, att_length, att_length);
-
- if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, att_tree, NULL)) {
- call_dissector_only(data_handle, next_tvb, pinfo, att_tree, NULL);
- }
-
- }
- break;
-
- case REQUESTED_TRANSPORT:
- if (att_length < 1)
- break;
- proto_tree_add_item(att_tree, stun_att_transp, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (att_length < 4)
- break;
-
- {
- guint8 protoCode = tvb_get_guint8(tvb, offset);
- proto_item_append_text(att_tree, ": %s", val_to_str(protoCode, transportnames, "Unknown (0x%8x)"));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " %s",
- val_to_str(protoCode, transportnames, "Unknown (0x%8x)")
- );
- }
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+1, 3, ENC_BIG_ENDIAN);
- break;
-
- case CHANNEL_NUMBER:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_channelnum, tvb, offset, 2, ENC_BIG_ENDIAN);
- {
- guint16 chan = tvb_get_ntohs(tvb, offset);
- proto_item_append_text(att_tree, ": 0x%x", chan);
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " ChannelNumber=0x%x",
- chan
- );
- }
- proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+2, 2, ENC_BIG_ENDIAN);
- break;
-
- case BANDWIDTH:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_bandwidth, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " bandwidth: %d",
- tvb_get_ntohl(tvb, offset)
- );
- break;
- case LIFETIME:
- if (att_length < 4)
- break;
- proto_tree_add_item(att_tree, stun_att_lifetime, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
- col_append_fstr(
- pinfo->cinfo, COL_INFO,
- " lifetime: %d",
- tvb_get_ntohl(tvb, offset)
- );
- break;
-
- default:
- if (att_length > 0)
- proto_tree_add_item(att_tree, stun_att_value, tvb, offset, att_length, ENC_NA);
- if (att_length % 4 != 0)
- proto_tree_add_uint(att_tree, stun_att_padding, tvb,
- offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
- break;
- }
+ switch (att_type) {
+
+ /* Deprecated STUN RFC3489 attributes */
+ case RESPONSE_ADDRESS:
+ case SOURCE_ADDRESS:
+ case CHANGED_ADDRESS:
+ case REFLECTED_FROM:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (att_length < 2)
+ break;
+ proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
+ switch (tvb_get_guint8(tvb, offset+1))
+ {
+ case 1:
+ if (att_length < 8)
+ break;
+ proto_tree_add_item(att_tree, stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
+ proto_item_append_text(att_tree, " (Deprecated): %s:%d", tvb_ip_to_str(tvb, offset+4),tvb_get_ntohs(tvb,offset+2));
+
+ break;
+
+ case 2:
+ if (att_length < 20)
+ break;
+ proto_tree_add_item(att_tree, stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
+ break;
+ }
+ break;
+
+ /* Deprecated STUN RFC3489 attributes */
+ case PASSWORD:
+ proto_tree_add_item(att_tree, stun_att_password, tvb, offset, att_length, ENC_ASCII|ENC_NA);
+ proto_item_append_text(att_tree, " (Deprecated): %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding,
+ tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case MAPPED_ADDRESS:
+ case ALTERNATE_SERVER:
+ case RESPONSE_ORIGIN:
+ case OTHER_ADDRESS:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (att_length < 2)
+ break;
+ proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
+ switch (tvb_get_guint8(tvb, offset+1)) {
+ case 1:
+ if (att_length < 8)
+ break;
+ proto_tree_add_item(att_tree, stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
+ proto_item_append_text(att_tree, ": %s:%d", tvb_ip_to_str(tvb,offset+4),tvb_get_ntohs(tvb,offset+2));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " %s: %s:%d",
+ val_to_str_ext_const(att_type, &attributes_ext, "Unknown"),
+ tvb_ip_to_str(tvb,offset+4),
+ tvb_get_ntohs(tvb,offset+2)
+ );
+ break;
+
+ case 2:
+ if (att_length < 20)
+ break;
+ proto_tree_add_item(att_tree, stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
+ break;
+ }
+ break;
+
+ case CHANGE_REQUEST:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_change_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(att_tree, stun_att_change_port, tvb, offset, 4, ENC_BIG_ENDIAN);
+ break;
+
+ case USERNAME:
+ proto_tree_add_item(att_tree, stun_att_username, tvb, offset, att_length, ENC_ASCII|ENC_NA);
+ proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " user: %s",
+ tvb_get_string(wmem_packet_scope(), tvb,offset, att_length)
+ );
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding,
+ tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case MESSAGE_INTEGRITY:
+ if (att_length < 20)
+ break;
+ proto_tree_add_item(att_tree, stun_att_hmac, tvb, offset, att_length, ENC_NA);
+ break;
+
+ case ERROR_CODE:
+ if (att_length < 2)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
+ if (att_length < 3)
+ break;
+ proto_tree_add_item(att_tree, stun_att_error_class, tvb, offset+2, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_error_number, tvb, offset+3, 1, ENC_BIG_ENDIAN);
+ {
+ int human_error_num = tvb_get_guint8(tvb, offset+2) * 100 + tvb_get_guint8(tvb, offset+3);
+ proto_item_append_text(
+ att_tree,
+ " %d (%s)",
+ human_error_num, /* human readable error code */
+ val_to_str_ext_const(human_error_num, &error_code_ext, "*Unknown error code*")
+ );
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " error-code: %d (%s)",
+ human_error_num,
+ val_to_str_ext_const(human_error_num, &error_code_ext, "*Unknown error code*")
+ );
+ }
+ if (att_length < 5)
+ break;
+ proto_tree_add_item(att_tree, stun_att_error_reason, tvb, offset+4, att_length-4, ENC_ASCII|ENC_NA);
+
+ proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset+4, att_length-4));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " %s",
+ tvb_get_string(wmem_packet_scope(), tvb, offset+4, att_length-4)
+ );
+
+
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case UNKNOWN_ATTRIBUTES:
+ for (i = 0; i < att_length; i += 2)
+ proto_tree_add_item(att_tree, stun_att_unknown, tvb, offset+i, 2, ENC_BIG_ENDIAN);
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case REALM:
+ proto_tree_add_item(att_tree, stun_att_realm, tvb, offset, att_length, ENC_ASCII|ENC_NA);
+ proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " realm: %s",
+ tvb_get_string(wmem_packet_scope(), tvb,offset, att_length)
+ );
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case NONCE:
+ proto_tree_add_item(att_tree, stun_att_nonce, tvb, offset, att_length, ENC_ASCII|ENC_NA);
+ proto_item_append_text(att_tree, ": %s", tvb_get_string(wmem_packet_scope(), tvb, offset, att_length));
+ col_append_str(
+ pinfo->cinfo, COL_INFO,
+ " with nonce"
+ );
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case XOR_MAPPED_ADDRESS:
+ case XOR_PEER_ADDRESS:
+ case XOR_RELAYED_ADDRESS:
+ case XOR_RESPONSE_TARGET:
+ case XOR_REFLECTED_FROM:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (att_length < 2)
+ break;
+ proto_tree_add_item(att_tree, stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_xor_port, tvb, offset+2, 2, ENC_NA);
+
+ /* Show the port 'in the clear'
+ XOR (host order) transid with (host order) xor-port.
+ Add host-order port into tree. */
+ ti = proto_tree_add_uint(att_tree, stun_att_port, tvb, offset+2, 2,
+ tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16));
+ PROTO_ITEM_SET_GENERATED(ti);
+
+ if (att_length < 8)
+ break;
+ switch (tvb_get_guint8(tvb, offset+1)) {
+ case 1:
+ proto_tree_add_item(att_tree, stun_att_xor_ipv4, tvb, offset+4, 4, ENC_NA);
+
+ /* Show the address 'in the clear'.
+ XOR (host order) transid with (host order) xor-address.
+ Add in network order tree. */
+ ti = proto_tree_add_ipv4(att_tree, stun_att_ipv4, tvb, offset+4, 4,
+ tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word));
+ PROTO_ITEM_SET_GENERATED(ti);
+
+ {
+ const gchar *ipstr;
+ guint32 ip;
+ guint16 port;
+ ip = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word);
+ ipstr = ip_to_str((guint8*)&ip);
+ port = tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16);
+ proto_item_append_text(att_tree, ": %s:%d", ipstr, port);
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " %s: %s:%d",
+ val_to_str_ext_const(att_type, &attributes_ext, "Unknown"),
+ ipstr,
+ port
+ );
+ }
+ break;
+
+ case 2:
+ if (att_length < 20)
+ break;
+ proto_tree_add_item(att_tree, stun_att_xor_ipv6, tvb, offset+4, 16, ENC_NA);
+ {
+ guint32 IPv6[4];
+ tvb_get_ipv6(tvb, offset+4, (struct e_in6_addr *)IPv6);
+ IPv6[0] = IPv6[0] ^ g_htonl(magic_cookie_first_word);
+ IPv6[1] = IPv6[1] ^ g_htonl(transaction_id[0]);
+ IPv6[2] = IPv6[2] ^ g_htonl(transaction_id[1]);
+ IPv6[3] = IPv6[3] ^ g_htonl(transaction_id[2]);
+ ti = proto_tree_add_ipv6(att_tree, stun_att_ipv6, tvb, offset+4, 16,
+ (const guint8 *)IPv6);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
+
+ break;
+ }
+ break;
+
+ case REQUESTED_ADDRESS_TYPE:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_family, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+1, 3, ENC_BIG_ENDIAN);
+ break;
+ case EVEN_PORT:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_reserve_next, tvb, offset, 1, ENC_BIG_ENDIAN);
+ break;
+
+ case RESERVATION_TOKEN:
+ if (att_length < 8)
+ break;
+ proto_tree_add_item(att_tree, stun_att_token, tvb, offset, 8, ENC_NA);
+ break;
+
+ case PRIORITY:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_priority, tvb, offset, 4, ENC_BIG_ENDIAN);
+ break;
+
+ case PADDING:
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset, att_length, att_length);
+ break;
+
+ case ICMP:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_icmp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(att_tree, stun_att_icmp_code, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ break;
+
+ case SOFTWARE:
+ proto_tree_add_item(att_tree, stun_att_software, tvb, offset, att_length, ENC_ASCII|ENC_NA);
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+
+ case CACHE_TIMEOUT:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_cache_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
+ break;
+
+ case FINGERPRINT:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_crc32, tvb, offset, att_length, ENC_BIG_ENDIAN);
+ break;
+
+ case ICE_CONTROLLED:
+ case ICE_CONTROLLING:
+ if (att_length < 8)
+ break;
+ proto_tree_add_item(att_tree, stun_att_tie_breaker, tvb, offset, 8, ENC_NA);
+ break;
+
+ case DATA:
+ if (att_length > 0) {
+ tvbuff_t *next_tvb;
+ proto_tree_add_item(att_tree, stun_att_value, tvb, offset, att_length, ENC_NA);
+ if (att_length % 4 != 0) {
+ guint pad;
+ pad = 4-(att_length % 4);
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb, offset+att_length, pad, pad);
+ }
+
+ next_tvb = tvb_new_subset(tvb, offset, att_length, att_length);
+
+ if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, att_tree, NULL)) {
+ call_dissector_only(data_handle, next_tvb, pinfo, att_tree, NULL);
+ }
+
+ }
+ break;
+
+ case REQUESTED_TRANSPORT:
+ if (att_length < 1)
+ break;
+ proto_tree_add_item(att_tree, stun_att_transp, tvb, offset, 1, ENC_BIG_ENDIAN);
+ if (att_length < 4)
+ break;
+
+ {
+ guint8 protoCode = tvb_get_guint8(tvb, offset);
+ proto_item_append_text(att_tree, ": %s", val_to_str(protoCode, transportnames, "Unknown (0x%8x)"));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " %s",
+ val_to_str(protoCode, transportnames, "Unknown (0x%8x)")
+ );
+ }
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+1, 3, ENC_BIG_ENDIAN);
+ break;
+
+ case CHANNEL_NUMBER:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_channelnum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ {
+ guint16 chan = tvb_get_ntohs(tvb, offset);
+ proto_item_append_text(att_tree, ": 0x%x", chan);
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " ChannelNumber=0x%x",
+ chan
+ );
+ }
+ proto_tree_add_item(att_tree, stun_att_reserved, tvb, offset+2, 2, ENC_BIG_ENDIAN);
+ break;
+
+ case BANDWIDTH:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_bandwidth, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " bandwidth: %d",
+ tvb_get_ntohl(tvb, offset)
+ );
+ break;
+ case LIFETIME:
+ if (att_length < 4)
+ break;
+ proto_tree_add_item(att_tree, stun_att_lifetime, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
+ col_append_fstr(
+ pinfo->cinfo, COL_INFO,
+ " lifetime: %d",
+ tvb_get_ntohl(tvb, offset)
+ );
+ break;
+
+ default:
+ if (att_length > 0)
+ proto_tree_add_item(att_tree, stun_att_value, tvb, offset, att_length, ENC_NA);
+ if (att_length % 4 != 0)
+ proto_tree_add_uint(att_tree, stun_att_padding, tvb,
+ offset+att_length, 4-(att_length % 4), 4-(att_length % 4));
+ break;
+ }
offset += (att_length+3) & ~0x3;
}
}
@@ -1160,7 +1162,7 @@ proto_register_stun(void)
/* ////////////////////////////////////// */
{ &stun_att_type,
{ "Attribute Type", "stun.att.type", FT_UINT16,
- BASE_HEX, VALS(attributes), 0x0, NULL, HFILL }
+ BASE_HEX | BASE_EXT_STRING, &attributes_ext, 0x0, NULL, HFILL }
},
{ &stun_att_type_comprehension,
{ "Attribute Type Comprehension", "stun.att.type.comprehension", FT_UINT16,
@@ -1331,8 +1333,8 @@ proto_register_stun(void)
/* heuristic subdissectors (used for the DATA field) */
register_heur_dissector_list("stun", &heur_subdissector_list);
- new_register_dissector("stun-udp", dissect_stun, proto_stun);
- new_register_dissector("stun-heur", dissect_stun_heur, proto_stun);
+ new_register_dissector("stun-udp", dissect_stun, proto_stun);
+ new_register_dissector("stun-heur", dissect_stun_heur, proto_stun);
}
void
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c
index 2517984abb..6cd181d138 100644
--- a/epan/dissectors/packet-tftp.c
+++ b/epan/dissectors/packet-tftp.c
@@ -55,8 +55,8 @@ void proto_register_tftp(void);
/* Things we may want to remember for a whole conversation */
typedef struct _tftp_conv_info_t {
- guint16 blocksize;
- gchar *source_file, *destination_file;
+ guint16 blocksize;
+ gchar *source_file, *destination_file;
} tftp_conv_info_t;
@@ -86,13 +86,13 @@ void proto_reg_handoff_tftp (void);
/* User definable values */
static range_t *global_tftp_port_range;
-#define TFTP_RRQ 1
-#define TFTP_WRQ 2
-#define TFTP_DATA 3
-#define TFTP_ACK 4
-#define TFTP_ERROR 5
-#define TFTP_OACK 6
-#define TFTP_INFO 255
+#define TFTP_RRQ 1
+#define TFTP_WRQ 2
+#define TFTP_DATA 3
+#define TFTP_ACK 4
+#define TFTP_ERROR 5
+#define TFTP_OACK 6
+#define TFTP_INFO 255
static const value_string tftp_opcode_vals[] = {
{ TFTP_RRQ, "Read Request" },
@@ -111,7 +111,7 @@ static const value_string tftp_error_code_vals[] = {
{ 2, "Access violation" },
{ 3, "Disk full or allocation exceeded" },
{ 4, "Illegal TFTP Operation" },
- { 5, "Unknown transfer ID" }, /* Does not cause termination */
+ { 5, "Unknown transfer ID" }, /* Does not cause termination */
{ 6, "File already exists" },
{ 7, "No such user" },
{ 8, "Option negotiation failed" },
@@ -120,206 +120,206 @@ static const value_string tftp_error_code_vals[] = {
static void
tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset,
- proto_tree *tree, guint16 opcode, tftp_conv_info_t *tftp_info)
+ proto_tree *tree, guint16 opcode, tftp_conv_info_t *tftp_info)
{
- int option_len, value_len;
- int value_offset;
- const char *optionname;
- const char *optionvalue;
- proto_item *opt_item;
- proto_tree *opt_tree;
-
- while (tvb_offset_exists(tvb, offset)) {
- option_len = tvb_strsize(tvb, offset); /* length of option */
- value_offset = offset + option_len;
- value_len = tvb_strsize(tvb, value_offset); /* length of value */
- optionname = tvb_format_text(tvb, offset, option_len);
- optionvalue = tvb_format_text(tvb, value_offset, value_len);
- opt_item = proto_tree_add_text(tree, tvb, offset, option_len+value_len,
- "Option: %s = %s", optionname, optionvalue);
-
- opt_tree = proto_item_add_subtree(opt_item, ett_tftp_option);
- proto_tree_add_item(opt_tree, hf_tftp_option_name, tvb, offset,
- option_len, ENC_ASCII|ENC_NA);
- proto_tree_add_item(opt_tree, hf_tftp_option_value, tvb, value_offset,
- value_len, ENC_ASCII|ENC_NA);
-
- offset += option_len + value_len;
-
- col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=%s",
- optionname, optionvalue);
-
- /* Special code to handle individual options */
- if (!g_ascii_strcasecmp((const char *)optionname, "blksize") &&
- opcode == TFTP_OACK) {
- gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10);
- if (blocksize < 8 || blocksize > 65464) {
- expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range);
- } else {
- tftp_info->blocksize = blocksize;
- }
- }
- }
+ int option_len, value_len;
+ int value_offset;
+ const char *optionname;
+ const char *optionvalue;
+ proto_item *opt_item;
+ proto_tree *opt_tree;
+
+ while (tvb_offset_exists(tvb, offset)) {
+ option_len = tvb_strsize(tvb, offset); /* length of option */
+ value_offset = offset + option_len;
+ value_len = tvb_strsize(tvb, value_offset); /* length of value */
+ optionname = tvb_format_text(tvb, offset, option_len);
+ optionvalue = tvb_format_text(tvb, value_offset, value_len);
+ opt_item = proto_tree_add_text(tree, tvb, offset, option_len+value_len,
+ "Option: %s = %s", optionname, optionvalue);
+
+ opt_tree = proto_item_add_subtree(opt_item, ett_tftp_option);
+ proto_tree_add_item(opt_tree, hf_tftp_option_name, tvb, offset,
+ option_len, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(opt_tree, hf_tftp_option_value, tvb, value_offset,
+ value_len, ENC_ASCII|ENC_NA);
+
+ offset += option_len + value_len;
+
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=%s",
+ optionname, optionvalue);
+
+ /* Special code to handle individual options */
+ if (!g_ascii_strcasecmp((const char *)optionname, "blksize") &&
+ opcode == TFTP_OACK) {
+ gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10);
+ if (blocksize < 8 || blocksize > 65464) {
+ expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range);
+ } else {
+ tftp_info->blocksize = blocksize;
+ }
+ }
+ }
}
static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
- tvbuff_t *tvb, packet_info *pinfo,
- proto_tree *tree)
+ tvbuff_t *tvb, packet_info *pinfo,
+ proto_tree *tree)
{
- proto_tree *tftp_tree = NULL;
- proto_item *ti;
- gint offset = 0;
- guint16 opcode;
- guint16 bytes;
- guint16 blocknum;
- guint i1;
- guint16 error;
-
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "TFTP");
-
- opcode = tvb_get_ntohs(tvb, offset);
-
- col_add_str(pinfo->cinfo, COL_INFO,
- val_to_str(opcode, tftp_opcode_vals, "Unknown (0x%04x)"));
-
- if (tree) {
- ti = proto_tree_add_item(tree, proto_tftp, tvb, offset, -1, ENC_NA);
- tftp_tree = proto_item_add_subtree(ti, ett_tftp);
-
- if (tftp_info->source_file) {
- ti = proto_tree_add_string(tftp_tree, hf_tftp_source_file, tvb,
- 0, 0, tftp_info->source_file);
- PROTO_ITEM_SET_GENERATED(ti);
- }
-
- if (tftp_info->destination_file) {
- ti = proto_tree_add_string(tftp_tree, hf_tftp_destination_file, tvb,
- 0, 0, tftp_info->destination_file);
- PROTO_ITEM_SET_GENERATED(ti);
- }
-
- proto_tree_add_uint(tftp_tree, hf_tftp_opcode, tvb,
- offset, 2, opcode);
- }
- offset += 2;
+ proto_tree *tftp_tree = NULL;
+ proto_item *ti;
+ gint offset = 0;
+ guint16 opcode;
+ guint16 bytes;
+ guint16 blocknum;
+ guint i1;
+ guint16 error;
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "TFTP");
+
+ opcode = tvb_get_ntohs(tvb, offset);
+
+ col_add_str(pinfo->cinfo, COL_INFO,
+ val_to_str(opcode, tftp_opcode_vals, "Unknown (0x%04x)"));
+
+ if (tree) {
+ ti = proto_tree_add_item(tree, proto_tftp, tvb, offset, -1, ENC_NA);
+ tftp_tree = proto_item_add_subtree(ti, ett_tftp);
+
+ if (tftp_info->source_file) {
+ ti = proto_tree_add_string(tftp_tree, hf_tftp_source_file, tvb,
+ 0, 0, tftp_info->source_file);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
+
+ if (tftp_info->destination_file) {
+ ti = proto_tree_add_string(tftp_tree, hf_tftp_destination_file, tvb,
+ 0, 0, tftp_info->destination_file);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
+
+ proto_tree_add_uint(tftp_tree, hf_tftp_opcode, tvb,
+ offset, 2, opcode);
+ }
+ offset += 2;
- switch (opcode) {
+ switch (opcode) {
- case TFTP_RRQ:
- i1 = tvb_strsize(tvb, offset);
- proto_tree_add_item(tftp_tree, hf_tftp_source_file,
- tvb, offset, i1, ENC_ASCII|ENC_NA);
+ case TFTP_RRQ:
+ i1 = tvb_strsize(tvb, offset);
+ proto_tree_add_item(tftp_tree, hf_tftp_source_file,
+ tvb, offset, i1, ENC_ASCII|ENC_NA);
- tftp_info->source_file = tvb_get_string(wmem_file_scope(), tvb, offset, i1);
+ tftp_info->source_file = tvb_get_string(wmem_file_scope(), tvb, offset, i1);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
- tvb_format_stringzpad(tvb, offset, i1));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
+ tvb_format_stringzpad(tvb, offset, i1));
- offset += i1;
+ offset += i1;
- i1 = tvb_strsize(tvb, offset);
- proto_tree_add_item(tftp_tree, hf_tftp_transfer_type,
- tvb, offset, i1, ENC_ASCII|ENC_NA);
+ i1 = tvb_strsize(tvb, offset);
+ proto_tree_add_item(tftp_tree, hf_tftp_transfer_type,
+ tvb, offset, i1, ENC_ASCII|ENC_NA);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s",
- tvb_format_stringzpad(tvb, offset, i1));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s",
+ tvb_format_stringzpad(tvb, offset, i1));
- offset += i1;
+ offset += i1;
- tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
- opcode, tftp_info);
- break;
+ tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
+ opcode, tftp_info);
+ break;
- case TFTP_WRQ:
- i1 = tvb_strsize(tvb, offset);
- proto_tree_add_item(tftp_tree, hf_tftp_destination_file,
- tvb, offset, i1, ENC_ASCII|ENC_NA);
+ case TFTP_WRQ:
+ i1 = tvb_strsize(tvb, offset);
+ proto_tree_add_item(tftp_tree, hf_tftp_destination_file,
+ tvb, offset, i1, ENC_ASCII|ENC_NA);
- tftp_info->destination_file =
- tvb_get_string(wmem_file_scope(), tvb, offset, i1);
+ tftp_info->destination_file =
+ tvb_get_string(wmem_file_scope(), tvb, offset, i1);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
- tvb_format_stringzpad(tvb, offset, i1));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
+ tvb_format_stringzpad(tvb, offset, i1));
- offset += i1;
+ offset += i1;
- i1 = tvb_strsize(tvb, offset);
- proto_tree_add_item(tftp_tree, hf_tftp_transfer_type,
- tvb, offset, i1, ENC_ASCII|ENC_NA);
+ i1 = tvb_strsize(tvb, offset);
+ proto_tree_add_item(tftp_tree, hf_tftp_transfer_type,
+ tvb, offset, i1, ENC_ASCII|ENC_NA);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s",
- tvb_format_stringzpad(tvb, offset, i1));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s",
+ tvb_format_stringzpad(tvb, offset, i1));
- offset += i1;
+ offset += i1;
- tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
- opcode, tftp_info);
- break;
+ tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
+ opcode, tftp_info);
+ break;
- case TFTP_INFO:
- tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
- opcode, tftp_info);
- break;
+ case TFTP_INFO:
+ tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
+ opcode, tftp_info);
+ break;
- case TFTP_DATA:
- blocknum = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2,
- blocknum);
+ case TFTP_DATA:
+ blocknum = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2,
+ blocknum);
- offset += 2;
+ offset += 2;
- bytes = tvb_reported_length_remaining(tvb, offset);
+ bytes = tvb_reported_length_remaining(tvb, offset);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i%s",
- blocknum,
- (bytes < tftp_info->blocksize)?" (last)":"" );
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i%s",
+ blocknum,
+ (bytes < tftp_info->blocksize)?" (last)":"" );
- if (bytes != 0) {
- tvbuff_t *data_tvb = tvb_new_subset(tvb, offset, -1, bytes);
- call_dissector(data_handle, data_tvb, pinfo, tree);
- }
- break;
+ if (bytes != 0) {
+ tvbuff_t *data_tvb = tvb_new_subset(tvb, offset, -1, bytes);
+ call_dissector(data_handle, data_tvb, pinfo, tree);
+ }
+ break;
- case TFTP_ACK:
- blocknum = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2,
- blocknum);
+ case TFTP_ACK:
+ blocknum = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2,
+ blocknum);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i",
- blocknum);
- break;
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i",
+ blocknum);
+ break;
- case TFTP_ERROR:
- error = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint(tftp_tree, hf_tftp_error_code, tvb, offset, 2,
- error);
+ case TFTP_ERROR:
+ error = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_uint(tftp_tree, hf_tftp_error_code, tvb, offset, 2,
+ error);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Code: %s",
- val_to_str(error, tftp_error_code_vals, "Unknown (%u)"));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Code: %s",
+ val_to_str(error, tftp_error_code_vals, "Unknown (%u)"));
- offset += 2;
+ offset += 2;
- i1 = tvb_strsize(tvb, offset);
- proto_tree_add_item(tftp_tree, hf_tftp_error_string, tvb, offset,
- i1, ENC_ASCII|ENC_NA);
+ i1 = tvb_strsize(tvb, offset);
+ proto_tree_add_item(tftp_tree, hf_tftp_error_string, tvb, offset,
+ i1, ENC_ASCII|ENC_NA);
- col_append_fstr(pinfo->cinfo, COL_INFO, ", Message: %s",
- tvb_format_stringzpad(tvb, offset, i1));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", Message: %s",
+ tvb_format_stringzpad(tvb, offset, i1));
- expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range);
- break;
+ expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range);
+ break;
- case TFTP_OACK:
- tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
- opcode, tftp_info);
- break;
+ case TFTP_OACK:
+ tftp_dissect_options(tvb, pinfo, offset, tftp_tree,
+ opcode, tftp_info);
+ break;
- default:
- proto_tree_add_text(tftp_tree, tvb, offset, -1,
- "Data (%d bytes)", tvb_reported_length_remaining(tvb, offset));
- break;
+ default:
+ proto_tree_add_text(tftp_tree, tvb, offset, -1,
+ "Data (%d bytes)", tvb_reported_length_remaining(tvb, offset));
+ break;
- }
+ }
return;
}
@@ -365,61 +365,61 @@ dissect_embeddedtftp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
static void
dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- conversation_t *conversation = NULL;
- tftp_conv_info_t *tftp_info;
-
- /*
- * The first TFTP packet goes to the TFTP port; the second one
- * comes from some *other* port, but goes back to the same
- * IP address and port as the ones from which the first packet
- * came; all subsequent packets go between those two IP addresses
- * and ports.
- *
- * If this packet went to the TFTP port, we check to see if
- * there's already a conversation with one address/port pair
- * matching the source IP address and port of this packet,
- * the other address matching the destination IP address of this
- * packet, and any destination port.
- *
- * If not, we create one, with its address 1/port 1 pair being
- * the source address/port of this packet, its address 2 being
- * the destination address of this packet, and its port 2 being
- * wildcarded, and give it the TFTP dissector as a dissector.
- */
- if (value_is_in_range(global_tftp_port_range, pinfo->destport)) {
- conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
- pinfo->srcport, 0, NO_PORT_B);
- if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
- conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
- pinfo->srcport, 0, NO_PORT2);
- conversation_set_dissector(conversation, tftp_handle);
- }
- } else {
- conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
- pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
- if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
- conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
- pinfo->destport, pinfo->srcport, 0);
- conversation_set_dissector(conversation, tftp_handle);
- } else if (conversation->options & NO_PORT_B) {
- if (pinfo->destport == conversation->key_ptr->port1)
- conversation_set_port2(conversation, pinfo->srcport);
- else
- return;
- }
- }
- tftp_info = (tftp_conv_info_t *)conversation_get_proto_data(conversation, proto_tftp);
- if (!tftp_info) {
- tftp_info = wmem_new(wmem_file_scope(), tftp_conv_info_t);
- tftp_info->blocksize = 512; /* TFTP default block size */
- tftp_info->source_file = NULL;
- tftp_info->destination_file = NULL;
- conversation_add_proto_data(conversation, proto_tftp, tftp_info);
- }
-
- dissect_tftp_message(tftp_info, tvb, pinfo, tree);
-
- return;
+ conversation_t *conversation = NULL;
+ tftp_conv_info_t *tftp_info;
+
+ /*
+ * The first TFTP packet goes to the TFTP port; the second one
+ * comes from some *other* port, but goes back to the same
+ * IP address and port as the ones from which the first packet
+ * came; all subsequent packets go between those two IP addresses
+ * and ports.
+ *
+ * If this packet went to the TFTP port, we check to see if
+ * there's already a conversation with one address/port pair
+ * matching the source IP address and port of this packet,
+ * the other address matching the destination IP address of this
+ * packet, and any destination port.
+ *
+ * If not, we create one, with its address 1/port 1 pair being
+ * the source address/port of this packet, its address 2 being
+ * the destination address of this packet, and its port 2 being
+ * wildcarded, and give it the TFTP dissector as a dissector.
+ */
+ if (value_is_in_range(global_tftp_port_range, pinfo->destport)) {
+ conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
+ pinfo->srcport, 0, NO_PORT_B);
+ if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
+ conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
+ pinfo->srcport, 0, NO_PORT2);
+ conversation_set_dissector(conversation, tftp_handle);
+ }
+ } else {
+ conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
+ conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
+ pinfo->destport, pinfo->srcport, 0);
+ conversation_set_dissector(conversation, tftp_handle);
+ } else if (conversation->options & NO_PORT_B) {
+ if (pinfo->destport == conversation->key_ptr->port1)
+ conversation_set_port2(conversation, pinfo->srcport);
+ else
+ return;
+ }
+ }
+ tftp_info = (tftp_conv_info_t *)conversation_get_proto_data(conversation, proto_tftp);
+ if (!tftp_info) {
+ tftp_info = wmem_new(wmem_file_scope(), tftp_conv_info_t);
+ tftp_info->blocksize = 512; /* TFTP default block size */
+ tftp_info->source_file = NULL;
+ tftp_info->destination_file = NULL;
+ conversation_add_proto_data(conversation, proto_tftp, tftp_info);
+ }
+
+ dissect_tftp_message(tftp_info, tvb, pinfo, tree);
+
+ return;
}
@@ -428,49 +428,49 @@ proto_register_tftp(void)
{
static hf_register_info hf[] = {
{ &hf_tftp_opcode,
- { "Opcode", "tftp.opcode",
- FT_UINT16, BASE_DEC, VALS(tftp_opcode_vals), 0x0,
- "TFTP message type", HFILL }},
+ { "Opcode", "tftp.opcode",
+ FT_UINT16, BASE_DEC, VALS(tftp_opcode_vals), 0x0,
+ "TFTP message type", HFILL }},
{ &hf_tftp_source_file,
- { "Source File", "tftp.source_file",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- "TFTP source file name", HFILL }},
+ { "Source File", "tftp.source_file",
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ "TFTP source file name", HFILL }},
{ &hf_tftp_destination_file,
{ "DESTINATION File", "tftp.destination_file",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- "TFTP source file name", HFILL }},
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ "TFTP source file name", HFILL }},
{ &hf_tftp_transfer_type,
- { "Type", "tftp.type",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- "TFTP transfer type", HFILL }},
+ { "Type", "tftp.type",
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ "TFTP transfer type", HFILL }},
{ &hf_tftp_blocknum,
{ "Block", "tftp.block",
- FT_UINT16, BASE_DEC, NULL, 0x0,
- "Block number", HFILL }},
+ FT_UINT16, BASE_DEC, NULL, 0x0,
+ "Block number", HFILL }},
{ &hf_tftp_error_code,
{ "Error code", "tftp.error.code",
- FT_UINT16, BASE_DEC, VALS(tftp_error_code_vals), 0x0,
- "Error code in case of TFTP error message", HFILL }},
+ FT_UINT16, BASE_DEC, VALS(tftp_error_code_vals), 0x0,
+ "Error code in case of TFTP error message", HFILL }},
{ &hf_tftp_error_string,
{ "Error message", "tftp.error.message",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- "Error string in case of TFTP error message", HFILL }},
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ "Error string in case of TFTP error message", HFILL }},
{ &hf_tftp_option_name,
{ "Option name", "tftp.option.name",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
{ &hf_tftp_option_value,
{ "Option value", "tftp.option.value",
- FT_STRINGZ, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ FT_STRINGZ, BASE_NONE, NULL, 0x0,
+ NULL, HFILL }},
};
static gint *ett[] = {
@@ -486,7 +486,7 @@ proto_register_tftp(void)
expert_module_t* expert_tftp;
proto_tftp = proto_register_protocol("Trivial File Transfer Protocol",
- "TFTP", "tftp");
+ "TFTP", "tftp");
proto_register_field_array(proto_tftp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_tftp = expert_register_protocol(proto_tftp);
@@ -499,10 +499,10 @@ proto_register_tftp(void)
tftp_module = prefs_register_protocol(proto_tftp, proto_reg_handoff_tftp);
prefs_register_range_preference(tftp_module, "udp_ports",
- "TFTP port numbers",
- "Port numbers used for TFTP traffic "
- "(default " UDP_PORT_TFTP_RANGE ")",
- &global_tftp_port_range, MAX_UDP_PORT);
+ "TFTP port numbers",
+ "Port numbers used for TFTP traffic "
+ "(default " UDP_PORT_TFTP_RANGE ")",
+ &global_tftp_port_range, MAX_UDP_PORT);
}
void
diff --git a/epan/dissectors/packet-usb-audio.c b/epan/dissectors/packet-usb-audio.c
index 0f1cf4ee41..b6d3889238 100644
--- a/epan/dissectors/packet-usb-audio.c
+++ b/epan/dissectors/packet-usb-audio.c
@@ -42,17 +42,17 @@ static gint ett_usb_audio_desc = -1;
static dissector_handle_t sysex_handle;
-#define AUDIO_SUBCLASS_UNDEFINED 0x00
-#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
-#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
-#define AUDIO_SUBCLASS_MIDISTREAMING 0x03
+#define AUDIO_SUBCLASS_UNDEFINED 0x00
+#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
+#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
+#define AUDIO_SUBCLASS_MIDISTREAMING 0x03
#if 0
static const value_string usb_audio_subclass_vals[] = {
- {AUDIO_SUBCLASS_UNDEFINED, "SUBCLASS_UNDEFINED"},
- {AUDIO_SUBCLASS_AUDIOCONTROL, "AUDIOCONSTROL"},
- {AUDIO_SUBCLASS_AUDIOSTREAMING, "AUDIOSTREAMING"},
- {AUDIO_SUBCLASS_MIDISTREAMING, "MIDISTREAMING"},
+ {AUDIO_SUBCLASS_UNDEFINED, "SUBCLASS_UNDEFINED"},
+ {AUDIO_SUBCLASS_AUDIOCONTROL, "AUDIOCONSTROL"},
+ {AUDIO_SUBCLASS_AUDIOSTREAMING, "AUDIOSTREAMING"},
+ {AUDIO_SUBCLASS_MIDISTREAMING, "MIDISTREAMING"},
{0, NULL}
};
#endif
@@ -83,7 +83,7 @@ static const value_string code_index_vals[] = {
static const value_string aud_descriptor_type_vals[] = {
{CS_INTERFACE, "audio class interface"},
- {CS_ENDPOINT, "audio class endpoint"},
+ {CS_ENDPOINT, "audio class endpoint"},
{0,NULL}
};
static value_string_ext aud_descriptor_type_vals_ext =
@@ -137,8 +137,8 @@ is_sysex_code(guint8 code)
static gboolean
is_last_sysex_packet_in_tvb(tvbuff_t *tvb, gint offset)
{
- gboolean last = TRUE;
- gint length = tvb_length(tvb);
+ gboolean last = TRUE;
+ gint length = tvb_length(tvb);
offset += 4;
while (offset < length)
@@ -163,9 +163,9 @@ dissect_usb_midi_event(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *usb_audio_tree, proto_tree *parent_tree,
gint offset)
{
- guint8 code;
- guint8 cable;
- gboolean save_fragmented;
+ guint8 code;
+ guint8 cable;
+ gboolean save_fragmented;
proto_tree *tree = NULL;
col_set_str(pinfo->cinfo, COL_INFO, "USB-MIDI Event Packets");
@@ -176,7 +176,7 @@ dissect_usb_midi_event(tvbuff_t *tvb, packet_info *pinfo,
if (parent_tree)
{
- proto_item *ti = NULL;
+ proto_item *ti;
ti = proto_tree_add_protocol_format(usb_audio_tree, proto_usb_audio, tvb, offset, 4, "USB Midi Event Packet");
tree = proto_item_add_subtree(ti, ett_usb_audio);
@@ -276,12 +276,12 @@ dissect_usb_audio_descriptor(tvbuff_t *tvb, packet_info *pinfo _U_,
/* dissector for usb midi bulk data */
static int
-dissect_usb_audio_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data)
+dissect_usb_audio_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
{
usb_conv_info_t *usb_conv_info;
- proto_tree *tree = NULL;
- guint offset;
- guint length = tvb_length(tvb);
+ proto_tree *tree = NULL;
+ guint offset;
+ guint length = tvb_length(tvb);
/* Reject the packet if data is NULL */
@@ -293,9 +293,9 @@ dissect_usb_audio_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tre
if (parent_tree)
{
- proto_item *ti = NULL;
+ proto_item *ti;
- ti = proto_tree_add_protocol_format(parent_tree, proto_usb_audio, tvb, 0, -1, "USB Audio");
+ ti = proto_tree_add_protocol_format(parent_tree, proto_usb_audio, tvb, 0, -1, "USB Audio");
tree = proto_item_add_subtree(ti, ett_usb_audio);
}
diff --git a/epan/dissectors/packet-vrrp.c b/epan/dissectors/packet-vrrp.c
index 617e69de95..e54004b8c6 100644
--- a/epan/dissectors/packet-vrrp.c
+++ b/epan/dissectors/packet-vrrp.c
@@ -60,9 +60,9 @@ static gint hf_vrrp_auth_string = -1;
static expert_field ei_vrrp_checksum = EI_INIT;
-#define VRRP_VERSION_MASK 0xf0
-#define VRRP_TYPE_MASK 0x0f
-#define VRRP_AUTH_DATA_LEN 8
+#define VRRP_VERSION_MASK 0xf0
+#define VRRP_TYPE_MASK 0x0f
+#define VRRP_AUTH_DATA_LEN 8
#define VRRP_TYPE_ADVERTISEMENT 1
static const value_string vrrp_type_vals[] = {
@@ -70,11 +70,11 @@ static const value_string vrrp_type_vals[] = {
{0, NULL}
};
-#define VRRP_AUTH_TYPE_NONE 0
+#define VRRP_AUTH_TYPE_NONE 0
#define VRRP_AUTH_TYPE_SIMPLE_TEXT 1
#define VRRP_AUTH_TYPE_IP_AUTH_HDR 2
static const value_string vrrp_auth_vals[] = {
- {VRRP_AUTH_TYPE_NONE, "No Authentication"},
+ {VRRP_AUTH_TYPE_NONE, "No Authentication"},
{VRRP_AUTH_TYPE_SIMPLE_TEXT, "Simple Text Authentication [RFC 2338] / Reserved [RFC 3768]"},
{VRRP_AUTH_TYPE_IP_AUTH_HDR, "IP Authentication Header [RFC 2338] / Reserved [RFC 3768]"},
{0, NULL}
@@ -83,11 +83,11 @@ static const value_string vrrp_auth_vals[] = {
#define VRRP_PRIORITY_MASTER_STOPPING 0
/* Values between 1 and 254 inclusive are for backup VRRP routers */
#define VRRP_PRIORITY_DEFAULT 100
-#define VRRP_PRIORITY_OWNER 255
+#define VRRP_PRIORITY_OWNER 255
static const value_string vrrp_prio_vals[] = {
{VRRP_PRIORITY_MASTER_STOPPING, "Current Master has stopped participating in VRRP"},
- {VRRP_PRIORITY_DEFAULT, "Default priority for a backup VRRP router"},
- {VRRP_PRIORITY_OWNER, "This VRRP router owns the virtual router's IP address(es)"},
+ {VRRP_PRIORITY_DEFAULT, "Default priority for a backup VRRP router"},
+ {VRRP_PRIORITY_OWNER, "This VRRP router owns the virtual router's IP address(es)"},
{0, NULL }
};
@@ -128,45 +128,45 @@ dissect_vrrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
val_to_str_const(lo_nibble(ver_type), vrrp_type_vals, "Unknown"));
ver_type_tree = proto_item_add_subtree(tv, ett_vrrp_ver_type);
- if(ver_type_tree){
- proto_tree_add_uint(ver_type_tree, hf_vrrp_version, tvb,
- offset, 1, ver_type);
- proto_tree_add_uint(ver_type_tree, hf_vrrp_type, tvb, offset, 1, ver_type);
- offset++;
-
- proto_tree_add_item(vrrp_tree, hf_vrrp_virt_rtr_id, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset++;
-
- proto_tree_add_uint_format(vrrp_tree, hf_vrrp_prio, tvb, offset, 1, priority, "Priority: %u (%s)",
- priority,
- val_to_str_const(priority, vrrp_prio_vals, "Non-default backup priority"));
- offset++;
-
- proto_tree_add_uint(vrrp_tree, hf_vrrp_addr_count, tvb,
- offset, 1, addr_count);
- offset++;
-
- switch(hi_nibble(ver_type)) {
- case 3:
- /* 4 bits reserved (mbz) + 12 bits interval */
- proto_tree_add_item(vrrp_tree, hf_vrrp_reserved_mbz, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(vrrp_tree, hf_vrrp_short_adver_int, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset+=2;
- break;
- case 2:
- default:
- /* 1 byte auth type + 1 byte interval */
- auth_type = tvb_get_guint8(tvb, offset);
- proto_tree_add_item(vrrp_tree, hf_vrrp_auth_type, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset++;
-
- proto_tree_add_item(vrrp_tree, hf_vrrp_adver_int, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset++;
- break;
- }
- }else{
- offset+=6;
- }
+ if(ver_type_tree){
+ proto_tree_add_uint(ver_type_tree, hf_vrrp_version, tvb,
+ offset, 1, ver_type);
+ proto_tree_add_uint(ver_type_tree, hf_vrrp_type, tvb, offset, 1, ver_type);
+ offset += 1;
+
+ proto_tree_add_item(vrrp_tree, hf_vrrp_virt_rtr_id, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+
+ proto_tree_add_uint_format(vrrp_tree, hf_vrrp_prio, tvb, offset, 1, priority, "Priority: %u (%s)",
+ priority,
+ val_to_str_const(priority, vrrp_prio_vals, "Non-default backup priority"));
+ offset += 1;
+
+ proto_tree_add_uint(vrrp_tree, hf_vrrp_addr_count, tvb,
+ offset, 1, addr_count);
+ offset += 1;
+
+ switch(hi_nibble(ver_type)) {
+ case 3:
+ /* 4 bits reserved (mbz) + 12 bits interval */
+ proto_tree_add_item(vrrp_tree, hf_vrrp_reserved_mbz, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(vrrp_tree, hf_vrrp_short_adver_int, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ break;
+ case 2:
+ default:
+ /* 1 byte auth type + 1 byte interval */
+ auth_type = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(vrrp_tree, hf_vrrp_auth_type, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+
+ proto_tree_add_item(vrrp_tree, hf_vrrp_adver_int, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ break;
+ }
+ }else{
+ offset += 6;
+ }
checksum_item = proto_tree_add_item(vrrp_tree, hf_vrrp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
@@ -212,15 +212,15 @@ dissect_vrrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
}
}
- offset+=2;
+ offset += 2;
while (addr_count > 0) {
if (is_ipv6) {
proto_tree_add_item(vrrp_tree, hf_vrrp_ip6, tvb, offset, 16, ENC_NA);
- offset+=16;
+ offset += 16;
} else {
proto_tree_add_item(vrrp_tree, hf_vrrp_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
- offset+=4;
+ offset += 4;
}
addr_count--;
}
diff --git a/epan/dissectors/packet-websocket.c b/epan/dissectors/packet-websocket.c
index f73e2d0d29..344da0b567 100644
--- a/epan/dissectors/packet-websocket.c
+++ b/epan/dissectors/packet-websocket.c
@@ -136,16 +136,16 @@ static tvbuff_t *
tvb_unmasked(tvbuff_t *tvb, const guint offset, guint payload_length, const guint8 *masking_key)
{
- gchar *data_unmask;
- tvbuff_t *tvb_unmask = NULL;
- guint i;
+ gchar *data_unmask;
+ tvbuff_t *tvb_unmask = NULL;
+ guint i;
const guint8 *data_mask;
- guint unmasked_length = payload_length > MAX_UNMASKED_LEN ? MAX_UNMASKED_LEN : payload_length;
+ guint unmasked_length = payload_length > MAX_UNMASKED_LEN ? MAX_UNMASKED_LEN : payload_length;
data_unmask = (gchar *)g_malloc(unmasked_length);
- data_mask = tvb_get_ptr(tvb, offset, unmasked_length);
+ data_mask = tvb_get_ptr(tvb, offset, unmasked_length);
/* Unmasked(XOR) Data... */
- for(i=0; i < unmasked_length; i++){
+ for(i=0; i < unmasked_length; i++) {
data_unmask[i] = data_mask[i] ^ masking_key[i%4];
}
@@ -157,29 +157,29 @@ tvb_unmasked(tvbuff_t *tvb, const guint offset, guint payload_length, const guin
static int
dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *ws_tree, guint8 opcode, guint payload_length, guint8 mask, const guint8* masking_key)
{
- guint offset = 0;
- proto_item *ti_unmask, *ti;
- dissector_handle_t handle;
- proto_tree *pl_tree, *mask_tree = NULL;
- tvbuff_t *payload_tvb = NULL;
+ guint offset = 0;
+ proto_item *ti_unmask, *ti;
+ dissector_handle_t handle;
+ proto_tree *pl_tree, *mask_tree = NULL;
+ tvbuff_t *payload_tvb = NULL;
/* Payload */
ti = proto_tree_add_item(ws_tree, hf_ws_payload, tvb, offset, payload_length, ENC_NA);
pl_tree = proto_item_add_subtree(ti, ett_ws_pl);
- if(mask){
+ if (mask) {
payload_tvb = tvb_unmasked(tvb, offset, payload_length, masking_key);
tvb_set_child_real_data_tvbuff(tvb, payload_tvb);
add_new_data_source(pinfo, payload_tvb, payload_length > tvb_length(payload_tvb) ? "Unmasked Data (truncated)" : "Unmasked Data");
ti = proto_tree_add_item(ws_tree, hf_ws_payload_unmask, payload_tvb, offset, payload_length, ENC_NA);
mask_tree = proto_item_add_subtree(ti, ett_ws_mask);
- }else{
+ } else {
payload_tvb = tvb_new_subset(tvb, offset, payload_length, -1);
}
handle = dissector_get_uint_handle(port_subdissector_table, pinfo->match_uint);
- if(handle != NULL){
+ if (handle != NULL) {
call_dissector_only(handle, payload_tvb, pinfo, tree, NULL);
- }else{
+ } else {
dissector_try_heuristic(heur_subdissector_list, payload_tvb, pinfo, tree, NULL);
}
@@ -187,7 +187,7 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
/* TODO: Add dissector of Extension (not extension available for the moment...) */
/* Application Data */
- switch(opcode){
+ switch (opcode) {
case WS_CONTINUE: /* Continue */
proto_tree_add_item(pl_tree, hf_ws_payload_continue, tvb, offset, payload_length, ENC_NA);
@@ -195,20 +195,20 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
break;
case WS_TEXT: /* Text */
- if(mask){
+ if (mask) {
proto_tree_add_item(pl_tree, hf_ws_payload_text_mask, tvb, offset, payload_length, ENC_NA);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_text_unmask, payload_tvb, offset, payload_length, ENC_UTF_8|ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_text, payload_tvb, offset, payload_length, ENC_UTF_8|ENC_NA);
PROTO_ITEM_SET_HIDDEN(ti_unmask);
- }else{
+ } else {
const gchar *saved_match_string = pinfo->match_string;
void *save_private_data = pinfo->private_data;
pinfo->match_string = NULL;
pinfo->private_data = NULL;
- switch(pref_text_type){
+ switch (pref_text_type) {
case WEBSOCKET_TEXT:
call_dissector(text_lines_handle, payload_tvb, pinfo, pl_tree);
break;
@@ -228,20 +228,20 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
break;
case WS_BINARY: /* Binary */
- if(mask){
+ if (mask) {
proto_tree_add_item(pl_tree, hf_ws_payload_binary_mask, tvb, offset, payload_length, ENC_NA);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_binary_unmask, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_binary, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_HIDDEN(ti_unmask);
- }else{
+ } else {
proto_tree_add_item(pl_tree, hf_ws_payload_binary, tvb, offset, payload_length, ENC_NA);
}
offset += payload_length;
break;
case WS_CLOSE: /* Close */
- if(mask){
+ if (mask) {
proto_tree_add_item(pl_tree, hf_ws_payload_close_mask, tvb, offset, payload_length, ENC_NA);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_close_unmask, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
@@ -250,14 +250,14 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_close_status_code, payload_tvb, offset, 2, ENC_BIG_ENDIAN);
PROTO_ITEM_SET_GENERATED(ti_unmask);
- if(payload_length > 2){
+ if (payload_length > 2) {
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_close_reason, payload_tvb, offset+2, payload_length-2, ENC_ASCII|ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
}
- }else{
+ } else {
proto_tree_add_item(pl_tree, hf_ws_payload_close, tvb, offset, payload_length, ENC_NA);
proto_tree_add_item(pl_tree, hf_ws_payload_close_status_code, tvb, offset, 2, ENC_BIG_ENDIAN);
- if(payload_length > 2){
+ if (payload_length > 2) {
proto_tree_add_item(pl_tree, hf_ws_payload_close_reason, tvb, offset+2, payload_length-2, ENC_ASCII|ENC_NA);
}
}
@@ -265,26 +265,26 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
break;
case WS_PING: /* Ping */
- if(mask){
+ if (mask) {
proto_tree_add_item(pl_tree, hf_ws_payload_ping_mask, tvb, offset, payload_length, ENC_NA);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_ping_unmask, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_ping, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_HIDDEN(ti_unmask);
- }else{
+ } else {
proto_tree_add_item(pl_tree, hf_ws_payload_ping, tvb, offset, payload_length, ENC_NA);
}
offset += payload_length;
break;
case WS_PONG: /* Pong */
- if(mask){
+ if (mask) {
proto_tree_add_item(pl_tree, hf_ws_payload_pong_mask, tvb, offset, payload_length, ENC_NA);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_pong_unmask, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_GENERATED(ti_unmask);
ti_unmask = proto_tree_add_item(mask_tree, hf_ws_payload_pong, payload_tvb, offset, payload_length, ENC_NA);
PROTO_ITEM_SET_HIDDEN(ti_unmask);
- }else{
+ } else {
proto_tree_add_item(pl_tree, hf_ws_payload_pong, tvb, offset, payload_length, ENC_NA);
}
offset += payload_length;
@@ -304,35 +304,35 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p
static int
dissect_websocket(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- proto_item *ti, *ti_len;
- guint8 fin, opcode, mask;
- guint length, short_length, payload_length, recurse_length;
- guint payload_offset, mask_offset, recurse_offset;
- proto_tree *ws_tree = NULL;
+ proto_item *ti, *ti_len;
+ guint8 fin, opcode, mask;
+ guint length, short_length, payload_length, recurse_length;
+ guint payload_offset, mask_offset, recurse_offset;
+ proto_tree *ws_tree = NULL;
const guint8 *masking_key = NULL;
- tvbuff_t *tvb_payload = NULL;
+ tvbuff_t *tvb_payload;
length = tvb_length(tvb);
- if(length<2){
+ if (length < 2) {
pinfo->desegment_len = 2;
return 0;
}
short_length = tvb_get_guint8(tvb, 1) & MASK_WS_PAYLOAD_LEN;
- if(short_length==126){
- if(length < 2+2){
+ if (short_length == 126) {
+ if (length < 2+2) {
pinfo->desegment_len = 2+2;
return 0;
}
payload_length = tvb_get_ntohs(tvb, 2);
mask_offset = 2+2;
}
- else if(short_length==127){
- if(length < 2+8){
+ else if (short_length == 127) {
+ if (length < 2+8) {
pinfo->desegment_len = 2+8;
return 0;
}
- /* warning C4244: '=' : conversion from 'guint64' to 'guint ', possible loss of data */
+ /* warning C4244: '=' : conversion from 'guint64' to 'guint ', possible loss of data */
payload_length = (guint)tvb_get_ntoh64(tvb, 2);
mask_offset = 2+8;
}
@@ -352,7 +352,7 @@ dissect_websocket(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
payload_length = tvb_reported_length_remaining(tvb, payload_offset);
}
- if(length < payload_offset + payload_length){
+ if (length < payload_offset + payload_length) {
/* XXXX Warning desegment_len is 32 bits */
pinfo->desegment_len = payload_offset + payload_length - length;
return 0;
@@ -363,7 +363,7 @@ dissect_websocket(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WebSocket");
col_set_str(pinfo->cinfo, COL_INFO, "WebSocket");
- if(tree){
+ if (tree) {
ti = proto_tree_add_item(tree, proto_websocket, tvb, 0, payload_offset, ENC_NA);
ws_tree = proto_item_add_subtree(ti, ett_ws);
}
@@ -385,17 +385,17 @@ dissect_websocket(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
/* (Extended) Payload Length */
ti_len = proto_tree_add_item(ws_tree, hf_ws_payload_length, tvb, 1, 1, ENC_NA);
- if(short_length==126){
+ if (short_length == 126) {
proto_item_append_text(ti_len, " Extended Payload Length (16 bits)");
proto_tree_add_item(ws_tree, hf_ws_payload_length_ext_16, tvb, 2, 2, ENC_BIG_ENDIAN);
}
- else if(short_length==127){
+ else if (short_length == 127) {
proto_item_append_text(ti_len, " Extended Payload Length (64 bits)");
proto_tree_add_item(ws_tree, hf_ws_payload_length_ext_64, tvb, 2, 8, ENC_BIG_ENDIAN);
}
/* Masking-key */
- if(mask){
+ if (mask) {
proto_tree_add_item(ws_tree, hf_ws_masking_key, tvb, mask_offset, 4, ENC_NA);
masking_key = tvb_get_ptr(tvb, mask_offset, 4);
}
@@ -406,9 +406,9 @@ dissect_websocket(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
/* Call this function recursively, to see if we have enough data to parse another websocket message */
recurse_offset = payload_offset + payload_length;
- if(length > recurse_offset){
+ if (length > recurse_offset) {
recurse_length = dissect_websocket(tvb_new_subset_remaining(tvb, payload_offset+payload_length), pinfo, tree, data);
- if(pinfo->desegment_len) pinfo->desegment_offset += recurse_offset;
+ if (pinfo->desegment_len) pinfo->desegment_offset += recurse_offset;
return recurse_offset + recurse_length;
}
return recurse_offset;
@@ -621,8 +621,8 @@ proto_register_websocket(void)
void
proto_reg_handoff_websocket(void)
{
- text_lines_handle = find_dissector("data-text-lines");
- json_handle = find_dissector("json");
+ text_lines_handle = find_dissector("data-text-lines");
+ json_handle = find_dissector("json");
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html