static int dissect_object_id(tvbuff_t *tvb, proto_tree *tree, int offset, guint8 flags, enum OID_USAGE oid_usage) { guint8 n_subid; guint8 prefix; guint8 include; proto_item* item; proto_tree* subtree; guint32 oid[2048]; char str_oid[2048]; int i; memset(oid, '\0', sizeof(oid)); memset(str_oid, '\0', sizeof(str_oid)); n_subid = tvb_get_guint8(tvb, offset); prefix = tvb_get_guint8(tvb, offset + 1); include = tvb_get_guint8(tvb, offset + 2); tvb_get_guint8(tvb, offset + 3); for(i=0; i<n_subid; i++) { NORLEL(flags, oid[i], tvb, (offset+4) + (i*4)); } if(!convert_oid_to_str(&oid[0], n_subid, &str_oid[0], 2048, prefix)) g_snprintf(&str_oid[0], 2048, "(null)"); if(tree) { const char *range = ""; const char *inclusion = (include) ? " (Inclusive)" : " (Exclusive)"; switch (oid_usage) { case OID_START_RANGE: range = "(Range Start) "; break; case OID_END_RANGE: range = " (Range End) "; break; default: inclusion = ""; break; } item = proto_tree_add_text(tree, tvb, offset, 4 + (n_subid * 4) , "Object Identifier: %s%s%s", range, str_oid, inclusion); subtree = proto_item_add_subtree(item, ett_obj_ident); } else return offset; proto_tree_add_uint(subtree, hf_oid_sub, tvb, offset, 1, n_subid); proto_tree_add_uint(subtree, hf_oid_prefix, tvb, offset + 1, 1, prefix); proto_tree_add_boolean(subtree, hf_oid_include, tvb, offset + 2, 1, include); proto_tree_add_string(subtree, hf_oid_str, tvb, offset + 4, (n_subid * 4), str_oid); return 4 + (n_subid * 4); }
static int dissect_octet_string(tvbuff_t *tvb, proto_tree *tree, int offset, char flags) { guint32 n_oct, p_noct; char context[1024]; NORLEL(flags, n_oct, tvb, offset); p_noct = PADDING(n_oct); if (n_oct >= 1024) THROW(ReportedBoundsError); tvb_get_nstringz(tvb, offset + 4, n_oct, context); context[n_oct]='\0'; proto_tree_add_uint(tree,hf_ostring_len,tvb,offset,4,n_oct); proto_tree_add_string(tree, hf_ostring, tvb, offset + 4, n_oct, context); return p_noct + 4; }
static int dissect_octet_string(tvbuff_t *tvb, proto_tree *tree, int offset, guint8 flags) { guint32 n_oct, p_noct; NORLEL(flags, n_oct, tvb, offset); p_noct = PADDING(n_oct); proto_tree_add_uint(tree, hf_ostring_len, tvb, offset, 4, n_oct); /* * XXX - an "octet string" is not necessarily a text string, so * having hf_ostring be FT_STRING is not necessarily appropriate. */ proto_tree_add_item(tree, hf_ostring, tvb, offset + 4, n_oct, ENC_ASCII|ENC_NA); return p_noct + 4; }
static void dissect_response_pdu(tvbuff_t *tvb, proto_tree *tree, int offset, int len, guint8 flags) { proto_tree* subtree; guint encoding = (flags & NETWORK_BYTE_ORDER) ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN; guint32 r_uptime; subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_response, NULL, "Response-PDU"); NORLEL(flags, r_uptime, tvb, offset); proto_tree_add_uint_format(subtree, hf_resp_uptime, tvb, offset, 4, r_uptime, "sysUptime: %s", time_msecs_to_str(wmem_packet_scope(), r_uptime)); proto_tree_add_item(subtree, hf_resp_error, tvb, offset + 4, 2, encoding); proto_tree_add_item(subtree, hf_resp_index, tvb, offset + 6, 2, encoding); offset += 8; len += PDU_HDR_LEN; while(len > offset) { offset += dissect_varbind(tvb, subtree, offset, len, flags); } }
static int dissect_object_id(tvbuff_t *tvb, proto_tree *tree, int offset, char flags) { guint8 n_subid; guint8 prefix; guint8 include; proto_item* item; proto_tree* subtree; guint32 oid[2048]; char str_oid[2048]; int i, slen; memset(oid, '\0', sizeof(oid)); memset(str_oid, '\0', sizeof(str_oid)); n_subid = tvb_get_guint8(tvb, offset); prefix = tvb_get_guint8(tvb, offset + 1); include = tvb_get_guint8(tvb,offset + 2); tvb_get_guint8(tvb, offset + 3); for(i=0; i<n_subid; i++) { NORLEL(flags, oid[i], tvb, (offset+4) + (i*4)); } if(!(slen = convert_oid_to_str(&oid[0], n_subid, &str_oid[0], 2048, prefix))) return offset; if(tree) { item = proto_tree_add_text(tree,tvb,offset,n_subid + 4 , "Object Identifier: (%s) %s",(include) ? "Start" : "End" , str_oid); subtree = proto_item_add_subtree(item, ett_obj_ident); } else return offset; proto_tree_add_uint(subtree, hf_oid_sub, tvb, offset, 1, n_subid); proto_tree_add_uint(subtree, hf_oid_prefix, tvb, offset + 1, 1, prefix); proto_tree_add_uint(subtree, hf_oid_include, tvb, offset + 2, 1, include); proto_tree_add_string(subtree,hf_oid_str, tvb, offset + 4, slen, str_oid); return 4 + (n_subid * 4); }