Give the code that computes protocol statistics a progress dialog box,
[obnox/wireshark/wip.git] / packet-wtls.c
index bd5e22f939f5b6ce3b0a1509d59855511031bc52..8a4194754c62eff29378d8b60583b5043c81078a 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Routines to dissect WTLS component of WAP traffic.
  * 
- * $Id: packet-wtls.c,v 1.1 2001/02/13 00:17:54 guy Exp $
+ * $Id: packet-wtls.c,v 1.4 2001/03/09 04:35:22 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -382,8 +382,8 @@ dissect_wtls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        else {
                                count = tvb_length (tvb)-offset_wtls;
                        }
-                       ti = proto_tree_add_item(wtls_tree, hf_wtls_record, tvb, offset_wtls,
-                                count, bo_little_endian);
+                       ti = proto_tree_add_uint(wtls_tree, hf_wtls_record, tvb, offset_wtls,
+                                count, pdut);
                        wtls_rec_tree = proto_item_add_subtree(ti, ett_wtls_rec);
 
                        offset = offset_wtls;
@@ -450,6 +450,7 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
        int size = 0;
        guint public_key = 0;
        guint signature = 0;
+       char valStr[1024];
 
        proto_item *ti;
        proto_item *cli_key_item;
@@ -458,10 +459,10 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
        proto_tree *wtls_msg_type_item_sub_tree;
        proto_tree *wtls_msg_type_item_sub_sub_tree;
 
-       ti = proto_tree_add_item(tree, hf_wtls_hands, tvb, offset,count, bo_little_endian);
+       pdu_msg_type = tvb_get_guint8 (tvb, offset);
+       ti = proto_tree_add_uint(tree, hf_wtls_hands, tvb, offset,count, pdu_msg_type);
        wtls_msg_type_tree = proto_item_add_subtree(ti, ett_wtls_msg_type);
        
-       pdu_msg_type = tvb_get_guint8 (tvb, offset);
        ti = proto_tree_add_item (wtls_msg_type_tree, hf_wtls_hands_type,
                        tvb,offset,1,bo_big_endian);
        offset+=1;
@@ -496,15 +497,16 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                        wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
                        offset+=2;
                        for (;count > 0;count-=client_size) {
-                               cli_key_item = proto_tree_add_item(wtls_msg_type_item_sub_tree, 
+                               value = tvb_get_guint8 (tvb, offset);
+                               cli_key_item = proto_tree_add_uint(wtls_msg_type_item_sub_tree, 
                                                hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
-                                               bo_little_endian);
+                                               value);
                                client_size=1;
                                wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
                                                                  ett_wtls_msg_type_item_sub_sub);
-                               ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
+                               ti = proto_tree_add_uint(wtls_msg_type_item_sub_sub_tree,
                                                hf_wtls_hands_cli_hello_key_exchange_suite,
-                                               tvb,offset,1,bo_big_endian);
+                                               tvb,offset,1,value);
                                offset++;
                                value = tvb_get_guint8 (tvb, offset);
                                ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
@@ -535,15 +537,16 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                        wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
                        offset+=2;
                        for (;count > 0;count-=client_size) {
-                               cli_key_item = proto_tree_add_item(wtls_msg_type_item_sub_tree, 
+                               value = tvb_get_guint8 (tvb, offset);
+                               cli_key_item = proto_tree_add_uint(wtls_msg_type_item_sub_tree, 
                                                hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
-                                               bo_little_endian);
+                                               value);
                                client_size=1;
                                wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
                                                                  ett_wtls_msg_type_item_sub_sub);
-                               ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
+                               ti = proto_tree_add_uint(wtls_msg_type_item_sub_sub_tree,
                                                hf_wtls_hands_cli_hello_key_exchange_suite,
-                                               tvb,offset,1,bo_big_endian);
+                                               tvb,offset,1,value);
                                offset++;
                                value = tvb_get_guint8 (tvb, offset);
                                ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
@@ -718,11 +721,13 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                                                                offset+=2;
                                                                client_size+=2;
                                                                value =  tvb_get_guint8 (tvb, offset);
-                                                               ti = proto_tree_add_item(
+                                                               strncpy(valStr,tvb_get_ptr (tvb, offset+1, value),value);
+                                                               valStr[value]=0;
+                                                               ti = proto_tree_add_string(
                                                                                wtls_msg_type_item_sub_tree, 
                                                                                hf_wtls_hands_certificate_wtls_issuer_name,
                                                                                tvb, offset,1+value,
-                                                                               bo_big_endian);
+                                                                               valStr);
                                                                offset+=1+value;
                                                                client_size+=1+value;
                                                                break;
@@ -766,11 +771,13 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                                                                offset+=2;
                                                                client_size+=2;
                                                                value =  tvb_get_guint8 (tvb, offset);
-                                                               ti = proto_tree_add_item(
+                                                               strncpy(valStr,tvb_get_ptr (tvb, offset+1, value),value);
+                                                               valStr[value]=0;
+                                                               ti = proto_tree_add_string(
                                                                                wtls_msg_type_item_sub_tree, 
                                                                                hf_wtls_hands_certificate_wtls_subject_name,
                                                                                tvb, offset,1+value,
-                                                                               bo_big_endian);
+                                                                               valStr);
                                                                offset+=1+value;
                                                                client_size+=1+value;
                                                                break;
