コード例 #1
0
/*
 * Name: isis_dissect_isis_psnp()
 *
 * Description:
 *	Tear apart a L1 or L2 PSNP header and then call into payload dissect
 *	to pull apart the lsp id payload.
 *
 * Input:
 *	tvbuff_t * : tvbuffer for packet data
 *	proto_tree * : protocol display tree to add to.  May be NULL.
 *	int : our offset into packet data
 *	int : type (l1 psnp, l2 psnp)
 *	int : header length of packet.
 *	int : length of IDs in packet.
 *
 * Output:
 *      void, but we will add to proto tree if !NULL.
 */
void
isis_dissect_isis_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
	int type, int header_length, int id_length)
{
	proto_item	*ti;
	proto_tree	*psnp_tree = NULL;
	guint16		pdu_length;
	int 		len;

	if (tree) {
		ti = proto_tree_add_text(tree, tvb, offset, -1,
		    PROTO_STRING_PSNP);
		psnp_tree = proto_item_add_subtree(ti, ett_isis_psnp);
	}

	pdu_length = tvb_get_ntohs(tvb, offset);
	if (tree) {
		proto_tree_add_uint(psnp_tree, hf_isis_psnp_pdu_length, tvb,
			offset, 2, pdu_length);
	}
	offset += 2;

	if (tree) {
		proto_tree_add_text(psnp_tree, tvb, offset, id_length + 1,
			"Source-ID: %s",
			print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length + 1 ) );
	}
	if (check_col(pinfo->cinfo, COL_INFO)) {
		col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
			print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
	}
	offset += id_length + 1;

	len = pdu_length - header_length;
	if (len < 0) {
		isis_dissect_unknown(tvb, tree, offset,
			"packet header length %d went beyond packet",
			header_length );
		return;
	}
	/* Call into payload dissector */
	if (type == ISIS_TYPE_L1_PSNP ) {
		isis_dissect_clvs(tvb, psnp_tree, offset,
			clv_l1_psnp_opts, len, id_length,
			ett_isis_psnp_clv_unknown );
	} else {
		isis_dissect_clvs(tvb, psnp_tree, offset,
			clv_l2_psnp_opts, len, id_length,
			ett_isis_psnp_clv_unknown );
	}
}
コード例 #2
0
/*
 * Name: isis_dissect_isis_hello()
 *
 * Description:
 *	This procedure rips apart the various types of ISIS hellos.  L1H and
 *	L2H's are identical for the most part, while the PTP hello has
 *	a shorter header.
 *
 * Input:
 *	tvbuff_t * : tvbuffer for packet data
 *	proto_tree * : protocol display tree to add to.  May be NULL.
 *	int offset : our offset into packet data.
 *	int : hello type, a la packet-isis.h ISIS_TYPE_* values
 *	int : header length of packet.
 *	int : length of IDs in packet.
 *
 * Output:
 *	void, will modify proto_tree if not NULL.
 */
