Convert asn1 template files proto_tree_add_item() 'encoding' arg for field types...
[obnox/wireshark/wip.git] / epan / dissectors / packet-snmp.c
index fd33e8715a1d1400382e4e129748e34590c3e61f..926ec8ea39bb931a151596fc2095519782e76604 100644 (file)
@@ -1,11 +1,11 @@
 /* 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 -D . -O ../../epan/dissectors snmp.asn */
 
 /* Input file: packet-snmp-template.c */
 
-#line 1 "packet-snmp-template.c"
+#line 1 "../../asn1/snmp/packet-snmp-template.c"
 /* packet-snmp.c
  * Routines for SNMP (simple network management protocol)
  * Copyright (C) 1998 Didier Jorand
@@ -227,7 +227,7 @@ static int hf_snmp_scalar_instance_index = -1;
 
 
 /*--- Included file: packet-snmp-hf.c ---*/
-#line 1 "packet-snmp-hf.c"
+#line 1 "../../asn1/snmp/packet-snmp-hf.c"
 static int hf_snmp_SMUX_PDUs_PDU = -1;            /* SMUX_PDUs */
 static int hf_snmp_version = -1;                  /* Version */
 static int hf_snmp_community = -1;                /* Community */
@@ -261,7 +261,7 @@ static int hf_snmp_set_request = -1;              /* SetRequest_PDU */
 static int hf_snmp_trap = -1;                     /* Trap_PDU */
 static int hf_snmp_getBulkRequest = -1;           /* GetBulkRequest_PDU */
 static int hf_snmp_informRequest = -1;            /* InformRequest_PDU */
-static int hf_snmp_sNMPv2_Trap = -1;              /* SNMPv2_Trap_PDU */
+static int hf_snmp_snmpV2_trap = -1;              /* SNMPv2_Trap_PDU */
 static int hf_snmp_report = -1;                   /* Report_PDU */
 static int hf_snmp_request_id = -1;               /* INTEGER */
 static int hf_snmp_error_status = -1;             /* T_error_status */
@@ -295,7 +295,7 @@ static int hf_snmp_priority = -1;                 /* INTEGER_M1_2147483647 */
 static int hf_snmp_operation = -1;                /* T_operation */
 
 /*--- End of included file: packet-snmp-hf.c ---*/
-#line 221 "packet-snmp-template.c"
+#line 221 "../../asn1/snmp/packet-snmp-template.c"
 
 static int hf_smux_version = -1;
 static int hf_smux_pdutype = -1;
@@ -316,7 +316,7 @@ static gint ett_decoding_error = -1;
 
 
 /*--- Included file: packet-snmp-ett.c ---*/
-#line 1 "packet-snmp-ett.c"
+#line 1 "../../asn1/snmp/packet-snmp-ett.c"
 static gint ett_snmp_Message = -1;
 static gint ett_snmp_Messagev2u = -1;
 static gint ett_snmp_T_datav2u = -1;
@@ -338,7 +338,7 @@ static gint ett_snmp_SimpleOpen_U = -1;
 static gint ett_snmp_RReqPDU_U = -1;
 
 /*--- End of included file: packet-snmp-ett.c ---*/
-#line 240 "packet-snmp-template.c"
+#line 240 "../../asn1/snmp/packet-snmp-template.c"
 
 static const true_false_string auth_flags = {
        "OK",
@@ -551,7 +551,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
 
        /* then we have the  value's header */
        offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
-       value_offset = offset = get_ber_length(tvb, offset, &value_len, &ind);
+       value_offset = get_ber_length(tvb, offset, &value_len, &ind);
 
        if (! (!pc) ) {
                proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"the value must be in primitive encoding");
@@ -569,7 +569,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
        pt_varbind = proto_item_add_subtree(pi_varbind,ett_varbind);
        *label = '\0';
 
-       pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,FALSE);
+       pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA);
        pt_name = proto_item_add_subtree(pi_name,ett_name);
 
        /* fetch ObjectName and its relative oid_info */
