Replace proto_tree_add_text with proto_tree_add_item/expert_info
authorMichael Mann <mmann78@netscape.net>
Thu, 28 Feb 2013 23:01:31 +0000 (23:01 -0000)
committerMichael Mann <mmann78@netscape.net>
Thu, 28 Feb 2013 23:01:31 +0000 (23:01 -0000)
svn path=/trunk/; revision=47956

epan/dissectors/packet-msproxy.c

index cae913f0ca49f6dca90a5cb7254d6650c71f9ddf..6a442fc1bf74450a8c362f29a2a15d2cc6a1332a 100644 (file)
@@ -50,6 +50,7 @@
 #include <epan/addr_resolv.h>
 #include <epan/conversation.h>
 #include <epan/emem.h>
+#include <epan/expert.h>
 
 #include "packet-tcp.h"
 #include "packet-udp.h"
@@ -78,6 +79,15 @@ static int hf_msproxy_boundport = -1;
 static int hf_msproxy_bind_id = -1;
 static int hf_msproxy_resolvaddr = -1;
 
+static int hf_msproxy_client_id = -1;
+static int hf_msproxy_version = -1;
+static int hf_msproxy_server_id = -1;
+static int hf_msproxy_server_ack = -1;
+static int hf_msproxy_client_ack = -1;
+static int hf_msproxy_seq_num = -1;
+static int hf_msproxy_rwsp_signature = -1;
+static int hf_msproxy_ntlmssp_signature = -1;
+
 static int hf_msproxy_server_int_addr = -1;
 static int hf_msproxy_server_int_port = -1;
 static int hf_msproxy_server_ext_addr = -1;
@@ -445,8 +455,7 @@ static int dissect_auth(tvbuff_t *tvb, int offset,
 
        offset += 134;
        if ( tree) {
-               proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
-                       tvb_get_ephemeral_string( tvb, offset, 7));
+               proto_tree_add_item( tree, hf_msproxy_ntlmssp_signature, tvb, offset, 7, ENC_NA|ENC_ASCII);
        }
        offset += 7;
 
