7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/asn1.h>
37 #include "packet-ber.h"
38 #include "packet-acse.h"
39 #include "packet-mms.h"
45 /* Initialize the protocol and registered fields */
48 #include "packet-mms-hf.c"
50 /* Initialize the subtree pointers */
51 static gint ett_mms = -1;
52 #include "packet-mms-ett.c"
54 #include "packet-mms-fn.c"
57 * Dissect MMS PDUs inside a PPDU.
60 dissect_mms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
64 proto_item *item=NULL;
65 proto_tree *tree=NULL;
67 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
70 item = proto_tree_add_item(parent_tree, proto_mms, tvb, 0, -1, FALSE);
71 tree = proto_item_add_subtree(item, ett_mms);
73 if (check_col(pinfo->cinfo, COL_PROTOCOL))
74 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MMS");
75 if (check_col(pinfo->cinfo, COL_INFO))
76 col_clear(pinfo->cinfo, COL_INFO);
78 while (tvb_reported_length_remaining(tvb, offset) > 0){
80 offset=dissect_mms_MMSpdu(FALSE, tvb, offset, &asn1_ctx , tree, -1);
81 if(offset == old_offset){
82 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte MMS PDU");
83 offset = tvb_length(tvb);
90 /*--- proto_register_mms -------------------------------------------*/
91 void proto_register_mms(void) {
94 static hf_register_info hf[] =
96 #include "packet-mms-hfarr.c"
99 /* List of subtrees */
100 static gint *ett[] = {
102 #include "packet-mms-ettarr.c"
105 /* Register protocol */
106 proto_mms = proto_register_protocol(PNAME, PSNAME, PFNAME);
107 register_dissector("mms", dissect_mms, proto_mms);
108 /* Register fields and subtrees */
109 proto_register_field_array(proto_mms, hf, array_length(hf));
110 proto_register_subtree_array(ett, array_length(ett));
116 dissect_mms_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
118 /* must check that this really is an mms packet */
128 /* first, check do we have at least 2 bytes (pdu) */
129 if (!tvb_bytes_exist(tvb, 0, 2))
130 return FALSE; /* no */
132 /* can we recognize MMS PDU ? Return FALSE if not */
133 /* get MMS PDU type */
134 offset = get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
138 /* Class should be constructed */
139 if (tmp_class!=BER_CLASS_CON)
142 /* see if the tag is a valid MMS PDU */
143 match_strval_idx(tmp_tag, mms_MMSpdu_vals, &idx);
145 return FALSE; /* no, it isn't an MMS PDU */
148 /* check MMS length */
149 oct = tvb_get_guint8(tvb, offset)& 0x7F;
151 /* MMS requires length after tag so not MMS if indefinite length*/
154 offset = get_ber_length(tvb, offset, &length, NULL);
155 /* do we have enough bytes? */
156 if (!tvb_bytes_exist(tvb, offset, length))
159 dissect_mms(tvb, pinfo, parent_tree);
163 /*--- proto_reg_handoff_mms --- */
164 void proto_reg_handoff_mms(void) {
165 register_ber_oid_dissector("1.0.9506.2.3", dissect_mms, proto_mms,"MMS");
166 register_ber_oid_dissector("1.0.9506.2.1", dissect_mms, proto_mms,"mms-abstract-syntax-version1(1)");
167 heur_dissector_add("cotp", dissect_mms_heur, proto_mms);
168 heur_dissector_add("cotp_is", dissect_mms_heur, proto_mms);