diff options
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-bofl.c | 48 | ||||
-rw-r--r-- | epan/dissectors/packet-brp.c | 34 | ||||
-rw-r--r-- | epan/dissectors/packet-cast.c | 714 | ||||
-rw-r--r-- | epan/dissectors/packet-cdp.c | 1839 | ||||
-rw-r--r-- | epan/dissectors/packet-chdlc.c | 117 | ||||
-rw-r--r-- | epan/dissectors/packet-clnp.c | 60 | ||||
-rw-r--r-- | epan/dissectors/packet-cmpp.c | 493 | ||||
-rw-r--r-- | epan/dissectors/packet-cosine.c | 128 | ||||
-rw-r--r-- | epan/dissectors/packet-csm-encaps.c | 1062 | ||||
-rw-r--r-- | epan/dissectors/packet-csn1.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-csn1.h | 82 |
11 files changed, 2295 insertions, 2288 deletions
diff --git a/epan/dissectors/packet-bofl.c b/epan/dissectors/packet-bofl.c index 40c40c5056..e171f057fa 100644 --- a/epan/dissectors/packet-bofl.c +++ b/epan/dissectors/packet-bofl.c @@ -73,27 +73,27 @@ dissect_bofl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo, COL_INFO); if (tree) { - ti = proto_tree_add_item(tree, proto_bofl, tvb, 0, -1, ENC_NA); - bofl_tree = proto_item_add_subtree(ti, ett_bofl); + ti = proto_tree_add_item(tree, proto_bofl, tvb, 0, -1, ENC_NA); + bofl_tree = proto_item_add_subtree(ti, ett_bofl); } pdu = tvb_get_ntohl(tvb, 0); - col_add_fstr(pinfo->cinfo, COL_INFO, - "PDU: 0x%08x", pdu); + col_add_fstr(pinfo->cinfo, COL_INFO, + "PDU: 0x%08x", pdu); if (tree) - proto_tree_add_uint(bofl_tree, hf_bofl_pdu, tvb, 0, 4, pdu); + proto_tree_add_uint(bofl_tree, hf_bofl_pdu, tvb, 0, 4, pdu); sequence = tvb_get_ntohl(tvb, 4); - col_append_fstr(pinfo->cinfo, COL_INFO, - " Sequence: %u", sequence); + col_append_fstr(pinfo->cinfo, COL_INFO, + " Sequence: %u", sequence); if (tree) { - proto_tree_add_uint(bofl_tree, hf_bofl_sequence, tvb, 4, 4, sequence); + proto_tree_add_uint(bofl_tree, hf_bofl_sequence, tvb, 4, 4, sequence); - len = tvb_length_remaining(tvb, 8); - if (len > 0) - proto_tree_add_text(bofl_tree, tvb, 8, len, - "Padding (%d byte)", len); + len = tvb_length_remaining(tvb, 8); + if (len > 0) + proto_tree_add_text(bofl_tree, tvb, 8, len, + "Padding (%d byte)", len); } } @@ -102,24 +102,24 @@ void proto_register_bofl(void) { static hf_register_info hf[] = { - { &hf_bofl_pdu, - { "PDU", "bofl.pdu", - FT_UINT32, BASE_HEX, NULL, 0, - "PDU; normally equals 0x01010000 or 0x01011111", HFILL } - }, - { &hf_bofl_sequence, - { "Sequence", "bofl.sequence", - FT_UINT32, BASE_DEC, NULL, 0, - "incremental counter", HFILL } - } + { &hf_bofl_pdu, + { "PDU", "bofl.pdu", + FT_UINT32, BASE_HEX, NULL, 0, + "PDU; normally equals 0x01010000 or 0x01011111", HFILL } + }, + { &hf_bofl_sequence, + { "Sequence", "bofl.sequence", + FT_UINT32, BASE_DEC, NULL, 0, + "incremental counter", HFILL } + } }; static gint *ett[] = { - &ett_bofl, + &ett_bofl, }; proto_bofl = proto_register_protocol("Wellfleet Breath of Life", - "BOFL", "bofl"); + "BOFL", "bofl"); proto_register_field_array(proto_bofl, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } diff --git a/epan/dissectors/packet-brp.c b/epan/dissectors/packet-brp.c index 9117766033..6944870114 100644 --- a/epan/dissectors/packet-brp.c +++ b/epan/dissectors/packet-brp.c @@ -134,11 +134,11 @@ static int dissect_brp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *brp_item = NULL; - proto_tree *brp_tree = NULL; - gint offset = 0; - guint8 type = 0; - guint8 packet_type = tvb_get_guint8(tvb, 0); + proto_item *brp_item = NULL; + proto_tree *brp_tree = NULL; + gint offset = 0; + guint8 type = 0; + guint8 packet_type = tvb_get_guint8(tvb, 0); /* If there is a "tree" requested, we handle that request. */ @@ -401,9 +401,9 @@ void proto_register_brp (void) /* Register preferences */ prefs_register_uint_preference(brp_module, "port", - "BRP Port", - "Set the UDP port for BRP messages", - 10, &global_brp_port); + "BRP Port", + "Set the UDP port for BRP messages", + 10, &global_brp_port); new_register_dissector("brp", dissect_brp, proto_brp); } @@ -411,23 +411,23 @@ void proto_register_brp (void) /*--- proto_reg_handoff_brp -------------------------------------------*/ void proto_reg_handoff_brp(void) { - static gboolean initialized = FALSE; + static gboolean initialized = FALSE; static dissector_handle_t brp_handle; - static guint saved_brp_port; + static guint saved_brp_port; if (!initialized) { - brp_handle = new_create_dissector_handle(dissect_brp, proto_brp); - dissector_add_handle("udp.port", brp_handle); - initialized = TRUE; + brp_handle = new_create_dissector_handle(dissect_brp, proto_brp); + dissector_add_handle("udp.port", brp_handle); + initialized = TRUE; } else { - if (saved_brp_port != 0) { - dissector_delete_uint("udp.port", saved_brp_port, brp_handle); - } + if (saved_brp_port != 0) { + dissector_delete_uint("udp.port", saved_brp_port, brp_handle); + } } /* Set the port number */ if (global_brp_port != 0) { - dissector_add_uint("udp.port", global_brp_port, brp_handle); + dissector_add_uint("udp.port", global_brp_port, brp_handle); } saved_brp_port = global_brp_port; } diff --git a/epan/dissectors/packet-cast.c b/epan/dissectors/packet-cast.c index 72d2bb6536..3aecf411e7 100644 --- a/epan/dissectors/packet-cast.c +++ b/epan/dissectors/packet-cast.c @@ -41,8 +41,8 @@ * infrastructure for now * * typedef struct { - * guint32 id; - * char * name; + * guint32 id; + * char *name; * } message_id_t; */ @@ -121,7 +121,7 @@ static const value_string message_id[] = { {0x00D0, "CallDiscoveryprotocol"}, {0x00D1, "CallControlprotocol"}, - {0 , NULL} /* terminator */ + {0 , NULL} /* terminator */ }; static const value_string audioCodecTypes[] = { @@ -141,55 +141,55 @@ static const value_string orcStatus[] = { }; static const value_string mediaPayloads[] = { - {1 , "Non-standard codec"}, - {2 , "G.711 A-law 64k"}, - {3 , "G.711 A-law 56k"}, - {4 , "G.711 u-law 64k"}, - {5 , "G.711 u-law 56k"}, - {6 , "G.722 64k"}, - {7 , "G.722 56k"}, - {8 , "G.722 48k"}, - {9 , "G.723.1"}, - {10 , "G.728"}, - {11 , "G.729"}, - {12 , "G.729 Annex A"}, - {13 , "IS11172 AudioCap"}, /* IS11172 is an ISO MPEG standard */ - {14 , "IS13818 AudioCap"}, /* IS13818 is an ISO MPEG standard */ - {15 , "G.729 Annex B"}, - {16 , "G.729 Annex A+Annex B"}, - {18 , "GSM Full Rate"}, - {19 , "GSM Half Rate"}, - {20 , "GSM Enhanced Full Rate"}, - {25 , "Wideband 256k"}, - {32 , "Data 64k"}, - {33 , "Data 56k"}, - {80 , "GSM"}, - {81 , "ActiveVoice"}, - {82 , "G.726 32K"}, - {83 , "G.726 24K"}, - {84 , "G.726 16K"}, - {85 , "G.729B"}, - {86 , "G.729B Low Complexity"}, - {100 , "H261"}, - {101 , "H263"}, - {102 , "Vieo"}, - {105 , "T120"}, - {106 , "H224"}, - {257 , "RFC2833_DynPayload"}, - {0 , NULL} + { 1 , "Non-standard codec"}, + { 2 , "G.711 A-law 64k"}, + { 3 , "G.711 A-law 56k"}, + { 4 , "G.711 u-law 64k"}, + { 5 , "G.711 u-law 56k"}, + { 6 , "G.722 64k"}, + { 7 , "G.722 56k"}, + { 8 , "G.722 48k"}, + { 9 , "G.723.1"}, + { 10 , "G.728"}, + { 11 , "G.729"}, + { 12 , "G.729 Annex A"}, + { 13 , "IS11172 AudioCap"}, /* IS11172 is an ISO MPEG standard */ + { 14 , "IS13818 AudioCap"}, /* IS13818 is an ISO MPEG standard */ + { 15 , "G.729 Annex B"}, + { 16 , "G.729 Annex A+Annex B"}, + { 18 , "GSM Full Rate"}, + { 19 , "GSM Half Rate"}, + { 20 , "GSM Enhanced Full Rate"}, + { 25 , "Wideband 256k"}, + { 32 , "Data 64k"}, + { 33 , "Data 56k"}, + { 80 , "GSM"}, + { 81 , "ActiveVoice"}, + { 82 , "G.726 32K"}, + { 83 , "G.726 24K"}, + { 84 , "G.726 16K"}, + { 85 , "G.729B"}, + { 86 , "G.729B Low Complexity"}, + {100 , "H261"}, + {101 , "H263"}, + {102 , "Vieo"}, + {105 , "T120"}, + {106 , "H224"}, + {257 , "RFC2833_DynPayload"}, + {0 , NULL} }; static const value_string cast_Layouts[] = { - {0 , "NoLayout"}, - {1 , "OneByOne"}, - {2 , "OneByTwo"}, - {3 , "TwoByTwo"}, - {4 , "TwoByTwo3Alt1"}, - {5 , "TwoByTwo3Alt2"}, - {6 , "ThreeByThree"}, - {7 , "ThreeByThree6Alt1"}, - {8 , "ThreeByThree6Alt2"}, - {9 , "ThreeByThree4Alt1"}, + { 0 , "NoLayout"}, + { 1 , "OneByOne"}, + { 2 , "OneByTwo"}, + { 3 , "TwoByTwo"}, + { 4 , "TwoByTwo3Alt1"}, + { 5 , "TwoByTwo3Alt2"}, + { 6 , "ThreeByThree"}, + { 7 , "ThreeByThree6Alt1"}, + { 8 , "ThreeByThree6Alt2"}, + { 9 , "ThreeByThree4Alt1"}, {10 , "ThreeByThree4Alt2"}, {0 , NULL} }; @@ -236,16 +236,16 @@ static const value_string cast_miscCommandType[] = { }; static const value_string cast_callStateTypes[] = { - {0 , "TsIdle"}, - {1 , "TsOffHook"}, - {2 , "TsOnHook"}, - {3 , "TsRingOut"}, - {4 , "TsRingIn"}, - {5 , "TsConnected"}, - {6 , "TsBusy"}, - {7 , "TsCongestion"}, - {8 , "TsHold"}, - {9 , "TsCallWaiting"}, + { 0 , "TsIdle"}, + { 1 , "TsOffHook"}, + { 2 , "TsOnHook"}, + { 3 , "TsRingOut"}, + { 4 , "TsRingIn"}, + { 5 , "TsConnected"}, + { 6 , "TsBusy"}, + { 7 , "TsCongestion"}, + { 8 , "TsHold"}, + { 9 , "TsCallWaiting"}, {10 , "TsCallTransfer"}, {11 , "TsCallPark"}, {12 , "TsProceed"}, @@ -271,16 +271,16 @@ static const value_string cast_callSecurityStatusTypes[] = { }; -#define MAX_CUSTOM_PICTURES 6 -#define MAX_SERVICE_TYPE 4 -#define MAX_LAYOUT_WITH_SAME_SERVICE 5 -#define MAX_PICTURE_FORMAT 5 -#define MAX_REFERENCE_PICTURE 4 -#define MAX_LEVEL_PREFERENCE 4 -#define StationMaxVideoCapabilities 10 -#define StationMaxDataCapabilities 5 -#define StationMaxNameSize 40 /* max size of calling party's name */ -#define StationMaxDirnumSize 24 /* max size of calling or called party dirnum */ +#define MAX_CUSTOM_PICTURES 6 +#define MAX_SERVICE_TYPE 4 +#define MAX_LAYOUT_WITH_SAME_SERVICE 5 +#define MAX_PICTURE_FORMAT 5 +#define MAX_REFERENCE_PICTURE 4 +#define MAX_LEVEL_PREFERENCE 4 +#define StationMaxVideoCapabilities 10 +#define StationMaxDataCapabilities 5 +#define StationMaxNameSize 40 /* max size of calling party's name */ +#define StationMaxDirnumSize 24 /* max size of calling or called party dirnum */ static void dissect_cast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); @@ -392,7 +392,8 @@ static gboolean cast_desegment = TRUE; static dissector_handle_t data_handle; /* Dissect a single CAST PDU */ -static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static void +dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; @@ -462,8 +463,8 @@ static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree count = offset+28; /* total of 120 bytes */ for ( i = 0; i < MAX_CUSTOM_PICTURES; i++ ) { - ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 20, "customPictureFormat[%d]", i); - cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); + ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 20, "customPictureFormat[%d]", i); + cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); proto_tree_add_item(cast_sub_tree, hf_cast_pictureWidth, tvb, count, 4, ENC_LITTLE_ENDIAN); count+= 4; proto_tree_add_item(cast_sub_tree, hf_cast_pictureHeight, tvb, count, 4, ENC_LITTLE_ENDIAN); @@ -492,8 +493,8 @@ static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree count+= 4; cast_sub_tree_sav_sav = cast_sub_tree_sav; for ( t = 0; t < MAX_LAYOUT_WITH_SAME_SERVICE; t++ ) { - ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 20, "layouts[%d]", t); - cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); + ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 20, "layouts[%d]", t); + cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); proto_tree_add_item(cast_sub_tree, hf_cast_layout, tvb, count, 4, ENC_LITTLE_ENDIAN); count+= 4; } @@ -661,8 +662,8 @@ static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_tree_add_item(cast_tree, hf_cast_DSCPValue, tvb, offset+44, 4, ENC_LITTLE_ENDIAN); /* add video part of union */ - ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 30, "videoParameters"); - cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); + ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 30, "videoParameters"); + cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree); proto_tree_add_item(cast_sub_tree, hf_cast_bitRate, tvb, offset+48, 4, ENC_LITTLE_ENDIAN); proto_tree_add_item(cast_sub_tree, hf_cast_pictureFormatCount, tvb, offset+52, 4, ENC_LITTLE_ENDIAN); cast_sub_tree_sav = cast_sub_tree; @@ -1033,7 +1034,8 @@ static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree } /* Get the length of a single CAST PDU */ -static guint get_cast_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) +static guint +get_cast_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) { guint32 hdr_data_length; @@ -1050,7 +1052,8 @@ static guint get_cast_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) } /* Code to actually dissect the packets */ -static void dissect_cast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static void +dissect_cast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* The general structure of a packet: {IP-Header|TCP-Header|n*CAST} * CAST-Packet: {Header(Size, Reserved)|Data(MessageID, Message-Data)} @@ -1088,647 +1091,647 @@ proto_register_cast(void) static hf_register_info hf[] = { { &hf_cast_data_length, { "Data Length", "cast.data_length", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Number of bytes in the data portion.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Number of bytes in the data portion.", + HFILL } }, { &hf_cast_reserved, { "Marker", "cast.marker", - FT_UINT32, BASE_HEX, NULL, 0x0, - "Marker value should ne zero.", - HFILL } + FT_UINT32, BASE_HEX, NULL, 0x0, + "Marker value should ne zero.", + HFILL } }, /* FIXME: Enable use of message name ??? */ { &hf_cast_messageid, { "Message ID", "cast.messageid", - FT_UINT32, BASE_HEX, VALS(message_id), 0x0, - "The function requested/done with this message.", - HFILL } + FT_UINT32, BASE_HEX, VALS(message_id), 0x0, + "The function requested/done with this message.", + HFILL } }, { &hf_cast_version, { "Version", "cast.version", - FT_UINT32, BASE_DEC, NULL, 0x0, - "The version in the keepalive version messages.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "The version in the keepalive version messages.", + HFILL } }, { &hf_cast_ORCStatus, { "ORCStatus", "cast.ORCStatus", - FT_UINT32, BASE_DEC, VALS(orcStatus), 0x0, - "The status of the opened receive channel.", - HFILL } + FT_UINT32, BASE_DEC, VALS(orcStatus), 0x0, + "The status of the opened receive channel.", + HFILL } }, { &hf_cast_ipAddress, { "IP Address", "cast.ipAddress", - FT_IPv4, BASE_NONE, NULL, 0x0, - "An IP address", - HFILL } + FT_IPv4, BASE_NONE, NULL, 0x0, + "An IP address", + HFILL } }, { &hf_cast_portNumber, { "Port Number", "cast.portNumber", - FT_UINT32, BASE_DEC, NULL, 0x0, - "A port number", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "A port number", + HFILL } }, { &hf_cast_passThruPartyID, { "PassThruPartyID", "cast.passThruPartyID", - FT_UINT32, BASE_DEC, NULL, 0x0, - "The pass thru party id", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "The pass thru party id", + HFILL } }, { &hf_cast_callIdentifier, { "Call Identifier", "cast.callIdentifier", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Call identifier for this call.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Call identifier for this call.", + HFILL } }, { &hf_cast_conferenceID, { "Conference ID", "cast.conferenceID", - FT_UINT32, BASE_DEC, NULL, 0x0, - "The conference ID", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "The conference ID", + HFILL } }, { &hf_cast_payloadType, { "PayloadType", "cast.payloadType", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PayloadType.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PayloadType.", + HFILL } }, { &hf_cast_lineInstance, { "Line Instance", "cast.lineInstance", - FT_UINT32, BASE_DEC, NULL, 0x0, - "The display call plane associated with this call.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "The display call plane associated with this call.", + HFILL } }, { &hf_cast_payloadCapability, { "PayloadCapability", "cast.payloadCapability", - FT_UINT32, BASE_DEC, VALS(mediaPayloads), 0x0, - "The payload capability for this media capability structure.", - HFILL } + FT_UINT32, BASE_DEC, VALS(mediaPayloads), 0x0, + "The payload capability for this media capability structure.", + HFILL } }, { &hf_cast_isConferenceCreator, { "IsConferenceCreator", "cast.isConferenceCreator", - FT_UINT32, BASE_DEC, NULL, 0x0, - "IsConferenceCreator.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "IsConferenceCreator.", + HFILL } }, { &hf_cast_payload_rfc_number, { "Payload_rfc_number", "cast.payload_rfc_number", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Payload_rfc_number.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Payload_rfc_number.", + HFILL } }, { &hf_cast_videoCapCount, { "VideoCapCount", "cast.videoCapCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "VideoCapCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "VideoCapCount.", + HFILL } }, { &hf_cast_dataCapCount, { "DataCapCount", "cast.dataCapCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "DataCapCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "DataCapCount.", + HFILL } }, { &hf_cast_RTPPayloadFormat, { "RTPPayloadFormat", "cast.RTPPayloadFormat", - FT_UINT32, BASE_DEC, NULL, 0x0, - "RTPPayloadFormat.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "RTPPayloadFormat.", + HFILL } }, { &hf_cast_customPictureFormatCount, { "CustomPictureFormatCount", "cast.customPictureFormatCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "CustomPictureFormatCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "CustomPictureFormatCount.", + HFILL } }, { &hf_cast_pictureWidth, { "PictureWidth", "cast.pictureWidth", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PictureWidth.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PictureWidth.", + HFILL } }, { &hf_cast_pictureHeight, { "PictureHeight", "cast.pictureHeight", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PictureHeight.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PictureHeight.", + HFILL } }, { &hf_cast_pixelAspectRatio, { "PixelAspectRatio", "cast.pixelAspectRatio", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PixelAspectRatio.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PixelAspectRatio.", + HFILL } }, { &hf_cast_clockConversionCode, { "ClockConversionCode", "cast.clockConversionCode", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ClockConversionCode.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ClockConversionCode.", + HFILL } }, { &hf_cast_clockDivisor, { "ClockDivisor", "cast.clockDivisor", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Clock Divisor.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Clock Divisor.", + HFILL } }, { &hf_cast_activeStreamsOnRegistration, { "ActiveStreamsOnRegistration", "cast.activeStreamsOnRegistration", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ActiveStreamsOnRegistration.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ActiveStreamsOnRegistration.", + HFILL } }, { &hf_cast_maxBW, { "MaxBW", "cast.maxBW", - FT_UINT32, BASE_DEC, NULL, 0x0, - "MaxBW.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "MaxBW.", + HFILL } }, { &hf_cast_serviceResourceCount, { "ServiceResourceCount", "cast.serviceResourceCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ServiceResourceCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ServiceResourceCount.", + HFILL } }, { &hf_cast_layoutCount, { "LayoutCount", "cast.layoutCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "LayoutCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "LayoutCount.", + HFILL } }, { &hf_cast_layout, { "Layout", "cast.layout", - FT_UINT32, BASE_DEC, VALS(cast_Layouts), 0x0, - NULL, - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_Layouts), 0x0, + NULL, + HFILL } }, { &hf_cast_maxConferences, { "MaxConferences", "cast.maxConferences", - FT_UINT32, BASE_DEC, NULL, 0x0, - "MaxConferences.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "MaxConferences.", + HFILL } }, { &hf_cast_activeConferenceOnRegistration, { "ActiveConferenceOnRegistration", "cast.activeConferenceOnRegistration", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ActiveConferenceOnRegistration.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ActiveConferenceOnRegistration.", + HFILL } }, { &hf_cast_transmitOrReceive, { "TransmitOrReceive", "cast.transmitOrReceive", - FT_UINT32, BASE_DEC, VALS(cast_transmitOrReceive), 0x0, - NULL, - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_transmitOrReceive), 0x0, + NULL, + HFILL } }, { &hf_cast_levelPreferenceCount, { "LevelPreferenceCount", "cast.levelPreferenceCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "LevelPreferenceCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "LevelPreferenceCount.", + HFILL } }, { &hf_cast_transmitPreference, { "TransmitPreference", "cast.transmitPreference", - FT_UINT32, BASE_DEC, NULL, 0x0, - "TransmitPreference.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "TransmitPreference.", + HFILL } }, { &hf_cast_format, { "Format", "cast.format", - FT_UINT32, BASE_DEC, VALS(cast_formatTypes), 0x0, - "Format.", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_formatTypes), 0x0, + "Format.", + HFILL } }, { &hf_cast_maxBitRate, { "MaxBitRate", "cast.maxBitRate", - FT_UINT32, BASE_DEC, NULL, 0x0, - "MaxBitRate.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "MaxBitRate.", + HFILL } }, { &hf_cast_minBitRate, { "MinBitRate", "cast.minBitRate", - FT_UINT32, BASE_DEC, NULL, 0x0, - "MinBitRate.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "MinBitRate.", + HFILL } }, { &hf_cast_MPI, { "MPI", "cast.MPI", - FT_UINT32, BASE_DEC, NULL, 0x0, - "MPI.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "MPI.", + HFILL } }, { &hf_cast_serviceNumber, { "ServiceNumber", "cast.serviceNumber", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ServiceNumber.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ServiceNumber.", + HFILL } }, { &hf_cast_temporalSpatialTradeOffCapability, { "TemporalSpatialTradeOffCapability", "cast.temporalSpatialTradeOffCapability", - FT_UINT32, BASE_DEC, NULL, 0x0, - "TemporalSpatialTradeOffCapability.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "TemporalSpatialTradeOffCapability.", + HFILL } }, { &hf_cast_stillImageTransmission, { "StillImageTransmission", "cast.stillImageTransmission", - FT_UINT32, BASE_DEC, NULL, 0x0, - "StillImageTransmission.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "StillImageTransmission.", + HFILL } }, { &hf_cast_h263_capability_bitfield, { "H263_capability_bitfield", "cast.h263_capability_bitfield", - FT_UINT32, BASE_DEC, NULL, 0x0, - "H263_capability_bitfield.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "H263_capability_bitfield.", + HFILL } }, { &hf_cast_annexNandWFutureUse, { "AnnexNandWFutureUse", "cast.annexNandWFutureUse", - FT_UINT32, BASE_DEC, NULL, 0x0, - "AnnexNandWFutureUse.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "AnnexNandWFutureUse.", + HFILL } }, { &hf_cast_modelNumber, { "ModelNumber", "cast.modelNumber", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ModelNumber.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ModelNumber.", + HFILL } }, { &hf_cast_bandwidth, { "Bandwidth", "cast.bandwidth", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Bandwidth.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Bandwidth.", + HFILL } }, { &hf_cast_protocolDependentData, { "ProtocolDependentData", "cast.protocolDependentData", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ProtocolDependentData.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ProtocolDependentData.", + HFILL } }, { &hf_cast_DSCPValue, { "DSCPValue", "cast.DSCPValue", - FT_UINT32, BASE_DEC, NULL, 0x0, - "DSCPValue.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "DSCPValue.", + HFILL } }, { &hf_cast_serviceNum, { "ServiceNum", "cast.serviceNum", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ServiceNum.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ServiceNum.", + HFILL } }, { &hf_cast_precedenceValue, { "Precedence", "cast.precedenceValue", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Precedence value", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Precedence value", + HFILL } }, { &hf_cast_maxStreams, { "MaxStreams", "cast.maxStreams", - FT_UINT32, BASE_DEC, NULL, 0x0, - "32 bit unsigned integer indicating the maximum number of simultansous RTP duplex streams that the client can handle.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "32 bit unsigned integer indicating the maximum number of simultansous RTP duplex streams that the client can handle.", + HFILL } }, { &hf_cast_millisecondPacketSize, { "MS/Packet", "cast.millisecondPacketSize", - FT_UINT32, BASE_DEC, NULL, 0x0, - "The number of milliseconds of conversation in each packet", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "The number of milliseconds of conversation in each packet", + HFILL } }, { &hf_cast_echoCancelType, { "Echo Cancel Type", "cast.echoCancelType", - FT_UINT32, BASE_DEC, VALS(cast_echoCancelTypes), 0x0, - "Is echo cancelling enabled or not", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_echoCancelTypes), 0x0, + "Is echo cancelling enabled or not", + HFILL } }, { &hf_cast_g723BitRate, { "G723 BitRate", "cast.g723BitRate", - FT_UINT32, BASE_DEC, VALS(cast_g723BitRates), 0x0, - "The G723 bit rate for this stream/JUNK if not g723 stream", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_g723BitRates), 0x0, + "The G723 bit rate for this stream/JUNK if not g723 stream", + HFILL } }, { &hf_cast_pictureFormatCount, { "PictureFormatCount", "cast.pictureFormatCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PictureFormatCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PictureFormatCount.", + HFILL } }, { &hf_cast_confServiceNum, { "ConfServiceNum", "cast.confServiceNum", - FT_UINT32, BASE_DEC, NULL, 0x0, - "ConfServiceNum.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "ConfServiceNum.", + HFILL } }, { &hf_cast_miscCommandType, { "MiscCommandType", "cast.miscCommandType", - FT_UINT32, BASE_DEC, VALS(cast_miscCommandType), 0x0, - NULL, - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_miscCommandType), 0x0, + NULL, + HFILL } }, { &hf_cast_temporalSpatialTradeOff, { "TemporalSpatialTradeOff", "cast.temporalSpatialTradeOff", - FT_UINT32, BASE_DEC, NULL, 0x0, - "TemporalSpatialTradeOff.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "TemporalSpatialTradeOff.", + HFILL } }, { &hf_cast_firstGOB, { "FirstGOB", "cast.firstGOB", - FT_UINT32, BASE_DEC, NULL, 0x0, - "FirstGOB.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "FirstGOB.", + HFILL } }, { &hf_cast_numberOfGOBs, { "NumberOfGOBs", "cast.numberOfGOBs", - FT_UINT32, BASE_DEC, NULL, 0x0, - "NumberOfGOBs.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "NumberOfGOBs.", + HFILL } }, { &hf_cast_firstMB, { "FirstMB", "cast.firstMB", - FT_UINT32, BASE_DEC, NULL, 0x0, - "FirstMB.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "FirstMB.", + HFILL } }, { &hf_cast_numberOfMBs, { "NumberOfMBs", "cast.numberOfMBs", - FT_UINT32, BASE_DEC, NULL, 0x0, - "NumberOfMBs.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "NumberOfMBs.", + HFILL } }, { &hf_cast_pictureNumber, { "PictureNumber", "cast.pictureNumber", - FT_UINT32, BASE_DEC, NULL, 0x0, - "PictureNumber.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "PictureNumber.", + HFILL } }, { &hf_cast_longTermPictureIndex, { "LongTermPictureIndex", "cast.longTermPictureIndex", - FT_UINT32, BASE_DEC, NULL, 0x0, - "LongTermPictureIndex.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "LongTermPictureIndex.", + HFILL } }, { &hf_cast_recoveryReferencePictureCount, { "RecoveryReferencePictureCount", "cast.recoveryReferencePictureCount", - FT_UINT32, BASE_DEC, NULL, 0x0, - "RecoveryReferencePictureCount.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "RecoveryReferencePictureCount.", + HFILL } }, { &hf_cast_calledParty, { "CalledParty", "cast.calledParty", - FT_STRING, BASE_NONE, NULL, 0x0, - "The number called.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The number called.", + HFILL } }, { &hf_cast_privacy, { "Privacy", "cast.privacy", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Privacy.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Privacy.", + HFILL } }, { &hf_cast_precedenceLv, { "PrecedenceLv", "cast.precedenceLv", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Precedence Level.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Precedence Level.", + HFILL } }, { &hf_cast_precedenceDm, { "PrecedenceDm", "cast.precedenceDm", - FT_UINT32, BASE_DEC, NULL, 0x0, - "Precedence Domain.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "Precedence Domain.", + HFILL } }, { &hf_cast_callState, { "CallState", "cast.callState", - FT_UINT32, BASE_DEC, VALS(cast_callStateTypes), 0x0, - "CallState.", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_callStateTypes), 0x0, + "CallState.", + HFILL } }, { &hf_cast_callingPartyName, { "Calling Party Name", "cast.callingPartyName", - FT_STRING, BASE_NONE, NULL, 0x0, - "The passed name of the calling party.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The passed name of the calling party.", + HFILL } }, { &hf_cast_callingParty, { "Calling Party", "cast.callingParty", - FT_STRING, BASE_NONE, NULL, 0x0, - "The passed number of the calling party.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The passed number of the calling party.", + HFILL } }, { &hf_cast_calledPartyName, { "Called Party Name", "cast.calledPartyName", - FT_STRING, BASE_NONE, NULL, 0x0, - "The name of the party we are calling.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The name of the party we are calling.", + HFILL } }, { &hf_cast_callType, { "Call Type", "cast.callType", - FT_UINT32, BASE_DEC, VALS(cast_callTypes), 0x0, - "What type of call, in/out/etc", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_callTypes), 0x0, + "What type of call, in/out/etc", + HFILL } }, { &hf_cast_originalCalledPartyName, { "Original Called Party Name", "cast.originalCalledPartyName", - FT_STRING, BASE_NONE, NULL, 0x0, - "name of the original person who placed the call.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "name of the original person who placed the call.", + HFILL } }, { &hf_cast_originalCalledParty, { "Original Called Party", "cast.originalCalledParty", - FT_STRING, BASE_NONE, NULL, 0x0, - "The number of the original calling party.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The number of the original calling party.", + HFILL } }, { &hf_cast_lastRedirectingPartyName, { "LastRedirectingPartyName", "cast.lastRedirectingPartyName", - FT_STRING, BASE_NONE, NULL, 0x0, - "LastRedirectingPartyName.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "LastRedirectingPartyName.", + HFILL } }, { &hf_cast_lastRedirectingParty, { "LastRedirectingParty", "cast.lastRedirectingParty", - FT_STRING, BASE_NONE, NULL, 0x0, - "LastRedirectingParty.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "LastRedirectingParty.", + HFILL } }, { &hf_cast_cgpnVoiceMailbox, { "CgpnVoiceMailbox", "cast.cgpnVoiceMailbox", - FT_STRING, BASE_NONE, NULL, 0x0, - "CgpnVoiceMailbox.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "CgpnVoiceMailbox.", + HFILL } }, { &hf_cast_cdpnVoiceMailbox, { "CdpnVoiceMailbox", "cast.cdpnVoiceMailbox", - FT_STRING, BASE_NONE, NULL, 0x0, - "CdpnVoiceMailbox.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "CdpnVoiceMailbox.", + HFILL } }, { &hf_cast_originalCdpnVoiceMailbox, { "OriginalCdpnVoiceMailbox", "cast.originalCdpnVoiceMailbox", - FT_STRING, BASE_NONE, NULL, 0x0, - "OriginalCdpnVoiceMailbox.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "OriginalCdpnVoiceMailbox.", + HFILL } }, { &hf_cast_lastRedirectingVoiceMailbox, { "LastRedirectingVoiceMailbox", "cast.lastRedirectingVoiceMailbox", - FT_STRING, BASE_NONE, NULL, 0x0, - "LastRedirectingVoiceMailbox.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "LastRedirectingVoiceMailbox.", + HFILL } }, { &hf_cast_originalCdpnRedirectReason, { "OriginalCdpnRedirectReason", "cast.originalCdpnRedirectReason", - FT_UINT32, BASE_DEC, NULL, 0x0, - "OriginalCdpnRedirectReason.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "OriginalCdpnRedirectReason.", + HFILL } }, { &hf_cast_lastRedirectingReason, { "LastRedirectingReason", "cast.lastRedirectingReason", - FT_UINT32, BASE_DEC, NULL, 0x0, - "LastRedirectingReason.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "LastRedirectingReason.", + HFILL } }, { &hf_cast_callInstance, { "CallInstance", "cast.callInstance", - FT_UINT32, BASE_DEC, NULL, 0x0, - "CallInstance.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "CallInstance.", + HFILL } }, { &hf_cast_callSecurityStatus, { "CallSecurityStatus", "cast.callSecurityStatus", - FT_UINT32, BASE_DEC, VALS(cast_callSecurityStatusTypes), 0x0, - "CallSecurityStatus.", - HFILL } + FT_UINT32, BASE_DEC, VALS(cast_callSecurityStatusTypes), 0x0, + "CallSecurityStatus.", + HFILL } }, { &hf_cast_directoryNumber, { "Directory Number", "cast.directoryNumber", - FT_STRING, BASE_NONE, NULL, 0x0, - "The number we are reporting statistics for.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "The number we are reporting statistics for.", + HFILL } }, { &hf_cast_requestorIpAddress, { "RequestorIpAddress", "cast.requestorIpAddress", - FT_IPv4, BASE_NONE, NULL, 0x0, - NULL, - HFILL } + FT_IPv4, BASE_NONE, NULL, 0x0, + NULL, + HFILL } }, { &hf_cast_stationIpAddress, { "StationIpAddress", "cast.stationIpAddress", - FT_IPv4, BASE_NONE, NULL, 0x0, - NULL, - HFILL } + FT_IPv4, BASE_NONE, NULL, 0x0, + NULL, + HFILL } }, { &hf_cast_stationFriendlyName, { "StationFriendlyName", "cast.stationFriendlyName", - FT_STRING, BASE_NONE, NULL, 0x0, - "StationFriendlyName.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "StationFriendlyName.", + HFILL } }, { &hf_cast_stationGUID, { "stationGUID", "cast.stationGUID", - FT_STRING, BASE_NONE, NULL, 0x0, - "stationGUID.", - HFILL } + FT_STRING, BASE_NONE, NULL, 0x0, + "stationGUID.", + HFILL } }, { &hf_cast_audio, { "AudioCodec", "cast.audio", - FT_UINT32, BASE_DEC, VALS(audioCodecTypes), 0x0, - "The audio codec that is in use.", - HFILL } + FT_UINT32, BASE_DEC, VALS(audioCodecTypes), 0x0, + "The audio codec that is in use.", + HFILL } }, { &hf_cast_bitRate, { "BitRate", "cast.bitRate", - FT_UINT32, BASE_DEC, NULL, 0x0, - "BitRate.", - HFILL } + FT_UINT32, BASE_DEC, NULL, 0x0, + "BitRate.", + HFILL } }, }; @@ -1743,9 +1746,8 @@ proto_register_cast(void) /* Register the protocol name and description */ proto_cast = proto_register_protocol("Cast Client Control Protocol", - "CAST", "cast"); + "CAST", "cast"); - /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_cast, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c index 18331cbc25..84294ea715 100644 --- a/epan/dissectors/packet-cdp.c +++ b/epan/dissectors/packet-cdp.c @@ -27,7 +27,6 @@ # include "config.h" #endif -#include <stdlib.h> #include <string.h> #include <glib.h> @@ -42,20 +41,20 @@ /* * See * - * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#xtocid12 + * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#xtocid12 * * for some information on CDP. * * See * - * http://www.cisco.com/en/US/products/hw/switches/ps663/products_tech_note09186a0080094713.shtml#cdp + * http://www.cisco.com/en/US/products/hw/switches/ps663/products_tech_note09186a0080094713.shtml#cdp * * for some more information on CDP version 2. */ /* Offsets in TLV structure. */ -#define TLV_TYPE 0 -#define TLV_LENGTH 2 +#define TLV_TYPE 0 +#define TLV_LENGTH 2 static int proto_cdp = -1; static int hf_cdp_version = -1; @@ -92,13 +91,13 @@ static void add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, gint len, const gchar *prefix); -#define TYPE_DEVICE_ID 0x0001 -#define TYPE_ADDRESS 0x0002 -#define TYPE_PORT_ID 0x0003 -#define TYPE_CAPABILITIES 0x0004 -#define TYPE_IOS_VERSION 0x0005 -#define TYPE_PLATFORM 0x0006 -#define TYPE_IP_PREFIX 0x0007 +#define TYPE_DEVICE_ID 0x0001 +#define TYPE_ADDRESS 0x0002 +#define TYPE_PORT_ID 0x0003 +#define TYPE_CAPABILITIES 0x0004 +#define TYPE_IOS_VERSION 0x0005 +#define TYPE_PLATFORM 0x0006 +#define TYPE_IP_PREFIX 0x0007 #define TYPE_PROTOCOL_HELLO 0x0008 /* Protocol Hello */ #define TYPE_VTP_MGMT_DOMAIN 0x0009 /* VTP Domain, CTPv2 - see second URL */ #define TYPE_NATIVE_VLAN 0x000a /* Native VLAN, CTPv2 - see second URL */ @@ -123,54 +122,54 @@ add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, #define TYPE_SPARE_POE 0x001f /* Spare Pair PoE */ static const value_string type_vals[] = { - { TYPE_DEVICE_ID, "Device ID" }, - { TYPE_ADDRESS, "Addresses" }, - { TYPE_PORT_ID, "Port ID" }, - { TYPE_CAPABILITIES, "Capabilities" }, - { TYPE_IOS_VERSION, "Software version" }, - { TYPE_PLATFORM, "Platform" }, - { TYPE_IP_PREFIX, "IP Prefix/Gateway (used for ODR)" }, - { TYPE_PROTOCOL_HELLO, "Protocol Hello" }, - { TYPE_VTP_MGMT_DOMAIN, "VTP Management Domain" }, - { TYPE_NATIVE_VLAN, "Native VLAN" }, - { TYPE_DUPLEX, "Duplex" }, - { TYPE_VOIP_VLAN_REPLY, "VoIP VLAN Reply" }, - { TYPE_VOIP_VLAN_QUERY, "VoIP VLAN Query" }, - { TYPE_POWER, "Power consumption" }, - { TYPE_MTU, "MTU"}, - { TYPE_TRUST_BITMAP, "Trust Bitmap" }, - { TYPE_UNTRUSTED_COS, "Untrusted Port CoS" }, - { TYPE_SYSTEM_NAME, "System Name" }, - { TYPE_SYSTEM_OID, "System Object ID" }, - { TYPE_MANAGEMENT_ADDR, "Management Address" }, - { TYPE_LOCATION, "Location" }, - { TYPE_EXT_PORT_ID, "External Port-ID" }, - { TYPE_POWER_REQUESTED, "Power Requested" }, - { TYPE_POWER_AVAILABLE, "Power Available" }, - { TYPE_PORT_UNIDIR, "Port Unidirectional" }, - { TYPE_NRGYZ, "EnergyWise" }, - { TYPE_SPARE_POE, "Spare PoE" }, - { 0, NULL } + { TYPE_DEVICE_ID, "Device ID" }, + { TYPE_ADDRESS, "Addresses" }, + { TYPE_PORT_ID, "Port ID" }, + { TYPE_CAPABILITIES, "Capabilities" }, + { TYPE_IOS_VERSION, "Software version" }, + { TYPE_PLATFORM, "Platform" }, + { TYPE_IP_PREFIX, "IP Prefix/Gateway (used for ODR)" }, + { TYPE_PROTOCOL_HELLO, "Protocol Hello" }, + { TYPE_VTP_MGMT_DOMAIN, "VTP Management Domain" }, + { TYPE_NATIVE_VLAN, "Native VLAN" }, + { TYPE_DUPLEX, "Duplex" }, + { TYPE_VOIP_VLAN_REPLY, "VoIP VLAN Reply" }, + { TYPE_VOIP_VLAN_QUERY, "VoIP VLAN Query" }, + { TYPE_POWER, "Power consumption" }, + { TYPE_MTU, "MTU"}, + { TYPE_TRUST_BITMAP, "Trust Bitmap" }, + { TYPE_UNTRUSTED_COS, "Untrusted Port CoS" }, + { TYPE_SYSTEM_NAME, "System Name" }, + { TYPE_SYSTEM_OID, "System Object ID" }, + { TYPE_MANAGEMENT_ADDR, "Management Address" }, + { TYPE_LOCATION, "Location" }, + { TYPE_EXT_PORT_ID, "External Port-ID" }, + { TYPE_POWER_REQUESTED, "Power Requested" }, + { TYPE_POWER_AVAILABLE, "Power Available" }, + { TYPE_PORT_UNIDIR, "Port Unidirectional" }, + { TYPE_NRGYZ, "EnergyWise" }, + { TYPE_SPARE_POE, "Spare PoE" }, + { 0, NULL } }; #define TYPE_HELLO_CLUSTER_MGMT 0x0112 static const value_string type_hello_vals[] = { - { TYPE_HELLO_CLUSTER_MGMT, "Cluster Management" }, - { 0, NULL } + { TYPE_HELLO_CLUSTER_MGMT, "Cluster Management" }, + { 0, NULL } }; -#define TYPE_NRGYZ_ROLE 0x00000007 -#define TYPE_NRGYZ_DOMAIN 0x00000008 -#define TYPE_NRGYZ_NAME 0x00000009 -#define TYPE_NRGYZ_REPLYTO 0x00000017 +#define TYPE_NRGYZ_ROLE 0x00000007 +#define TYPE_NRGYZ_DOMAIN 0x00000008 +#define TYPE_NRGYZ_NAME 0x00000009 +#define TYPE_NRGYZ_REPLYTO 0x00000017 static const value_string type_nrgyz_vals[] = { - { TYPE_NRGYZ_ROLE, "Role" }, - { TYPE_NRGYZ_DOMAIN, "Domain" }, - { TYPE_NRGYZ_NAME, "Name" }, - { TYPE_NRGYZ_REPLYTO, "Reply To" }, - { 0, NULL } + { TYPE_NRGYZ_ROLE, "Role" }, + { TYPE_NRGYZ_DOMAIN, "Domain" }, + { TYPE_NRGYZ_NAME, "Name" }, + { TYPE_NRGYZ_REPLYTO, "Reply To" }, + { 0, NULL } }; static void @@ -178,38 +177,38 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti, *checksum_item; proto_tree *cdp_tree = NULL, *checksum_tree; - int offset = 0; - guint16 type; - guint16 length, packet_checksum, computed_checksum, data_length; - gboolean checksum_good, checksum_bad; - proto_item *tlvi = NULL; + int offset = 0; + guint16 type; + guint16 length, packet_checksum, computed_checksum, data_length; + gboolean checksum_good, checksum_bad; + proto_item *tlvi = NULL; proto_tree *tlv_tree = NULL; - int real_length; - guint32 naddresses; - guint32 power_avail_len, power_avail; - guint32 power_req_len, power_req; - int addr_length; - guint32 ip_addr; - vec_t cksum_vec[1]; + int real_length; + guint32 naddresses; + guint32 power_avail_len, power_avail; + guint32 power_req_len, power_req; + int addr_length; + guint32 ip_addr; + vec_t cksum_vec[1]; col_set_str(pinfo->cinfo, COL_PROTOCOL, "CDP"); col_clear(pinfo->cinfo, COL_INFO); if (tree) { ti = proto_tree_add_item(tree, proto_cdp, tvb, offset, -1, ENC_NA); - cdp_tree = proto_item_add_subtree(ti, ett_cdp); + cdp_tree = proto_item_add_subtree(ti, ett_cdp); - /* CDP header */ - proto_tree_add_item(cdp_tree, hf_cdp_version, tvb, offset, 1, ENC_BIG_ENDIAN); - offset += 1; + /* CDP header */ + proto_tree_add_item(cdp_tree, hf_cdp_version, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; - proto_tree_add_uint_format_value(cdp_tree, hf_cdp_ttl, tvb, offset, 1, - tvb_get_guint8(tvb, offset), - "%u seconds", - tvb_get_guint8(tvb, offset)); - offset += 1; + proto_tree_add_uint_format_value(cdp_tree, hf_cdp_ttl, tvb, offset, 1, + tvb_get_guint8(tvb, offset), + "%u seconds", + tvb_get_guint8(tvb, offset)); + offset += 1; } else { - offset += 2; /* The version/ttl fields from above */ + offset += 2; /* The version/ttl fields from above */ } /* Checksum display & verification code */ @@ -256,686 +255,685 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) checksum_bad = !checksum_good; if (checksum_good) { checksum_item = proto_tree_add_uint_format(cdp_tree, - hf_cdp_checksum, tvb, offset, 2, packet_checksum, - "Checksum: 0x%04x [correct]", packet_checksum); + hf_cdp_checksum, tvb, offset, 2, packet_checksum, + "Checksum: 0x%04x [correct]", packet_checksum); } else { - checksum_item = proto_tree_add_uint_format(cdp_tree, - hf_cdp_checksum, tvb, offset, 2, packet_checksum, - "Checksum: 0x%04x [incorrect, should be 0x%04x]", - packet_checksum, - in_cksum_shouldbe(packet_checksum, computed_checksum)); + checksum_item = proto_tree_add_uint_format(cdp_tree, + hf_cdp_checksum, tvb, offset, 2, packet_checksum, + "Checksum: 0x%04x [incorrect, should be 0x%04x]", + packet_checksum, + in_cksum_shouldbe(packet_checksum, computed_checksum)); } checksum_tree = proto_item_add_subtree(checksum_item, ett_cdp_checksum); checksum_item = proto_tree_add_boolean(checksum_tree, hf_cdp_checksum_good, - tvb, offset, 2, checksum_good); + tvb, offset, 2, checksum_good); PROTO_ITEM_SET_GENERATED(checksum_item); checksum_item = proto_tree_add_boolean(checksum_tree, hf_cdp_checksum_bad, - tvb, offset, 2, checksum_bad); + tvb, offset, 2, checksum_bad); PROTO_ITEM_SET_GENERATED(checksum_item); offset += 2; while (tvb_reported_length_remaining(tvb, offset) != 0) { - type = tvb_get_ntohs(tvb, offset + TLV_TYPE); - length = tvb_get_ntohs(tvb, offset + TLV_LENGTH); - if (length < 4) { - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, 4, - "TLV with invalid length %u (< 4)", - length); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - break; - } - - switch (type) { - - case TYPE_DEVICE_ID: - /* Device ID */ - - col_append_fstr(pinfo->cinfo, COL_INFO, - "Device ID: %s ", - tvb_format_stringzpad(tvb, offset + 4, length - 4)); - - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "Device ID: %s", - tvb_format_stringzpad(tvb, offset + 4, length - 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_deviceid, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA); - } - offset += length; - break; - - case TYPE_PORT_ID: - real_length = length; - if (tvb_get_guint8(tvb, offset + real_length) != 0x00) { - /* The length in the TLV doesn't appear to be the - length of the TLV, as the byte just past it - isn't the first byte of a 2-byte big-endian - small integer; make the length of the TLV the length - in the TLV, plus 4 bytes for the TLV type and length, - minus 1 because that's what makes one capture work. */ - real_length = length + 3; - } - - col_append_fstr(pinfo->cinfo, COL_INFO, - "Port ID: %s ", - tvb_format_stringzpad(tvb, offset + 4, - length - 4)); - - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - real_length, "Port ID: %s", - tvb_format_text(tvb, offset + 4, real_length - 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_portid, tvb, offset + 4, real_length - 4, ENC_ASCII|ENC_NA); - } - offset += real_length; - break; - - case TYPE_ADDRESS: - /* Addresses */ - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "Addresses"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - length -= 4; - naddresses = tvb_get_ntohl(tvb, offset); - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, 4, - "Number of addresses: %u", naddresses); - } - offset += 4; - length -= 4; - while (naddresses != 0) { - addr_length = dissect_address_tlv(tvb, offset, length, - tlv_tree); - if (addr_length < 0) - break; - offset += addr_length; - length -= addr_length; - - naddresses--; - } - offset += length; - break; - - case TYPE_CAPABILITIES: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "Capabilities"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - length -= 4; - dissect_capabilities(tvb, offset, length, tlv_tree); - offset += length; - break; - - case TYPE_IOS_VERSION: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "Software Version"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - add_multi_line_string_to_tree(tlv_tree, tvb, offset + 4, - length - 4, "Software Version: "); - } - offset += length; - break; - - case TYPE_PLATFORM: - /* ??? platform */ - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Platform: %s", - tvb_format_text(tvb, offset + 4, length - 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA); - } - offset += length; - break; - - case TYPE_IP_PREFIX: - if (length == 8) { - /* if length is 8 then this is default gw not prefix */ - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "ODR Default gateway: %s", - tvb_ip_to_str(tvb, offset+4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset+4, 4, - "ODR Default gateway = %s", - tvb_ip_to_str(tvb, offset+4)); - } - offset += 8; - } else { - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "IP Prefixes: %d",length/5); - - /* the actual number of prefixes is (length-4)/5 - but if the variable is not a "float" but "integer" - then length/5=(length-4)/5 :) */ - - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - length -= 4; - while (length > 0) { - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, 5, - "IP Prefix = %s/%u", - tvb_ip_to_str(tvb, offset), - tvb_get_guint8(tvb,offset+4)); - } - offset += 5; - length -= 5; - } - } - break; - - case TYPE_PROTOCOL_HELLO: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset,length, "Protocol Hello: %s", - val_to_str(tvb_get_ntohs(tvb, offset+7), type_hello_vals, "Unknown (0x%04x)")); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset+4, 3, - "OUI: 0x%06X (%s)", - tvb_get_ntoh24(tvb,offset+4), - val_to_str(tvb_get_ntoh24(tvb,offset+4), oui_vals, "Unknown")); - proto_tree_add_text(tlv_tree, tvb, offset+7, 2, - "Protocol ID: 0x%04X (%s)", - tvb_get_ntohs(tvb, offset+7), - val_to_str(tvb_get_ntohs(tvb, offset+7), type_hello_vals, "Unknown")); - - switch(tvb_get_ntohs(tvb, offset+7)) { - - case TYPE_HELLO_CLUSTER_MGMT: - /* proto_tree_add_text(tlv_tree, tvb, offset+9, - length - 9, "Cluster Management"); - */ - ip_addr = tvb_get_ipv4(tvb, offset+9); - proto_tree_add_text(tlv_tree, tvb, offset+9, 4, - "Cluster Master IP: %s",ip_to_str((guint8 *)&ip_addr)); - ip_addr = tvb_get_ipv4(tvb, offset+13); - proto_tree_add_text(tlv_tree, tvb, offset+13, 4, - "UNKNOWN (IP?): 0x%08X (%s)", - ip_addr, ip_to_str((guint8 *)&ip_addr)); - proto_tree_add_text(tlv_tree, tvb, offset+17, 1, - "Version?: 0x%02X", - tvb_get_guint8(tvb, offset+17)); - proto_tree_add_text(tlv_tree, tvb, offset+18, 1, - "Sub Version?: 0x%02X", - tvb_get_guint8(tvb, offset+18)); - proto_tree_add_text(tlv_tree, tvb, offset+19, 1, - "Status?: 0x%02X", - tvb_get_guint8(tvb, offset+19)); - proto_tree_add_text(tlv_tree, tvb, offset+20, 1, - "UNKNOWN: 0x%02X", - tvb_get_guint8(tvb, offset+20)); - proto_tree_add_text(tlv_tree, tvb, offset+21, 6, - "Cluster Commander MAC: %s", - tvb_ether_to_str(tvb, offset+21)); - proto_tree_add_text(tlv_tree, tvb, offset+27, 6, - "Switch's MAC: %s", - tvb_ether_to_str(tvb, offset+27)); - proto_tree_add_text(tlv_tree, tvb, offset+33, 1, - "UNKNOWN: 0x%02X", - tvb_get_guint8(tvb, offset+33)); - proto_tree_add_text(tlv_tree, tvb, offset+34, 2, - "Management VLAN: %d", - tvb_get_ntohs(tvb, offset+34)); - break; - default: - proto_tree_add_text(tlv_tree, tvb, offset + 9, - length - 9, "Unknown"); - break; - } - } - offset += length; - break; - - case TYPE_VTP_MGMT_DOMAIN: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "VTP Management Domain: %s", - tvb_format_text(tvb, offset + 4, length - 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "VTP Management Domain: %s", - tvb_format_text(tvb, offset + 4, length - 4)); - } - offset += length; - break; - - case TYPE_NATIVE_VLAN: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Native VLAN: %u", - tvb_get_ntohs(tvb, offset + 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Native VLAN: %u", - tvb_get_ntohs(tvb, offset + 4)); - } - offset += length; - break; - - case TYPE_DUPLEX: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Duplex: %s", - tvb_get_guint8(tvb, offset + 4) ? - "Full" : "Half" ); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Duplex: %s", - tvb_get_guint8(tvb, offset + 4) ? - "Full" : "Half" ); - } - offset += length; - break; - - case TYPE_VOIP_VLAN_REPLY: - if (tree) { - if (length >= 7) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length, - "VoIP VLAN Reply: %u", tvb_get_ntohs(tvb, offset + 5)); - } else { - /* - * XXX - what are these? I've seen them in some captures; - * they have a length of 6, and run up to the end of - * the packet, so if we try to dissect it the same way - * we dissect the 7-byte ones, we report a malformed - * frame. - */ - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "VoIP VLAN Reply"); - } - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 1, "Data"); - if (length >= 7) { - proto_tree_add_text(tlv_tree, tvb, offset + 5, - 2, "Voice VLAN: %u", - tvb_get_ntohs(tvb, offset + 5)); - } - } - offset += length; - break; - - case TYPE_VOIP_VLAN_QUERY: - if (tree) { - if (length >= 7) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "VoIP VLAN Query: %u", tvb_get_ntohs(tvb, offset + 5)); - } else { - /* - * XXX - what are these? I've seen them in some captures; - * they have a length of 6, and run up to the end of - * the packet, so if we try to dissect it the same way - * we dissect the 7-byte ones, we report a malformed - * frame. - */ - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "VoIP VLAN Query"); - } - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 1, "Data"); - if (length >= 7) { - proto_tree_add_text(tlv_tree, tvb, offset + 5, - 2, "Voice VLAN: %u", - tvb_get_ntohs(tvb, offset + 5)); - } - } - offset += length; - break; - - case TYPE_POWER: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Power Consumption: %u mW", - tvb_get_ntohs(tvb, offset + 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Power Consumption: %u mW", - tvb_get_ntohs(tvb, offset + 4)); - } - offset += length; - break; - - case TYPE_MTU: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "MTU: %u", - tvb_get_ntohl(tvb,offset + 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "MTU: %u", - tvb_get_ntohl(tvb,offset + 4)); - } - offset += length; - break; - - case TYPE_TRUST_BITMAP: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Trust Bitmap: 0x%02X", - tvb_get_guint8(tvb, offset + 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Trust Bitmap: %02x", - tvb_get_guint8(tvb, offset + 4)); - } - offset += length; - break; - - case TYPE_UNTRUSTED_COS: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Untrusted port CoS: 0x%02X", - tvb_get_guint8(tvb, offset + 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Untrusted port CoS: %02x", - tvb_get_guint8(tvb, offset + 4)); - } - offset += length; - break; - - case TYPE_SYSTEM_NAME: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "System Name: %s", - tvb_format_text(tvb, offset + 4, length - 4)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "System Name: %s", - tvb_format_text(tvb, offset + 4, length - 4)); - } - offset += length; - break; - - case TYPE_SYSTEM_OID: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "System Object Identifier"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "System Object Identifier: %s", - tvb_bytes_to_str(tvb, offset + 4, length - 4)); - } - offset += length; - break; - - case TYPE_MANAGEMENT_ADDR: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Management Addresses"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - length -= 4; - naddresses = tvb_get_ntohl(tvb, offset); - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, 4, - "Number of addresses: %u", naddresses); - } - offset += 4; - length -= 4; - while (naddresses != 0) { - addr_length = dissect_address_tlv(tvb, offset, length, - tlv_tree); - if (addr_length < 0) - break; - offset += addr_length; - length -= addr_length; - - naddresses--; - } - offset += length; - break; - - case TYPE_LOCATION: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Location: %s", - tvb_format_text(tvb, offset + 5, length - 5)); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 1 , "UNKNOWN: 0x%02X", - tvb_get_guint8(tvb, offset + 4)); - proto_tree_add_text(tlv_tree, tvb, offset + 5, - length - 5, "Location: %s", - tvb_format_text(tvb, offset + 5, length - 5)); - } - offset += length; - break; - - case TYPE_POWER_REQUESTED: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Power Request: "); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 2, "Request-ID: %u", - tvb_get_ntohs(tvb, offset + 4)); - proto_tree_add_text(tlv_tree, tvb, offset + 6, - 2, "Management-ID: %u", - tvb_get_ntohs(tvb, offset + 6)); - } - power_req_len = (tvb_get_ntohs(tvb, offset + TLV_LENGTH)) - 8; - /* Move offset to where the list of Power Request Values Exist */ - offset += 8; - while(power_req_len) { - if (power_req_len > 4) { - power_req = tvb_get_ntohl(tvb, offset); - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, - 4, "Power Requested: %u mW", power_req); - proto_item_append_text(tlvi, "%u mW, ", power_req); - } - power_req_len -= 4; - offset += 4; - } else { - if (power_req_len == 4) { - power_req = tvb_get_ntohl(tvb, offset); - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, - 4, "Power Requested: %u mW", power_req); - proto_item_append_text(tlvi, "%u mW", power_req); - } - } - offset += power_req_len; - break; - } - } - break; - - case TYPE_POWER_AVAILABLE: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "Power Available: "); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 2, "Request-ID: %u", - tvb_get_ntohs(tvb, offset + 4)); - proto_tree_add_text(tlv_tree, tvb, offset + 6, - 2, "Management-ID: %u", - tvb_get_ntohs(tvb, offset + 6)); - } - power_avail_len = (tvb_get_ntohs(tvb, offset + TLV_LENGTH)) - 8; - /* Move offset to where the list of Power Available Values Exist */ - offset += 8; - while(power_avail_len) { - if (power_avail_len >= 4) { - power_avail = tvb_get_ntohl(tvb, offset); - if (tree) { - proto_tree_add_text(tlv_tree, tvb, offset, - 4, "Power Available: %u mW", power_avail); - proto_item_append_text(tlvi, "%u mW, ", power_avail); - } - power_avail_len -= 4; - offset += 4; - } else { - offset += power_avail_len; - break; - } - } - break; - - case TYPE_NRGYZ: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, - offset, length, "EnergyWise"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - 20, "Encrypted Data"); - proto_tree_add_text(tlv_tree, tvb, offset + 24, - 4, "Unknown (Seen Sequence?): %u", - tvb_get_ntohl(tvb, offset + 24)); - proto_tree_add_text(tlv_tree, tvb, offset + 28, - 4, "Sequence Number: %u", - tvb_get_ntohl(tvb, offset + 28)); - proto_tree_add_text(tlv_tree, tvb, offset + 32, - 16, "Model Number: %s", - tvb_format_stringzpad(tvb, offset + 32, 16)); - proto_tree_add_text(tlv_tree, tvb, offset + 48, - 2, "Unknown Pad: %x", - tvb_get_ntohs(tvb, offset + 48)); - proto_tree_add_text(tlv_tree, tvb, offset + 50, - 3, "Hardware Version ID: %s", - tvb_format_stringzpad(tvb, offset + 50, 3)); - proto_tree_add_text(tlv_tree, tvb, offset + 53, - 11, "System Serial Number: %s", - tvb_format_stringzpad(tvb, offset + 53, 11)); - proto_tree_add_text(tlv_tree, tvb, offset + 64, - 8, "Unknown Values"); - proto_tree_add_text(tlv_tree, tvb, offset + 72, - 2, "Length of TLV table: %u", - tvb_get_ntohs(tvb, offset + 72)); - proto_tree_add_text(tlv_tree, tvb, offset + 74, - 2, "Number of TLVs in table: %u", - tvb_get_ntohs(tvb, offset + 74)); + type = tvb_get_ntohs(tvb, offset + TLV_TYPE); + length = tvb_get_ntohs(tvb, offset + TLV_LENGTH); + if (length < 4) { + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, 4, + "TLV with invalid length %u (< 4)", + length); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + break; + } + + switch (type) { + + case TYPE_DEVICE_ID: + /* Device ID */ + + col_append_fstr(pinfo->cinfo, COL_INFO, + "Device ID: %s ", + tvb_format_stringzpad(tvb, offset + 4, length - 4)); + + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "Device ID: %s", + tvb_format_stringzpad(tvb, offset + 4, length - 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_deviceid, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA); + } + offset += length; + break; + + case TYPE_PORT_ID: + real_length = length; + if (tvb_get_guint8(tvb, offset + real_length) != 0x00) { + /* The length in the TLV doesn't appear to be the + length of the TLV, as the byte just past it + isn't the first byte of a 2-byte big-endian + small integer; make the length of the TLV the length + in the TLV, plus 4 bytes for the TLV type and length, + minus 1 because that's what makes one capture work. */ + real_length = length + 3; + } + + col_append_fstr(pinfo->cinfo, COL_INFO, + "Port ID: %s ", + tvb_format_stringzpad(tvb, offset + 4, + length - 4)); + + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + real_length, "Port ID: %s", + tvb_format_text(tvb, offset + 4, real_length - 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_portid, tvb, offset + 4, real_length - 4, ENC_ASCII|ENC_NA); + } + offset += real_length; + break; + + case TYPE_ADDRESS: + /* Addresses */ + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "Addresses"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + length -= 4; + naddresses = tvb_get_ntohl(tvb, offset); + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, 4, + "Number of addresses: %u", naddresses); + } + offset += 4; + length -= 4; + while (naddresses != 0) { + addr_length = dissect_address_tlv(tvb, offset, length, + tlv_tree); + if (addr_length < 0) + break; + offset += addr_length; + length -= addr_length; + + naddresses--; + } + offset += length; + break; + + case TYPE_CAPABILITIES: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "Capabilities"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + length -= 4; + dissect_capabilities(tvb, offset, length, tlv_tree); + offset += length; + break; + + case TYPE_IOS_VERSION: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "Software Version"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + add_multi_line_string_to_tree(tlv_tree, tvb, offset + 4, + length - 4, "Software Version: "); + } + offset += length; + break; + + case TYPE_PLATFORM: + /* ??? platform */ + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Platform: %s", + tvb_format_text(tvb, offset + 4, length - 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA); + } + offset += length; + break; + + case TYPE_IP_PREFIX: + if (length == 8) { + /* if length is 8 then this is default gw not prefix */ + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "ODR Default gateway: %s", + tvb_ip_to_str(tvb, offset+4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset+4, 4, + "ODR Default gateway = %s", + tvb_ip_to_str(tvb, offset+4)); + } + offset += 8; + } else { + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "IP Prefixes: %d",length/5); + + /* the actual number of prefixes is (length-4)/5 + but if the variable is not a "float" but "integer" + then length/5=(length-4)/5 :) */ + + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + length -= 4; + while (length > 0) { + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, 5, + "IP Prefix = %s/%u", + tvb_ip_to_str(tvb, offset), + tvb_get_guint8(tvb,offset+4)); + } + offset += 5; + length -= 5; + } + } + break; + + case TYPE_PROTOCOL_HELLO: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset,length, "Protocol Hello: %s", + val_to_str(tvb_get_ntohs(tvb, offset+7), type_hello_vals, "Unknown (0x%04x)")); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset+4, 3, + "OUI: 0x%06X (%s)", + tvb_get_ntoh24(tvb,offset+4), + val_to_str(tvb_get_ntoh24(tvb,offset+4), oui_vals, "Unknown")); + proto_tree_add_text(tlv_tree, tvb, offset+7, 2, + "Protocol ID: 0x%04X (%s)", + tvb_get_ntohs(tvb, offset+7), + val_to_str(tvb_get_ntohs(tvb, offset+7), type_hello_vals, "Unknown")); + + switch(tvb_get_ntohs(tvb, offset+7)) { + + case TYPE_HELLO_CLUSTER_MGMT: + /* proto_tree_add_text(tlv_tree, tvb, offset+9, + length - 9, "Cluster Management"); + */ + ip_addr = tvb_get_ipv4(tvb, offset+9); + proto_tree_add_text(tlv_tree, tvb, offset+9, 4, + "Cluster Master IP: %s",ip_to_str((guint8 *)&ip_addr)); + ip_addr = tvb_get_ipv4(tvb, offset+13); + proto_tree_add_text(tlv_tree, tvb, offset+13, 4, + "UNKNOWN (IP?): 0x%08X (%s)", + ip_addr, ip_to_str((guint8 *)&ip_addr)); + proto_tree_add_text(tlv_tree, tvb, offset+17, 1, + "Version?: 0x%02X", + tvb_get_guint8(tvb, offset+17)); + proto_tree_add_text(tlv_tree, tvb, offset+18, 1, + "Sub Version?: 0x%02X", + tvb_get_guint8(tvb, offset+18)); + proto_tree_add_text(tlv_tree, tvb, offset+19, 1, + "Status?: 0x%02X", + tvb_get_guint8(tvb, offset+19)); + proto_tree_add_text(tlv_tree, tvb, offset+20, 1, + "UNKNOWN: 0x%02X", + tvb_get_guint8(tvb, offset+20)); + proto_tree_add_text(tlv_tree, tvb, offset+21, 6, + "Cluster Commander MAC: %s", + tvb_ether_to_str(tvb, offset+21)); + proto_tree_add_text(tlv_tree, tvb, offset+27, 6, + "Switch's MAC: %s", + tvb_ether_to_str(tvb, offset+27)); + proto_tree_add_text(tlv_tree, tvb, offset+33, 1, + "UNKNOWN: 0x%02X", + tvb_get_guint8(tvb, offset+33)); + proto_tree_add_text(tlv_tree, tvb, offset+34, 2, + "Management VLAN: %d", + tvb_get_ntohs(tvb, offset+34)); + break; + default: + proto_tree_add_text(tlv_tree, tvb, offset + 9, + length - 9, "Unknown"); + break; + } + } + offset += length; + break; + + case TYPE_VTP_MGMT_DOMAIN: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "VTP Management Domain: %s", + tvb_format_text(tvb, offset + 4, length - 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "VTP Management Domain: %s", + tvb_format_text(tvb, offset + 4, length - 4)); + } + offset += length; + break; + + case TYPE_NATIVE_VLAN: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Native VLAN: %u", + tvb_get_ntohs(tvb, offset + 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Native VLAN: %u", + tvb_get_ntohs(tvb, offset + 4)); + } + offset += length; + break; + + case TYPE_DUPLEX: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Duplex: %s", + tvb_get_guint8(tvb, offset + 4) ? + "Full" : "Half" ); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Duplex: %s", + tvb_get_guint8(tvb, offset + 4) ? + "Full" : "Half" ); + } + offset += length; + break; + + case TYPE_VOIP_VLAN_REPLY: + if (tree) { + if (length >= 7) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length, + "VoIP VLAN Reply: %u", tvb_get_ntohs(tvb, offset + 5)); + } else { + /* + * XXX - what are these? I've seen them in some captures; + * they have a length of 6, and run up to the end of + * the packet, so if we try to dissect it the same way + * we dissect the 7-byte ones, we report a malformed + * frame. + */ + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "VoIP VLAN Reply"); + } + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 1, "Data"); + if (length >= 7) { + proto_tree_add_text(tlv_tree, tvb, offset + 5, + 2, "Voice VLAN: %u", + tvb_get_ntohs(tvb, offset + 5)); + } + } + offset += length; + break; + + case TYPE_VOIP_VLAN_QUERY: + if (tree) { + if (length >= 7) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "VoIP VLAN Query: %u", tvb_get_ntohs(tvb, offset + 5)); + } else { + /* + * XXX - what are these? I've seen them in some captures; + * they have a length of 6, and run up to the end of + * the packet, so if we try to dissect it the same way + * we dissect the 7-byte ones, we report a malformed + * frame. + */ + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "VoIP VLAN Query"); + } + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 1, "Data"); + if (length >= 7) { + proto_tree_add_text(tlv_tree, tvb, offset + 5, + 2, "Voice VLAN: %u", + tvb_get_ntohs(tvb, offset + 5)); + } + } + offset += length; + break; + + case TYPE_POWER: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Power Consumption: %u mW", + tvb_get_ntohs(tvb, offset + 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Power Consumption: %u mW", + tvb_get_ntohs(tvb, offset + 4)); + } + offset += length; + break; + + case TYPE_MTU: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "MTU: %u", + tvb_get_ntohl(tvb,offset + 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "MTU: %u", + tvb_get_ntohl(tvb,offset + 4)); + } + offset += length; + break; + + case TYPE_TRUST_BITMAP: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Trust Bitmap: 0x%02X", + tvb_get_guint8(tvb, offset + 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Trust Bitmap: %02x", + tvb_get_guint8(tvb, offset + 4)); + } + offset += length; + break; + + case TYPE_UNTRUSTED_COS: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Untrusted port CoS: 0x%02X", + tvb_get_guint8(tvb, offset + 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Untrusted port CoS: %02x", + tvb_get_guint8(tvb, offset + 4)); + } + offset += length; + break; + + case TYPE_SYSTEM_NAME: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "System Name: %s", + tvb_format_text(tvb, offset + 4, length - 4)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "System Name: %s", + tvb_format_text(tvb, offset + 4, length - 4)); + } + offset += length; + break; + + case TYPE_SYSTEM_OID: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "System Object Identifier"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "System Object Identifier: %s", + tvb_bytes_to_str(tvb, offset + 4, length - 4)); + } + offset += length; + break; + + case TYPE_MANAGEMENT_ADDR: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Management Addresses"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + length -= 4; + naddresses = tvb_get_ntohl(tvb, offset); + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, 4, + "Number of addresses: %u", naddresses); + } + offset += 4; + length -= 4; + while (naddresses != 0) { + addr_length = dissect_address_tlv(tvb, offset, length, + tlv_tree); + if (addr_length < 0) + break; + offset += addr_length; + length -= addr_length; + + naddresses--; + } + offset += length; + break; + + case TYPE_LOCATION: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Location: %s", + tvb_format_text(tvb, offset + 5, length - 5)); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 1 , "UNKNOWN: 0x%02X", + tvb_get_guint8(tvb, offset + 4)); + proto_tree_add_text(tlv_tree, tvb, offset + 5, + length - 5, "Location: %s", + tvb_format_text(tvb, offset + 5, length - 5)); + } + offset += length; + break; + + case TYPE_POWER_REQUESTED: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Power Request: "); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 2, "Request-ID: %u", + tvb_get_ntohs(tvb, offset + 4)); + proto_tree_add_text(tlv_tree, tvb, offset + 6, + 2, "Management-ID: %u", + tvb_get_ntohs(tvb, offset + 6)); + } + power_req_len = (tvb_get_ntohs(tvb, offset + TLV_LENGTH)) - 8; + /* Move offset to where the list of Power Request Values Exist */ + offset += 8; + while(power_req_len) { + if (power_req_len > 4) { + power_req = tvb_get_ntohl(tvb, offset); + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, + 4, "Power Requested: %u mW", power_req); + proto_item_append_text(tlvi, "%u mW, ", power_req); + } + power_req_len -= 4; + offset += 4; + } else { + if (power_req_len == 4) { + power_req = tvb_get_ntohl(tvb, offset); + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, + 4, "Power Requested: %u mW", power_req); + proto_item_append_text(tlvi, "%u mW", power_req); + } + } + offset += power_req_len; + break; + } + } + break; + + case TYPE_POWER_AVAILABLE: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "Power Available: "); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 2, "Request-ID: %u", + tvb_get_ntohs(tvb, offset + 4)); + proto_tree_add_text(tlv_tree, tvb, offset + 6, + 2, "Management-ID: %u", + tvb_get_ntohs(tvb, offset + 6)); + } + power_avail_len = (tvb_get_ntohs(tvb, offset + TLV_LENGTH)) - 8; + /* Move offset to where the list of Power Available Values Exist */ + offset += 8; + while(power_avail_len) { + if (power_avail_len >= 4) { + power_avail = tvb_get_ntohl(tvb, offset); + if (tree) { + proto_tree_add_text(tlv_tree, tvb, offset, + 4, "Power Available: %u mW", power_avail); + proto_item_append_text(tlvi, "%u mW, ", power_avail); + } + power_avail_len -= 4; + offset += 4; + } else { + offset += power_avail_len; + break; + } + } + break; + + case TYPE_NRGYZ: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, + offset, length, "EnergyWise"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + proto_tree_add_text(tlv_tree, tvb, offset + 4, + 20, "Encrypted Data"); + proto_tree_add_text(tlv_tree, tvb, offset + 24, + 4, "Unknown (Seen Sequence?): %u", + tvb_get_ntohl(tvb, offset + 24)); + proto_tree_add_text(tlv_tree, tvb, offset + 28, + 4, "Sequence Number: %u", + tvb_get_ntohl(tvb, offset + 28)); + proto_tree_add_text(tlv_tree, tvb, offset + 32, + 16, "Model Number: %s", + tvb_format_stringzpad(tvb, offset + 32, 16)); + proto_tree_add_text(tlv_tree, tvb, offset + 48, + 2, "Unknown Pad: %x", + tvb_get_ntohs(tvb, offset + 48)); + proto_tree_add_text(tlv_tree, tvb, offset + 50, + 3, "Hardware Version ID: %s", + tvb_format_stringzpad(tvb, offset + 50, 3)); + proto_tree_add_text(tlv_tree, tvb, offset + 53, + 11, "System Serial Number: %s", + tvb_format_stringzpad(tvb, offset + 53, 11)); + proto_tree_add_text(tlv_tree, tvb, offset + 64, + 8, "Unknown Values"); + proto_tree_add_text(tlv_tree, tvb, offset + 72, + 2, "Length of TLV table: %u", + tvb_get_ntohs(tvb, offset + 72)); + proto_tree_add_text(tlv_tree, tvb, offset + 74, + 2, "Number of TLVs in table: %u", + tvb_get_ntohs(tvb, offset + 74)); /* - proto_tree_add_text(tlv_tree, tvb, - offset + 76, length - 76, - "EnergyWise TLV Table"); + proto_tree_add_text(tlv_tree, tvb, + offset + 76, length - 76, + "EnergyWise TLV Table"); */ - dissect_nrgyz_tlv(tvb, offset + 76, - tvb_get_ntohs(tvb, offset + 72), - tvb_get_ntohs(tvb, offset + 74), - tlv_tree); - - - } - offset += length; - break; - - case TYPE_SPARE_POE: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length, - "Spare Pair PoE"); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - } - offset += 4; - length -= 4; - dissect_spare_poe_tlv(tvb, offset, length, tlv_tree); - offset += length; - break; - - default: - if (tree) { - tlvi = proto_tree_add_text(cdp_tree, tvb, offset, - length, "Type: %s, length: %u", - val_to_str(type, type_vals, "Unknown (0x%04x)"), - length); - tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); - proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); - if (length > 4) { - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Data"); - } else { - return; - } - } - offset += length; - } + dissect_nrgyz_tlv(tvb, offset + 76, + tvb_get_ntohs(tvb, offset + 72), + tvb_get_ntohs(tvb, offset + 74), + tlv_tree); + + + } + offset += length; + break; + + case TYPE_SPARE_POE: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, length, + "Spare Pair PoE"); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + } + offset += 4; + length -= 4; + dissect_spare_poe_tlv(tvb, offset, length, tlv_tree); + offset += length; + break; + + default: + if (tree) { + tlvi = proto_tree_add_text(cdp_tree, tvb, offset, + length, "Type: %s, length: %u", + val_to_str(type, type_vals, "Unknown (0x%04x)"), + length); + tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv); + proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN); + if (length > 4) { + proto_tree_add_text(tlv_tree, tvb, offset + 4, + length - 4, "Data"); + } else { + return; + } + } + offset += length; + } } - call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, - cdp_tree); + call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, cdp_tree); } -#define PROTO_TYPE_NLPID 1 -#define PROTO_TYPE_IEEE_802_2 2 +#define PROTO_TYPE_NLPID 1 +#define PROTO_TYPE_IEEE_802_2 2 static const value_string proto_type_vals[] = { - { PROTO_TYPE_NLPID, "NLPID" }, - { PROTO_TYPE_IEEE_802_2, "802.2" }, - { 0, NULL } + { PROTO_TYPE_NLPID, "NLPID" }, + { PROTO_TYPE_IEEE_802_2, "802.2" }, + { 0, NULL } }; static int @@ -943,11 +941,11 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) { proto_item *ti; proto_tree *address_tree; - guint8 protocol_type; - guint8 protocol_length; - int nlpid; + guint8 protocol_type; + guint8 protocol_length; + int nlpid; const char *protocol_str; - guint16 address_length; + guint16 address_length; const char *address_type_str; const char *address_str; @@ -957,15 +955,15 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) address_tree = proto_item_add_subtree(ti, ett_cdp_address); protocol_type = tvb_get_guint8(tvb, offset); proto_tree_add_text(address_tree, tvb, offset, 1, "Protocol type: %s", - val_to_str(protocol_type, proto_type_vals, "Unknown (0x%02x)")); + val_to_str(protocol_type, proto_type_vals, "Unknown (0x%02x)")); offset += 1; length -= 1; if (length < 1) - return -1; + return -1; protocol_length = tvb_get_guint8(tvb, offset); proto_tree_add_text(address_tree, tvb, offset, 1, "Protocol length: %u", - protocol_length); + protocol_length); offset += 1; length -= 1; @@ -975,26 +973,26 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) "Protocol: %s (truncated)", tvb_bytes_to_str(tvb, offset, length)); } - return -1; + return -1; } protocol_str = NULL; - if (protocol_type == PROTO_TYPE_NLPID && protocol_length == 1) { - nlpid = tvb_get_guint8(tvb, offset); - protocol_str = val_to_str(nlpid, nlpid_vals, "Unknown (0x%02x)"); + if ((protocol_type == PROTO_TYPE_NLPID) && (protocol_length == 1)) { + nlpid = tvb_get_guint8(tvb, offset); + protocol_str = val_to_str(nlpid, nlpid_vals, "Unknown (0x%02x)"); } else nlpid = -1; if (protocol_str == NULL) protocol_str = tvb_bytes_to_str(tvb, offset, protocol_length); proto_tree_add_text(address_tree, tvb, offset, protocol_length, - "Protocol: %s", protocol_str); + "Protocol: %s", protocol_str); offset += protocol_length; length -= protocol_length; if (length < 2) - return -1; + return -1; address_length = tvb_get_ntohs(tvb, offset); proto_tree_add_text(address_tree, tvb, offset, 2, "Address length: %u", - address_length); + address_length); offset += 2; length -= 2; @@ -1004,7 +1002,7 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) "Address: %s (truncated)", tvb_bytes_to_str(tvb, offset, length)); } - return -1; + return -1; } /* XXX - the Cisco document seems to be saying that, for 802.2-format protocol types, 0xAAAA03 0x000000 0x0800 is IPv6, but 0x0800 is @@ -1012,7 +1010,7 @@ dissect_address_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree) length = 2 + protocol_length + 2 + address_length; address_type_str = NULL; address_str = NULL; - if (protocol_type == PROTO_TYPE_NLPID && protocol_length == 1) { + if ((protocol_type == PROTO_TYPE_NLPID) && (protocol_length == 1)) { switch (nlpid) { /* XXX - dissect NLPID_ISO8473_CLNP as OSI CLNP address? */ @@ -1042,7 +1040,7 @@ dissect_capabilities(tvbuff_t *tvb, int offset, int length, proto_tree *tree) { proto_item *ti; proto_tree *capabilities_tree; - guint32 capabilities; + guint32 capabilities; if (length < 4) return; @@ -1051,137 +1049,136 @@ dissect_capabilities(tvbuff_t *tvb, int offset, int length, proto_tree *tree) capabilities); capabilities_tree = proto_item_add_subtree(ti, ett_cdp_capabilities); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x01, 4*8, - "Is a Router", - "Not a Router")); + decode_boolean_bitfield(capabilities, 0x01, 4*8, + "Is a Router", + "Not a Router")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x02, 4*8, - "Is a Transparent Bridge", - "Not a Transparent Bridge")); + decode_boolean_bitfield(capabilities, 0x02, 4*8, + "Is a Transparent Bridge", + "Not a Transparent Bridge")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x04, 4*8, - "Is a Source Route Bridge", - "Not a Source Route Bridge")); + decode_boolean_bitfield(capabilities, 0x04, 4*8, + "Is a Source Route Bridge", + "Not a Source Route Bridge")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x08, 4*8, - "Is a Switch", - "Not a Switch")); + decode_boolean_bitfield(capabilities, 0x08, 4*8, + "Is a Switch", + "Not a Switch")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x10, 4*8, - "Is a Host", - "Not a Host")); + decode_boolean_bitfield(capabilities, 0x10, 4*8, + "Is a Host", + "Not a Host")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x20, 4*8, - "Is IGMP capable", - "Not IGMP capable")); + decode_boolean_bitfield(capabilities, 0x20, 4*8, + "Is IGMP capable", + "Not IGMP capable")); proto_tree_add_text(capabilities_tree, tvb, offset, 4, "%s", - decode_boolean_bitfield(capabilities, 0x40, 4*8, - "Is a Repeater", - "Not a Repeater")); + decode_boolean_bitfield(capabilities, 0x40, 4*8, + "Is a Repeater", + "Not a Repeater")); } static void dissect_nrgyz_tlv(tvbuff_t *tvb, int offset, guint16 length, guint16 num, - proto_tree *tree) + proto_tree *tree) { - guint32 tlvt, tlvl, ip_addr; - proto_item *it = NULL; + guint32 tlvt, tlvl, ip_addr; + proto_item *it = NULL; proto_tree *etree = NULL; char const *ttext = NULL; - while (num-- && length >= 8) { - tlvt = tvb_get_ntohl(tvb, offset); - tlvl = tvb_get_ntohl(tvb, offset + 4); - - if (length < tlvl) break; - length -= tlvl; - - if (tlvl < 8) { - proto_tree_add_text(tree, tvb, offset, 8, - "TLV with invalid length %u (< 8)", - tlvl); - offset += 8; - break; - } - else { - ttext = val_to_str(tlvt, type_nrgyz_vals, "Unknown (0x%04x)"); - switch (tlvt) { - case TYPE_NRGYZ_ROLE: - case TYPE_NRGYZ_DOMAIN: - case TYPE_NRGYZ_NAME: - it = proto_tree_add_text(tree, tvb, offset, - tlvl, "EnergyWise %s: %s", ttext, - tvb_format_stringzpad(tvb, - offset + 8, tlvl - 8) - ); - break; - case TYPE_NRGYZ_REPLYTO: - ip_addr = tvb_get_ipv4(tvb, offset + 12); - it = proto_tree_add_text(tree, tvb, offset, - tlvl, "EnergyWise %s: %s port %u", - ttext, - ip_to_str((guint8 *)&ip_addr), - tvb_get_ntohs(tvb, offset + 10) - ); - break; - default: - it = proto_tree_add_text(tree, tvb, offset, - tlvl, "EnergyWise %s TLV", ttext); - } - etree = proto_item_add_subtree(it, ett_cdp_nrgyz_tlv); - proto_tree_add_text(etree, tvb, offset, 4, - "TLV Type: %x (%s)", tlvt, ttext); - proto_tree_add_text(etree, tvb, offset + 4, 4, - "TLV Length: %u", tlvl); - switch (tlvt) { - case TYPE_NRGYZ_ROLE: - case TYPE_NRGYZ_DOMAIN: - case TYPE_NRGYZ_NAME: - proto_tree_add_text(etree, tvb, offset + 8, - tlvl - 8, "%s %s", ttext, - tvb_format_stringzpad(tvb, - offset + 8, tlvl - 8) - ); - break; - case TYPE_NRGYZ_REPLYTO: - ip_addr = tvb_get_ipv4(tvb, offset + 12); - proto_tree_add_text(etree, tvb, offset + 8, 2, - "Unknown Field"); - proto_tree_add_text(etree, tvb, offset + 10, 2, - "Port %d", - tvb_get_ntohs(tvb, offset + 10) - ); - proto_tree_add_text(etree, tvb, offset + 12, 4, - "IP Address %s", - ip_to_str((guint8 *)&ip_addr) - ); - proto_tree_add_text(etree, tvb, offset + 16, 2, - "Unknown Field (Backup server Port?)"); - proto_tree_add_text(etree, tvb, offset + 18, 4, - "Unknown Field (Backup Server IP?)"); - break; - default: - if (tlvl > 8) { - proto_tree_add_text(etree, tvb, offset + 8, - tlvl - 8, "Data"); - } - } - offset += tlvl; - } + while (num-- && (length >= 8)) { + tlvt = tvb_get_ntohl(tvb, offset); + tlvl = tvb_get_ntohl(tvb, offset + 4); + + if (length < tlvl) + break; + length -= tlvl; + + if (tlvl < 8) { + proto_tree_add_text(tree, tvb, offset, 8, + "TLV with invalid length %u (< 8)", + tlvl); + offset += 8; + break; + } + else { + ttext = val_to_str(tlvt, type_nrgyz_vals, "Unknown (0x%04x)"); + switch (tlvt) { + case TYPE_NRGYZ_ROLE: + case TYPE_NRGYZ_DOMAIN: + case TYPE_NRGYZ_NAME: + it = proto_tree_add_text(tree, tvb, offset, + tlvl, "EnergyWise %s: %s", ttext, + tvb_format_stringzpad(tvb, offset + 8, tlvl - 8) + ); + break; + case TYPE_NRGYZ_REPLYTO: + ip_addr = tvb_get_ipv4(tvb, offset + 12); + it = proto_tree_add_text(tree, tvb, offset, + tlvl, "EnergyWise %s: %s port %u", + ttext, + ip_to_str((guint8 *)&ip_addr), + tvb_get_ntohs(tvb, offset + 10) + ); + break; + default: + it = proto_tree_add_text(tree, tvb, offset, + tlvl, "EnergyWise %s TLV", ttext); + } + etree = proto_item_add_subtree(it, ett_cdp_nrgyz_tlv); + proto_tree_add_text(etree, tvb, offset, 4, + "TLV Type: %x (%s)", tlvt, ttext); + proto_tree_add_text(etree, tvb, offset + 4, 4, + "TLV Length: %u", tlvl); + switch (tlvt) { + case TYPE_NRGYZ_ROLE: + case TYPE_NRGYZ_DOMAIN: + case TYPE_NRGYZ_NAME: + proto_tree_add_text(etree, tvb, offset + 8, + tlvl - 8, "%s %s", ttext, + tvb_format_stringzpad(tvb, offset + 8, tlvl - 8) + ); + break; + case TYPE_NRGYZ_REPLYTO: + ip_addr = tvb_get_ipv4(tvb, offset + 12); + proto_tree_add_text(etree, tvb, offset + 8, 2, + "Unknown Field"); + proto_tree_add_text(etree, tvb, offset + 10, 2, + "Port %d", + tvb_get_ntohs(tvb, offset + 10) + ); + proto_tree_add_text(etree, tvb, offset + 12, 4, + "IP Address %s", + ip_to_str((guint8 *)&ip_addr) + ); + proto_tree_add_text(etree, tvb, offset + 16, 2, + "Unknown Field (Backup server Port?)"); + proto_tree_add_text(etree, tvb, offset + 18, 4, + "Unknown Field (Backup Server IP?)"); + break; + default: + if (tlvl > 8) { + proto_tree_add_text(etree, tvb, offset + 8, + tlvl - 8, "Data"); + } + } + offset += tlvl; + } } if (length) { - proto_tree_add_text(tree, tvb, offset, length, - "Invalid garbage at end"); + proto_tree_add_text(tree, tvb, offset, length, + "Invalid garbage at end"); } } static void dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, - proto_tree *tree) + proto_tree *tree) { proto_item *ti; proto_tree *tlv_tree; - guint8 tlv_data; + guint8 tlv_data; if (length == 0) { return; @@ -1189,52 +1186,52 @@ dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, tlv_data = tvb_get_guint8(tvb, offset); ti = proto_tree_add_text(tree, tvb, offset, length, - "Spare Pair PoE: 0x%02x", tlv_data); + "Spare Pair PoE: 0x%02x", tlv_data); tlv_tree = proto_item_add_subtree(ti, ett_cdp_spare_poe_tlv); proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", decode_boolean_bitfield(tlv_data, 0x01, 8, - "PSE Four-Wire PoE Supported", - "PSE Four-Wire PoE Not Supported")); + "PSE Four-Wire PoE Supported", + "PSE Four-Wire PoE Not Supported")); proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", decode_boolean_bitfield(tlv_data, 0x02, 8, - "PD Spare Pair Architecture Shared", - "PD Spare Pair Architecture Independent")); + "PD Spare Pair Architecture Shared", + "PD Spare Pair Architecture Independent")); proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", decode_boolean_bitfield(tlv_data, 0x04, 8, - "PD Request Spare Pair PoE On", - "PD Request Spare Pair PoE Off")); + "PD Request Spare Pair PoE On", + "PD Request Spare Pair PoE Off")); proto_tree_add_text(tlv_tree, tvb, offset, 1, "%s", decode_boolean_bitfield(tlv_data, 0x08, 8, - "PSE Spare Pair PoE On", - "PSE Spare Pair PoE Off")); + "PSE Spare Pair PoE On", + "PSE Spare Pair PoE Off")); } static void add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, gint len, const gchar *prefix) { - int prefix_len; - int i; + int prefix_len; + int i; char blanks[64+1]; gint next; - int line_len; - int data_len; + int line_len; + int data_len; prefix_len = (int)strlen(prefix); if (prefix_len > 64) - prefix_len = 64; + prefix_len = 64; for (i = 0; i < prefix_len; i++) - blanks[i] = ' '; + blanks[i] = ' '; blanks[i] = '\0'; while (len > 0) { - line_len = tvb_find_line_end(tvb, start, len, &next, FALSE); - data_len = next - start; - proto_tree_add_text(tree, tvb, start, data_len, "%s%s", prefix, - tvb_format_stringzpad(tvb, start, line_len)); - start += data_len; - len -= data_len; - prefix = blanks; + line_len = tvb_find_line_end(tvb, start, len, &next, FALSE); + data_len = next - start; + proto_tree_add_text(tree, tvb, start, data_len, "%s%s", prefix, + tvb_format_stringzpad(tvb, start, line_len)); + start += data_len; + len -= data_len; + prefix = blanks; } } @@ -1242,58 +1239,58 @@ void proto_register_cdp(void) { static hf_register_info hf[] = { - { &hf_cdp_version, - { "Version", "cdp.version", FT_UINT8, BASE_DEC, NULL, 0x0, - NULL, HFILL }}, + { &hf_cdp_version, + { "Version", "cdp.version", FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, - { &hf_cdp_ttl, - { "TTL", "cdp.ttl", FT_UINT16, BASE_DEC, NULL, 0x0, - NULL, HFILL }}, + { &hf_cdp_ttl, + { "TTL", "cdp.ttl", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, - { &hf_cdp_checksum, - { "Checksum", "cdp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, - NULL, HFILL }}, + { &hf_cdp_checksum, + { "Checksum", "cdp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, - { &hf_cdp_checksum_good, - { "Good", "cdp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }}, + { &hf_cdp_checksum_good, + { "Good", "cdp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }}, - { &hf_cdp_checksum_bad, - { "Bad", "cdp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }}, + { &hf_cdp_checksum_bad, + { "Bad", "cdp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }}, - { &hf_cdp_tlvtype, - { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0, - NULL, HFILL }}, + { &hf_cdp_tlvtype, + { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0, + NULL, HFILL }}, - { &hf_cdp_tlvlength, - { "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0, - NULL, HFILL }}, + { &hf_cdp_tlvlength, + { "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, - { &hf_cdp_deviceid, - {"Device ID", "cdp.deviceid", FT_STRING, BASE_NONE, - NULL, 0, NULL, HFILL }}, + { &hf_cdp_deviceid, + {"Device ID", "cdp.deviceid", FT_STRING, BASE_NONE, + NULL, 0, NULL, HFILL }}, - { &hf_cdp_platform, - {"Platform", "cdp.platform", FT_STRING, BASE_NONE, - NULL, 0, NULL, HFILL }}, + { &hf_cdp_platform, + {"Platform", "cdp.platform", FT_STRING, BASE_NONE, + NULL, 0, NULL, HFILL }}, - { &hf_cdp_portid, - {"Sent through Interface", "cdp.portid", FT_STRING, BASE_NONE, - NULL, 0, NULL, HFILL }} + { &hf_cdp_portid, + {"Sent through Interface", "cdp.portid", FT_STRING, BASE_NONE, + NULL, 0, NULL, HFILL }} }; static gint *ett[] = { - &ett_cdp, - &ett_cdp_tlv, - &ett_cdp_nrgyz_tlv, - &ett_cdp_address, - &ett_cdp_capabilities, - &ett_cdp_checksum, - &ett_cdp_spare_poe_tlv + &ett_cdp, + &ett_cdp_tlv, + &ett_cdp_nrgyz_tlv, + &ett_cdp_address, + &ett_cdp_capabilities, + &ett_cdp_checksum, + &ett_cdp_spare_poe_tlv }; proto_cdp = proto_register_protocol("Cisco Discovery Protocol", - "CDP", "cdp"); + "CDP", "cdp"); proto_register_field_array(proto_cdp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } @@ -1304,8 +1301,8 @@ proto_reg_handoff_cdp(void) dissector_handle_t cdp_handle; data_handle = find_dissector("data"); - cdp_handle = create_dissector_handle(dissect_cdp, proto_cdp); + cdp_handle = create_dissector_handle(dissect_cdp, proto_cdp); dissector_add_uint("llc.cisco_pid", 0x2000, cdp_handle); - dissector_add_uint("chdlctype", 0x2000, cdp_handle); - dissector_add_uint("ppp.protocol", 0x0207, cdp_handle); + dissector_add_uint("chdlctype", 0x2000, cdp_handle); + dissector_add_uint("ppp.protocol", 0x0207, cdp_handle); } diff --git a/epan/dissectors/packet-chdlc.c b/epan/dissectors/packet-chdlc.c index a26b60f37d..8553d3a344 100644 --- a/epan/dissectors/packet-chdlc.c +++ b/epan/dissectors/packet-chdlc.c @@ -40,7 +40,7 @@ /* * See section 4.3.1 of RFC 1547, and * - * http://www.nethelp.no/net/cisco-hdlc.txt + * http://www.nethelp.no/net/cisco-hdlc.txt */ static int proto_chdlc = -1; @@ -76,31 +76,31 @@ static dissector_handle_t data_handle; * wouldn't be in the Ethernet dissector table, and check that * table first and the Ethernet dissector table if that fails. */ -#define CISCO_SLARP 0x8035 /* Cisco SLARP protocol */ +#define CISCO_SLARP 0x8035 /* Cisco SLARP protocol */ static dissector_table_t subdissector_table; static const value_string chdlc_address_vals[] = { - {CHDLC_ADDR_UNICAST, "Unicast"}, - {CHDLC_ADDR_MULTICAST, "Multicast"}, - {0, NULL} + {CHDLC_ADDR_UNICAST, "Unicast"}, + {CHDLC_ADDR_MULTICAST, "Multicast"}, + {0, NULL} }; const value_string chdlc_vals[] = { - {0x2000, "Cisco Discovery Protocol"}, - {ETHERTYPE_IP, "IP"}, - {ETHERTYPE_IPv6, "IPv6"}, - {CISCO_SLARP, "SLARP"}, - {ETHERTYPE_DEC_LB, "DEC LanBridge"}, - {CHDLCTYPE_BPDU, "Spanning Tree BPDU"}, - {ETHERTYPE_ATALK, "Appletalk"}, - {ETHERTYPE_AARP, "AARP"}, - {ETHERTYPE_IPX, "Netware IPX/SPX"}, - {ETHERTYPE_ETHBRIDGE, "Transparent Ethernet bridging" }, - {CHDLCTYPE_OSI, "OSI" }, - {ETHERTYPE_MPLS, "MPLS unicast"}, - {ETHERTYPE_MPLS_MULTI, "MPLS multicast"}, - {0, NULL} + {0x2000, "Cisco Discovery Protocol"}, + {ETHERTYPE_IP, "IP"}, + {ETHERTYPE_IPv6, "IPv6"}, + {CISCO_SLARP, "SLARP"}, + {ETHERTYPE_DEC_LB, "DEC LanBridge"}, + {CHDLCTYPE_BPDU, "Spanning Tree BPDU"}, + {ETHERTYPE_ATALK, "Appletalk"}, + {ETHERTYPE_AARP, "AARP"}, + {ETHERTYPE_IPX, "Netware IPX/SPX"}, + {ETHERTYPE_ETHBRIDGE, "Transparent Ethernet bridging" }, + {CHDLCTYPE_OSI, "OSI" }, + {ETHERTYPE_MPLS, "MPLS unicast"}, + {ETHERTYPE_MPLS_MULTI, "MPLS multicast"}, + {0, NULL} }; void @@ -121,15 +121,15 @@ capture_chdlc( const guchar *pd, int offset, int len, packet_counts *ld ) { void chdlctype(guint16 chdlc_type, tvbuff_t *tvb, int offset_after_chdlctype, - packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, - int chdlctype_id) + packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, + int chdlctype_id) { - tvbuff_t *next_tvb; - int padbyte = 0; + tvbuff_t *next_tvb; + int padbyte = 0; if (tree) { proto_tree_add_uint(fh_tree, chdlctype_id, tvb, - offset_after_chdlctype - 2, 2, chdlc_type); + offset_after_chdlctype - 2, 2, chdlc_type); } padbyte = tvb_get_guint8(tvb, offset_after_chdlctype); @@ -147,7 +147,7 @@ chdlctype(guint16 chdlc_type, tvbuff_t *tvb, int offset_after_chdlctype, /* do lookup with the subdissector table */ if (!dissector_try_uint(subdissector_table, chdlc_type, next_tvb, pinfo, tree)) { - col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", chdlc_type); + col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", chdlc_type); call_dissector(data_handle,next_tvb, pinfo, tree); } } @@ -159,8 +159,8 @@ dissect_chdlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; proto_tree *fh_tree = NULL; - guint8 addr; - guint16 proto; + guint8 addr; + guint16 proto; col_set_str(pinfo->cinfo, COL_PROTOCOL, "CHDLC"); col_clear(pinfo->cinfo, COL_INFO); @@ -221,7 +221,7 @@ proto_register_chdlc(void) /* subdissector code */ subdissector_table = register_dissector_table("chdlctype", - "Cisco HDLC frame type", FT_UINT16, BASE_HEX); + "Cisco HDLC frame type", FT_UINT16, BASE_HEX); register_dissector("chdlc", dissect_chdlc, proto_chdlc); @@ -229,11 +229,11 @@ proto_register_chdlc(void) chdlc_module = prefs_register_protocol(proto_chdlc, NULL); prefs_register_enum_preference(chdlc_module, - "fcs_type", - "CHDLC Frame Checksum Type", - "The type of CHDLC frame checksum (none, 16-bit, 32-bit)", - &chdlc_fcs_decode, - fcs_options, ENC_BIG_ENDIAN); + "fcs_type", + "CHDLC Frame Checksum Type", + "The type of CHDLC frame checksum (none, 16-bit, 32-bit)", + &chdlc_fcs_decode, + fcs_options, ENC_BIG_ENDIAN); } @@ -242,21 +242,24 @@ proto_reg_handoff_chdlc(void) { dissector_handle_t chdlc_handle; - data_handle = find_dissector("data"); + data_handle = find_dissector("data"); chdlc_handle = find_dissector("chdlc"); dissector_add_uint("wtap_encap", WTAP_ENCAP_CHDLC, chdlc_handle); dissector_add_uint("wtap_encap", WTAP_ENCAP_CHDLC_WITH_PHDR, chdlc_handle); } -#define SLARP_REQUEST 0 -#define SLARP_REPLY 1 -#define SLARP_LINECHECK 2 + + + +#define SLARP_REQUEST 0 +#define SLARP_REPLY 1 +#define SLARP_LINECHECK 2 static const value_string slarp_ptype_vals[] = { - {SLARP_REQUEST, "Request"}, - {SLARP_REPLY, "Reply"}, - {SLARP_LINECHECK, "Line keepalive"}, - {0, NULL} + {SLARP_REQUEST, "Request"}, + {SLARP_REPLY, "Reply"}, + {SLARP_LINECHECK, "Line keepalive"}, + {0, NULL} }; static void @@ -264,10 +267,10 @@ dissect_slarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; proto_tree *slarp_tree = NULL; - guint32 code; - guint32 addr; - guint32 mysequence; - guint32 yoursequence; + guint32 code; + guint32 addr; + guint32 mysequence; + guint32 yoursequence; col_set_str(pinfo->cinfo, COL_PROTOCOL, "SLARP"); col_clear(pinfo->cinfo, COL_INFO); @@ -283,31 +286,31 @@ dissect_slarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case SLARP_REQUEST: case SLARP_REPLY: - addr = tvb_get_ipv4(tvb, 4); - col_add_fstr(pinfo->cinfo, COL_INFO, "%s, from %s, mask %s", - val_to_str(code, slarp_ptype_vals, "Unknown (%d)"), - get_hostname(addr), tvb_ip_to_str(tvb, 8)); + addr = tvb_get_ipv4(tvb, 4); + col_add_fstr(pinfo->cinfo, COL_INFO, "%s, from %s, mask %s", + val_to_str(code, slarp_ptype_vals, "Unknown (%d)"), + get_hostname(addr), tvb_ip_to_str(tvb, 8)); if (tree) { proto_tree_add_uint(slarp_tree, hf_slarp_ptype, tvb, 0, 4, code); proto_tree_add_item(slarp_tree, hf_slarp_address, tvb, 4, 4, ENC_BIG_ENDIAN); proto_tree_add_text(slarp_tree, tvb, 8, 4, - "Netmask: %s", tvb_ip_to_str(tvb, 8)); + "Netmask: %s", tvb_ip_to_str(tvb, 8)); } break; case SLARP_LINECHECK: mysequence = tvb_get_ntohl(tvb, 4); yoursequence = tvb_get_ntohl(tvb, 8); - col_add_fstr(pinfo->cinfo, COL_INFO, - "%s, outgoing sequence %u, returned sequence %u", - val_to_str(code, slarp_ptype_vals, "Unknown (%d)"), - mysequence, yoursequence); + col_add_fstr(pinfo->cinfo, COL_INFO, + "%s, outgoing sequence %u, returned sequence %u", + val_to_str(code, slarp_ptype_vals, "Unknown (%d)"), + mysequence, yoursequence); if (tree) { proto_tree_add_uint(slarp_tree, hf_slarp_ptype, tvb, 0, 4, code); proto_tree_add_uint(slarp_tree, hf_slarp_mysequence, tvb, 4, 4, - mysequence); + mysequence); proto_tree_add_uint(slarp_tree, hf_slarp_mysequence, tvb, 8, 4, - yoursequence); + yoursequence); } break; @@ -316,7 +319,7 @@ dissect_slarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { proto_tree_add_uint(slarp_tree, hf_slarp_ptype, tvb, 0, 4, code); call_dissector(data_handle, tvb_new_subset_remaining(tvb, 4), pinfo, - slarp_tree); + slarp_tree); } break; } diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c index af687f5f5a..d895565b70 100644 --- a/epan/dissectors/packet-clnp.c +++ b/epan/dissectors/packet-clnp.c @@ -29,8 +29,8 @@ #endif #include <glib.h> -#include <epan/prefs.h> #include <epan/packet.h> +#include <epan/prefs.h> #include <epan/reassemble.h> #include "packet-frame.h" #include "packet-osi.h" @@ -188,33 +188,34 @@ static gboolean clnp_reassemble = TRUE; * CLNP part / main entry point */ -static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static void +dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *clnp_tree = NULL; - proto_item *ti; - guint8 cnf_proto_id; - guint8 cnf_hdr_len; - guint8 cnf_vers; - guint8 cnf_ttl; - guint8 cnf_type; - char flag_string[6+1]; - const char *pdu_type_string; - proto_tree *type_tree; - guint16 segment_length; - guint16 du_id = 0; - guint16 segment_offset = 0; - guint16 cnf_cksum; - cksum_status_t cksum_status; - int offset; - guchar src_len, dst_len, nsel, opt_len = 0; - const guint8 *dst_addr, *src_addr; - guint next_length; - proto_tree *discpdu_tree; - gboolean save_in_error_pkt; - fragment_data *fd_head; - tvbuff_t *next_tvb; - gboolean update_col_info = TRUE; - gboolean save_fragmented; + proto_tree *clnp_tree = NULL; + proto_item *ti; + guint8 cnf_proto_id; + guint8 cnf_hdr_len; + guint8 cnf_vers; + guint8 cnf_ttl; + guint8 cnf_type; + char flag_string[6+1]; + const char *pdu_type_string; + proto_tree *type_tree; + guint16 segment_length; + guint16 du_id = 0; + guint16 segment_offset = 0; + guint16 cnf_cksum; + cksum_status_t cksum_status; + int offset; + guchar src_len, dst_len, nsel, opt_len = 0; + const guint8 *dst_addr, *src_addr; + guint next_length; + proto_tree *discpdu_tree; + gboolean save_in_error_pkt; + fragment_data *fd_head; + tvbuff_t *next_tvb; + gboolean update_col_info = TRUE; + gboolean save_fragmented; col_set_str(pinfo->cinfo, COL_PROTOCOL, "CLNP"); col_clear(pinfo->cinfo, COL_INFO); @@ -510,7 +511,7 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) part of the discarded PDU", i.e. it's like an ICMP error; dissect it as a CLNP PDU. */ - col_add_fstr(pinfo->cinfo, COL_INFO, "%s NPDU %s", pdu_type_string, flag_string); + col_add_fstr(pinfo->cinfo, COL_INFO, "%s NPDU %s", pdu_type_string, flag_string); next_length = tvb_length_remaining(tvb, offset); if (next_length != 0) { /* We have payload; dissect it. */ @@ -551,7 +552,8 @@ clnp_reassemble_init(void) reassembled_table_init(&clnp_reassembled_table); } -void proto_register_clnp(void) +void +proto_register_clnp(void) { static hf_register_info hf[] = { { &hf_clnp_id, diff --git a/epan/dissectors/packet-cmpp.c b/epan/dissectors/packet-cmpp.c index f6bdf478ab..c5b381a7f2 100644 --- a/epan/dissectors/packet-cmpp.c +++ b/epan/dissectors/packet-cmpp.c @@ -27,18 +27,16 @@ # include "config.h" #endif -#include <stdlib.h> - #include <epan/packet.h> #include <epan/dissectors/packet-tcp.h> -#define CMPP_FIX_HEADER_LENGTH 12 +#define CMPP_FIX_HEADER_LENGTH 12 #define CMPP_DELIVER_REPORT_LEN 71 /* These are not registered with IANA */ -#define CMPP_SP_LONG_PORT 7890 -#define CMPP_SP_SHORT_PORT 7900 -#define CMPP_ISMG_LONG_PORT 7930 +#define CMPP_SP_LONG_PORT 7890 +#define CMPP_SP_SHORT_PORT 7900 +#define CMPP_ISMG_LONG_PORT 7930 #define CMPP_ISMG_SHORT_PORT 9168 /* Initialize the protocol and registered fields */ @@ -152,39 +150,39 @@ static gboolean cmpp_desegment = TRUE; #define CMPP_PUSH_MO_ROUTE_UPDATE_RESP 0x80000016 #define CMPP_GET_MO_ROUTE_RESP 0x80000017 static const value_string vals_command_Id[] = { /* Operation */ - { CMPP_CONNECT, "CMPP_CONNECT" }, - { CMPP_CONNECT_RESP, "CMPP_CONNECT_RESP" }, - { CMPP_TERMINATE, "CMPP_TERMINATE" }, - { CMPP_TERMINATE_RESP, "CMPP_TERMINATE_RESP" }, - { CMPP_SUBMIT, "CMPP_SUBMIT" }, - { CMPP_SUBMIT_RESP, "CMPP_SUBMIT_RESP" }, - { CMPP_DELIVER, "CMPP_DELIVER" }, - { CMPP_DELIVER_RESP, "CMPP_DELIVER_RESP" }, - { CMPP_QUERY, "CMPP_QUERY" }, - { CMPP_QUERY_RESP, "CMPP_QUERY" }, - { CMPP_CANCEL, "CMPP_CANCEL" }, - { CMPP_CANCEL_RESP, "CMPP_CANCEL_RESP" }, - { CMPP_ACTIVE_TEST, "CMPP_ACTIVE_TEST" }, - { CMPP_ACTIVE_TEST_RESP, "CMPP_ACTIVE_TEST_RESP" }, - { CMPP_FWD, "CMPP_FWD" }, - { CMPP_FWD_RESP, "CMPP_FWD_RESP" }, - { CMPP_MT_ROUTE, "CMPP_MT_ROUTE" }, - { CMPP_MO_ROUTE, "CMPP_MO_ROUTE" }, - { CMPP_GET_MT_ROUTE, "CMPP_GET_MT_ROUTE" }, - { CMPP_MT_ROUTE_UPDATE, "CMPP_MT_ROUTE_UPDATE" }, - { CMPP_MO_ROUTE_UPDATE, "CMPP_MO_ROUTE_UPDATE" }, - { CMPP_PUSH_MT_ROUTE_UPDATE, "CMPP_PUSH_MT_ROUTE_UPDATE" }, - { CMPP_PUSH_MO_ROUTE_UPDATE, "CMPP_PUSH_MO_ROUTE_UPDATE" }, - { CMPP_GET_MO_ROUTE, "CMPP_GET_MO_ROUTE" }, - { CMPP_MT_ROUTE_RESP, "CMPP_MT_ROUTE_RESP" }, - { CMPP_MO_ROUTE_RESP, "CMPP_MO_ROUTE_RESP" }, - { CMPP_GET_MT_ROUTE_RESP, "CMPP_GET_MT_ROUTE_RESP" }, - { CMPP_MT_ROUTE_UPDATE_RESP, "CMPP_MT_ROUTE_UPDATE_RESP" }, - { CMPP_MO_ROUTE_UPDATE_RESP, "CMPP_MO_ROUTE_UPDATE_RESP" }, - { CMPP_PUSH_MT_ROUTE_UPDATE_RESP, "CMPP_PUSH_MT_ROUTE_UPDATE_RESP" }, - { CMPP_PUSH_MO_ROUTE_UPDATE_RESP, "CMPP_PUSH_MO_ROUTE_UPDATE_RESP" }, - { CMPP_GET_MO_ROUTE_RESP, "CMPP_GET_MO_ROUTE_RESP" }, - { 0, NULL } + { CMPP_CONNECT, "CMPP_CONNECT" }, + { CMPP_CONNECT_RESP, "CMPP_CONNECT_RESP" }, + { CMPP_TERMINATE, "CMPP_TERMINATE" }, + { CMPP_TERMINATE_RESP, "CMPP_TERMINATE_RESP" }, + { CMPP_SUBMIT, "CMPP_SUBMIT" }, + { CMPP_SUBMIT_RESP, "CMPP_SUBMIT_RESP" }, + { CMPP_DELIVER, "CMPP_DELIVER" }, + { CMPP_DELIVER_RESP, "CMPP_DELIVER_RESP" }, + { CMPP_QUERY, "CMPP_QUERY" }, + { CMPP_QUERY_RESP, "CMPP_QUERY" }, + { CMPP_CANCEL, "CMPP_CANCEL" }, + { CMPP_CANCEL_RESP, "CMPP_CANCEL_RESP" }, + { CMPP_ACTIVE_TEST, "CMPP_ACTIVE_TEST" }, + { CMPP_ACTIVE_TEST_RESP, "CMPP_ACTIVE_TEST_RESP" }, + { CMPP_FWD, "CMPP_FWD" }, + { CMPP_FWD_RESP, "CMPP_FWD_RESP" }, + { CMPP_MT_ROUTE, "CMPP_MT_ROUTE" }, + { CMPP_MO_ROUTE, "CMPP_MO_ROUTE" }, + { CMPP_GET_MT_ROUTE, "CMPP_GET_MT_ROUTE" }, + { CMPP_MT_ROUTE_UPDATE, "CMPP_MT_ROUTE_UPDATE" }, + { CMPP_MO_ROUTE_UPDATE, "CMPP_MO_ROUTE_UPDATE" }, + { CMPP_PUSH_MT_ROUTE_UPDATE, "CMPP_PUSH_MT_ROUTE_UPDATE" }, + { CMPP_PUSH_MO_ROUTE_UPDATE, "CMPP_PUSH_MO_ROUTE_UPDATE" }, + { CMPP_GET_MO_ROUTE, "CMPP_GET_MO_ROUTE" }, + { CMPP_MT_ROUTE_RESP, "CMPP_MT_ROUTE_RESP" }, + { CMPP_MO_ROUTE_RESP, "CMPP_MO_ROUTE_RESP" }, + { CMPP_GET_MT_ROUTE_RESP, "CMPP_GET_MT_ROUTE_RESP" }, + { CMPP_MT_ROUTE_UPDATE_RESP, "CMPP_MT_ROUTE_UPDATE_RESP" }, + { CMPP_MO_ROUTE_UPDATE_RESP, "CMPP_MO_ROUTE_UPDATE_RESP" }, + { CMPP_PUSH_MT_ROUTE_UPDATE_RESP, "CMPP_PUSH_MT_ROUTE_UPDATE_RESP" }, + { CMPP_PUSH_MO_ROUTE_UPDATE_RESP, "CMPP_PUSH_MO_ROUTE_UPDATE_RESP" }, + { CMPP_GET_MO_ROUTE_RESP, "CMPP_GET_MO_ROUTE_RESP" }, + { 0, NULL } }; static const value_string vals_connect_resp_status[] = { /* Connection Status */ @@ -266,13 +264,13 @@ cmpp_octet_string(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset, gint static char* cmpp_version(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) { - gint8 version, major, minor; - char *strval; + gint8 version, major, minor; + char *strval; version = tvb_get_guint8(tvb, offset); - minor = version & 0x0F; - major = (version & 0xF0) >> 4; - strval = ep_strdup_printf("%02u.%02u", major, minor); + minor = version & 0x0F; + major = (version & 0xF0) >> 4; + strval = ep_strdup_printf("%02u.%02u", major, minor); /* TODO: the version should be added as a uint_format */ proto_tree_add_string(tree, field, tvb, offset, 1, strval); return strval; @@ -281,9 +279,9 @@ cmpp_version(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) static char* cmpp_timestamp(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) { - gint8 month, day, hour, minute, second; - gint32 timevalue; - char *strval; + gint8 month, day, hour, minute, second; + gint32 timevalue; + char *strval; timevalue = tvb_get_ntohl(tvb, offset); second = timevalue % 100; @@ -344,11 +342,11 @@ cmpp_boolean(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) static void cmpp_msg_id(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) { - guint8 month,day,hour,minute,second; - guint32 ismg_code; + guint8 month,day,hour,minute,second; + guint32 ismg_code; proto_item *pi; proto_tree *sub_tree; - char *strval; + char *strval; pi = proto_tree_add_item(tree, field, tvb, offset, 8, ENC_BIG_ENDIAN); sub_tree = proto_item_add_subtree(pi, ett_msg_id); @@ -398,7 +396,7 @@ cmpp_connect_resp(proto_tree *tree, tvbuff_t *tvb) static void cmpp_submit(proto_tree *tree, tvbuff_t *tvb) { - int offset, i; + int offset, i; guint8 destUsr, msgLen; offset = CMPP_FIX_HEADER_LENGTH; cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset); @@ -493,7 +491,7 @@ cmpp_deliver_report(proto_tree *tree, tvbuff_t *tvb, gint field, guint offset) static void cmpp_deliver(proto_tree *tree, tvbuff_t *tvb) { - guint offset, msgLen; + guint offset, msgLen; gboolean report; offset = CMPP_FIX_HEADER_LENGTH; cmpp_msg_id(tree, tvb, hf_cmpp_msg_id, offset); @@ -541,11 +539,11 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Set up structures needed to add the protocol subtree and manage it */ - proto_item *ti; - proto_tree *cmpp_tree; - guint command_id; - guint tvb_len; - guint total_length; + proto_item *ti; + proto_tree *cmpp_tree; + guint command_id; + guint tvb_len; + guint total_length; const gchar *command_str; /* Header command string */ /* Get the length of the PDU */ @@ -625,7 +623,7 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static guint get_cmpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, gint offset) { - return tvb_get_ntohl(tvb, offset); + return tvb_get_ntohl(tvb, offset); } @@ -664,296 +662,293 @@ dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Register the protocol with Wireshark */ -/* this format is require because a script is used to build the C function - that calls all the protocol registration. -*/ void proto_register_cmpp(void) { /* Setup list of header fields See Section 1.6.1 for details*/ static hf_register_info hf[] = { { &hf_cmpp_Total_Length, - { "Total Length", "cmpp.Total_Length", - FT_UINT32, BASE_DEC, NULL, 0x00, - "Total length of the CMPP PDU.", - HFILL } + { "Total Length", "cmpp.Total_Length", + FT_UINT32, BASE_DEC, NULL, 0x00, + "Total length of the CMPP PDU.", + HFILL } }, { &hf_cmpp_Command_Id, - { "Command Id", "cmpp.Command_Id", - FT_UINT32, BASE_HEX, VALS(vals_command_Id), 0x00, - "Command Id of the CMPP messages", - HFILL } + { "Command Id", "cmpp.Command_Id", + FT_UINT32, BASE_HEX, VALS(vals_command_Id), 0x00, + "Command Id of the CMPP messages", + HFILL } }, { &hf_cmpp_Sequence_Id, - { "Sequence Id", "cmpp.Sequence_Id", - FT_UINT32, BASE_DEC, NULL, 0x00, - "Sequence Id of the CMPP messages", - HFILL } + { "Sequence Id", "cmpp.Sequence_Id", + FT_UINT32, BASE_DEC, NULL, 0x00, + "Sequence Id of the CMPP messages", + HFILL } }, { &hf_cmpp_connect_Source_Addr, - { "Source Addr", "cmpp.connect.Source_Addr", - FT_STRING, BASE_NONE, NULL, 0x00, - "Source Address, the SP_Id", - HFILL } + { "Source Addr", "cmpp.connect.Source_Addr", + FT_STRING, BASE_NONE, NULL, 0x00, + "Source Address, the SP_Id", + HFILL } }, { &hf_cmpp_connect_AuthenticatorSource, - { "Authenticator Source", "cmpp.connect.AuthenticatorSource", - FT_STRING, BASE_NONE, NULL, 0x00, - "Authenticator source, MD5(Source_addr + 9 zero + shared secret + timestamp)", - HFILL } + { "Authenticator Source", "cmpp.connect.AuthenticatorSource", + FT_STRING, BASE_NONE, NULL, 0x00, + "Authenticator source, MD5(Source_addr + 9 zero + shared secret + timestamp)", + HFILL } }, { &hf_cmpp_Version, - { "Version", "cmpp.Version", - FT_STRING, BASE_NONE, NULL, 0x00, - "CMPP Version", - HFILL } + { "Version", "cmpp.Version", + FT_STRING, BASE_NONE, NULL, 0x00, + "CMPP Version", + HFILL } }, { &hf_cmpp_connect_Timestamp, - { "Timestamp", "cmpp.connect.Timestamp", - FT_STRING, BASE_NONE, NULL, 0x00, - "Timestamp MM/DD HH:MM:SS", - HFILL } + { "Timestamp", "cmpp.connect.Timestamp", + FT_STRING, BASE_NONE, NULL, 0x00, + "Timestamp MM/DD HH:MM:SS", + HFILL } }, { &hf_cmpp_connect_resp_status, - { "Connect Response Status", "cmpp.connect_resp.Status", - FT_UINT32, BASE_DEC, VALS(vals_connect_resp_status), 0x00, - "Response Status, Value higher then 4 means other error", - HFILL } + { "Connect Response Status", "cmpp.connect_resp.Status", + FT_UINT32, BASE_DEC, VALS(vals_connect_resp_status), 0x00, + "Response Status, Value higher then 4 means other error", + HFILL } }, { &hf_cmpp_connect_resp_AuthenticatorISMG, - { "SIMG Authenticate result", "cmpp.connect_resp.AuthenticatorISMG", - FT_STRING, BASE_NONE, NULL, 0x00, - "Authenticator result, MD5(Status + AuthenticatorSource + shared secret)", - HFILL } + { "SIMG Authenticate result", "cmpp.connect_resp.AuthenticatorISMG", + FT_STRING, BASE_NONE, NULL, 0x00, + "Authenticator result, MD5(Status + AuthenticatorSource + shared secret)", + HFILL } }, { &hf_cmpp_msg_id, - { "Msg_Id", "cmpp.Msg_Id", - FT_UINT64, BASE_HEX, NULL, 0x00, - "Message ID", - HFILL } + { "Msg_Id", "cmpp.Msg_Id", + FT_UINT64, BASE_HEX, NULL, 0x00, + "Message ID", + HFILL } }, { &hf_cmpp_submit_pk_total, - { "Number of Part", "cmpp.submit.Pk_total", - FT_UINT8, BASE_DEC, NULL, 0x00, - "Total number of parts of the message with the same Msg_Id, start from 1", - HFILL } + { "Number of Part", "cmpp.submit.Pk_total", + FT_UINT8, BASE_DEC, NULL, 0x00, + "Total number of parts of the message with the same Msg_Id, start from 1", + HFILL } }, { &hf_cmpp_submit_pk_number, - { "Part Number", "cmpp.submit.Pk_number", - FT_UINT8, BASE_DEC, NULL, 0x00, - "Part number of the message with the same Msg_Id, start from 1", - HFILL } + { "Part Number", "cmpp.submit.Pk_number", + FT_UINT8, BASE_DEC, NULL, 0x00, + "Part number of the message with the same Msg_Id, start from 1", + HFILL } }, { &hf_msg_id_timestamp, - { "Timestamp", "cmpp.Msg_Id.timestamp", - FT_STRING, BASE_NONE, NULL, 0x00, - "Timestamp MM/DD HH:MM:SS Bit 64 ~ 39", - HFILL } + { "Timestamp", "cmpp.Msg_Id.timestamp", + FT_STRING, BASE_NONE, NULL, 0x00, + "Timestamp MM/DD HH:MM:SS Bit 64 ~ 39", + HFILL } }, { &hf_msg_id_ismg_code, - { "ISMG Code", "cmpp.Msg_Id.ismg_code", - FT_UINT32, BASE_DEC, NULL, 0x00, - "ISMG Code, bit 38 ~ 17", - HFILL } + { "ISMG Code", "cmpp.Msg_Id.ismg_code", + FT_UINT32, BASE_DEC, NULL, 0x00, + "ISMG Code, bit 38 ~ 17", + HFILL } }, { &hf_msg_id_sequence_id, - { "Msg_Id sequence Id", "cmpp.Msg_Id.sequence_id", - FT_UINT16, BASE_DEC, NULL, 0x00, - "Msg_Id sequence Id, bit 16 ~ 1", - HFILL } + { "Msg_Id sequence Id", "cmpp.Msg_Id.sequence_id", + FT_UINT16, BASE_DEC, NULL, 0x00, + "Msg_Id sequence Id, bit 16 ~ 1", + HFILL } }, { &hf_cmpp_submit_Registered_Delivery, - { "Registered Delivery", "cmpp.submit.Registered_Delivery", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "Registered Delivery flag", - HFILL } + { "Registered Delivery", "cmpp.submit.Registered_Delivery", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "Registered Delivery flag", + HFILL } }, { &hf_cmpp_submit_Msg_level, - { "Message Level", "cmpp.submit.Msg_level", - FT_UINT8, BASE_DEC, NULL, 0x00, - NULL, - HFILL } + { "Message Level", "cmpp.submit.Msg_level", + FT_UINT8, BASE_DEC, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_Service_Id, - { "Service ID", "cmpp.Servicd_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "Service ID, a mix of characters, numbers and symbol", - HFILL } + { "Service ID", "cmpp.Servicd_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "Service ID, a mix of characters, numbers and symbol", + HFILL } }, { &hf_cmpp_submit_Fee_UserType, - { "Charging Informations", "cmpp.submit.Fee_UserType", - FT_UINT8, BASE_DEC, VALS(vals_submit_Fee_UserType), 0x00, - "Charging Informations, if value is 3, this field will not be used", - HFILL } + { "Charging Informations", "cmpp.submit.Fee_UserType", + FT_UINT8, BASE_DEC, VALS(vals_submit_Fee_UserType), 0x00, + "Charging Informations, if value is 3, this field will not be used", + HFILL } }, { &hf_cmpp_submit_Fee_terminal_Id, - { "Fee Terminal ID", "cmpp.submit.Fee_terminal_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "Fee Terminal ID, Valid only when Fee_UserType is 3", - HFILL } + { "Fee Terminal ID", "cmpp.submit.Fee_terminal_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "Fee Terminal ID, Valid only when Fee_UserType is 3", + HFILL } }, { &hf_cmpp_submit_Fee_terminal_type, - { "Fake Fee Terminal", "cmpp.submit.Fee_terminal_type", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "Fee terminal type, 0 is real, 1 is fake", - HFILL } + { "Fake Fee Terminal", "cmpp.submit.Fee_terminal_type", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "Fee terminal type, 0 is real, 1 is fake", + HFILL } }, { &hf_cmpp_TP_pId, - { "TP pId", "cmpp.TP_pId", - FT_UINT8, BASE_DEC, NULL, 0x00, - "GSM TP pId Field", - HFILL } + { "TP pId", "cmpp.TP_pId", + FT_UINT8, BASE_DEC, NULL, 0x00, + "GSM TP pId Field", + HFILL } }, { &hf_cmpp_TP_udhi, - { "TP udhi", "cmpp.TP_udhi", - FT_UINT8, BASE_DEC, NULL, 0x00, - "GSM TP udhi field", - HFILL } + { "TP udhi", "cmpp.TP_udhi", + FT_UINT8, BASE_DEC, NULL, 0x00, + "GSM TP udhi field", + HFILL } }, { &hf_cmpp_Msg_Fmt, - { "Message Format", "cmpp.Msg_Fmt", - FT_UINT8, BASE_DEC, VALS(vals_Msg_Fmt), 0x00, - NULL, - HFILL } + { "Message Format", "cmpp.Msg_Fmt", + FT_UINT8, BASE_DEC, VALS(vals_Msg_Fmt), 0x00, + NULL, + HFILL } }, { &hf_cmpp_submit_Msg_src, - { "Message Source SP_Id", "cmpp.submit.Msg_src", - FT_STRING, BASE_NONE, NULL, 0x00, - "Message source SP ID", - HFILL } + { "Message Source SP_Id", "cmpp.submit.Msg_src", + FT_STRING, BASE_NONE, NULL, 0x00, + "Message source SP ID", + HFILL } }, { &hf_cmpp_submit_FeeType, /* TODO Replace this with a vals_string*/ - { "Fee Type", "cmpp.submit.FeeType", - FT_STRING, BASE_NONE, NULL, 0x00, - NULL, - HFILL } + { "Fee Type", "cmpp.submit.FeeType", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_submit_FeeCode, - { "Fee Code", "cmpp.submit.FeeCode", - FT_STRING, BASE_NONE, NULL, 0x00, - NULL, - HFILL } + { "Fee Code", "cmpp.submit.FeeCode", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_submit_Valld_Time, - { "Valid time", "cmpp.submit.Valld_Time", - FT_STRING, BASE_NONE, NULL, 0x00, - "Message Valid Time, format follow SMPP 3.3", - HFILL } + { "Valid time", "cmpp.submit.Valld_Time", + FT_STRING, BASE_NONE, NULL, 0x00, + "Message Valid Time, format follow SMPP 3.3", + HFILL } }, { &hf_cmpp_submit_At_Time, - { "Send time", "cmpp.submit.At_time", - FT_STRING, BASE_NONE, NULL, 0x00, - "Message send time, format following SMPP 3.3", - HFILL } + { "Send time", "cmpp.submit.At_time", + FT_STRING, BASE_NONE, NULL, 0x00, + "Message send time, format following SMPP 3.3", + HFILL } }, { &hf_cmpp_submit_Src_Id, - { "Source ID", "cmpp.submit.Src_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "This value matches SMPP submit_sm source_addr field", - HFILL } + { "Source ID", "cmpp.submit.Src_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "This value matches SMPP submit_sm source_addr field", + HFILL } }, { &hf_cmpp_submit_DestUsr_tl, - { "Destination Address Count", "cmpp.submit.DestUsr_tl", - FT_UINT8, BASE_DEC, NULL, 0x00, - "Number of destination address, must smaller then 100", - HFILL } + { "Destination Address Count", "cmpp.submit.DestUsr_tl", + FT_UINT8, BASE_DEC, NULL, 0x00, + "Number of destination address, must smaller then 100", + HFILL } }, { &hf_cmpp_Dest_terminal_Id, - { "Destination Address", "cmpp.Dest_terminal_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "MSISDN number which receive the SMS", - HFILL } + { "Destination Address", "cmpp.Dest_terminal_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "MSISDN number which receive the SMS", + HFILL } }, { &hf_cmpp_submit_Dest_terminal_type, - { "Fake Destination Terminal", "cmpp.submit.Dest_terminal_type", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "destination terminal type, 0 is real, 1 is fake", - HFILL } + { "Fake Destination Terminal", "cmpp.submit.Dest_terminal_type", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "destination terminal type, 0 is real, 1 is fake", + HFILL } }, { &hf_cmpp_Msg_Length, - { "Message length", "cmpp.Msg_Length", - FT_UINT8, BASE_DEC, NULL, 0x00, - "SMS Message length, ASCII must be <= 160 bytes, other must be <= 140 bytes", - HFILL } + { "Message length", "cmpp.Msg_Length", + FT_UINT8, BASE_DEC, NULL, 0x00, + "SMS Message length, ASCII must be <= 160 bytes, other must be <= 140 bytes", + HFILL } }, { &hf_cmpp_Msg_Content, - { "Message Content", "cmpp.Msg_Content", - FT_STRING, BASE_NONE, NULL, 0x00, - NULL, - HFILL } + { "Message Content", "cmpp.Msg_Content", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_LinkID, - { "Link ID", "cmpp.LinkID", - FT_STRING, BASE_NONE, NULL, 0x00, - NULL, - HFILL } + { "Link ID", "cmpp.LinkID", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_submit_resp_Result, - { "Result", "cmpp.submit_resp.Result", - FT_UINT32, BASE_DEC, VALS(vals_Submit_Resp_Result), 0x00, - "Submit Result", - HFILL } + { "Result", "cmpp.submit_resp.Result", + FT_UINT32, BASE_DEC, VALS(vals_Submit_Resp_Result), 0x00, + "Submit Result", + HFILL } }, { &hf_cmpp_deliver_Dest_Id, - { "Destination ID", "cmpp.deliver.Dest_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "SP Service ID or server number", - HFILL } + { "Destination ID", "cmpp.deliver.Dest_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "SP Service ID or server number", + HFILL } }, { &hf_cmpp_deliver_Src_terminal_Id, - { "Src_terminal_Id", "cmpp.deliver.Src_terminal_Id", - FT_STRING, BASE_NONE, NULL, 0x00, - "Source MSISDN number, if it is deliver report, this will be the CMPP_SUBMIT destination number", - HFILL } + { "Src_terminal_Id", "cmpp.deliver.Src_terminal_Id", + FT_STRING, BASE_NONE, NULL, 0x00, + "Source MSISDN number, if it is deliver report, this will be the CMPP_SUBMIT destination number", + HFILL } }, { &hf_cmpp_deliver_Src_terminal_type, - { "Fake source terminal type", "cmpp.deliver.Src_terminal_type", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "Type of the source terminal, can be 0 (real) or 1 (fake)", - HFILL } + { "Fake source terminal type", "cmpp.deliver.Src_terminal_type", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "Type of the source terminal, can be 0 (real) or 1 (fake)", + HFILL } }, { &hf_cmpp_deliver_Registered_Delivery, - { "Deliver Report", "cmpp.deliver.Registered_Delivery", - FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "The message is a deliver report if this value = 1", - HFILL } + { "Deliver Report", "cmpp.deliver.Registered_Delivery", + FT_BOOLEAN, BASE_NONE, NULL, 0x0, + "The message is a deliver report if this value = 1", + HFILL } }, { &hf_cmpp_deliver_Report, - { "Detail Deliver Report", "cmpp.deliver.Report", - FT_NONE, BASE_NONE, NULL, 0x00, - "The detail report", - HFILL } + { "Detail Deliver Report", "cmpp.deliver.Report", + FT_NONE, BASE_NONE, NULL, 0x00, + "The detail report", + HFILL } }, { &hf_cmpp_deliver_Report_Stat, - { "Deliver Status", "cmpp.deliver.Report.Status", - FT_STRING, BASE_NONE, NULL, 0x00, - NULL, - HFILL } + { "Deliver Status", "cmpp.deliver.Report.Status", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, + HFILL } }, { &hf_cmpp_deliver_Report_Submit_time, - { "Submit_time", "cmpp.deliver.Report.Submit_time", - FT_STRING, BASE_NONE, NULL, 0x00, - "Format YYMMDDHHMM", - HFILL } + { "Submit_time", "cmpp.deliver.Report.Submit_time", + FT_STRING, BASE_NONE, NULL, 0x00, + "Format YYMMDDHHMM", + HFILL } }, { &hf_cmpp_deliver_Report_Done_time, - { "Done_time", "cmpp.deliver.Report.Done_time", - FT_STRING, BASE_NONE, NULL, 0x00, - "Format YYMMDDHHMM", - HFILL } + { "Done_time", "cmpp.deliver.Report.Done_time", + FT_STRING, BASE_NONE, NULL, 0x00, + "Format YYMMDDHHMM", + HFILL } }, { &hf_cmpp_deliver_Report_SMSC_sequence, - { "SMSC_sequence", "cmpp.Report.SMSC_sequence", - FT_UINT32, BASE_DEC, NULL, 0x00, - "Sequence number", - HFILL } + { "SMSC_sequence", "cmpp.Report.SMSC_sequence", + FT_UINT32, BASE_DEC, NULL, 0x00, + "Sequence number", + HFILL } }, { &hf_cmpp_deliver_resp_Result, - { "Result", "cmpp.deliver_resp.Result", - FT_UINT32, BASE_DEC, VALS(vals_Deliver_Resp_Result), 0x00, - "Deliver Result", - HFILL } + { "Result", "cmpp.deliver_resp.Result", + FT_UINT32, BASE_DEC, VALS(vals_Deliver_Resp_Result), 0x00, + "Deliver Result", + HFILL } } }; diff --git a/epan/dissectors/packet-cosine.c b/epan/dissectors/packet-cosine.c index dffd46ef63..ddc0e1ae7e 100644 --- a/epan/dissectors/packet-cosine.c +++ b/epan/dissectors/packet-cosine.c @@ -55,9 +55,9 @@ static dissector_handle_t data_handle; static void dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *fh_tree; - proto_item *ti; - union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header; + proto_tree *fh_tree; + proto_item *ti; + union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header; /* load the top pane info. This should be overwritten by the next protocol in the stack */ @@ -70,8 +70,8 @@ dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) layer (ie none) */ if(tree) { ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0, - "CoSine IPNOS L2 debug output (%s)", - pseudo_header->cosine.if_name); + "CoSine IPNOS L2 debug output (%s)", + pseudo_header->cosine.if_name); fh_tree = proto_item_add_subtree(ti, ett_raw); proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro); proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off); @@ -80,65 +80,65 @@ dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err); switch (pseudo_header->cosine.encap) { + case COSINE_ENCAP_ETH: + break; + case COSINE_ENCAP_ATM: + case COSINE_ENCAP_PPoATM: + proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header"); + break; + case COSINE_ENCAP_PPP: + case COSINE_ENCAP_FR: + case COSINE_ENCAP_PPoFR: + proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID"); + break; + case COSINE_ENCAP_HDLC: + if (pseudo_header->cosine.direction == COSINE_DIR_TX) { + proto_tree_add_text(fh_tree, tvb, 0, 2, + "Channel handle ID"); + } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) { + proto_tree_add_text(fh_tree, tvb, 0, 4, + "Channel handle ID"); + } + break; + default: + break; + } + } + + switch (pseudo_header->cosine.encap) { case COSINE_ENCAP_ETH: - break; + call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0), + pinfo, tree); + break; case COSINE_ENCAP_ATM: case COSINE_ENCAP_PPoATM: - proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header"); - break; + call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16), + pinfo, tree); + break; case COSINE_ENCAP_PPP: + call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4), + pinfo, tree); + break; + case COSINE_ENCAP_HDLC: + if (pseudo_header->cosine.direction == COSINE_DIR_TX) { + call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2), + pinfo, tree); + } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) { + call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4), + pinfo, tree); + } + break; case COSINE_ENCAP_FR: case COSINE_ENCAP_PPoFR: - proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID"); - break; - case COSINE_ENCAP_HDLC: - if (pseudo_header->cosine.direction == COSINE_DIR_TX) { - proto_tree_add_text(fh_tree, tvb, 0, 2, - "Channel handle ID"); - } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) { - proto_tree_add_text(fh_tree, tvb, 0, 4, - "Channel handle ID"); - } - break; + call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4), + pinfo, tree); + break; + case COSINE_ENCAP_TEST: + case COSINE_ENCAP_UNKNOWN: + call_dissector(data_handle, tvb, pinfo, tree); + break; default: - break; - } - } - - switch (pseudo_header->cosine.encap) { - case COSINE_ENCAP_ETH: - call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0), - pinfo, tree); - break; - case COSINE_ENCAP_ATM: - case COSINE_ENCAP_PPoATM: - call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16), - pinfo, tree); - break; - case COSINE_ENCAP_PPP: - call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4), - pinfo, tree); - break; - case COSINE_ENCAP_HDLC: - if (pseudo_header->cosine.direction == COSINE_DIR_TX) { - call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2), - pinfo, tree); - } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) { - call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4), - pinfo, tree); - } - break; - case COSINE_ENCAP_FR: - case COSINE_ENCAP_PPoFR: - call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4), - pinfo, tree); - break; - case COSINE_ENCAP_TEST: - case COSINE_ENCAP_UNKNOWN: - call_dissector(data_handle, tvb, pinfo, tree); - break; - default: - break; + break; } } @@ -153,7 +153,7 @@ proto_register_cosine(void) { &hf_pri, { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, { &hf_rm, - { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, + { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, { &hf_err, { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, }; @@ -163,7 +163,7 @@ proto_register_cosine(void) }; proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output", - "CoSine", "cosine"); + "CoSine", "cosine"); proto_register_field_array(proto_cosine, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } @@ -177,11 +177,11 @@ proto_reg_handoff_cosine(void) * Get handles for dissectors. */ eth_withoutfcs_handle = find_dissector("eth_withoutfcs"); - ppp_hdlc_handle = find_dissector("ppp_hdlc"); - llc_handle = find_dissector("llc"); - chdlc_handle = find_dissector("chdlc"); - fr_handle = find_dissector("fr"); - data_handle = find_dissector("data"); + ppp_hdlc_handle = find_dissector("ppp_hdlc"); + llc_handle = find_dissector("llc"); + chdlc_handle = find_dissector("chdlc"); + fr_handle = find_dissector("fr"); + data_handle = find_dissector("data"); cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine); dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle); diff --git a/epan/dissectors/packet-csm-encaps.c b/epan/dissectors/packet-csm-encaps.c index 657a60eff6..3c4918b09f 100644 --- a/epan/dissectors/packet-csm-encaps.c +++ b/epan/dissectors/packet-csm-encaps.c @@ -45,56 +45,56 @@ #include <epan/etypes.h> -#define OPCODE_NOOP 0x0000 +#define OPCODE_NOOP 0x0000 #define OPCODE_CONTROL_PACKET 0x0001 #define OPCODE_RELIABLE_DATA 0x0002 -#define CSM_ENCAPS_CTRL_ACK 0x80 -#define CSM_ENCAPS_CTRL_ACK_SUPPRESS 0x40 -#define CSM_ENCAPS_CTRL_ACK_TO_HOST 0x20 -#define CSM_ENCAPS_CTRL_ENDIAN 0x01 +#define CSM_ENCAPS_CTRL_ACK 0x80 +#define CSM_ENCAPS_CTRL_ACK_SUPPRESS 0x40 +#define CSM_ENCAPS_CTRL_ACK_TO_HOST 0x20 +#define CSM_ENCAPS_CTRL_ENDIAN 0x01 -#define CSM_ENCAPS_TYPE_CHANGE 0x00 -#define CSM_ENCAPS_TYPE_QUERY 0x01 -#define CSM_ENCAPS_TYPE_RESPONSE 0x02 -#define CSM_ENCAPS_TYPE_INDICATION 0x03 -#define CSM_ENCAPS_TYPE_QUERY_RESPONSE 0x04 +#define CSM_ENCAPS_TYPE_CHANGE 0x00 +#define CSM_ENCAPS_TYPE_QUERY 0x01 +#define CSM_ENCAPS_TYPE_RESPONSE 0x02 +#define CSM_ENCAPS_TYPE_INDICATION 0x03 +#define CSM_ENCAPS_TYPE_QUERY_RESPONSE 0x04 #define CSM_ENCAPS_TYPE_INDICATION_RESPONSE 0x05 static const value_string opcode_vals[] = { - { OPCODE_NOOP, "No Operation" }, - { OPCODE_CONTROL_PACKET, "Control Packet" }, - { OPCODE_RELIABLE_DATA, "Reliable Data Transfer" }, - { 0, NULL } + { OPCODE_NOOP, "No Operation" }, + { OPCODE_CONTROL_PACKET, "Control Packet" }, + { OPCODE_RELIABLE_DATA, "Reliable Data Transfer" }, + { 0, NULL } }; static const value_string function_code_vals[] = { - {0x0000, " "}, - { 0, NULL } + {0x0000, " "}, + { 0, NULL } }; static const value_string class_type_vals[] = { - { 0, NULL } + { 0, NULL } }; static const value_string exclusive_to_host_vals[] = { - { 0, NULL } + { 0, NULL } }; static const value_string exclusive_to_host_ct_vals[] = { - { 0, NULL } + { 0, NULL } }; static const value_string error_vals[] = { - { 0, NULL } + { 0, NULL } }; @@ -102,61 +102,61 @@ static const value_string error_vals[] = { /* Initialize the protocol and registered fields */ static int proto_csm_encaps = -1; -static int hf_csm_encaps_opcode = -1; -static int hf_csm_encaps_seq = -1; -static int hf_csm_encaps_ctrl = -1; -static int hf_csm_encaps_ctrl_endian = -1; -static int hf_csm_encaps_ctrl_ack = -1; +static int hf_csm_encaps_opcode = -1; +static int hf_csm_encaps_seq = -1; +static int hf_csm_encaps_ctrl = -1; +static int hf_csm_encaps_ctrl_endian = -1; +static int hf_csm_encaps_ctrl_ack = -1; static int hf_csm_encaps_ctrl_ack_suppress = -1; -static int hf_csm_encaps_channel = -1; -static int hf_csm_encaps_index = -1; -static int hf_csm_encaps_length = -1; -static int hf_csm_encaps_class = -1; -static int hf_csm_encaps_type = -1; -static int hf_csm_encaps_function_code = -1; -static int hf_csm_encaps_reserved = -1; -static int hf_csm_encaps_param_error = -1; -static int hf_csm_encaps_param1 = -1; -static int hf_csm_encaps_param2 = -1; -static int hf_csm_encaps_param3 = -1; -static int hf_csm_encaps_param4 = -1; -static int hf_csm_encaps_param5 = -1; -static int hf_csm_encaps_param6 = -1; -static int hf_csm_encaps_param7 = -1; -static int hf_csm_encaps_param8 = -1; -static int hf_csm_encaps_param9 = -1; -static int hf_csm_encaps_param10 = -1; -static int hf_csm_encaps_param11 = -1; -static int hf_csm_encaps_param12 = -1; -static int hf_csm_encaps_param13 = -1; -static int hf_csm_encaps_param14 = -1; -static int hf_csm_encaps_param15 = -1; -static int hf_csm_encaps_param16 = -1; -static int hf_csm_encaps_param17 = -1; -static int hf_csm_encaps_param18 = -1; -static int hf_csm_encaps_param19 = -1; -static int hf_csm_encaps_param20 = -1; -static int hf_csm_encaps_param21 = -1; -static int hf_csm_encaps_param22 = -1; -static int hf_csm_encaps_param23 = -1; -static int hf_csm_encaps_param24 = -1; -static int hf_csm_encaps_param25 = -1; -static int hf_csm_encaps_param26 = -1; -static int hf_csm_encaps_param27 = -1; -static int hf_csm_encaps_param28 = -1; -static int hf_csm_encaps_param29 = -1; -static int hf_csm_encaps_param30 = -1; -static int hf_csm_encaps_param31 = -1; -static int hf_csm_encaps_param32 = -1; -static int hf_csm_encaps_param33 = -1; -static int hf_csm_encaps_param34 = -1; -static int hf_csm_encaps_param35 = -1; -static int hf_csm_encaps_param36 = -1; -static int hf_csm_encaps_param37 = -1; -static int hf_csm_encaps_param38 = -1; -static int hf_csm_encaps_param39 = -1; -static int hf_csm_encaps_param40 = -1; -static int hf_csm_encaps_param = -1; +static int hf_csm_encaps_channel = -1; +static int hf_csm_encaps_index = -1; +static int hf_csm_encaps_length = -1; +static int hf_csm_encaps_class = -1; +static int hf_csm_encaps_type = -1; +static int hf_csm_encaps_function_code = -1; +static int hf_csm_encaps_reserved = -1; +static int hf_csm_encaps_param_error = -1; +static int hf_csm_encaps_param1 = -1; +static int hf_csm_encaps_param2 = -1; +static int hf_csm_encaps_param3 = -1; +static int hf_csm_encaps_param4 = -1; +static int hf_csm_encaps_param5 = -1; +static int hf_csm_encaps_param6 = -1; +static int hf_csm_encaps_param7 = -1; +static int hf_csm_encaps_param8 = -1; +static int hf_csm_encaps_param9 = -1; +static int hf_csm_encaps_param10 = -1; +static int hf_csm_encaps_param11 = -1; +static int hf_csm_encaps_param12 = -1; +static int hf_csm_encaps_param13 = -1; +static int hf_csm_encaps_param14 = -1; +static int hf_csm_encaps_param15 = -1; +static int hf_csm_encaps_param16 = -1; +static int hf_csm_encaps_param17 = -1; +static int hf_csm_encaps_param18 = -1; +static int hf_csm_encaps_param19 = -1; +static int hf_csm_encaps_param20 = -1; +static int hf_csm_encaps_param21 = -1; +static int hf_csm_encaps_param22 = -1; +static int hf_csm_encaps_param23 = -1; +static int hf_csm_encaps_param24 = -1; +static int hf_csm_encaps_param25 = -1; +static int hf_csm_encaps_param26 = -1; +static int hf_csm_encaps_param27 = -1; +static int hf_csm_encaps_param28 = -1; +static int hf_csm_encaps_param29 = -1; +static int hf_csm_encaps_param30 = -1; +static int hf_csm_encaps_param31 = -1; +static int hf_csm_encaps_param32 = -1; +static int hf_csm_encaps_param33 = -1; +static int hf_csm_encaps_param34 = -1; +static int hf_csm_encaps_param35 = -1; +static int hf_csm_encaps_param36 = -1; +static int hf_csm_encaps_param37 = -1; +static int hf_csm_encaps_param38 = -1; +static int hf_csm_encaps_param39 = -1; +static int hf_csm_encaps_param40 = -1; +static int hf_csm_encaps_param = -1; /* Initialize the subtree pointers */ @@ -168,13 +168,13 @@ static gint ett_csm_encaps_control = -1; static gchar * csm_fc(guint16 fc, guint16 ct) { - if (fc == 0x0000) { - return g_strdup(val_to_str(ct, class_type_vals, - "0x%04x")); - } else { - return g_strdup(val_to_str(fc, function_code_vals, - "0x%04x")); - } + if (fc == 0x0000) { + return g_strdup(val_to_str(ct, class_type_vals, + "0x%04x")); + } else { + return g_strdup(val_to_str(fc, function_code_vals, + "0x%04x")); + } } @@ -183,14 +183,14 @@ csm_fc(guint16 fc, guint16 ct) static gboolean csm_to_host(guint16 fc, guint16 ct) { - if (fc == 0x0000) - { - return (match_strval(ct, exclusive_to_host_ct_vals) != NULL); - } - else - { - return (match_strval(fc, exclusive_to_host_vals) != NULL); - } + if (fc == 0x0000) + { + return (match_strval(ct, exclusive_to_host_ct_vals) != NULL); + } + else + { + return (match_strval(fc, exclusive_to_host_vals) != NULL); + } } @@ -199,447 +199,455 @@ csm_to_host(guint16 fc, guint16 ct) static void dissect_csm_encaps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *ti, *subitem; - proto_tree *csm_encaps_tree = NULL; - proto_tree *csm_encaps_control_tree = NULL; - guint16 function_code, channel, class_type; - guint control, type, sequence, length; - guint i; - gboolean show_error_param= FALSE; - gchar *str_function_name; - - - function_code = tvb_get_letohs(tvb, 10); - control = tvb_get_guint8(tvb, 3); - - class_type= tvb_get_guint8(tvb, 9); - class_type= class_type<<8; - class_type|= tvb_get_guint8(tvb, 8); - - type = tvb_get_guint8(tvb, 8); - sequence = tvb_get_guint8(tvb, 2); - length = tvb_get_guint8(tvb, 6); - channel = tvb_get_ntohs(tvb, 4); - - - if (CSM_ENCAPS_CTRL_ACK&control) - show_error_param= FALSE; - else - { - if (csm_to_host(function_code, class_type)) /* exclusive messages to host */ - show_error_param= FALSE; - else - { - if (type == CSM_ENCAPS_TYPE_RESPONSE) - show_error_param= TRUE; - else - show_error_param= FALSE; - } - } - - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "CSM_ENCAPS"); - - col_clear(pinfo->cinfo, COL_INFO); - - - if (CSM_ENCAPS_CTRL_ACK&control) - { - if (CSM_ENCAPS_CTRL_ACK_TO_HOST&control) - col_append_fstr(pinfo->cinfo, COL_INFO, "<-- ACK Ch: 0x%04X, Seq: %2d (To Host)", channel, sequence); - else - col_append_fstr(pinfo->cinfo, COL_INFO, "--> ACK Ch: 0x%04X, Seq: %2d (From Host)", channel, sequence); - } - else - { - str_function_name= csm_fc(function_code, class_type); - if ((type == CSM_ENCAPS_TYPE_RESPONSE) || (csm_to_host(function_code, class_type))) - col_append_fstr(pinfo->cinfo, COL_INFO, "<-- %-35s Ch: 0x%04X, Seq: %2d (To Host)", str_function_name, channel, sequence); - else - col_append_fstr(pinfo->cinfo, COL_INFO, "--> %-35s Ch: 0x%04X, Seq: %2d (From Host)", str_function_name, channel, sequence); - g_free(str_function_name); - } - - - if (tree) { - ti = proto_tree_add_item(tree, proto_csm_encaps, tvb, 0, -1, ENC_NA); - csm_encaps_tree = proto_item_add_subtree(ti, ett_csm_encaps); - - - - - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_opcode, tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_seq, tvb, 2, 1, ENC_BIG_ENDIAN); - - subitem = proto_tree_add_uint(csm_encaps_tree, hf_csm_encaps_ctrl, tvb, 3, 1, control); - csm_encaps_control_tree = proto_item_add_subtree(subitem, ett_csm_encaps_control); - - proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_ack, tvb, 3, 1, control); - proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_ack_suppress, tvb, 3, 1, control); - proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_endian, tvb, 3, 1, control); - - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_channel, tvb, 4, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_length, tvb, 6, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_index, tvb, 7, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_class, tvb, 9, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_type, tvb, 8, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_function_code, tvb, 10, 2, ENC_LITTLE_ENDIAN); - - i=6; - - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_reserved, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) - { - if (show_error_param) - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param_error, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); - else - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param1, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); - i+=2; - } - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param2, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param3, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param4, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param5, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param6, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param7, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param8, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param9, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param10, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param11, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param12, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param13, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param14, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param15, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param16, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param17, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param18, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param19, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param20, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param21, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param22, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param23, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param24, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param25, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param26, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param27, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param28, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param29, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param30, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param31, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param32, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param33, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param34, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param35, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param36, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param37, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param38, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param39, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param40, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; - - for (; i<length; i+=2) - proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); - } + proto_item *ti, *subitem; + proto_tree *csm_encaps_tree = NULL; + proto_tree *csm_encaps_control_tree = NULL; + guint16 function_code, channel, class_type; + guint control, type, sequence, length; + guint i; + gboolean show_error_param= FALSE; + gchar *str_function_name; + + + function_code = tvb_get_letohs(tvb, 10); + control = tvb_get_guint8(tvb, 3); + + class_type = tvb_get_guint8(tvb, 9); + class_type = class_type<<8; + class_type|= tvb_get_guint8(tvb, 8); + + type = tvb_get_guint8(tvb, 8); + sequence = tvb_get_guint8(tvb, 2); + length = tvb_get_guint8(tvb, 6); + channel = tvb_get_ntohs(tvb, 4); + + + if (CSM_ENCAPS_CTRL_ACK&control) + show_error_param= FALSE; + else + { + if (csm_to_host(function_code, class_type)) /* exclusive messages to host */ + show_error_param= FALSE; + else + { + if (type == CSM_ENCAPS_TYPE_RESPONSE) + show_error_param= TRUE; + else + show_error_param= FALSE; + } + } + + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CSM_ENCAPS"); + + col_clear(pinfo->cinfo, COL_INFO); + + + if (CSM_ENCAPS_CTRL_ACK&control) + { + if (CSM_ENCAPS_CTRL_ACK_TO_HOST&control) + col_append_fstr(pinfo->cinfo, COL_INFO, + "<-- ACK Ch: 0x%04X, Seq: %2d (To Host)", + channel, sequence); + else + col_append_fstr(pinfo->cinfo, COL_INFO, + "--> ACK Ch: 0x%04X, Seq: %2d (From Host)", + channel, sequence); + } + else + { + str_function_name= csm_fc(function_code, class_type); + if ((type == CSM_ENCAPS_TYPE_RESPONSE) || (csm_to_host(function_code, class_type))) + col_append_fstr(pinfo->cinfo, COL_INFO, + "<-- %-35s Ch: 0x%04X, Seq: %2d (To Host)", + str_function_name, channel, sequence); + else + col_append_fstr(pinfo->cinfo, COL_INFO, + "--> %-35s Ch: 0x%04X, Seq: %2d (From Host)", + str_function_name, channel, sequence); + g_free(str_function_name); + } + + + if (tree) { + ti = proto_tree_add_item(tree, proto_csm_encaps, tvb, 0, -1, ENC_NA); + csm_encaps_tree = proto_item_add_subtree(ti, ett_csm_encaps); + + + + + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_opcode, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_seq, tvb, 2, 1, ENC_BIG_ENDIAN); + + subitem = proto_tree_add_uint(csm_encaps_tree, hf_csm_encaps_ctrl, tvb, 3, 1, control); + csm_encaps_control_tree = proto_item_add_subtree(subitem, ett_csm_encaps_control); + + proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_ack, tvb, 3, 1, control); + proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_ack_suppress, tvb, 3, 1, control); + proto_tree_add_boolean(csm_encaps_control_tree, hf_csm_encaps_ctrl_endian, tvb, 3, 1, control); + + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_channel, tvb, 4, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_length, tvb, 6, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_index, tvb, 7, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_class, tvb, 9, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_type, tvb, 8, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_function_code, tvb, 10, 2, ENC_LITTLE_ENDIAN); + + i=6; + + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_reserved, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) + { + if (show_error_param) + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param_error, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); + else + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param1, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); + i+=2; + } + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param2, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param3, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param4, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param5, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param6, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param7, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param8, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param9, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param10, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param11, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param12, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param13, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param14, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param15, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param16, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param17, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param18, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param19, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param20, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param21, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param22, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param23, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param24, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param25, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param26, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param27, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param28, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param29, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param30, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param31, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param32, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param33, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param34, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param35, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param36, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param37, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param38, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param39, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param40, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2; + + for (; i<length; i+=2) + proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); + } } void proto_register_csm_encaps(void) { - static struct true_false_string control_endian_bit = {"Little Endian","Big Endian"}; - static struct true_false_string control_ack_bit = {"ACK Packet", "Message Packet"}; - static struct true_false_string control_ack_suppress_bit = {"ACK Suppressed", "ACK Required"}; - - - static hf_register_info hf[] = { - { &hf_csm_encaps_opcode, - { "Opcode", "csm_encaps.opcode", - FT_UINT16, BASE_HEX, VALS(opcode_vals), 0, - "CSM_ENCAPS Opcode", HFILL } - }, - { &hf_csm_encaps_seq, - { "Sequence Number", "csm_encaps.seq_num", - FT_UINT8, BASE_DEC, NULL, 0, - "CSM_ENCAPS Sequence Number", HFILL } - }, - - { &hf_csm_encaps_ctrl, - { "Control", "csm_encaps.ctrl", - FT_UINT8, BASE_HEX, NULL, 0, - "CSM_ENCAPS Control", HFILL } - }, - - { &hf_csm_encaps_ctrl_ack, - { "Packet Bit", "csm_encaps.ctrl.ack", - FT_BOOLEAN, 8, TFS(&control_ack_bit), CSM_ENCAPS_CTRL_ACK, - "Message Packet/ACK Packet", HFILL } - }, - { &hf_csm_encaps_ctrl_ack_suppress, - { "ACK Suppress Bit", "csm_encaps.ctrl.ack_suppress", - FT_BOOLEAN, 8, TFS(&control_ack_suppress_bit), CSM_ENCAPS_CTRL_ACK_SUPPRESS, - "ACK Required/ACK Suppressed", HFILL } - }, - { &hf_csm_encaps_ctrl_endian, - { "Endian Bit", "csm_encaps.ctrl.endian", - FT_BOOLEAN, 8, TFS(&control_endian_bit), CSM_ENCAPS_CTRL_ENDIAN, - "Little Endian/Big Endian", HFILL } - }, - - - { &hf_csm_encaps_channel, - { "Channel Number", "csm_encaps.channel", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Channel Number", HFILL } - }, - { &hf_csm_encaps_index, - { "Index", "csm_encaps.index", - FT_UINT8, BASE_DEC, NULL, 0, - "CSM_ENCAPS Index", HFILL } - }, - { &hf_csm_encaps_length, - { "Length", "csm_encaps.length", - FT_UINT8, BASE_DEC, NULL, 0, - "CSM_ENCAPS Length", HFILL } - }, - { &hf_csm_encaps_class, - { "Class", "csm_encaps.class", - FT_UINT8, BASE_DEC, NULL, 0, - "CSM_ENCAPS Class", HFILL } - }, - { &hf_csm_encaps_type, - { "Type", "csm_encaps.type", - FT_UINT8, BASE_DEC, NULL, 0, - "CSM_ENCAPS Type", HFILL } - }, - { &hf_csm_encaps_function_code, - { "Function Code", "csm_encaps.function_code", - FT_UINT16, BASE_HEX, VALS(function_code_vals), 0, - "CSM_ENCAPS Function Code", HFILL } - }, - { &hf_csm_encaps_reserved, - { "Reserved", "csm_encaps.reserved", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Reserved", HFILL } - }, - { &hf_csm_encaps_param_error, - { "Parameter 1", "csm_encaps.param1", - FT_UINT16, BASE_HEX, VALS(error_vals), 0, - "CSM_ENCAPS Parameter 1", HFILL } - }, - { &hf_csm_encaps_param1, - { "Parameter 1", "csm_encaps.param1", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 1", HFILL } - }, - { &hf_csm_encaps_param2, - { "Parameter 2", "csm_encaps.param2", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 2", HFILL } - }, - { &hf_csm_encaps_param3, - { "Parameter 3", "csm_encaps.param3", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 3", HFILL } - }, - { &hf_csm_encaps_param4, - { "Parameter 4", "csm_encaps.param4", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 4", HFILL } - }, - { &hf_csm_encaps_param5, - { "Parameter 5", "csm_encaps.param5", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 5", HFILL } - }, - { &hf_csm_encaps_param6, - { "Parameter 6", "csm_encaps.param6", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 6", HFILL } - }, - { &hf_csm_encaps_param7, - { "Parameter 7", "csm_encaps.param7", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 7", HFILL } - }, - { &hf_csm_encaps_param8, - { "Parameter 8", "csm_encaps.param8", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 8", HFILL } - }, - { &hf_csm_encaps_param9, - { "Parameter 9", "csm_encaps.param9", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 9", HFILL } - }, - { &hf_csm_encaps_param10, - { "Parameter 10", "csm_encaps.param10", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 10", HFILL } - }, - { &hf_csm_encaps_param11, - { "Parameter 11", "csm_encaps.param11", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 11", HFILL } - }, - { &hf_csm_encaps_param12, - { "Parameter 12", "csm_encaps.param12", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 12", HFILL } - }, - { &hf_csm_encaps_param13, - { "Parameter 13", "csm_encaps.param13", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 13", HFILL } - }, - { &hf_csm_encaps_param14, - { "Parameter 14", "csm_encaps.param14", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 14", HFILL } - }, - { &hf_csm_encaps_param15, - { "Parameter 15", "csm_encaps.param15", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 15", HFILL } - }, - { &hf_csm_encaps_param16, - { "Parameter 16", "csm_encaps.param16", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 16", HFILL } - }, - { &hf_csm_encaps_param17, - { "Parameter 17", "csm_encaps.param17", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 17", HFILL } - }, - { &hf_csm_encaps_param18, - { "Parameter 18", "csm_encaps.param18", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 18", HFILL } - }, - { &hf_csm_encaps_param19, - { "Parameter 19", "csm_encaps.param19", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 19", HFILL } - }, - { &hf_csm_encaps_param20, - { "Parameter 20", "csm_encaps.param20", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 20", HFILL } - }, - { &hf_csm_encaps_param21, - { "Parameter 21", "csm_encaps.param21", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 21", HFILL } - }, - { &hf_csm_encaps_param22, - { "Parameter 22", "csm_encaps.param22", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 22", HFILL } - }, - { &hf_csm_encaps_param23, - { "Parameter 23", "csm_encaps.param23", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 23", HFILL } - }, - { &hf_csm_encaps_param24, - { "Parameter 24", "csm_encaps.param24", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 24", HFILL } - }, - { &hf_csm_encaps_param25, - { "Parameter 25", "csm_encaps.param25", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 25", HFILL } - }, - { &hf_csm_encaps_param26, - { "Parameter 26", "csm_encaps.param26", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 26", HFILL } - }, - { &hf_csm_encaps_param27, - { "Parameter 27", "csm_encaps.param27", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 27", HFILL } - }, - { &hf_csm_encaps_param28, - { "Parameter 28", "csm_encaps.param28", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 28", HFILL } - }, - { &hf_csm_encaps_param29, - { "Parameter 29", "csm_encaps.param29", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 29", HFILL } - }, - { &hf_csm_encaps_param30, - { "Parameter 30", "csm_encaps.param30", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 30", HFILL } - }, - { &hf_csm_encaps_param31, - { "Parameter 31", "csm_encaps.param31", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 31", HFILL } - }, - { &hf_csm_encaps_param32, - { "Parameter 32", "csm_encaps.param32", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 32", HFILL } - }, - { &hf_csm_encaps_param33, - { "Parameter 33", "csm_encaps.param33", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 33", HFILL } - }, - { &hf_csm_encaps_param34, - { "Parameter 34", "csm_encaps.param34", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 34", HFILL } - }, - { &hf_csm_encaps_param35, - { "Parameter 35", "csm_encaps.param35", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 35", HFILL } - }, - { &hf_csm_encaps_param36, - { "Parameter 36", "csm_encaps.param36", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 36", HFILL } - }, - { &hf_csm_encaps_param37, - { "Parameter 37", "csm_encaps.param37", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 37", HFILL } - }, - { &hf_csm_encaps_param38, - { "Parameter 38", "csm_encaps.param38", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 38", HFILL } - }, - { &hf_csm_encaps_param39, - { "Parameter 39", "csm_encaps.param39", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 39", HFILL } - }, - { &hf_csm_encaps_param40, - { "Parameter 40", "csm_encaps.param40", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter 40", HFILL } - }, - { &hf_csm_encaps_param, - { "Parameter", "csm_encaps.param", - FT_UINT16, BASE_HEX, NULL, 0, - "CSM_ENCAPS Parameter", HFILL } - }, - }; - - static gint *ett[] = { - &ett_csm_encaps, - &ett_csm_encaps_control - }; - - proto_csm_encaps = proto_register_protocol("CSM_ENCAPS", "CSM_ENCAPS", "csm_encaps"); - proto_register_field_array(proto_csm_encaps, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); + static struct true_false_string control_endian_bit = {"Little Endian","Big Endian"}; + static struct true_false_string control_ack_bit = {"ACK Packet", "Message Packet"}; + static struct true_false_string control_ack_suppress_bit = {"ACK Suppressed", "ACK Required"}; + + + static hf_register_info hf[] = { + { &hf_csm_encaps_opcode, + { "Opcode", "csm_encaps.opcode", + FT_UINT16, BASE_HEX, VALS(opcode_vals), 0, + "CSM_ENCAPS Opcode", HFILL } + }, + { &hf_csm_encaps_seq, + { "Sequence Number", "csm_encaps.seq_num", + FT_UINT8, BASE_DEC, NULL, 0, + "CSM_ENCAPS Sequence Number", HFILL } + }, + + { &hf_csm_encaps_ctrl, + { "Control", "csm_encaps.ctrl", + FT_UINT8, BASE_HEX, NULL, 0, + "CSM_ENCAPS Control", HFILL } + }, + + { &hf_csm_encaps_ctrl_ack, + { "Packet Bit", "csm_encaps.ctrl.ack", + FT_BOOLEAN, 8, TFS(&control_ack_bit), CSM_ENCAPS_CTRL_ACK, + "Message Packet/ACK Packet", HFILL } + }, + { &hf_csm_encaps_ctrl_ack_suppress, + { "ACK Suppress Bit", "csm_encaps.ctrl.ack_suppress", + FT_BOOLEAN, 8, TFS(&control_ack_suppress_bit), CSM_ENCAPS_CTRL_ACK_SUPPRESS, + "ACK Required/ACK Suppressed", HFILL } + }, + { &hf_csm_encaps_ctrl_endian, + { "Endian Bit", "csm_encaps.ctrl.endian", + FT_BOOLEAN, 8, TFS(&control_endian_bit), CSM_ENCAPS_CTRL_ENDIAN, + "Little Endian/Big Endian", HFILL } + }, + + + { &hf_csm_encaps_channel, + { "Channel Number", "csm_encaps.channel", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Channel Number", HFILL } + }, + { &hf_csm_encaps_index, + { "Index", "csm_encaps.index", + FT_UINT8, BASE_DEC, NULL, 0, + "CSM_ENCAPS Index", HFILL } + }, + { &hf_csm_encaps_length, + { "Length", "csm_encaps.length", + FT_UINT8, BASE_DEC, NULL, 0, + "CSM_ENCAPS Length", HFILL } + }, + { &hf_csm_encaps_class, + { "Class", "csm_encaps.class", + FT_UINT8, BASE_DEC, NULL, 0, + "CSM_ENCAPS Class", HFILL } + }, + { &hf_csm_encaps_type, + { "Type", "csm_encaps.type", + FT_UINT8, BASE_DEC, NULL, 0, + "CSM_ENCAPS Type", HFILL } + }, + { &hf_csm_encaps_function_code, + { "Function Code", "csm_encaps.function_code", + FT_UINT16, BASE_HEX, VALS(function_code_vals), 0, + "CSM_ENCAPS Function Code", HFILL } + }, + { &hf_csm_encaps_reserved, + { "Reserved", "csm_encaps.reserved", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Reserved", HFILL } + }, + { &hf_csm_encaps_param_error, + { "Parameter 1", "csm_encaps.param1", + FT_UINT16, BASE_HEX, VALS(error_vals), 0, + "CSM_ENCAPS Parameter 1", HFILL } + }, + { &hf_csm_encaps_param1, + { "Parameter 1", "csm_encaps.param1", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 1", HFILL } + }, + { &hf_csm_encaps_param2, + { "Parameter 2", "csm_encaps.param2", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 2", HFILL } + }, + { &hf_csm_encaps_param3, + { "Parameter 3", "csm_encaps.param3", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 3", HFILL } + }, + { &hf_csm_encaps_param4, + { "Parameter 4", "csm_encaps.param4", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 4", HFILL } + }, + { &hf_csm_encaps_param5, + { "Parameter 5", "csm_encaps.param5", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 5", HFILL } + }, + { &hf_csm_encaps_param6, + { "Parameter 6", "csm_encaps.param6", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 6", HFILL } + }, + { &hf_csm_encaps_param7, + { "Parameter 7", "csm_encaps.param7", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 7", HFILL } + }, + { &hf_csm_encaps_param8, + { "Parameter 8", "csm_encaps.param8", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 8", HFILL } + }, + { &hf_csm_encaps_param9, + { "Parameter 9", "csm_encaps.param9", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 9", HFILL } + }, + { &hf_csm_encaps_param10, + { "Parameter 10", "csm_encaps.param10", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 10", HFILL } + }, + { &hf_csm_encaps_param11, + { "Parameter 11", "csm_encaps.param11", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 11", HFILL } + }, + { &hf_csm_encaps_param12, + { "Parameter 12", "csm_encaps.param12", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 12", HFILL } + }, + { &hf_csm_encaps_param13, + { "Parameter 13", "csm_encaps.param13", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 13", HFILL } + }, + { &hf_csm_encaps_param14, + { "Parameter 14", "csm_encaps.param14", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 14", HFILL } + }, + { &hf_csm_encaps_param15, + { "Parameter 15", "csm_encaps.param15", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 15", HFILL } + }, + { &hf_csm_encaps_param16, + { "Parameter 16", "csm_encaps.param16", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 16", HFILL } + }, + { &hf_csm_encaps_param17, + { "Parameter 17", "csm_encaps.param17", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 17", HFILL } + }, + { &hf_csm_encaps_param18, + { "Parameter 18", "csm_encaps.param18", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 18", HFILL } + }, + { &hf_csm_encaps_param19, + { "Parameter 19", "csm_encaps.param19", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 19", HFILL } + }, + { &hf_csm_encaps_param20, + { "Parameter 20", "csm_encaps.param20", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 20", HFILL } + }, + { &hf_csm_encaps_param21, + { "Parameter 21", "csm_encaps.param21", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 21", HFILL } + }, + { &hf_csm_encaps_param22, + { "Parameter 22", "csm_encaps.param22", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 22", HFILL } + }, + { &hf_csm_encaps_param23, + { "Parameter 23", "csm_encaps.param23", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 23", HFILL } + }, + { &hf_csm_encaps_param24, + { "Parameter 24", "csm_encaps.param24", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 24", HFILL } + }, + { &hf_csm_encaps_param25, + { "Parameter 25", "csm_encaps.param25", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 25", HFILL } + }, + { &hf_csm_encaps_param26, + { "Parameter 26", "csm_encaps.param26", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 26", HFILL } + }, + { &hf_csm_encaps_param27, + { "Parameter 27", "csm_encaps.param27", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 27", HFILL } + }, + { &hf_csm_encaps_param28, + { "Parameter 28", "csm_encaps.param28", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 28", HFILL } + }, + { &hf_csm_encaps_param29, + { "Parameter 29", "csm_encaps.param29", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 29", HFILL } + }, + { &hf_csm_encaps_param30, + { "Parameter 30", "csm_encaps.param30", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 30", HFILL } + }, + { &hf_csm_encaps_param31, + { "Parameter 31", "csm_encaps.param31", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 31", HFILL } + }, + { &hf_csm_encaps_param32, + { "Parameter 32", "csm_encaps.param32", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 32", HFILL } + }, + { &hf_csm_encaps_param33, + { "Parameter 33", "csm_encaps.param33", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 33", HFILL } + }, + { &hf_csm_encaps_param34, + { "Parameter 34", "csm_encaps.param34", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 34", HFILL } + }, + { &hf_csm_encaps_param35, + { "Parameter 35", "csm_encaps.param35", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 35", HFILL } + }, + { &hf_csm_encaps_param36, + { "Parameter 36", "csm_encaps.param36", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 36", HFILL } + }, + { &hf_csm_encaps_param37, + { "Parameter 37", "csm_encaps.param37", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 37", HFILL } + }, + { &hf_csm_encaps_param38, + { "Parameter 38", "csm_encaps.param38", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 38", HFILL } + }, + { &hf_csm_encaps_param39, + { "Parameter 39", "csm_encaps.param39", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 39", HFILL } + }, + { &hf_csm_encaps_param40, + { "Parameter 40", "csm_encaps.param40", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter 40", HFILL } + }, + { &hf_csm_encaps_param, + { "Parameter", "csm_encaps.param", + FT_UINT16, BASE_HEX, NULL, 0, + "CSM_ENCAPS Parameter", HFILL } + }, + }; + + static gint *ett[] = { + &ett_csm_encaps, + &ett_csm_encaps_control + }; + + proto_csm_encaps = proto_register_protocol("CSM_ENCAPS", "CSM_ENCAPS", "csm_encaps"); + proto_register_field_array(proto_csm_encaps, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); } @@ -647,8 +655,8 @@ proto_register_csm_encaps(void) void proto_reg_handoff_csm_encaps(void) { - dissector_handle_t csm_encaps_handle; + dissector_handle_t csm_encaps_handle; - csm_encaps_handle = create_dissector_handle(dissect_csm_encaps, proto_csm_encaps); - dissector_add_uint("ethertype", ETHERTYPE_CSM_ENCAPS, csm_encaps_handle); + csm_encaps_handle = create_dissector_handle(dissect_csm_encaps, proto_csm_encaps); + dissector_add_uint("ethertype", ETHERTYPE_CSM_ENCAPS, csm_encaps_handle); } diff --git a/epan/dissectors/packet-csn1.c b/epan/dissectors/packet-csn1.c index 944ac8809a..f88ff86c74 100644 --- a/epan/dissectors/packet-csn1.c +++ b/epan/dissectors/packet-csn1.c @@ -405,7 +405,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t { if (remaining_bits_len >= pDescr->descr.crumb_spec[pDescr->i].crumb_bit_length) { - proto_tree_add_split_bits_crumb(tree, *pDescr->serialize.hf_ptr, tvb, bit_offset, + proto_tree_add_split_bits_crumb(tree, *pDescr->serialize.hf_ptr, tvb, bit_offset, pDescr->descr.crumb_spec, pDescr->i); remaining_bits_len -= pDescr->descr.crumb_spec[pDescr->i].crumb_bit_length; @@ -624,7 +624,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t ti = proto_tree_add_text(tree, tvb, bit_offset>>3, 1, "%s", pDescr->sz); test_tree = proto_item_add_subtree(ti, ett_csn1); } else { - test_tree = tree; + test_tree = tree; } csnStreamInit(&arT, bit_offset, remaining_bits_len); @@ -1594,7 +1594,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t no_of_bits = callback(tree, tvb, pvDATA(data, pDescr->i), pvDATA(data, pDescr->offset), bit_offset, ett_csn1); bit_offset += no_of_bits; - + pDescr++; break; } diff --git a/epan/dissectors/packet-csn1.h b/epan/dissectors/packet-csn1.h index f40dde9273..5bd035b3dd 100644 --- a/epan/dissectors/packet-csn1.h +++ b/epan/dissectors/packet-csn1.h @@ -254,13 +254,13 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * Similar to the M_BIT except that not only bit 0 or 1 but also the * end of the message may be encountered when looking for the next element in * the message. - * Covers the case {null | 0 | 1} + * Covers the case {null | 0 | 1} *****************************************************************************/ #define M_BIT_OR_NULL(_STRUCT, _MEMBER, _HF_PTR)\ {CSN_BIT, 0, {0}, offsetof(_STRUCT, _MEMBER), TRUE, #_MEMBER, {(StreamSerializeFcn_t) _HF_PTR}} /****************************************************************************** * M_NEXT_EXIST(Par1, Par2, Par3) - * Indicates whether the next element or a group of elements defined in the + * Indicates whether the next element or a group of elements defined in the * structure is present or not. * Par1: C structure name * Par2: C structure element name @@ -274,7 +274,7 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * M_NEXT_EXIST_LH(Par1, Par2, Par3) * similar to the M_NEXT_EXIST except that instead of bit 0/1 which is fetched * from the message in order to find out whether the next element/elements are - * present in the message, the logical operation XOR with the background + * present in the message, the logical operation XOR with the background * pattern 0x2B is performed on the read bit before the decision is made. *****************************************************************************/ #define M_NEXT_EXIST_LH(_STRUCT, _MEMBER, _NoOfExisting)\ @@ -283,9 +283,9 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD /****************************************************************************** * M_NEXT_EXIST_OR_NULL(Par1, Par2, Par3) * Similar to the M_NEXT_EXIST except that not only bit 0 or 1 but also the end - * of the message may be encountered when looking for the next element in the + * of the message may be encountered when looking for the next element in the * message. - * Covers the case {null | 0 | 1 < IE >} + * Covers the case {null | 0 | 1 < IE >} *****************************************************************************/ #define M_NEXT_EXIST_OR_NULL(_STRUCT, _MEMBER, _NoOfExisting)\ {CSN_NEXT_EXIST, _NoOfExisting, {0}, offsetof(_STRUCT, _MEMBER), TRUE, #_MEMBER, {(StreamSerializeFcn_t)0}} @@ -295,7 +295,7 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * Similar to the M_NEXT_EXIST_LH except that not only bit 0 or 1 but also the * end of the message may be encountered when looking for the next element in * the message. - * Covers the case {null | L | H < IE >} + * Covers the case {null | L | H < IE >} *****************************************************************************/ #define M_NEXT_EXIST_OR_NULL_LH(_STRUCT, _MEMBER, _NoOfExisting)\ {CSN_NEXT_EXIST_LH, _NoOfExisting, {(void*)1}, offsetof(_STRUCT, _MEMBER), TRUE, #_MEMBER, {(StreamSerializeFcn_t)0}} @@ -339,7 +339,7 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * Similar to the M_UINT except that not only the request set of bits but also the * end of the message may be encountered when looking for the next element in * the message. - * Covers the case {null | 0 | 1 < IE >} + * Covers the case {null | 0 | 1 < IE >} *****************************************************************************/ #define M_UINT_OR_NULL(_STRUCT, _MEMBER, _BITS, _HF_PTR)\ {CSN_UINT, _BITS, {0}, offsetof(_STRUCT, _MEMBER), TRUE, #_MEMBER, {(StreamSerializeFcn_t) _HF_PTR}} @@ -347,8 +347,8 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD /****************************************************************************** * M_UINT_LH(Par1, Par2, Par3, Par4) * This macro has the same functionality as M_UINT except that in addition the - * logical "exclusive or" operation with the background value "0x2B" is - * performed before the final value of the integer number is delivered from the + * logical "exclusive or" operation with the background value "0x2B" is + * performed before the final value of the integer number is delivered from the * received CSN.1 message *****************************************************************************/ #define M_UINT_LH(_STRUCT, _MEMBER, _BITS, _HF_PTR)\ @@ -419,16 +419,16 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD /****************************************************************************** * M_REC_ARRAY(Par1, Par2, Par3, Par4) - * similar to the M_VAR_ARRAY. The difference is that the size of the array is + * similar to the M_VAR_ARRAY. The difference is that the size of the array is * not known in advance and it has to be calculated during unpacking. Its value - * is stored in a variable which belongs to the same structure as the array. - * A zero element terminates the array. The CSN.1 syntax describes it + * is stored in a variable which belongs to the same structure as the array. + * A zero element terminates the array. The CSN.1 syntax describes it * recursively as: - * <array> ::={1 <element> <array>| 0} + * <array> ::={1 <element> <array>| 0} * * Par1: C structure name * Par2: C structure element name - * Par3: name of the structure member where the calculated the size of the + * Par3: name of the structure member where the calculated the size of the * array will be stored * Par4: length of each element in bits *****************************************************************************/ @@ -501,8 +501,8 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * M_UNION(Par1, Par2) * Informs the CSN.1 library that a union follows and how many possible choices * there are in the union. The actual value of the choice, which points out the - * chosen element of the union is stored in the uint8 variable and is usually - * called UnionType. The elements of the union have to be listed directly after + * chosen element of the union is stored in the uint8 variable and is usually + * called UnionType. The elements of the union have to be listed directly after * the M_UNION statement. * Par1: C structure name * Par2: number of possible choice in the union @@ -519,12 +519,12 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD /****************************************************************************** * M_CHOICE(Par1, Par2, Par3, Par4) - * Similar to the M_UNION. In the M_UNION the selected element of all possible - * choices in the union is referred as a sequential numbers, i.e., the first - * choice is addressed as choice 0 the second as choice 1, the third as choice + * Similar to the M_UNION. In the M_UNION the selected element of all possible + * choices in the union is referred as a sequential numbers, i.e., the first + * choice is addressed as choice 0 the second as choice 1, the third as choice * 2 and so on, both in the encoded message and in the variable UnionType which - * is the part of the message. In the CSN_CHOICE case, this rule does not - * apply. There is free but predefined mapping of the element of the union and + * is the part of the message. In the CSN_CHOICE case, this rule does not + * apply. There is free but predefined mapping of the element of the union and * the value which addresses this element. * The value of the address is called a selector. * After unpacking, this value is then converted to the sequential number of the @@ -532,14 +532,14 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * Par1: C structure name * Par2: C structure element name * Par3: address of an array of type CSN_ChoiceElement_t where all possible - * values of the selector are provided, together with the selector - * length expressed in bits and the address of the CSN_DESCR type - * where the element is defined. For every element in the union - * there is one line in the Choice variable. These lines have to - * appear in the _CHOICE in the same order as the elements in the - * union. The element of the union selected in the message through - * the _CHOICE parameter is after unpacking translated to the - * corresponding sequential number of this element and stored in + * values of the selector are provided, together with the selector + * length expressed in bits and the address of the CSN_DESCR type + * where the element is defined. For every element in the union + * there is one line in the Choice variable. These lines have to + * appear in the _CHOICE in the same order as the elements in the + * union. The element of the union selected in the message through + * the _CHOICE parameter is after unpacking translated to the + * corresponding sequential number of this element and stored in * the variable pointed out by the _MEMBER * Par4: number of possible choices in the union *****************************************************************************/ @@ -552,15 +552,15 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * displayed to show there was a choice *****************************************************************************/ #define M_CHOICE_IL(_STRUCT, _MEMBER, _CHOICE, _ElementCount)\ - {CSN_CHOICE, _ElementCount, {(void*)_CHOICE}, offsetof(_STRUCT, _MEMBER), FALSE, NULL, {(StreamSerializeFcn_t)0}} + {CSN_CHOICE, _ElementCount, {(void*)_CHOICE}, offsetof(_STRUCT, _MEMBER), FALSE, NULL, {(StreamSerializeFcn_t)0}} /****************************************************************************** * M_FIXED(Par1, Par2, Par3) - * Defines a fixed value of type integer which should be fetched from or stored + * Defines a fixed value of type integer which should be fetched from or stored * in the message * Par1: C structure name * Par2: gives the length of the fixed number in bits. - * Par3: the value of the number. If the expected value is not present in + * Par3: the value of the number. If the expected value is not present in * the message the unpacking procedure is aborted *****************************************************************************/ #define M_FIXED(_STRUCT, _BITS, _BITVALUE)\ @@ -571,21 +571,21 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD * Same as M_FIXED but allows to define a custom string for the subtree * Par1: C structure name * Par2: gives the length of the fixed number in bits. - * Par3: the value of the number. If the expected value is not present in + * Par3: the value of the number. If the expected value is not present in * the message the unpacking procedure is aborted * Par4: C string for the text *****************************************************************************/ #define M_FIXED_LABEL(_STRUCT, _BITS, _BITVALUE, _LABEL)\ - {CSN_FIXED, _BITS, {0}, _BITVALUE, FALSE, _LABEL, {(StreamSerializeFcn_t)0}} + {CSN_FIXED, _BITS, {0}, _BITVALUE, FALSE, _LABEL, {(StreamSerializeFcn_t)0}} /****************************************************************************** * M_SERIALIZE(Par1, Par2, Par3) - * Allows using a complete free format of data being encoded or decoded. - * When the M_SERIALIZE is encounted during encoding or decoding of a message - * the CSNstream program passes the control over to the specified function - * together with all necessary parameters about the current position within - * the message being unpacked or packed. When transferring of "serialized" - * data to or from the message is finished by the function the CSNstream gets + * Allows using a complete free format of data being encoded or decoded. + * When the M_SERIALIZE is encounted during encoding or decoding of a message + * the CSNstream program passes the control over to the specified function + * together with all necessary parameters about the current position within + * the message being unpacked or packed. When transferring of "serialized" + * data to or from the message is finished by the function the CSNstream gets * back control over the data stream and continues to work with the message. *****************************************************************************/ #define M_SERIALIZE(_STRUCT, _MEMBER, _LENGTH_LEN, _SERIALIZEFCN)\ @@ -596,7 +596,7 @@ gint16 csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pD /****************************************************************************** * M_BITMAP(Par1, Par2, Par3) - * Defines a type which consists of a bitmap. The size of the bitmap in bits + * Defines a type which consists of a bitmap. The size of the bitmap in bits * is fixed and provided by the parameter Par3 * Par1: C structure name * Par2: C structure element name |