@@ -651,28 +660,22 @@ static void dissect_msproxy_request(tvbuff_t *tvb,
        int cmd;
 
        if ( tree) {
-               proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_client_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%0x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_server_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 1, "Server ack: %u",
-                       tvb_get_guint8( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_server_ack, tvb, offset, 1, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: %u",
-                       tvb_get_guint8( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_seq_num, tvb, offset, 1, ENC_LITTLE_ENDIAN);
                offset += 8;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
-                       tvb_get_ephemeral_string( tvb, offset, 4));
+               proto_tree_add_item( tree, hf_msproxy_rwsp_signature, tvb, offset, 4, ENC_NA|ENC_ASCII);
                offset += 12;
        }
        else                    /* no tree */
@@ -802,8 +805,7 @@ static void dissect_auth_1_ack(tvbuff_t *tvb, int offset,
 
        offset += 134;
        if ( tree) {
-               proto_tree_add_text( tree, tvb, offset, 7, "NTLMSSP signature: %.7s",
-                       tvb_get_ephemeral_string( tvb, offset, 7));
+               proto_tree_add_item( tree, hf_msproxy_ntlmssp_signature, tvb, offset, 7, ENC_NA|ENC_ASCII);
                offset += 48;
 
                /* XXX - always 255? */
@@ -975,32 +977,25 @@ static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
 
        int offset = 0;
        int cmd;
+       proto_item* ti;
 
        if ( tree) {
-               proto_tree_add_text( tree, tvb, offset, 4, "Client id: 0x%0x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_client_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "Version: 0x%04x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "Server id: 0x%04x",
-                       tvb_get_letohl( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_server_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 1, "Client ack: 0x%02x",
-                       tvb_get_guint8( tvb, offset));
+               proto_tree_add_item( tree, hf_msproxy_client_ack, tvb, offset, 1, ENC_LITTLE_ENDIAN);
                offset += 4;
 
-               proto_tree_add_text( tree, tvb, offset, 1, "Sequence Number: 0x%02x",
-                       tvb_get_guint8( tvb, offset));
-
+               proto_tree_add_item( tree, hf_msproxy_seq_num, tvb, offset, 1, ENC_LITTLE_ENDIAN);
                offset += 8;
 
-               proto_tree_add_text( tree, tvb, offset, 4, "RWSP signature: %.4s",
-                       tvb_get_ephemeral_string( tvb, offset, 4));
-
+               proto_tree_add_item( tree, hf_msproxy_rwsp_signature, tvb, offset, 4, ENC_NA|ENC_ASCII);
                offset += 12;
        }
        else
@@ -1008,8 +1003,7 @@ static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
 
        cmd = tvb_get_ntohs( tvb, offset);
 
-       if ( tree)
-               proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
+       ti = proto_tree_add_uint_format( tree, hf_msproxy_cmd, tvb, offset, 2,
                        cmd, "Command: 0x%02x (%s)", cmd,
                        get_msproxy_cmd_name( cmd, FROM_SERVER));
        offset += 2;
@@ -1057,20 +1051,16 @@ static void dissect_msproxy_response(tvbuff_t *tvb, packet_info *pinfo,
 
                case MSPROXY_CONNECT_AUTHFAILED:
                case MSPROXY_BIND_AUTHFAILED:
-                       proto_tree_add_text( tree, tvb, offset, 0, "No know information (help wanted)");
+                       expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN, "No know information (help wanted)");
                        break;
 
                default:
 
-                       if (tree &&
-                          (((cmd >> 8) ==  MSPROXY_CONNREFUSED) ||
-                           ((cmd >> 12) ==  MSPROXY_CONNREFUSED)))
-                               proto_tree_add_text( tree, tvb, offset, 0,
-                                       "No know information (help wanted)");
-
-                       else if ( tree)
-                               proto_tree_add_text( tree, tvb, offset, 0,
-                                       "Unhandled response command (report this, please)");
+                       if ((((cmd >> 8) ==  MSPROXY_CONNREFUSED) ||
+                               ((cmd >> 12) ==  MSPROXY_CONNREFUSED)))
+                               expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN, "No know information (help wanted)");
+                       else
+                               expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN, "Unhandled response command (report this, please)");                
        }
 
 
@@ -1236,12 +1226,51 @@ proto_register_msproxy( void){
                        { "Address", "msproxy.resolvaddr", FT_IPv4, BASE_NONE, NULL,
                                0x0, NULL, HFILL
                        }
-               }
-
+               },
+               { &hf_msproxy_client_id,
+                       { "Client Id",  "msproxy.client_id", FT_UINT32,
+                               BASE_HEX, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_version,
+                       { "Version",    "msproxy.version", FT_UINT32,
+                               BASE_HEX, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_server_id,
+                       { "Server id",  "msproxy.server_id", FT_UINT32,
+                               BASE_HEX, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_server_ack,
+                       { "Server ack", "msproxy.server_ack", FT_UINT8,
+                               BASE_DEC, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_client_ack,
+                       { "Client ack", "msproxy.client_ack", FT_UINT8,
+                               BASE_DEC, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_seq_num,
+                       { "Sequence Number",    "msproxy.seq_num", FT_UINT8,
+                               BASE_DEC, NULL, 0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_rwsp_signature,
+                       { "RWSP signature", "msproxy.rwsp_signature", FT_STRING, BASE_NONE, NULL,
+                               0x0, NULL, HFILL
+                       }
+               },
+               { &hf_msproxy_ntlmssp_signature,
+                       { "NTLMSSP signature", "msproxy.ntlmssp_signature", FT_STRING, BASE_NONE, NULL,
+                               0x0, NULL, HFILL
+                       }
+               },
        };
 
-       proto_msproxy = proto_register_protocol( "MS Proxy Protocol",
-           "MS Proxy", "msproxy");
+       proto_msproxy = proto_register_protocol( "MS Proxy Protocol",
+               "MS Proxy", "msproxy");
 
        proto_register_field_array(proto_msproxy, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
@@ -1249,7 +1278,7 @@ proto_register_msproxy( void){
        register_init_routine( &msproxy_reinit);        /* register re-init routine */
 
        msproxy_sub_handle = create_dissector_handle(msproxy_sub_dissector,
-           proto_msproxy);
+               proto_msproxy);
 }
 
 
@@ -1261,6 +1290,6 @@ proto_reg_handoff_msproxy(void) {
        dissector_handle_t msproxy_handle;
 
        msproxy_handle = create_dissector_handle(dissect_msproxy,
-           proto_msproxy);
+               proto_msproxy);
        dissector_add_uint("udp.port", UDP_PORT_MSPROXY, msproxy_handle);
 }