@@ -623,7 +623,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
                        }
                }
 
-               pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,FALSE);
+               pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
                expert_add_info_format(actx->pinfo, pi, PI_RESPONSE_CODE, PI_NOTE, "%s",note);
                g_strlcpy (label, note, ITEM_LABEL_LENGTH);
                goto set_label;
@@ -640,7 +640,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
                        } else if (oid_left  == 0) {
                                if (ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
                                        /* unSpecified  does not require an instance sub-id add the new value and get off the way! */
-                                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,FALSE);
+                                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
                                        goto set_label;
                                } else {
                                        proto_item* pi = proto_tree_add_text(pt_name,tvb,0,0,"A scalar should have one instance sub-id this one has none");
@@ -664,7 +664,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
 
                                if ( key_len == 0 && ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
                                        /* unSpecified  does not require an instance sub-id add the new value and get off the way! */
-                                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,FALSE);
+                                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
                                        goto set_label;
                                }
 
@@ -690,7 +690,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
                                                                if (IS_FT_INT(k->ft_type)) {
                                                                        proto_tree_add_int(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);
                                                                } else { /* if it's not an unsigned int let proto_tree_add_uint throw a warning */
-                                                                       proto_tree_add_uint(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);
+                                                                       proto_tree_add_uint64(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);
                                                                }
                                                                key_start++;
                                                                key_len--;
@@ -794,11 +794,11 @@ show_oid_index:
                                                                        case OID_KEY_TYPE_IPADDR: {
                                                                                guint32* ipv4_p = (void*)buf;
                                                                                proto_tree_add_ipv4(pt_name,k->hfid,tvb,name_offset,buf_len, *ipv4_p);
+                                                                               }
                                                                                break;
                                                                        default:
                                                                                DISSECTOR_ASSERT_NOT_REACHED();
                                                                                break;
-                                                                       }
                                                                }
 
                                                                key_start += buf_len;
@@ -831,31 +831,34 @@ indexing_done:
 
        if (oid_info_is_ok && oid_info->value_type) {
                if (ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
-                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,FALSE);
-               }  else {
+                       pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
+               } else {
+                       /* Provide a tree_item to attach errors to, if needed. */
+                       pi_value = pi_name;
+
                        if ((oid_info->value_type->ber_class != BER_CLASS_ANY) &&
                                (ber_class != oid_info->value_type->ber_class))
                                format_error = BER_WRONG_TAG;
-
-                       if ((oid_info->value_type->ber_tag != BER_TAG_ANY) &&
+                       else if ((oid_info->value_type->ber_tag != BER_TAG_ANY) &&
                                (tag != oid_info->value_type->ber_tag))
                                format_error = BER_WRONG_TAG;
+                       else {
+                               max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;
+                               min_len  = oid_info->value_type->min_len;
 
-                       max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;
-                       min_len  = oid_info->value_type->min_len;
-
-                       if ((int)value_len < min_len || (int)value_len > max_len) {
-                               format_error = BER_WRONG_LENGTH;
-                       } else {
-                               pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,FALSE);
+                               if ((int)value_len < min_len || (int)value_len > max_len)
+                                       format_error = BER_WRONG_LENGTH;
                        }
+
+                       if (format_error == BER_NO_ERROR)
+                               pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
                }
        } else {
                switch(ber_class|(tag<<4)) {
                        case BER_CLASS_UNI|(BER_UNI_TAG_INTEGER<<4):
                        {
                                gint64 val=0;
-                               unsigned offset = value_offset;
+                               unsigned int_val_offset = value_offset;
                                unsigned i;
 
                                max_len = 5; min_len = 1;
@@ -866,12 +869,12 @@ indexing_done:
 
                                if(value_len > 0) {
                                        /* extend sign bit */
-                                       if(tvb_get_guint8(tvb, offset)&0x80) {
+                                       if(tvb_get_guint8(tvb, int_val_offset)&0x80) {
                                                val=-1;
                                        }
                                        for(i=0;i<value_len;i++) {
-                                               val=(val<<8)|tvb_get_guint8(tvb, offset);
-                                               offset++;
+                                               val=(val<<8)|tvb_get_guint8(tvb, int_val_offset);
+                                               int_val_offset++;
                                        }
                                }
                                proto_tree_add_int64(pt_varbind, hf_snmp_integer32_value, tvb,value_offset,value_len, val);
@@ -924,7 +927,7 @@ indexing_done:
                                break;
                }
 
-               pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,FALSE);
+               pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
                if (format_error != BER_NO_ERROR) {
                        expert_add_info_format(actx->pinfo, pi_value, PI_UNDECODED, PI_NOTE, "Unresolved value, Missing MIB");
                }
@@ -1048,7 +1051,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
     /* first bit: engine id conformance */
     if (len_remain<4) return offset;
     conformance = ((tvb_get_guint8(tvb, offset)>>7) & 0x01);
-    proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, FALSE);
+    proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN);
 
     /* 4-byte enterprise number/name */
     if (len_remain<4) return offset;