@@ -805,15 +812,15 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                                                switch (public_key) {
                                                        case PUBLIC_KEY_RSA :
                                                                value = tvb_get_ntohs (tvb, offset);
-                                                               ti = proto_tree_add_item(wtls_msg_type_item_sub_tree,
+                                                               ti = proto_tree_add_uint(wtls_msg_type_item_sub_tree,
                                                                        hf_wtls_hands_certificate_wtls_rsa_exponent,
-                                                                       tvb,offset,value+2,bo_big_endian);
+                                                                       tvb,offset,value+2,value*8);
                                                                offset+=2+value;
                                                                client_size+=2+value;
                                                                value = tvb_get_ntohs (tvb, offset);
-                                                               ti = proto_tree_add_item(wtls_msg_type_item_sub_tree,
+                                                               ti = proto_tree_add_uint(wtls_msg_type_item_sub_tree,
                                                                        hf_wtls_hands_certificate_wtls_rsa_modules,
-                                                                       tvb,offset,value+2,bo_big_endian);
+                                                                       tvb,offset,value+2,value*8);
                                                                offset+=2+value;
                                                                client_size+=2+value;
                                                                break;
@@ -823,9 +830,9 @@ dissect_wtls_handshake(proto_tree *tree, tvbuff_t *tvb, guint offset, guint coun
                                                                break;
                                                }
                                                value = tvb_get_ntohs (tvb, offset);
-                                               ti = proto_tree_add_item(wtls_msg_type_item_sub_tree,
+                                               ti = proto_tree_add_uint(wtls_msg_type_item_sub_tree,
                                                        hf_wtls_hands_certificate_wtls_signature,
-                                                       tvb,offset,2+value,bo_big_endian);
+                                                       tvb,offset,2+value,value*8);
                                                offset+=2+value;
                                                client_size+=2+value;
                                                break;
@@ -864,14 +871,14 @@ proto_register_wtls(void)
                { &hf_wtls_record,
                        {       "Record",           
                                "wsp.wtls.record",
-                                FT_NONE, BASE_NONE, NULL, 0x00,
+                                FT_UINT8, BASE_NONE, VALS ( wtls_vals_record_type ), 0x0f,
                                "Record" 
                        }
                },
                { &hf_wtls_record_type,
                        {       "Record Type",           
                                "wsp.wtls.rec_type",
-                                FT_UINT8, BASE_DEC, VALS ( wtls_vals_record_type ), 0x0f,
+                                FT_UINT8, BASE_NONE, VALS ( wtls_vals_record_type ), 0x0f,
                                "Record Type" 
                        }
                },
@@ -899,7 +906,7 @@ proto_register_wtls(void)
                { &hf_wtls_hands,
                        {       "Handshake",           
                                "wsp.wtls.handshake",
-                                FT_NONE, BASE_DEC, NULL, 0x00,
+                                FT_UINT8, BASE_HEX, VALS ( wtls_vals_handshake_type ), 0x00,
                                "Handshake" 
                        }
                },
@@ -969,7 +976,7 @@ proto_register_wtls(void)
                { &hf_wtls_hands_cli_hello_key_exchange,
                        {       "Key Exchange",           
                                "wsp.wtls.handshake.client_hello.key.key_exchange",
-                                FT_NONE, BASE_NONE, NULL, 0x00,
+                                FT_UINT8, BASE_HEX, VALS ( wtls_vals_key_exchange_suite ), 0x00,
                                "Key Exchange" 
                        }
                },
@@ -1177,10 +1184,10 @@ proto_register_wtls(void)
                        }
                },
                { &hf_wtls_hands_certificate_wtls_signature,
-                       {       "Signature",           
+                       {       "Signature Size",           
                                "wsp.wtls.handshake.certificate.signature.signature",
-                                FT_NONE, BASE_HEX, NULL, 0x00,
-                               "Signature" 
+                                FT_UINT32, BASE_DEC, NULL, 0x00,
+                               "Signature Size
                        }
                },
                { &hf_wtls_hands_certificate_wtls_issuer_type,
@@ -1200,7 +1207,7 @@ proto_register_wtls(void)
                { &hf_wtls_hands_certificate_wtls_issuer_name,
                        {       "Name",           
                                "wsp.wtls.handshake.certificate.issuer.name",
-                                FT_NONE, BASE_HEX, NULL, 0x00,
+                                FT_STRING, BASE_NONE, NULL, 0x00,
                                "Name" 
                        }
                },
@@ -1235,7 +1242,7 @@ proto_register_wtls(void)
                { &hf_wtls_hands_certificate_wtls_subject_name,
                        {       "Name",           
                                "wsp.wtls.handshake.certificate.subject.name",
-                                FT_NONE, BASE_HEX, NULL, 0x00,
+                                FT_STRING, BASE_NONE, NULL, 0x00,
                                "Name" 
                        }
                },
@@ -1261,17 +1268,17 @@ proto_register_wtls(void)
                        }
                },
                { &hf_wtls_hands_certificate_wtls_rsa_exponent,
-                       {       "RSA Exponent",           
+                       {       "RSA Exponent Size",           
                                "wsp.wtls.handshake.certificate.rsa.exponent",
-                                FT_NONE, BASE_HEX, NULL, 0x00,
-                               "RSA Exponent" 
+                                FT_UINT32, BASE_DEC, NULL, 0x00,
+                               "RSA Exponent Size
                        }
                },
                { &hf_wtls_hands_certificate_wtls_rsa_modules,
-                       {       "RSA Modulus",           
+                       {       "RSA Modulus Size",           
                                "wsp.wtls.handshake.certificate.rsa.modulus",
-                                FT_NONE, BASE_HEX, NULL, 0x00,
-                               "RSA Modulus" 
+                                FT_UINT32, BASE_DEC, NULL, 0x00,
+                               "RSA Modulus Size
                        }
                },
                { &hf_wtls_alert,
@@ -1321,7 +1328,7 @@ proto_register_wtls(void)
        proto_register_subtree_array(ett, array_length(ett));
 
        register_dissector("wtls", dissect_wtls, proto_wtls);
-};
+}
 
 void
 proto_reg_handoff_wtls(void)