Convert asn1 template files proto_tree_add_item() 'encoding' arg for field types...
[obnox/wireshark/wip.git] / asn1 / snmp / packet-snmp-template.c
index f92a614ba119d4e3f863d6f5197220a0836d6632..d4ab5e99a0cdb6cd367e45354286fc0b15ae7013 100644 (file)
@@ -449,7 +449,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");
@@ -467,7 +467,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 */
@@ -521,7 +521,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;
@@ -538,7 +538,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");
@@ -562,7 +562,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;
                                }
 
@@ -588,7 +588,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--;
@@ -729,7 +729,7 @@ 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);
+                       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;
@@ -749,7 +749,7 @@ indexing_done:
                        }
 
                        if (format_error == BER_NO_ERROR)
-                               pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,FALSE);
+                               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)) {
@@ -825,7 +825,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");
                }
@@ -949,7 +949,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;
@@ -989,7 +989,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;
        }
@@ -997,7 +997,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;
        }
@@ -1005,13 +1005,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;
        }
@@ -1019,7 +1019,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;
        }
@@ -1030,7 +1030,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;
@@ -1046,7 +1046,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;
        }
@@ -1630,7 +1630,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);
        }
 
@@ -1711,7 +1711,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;
        }
@@ -1781,7 +1781,7 @@ 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);
        }
 
@@ -1962,7 +1962,7 @@ snmp_users_update_cb(void* p _U_, const char** err)
                snmp_ue_assoc_t* u = &(ueas[i]);
 
                /* RFC 3411 section 5 */
-               if (u->engine.len < 5 || u->engine.len > 32) {
+               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);
                }