summaryrefslogtreecommitdiff
path: root/asn1
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2009-11-01 18:45:43 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2009-11-01 18:45:43 +0000
commit5c625026446e3c08b2dafdffe5c900c06de9999c (patch)
treeec7a6aa94d5c00127cf06a92c00e4650e67f3b01 /asn1
parent72e8e8dbee327966b181a497db61ba83008465a3 (diff)
downloadwireshark-5c625026446e3c08b2dafdffe5c900c06de9999c.tar.gz
Added a UAT table to describe enterprise specific-trap types.
svn path=/trunk/; revision=30796
Diffstat (limited to 'asn1')
-rw-r--r--asn1/snmp/packet-snmp-template.c101
-rw-r--r--asn1/snmp/snmp.cnf48
2 files changed, 120 insertions, 29 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c
index 520ac0d426..13d164dcaa 100644
--- a/asn1/snmp/packet-snmp-template.c
+++ b/asn1/snmp/packet-snmp-template.c
@@ -143,11 +143,20 @@ static snmp_usm_decoder_t priv_protos[] = {snmp_usm_priv_des, snmp_usm_priv_aes}
static snmp_ue_assoc_t* ueas = NULL;
static guint num_ueas = 0;
-static uat_t* assocs_uat = NULL;
static snmp_ue_assoc_t* localized_ues = NULL;
static snmp_ue_assoc_t* unlocalized_ues = NULL;
/****/
+/* Variabled used for handling enterprise spesific trap types */
+typedef struct _snmp_st_assoc_t {
+ char *enterprise;
+ guint trap;
+ char *desc;
+} snmp_st_assoc_t;
+static guint num_specific_traps = 0;
+static snmp_st_assoc_t *specific_traps = NULL;
+static char *enterprise_oid = NULL;
+static guint generic_trap = 0;
static snmp_usm_params_t usm_p = {FALSE,FALSE,0,0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,FALSE};
@@ -285,6 +294,26 @@ static const value_string smux_types[] = {
dissector_table_t value_sub_dissectors_table;
+
+static const gchar *
+snmp_lookup_specific_trap (guint specific_trap)
+{
+ guint8 *enterprise = NULL;
+ guint i;
+
+ for (i = 0; i < num_specific_traps; i++) {
+ snmp_st_assoc_t *u = &(specific_traps[i]);
+
+ if ((u->trap == specific_trap) &&
+ (strcmp (u->enterprise, enterprise_oid) == 0))
+ {
+ return u->desc;
+ }
+ }
+
+ return NULL;
+}
+
/*
* dissect_snmp_VarBind
* this routine dissects variable bindings, looking for the oid information in our oid reporsitory
@@ -820,7 +849,7 @@ set_label:
proto_item_set_text(pi_varbind,"%s: %s",repr,valstr);
- if (display_oid && info_oid && check_col(actx->pinfo->cinfo, COL_INFO)) {
+ if (display_oid && info_oid) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", info_oid);
}
@@ -1538,10 +1567,8 @@ dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
next_tvb_init(&var_list);
- if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
- col_set_str(pinfo->cinfo, COL_PROTOCOL,
- proto_get_protocol_short_name(find_protocol_by_id(proto)));
- }
+ col_set_str(pinfo->cinfo, COL_PROTOCOL,
+ proto_get_protocol_short_name(find_protocol_by_id(proto)));
if (tree) {
item = proto_tree_add_item(tree, proto, tvb, start_offset,
@@ -1876,6 +1903,32 @@ UAT_BUFFER_CB_DEF(snmp_users,engine_id,snmp_ue_assoc_t,engine.data,engine.len)
UAT_VS_DEF(snmp_users,auth_model,snmp_ue_assoc_t,0,"MD5")
UAT_VS_DEF(snmp_users,priv_proto,snmp_ue_assoc_t,0,"DES")
+static void *
+snmp_specific_trap_copy_cb(void *dest, const void *orig, unsigned len _U_)
+{
+ snmp_st_assoc_t *u = dest;
+ const snmp_st_assoc_t *o = orig;
+
+ u->enterprise = g_strdup(o->enterprise);
+ u->trap = o->trap;
+ u->desc = g_strdup(o->desc);
+
+ return dest;
+}
+
+static void
+snmp_specific_trap_free_cb(void *r)
+{
+ snmp_st_assoc_t *u = r;
+
+ g_free(u->enterprise);
+ g_free(u->desc);
+}
+
+UAT_CSTRING_CB_DEF(specific_traps, enterprise, snmp_st_assoc_t)
+UAT_DEC_CB_DEF(specific_traps, trap, snmp_st_assoc_t)
+UAT_CSTRING_CB_DEF(specific_traps, desc, snmp_st_assoc_t)
+
/*--- proto_register_snmp -------------------------------------------*/
void proto_register_snmp(void) {
/* List of fields */
@@ -1965,6 +2018,7 @@ void proto_register_snmp(void) {
#include "packet-snmp-ettarr.c"
};
module_t *snmp_module;
+
static uat_field_t users_fields[] = {
UAT_FLD_BUFFER(snmp_users,engine_id,"Engine ID","Engine-id for this entry (empty = any)"),
UAT_FLD_LSTRING(snmp_users,userName,"Username","The username"),
@@ -1975,7 +2029,7 @@ void proto_register_snmp(void) {
UAT_END_FIELDS
};
- assocs_uat = uat_new("SNMP Users",
+ uat_t *assocs_uat = uat_new("SNMP Users",
sizeof(snmp_ue_assoc_t),
"snmp_users",
TRUE,
@@ -1988,6 +2042,26 @@ void proto_register_snmp(void) {
snmp_users_free_cb,
users_fields);
+ static uat_field_t specific_traps_flds[] = {
+ UAT_FLD_CSTRING(specific_traps,enterprise,"Enterprise OID","Enterprise Object Identifier"),
+ UAT_FLD_DEC(specific_traps,trap,"Trap Id","The specific-trap value"),
+ UAT_FLD_CSTRING(specific_traps,desc,"Description","Trap type description"),
+ UAT_END_FIELDS
+ };
+
+ uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types",
+ sizeof(snmp_st_assoc_t),
+ "snmp_specific_traps",
+ TRUE,
+ (void**) &specific_traps,
+ &num_specific_traps,
+ UAT_CAT_GENERAL,
+ "ChSNMPEnterpriseSpecificTrapTypes",
+ snmp_specific_trap_copy_cb,
+ NULL,
+ snmp_specific_trap_free_cb,
+ specific_traps_flds);
+
/* Register protocol */
proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
new_register_dissector("snmp", dissect_snmp, proto_snmp);
@@ -2019,9 +2093,14 @@ void proto_register_snmp(void) {
&snmp_var_in_tree);
prefs_register_uat_preference(snmp_module, "users_table",
- "Users Table",
- "Table of engine-user associations used for authentication and decryption",
- assocs_uat);
+ "Users Table",
+ "Table of engine-user associations used for authentication and decryption",
+ assocs_uat);
+
+ prefs_register_uat_preference(snmp_module, "specific_traps_table",
+ "Enterprise Specific Trap Types",
+ "Table of enterprise specific-trap type descriptions",
+ specific_traps_uat);
#ifdef HAVE_LIBSMI
prefs_register_static_text_preference(snmp_module, "info_mibs",
@@ -2055,7 +2134,7 @@ void proto_reg_handoff_snmp(void) {
data_handle = find_dissector("data");
- register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp);
+ register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);
/*
* Process preference settings.
diff --git a/asn1/snmp/snmp.cnf b/asn1/snmp/snmp.cnf
index ce692d917c..5cdcdc16b4 100644
--- a/asn1/snmp/snmp.cnf
+++ b/asn1/snmp/snmp.cnf
@@ -24,32 +24,47 @@ BulkPDU/request-id bulkPDU_request-id
#.FN_BODY PDUs
gint pdu_type=-1;
- if (check_col(actx->pinfo->cinfo, COL_INFO))
- col_clear(actx->pinfo->cinfo, COL_INFO);
+ col_clear(actx->pinfo->cinfo, COL_INFO);
%(DEFAULT_BODY)s
if( (pdu_type!=-1) && snmp_PDUs_vals[pdu_type].strptr ){
- if (check_col(actx->pinfo->cinfo, COL_INFO))
- col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%%s", snmp_PDUs_vals[pdu_type].strptr);
+ col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%%s", snmp_PDUs_vals[pdu_type].strptr);
}
#.END
+#.FN_BODY Trap-PDU/_untag
+ generic_trap = 0;
+ enterprise_oid = NULL;
-#.FN_PARS EnterpriseOID
+%(DEFAULT_BODY)s
+
+#.FN_PARS Trap-PDU/_untag/generic-trap VAL_PTR = &generic_trap
+
+#.FN_BODY Trap-PDU/_untag/specific-trap VAL_PTR = &specific_trap
+ guint specific_trap;
+
+%(DEFAULT_BODY)s
+
+ if (generic_trap == 6) { /* enterprise specific */
+ const gchar *specific_str = snmp_lookup_specific_trap (specific_trap);
+ if (specific_str) {
+ proto_item_append_text(actx->created_item, " (%%s)", specific_str);
+ }
+ }
+#.END
- VAL_PTR = &param_tvb
+
+#.FN_PARS EnterpriseOID FN_VARIANT = _str VAL_PTR = &enterprise_oid
#.FN_BODY EnterpriseOID
- tvbuff_t* param_tvb = NULL;
const gchar* name;
- gint len;
%(DEFAULT_BODY)s
- if (display_oid && param_tvb) {
- len = tvb_length_remaining (param_tvb, 0);
- name = oid_resolved_from_encoded(tvb_get_ptr(param_tvb, 0, len), len);
- if (name && check_col(actx->pinfo->cinfo, COL_INFO)) {
+
+ if (display_oid && enterprise_oid) {
+ name = oid_resolved_from_string(enterprise_oid);
+ if (name) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %%s", name);
}
}
@@ -118,8 +133,7 @@ gint pdu_type=-1;
expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN,
"Failed to decrypt encryptedPDU: %%s", error);
- if (check_col(actx->pinfo->cinfo, COL_INFO))
- col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");
+ col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");
return offset;
} else {
@@ -133,8 +147,7 @@ gint pdu_type=-1;
expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN,
"Decrypted data not formatted as expected");
- if (check_col(actx->pinfo->cinfo, COL_INFO))
- col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
+ col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
return offset;
}
@@ -147,8 +160,7 @@ gint pdu_type=-1;
dissect_snmp_ScopedPDU(FALSE, cleartext_tvb, 0, actx, decrypted_tree, -1);
}
} else {
- if (check_col(actx->pinfo->cinfo, COL_INFO))
- col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");
+ col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");
}
#.FN_BODY SNMPv3Message/msgSecurityParameters