void
isis_dissect_isis_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
                        int hello_type, int header_length, int id_length)
{
    proto_item	*ti;
    proto_tree	*hello_tree = NULL;
    int 		len;
    guint8		octet;
    const guint8	*source_id;
    guint16		pdu_length;
    const guint8	*lan_id;

    if (tree) {
        ti = proto_tree_add_text(tree, tvb, offset, -1, "ISIS HELLO");
        hello_tree = proto_item_add_subtree(ti, ett_isis_hello);
        octet = tvb_get_guint8(tvb, offset);
        proto_tree_add_uint_format(hello_tree,
                                   hf_isis_hello_circuit_reserved,
                                   tvb, offset, 1, octet,
                                   "Circuit type              : %s, reserved(0x%02x == 0)",
                                   val_to_str(octet&ISIS_HELLO_CTYPE_MASK,
                                              isis_hello_circuit_type_vals,
                                              "Unknown (0x%x)"),
                                   octet&ISIS_HELLO_CT_RESERVED_MASK
                                  );
    }
    offset += 1;

    if (tree) {
        source_id = tvb_get_ptr(tvb, offset, id_length);
        proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, tvb,
                                    offset, id_length, source_id,
                                    "System-ID {Sender of PDU} : %s",
                                    print_system_id( source_id, id_length ) );
    }
    if (check_col(pinfo->cinfo, COL_INFO)) {
        col_append_fstr(pinfo->cinfo, COL_INFO, ", System-ID: %s",
                        print_system_id( tvb_get_ptr(tvb, offset, id_length), id_length ) );
    }
    offset += id_length;

    if (tree) {
        proto_tree_add_item(hello_tree, hf_isis_hello_holding_timer, tvb,
                            offset, 2, ENC_BIG_ENDIAN);
    }
    offset += 2;

    pdu_length = tvb_get_ntohs(tvb, offset);
    if (tree) {
        proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, tvb,
                            offset, 2, pdu_length);
    }
    offset += 2;

    if (hello_type == ISIS_TYPE_PTP_HELLO) {
        if (tree) {
            proto_tree_add_item(hello_tree, hf_isis_hello_local_circuit_id, tvb,
                                offset, 1, ENC_BIG_ENDIAN );
        }
        offset += 1;
    } else {
        if (tree) {
            octet = tvb_get_guint8(tvb, offset);
            proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, tvb,
                                       offset, 1, octet,
                                       "Priority                  : %d, reserved(0x%02x == 0)",
                                       octet&ISIS_HELLO_PRIORITY_MASK,
                                       octet&ISIS_HELLO_P_RESERVED_MASK );
        }
        offset += 1;

        if (tree) {
            lan_id = tvb_get_ptr(tvb, offset, id_length+1);
            proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, tvb,
                                        offset, id_length + 1, lan_id,
                                        "System-ID {Designated IS} : %s",
                                        print_system_id( lan_id, id_length + 1 ) );
        }
        offset += id_length + 1;
    }

    len = pdu_length;
    len -= header_length;
    if (len < 0) {
        isis_dissect_unknown(tvb, tree, offset,
                             "Packet header length %d went beyond packet",
                             header_length );
        return;
    }
    /*
     * Now, we need to decode our CLVs.  We need to pass in
     * our list of valid ones!
     */
    if (hello_type == ISIS_TYPE_L1_HELLO) {
        isis_dissect_clvs(tvb, hello_tree, offset,
                          clv_l1_hello_opts, len, id_length,
                          ett_isis_hello_clv_unknown);
    } else if (hello_type == ISIS_TYPE_L2_HELLO) {
        isis_dissect_clvs(tvb, hello_tree, offset,
                          clv_l2_hello_opts, len, id_length,
                          ett_isis_hello_clv_unknown);
    } else {
        isis_dissect_clvs(tvb, hello_tree, offset,
                          clv_ptp_hello_opts, len, id_length,
                          ett_isis_hello_clv_unknown);
    }
}
コード例 #3
0
/*
 * Name: isis_dissect_isis_csnp()
 *
 * Description:
 *	Tear apart a L1 or L2 CSNP header and then call into payload dissect
 *	to pull apart the lsp id payload.
 *
 * Input:
 *	tvbuff_t * : tvbuffer for packet data
 *	proto_tree * : protocol display tree to add to.  May be NULL.
 *	int offset : our offset into packet data.
 *	int : type (l1 csnp, l2 csnp)
 *	int : header length of packet.
 *	int : length of IDs in packet.
 *
 * Output:
 *      void, but we will add to proto tree if !NULL.
 */
void
isis_dissect_isis_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
	int type, int header_length, int id_length)
{
	proto_item	*ti;
	proto_tree	*csnp_tree = NULL;
	guint16		pdu_length;
	int 		len;

	if (tree) {
		ti = proto_tree_add_text(tree, tvb, offset, -1,
		    PROTO_STRING_CSNP);
		csnp_tree = proto_item_add_subtree(ti, ett_isis_csnp);
	}

	pdu_length = tvb_get_ntohs(tvb, offset);
	if (tree) {
		proto_tree_add_uint(csnp_tree, hf_isis_csnp_pdu_length, tvb,
			offset, 2, pdu_length);
	}
	offset += 2;

	if (tree) {
		proto_tree_add_text(csnp_tree, tvb, offset, id_length + 1,
			"Source-ID:    %s",
				print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
	}
	col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
			print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );

	offset += id_length + 1;

	proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2, "Start LSP-ID: %s",
                                    print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );

	col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP-ID: %s",
			print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );

	offset += id_length + 2;

	proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2, "End LSP-ID: %s",
                                    print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );

	col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP-ID: %s",
			print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );

	offset += id_length + 2;

	len = pdu_length - header_length;
	if (len < 0) {
		return;
	}
	/* Call into payload dissector */
	if (type == ISIS_TYPE_L1_CSNP ) {
		isis_dissect_clvs(tvb, csnp_tree, offset,
			clv_l1_csnp_opts, len, id_length,
			ett_isis_csnp_clv_unknown );
	} else {
		isis_dissect_clvs(tvb, csnp_tree, offset,
			clv_l2_csnp_opts, len, id_length,
			ett_isis_csnp_clv_unknown );
	}
}