* length of the result string.
*
* XXX - check for "sprint_realloc_objid()" failure.
+ * XXX - if we convert this to ep_alloc(), make sure the fourth
+ * argument to sprint_realloc_objid() is FALSE.
*/
oid_string_len = 256;
oid_string = malloc(oid_string_len);
return NULL;
*oid_string = '\0';
oid_out_len = 0;
- sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, 1,
+ sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, TRUE,
oid, oid_length);
result_len += strlen(oid_string) + 3;
#endif
/* returns the decoded (can be NULL) and non_decoded OID strings,
returned pointers shall be freed by the caller */
-void
-new_format_oid(subid_t *oid, guint oid_length,
+void
+new_format_oid(subid_t *oid, guint oid_length,
gchar **non_decoded, gchar **decoded)
{
int non_decoded_len;
* length of the result string.
*/
+ /*
+ * XXX - if we convert this to ep_alloc(), make sure the fourth
+ * argument to sprint_realloc_objid() is FALSE.
+ */
+
oid_string_len = 256;
oid_string = malloc(oid_string_len);
if (oid_string != NULL) {
*oid_string = '\0';
oid_out_len = 0;
- sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, 1,
+ sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, TRUE,
oid, oid_length);
}
*decoded = oid_string;
{ 0, NULL }
};
-/*
+/*
* SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)
* or historic RFC 1910 (AgentID)
*/
/* 4-byte enterprise number/name */
if (len_remain<4) return offset;
enterpriseid = tvb_get_ntohl(tvb, offset);
- if (conformance)
+ if (conformance)
enterpriseid -= 0x80000000; /* ignore first bit */
proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);
offset+=4;
case 128:
/* most common enterprise-specific format: (ucd|net)-snmp random */
if ((enterpriseid==2021)||(enterpriseid==8072)) {
- proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
+ 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);
seconds = tvb_get_letohl(tvb, offset+4);
ts.secs = seconds;
- proto_tree_add_time_format(tree, hf_snmp_engineid_time, tvb, offset+4, 4,
+ proto_tree_add_time_format(tree, hf_snmp_engineid_time, tvb, offset+4, 4,
&ts, "Engine ID Data: Creation Time: %s",
abs_time_secs_to_str(seconds));
offset+=8;
guint32 tmp_length;
gboolean tmp_ind;
- /*
- * See if this looks like SNMP or not. if not, return 0 so
+ /*
+ * See if this looks like SNMP or not. if not, return 0 so
* ethereal can try som other dissector instead.
*/
/* All SNMP packets are BER encoded and consist of a SEQUENCE
/* Register protocol */
proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
new_register_dissector("snmp", dissect_snmp, proto_snmp);
-
+
/* Register fields and subtrees */
proto_register_field_array(proto_snmp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
if (!variable->type)
variable->type=mib_to_asn_type(subtree->type);
- if (!sprint_realloc_by_type(&buf, &buf_len, &out_len, TRUE, variable, subtree->enums, subtree->hint, NULL))
+ if (!sprint_realloc_by_type(&buf, &buf_len, &out_len, FALSE, variable, subtree->enums, subtree->hint, NULL))
g_snprintf(buf,SPRINT_MAX_LEN,"%s","sprint_realloc_by_type failed");
return buf;
subid_t *vb_oid;
guint vb_oid_length;
+ proto_item *vb_pi;
gchar *vb_display_string;
gchar *vb_display_string2;
- size_t returned_length, str_index = 0;
#ifdef HAVE_NET_SNMP
struct variable_list variable;
* We stopped, due to a non-printable character, before we got
* to the end of the string.
*/
- vb_display_string = ep_alloc(4*vb_length);
- returned_length = g_snprintf(vb_display_string, 4*vb_length, "%03u",
- vb_octet_string[0]);
- str_index += MIN(returned_length, 4*vb_length);
+ vb_pi = proto_tree_add_text(tree, tvb, vb_value_start, length,
+ "Value: %s: ", vb_type_name);
+ proto_item_append_text(vb_pi, "%03u", vb_octet_string[0]);
for (i = 1; i < vb_length; i++) {
- returned_length = g_snprintf(&vb_display_string[str_index],
- 4*vb_length-str_index, ".%03u", vb_octet_string[i]);
- str_index += MIN(returned_length, 4*vb_length-str_index);
+ proto_item_append_text(vb_pi, ".%03u", vb_octet_string[0]);
}
- proto_tree_add_text(tree, tvb, vb_value_start, length,
- "Value: %s: %s", vb_type_name, vb_display_string);
} else {
proto_tree_add_text(tree, tvb, vb_value_start, length,
"Value: %s: %.*s", vb_type_name, (int)vb_length,
case COPS_OBJECTID:
/* XXX Redo this using dissect_ber_object_identifier when it returns tvb
- or some other binary form of an OID */
+ or some other binary form of an OID */
offset = start;
offset = dissect_ber_identifier(pinfo, tree, tvb, offset, &class, &pc, &ber_tag);
offset = dissect_ber_length(pinfo, tree, tvb, offset, &vb_length, &ind);
offset = offset + vb_length;
length = offset - vb_value_start;
-/* ret = asn1_oid_value_decode (&asn1, vb_length, &vb_oid, &vb_oid_length);
+/* ret = asn1_oid_value_decode (&asn1, vb_length, &vb_oid, &vb_oid_length);
if (ret != ASN1_ERR_NOERROR)
- return ret;
+ return ret;
length = asn1.offset - start;
*/
if (tree) {
{ 0, NULL }
};
-/*
+/*
* SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)
* or historic RFC 1910 (AgentID)
*/
/* 4-byte enterprise number/name */
if (len_remain<4) return offset;
enterpriseid = tvb_get_ntohl(tvb, offset);
- if (conformance)
+ if (conformance)
enterpriseid -= 0x80000000; /* ignore first bit */
proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);
offset+=4;
case 128:
/* most common enterprise-specific format: (ucd|net)-snmp random */
if ((enterpriseid==2021)||(enterpriseid==8072)) {
- proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
+ 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);
seconds = tvb_get_letohl(tvb, offset+4);
ts.secs = seconds;
- proto_tree_add_time_format(tree, hf_snmp_engineid_time, tvb, offset+4, 4,
+ proto_tree_add_time_format(tree, hf_snmp_engineid_time, tvb, offset+4, 4,
&ts, "Engine ID Data: Creation Time: %s",
abs_time_secs_to_str(seconds));
offset+=8;
* length of the result string.
*
* XXX - check for "sprint_realloc_objid()" failure.
+ * XXX - if we convert this to ep_alloc(), make sure the fourth
+ * argument to sprint_realloc_objid() is FALSE.
*/
oid_string_len = 256;
oid_string = malloc(oid_string_len);
return NULL;
*oid_string = '\0';
oid_out_len = 0;
- sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, 1,
+ sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, TRUE,
oid, oid_length);
result_len += strlen(oid_string) + 3;
#endif
/* returns the decoded (can be NULL) and non_decoded OID strings,
returned pointers shall be freed by the caller */
-void
-new_format_oid(subid_t *oid, guint oid_length,
+void
+new_format_oid(subid_t *oid, guint oid_length,
gchar **non_decoded, gchar **decoded)
{
int non_decoded_len;
* length of the result string.
*/
+ /*
+ * XXX - if we convert this to ep_alloc(), make sure the fourth
+ * argument to sprint_realloc_objid() is FALSE.
+ */
+
oid_string_len = 256;
oid_string = malloc(oid_string_len);
if (oid_string != NULL) {
*oid_string = '\0';
oid_out_len = 0;
- sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, 1,
+ sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, TRUE,
oid, oid_length);
}
*decoded = oid_string;
/*
* XXX - check for "sprint_realloc_objid()" failure.
*/
+
+ /*
+ * XXX - if we convert this to ep_alloc(), make sure the fourth
+ * argument to sprint_realloc_objid() is FALSE.
+ */
buf_len = 256;
buf = malloc(buf_len);
if (buf != NULL) {
*buf = '\0';
out_len = 0;
- sprint_realloc_value(&buf, &buf_len, &out_len, 1,
+ sprint_realloc_value(&buf, &buf_len, &out_len, TRUE,
variable_oid, variable_oid_length, variable);
}
return buf;
case SNMP_OBJECTID:
/* XXX Redo this using dissect_ber_object_identifier when
- it returns tvb or some other binary form of an OID */
+ it returns tvb or some other binary form of an OID */
oid_buf = tvb_get_ptr(asn1->tvb, vb_value_start, vb_length);
vb_oid = g_malloc((vb_length+1) * sizeof(gulong));
vb_oid_length = oid_to_subid_buf(oid_buf, vb_length, vb_oid, ((vb_length+1) * sizeof(gulong)));
proto_tree_add_text(tree, tvb, offset,
length, "Non-repeaters: %u", error_status);
} else {
- proto_tree_add_uint(tree,
+ proto_tree_add_uint(tree,
hf_snmp_error_status,
tvb, offset,
length, error_status);
new_format_oid(variable_oid, variable_oid_length,
&non_decoded_oid, &decoded_oid);
-
+
if (display_oid && check_col(pinfo->cinfo, COL_INFO)) {
- col_append_fstr(pinfo->cinfo, COL_INFO,
- " %s",
+ col_append_fstr(pinfo->cinfo, COL_INFO,
+ " %s",
(decoded_oid == NULL) ? non_decoded_oid :
decoded_oid);
}
-
+
if (tree) {
if (decoded_oid) {
proto_tree_add_string_format(tree, hf_snmp_oid,
- tvb, offset,
- sequence_length,
+ tvb, offset,
+ sequence_length,
decoded_oid,
- "Object identifier %d: %s (%s)",
- vb_index,
+ "Object identifier %d: %s (%s)",
+ vb_index,
non_decoded_oid,
decoded_oid);
/* add also the non decoded oid string */
proto_tree_add_string_hidden(tree, hf_snmp_oid,
- tvb, offset,
+ tvb, offset,
sequence_length,
non_decoded_oid);
} else {
proto_tree_add_string_format(tree, hf_snmp_oid,
- tvb, offset,
- sequence_length,
+ tvb, offset,
+ sequence_length,
non_decoded_oid,
- "Object identifier %d: %s",
- vb_index,
+ "Object identifier %d: %s",
+ vb_index,
non_decoded_oid);
}
}
guint32 tmp_length;
gboolean tmp_ind;
- /*
- * See if this looks like SNMP or not. if not, return 0 so
+ /*
+ * See if this looks like SNMP or not. if not, return 0 so
* ethereal can try som other dissector instead.
*/
/* All SNMP packets are BER encoded and consist of a SEQUENCE
unsigned int amount_free;
unsigned int free_offset;
char *buf;
+#if ! defined(EP_DEBUG_FREE) && ! defined(SE_DEBUG_FREE)
unsigned int c_count;
void *canary[EMEM_ALLOCS_PER_CHUNK];
guint8 cmp_len[EMEM_ALLOCS_PER_CHUNK];
+#endif
} emem_chunk_t;
typedef struct _emem_header_t {