@@ -1088,7 +1091,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
       case SNMP_ENGINEID_FORMAT_IPV4:
        /* 4-byte IPv4 address */
        if (len_remain==4) {
-         proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
          offset+=4;
          len_remain=0;
        }
@@ -1096,7 +1099,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
       case SNMP_ENGINEID_FORMAT_IPV6:
        /* 16-byte IPv6 address */
        if (len_remain==16) {
-         proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA);
          offset+=16;
          len_remain=0;
        }
@@ -1104,13 +1107,13 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
       case SNMP_ENGINEID_FORMAT_MACADDRESS:
        /* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */
        if ((enterpriseid==9)&&(len_remain==7)) {
-         proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN);
          offset++;
          len_remain--;
        }
        /* 6-byte MAC address */
        if (len_remain==6) {
-         proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_BIG_ENDIAN);
          offset+=6;
          len_remain=0;
        }
@@ -1118,7 +1121,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
       case SNMP_ENGINEID_FORMAT_TEXT:
        /* max. 27-byte string, administratively assigned */
        if (len_remain<=27) {
-         proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII|ENC_NA);
          offset+=len_remain;
          len_remain=0;
        }
@@ -1129,7 +1132,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
          proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
          /* demystify: 4B random, 4B epoch seconds */
          if (len_remain==8) {
-           proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, FALSE);
+           proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA);
            seconds = tvb_get_letohl(tvb, offset+4);
            ts.secs = seconds;
            ts.nsecs = 0;
@@ -1145,7 +1148,7 @@ dissect_snmp_engineid(proto_tree *tree, tvbuff_t *tvb, int offset, int len)
       default:
        /* max. 27 bytes, administratively assigned or unknown format */
        if (len_remain<=27) {
-         proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, FALSE);
+         proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA);
          offset+=len_remain;
          len_remain=0;
        }
@@ -1273,9 +1276,9 @@ get_user_assoc(tvbuff_t* engine_tvb, tvbuff_t* user_tvb)
 
        if (! ( user_tvb && engine_tvb ) ) return NULL;
 
-       given_username_len = tvb_length_remaining(user_tvb,0);
+       given_username_len = tvb_ensure_length_remaining(user_tvb,0);
        given_username = ep_tvb_memdup(user_tvb,0,-1);
