static gboolean dissect_mms_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { /* must check that this really is an mms packet */ int offset = 0; guint32 length = 0 ; guint32 oct; gint idx = 0 ; gint8 tmp_class; gboolean tmp_pc; gint32 tmp_tag; /* first, check do we have at least 2 bytes (pdu) */ if (!tvb_bytes_exist(tvb, 0, 2)) return FALSE; /* no */ /* can we recognize MMS PDU ? Return FALSE if not */ /* get MMS PDU type */ offset = get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag); /* check MMS type */ /* Class should be constructed */ if (tmp_class!=BER_CLASS_CON) return FALSE; /* see if the tag is a valid MMS PDU */ match_strval_idx(tmp_tag, mms_MMSpdu_vals, &idx); if (idx == -1) { return FALSE; /* no, it isn't an MMS PDU */ } /* check MMS length */ oct = tvb_get_guint8(tvb, offset)& 0x7F; if (oct==0) /* MMS requires length after tag so not MMS if indefinite length*/ return FALSE; offset = get_ber_length(tvb, offset, &length, NULL); /* do we have enough bytes? */ if (!tvb_bytes_exist(tvb, offset, length)) return FALSE; dissect_mms(tvb, pinfo, parent_tree); return TRUE; }
/* Like match_strval_idx(), but doesn't return the index. */ const gchar* match_strval(guint32 val, const value_string *vs) { gint ignore_me; return match_strval_idx(val, vs, &ignore_me); }