Apply some of the patches from:
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 14 May 2009 20:04:28 +0000 (20:04 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 14 May 2009 20:04:28 +0000 (20:04 +0000)
http://wiki.wireshark.org/Development/Optimization

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28364 f5534014-38df-0310-8fa8-9805f1628bb7

asn1/snmp/packet-snmp-template.c
asn1/snmp/snmp.cnf
epan/dissectors/packet-snmp.c
epan/dissectors/packet-tali.c
epan/dissectors/packet-tcp.c

index 17541e97b83a458978f0e0b7aa5c14d3202cdeda..1138569ff15597288a864d3d7b94438930a8bbc4 100644 (file)
@@ -1232,7 +1232,7 @@ static gboolean snmp_usm_auth_sha1(snmp_usm_params_t* p _U_, guint8** calc_auth_
        return ( memcmp(auth,calc_auth,12) != 0 ) ? FALSE : TRUE;
 }
 
-static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_) {
+static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData , gchar const** error _U_) {
 #ifdef HAVE_LIBGCRYPT
     gcry_error_t err;
     gcry_cipher_hd_t hd = NULL;
@@ -1290,7 +1290,7 @@ static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encrypted
 
        gcry_cipher_close(hd);
 
-       clear_tvb = tvb_new_real_data(cleartext, cryptgrm_len, cryptgrm_len);
+       clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
 
        return clear_tvb;
 
@@ -1304,7 +1304,7 @@ on_gcry_error:
 #endif
 }
 
-static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_) {
+static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData , gchar const** error _U_) {
 #ifdef HAVE_LIBGCRYPT
     gcry_error_t err;
     gcry_cipher_hd_t hd = NULL;
@@ -1353,7 +1353,7 @@ static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encrypted
 
        gcry_cipher_close(hd);
 
-       clear_tvb = tvb_new_real_data(cleartext, cryptgrm_len, cryptgrm_len);
+       clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
 
        return clear_tvb;
 
index bf45f6322d73265e6516e4d5d17e9b9cde288707..6a3753b7f903c5d49b766939dd3f7a6db6bf3441 100644 (file)
@@ -141,7 +141,6 @@ gint pdu_type=-1;
 
                        
             add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");
-                       tvb_set_child_real_data_tvbuff(tvb, cleartext_tvb);
                        
                        decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,FALSE);
                        decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);
index 0756254496e88e77cf80950557899219527a27df..d5e9818daa2f140da0ab6b31bc2308927be1a75b 100644 (file)
@@ -1,7 +1,7 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
 /* packet-snmp.c                                                              */
-/* ../../tools/asn2wrs.py -b -p snmp -c ./snmp.cnf -s ./packet-snmp-template -D . snmp.asn */
+/* ../../tools/asn2wrs.py -b -p snmp -c snmp.cnf -s packet-snmp-template snmp.asn */
 
 /* Input file: packet-snmp-template.c */
 
@@ -1334,7 +1334,7 @@ static gboolean snmp_usm_auth_sha1(snmp_usm_params_t* p _U_, guint8** calc_auth_
        return ( memcmp(auth,calc_auth,12) != 0 ) ? FALSE : TRUE;
 }
 
-static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_) {
+static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData , gchar const** error _U_) {
 #ifdef HAVE_LIBGCRYPT
     gcry_error_t err;
     gcry_cipher_hd_t hd = NULL;
@@ -1392,7 +1392,7 @@ static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t* p _U_, tvbuff_t* encrypted
 
        gcry_cipher_close(hd);
 
-       clear_tvb = tvb_new_real_data(cleartext, cryptgrm_len, cryptgrm_len);
+       clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
 
        return clear_tvb;
 
@@ -1406,7 +1406,7 @@ on_gcry_error:
 #endif
 }
 
-static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData _U_, gchar const** error _U_) {
+static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encryptedData , gchar const** error _U_) {
 #ifdef HAVE_LIBGCRYPT
     gcry_error_t err;
     gcry_cipher_hd_t hd = NULL;
@@ -1455,7 +1455,7 @@ static tvbuff_t* snmp_usm_priv_aes(snmp_usm_params_t* p _U_, tvbuff_t* encrypted
 
        gcry_cipher_close(hd);
 
-       clear_tvb = tvb_new_real_data(cleartext, cryptgrm_len, cryptgrm_len);
+       clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
 
        return clear_tvb;
 
@@ -2088,7 +2088,7 @@ dissect_snmp_INTEGER_484_2147483647(gboolean implicit_tag _U_, tvbuff_t *tvb _U_
 
 static int
 dissect_snmp_T_msgFlags(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 213 "snmp.cnf"
+#line 212 "snmp.cnf"
        tvbuff_t *parameter_tvb = NULL;
 
    offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
@@ -2143,7 +2143,7 @@ dissect_snmp_HeaderData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
 
 static int
 dissect_snmp_T_msgSecurityParameters(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 156 "snmp.cnf"
+#line 155 "snmp.cnf"
 
        switch(MsgSecurityModel){
                case SNMP_SEC_USM:      /* 3 */         
@@ -2227,7 +2227,6 @@ dissect_snmp_T_encryptedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
 
                        
             add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");
-                       tvb_set_child_real_data_tvbuff(tvb, cleartext_tvb);
                        
                        decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,FALSE);
                        decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);
@@ -2279,7 +2278,7 @@ dissect_snmp_SNMPv3Message(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
                                    SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);
 
-#line 171 "snmp.cnf"
+#line 170 "snmp.cnf"
 
        if( usm_p.authenticated
                && usm_p.user_assoc
index b7fde297cbbefb3e635542143874d4d43f7ae073..c2e7bd26b7be1110969c7ce666cef22a939f28e1 100644 (file)
@@ -147,14 +147,12 @@ dissect_tali(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 static gboolean
 dissect_tali_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-  char sync[TALI_SYNC_LENGTH];     /* TALI sync */
   char opcode[TALI_OPCODE_LENGTH]; /* TALI opcode */
 
   if (tvb_reported_length(tvb) < TALI_HEADER_LENGTH)   /* Mandatory header     */
     return FALSE;
 
-  tvb_memcpy(tvb, (guint8*)sync, 0, TALI_SYNC_LENGTH);
-  if (strncmp(sync, TALI_SYNC, TALI_SYNC_LENGTH) != 0)
+  if (tvb_strneql(tvb, 0, TALI_SYNC, TALI_SYNC_LENGTH) != 0)
     return FALSE;
 
   tvb_memcpy(tvb, (guint8*)opcode, TALI_SYNC_LENGTH, TALI_OPCODE_LENGTH);
index f56bcbce6887150389aaffa0cdfcc2797039d282..ad73e8797f336a0935f00de6dd6e71b605e39cdc 100644 (file)
@@ -1628,11 +1628,9 @@ again:
                        int old_len;
 
                        /* create a new TVB structure for desegmented data */
-                       next_tvb = tvb_new_real_data(ipfd_head->data,
+                       next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
                                        ipfd_head->datalen, ipfd_head->datalen);
 
-                       /* add this tvb as a child to the original one */
-                       tvb_set_child_real_data_tvbuff(tvb, next_tvb);
 
                        /* add desegmented data to the data source list */
                        add_new_data_source(pinfo, next_tvb, "Reassembled TCP");