Wireshark-bugs: [Wireshark-bugs] [Bug 5881] Media Independent handover (MIH) protocol dissector

Date: Wed, 22 Jun 2011 04:57:19 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5881

--- Comment #7 from Ankith <ankitha@xxxxxxx> 2011-06-22 04:57:17 PDT ---
(From update of attachment 6270)
>diff -N -r -u --strip-trailing-cr ./wireshark/epan/dissectors/Makefile.common ./wireshark_mine/epan/dissectors/Makefile.common
>--- ./wireshark/epan/dissectors/Makefile.common	2011-05-02 10:27:59.332337979 +0530
>+++ ./wireshark_mine/epan/dissectors/Makefile.common	2011-05-02 10:31:43.495294504 +0530
>@@ -667,6 +667,7 @@
> 	packet-mesh.c		\
> 	packet-meta.c		\
> 	packet-mgcp.c		\
>+	packet-mih.c		\
> 	packet-mikey.c		\
> 	packet-miop.c		\
> 	packet-mip.c		\
>diff -N -r -u --strip-trailing-cr ./wireshark/epan/dissectors/packet-mih.c ./wireshark_mine/epan/dissectors/packet-mih.c
>--- ./wireshark/epan/dissectors/packet-mih.c	1970-01-01 05:30:00.000000000 +0530
>+++ ./wireshark_mine/epan/dissectors/packet-mih.c	2011-05-02 10:52:51.752883217 +0530
>@@ -0,0 +1,614 @@
>+/* packet-mih.c
>+ * Routines for the Media Independent Handover (MIH) Protocol dissection.
>+ * IEEE 802.21
>+ *
>+ *
>+ * Copyright 2010, Ankith Agarwal <ankitha@xxxxxxx>
>+ *
>+ * Wireshark - Network traffic analyzer
>+ * By Gerald Combs <gerald@xxxxxxxxxxxxx>
>+ * Copyright 1998 Gerald Combs
>+ *
>+ *
>+ * This program is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU General Public License
>+ * as published by the Free Software Foundation; either version 2
>+ * of the License, or (at your option) any later version.
>+ *
>+ * This program is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>+ * GNU General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU General Public License
>+ * along with this program; if not, write to the Free Software
>+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
>+ */
>+
>+
>+
>+#ifdef HAVE_CONFIG_H
>+# include "config.h"
>+#endif
>+
>+#include <epan/packet.h>
>+#include <epan/prefs.h>
>+#include <epan/reassemble.h>
>+#include <glib.h>
>+#define MIH_PORT 4551 
>+
>+
>+#define VERSION_MASK	0xF0
>+#define ACKREQ_MASK	0x8
>+#define ACKRESP_MASK	0x4
>+#define UIR_MASK	0x2
>+#define MORE_FRAG_MASK	0x1
>+#define FRAG_NO_MASK	0xFE
>+#define SID_MASK	0xF000
>+#define OPCODE_MASK	0xC00
>+#define AID_MASK	0x3FF
>+#define TRANS_ID_MASK	0x0FFF
>+
>+/*information holder integers...*/
>+static int proto_mih = -1;
>+static int hf_mih_version = -1;
>+static int hf_mih_ack_req = -1;
>+static int hf_mih_ack_resp = -1;
>+static int hf_mih_uir = -1;
>+static int hf_mih_more_frag = -1;
>+static int hf_mih_frag_no = -1;
>+static int hf_mih_mid = -1;
>+static int hf_mih_service_id = -1;
>+static int hf_mih_opcode = -1;
>+static int hf_mih_serv_actionid = -1;
>+static int hf_mih_event_actionid = -1;
>+static int hf_mih_command_actionid = -1;
>+static int hf_mih_info_actionid = -1;
>+static int hf_mih_tid = -1;
>+static int hf_mih_pay_len = -1;
>+static int hf_mih_type = -1;
>+static int hf_mih_type_length = -1;
>+static int hf_mih_value = -1;
>+
>+/*trees and subtrees...*/
>+
>+static gint ett_mih = -1;
>+static gint ett_ver_flags = -1;
>+static gint ett_mid = -1;
>+static gint ett_tlv[20] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
>+
>+static const value_string servicevalues[] = {
>+{1, "Service Management"},
>+{2, "Event Service"},
>+{3, "Command Service"},
>+{4, "Information Service"},
>+{0, NULL}
>+};
>+
>+
>+static const value_string opcodevalues[] = {
>+{0, "Confirm"},
>+{1, "Request"},
>+{2, "Response"},
>+{3, "Indication"},
>+{0, NULL},
>+};
>+
>+
>+static const value_string serv_act_id_values[] = {
>+{1, "MIH_Capability_Detected"},
>+{2, "MIH_Register"},
>+{3, "MIH_DeRegister"},
>+{4, "MIH_Event_SUbscribe"},
>+{5, "MIH_Event_Unsubscribe"},
>+{0, NULL}
>+};
>+
>+
>+static const value_string event_act_id_values[] = {
>+{1, "MIH_Link_Detected"},
>+{2, "MIH_Link_UP"},
>+{3, "MIH_Link_Down"},
>+{5, "MIH_Link_Parameter_Report"},
>+{6, "MIH_Link_Going_down"},
>+{7, "MIH_Link_Handover_Imminent"},
>+{8, "MIH_Handover_Complete"},
>+{0, NULL}
>+};
>+
>+
>+static const value_string command_act_id_values[] = {
>+{1, "MIH_Link_Get_Parameters"},
>+{2, "MIH_Link_Configure_Thresholds"},
>+{3, "MIH_Link_Actions"},
>+{4, "MIH_Net_HO_Candidate_Query"},
>+{5, "MIH_MN_HO_Candidate_Query"},
>+{6, "MIH_N2N_HO_Query_Resources"},
>+{7, "MIH_MN_HO_Commit"},
>+{8, "MIH_Net_HO-Commit"},
>+{9, "MN_N2N_HO_Commit"},
>+{10, "MIH_MN_HO_Complete"},
>+{11, "MIH_N2N_HO_Complete"},
>+{0, NULL}
>+};
>+
>+
>+static const value_string info_act_id_values[] = {
>+{1, "MIH_Get_Information"},
>+{2, "MIH_Push_information"},
>+{0, NULL}
>+};
>+
>+
>+static const value_string typevaluenames[] = {
>+{ 1, "Source MIHIF ID" },
>+{ 2, "Destination MIHIF ID" },
>+{ 3, "Status" },
>+{ 4, "Link type" },
>+{ 5, "MIH event list" },
>+{ 6, "MIH command list" },
>+{ 7, "MIIS query type list" },
>+{ 8, "Transport option list" },
>+{ 9, "Link address list" },
>+{ 10, "MBB handover support" },
>+{ 11, "Register request code" },
>+{ 12, "Valid time interval" },
>+{ 13, "Link identifier" },
>+{ 14, "New Link identifier" },
>+{ 15, "Old access router" },
>+{ 16, "New access  router" },
>+{ 17, "IP renewal flag" },
>+{ 18, "Mobility management support" },
>+{ 19, "IP address configuration methods" },
>+{ 20, "Link down reason code" },
>+{ 21, "Time interval" },
>+{ 22, "Link going down reason" },
>+{ 23, "Link parameter report list" },
>+{ 24, "Device states request" },
>+{ 25, "Link identifier list" },
>+{ 26, "Device states response list" },
>+{ 27, "Get status request set" },
>+{ 28, "Get status response list" },
>+{ 29, "Configure request list" },
>+{ 30, "Configure response list" },
>+{ 31, "List of link PoA list" },
>+{ 32, "Preferred link list" },
>+{ 33, "Handover resource query list" },
>+{ 34, "Handover status" },
>+{ 35, "Access router address" },
>+{ 36, "DHCP server address" },
>+{ 37, "FA address" },
>+{ 38, "Link actions list" },
>+{ 39, "Link actions result list" },
>+{ 40, "Handover result" },
>+{ 41, "Resource status" },
>+{ 42, "Resource retention status" },
>+{ 43, "Info query binary data list" },
>+{ 44, "Info query RDF data list" },
>+{ 45, "Info query RDF schema URL" },
>+{ 46, "Info query RDF schema list" },
>+{ 47, "Max response size" },
>+{ 48, "Info response binary data list" },
>+{ 49, "Info response RDF data list" },
>+{ 50, "Info response RDF schema URL list" },
>+{ 51, "Info response RDF schema list" },
>+{ 52, "Mobile node MIHF ID" },
>+{ 53, "Query resource report flag" },
>+{ 54, "Event configuration info list" },
>+{ 55, "Target network info" },
>+{ 56, "List of target network info" },
>+{ 57, "Assigned resource set" },
>+{ 58, "Link detected info list" },
>+{ 59, "MN link ID" },
>+{ 60, "PoA" },
>+{ 61, "Unauthenticated information request" },
>+{ 62, "Network type" },
>+{ 63, "Requested resource set" },
>+{0, NULL}
>+};
>+
>+
>+static void dissect_mih(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
>+{	
>+	proto_item *ti = NULL;
>+	gint16 offset = 0;
>+	proto_item *item = NULL;
>+        proto_tree *mih_tree = NULL;
>+	proto_tree *ver_flags_tree = NULL;
>+	gint8 service = 0;
>+	gint16 payload_length = 0;
>+	gint8 i = 0;
>+	gint16 len = 0;
>+	gint16 len_of_len = 0;
>+        proto_tree *mid_tree = NULL;
>+	proto_tree *tlv_tree = NULL;
>+	col_set_str(pinfo->cinfo, COL_PROTOCOL, "MIH");
>+    	col_clear(pinfo->cinfo,COL_INFO);
>+	/*for adding a subtree to the dissector...*/
>+
>+	if (tree) 
>+	{ 	
>+		/* we are being asked for details */
>+
>+		ti = proto_tree_add_item(tree, proto_mih, tvb, 0, -1, FALSE);
>+		offset = 0;
>+		/*we are taking form 0 to -1 that is from start to end of the protocol..
>+		assuming that there is no encapsulation of another proto inside this...*/
>+/*//////////////////////////////////////////////////////////////////////////////////////////////////\/\**/
>+		mih_tree = proto_item_add_subtree(ti, ett_mih);
>+
>+		item = proto_tree_add_item(mih_tree, hf_mih_version, tvb, offset, 1, FALSE);
>+
>+		ver_flags_tree = proto_item_add_subtree(item, ett_ver_flags);
>+		item = proto_tree_add_item(ver_flags_tree, hf_mih_version, tvb, offset, 1, FALSE);
>+		
>+		item = proto_tree_add_item(ver_flags_tree, hf_mih_ack_req, tvb, offset, 1, FALSE);
>+		
>+		item = proto_tree_add_item(ver_flags_tree, hf_mih_ack_resp, tvb, offset, 1, FALSE);
>+		
>+		item = proto_tree_add_item(ver_flags_tree, hf_mih_uir, tvb, offset, 1, FALSE);
>+		
>+		item = proto_tree_add_item(ver_flags_tree, hf_mih_more_frag, tvb, offset, 1, FALSE);
>+		offset += 1;
>+		
>+		/*flags and version tree is done.....*/
>+	
>+		proto_tree_add_item(mih_tree, hf_mih_frag_no, tvb, offset, 1, FALSE);
>+	
>+		offset += 1;
>+		
>+		
>+		/*for MIH message ID*/
>+		item = proto_tree_add_item(mih_tree, hf_mih_mid, tvb, offset, 2, FALSE);
>+                
>+                mid_tree = proto_item_add_subtree(item, ett_mid);
>+		item = proto_tree_add_item(mid_tree, hf_mih_service_id, tvb, offset, 2, FALSE);
>+
>+		item = proto_tree_add_item(mid_tree, hf_mih_opcode, tvb, offset, 2, FALSE);
>+
>+		/*check for type of service..*/
>+		service = tvb_get_guint8(tvb, offset);
>+		service = service & 0xF0;
>+		service >>= 4;
>+	
>+		if(service == 1)
>+			/*/for Service Management..*/
>+			item = proto_tree_add_item(mid_tree, hf_mih_serv_actionid, tvb, offset, 2, FALSE);
>+		if(service == 2)
>+			/*for Service Management..*/
>+			item = proto_tree_add_item(mid_tree, hf_mih_event_actionid, tvb, offset, 2, FALSE);
>+		if(service == 3)
>+			/*for Service Management..*/
>+			item = proto_tree_add_item(mid_tree, hf_mih_command_actionid, tvb, offset, 2, FALSE);
>+		if(service == 4)
>+			/*for Service Management..*/
>+			item = proto_tree_add_item(mid_tree, hf_mih_info_actionid, tvb, offset, 2, FALSE);
>+
>+		offset += 2;
>+
>+
>+                proto_tree_add_item(mih_tree, hf_mih_tid, tvb, offset, 2, FALSE );
>+	
>+		offset += 2;
>+                
>+		proto_tree_add_item(mih_tree, hf_mih_pay_len, tvb, offset, 2, FALSE );
>+
>+		payload_length = tvb_get_ntohs(tvb, offset);
>+		offset += 2;
>+
>+		/*now the type length values list is present get them and decode it...
>+		loop for showing all the tlvs....*/
>+
>+		i = 0;
>+		while(payload_length >= 3)
>+		{
>+			/*for type...*/
>+			item = proto_tree_add_item(mih_tree, hf_mih_type, tvb, offset, 1, FALSE);
>+			tlv_tree = proto_item_add_subtree(item, ett_tlv[i]);
>+			
>+
>+
>+			proto_tree_add_item(tlv_tree, hf_mih_type, tvb, offset, 1, FALSE);
>+			offset += 1;
>+
>+			/*for length..*/
>+			proto_tree_add_item(tlv_tree, hf_mih_type_length, tvb, offset, 1, FALSE);
>+		
>+
>+			len = tvb_get_guint8(tvb , offset);
>+			offset += 1;
>+		
>+
>+			len_of_len = tvb_get_guint8(tvb, offset);
>+			proto_tree_add_item(tlv_tree, hf_mih_value, tvb, offset, len, FALSE);
>+		
>+			offset += len;
>+			payload_length -= (len + 2); 
>+			i++;
>+		}
>+	}
>+	
>+}
>+
>+
>+
>+/*dissector initialistaion*/
>+void proto_register_mih(void)
>+{
>+	static hf_register_info hf[] = 
>+	{
>+		{
>+			&hf_mih_version,
>+			{
>+				"MIH Version",
>+				"mih.version",
>+				FT_UINT8,
>+				BASE_DEC,
>+				NULL,
>+				VERSION_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_ack_req,
>+			{
>+				"MIH ACK-Req",
>+				"mih.acq_req",
>+				FT_UINT8,
>+				BASE_HEX,
>+				NULL,
>+				ACKREQ_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_ack_resp,
>+			{
>+				"MIH ACK-Resp",
>+				"mih.acq_resp",
>+				FT_UINT8,
>+				BASE_HEX,
>+				NULL,
>+				ACKRESP_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_uir,
>+			{
>+				"MIH Unauthenticated info request",
>+				"mih.uir",
>+				FT_UINT8,
>+				BASE_HEX,
>+				NULL,
>+				UIR_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_more_frag,
>+			{
>+				"MIH more fragment",
>+				"mih.more_frag",
>+				FT_UINT8,
>+				BASE_HEX,
>+				NULL,
>+				MORE_FRAG_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		/*{
>+			&hf_mih_pdu_type,
>+			{ 
>+				"MIH Version",
>+				"mih.version", 
>+				FT_UINT8, 
>+				BASE_DEC, 
>+				NULL, 
>+				0x0, 
>+				NULL, HFILL 
>+			}
>+		},*/
>+		{
>+			&hf_mih_frag_no,
>+			{
>+				"Fragment No:",
>+				"mih.frag_no",
>+				FT_UINT8,
>+				BASE_DEC,
>+				NULL,
>+				FRAG_NO_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_mid,
>+			{
>+				"MIH message ID:",
>+				"mih.mid",
>+				FT_UINT16,
>+				BASE_HEX,
>+				NULL,
>+				0x0,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_service_id,
>+			{
>+				"Service ID:",
>+				"mih.service_id",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(servicevalues),
>+				SID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_opcode,
>+			{
>+				"Opcode:",
>+				"mih.opcode",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(opcodevalues),
>+				OPCODE_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_serv_actionid,
>+			{
>+				"Action ID:",
>+				"mih.action_id",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(serv_act_id_values),
>+				AID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_event_actionid,
>+			{
>+				"Action ID:",
>+				"mih.action_id",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(event_act_id_values),
>+				AID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_command_actionid,
>+			{
>+				"Action ID:",
>+				"mih.action_id",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(command_act_id_values),
>+				AID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_info_actionid,
>+			{
>+				"Action ID:",
>+				"mih.action_id",
>+				FT_UINT16, 
>+				BASE_HEX,
>+				VALS(info_act_id_values),
>+				AID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_tid,
>+			{
>+				"TID:",
>+				"mih.tid",
>+				FT_UINT16,
>+				BASE_DEC,
>+				NULL,
>+				TRANS_ID_MASK,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_pay_len,
>+			{
>+				"Payload length:",
>+				"mih.pay_len",
>+				FT_UINT16,
>+				BASE_DEC,
>+				NULL,
>+				0x0,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_type,
>+			{
>+				"MIH TLV type:",
>+				"mih.tlv_type",
>+				FT_UINT8,
>+				BASE_DEC,
>+				VALS(typevaluenames),
>+				0x0,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_type_length,
>+			{
>+				"MIH TLV length:",
>+				"mih.tlv_length",
>+				FT_UINT8,
>+				BASE_DEC,
>+				NULL,
>+				0x0,
>+				NULL, HFILL
>+			}
>+		},
>+		{
>+			&hf_mih_value,
>+			{
>+				"MIH TLV value:",
>+				"mih.tlv_value",
>+				FT_STRING, 
>+				BASE_NONE, 
>+				NULL, 
>+				0x0,
>+                    		NULL, HFILL
>+			}
>+		}
>+	};
>+
>+	/* Setup protocol subtree array */
>+	static gint *ett[] = 
>+	{
>+		&ett_mih,
>+		&ett_ver_flags,
>+		&ett_mid,
>+		&(ett_tlv[0]),
>+		&(ett_tlv[1]),
>+		&(ett_tlv[2]),
>+		&(ett_tlv[3]),
>+		&(ett_tlv[4]),
>+		&(ett_tlv[5]),
>+		&(ett_tlv[6]),
>+		&(ett_tlv[7]),
>+		&(ett_tlv[8]),
>+		&(ett_tlv[9]),
>+		&(ett_tlv[10]),
>+		&(ett_tlv[11]),
>+		&(ett_tlv[12]),
>+		&(ett_tlv[13]),
>+		&(ett_tlv[14]),
>+		&(ett_tlv[15]),
>+		&(ett_tlv[16]),
>+		&(ett_tlv[17]),
>+		&(ett_tlv[18]),
>+		&(ett_tlv[19])
>+	};
>+	
>+	proto_mih = proto_register_protocol("MIH_Protocol", "MIH", "mih");
>+	proto_register_field_array(proto_mih, hf, array_length(hf));
>+	proto_register_subtree_array(ett, array_length(ett));
>+}
>+
>+
>+/*dissector handoff*/
>+
>+void proto_reg_handoff_mih(void)
>+{ 
>+	static dissector_handle_t mih_handle;
>+
>+	mih_handle = create_dissector_handle(dissect_mih, proto_mih);
>+	dissector_add("udp.port", MIH_PORT, mih_handle);
>+
>+}

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are watching all bug changes.