forked from osmocom/wireshark
Remove proto_tree_add_text_valist from dissectors.
The only remaining call to proto_tree_add_text_valist is in expert.c. Suggestions welcome on how to make it "private" enough so dissectors can't use it. Change-Id: I1b70789bd01a857c3ac06d198667aeb59c4d1be9 Reviewed-on: https://code.wireshark.org/review/4333 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
45fb37718e
commit
b2d81a2a8d
|
@ -1445,7 +1445,6 @@ DISSECTOR_INCLUDES = \
|
|||
packet-edonkey.h \
|
||||
packet-enc.h \
|
||||
packet-epmd.h \
|
||||
packet-esis.h \
|
||||
packet-ess.h \
|
||||
packet-eth.h \
|
||||
packet-fc.h \
|
||||
|
|
|
@ -27,11 +27,22 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/expert.h>
|
||||
#include <wsutil/pint.h>
|
||||
#include <epan/nlpid.h>
|
||||
#include "packet-osi.h"
|
||||
#include "packet-osi-options.h"
|
||||
#include "packet-esis.h"
|
||||
|
||||
/* The version we support is 1 */
|
||||
#define ESIS_REQUIRED_VERSION 1
|
||||
|
||||
/* ESIS PDU types */
|
||||
#define ESIS_ESH_PDU 02
|
||||
#define ESIS_ISH_PDU 04
|
||||
#define ESIS_RD_PDU 06
|
||||
|
||||
/* The length of the fixed part */
|
||||
#define ESIS_HDR_FIXED_LENGTH 9
|
||||
|
||||
void proto_register_esis(void);
|
||||
void proto_reg_handoff_esis(void);
|
||||
|
@ -59,21 +70,16 @@ static int hf_esis_bsnpa = -1;
|
|||
static gint ett_esis = -1;
|
||||
static gint ett_esis_area_addr = -1;
|
||||
|
||||
static expert_field ei_esis_version = EI_INIT;
|
||||
static expert_field ei_esis_length = EI_INIT;
|
||||
static expert_field ei_esis_type = EI_INIT;
|
||||
|
||||
static const value_string esis_vals[] = {
|
||||
{ ESIS_ESH_PDU, "ES HELLO"},
|
||||
{ ESIS_ISH_PDU, "IS HELLO"},
|
||||
{ ESIS_RD_PDU, "RD REQUEST"},
|
||||
{ 0, NULL} };
|
||||
|
||||
/* internal prototypes */
|
||||
|
||||
static void esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb,
|
||||
proto_tree *treepd);
|
||||
static void esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb,
|
||||
proto_tree *tree);
|
||||
static void esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb,
|
||||
proto_tree *tree);
|
||||
|
||||
/* ################## Descriptions ###########################################*/
|
||||
/* Parameters for the ESH PDU
|
||||
* Source Address Parameter:
|
||||
|
@ -123,38 +129,6 @@ static void esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb,
|
|||
/* ############################ Tool Functions ############################## */
|
||||
|
||||
|
||||
/* ############################## Dissection Functions ###################### */
|
||||
/*
|
||||
* Name: dissect_esis_unknown()
|
||||
*
|
||||
* Description:
|
||||
* There was some error in the protocol and we are in unknown space
|
||||
* here. Add a tree item to cover the error and go on. Note
|
||||
* that we make sure we don't go off the end of the bleedin packet here!
|
||||
*
|
||||
* This is just a copy of isis.c and isis.h, so I keep the stuff also
|
||||
* and adapt the names to cover possible protocol errors! I've really no
|
||||
* idea whether I need this or not.
|
||||
*
|
||||
* Input
|
||||
* tvbuff_t * : tvbuff with packet data.
|
||||
* proto_tree * : tree of display data. May be NULL.
|
||||
* char * : format text
|
||||
* subsequent args : arguments to format
|
||||
*
|
||||
* Output:
|
||||
* void (may modify proto tree)
|
||||
*/
|
||||
static void
|
||||
esis_dissect_unknown( tvbuff_t *tvb, proto_tree *tree, const char *fmat, ...){
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmat);
|
||||
proto_tree_add_text_valist(tree, tvb, 0, -1, fmat, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
|
||||
proto_tree *esis_area_tree;
|
||||
|
@ -273,64 +247,48 @@ esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
|
|||
*/
|
||||
static void
|
||||
dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
||||
const char *pdu_type_string = NULL;
|
||||
const char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)";
|
||||
esis_hdr_t ehdr;
|
||||
proto_item *ti;
|
||||
guint8 version, length;
|
||||
proto_item *ti, *type_item;
|
||||
proto_tree *esis_tree = NULL;
|
||||
guint8 variable_len;
|
||||
guint tmp_uint = 0;
|
||||
guint8 variable_len, type;
|
||||
guint16 holdtime, checksum;
|
||||
const char *cksum_status;
|
||||
|
||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
|
||||
col_clear(pinfo->cinfo, COL_INFO);
|
||||
|
||||
tvb_memcpy(tvb, (guint8 *)&ehdr, 0, sizeof ehdr);
|
||||
|
||||
if (tree) {
|
||||
ti = proto_tree_add_item(tree, proto_esis, tvb, 0, -1, ENC_NA);
|
||||
esis_tree = proto_item_add_subtree(ti, ett_esis);
|
||||
|
||||
if (ehdr.esis_version != ESIS_REQUIRED_VERSION){
|
||||
esis_dissect_unknown(tvb, esis_tree,
|
||||
"Unknown ESIS version (%u vs %u)",
|
||||
ehdr.esis_version, ESIS_REQUIRED_VERSION );
|
||||
return;
|
||||
}
|
||||
|
||||
if (ehdr.esis_length < ESIS_HDR_FIXED_LENGTH) {
|
||||
esis_dissect_unknown(tvb, esis_tree,
|
||||
proto_tree_add_item( esis_tree, hf_esis_nlpi, tvb, 0, 1, ENC_NA);
|
||||
ti = proto_tree_add_item( esis_tree, hf_esis_length, tvb, 1, 1, ENC_NA );
|
||||
length = tvb_get_guint8(tvb, 1);
|
||||
if (length < ESIS_HDR_FIXED_LENGTH) {
|
||||
expert_add_info_format(pinfo, ti, &ei_esis_length,
|
||||
"Bogus ESIS length (%u, must be >= %u)",
|
||||
ehdr.esis_length, ESIS_HDR_FIXED_LENGTH );
|
||||
length, ESIS_HDR_FIXED_LENGTH );
|
||||
return;
|
||||
}
|
||||
proto_tree_add_uint( esis_tree, hf_esis_nlpi, tvb, 0, 1, ehdr.esis_nlpi );
|
||||
proto_tree_add_uint( esis_tree, hf_esis_length, tvb,
|
||||
1, 1, ehdr.esis_length );
|
||||
proto_tree_add_uint( esis_tree, hf_esis_version, tvb, 2, 1,
|
||||
ehdr.esis_version );
|
||||
proto_tree_add_uint( esis_tree, hf_esis_reserved, tvb, 3, 1,
|
||||
ehdr.esis_reserved );
|
||||
|
||||
pdu_type_string = val_to_str(ehdr.esis_type&OSI_PDU_TYPE_MASK,
|
||||
esis_vals, "Unknown (0x%x)");
|
||||
version = tvb_get_guint8(tvb, 2);
|
||||
ti = proto_tree_add_item( esis_tree, hf_esis_version, tvb, 2, 1, ENC_NA);
|
||||
if (version != ESIS_REQUIRED_VERSION){
|
||||
expert_add_info_format(pinfo, ti, &ei_esis_version,
|
||||
"Unknown ESIS version (%u vs %u)",
|
||||
version, ESIS_REQUIRED_VERSION );
|
||||
}
|
||||
|
||||
proto_tree_add_uint_format( esis_tree, hf_esis_type, tvb, 4, 1,
|
||||
ehdr.esis_type,
|
||||
pdu_type_format_string,
|
||||
pdu_type_string,
|
||||
(ehdr.esis_type&0x80) ? "1" : "0",
|
||||
(ehdr.esis_type&0x40) ? "1" : "0",
|
||||
(ehdr.esis_type&0x20) ? "1" : "0");
|
||||
proto_tree_add_item( esis_tree, hf_esis_reserved, tvb, 3, 1, ENC_NA);
|
||||
|
||||
tmp_uint = pntoh16( ehdr.esis_holdtime );
|
||||
type_item = proto_tree_add_item( esis_tree, hf_esis_type, tvb, 4, 1, ENC_NA);
|
||||
type = tvb_get_guint8(tvb, 4) & OSI_PDU_TYPE_MASK;
|
||||
|
||||
holdtime = tvb_get_ntohs(tvb, 5);
|
||||
proto_tree_add_uint_format_value(esis_tree, hf_esis_holdtime, tvb, 5, 2,
|
||||
tmp_uint, "%u seconds",
|
||||
tmp_uint );
|
||||
holdtime, "%u seconds", holdtime);
|
||||
|
||||
tmp_uint = pntoh16( ehdr.esis_checksum );
|
||||
|
||||
switch (calc_checksum( tvb, 0, ehdr.esis_length, tmp_uint )) {
|
||||
checksum = tvb_get_ntohs(tvb, 7);
|
||||
switch (calc_checksum( tvb, 0, length, checksum)) {
|
||||
|
||||
case NO_CKSUM:
|
||||
cksum_status = "Not Used";
|
||||
|
@ -353,9 +311,7 @@ dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
DISSECTOR_ASSERT_NOT_REACHED();
|
||||
}
|
||||
proto_tree_add_uint_format_value( esis_tree, hf_esis_checksum, tvb, 7, 2,
|
||||
tmp_uint, "0x%x ( %s )",
|
||||
tmp_uint, cksum_status );
|
||||
}
|
||||
checksum, "0x%x ( %s )", checksum, cksum_status );
|
||||
|
||||
|
||||
/*
|
||||
|
@ -364,12 +320,12 @@ dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
* dispatch the sub-type.
|
||||
*/
|
||||
col_add_str(pinfo->cinfo, COL_INFO,
|
||||
val_to_str( ehdr.esis_type&OSI_PDU_TYPE_MASK, esis_vals,
|
||||
val_to_str( type, esis_vals,
|
||||
"Unknown (0x%x)" ) );
|
||||
|
||||
variable_len = ehdr.esis_length - ESIS_HDR_FIXED_LENGTH;
|
||||
variable_len = length - ESIS_HDR_FIXED_LENGTH;
|
||||
|
||||
switch (ehdr.esis_type & OSI_PDU_TYPE_MASK) {
|
||||
switch (type) {
|
||||
case ESIS_ESH_PDU:
|
||||
esis_dissect_esh_pdu( variable_len, tvb, esis_tree);
|
||||
break;
|
||||
|
@ -380,9 +336,7 @@ dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
esis_dissect_redirect_pdu( variable_len, tvb, esis_tree);
|
||||
break;
|
||||
default:
|
||||
esis_dissect_unknown(tvb, esis_tree,
|
||||
"Unknown ESIS packet type 0x%x",
|
||||
ehdr.esis_type & OSI_PDU_TYPE_MASK );
|
||||
expert_add_info(pinfo, type_item, &ei_esis_type);
|
||||
}
|
||||
} /* dissect_esis */
|
||||
|
||||
|
@ -414,13 +368,13 @@ proto_register_esis(void) {
|
|||
{ "PDU Length", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_esis_version,
|
||||
{ "Version (==1)", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ "Version", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_esis_reserved,
|
||||
{ "Reserved(==0)", "esis.res", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
|
||||
{ &hf_esis_type,
|
||||
{ "PDU Type", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals), 0xff, NULL, HFILL }},
|
||||
{ "PDU Type", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals), OSI_PDU_TYPE_MASK, NULL, HFILL }},
|
||||
|
||||
{ &hf_esis_holdtime,
|
||||
{ "Holding Time", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, "s", HFILL }},
|
||||
|
@ -438,18 +392,25 @@ proto_register_esis(void) {
|
|||
{ &hf_esis_da, { "DA", "esis.da", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_esis_bsnpa, { "BSNPA", "esis.bsnpa", FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
};
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static gint *ett[] = {
|
||||
&ett_esis,
|
||||
&ett_esis_area_addr,
|
||||
};
|
||||
|
||||
static ei_register_info ei[] = {
|
||||
{ &ei_esis_version, { "esis.ver.unknown", PI_PROTOCOL, PI_WARN, "Unknown ESIS version", EXPFILL }},
|
||||
{ &ei_esis_length, { "esis.length.invalid", PI_MALFORMED, PI_ERROR, "Bogus ESIS length", EXPFILL }},
|
||||
{ &ei_esis_type, { "esis.type.unknown", PI_PROTOCOL, PI_WARN, "Unknown ESIS packet type", EXPFILL }},
|
||||
};
|
||||
|
||||
expert_module_t* expert_esis;
|
||||
|
||||
proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
|
||||
proto_register_field_array(proto_esis, hf, array_length(hf));
|
||||
proto_register_subtree_array(ett, array_length(ett));
|
||||
expert_esis = expert_register_protocol(proto_esis);
|
||||
expert_register_field_array(expert_esis, ei, array_length(ei));
|
||||
register_dissector("esis", dissect_esis, proto_esis);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* packet-esis.h
|
||||
* Defines and such for ESIS protocol decode.
|
||||
*
|
||||
* Ralf Schneider <Ralf.Schneider@t-online.de>
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PACKET_ESIS_H
|
||||
#define _PACKET_ESIS_H
|
||||
|
||||
/* The version we support is 1 */
|
||||
#define ESIS_REQUIRED_VERSION 1
|
||||
|
||||
/* ESIS PDU types */
|
||||
#define ESIS_ESH_PDU 02
|
||||
#define ESIS_ISH_PDU 04
|
||||
#define ESIS_RD_PDU 06
|
||||
|
||||
/* The length of the fixed part */
|
||||
#define ESIS_HDR_FIXED_LENGTH 9
|
||||
|
||||
/* Inline Defines for masking */
|
||||
#define esis_type esis_type_reserved&OSI_PDU_TYPE_MASK
|
||||
#define esis_r8 esis_type_reserved&BIT_8
|
||||
#define esis_r7 esis_type_reserved&BIT_7
|
||||
#define esis_r6 esis_type_reserved&BIT_6
|
||||
|
||||
/* The fixed part (9 octets) of the ESIS protocol header */
|
||||
typedef struct {
|
||||
guint8 esis_nlpi; /* Network Layer Protocol Identifier == 0x82 */
|
||||
guint8 esis_length; /* Header ( PDU too, NoData ) length in octets */
|
||||
guint8 esis_version; /* ISIS version, must be 0x01 */
|
||||
guint8 esis_reserved; /* reserved byte, must be 0 */
|
||||
guint8 esis_type_reserved; /* packet type & MS-Bits (8-6) reserved */
|
||||
guint8 esis_holdtime[2]; /* Maximum time (sec) this PDU is valid */
|
||||
guint8 esis_checksum[2]; /* Computed on whole PDU Header, 0 means ignore */
|
||||
} esis_hdr_t;
|
||||
|
||||
#endif /* _PACKET_ESIS_H */
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/expert.h>
|
||||
#include <epan/to_str.h>
|
||||
#include "packet-ipx.h"
|
||||
|
||||
|
@ -114,6 +115,11 @@ static int hf_nlsp_svcs_info_hops_to_reach_the_service = -1;
|
|||
static int hf_nlsp_psnp_lsp_id_lsp_number = -1;
|
||||
static int hf_nlsp_ext_routes_network_number = -1;
|
||||
|
||||
static expert_field ei_nlsp_short_packet = EI_INIT;
|
||||
static expert_field ei_nlsp_long_packet = EI_INIT;
|
||||
static expert_field ei_nlsp_major_version = EI_INIT;
|
||||
static expert_field ei_nlsp_type = EI_INIT;
|
||||
|
||||
static gint ett_nlsp = -1;
|
||||
static gint ett_nlsp_hello_clv_area_addr = -1;
|
||||
static gint ett_nlsp_hello_clv_neighbors = -1;
|
||||
|
@ -179,39 +185,10 @@ typedef struct {
|
|||
int optcode; /* code for option */
|
||||
const char *tree_text; /* text for fold out */
|
||||
gint *tree_id; /* id for add_item */
|
||||
void (*dissect)(tvbuff_t *tvb, proto_tree *tree,
|
||||
void (*dissect)(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree,
|
||||
int offset, int length);
|
||||
} nlsp_clv_handle_t;
|
||||
|
||||
/*
|
||||
* Name: nlsp_dissect_unknown()
|
||||
*
|
||||
* Description:
|
||||
* There was some error in the protocol and we are in unknown space
|
||||
* here. Add a tree item to cover the error and go on. Note
|
||||
* that we make sure we don't go off the end of the bleedin packet here!
|
||||
*
|
||||
* Input
|
||||
* tvbuff_t * : tvbuffer for packet data
|
||||
* proto_tree * : tree of display data. May be NULL.
|
||||
* int : current offset into packet data
|
||||
* char * : format text
|
||||
* subsequent args : arguments to format
|
||||
*
|
||||
* Output:
|
||||
* void (may modify proto tree)
|
||||
*/
|
||||
static void
|
||||
nlsp_dissect_unknown(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
const char *fmat, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmat);
|
||||
proto_tree_add_text_valist(tree, tvb, offset, -1, fmat, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Name: nlsp_dissect_clvs()
|
||||
*
|
||||
|
@ -242,7 +219,7 @@ nlsp_dissect_unknown(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
nlsp_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
nlsp_dissect_clvs(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
const nlsp_clv_handle_t *opts, int len, int unknown_tree_id _U_)
|
||||
{
|
||||
guint8 code;
|
||||
|
@ -264,9 +241,8 @@ nlsp_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
break;
|
||||
|
||||
if ( len < length ) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
"Short CLV header (%d vs %d)",
|
||||
length, len );
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short CLV header (%d vs %d)", length, len );
|
||||
return;
|
||||
}
|
||||
q = 0;
|
||||
|
@ -278,7 +254,7 @@ nlsp_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
clv_tree = proto_tree_add_subtree_format(tree, tvb, offset - 2,
|
||||
length + 2, *opts[q].tree_id, NULL, "%s (%u)",
|
||||
opts[q].tree_text, length );
|
||||
opts[q].dissect(tvb, clv_tree, offset,
|
||||
opts[q].dissect(tvb, pinfo, clv_tree, offset,
|
||||
length);
|
||||
} else {
|
||||
proto_item* ti;
|
||||
|
@ -307,12 +283,12 @@ nlsp_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_area_address_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
while (length > 0) {
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short area address entry");
|
||||
return;
|
||||
}
|
||||
|
@ -322,7 +298,7 @@ dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short area address entry");
|
||||
return;
|
||||
}
|
||||
|
@ -349,13 +325,13 @@ dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_neighbor_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_neighbor_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
while (length > 0) {
|
||||
if (length < 6) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
"Short neighbor entry");
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet,
|
||||
tvb, offset, -1, "Short neighbor entry");
|
||||
return;
|
||||
}
|
||||
proto_tree_add_item(tree, hf_nlsp_neighbor, tvb, offset, 6, ENC_NA);
|
||||
|
@ -380,11 +356,11 @@ dissect_neighbor_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_hello_local_mtu_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_hello_local_mtu_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -510,7 +486,7 @@ nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
|
||||
len = packet_length - header_length;
|
||||
if (len < 0) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_long_packet, tvb, offset, -1,
|
||||
"packet header length %d went beyond packet",
|
||||
header_length);
|
||||
return;
|
||||
|
@ -520,7 +496,7 @@ nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* Now, we need to decode our CLVs. We need to pass in
|
||||
* our list of valid ones!
|
||||
*/
|
||||
nlsp_dissect_clvs(tvb, tree, offset,
|
||||
nlsp_dissect_clvs(tvb, pinfo, tree, offset,
|
||||
clv_hello_opts, len, ett_nlsp_hello_clv_unknown);
|
||||
}
|
||||
|
||||
|
@ -540,13 +516,13 @@ nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_lsp_mgt_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
guint8 name_length;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short management info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -555,7 +531,7 @@ dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 6) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short management info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -564,7 +540,7 @@ dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 6;
|
||||
|
||||
if (length < 1) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short management info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -574,7 +550,7 @@ dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 1;
|
||||
|
||||
if (length < 1) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short management info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -585,7 +561,7 @@ dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
|
||||
if (name_length != 0) {
|
||||
if (length < name_length) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short management info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -648,13 +624,13 @@ static const value_string media_type_vals[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_lsp_link_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
guint8 flags_cost;
|
||||
|
||||
if (length < 1) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -673,7 +649,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 1;
|
||||
|
||||
if (length < 3) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -681,7 +657,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 3;
|
||||
|
||||
if (length < 7) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -692,7 +668,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 7;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -701,7 +677,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -711,7 +687,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -721,7 +697,7 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 2) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short link info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -744,11 +720,11 @@ dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_lsp_svcs_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
if (length < 1) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short services info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -758,7 +734,7 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 1;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short services info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -768,7 +744,7 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 6) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short services info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -778,7 +754,7 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 6;
|
||||
|
||||
if (length < 2) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short services info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -788,7 +764,7 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 2;
|
||||
|
||||
if (length < 2) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short services info entry");
|
||||
return;
|
||||
}
|
||||
|
@ -819,12 +795,12 @@ dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_lsp_ext_routes_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_lsp_ext_routes_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
while (length > 0) {
|
||||
if (length < 1) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short external routes entry");
|
||||
return;
|
||||
}
|
||||
|
@ -834,7 +810,7 @@ dissect_lsp_ext_routes_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 1;
|
||||
|
||||
if (length < 4) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short external routes entry");
|
||||
return;
|
||||
}
|
||||
|
@ -844,7 +820,7 @@ dissect_lsp_ext_routes_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
length -= 4;
|
||||
|
||||
if (length < 2) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short external routes entry");
|
||||
return;
|
||||
}
|
||||
|
@ -989,7 +965,7 @@ nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
|
||||
len = packet_length - header_length;
|
||||
if (len < 0) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_long_packet, tvb, offset, -1,
|
||||
"packet header length %d went beyond packet",
|
||||
header_length);
|
||||
return;
|
||||
|
@ -999,7 +975,7 @@ nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* Now, we need to decode our CLVs. We need to pass in
|
||||
* our list of valid ones!
|
||||
*/
|
||||
nlsp_dissect_clvs(tvb, tree, offset,
|
||||
nlsp_dissect_clvs(tvb, pinfo, tree, offset,
|
||||
clv_l1_lsp_opts, len, ett_nlsp_lsp_clv_unknown);
|
||||
}
|
||||
|
||||
|
@ -1024,14 +1000,14 @@ nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* void, but we will add to proto tree if !NULL.
|
||||
*/
|
||||
static void
|
||||
dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_csnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
proto_tree *subtree;
|
||||
|
||||
while (length > 0) {
|
||||
if (length < 16) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short CSNP header entry");
|
||||
return;
|
||||
}
|
||||
|
@ -1060,14 +1036,14 @@ dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
|
|||
}
|
||||
|
||||
static void
|
||||
dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
|
||||
dissect_psnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
|
||||
int length)
|
||||
{
|
||||
proto_tree *subtree;
|
||||
|
||||
while (length > 0) {
|
||||
if (length < 16) {
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
|
||||
"Short PSNP header entry");
|
||||
return;
|
||||
}
|
||||
|
@ -1171,7 +1147,7 @@ nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
return;
|
||||
}
|
||||
/* Call into payload dissector */
|
||||
nlsp_dissect_clvs(tvb, tree, offset,
|
||||
nlsp_dissect_clvs(tvb, pinfo, tree, offset,
|
||||
clv_l1_csnp_opts, len, ett_nlsp_csnp_clv_unknown);
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1208,7 @@ nlsp_dissect_nlsp_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
return;
|
||||
}
|
||||
/* Call into payload dissector */
|
||||
nlsp_dissect_clvs(tvb, tree, offset,
|
||||
nlsp_dissect_clvs(tvb, pinfo, tree, offset,
|
||||
clv_l1_psnp_opts, len, ett_nlsp_psnp_clv_unknown);
|
||||
}
|
||||
|
||||
|
@ -1254,7 +1230,7 @@ nlsp_dissect_nlsp_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
static void
|
||||
dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
proto_item *ti;
|
||||
proto_item *ti, *type_item;
|
||||
proto_tree *nlsp_tree;
|
||||
int offset = 0;
|
||||
guint8 nlsp_major_version;
|
||||
|
@ -1265,18 +1241,6 @@ dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "NLSP");
|
||||
col_clear(pinfo->cinfo, COL_INFO);
|
||||
|
||||
nlsp_major_version = tvb_get_guint8(tvb, 5);
|
||||
if (nlsp_major_version != 1){
|
||||
col_add_fstr(pinfo->cinfo, COL_INFO,
|
||||
"Unknown NLSP version (%u vs 1)",
|
||||
nlsp_major_version);
|
||||
|
||||
nlsp_dissect_unknown(tvb, tree, 0,
|
||||
"Unknown NLSP version (%d vs 1)",
|
||||
nlsp_major_version, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
ti = proto_tree_add_item(tree, proto_nlsp, tvb, 0, -1, ENC_NA);
|
||||
nlsp_tree = proto_item_add_subtree(ti, ett_nlsp);
|
||||
|
||||
|
@ -1302,11 +1266,17 @@ dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
if (packet_type == NLSP_TYPE_L1_LSP) {
|
||||
proto_tree_add_boolean(nlsp_tree, hf_nlsp_nr, tvb, offset, 1, packet_type_flags );
|
||||
}
|
||||
proto_tree_add_uint(nlsp_tree, hf_nlsp_type, tvb, offset, 1, packet_type_flags );
|
||||
type_item = proto_tree_add_uint(nlsp_tree, hf_nlsp_type, tvb, offset, 1, packet_type_flags );
|
||||
offset += 1;
|
||||
|
||||
proto_tree_add_item(nlsp_tree, hf_nlsp_major_version, tvb,
|
||||
nlsp_major_version = tvb_get_guint8(tvb, offset);
|
||||
ti = proto_tree_add_item(nlsp_tree, hf_nlsp_major_version, tvb,
|
||||
offset, 1, ENC_BIG_ENDIAN );
|
||||
if (nlsp_major_version != 1){
|
||||
expert_add_info_format(pinfo, ti, &ei_nlsp_major_version,
|
||||
"Unknown NLSP version (%d vs 1)",
|
||||
nlsp_major_version);
|
||||
}
|
||||
offset += 1;
|
||||
|
||||
offset += 2; /* Reserved */
|
||||
|
@ -1335,8 +1305,7 @@ dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
break;
|
||||
|
||||
default:
|
||||
nlsp_dissect_unknown(tvb, tree, offset,
|
||||
"Unknown NLSP packet type");
|
||||
expert_add_info(pinfo, type_item, &ei_nlsp_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1528,10 +1497,21 @@ proto_register_nlsp(void)
|
|||
&ett_nlsp_psnp_clv_unknown,
|
||||
};
|
||||
|
||||
static ei_register_info ei[] = {
|
||||
{ &ei_nlsp_short_packet, { "nlsp.short_packet", PI_MALFORMED, PI_ERROR, "Short packet", EXPFILL }},
|
||||
{ &ei_nlsp_long_packet, { "nlsp.long_packet", PI_MALFORMED, PI_ERROR, "Long packet", EXPFILL }},
|
||||
{ &ei_nlsp_major_version, { "nlsp.major_version.unknown", PI_PROTOCOL, PI_WARN, "Unknown NLSP version", EXPFILL }},
|
||||
{ &ei_nlsp_type, { "nlsp.type.unknown", PI_PROTOCOL, PI_WARN, "Unknown NLSP packet type", EXPFILL }},
|
||||
};
|
||||
|
||||
expert_module_t* expert_nlsp;
|
||||
|
||||
proto_nlsp = proto_register_protocol("NetWare Link Services Protocol",
|
||||
"NLSP", "nlsp");
|
||||
proto_register_field_array(proto_nlsp, hf, array_length(hf));
|
||||
proto_register_subtree_array(ett, array_length(ett));
|
||||
expert_nlsp = expert_register_protocol(proto_nlsp);
|
||||
expert_register_field_array(expert_nlsp, ei, array_length(ei));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue