Example #1
0
static int
otlv_print(netdissect_options *ndo,
           const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
{
	int rc = 0;
	register const u_char *dp = (u_char *) TLV_DATA(otlv);
	u_int16_t type;
	int tll;
	char *ib = indent_pr(indent, 0);
	const struct optlv_h *ops;

	/*
	 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
	 * >= TLV_HDRL.
	 */
	ND_TCHECK(*otlv);
	type = EXTRACT_16BITS(&otlv->type);
	tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
	ops = get_forces_optlv_h(type);
	if (ndo->ndo_vflag >= 3) {
		ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
		       EXTRACT_16BITS(&otlv->length)));
	}
	/* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
	if (!ops->flags & ZERO_TTLV) {
		if (tll != 0)	/* instead of "if (tll)" - for readability .. */
			ND_PRINT((ndo, "%s: Illegal - MUST be empty\n", ops->s));
		return rc;
	}
	/* rest of ops must at least have 12B {pathinfo} */
	if (tll < OP_MIN_SIZ) {
		ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
		       EXTRACT_16BITS(&otlv->length)));
		ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
		       OP_MIN_SIZ));
		return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);

	}

	rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
	return rc;

trunc:
	ND_PRINT((ndo, "%s", tstr));
	return -1;
}
Example #2
0
static int
otlv_print(netdissect_options *ndo,
           const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
{
	int rc = 0;
	register const u_char *dp = (u_char *) TLV_DATA(otlv);
	uint16_t type;
	int tll;
	char *ib = indent_pr(indent, 0);
	const struct optlv_h *ops;

	/*
	 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
	 * >= TLV_HDRL.
	 */
	ND_TCHECK(*otlv);
	type = EXTRACT_16BITS(&otlv->type);
	tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
	ops = get_forces_optlv_h(type);
	if (ndo->ndo_vflag >= 3) {
		ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
		       EXTRACT_16BITS(&otlv->length)));
	}
	/* rest of ops must at least have 12B {pathinfo} */
	if (tll < OP_MIN_SIZ) {
		ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
		       EXTRACT_16BITS(&otlv->length)));
		ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
		       OP_MIN_SIZ));
		return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);

	}

	/* XXX - do anything with ops->flags? */
        if(ops->print) {
                rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
        }
	return rc;

trunc:
	ND_PRINT((ndo, "%s", tstr));
	return -1;
}