Ethereal-dev: Re: [Ethereal-dev] packet dissector for some HP switch protocol
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Charlie Lenahan <clenahan@xxxxxxxxxxxxxxxx>
Date: Thu, 31 Mar 2005 10:12:43 -0500
Was my patch overlooked , or not deemed worthy for inclusion? Thanks Charlie At 06:40 PM 3/18/2005, you wrote:
Attached is a packet dissector off of the HP Extended LLC. Also attached is a five packet dump from my network. The name "hpsw" can be changed if there is more suitable(logical) name. *** packet-hpext.c.orig 2005-03-18 18:30:43.369649968 -0500 --- packet-hpext.c 2005-03-18 18:30:10.795601976 -0500 *************** *** 48,53 **** --- 48,54 ---- const value_string xsap_vals[] = { { HPEXT_DXSAP, "RBOOT Destination Service Access Point" }, { HPEXT_SXSAP, "RBOOT Source Service Access Point" }, + { HPEXT_HPSW, "HP Switch Protocol" }, { HPEXT_SNMP, "SNMP" }, { 0x00, NULL } }; *** packet-hpext.h.orig 2005-03-18 18:31:48.625729536 -0500 --- packet-hpext.h 2005-03-18 18:32:01.347795488 -0500 *************** *** 25,28 **** --- 25,29 ---- #define HPEXT_DXSAP 0x608 #define HPEXT_SXSAP 0x609 + #define HPEXT_HPSW 0x623 #define HPEXT_SNMP 0x165A _______________________________________________ Ethereal-dev mailing list Ethereal-dev@xxxxxxxxxxxx http://www.ethereal.com/mailman/listinfo/ethereal-dev
Attachment:
hpsw.dump
Description: Binary data
/* packet-hpsw.c * Routines for HP Switch Config protocol * Charlie Lenahan <clenahan@xxxxxxxxxxxxxxxx> * * $Id: $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxx> * 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 <glib.h> #include <epan/packet.h> #include "etypes.h" #include "packet-hpext.h" static void dissect_hpsw_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree, proto_item *ti, guint8 type); static int proto_hpsw = -1; static int hf_hpsw_version = -1; static int hf_hpsw_type = -1; static int hf_hpsw_tlvtype = -1; static int hf_hpsw_tlvlength = -1; static gint ett_hpsw = -1; static gint ett_hpsw_tlv = -1; #define HPFOO_DEVICE_NAME 0x1 #define HPFOO_DEVICE_VERSION 0x2 #define HPFOO_CONFIG_NAME 0x3 #define HPFOO_IP_ADDR 0x5 #define HPFOO_FIELD_7 0x7 #define HPFOO_FIELD_8 0x8 #define HPFOO_FIELD_9 0x9 #define HPFOO_FIELD_10 0xa static const value_string hpsw_tlv_type_vals[] = { { HPFOO_DEVICE_NAME, "Device Name" }, { HPFOO_DEVICE_VERSION, "Version" }, { HPFOO_CONFIG_NAME, "Config" }, { HPFOO_IP_ADDR, "IP Addr" }, { HPFOO_FIELD_7, "Field 7" }, { HPFOO_FIELD_8, "Field 8" }, { HPFOO_FIELD_9, "Field 9" }, { HPFOO_FIELD_10, "Field 10" }, { 0x00, NULL } }; static void dissect_hpsw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *hp_tree = NULL; proto_tree *tlv_tree = NULL; proto_item *ti = NULL; guint8 version, type; if (check_col(pinfo->cinfo, COL_PROTOCOL)) { col_set_str(pinfo->cinfo, COL_PROTOCOL, "HP"); } if (check_col(pinfo->cinfo, COL_INFO)) { col_set_str(pinfo->cinfo, COL_INFO, "HP Switch Protocol"); } version = tvb_get_guint8(tvb, 0); if (tree) { guint16 offset =0; ti = proto_tree_add_item(tree, proto_hpsw, tvb, 0, -1, FALSE); hp_tree = proto_item_add_subtree(ti, ett_hpsw); proto_tree_add_uint(hp_tree, hf_hpsw_version, tvb, 0, 1, version); offset++; proto_tree_add_item(hp_tree, hf_hpsw_type, tvb, 1, 1, FALSE); offset++; while ( tvb_reported_length_remaining(tvb, offset) > 0 ) { guint8 type,length; type = tvb_get_guint8(tvb, offset); length = tvb_get_guint8(tvb, offset+1); /* make sure still in valid tlv */ if (( length < 1 ) || ( length > tvb_length_remaining(tvb,offset+2))) break; ti = proto_tree_add_text(hp_tree,tvb,offset,length+2,"%s", val_to_str(type,hpsw_tlv_type_vals,"Unknown TLV type: 0x%02x")); tlv_tree=proto_item_add_subtree(ti,ett_hpsw_tlv); /* type */ proto_tree_add_uint(tlv_tree, hf_hpsw_tlvtype, tvb, offset, 1, type); offset++; /* LENGTH (not inclusive of type and length bytes) */ proto_tree_add_uint(tlv_tree, hf_hpsw_tlvlength, tvb, offset, 1, length); offset++; dissect_hpsw_tlv(tvb,offset,length,tlv_tree,ti,type); offset += length; } } } static void dissect_hpsw_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree, proto_item *ti, guint8 type) { switch (type) { case HPFOO_DEVICE_NAME: if (length > 0) { proto_item_set_text(ti, "Device Name: %s", tvb_format_text(tvb, offset, length - 1)); proto_tree_add_text(tree, tvb, offset, length, "Device Name: %s", tvb_format_text(tvb, offset, length - 1)); } else { proto_item_set_text(ti, "Device Name: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Device Name: Bad length %u", length); } break; case HPFOO_DEVICE_VERSION: if (length > 0) { proto_item_set_text(ti, "Version: %s", tvb_format_text(tvb, offset, length - 1)); proto_tree_add_text(tree, tvb, offset, length, "Version: %s", tvb_format_text(tvb, offset, length - 1)); } else { proto_item_set_text(ti, "Version: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Version: Bad length %u", length); } break; case HPFOO_CONFIG_NAME: if (length > 0) { proto_item_set_text(ti, "Config: %s", tvb_format_text(tvb, offset, length - 1)); proto_tree_add_text(tree, tvb, offset, length, "Config: %s", tvb_format_text(tvb, offset, length - 1)); } else { proto_item_set_text(ti, "Config: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Config: Bad length %u", length); } break; case HPFOO_IP_ADDR: if (length == 4) { const guint8 *ipptr=tvb_get_ptr(tvb,offset,length); proto_item_set_text(ti, "IP Addr: %s", ip_to_str(ipptr)); proto_tree_add_text(tree, tvb, offset, length, "IP Addr: %s", ip_to_str(ipptr)); } else { proto_item_set_text(ti, "IP Addr: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "IP Addr: Bad length %u", length); } break; case HPFOO_FIELD_7: if (length == 1) { proto_item_set_text(ti, "Field 7: 0x%02x", tvb_get_guint8(tvb,offset)); proto_tree_add_text(tree, tvb, offset, length, "Field 7: 0x%02x", tvb_get_guint8(tvb,offset)); } else { proto_item_set_text(ti, "Field 7: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Field 7: Bad length %u", length); } break; case HPFOO_FIELD_8: if (length == 2) { proto_item_set_text(ti, "Field 8: 0x%02x", tvb_get_ntohs(tvb,offset)); proto_tree_add_text(tree, tvb, offset, length, "Field 8: 0x%02x", tvb_get_ntohs(tvb,offset)); } else { proto_item_set_text(ti, "Field 8: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Field 8: Bad length %u", length); } break; case HPFOO_FIELD_9: if (length == 2) { proto_item_set_text(ti, "Field 9: 0x%02x", tvb_get_ntohs(tvb,offset)); proto_tree_add_text(tree, tvb, offset, length, "Field 9: 0x%02x", tvb_get_ntohs(tvb,offset)); } else { proto_item_set_text(ti, "Field 9: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Field 9: Bad length %u", length); } break; case HPFOO_FIELD_10: if (length == 4) { proto_item_set_text(ti, "Field 10: 0x%04x", tvb_get_ntohl(tvb,offset)); proto_tree_add_text(tree, tvb, offset, length, "Field 9: 0x%04x", tvb_get_ntohl(tvb,offset)); } else { proto_item_set_text(ti, "Field 10: Bad length %u", length); proto_tree_add_text(tree, tvb, offset, length, "Field 10: Bad length %u", length); } break; default: proto_tree_add_text(tree, tvb, offset, length, "Data"); break; } } void proto_register_hpsw(void) { static hf_register_info hf[] = { { &hf_hpsw_version, { "Version", "hpsw.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }}, { &hf_hpsw_type, { "Type", "hpsw.type", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }}, { &hf_hpsw_tlvtype, { "Type", "hpsw.tlv_type", FT_UINT8, BASE_HEX, VALS(hpsw_tlv_type_vals), 0x0, "", HFILL }}, { &hf_hpsw_tlvlength, { "Length", "hpsw.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }}, }; static gint *ett[] = { &ett_hpsw, &ett_hpsw_tlv, }; proto_hpsw = proto_register_protocol( "HP Switch Protocol", "HPSW", "hpsw"); proto_register_field_array(proto_hpsw, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); register_dissector("hpsw", dissect_hpsw, proto_hpsw); } void proto_reg_handoff_hpsw(void) { dissector_handle_t hpsw_handle; hpsw_handle = find_dissector("hpsw"); dissector_add("hpext.dxsap", 0x0623, hpsw_handle); }
- References:
- [Ethereal-dev] A build error, menus with no text
- From: ilker
- Re: [Ethereal-dev] A build error, menus with no text
- From: Ulf Lamping
- Re: [Ethereal-dev] A build error, menus with no text
- From: ilker
- Re: [Ethereal-dev] A build error, menus with no text
- From: Ulf Lamping
- Re: [Ethereal-dev] A build error, menus with no text
- From: ilker
- [Ethereal-dev] packet dissector for some HP switch protocol
- From: Charlie Lenahan
- [Ethereal-dev] A build error, menus with no text
- Prev by Date: [Ethereal-dev] Buildbot crash output
- Next by Date: RE: [Ethereal-dev] VNC Support?
- Previous by thread: [Ethereal-dev] packet dissector for some HP switch protocol
- Next by thread: [Ethereal-dev] Reproducible crash in stats_tree.c (HTTP)
- Index(es):