-       given_engine_len = tvb_length_remaining(engine_tvb,0);
+       given_engine_len = tvb_ensure_length_remaining(engine_tvb,0);
        given_engine = ep_tvb_memdup(engine_tvb,0,-1);
 
        for (a = localized_ues; a; a = a->next) {
@@ -1593,13 +1596,13 @@ check_ScopedPdu(tvbuff_t* tvb)
 
 
 /*--- Included file: packet-snmp-fn.c ---*/
-#line 1 "packet-snmp-fn.c"
+#line 1 "../../asn1/snmp/packet-snmp-fn.c"
 
 
 
 static int
 dissect_snmp_EnterpriseOID(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 64 "snmp.cnf"
+#line 64 "../../asn1/snmp/snmp.cnf"
   const gchar* name;
 
   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &enterprise_oid);
@@ -1852,7 +1855,7 @@ dissect_snmp_GenericTrap(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse
 
 static int
 dissect_snmp_SpecificTrap(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 48 "snmp.cnf"
+#line 48 "../../asn1/snmp/snmp.cnf"
   guint specific_trap;
   
   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
@@ -1883,7 +1886,7 @@ static const ber_sequence_t Trap_PDU_U_sequence[] = {
 
 static int
 dissect_snmp_Trap_PDU_U(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 40 "snmp.cnf"
+#line 40 "../../asn1/snmp/snmp.cnf"
   generic_trap = 0;
   enterprise_oid = NULL;
 
@@ -1982,7 +1985,7 @@ static const value_string snmp_PDUs_vals[] = {
   {   4, "trap" },
   {   5, "getBulkRequest" },
   {   6, "informRequest" },
-  {   7, "sNMPv2-Trap" },
+  {   7, "snmpV2-trap" },
   {   8, "report" },
   { 0, NULL }
 };
@@ -1995,14 +1998,14 @@ static const ber_choice_t PDUs_choice[] = {
   {   4, &hf_snmp_trap           , BER_CLASS_CON, 4, BER_FLAGS_NOOWNTAG, dissect_snmp_Trap_PDU },
   {   5, &hf_snmp_getBulkRequest , BER_CLASS_CON, 5, BER_FLAGS_NOOWNTAG, dissect_snmp_GetBulkRequest_PDU },
   {   6, &hf_snmp_informRequest  , BER_CLASS_CON, 6, BER_FLAGS_NOOWNTAG, dissect_snmp_InformRequest_PDU },
-  {   7, &hf_snmp_sNMPv2_Trap    , BER_CLASS_CON, 7, BER_FLAGS_NOOWNTAG, dissect_snmp_SNMPv2_Trap_PDU },
+  {   7, &hf_snmp_snmpV2_trap    , BER_CLASS_CON, 7, BER_FLAGS_NOOWNTAG, dissect_snmp_SNMPv2_Trap_PDU },
   {   8, &hf_snmp_report         , BER_CLASS_CON, 8, BER_FLAGS_NOOWNTAG, dissect_snmp_Report_PDU },
   { 0, NULL, 0, 0, 0, NULL }
 };
 
 static int
 dissect_snmp_PDUs(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 28 "snmp.cnf"
+#line 28 "../../asn1/snmp/snmp.cnf"
 gint pdu_type=-1;
 
   col_clear(actx->pinfo->cinfo, COL_INFO);
@@ -2088,7 +2091,7 @@ dissect_snmp_Messagev2u(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
 
 static int
 dissect_snmp_SnmpEngineID(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 99 "snmp.cnf"
+#line 99 "../../asn1/snmp/snmp.cnf"
        tvbuff_t* param_tvb = NULL;
 
        offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
@@ -2107,7 +2110,7 @@ dissect_snmp_SnmpEngineID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offs
 
 static int
 dissect_snmp_T_msgAuthoritativeEngineID(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 90 "snmp.cnf"
+#line 90 "../../asn1/snmp/snmp.cnf"
 
   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
                                        &usm_p.engine_tvb);
@@ -2155,7 +2158,7 @@ dissect_snmp_T_msgUserName(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off
 
 static int
 dissect_snmp_T_msgAuthenticationParameters(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 112 "snmp.cnf"
+#line 112 "../../asn1/snmp/snmp.cnf"
        offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);
        if (usm_p.auth_tvb) {
                usm_p.auth_item = actx->created_item;
@@ -2209,7 +2212,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 227 "snmp.cnf"
+#line 227 "../../asn1/snmp/snmp.cnf"
        tvbuff_t *parameter_tvb = NULL;
 
    offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
@@ -2264,7 +2267,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 170 "snmp.cnf"
+#line 170 "../../asn1/snmp/snmp.cnf"
 
        switch(MsgSecurityModel){
                case SNMP_SEC_USM:      /* 3 */         
@@ -2306,7 +2309,7 @@ dissect_snmp_ScopedPDU(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
 
 static int
 dissect_snmp_T_encryptedPDU(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 121 "snmp.cnf"
+#line 121 "../../asn1/snmp/snmp.cnf"
        tvbuff_t* crypt_tvb;
        offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_snmp_encryptedPDU, &crypt_tvb);
 
@@ -2396,7 +2399,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 185 "snmp.cnf"
+#line 185 "../../asn1/snmp/snmp.cnf"
 
        if( usm_p.authenticated
                && usm_p.user_assoc
@@ -2713,7 +2716,7 @@ static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pro
 
 
 /*--- End of included file: packet-snmp-fn.c ---*/
-#line 1493 "packet-snmp-template.c"
+#line 1496 "../../asn1/snmp/packet-snmp-template.c"
 
 
 guint
@@ -2782,8 +2785,16 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
                 * BER).
                 */
                if (length_remaining < 6) {
+                       /*
+                        * Yes.  Tell the TCP dissector where the data
+                        * for this message starts in the data it handed
+                        * us and that we need "some more data."  Don't tell
+                        * it exactly how many bytes we need because if/when
+                        * we ask for even more (after the header) that will
+                        * break reassembly.
+                        */
                        pinfo->desegment_offset = offset;
-                       pinfo->desegment_len = 6 - length_remaining;
+                       pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
 
                        /*
                         * Return 0, which means "I didn't dissect anything
@@ -2843,7 +2854,7 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
        if (tree) {
                item = proto_tree_add_item(tree, proto, tvb, start_offset,
-                                          message_length, FALSE);
+                                          message_length, ENC_BIG_ENDIAN);
                snmp_tree = proto_item_add_subtree(item, ett);
        }
 
@@ -2924,7 +2935,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                }
        }
        /* then comes an INTEGER (version)*/
-       offset = get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
+       get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
        if((tmp_class!=BER_CLASS_UNI)||(tmp_tag!=BER_UNI_TAG_INTEGER)) {
                return 0;
        }
@@ -2994,11 +3005,11 @@ dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");
 
        if (tree) {
-               item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, FALSE);
+               item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, ENC_BIG_ENDIAN);
                smux_tree = proto_item_add_subtree(item, ett_smux);
        }
 
-       dissect_SMUX_PDUs_PDU(tvb, pinfo, tree);
+       dissect_SMUX_PDUs_PDU(tvb, pinfo, smux_tree);
 }
 
 
@@ -3038,8 +3049,8 @@ snmp_usm_password_to_key_md5(const guint8 *password, guint passwordlen,
        /*****************************************************/
        /* Now localize the key with the engineID and pass   */
        /* through MD5 to produce final key                  */
-       /* May want to ensure that engineLength <= 32,       */
-       /* otherwise need to use a buffer larger than 64     */
+       /* We ignore invalid engineLengths here. More strict */
+       /* checking is done in snmp_users_update_cb.         */
        /*****************************************************/
 
        md5_init(&MD);
@@ -3064,7 +3075,7 @@ snmp_usm_password_to_key_sha1(const guint8 *password, guint passwordlen,
                              guint8 *key)
 {
        sha1_context     SH;
-       guint8     *cp, password_buf[72];
+       guint8     *cp, password_buf[64];
        guint32      password_index = 0;
        guint32      count = 0, i;
 
@@ -3090,15 +3101,14 @@ snmp_usm_password_to_key_sha1(const guint8 *password, guint passwordlen,
        /*****************************************************/
        /* Now localize the key with the engineID and pass   */
        /* through SHA to produce final key                  */
-       /* May want to ensure that engineLength <= 32,       */
-       /* otherwise need to use a buffer larger than 72     */
+       /* We ignore invalid engineLengths here. More strict */
+       /* checking is done in snmp_users_update_cb.         */
        /*****************************************************/
-       memcpy(password_buf, key, 20);
-       memcpy(password_buf+20, engineID, engineLength);
-       memcpy(password_buf+20+engineLength, key, 20);
 
        sha1_starts(&SH);
-       sha1_update(&SH, password_buf, 40+engineLength);
+       sha1_update(&SH, key, 20);
+       sha1_update(&SH, engineID, engineLength);
+       sha1_update(&SH, key, 20);
        sha1_finish(&SH, key);
        return;
  }
@@ -3175,6 +3185,11 @@ snmp_users_update_cb(void* p _U_, const char** err)
        for (i=0; i<num_ueas-1; i++) {
                snmp_ue_assoc_t* u = &(ueas[i]);
 
+               /* RFC 3411 section 5 */
+               if ((u->engine.len > 0) && (u->engine.len < 5 || u->engine.len > 32)) {
+                       g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
+               }
+
 
                if ( u->user.userName.len == ue->user.userName.len
                        && u->engine.len == ue->engine.len ) {
@@ -3182,20 +3197,20 @@ snmp_users_update_cb(void* p _U_, const char** err)
                        if (u->engine.len > 0 && memcmp( u->engine.data,   ue->engine.data,  u->engine.len ) == 0) {
                                if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
                                        /* XXX: make a string for the engineId */
-                                       g_string_append_printf(es,"duplicate key (userName='%s')\n",ue->user.userName.data);
+                                       g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
                                }
                        }
 
                        if (u->engine.len == 0) {
                                if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
-                                       g_string_append_printf(es,"duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
+                                       g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
                                }
                        }
                }
        }
 
        if (es->len) {
-               g_string_truncate(es,es->len-2);
+               g_string_truncate(es,es->len-1);
                *err = ep_strdup(es->str);
        }
 
@@ -3355,7 +3370,7 @@ void proto_register_snmp(void) {
 
 
 /*--- Included file: packet-snmp-hfarr.c ---*/
-#line 1 "packet-snmp-hfarr.c"
+#line 1 "../../asn1/snmp/packet-snmp-hfarr.c"
     { &hf_snmp_SMUX_PDUs_PDU,
       { "SMUX-PDUs", "snmp.SMUX_PDUs",
         FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals), 0,
@@ -3488,8 +3503,8 @@ void proto_register_snmp(void) {
       { "informRequest", "snmp.informRequest",
         FT_NONE, BASE_NONE, NULL, 0,
         "InformRequest_PDU", HFILL }},
-    { &hf_snmp_sNMPv2_Trap,
-      { "sNMPv2-Trap", "snmp.sNMPv2_Trap",
+    { &hf_snmp_snmpV2_trap,
+      { "snmpV2-trap", "snmp.snmpV2_trap",
         FT_NONE, BASE_NONE, NULL, 0,
         "SNMPv2_Trap_PDU", HFILL }},
     { &hf_snmp_report,
@@ -3618,7 +3633,7 @@ void proto_register_snmp(void) {
         NULL, HFILL }},
 
 /*--- End of included file: packet-snmp-hfarr.c ---*/
-#line 2133 "packet-snmp-template.c"
+#line 2148 "../../asn1/snmp/packet-snmp-template.c"
   };
 
   /* List of subtrees */
@@ -3636,7 +3651,7 @@ void proto_register_snmp(void) {
          &ett_decoding_error,
 
 /*--- Included file: packet-snmp-ettarr.c ---*/
-#line 1 "packet-snmp-ettarr.c"
+#line 1 "../../asn1/snmp/packet-snmp-ettarr.c"
     &ett_snmp_Message,
     &ett_snmp_Messagev2u,
     &ett_snmp_T_datav2u,
@@ -3658,7 +3673,7 @@ void proto_register_snmp(void) {
     &ett_snmp_RReqPDU_U,
 
 /*--- End of included file: packet-snmp-ettarr.c ---*/
-#line 2149 "packet-snmp-template.c"
+#line 2164 "../../asn1/snmp/packet-snmp-template.c"
   };
   module_t *snmp_module;