For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
[obnox/wireshark/wip.git] / epan / dissectors / packet-slimp3.c
index c4608a5a52540bfc8dde57731c923f19267f8dec..41052074641e5f4a6bbb39afe86729bbae39d98f 100644 (file)
@@ -250,8 +250,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     if (opcode_str == NULL)
        return 0;
 
-    if (check_col(pinfo->cinfo, COL_PROTOCOL))
-       col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3");
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3");
 
     if (check_col(pinfo->cinfo, COL_INFO)) {
 
@@ -261,7 +260,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
     if (tree) {
 
-       ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, FALSE);
+       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,
@@ -307,7 +306,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        * [12..17]   reserved
        */
        if (tree) {
-           hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_ir, tvb, offset+8, 4, FALSE);
+           hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_ir, tvb, offset+8, 4, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
 
            i1 = tvb_get_ntohl(tvb, offset+2);
@@ -361,7 +360,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (tree) {
 
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_display,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
 
            /* Loop through the commands */
@@ -425,7 +424,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (check_col(pinfo->cinfo, COL_INFO)) {
            i1 = 18;
            lcd_strlen = 0;
-           while (tvb_offset_exists(tvb, offset + i1) && 
+           while (tvb_offset_exists(tvb, offset + i1) &&
                    lcd_strlen < MAX_LCD_STR_LEN) {
                switch (tvb_get_guint8(tvb, offset + i1)) {
 
@@ -462,7 +461,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case SLIMP3_CONTROL:
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_control,
-                                      tvb, offset+1, 1, FALSE);
+                                      tvb, offset+1, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            proto_tree_add_text(slimp3_tree, tvb, offset+1, 1, "Command: %s",
                                val_to_str(tvb_get_guint8(tvb, offset+1),
@@ -479,7 +478,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case SLIMP3_HELLO:
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_hello,
-                                      tvb, offset+1, 1, FALSE);
+                                      tvb, offset+1, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            if (to_server) {
                guint8 fw_ver = 0;
@@ -500,7 +499,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case SLIMP3_I2C:
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_i2c,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            if (to_server) {
                /* Hello response; client->server */
@@ -525,7 +524,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case SLIMP3_DATA_REQ:
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_data_request,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            proto_tree_add_text(slimp3_tree, tvb, offset+2, 2,
                                "Requested offset: %d bytes.",
@@ -551,11 +550,11 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        */
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_data,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            if (old_protocol) {
                proto_tree_add_text(slimp3_tree, tvb, offset, -1,
-                                   "Length: %d bytes", 
+                                   "Length: %d bytes",
                                    tvb_reported_length_remaining(tvb, offset+18));
                proto_tree_add_text(slimp3_tree, tvb, offset+2, 2,
                                    "Buffer offset: %d bytes.",
@@ -566,7 +565,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                    val_to_str(tvb_get_guint8(tvb, offset+1),
                                               slimp3_mpg_control, "Unknown (0x%0x)"));
                proto_tree_add_text(slimp3_tree, tvb, offset, -1,
-                                   "Length: %d bytes", 
+                                   "Length: %d bytes",
                                    tvb_reported_length_remaining(tvb, offset+18));
                proto_tree_add_text(slimp3_tree, tvb, offset+6, 2,
                                    "Write Pointer: %d",
@@ -579,13 +578,13 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        if (check_col(pinfo->cinfo, COL_INFO)) {
            if (old_protocol) {
-               col_append_fstr(pinfo->cinfo, COL_INFO, 
+               col_append_fstr(pinfo->cinfo, COL_INFO,
                                ", Length: %d bytes, Offset: %d bytes.",
                                tvb_reported_length_remaining(tvb, offset+18),
                                tvb_get_ntohs(tvb, offset+2) * 2);
            }
            else {
-               col_append_fstr(pinfo->cinfo, COL_INFO, 
+               col_append_fstr(pinfo->cinfo, COL_INFO,
                                ", %s, %d bytes at %d, Sequence: %d",
                                val_to_str(tvb_get_guint8(tvb, offset+1),
                                           slimp3_mpg_control, "Unknown (0x%0x)"),
@@ -600,7 +599,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (tree) {
            guint8 fw_ver;
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_discover_request,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            proto_tree_add_text(slimp3_tree, tvb, offset+1, 1,
                                "Device ID: %d.", tvb_get_guint8(tvb, offset+1));
@@ -619,18 +618,18 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case SLIMP3_DISC_RSP:
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_discover_response,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            proto_tree_add_text(slimp3_tree, tvb, offset+2, 4,
                                "Server Address: %s.",
-                               ip_to_str(tvb_get_ptr(tvb, offset+2, 4)));
+                               tvb_ip_to_str(tvb, offset+2));
            proto_tree_add_text(slimp3_tree, tvb, offset+6, 2,
                                "Server Port: %d", tvb_get_ntohs(tvb, offset + 6));
        }
 
        if (check_col(pinfo->cinfo, COL_INFO)) {
            col_append_fstr(pinfo->cinfo, COL_INFO, ", Server Address: %s. Server Port: %d",
-                           ip_to_str(tvb_get_ptr(tvb, offset+2, 4)),
+                           tvb_ip_to_str(tvb, offset+2),
                            tvb_get_ntohs(tvb, offset + 6));
        }
        break;
@@ -639,7 +638,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        /* Acknowledge MPEG data
        *
        *  [0]       'a'
-       *  [1..5]    
+       *  [1..5]
        *  [6..7]    Write pointer (in words)
        *  [8..9]    Read pointer (in words)
        *  [10..11]  Sequence number
@@ -647,7 +646,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        */
        if (tree) {
            hidden_item = proto_tree_add_item(slimp3_tree, hf_slimp3_data_ack,
-                                      tvb, offset, 1, FALSE);
+                                      tvb, offset, 1, ENC_BIG_ENDIAN);
            PROTO_ITEM_SET_HIDDEN(hidden_item);
            proto_tree_add_text(slimp3_tree, tvb, offset+6, 2,
                                "Write Pointer: %d",
@@ -692,47 +691,47 @@ proto_register_slimp3(void)
 
     { &hf_slimp3_control,
       { "Control Packet",   "slimp3.control",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 control", HFILL }},
 
     { &hf_slimp3_display,
       { "Display",                   "slimp3.display",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 display", HFILL }},
 
     { &hf_slimp3_hello,
       { "Hello",                     "slimp3.hello",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 hello", HFILL }},
 
     { &hf_slimp3_i2c,
       { "I2C",               "slimp3.i2c",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 I2C", HFILL }},
 
     { &hf_slimp3_data,
       { "Data",              "slimp3.data",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 Data", HFILL }},
 
     { &hf_slimp3_data_request,
       { "Data Request",      "slimp3.data_req",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 Data Request", HFILL }},
 
     { &hf_slimp3_discover_request,
       { "Discovery Request", "slimp3.discovery_req",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 Discovery Request", HFILL }},
 
     { &hf_slimp3_discover_response,
       { "Discovery Response", "slimp3.discovery_response",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 Discovery Response", HFILL }},
 
     { &hf_slimp3_data_ack,
       { "Data Ack",      "slimp3.data_ack",
-       FT_BOOLEAN, BASE_DEC, NULL, 0x0,
+       FT_BOOLEAN, BASE_NONE, NULL, 0x0,
        "SLIMP3 Data Ack", HFILL }},
 
   };
@@ -752,6 +751,6 @@ proto_reg_handoff_slimp3(void)
   dissector_handle_t slimp3_handle;
 
   slimp3_handle = new_create_dissector_handle(dissect_slimp3, proto_slimp3);
-  dissector_add("udp.port", UDP_PORT_SLIMP3_V1, slimp3_handle);
-  dissector_add("udp.port", UDP_PORT_SLIMP3_V2, slimp3_handle);
+  dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V1, slimp3_handle);
+  dissector_add_uint("udp.port", UDP_PORT_SLIMP3_V2, slimp3_handle);
 }