Ejemplo n.º 1
0
static void
atp_print(netdissect_options *ndo,
          register const struct atATP *ap, u_int length)
{
	char c;
	uint32_t data;

	if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
		/* Just bail if we don't have the whole chunk. */
		ND_PRINT((ndo, "%s", tstr));
		return;
	}
	if (length < sizeof(*ap)) {
		ND_PRINT((ndo, " [|atp %u]", length));
		return;
	}
	length -= sizeof(*ap);
	switch (ap->control & 0xc0) {

	case atpReqCode:
		ND_PRINT((ndo, " atp-req%s %d",
			     ap->control & atpXO? " " : "*",
			     EXTRACT_16BITS(&ap->transID)));

		atp_bitmap_print(ndo, ap->bitmap);

		if (length != 0)
			ND_PRINT((ndo, " [len=%u]", length));

		switch (ap->control & (atpEOM|atpSTS)) {
		case atpEOM:
			ND_PRINT((ndo, " [EOM]"));
			break;
		case atpSTS:
			ND_PRINT((ndo, " [STS]"));
			break;
		case atpEOM|atpSTS:
			ND_PRINT((ndo, " [EOM,STS]"));
			break;
		}
		break;

	case atpRspCode:
		ND_PRINT((ndo, " atp-resp%s%d:%d (%u)",
			     ap->control & atpEOM? "*" : " ",
			     EXTRACT_16BITS(&ap->transID), ap->bitmap, length));
		switch (ap->control & (atpXO|atpSTS)) {
		case atpXO:
			ND_PRINT((ndo, " [XO]"));
			break;
		case atpSTS:
			ND_PRINT((ndo, " [STS]"));
			break;
		case atpXO|atpSTS:
			ND_PRINT((ndo, " [XO,STS]"));
			break;
		}
		break;

	case atpRelCode:
		ND_PRINT((ndo, " atp-rel  %d", EXTRACT_16BITS(&ap->transID)));

		atp_bitmap_print(ndo, ap->bitmap);

		/* length should be zero */
		if (length)
			ND_PRINT((ndo, " [len=%u]", length));

		/* there shouldn't be any control flags */
		if (ap->control & (atpXO|atpEOM|atpSTS)) {
			c = '[';
			if (ap->control & atpXO) {
				ND_PRINT((ndo, "%cXO", c));
				c = ',';
			}
			if (ap->control & atpEOM) {
				ND_PRINT((ndo, "%cEOM", c));
				c = ',';
			}
			if (ap->control & atpSTS) {
				ND_PRINT((ndo, "%cSTS", c));
				c = ',';
			}
			ND_PRINT((ndo, "]"));
		}
		break;

	default:
		ND_PRINT((ndo, " atp-0x%x  %d (%u)", ap->control,
			     EXTRACT_16BITS(&ap->transID), length));
		break;
	}
	data = EXTRACT_32BITS(&ap->userData);
	if (data != 0)
		ND_PRINT((ndo, " 0x%x", data));
}
Ejemplo n.º 2
0
static void
atp_print(register const struct atATP *ap, u_int length)
{
	char c;
	u_int32_t data;

	if ((const u_char *)(ap + 1) > snapend) {
		/* Just bail if we don't have the whole chunk. */
		fputs(tstr, stdout);
		return;
	}
	length -= sizeof(*ap);
	switch (ap->control & 0xc0) {

	case atpReqCode:
		(void)printf(" atp-req%s %d",
			     ap->control & atpXO? " " : "*",
			     EXTRACT_16BITS(&ap->transID));

		atp_bitmap_print(ap->bitmap);

		if (length != 0)
			(void)printf(" [len=%d]", length);

		switch (ap->control & (atpEOM|atpSTS)) {
		case atpEOM:
			(void)printf(" [EOM]");
			break;
		case atpSTS:
			(void)printf(" [STS]");
			break;
		case atpEOM|atpSTS:
			(void)printf(" [EOM,STS]");
			break;
		}
		break;

	case atpRspCode:
		(void)printf(" atp-resp%s%d:%d (%d)",
			     ap->control & atpEOM? "*" : " ",
			     EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
		switch (ap->control & (atpXO|atpSTS)) {
		case atpXO:
			(void)printf(" [XO]");
			break;
		case atpSTS:
			(void)printf(" [STS]");
			break;
		case atpXO|atpSTS:
			(void)printf(" [XO,STS]");
			break;
		}
		break;

	case atpRelCode:
		(void)printf(" atp-rel  %d", EXTRACT_16BITS(&ap->transID));

		atp_bitmap_print(ap->bitmap);

		/* length should be zero */
		if (length)
			(void)printf(" [len=%d]", length);

		/* there shouldn't be any control flags */
		if (ap->control & (atpXO|atpEOM|atpSTS)) {
			c = '[';
			if (ap->control & atpXO) {
				(void)printf("%cXO", c);
				c = ',';
			}
			if (ap->control & atpEOM) {
				(void)printf("%cEOM", c);
				c = ',';
			}
			if (ap->control & atpSTS) {
				(void)printf("%cSTS", c);
				c = ',';
			}
			(void)printf("]");
		}
		break;

	default:
		(void)printf(" atp-0x%x  %d (%d)", ap->control,
			     EXTRACT_16BITS(&ap->transID), length);
		break;
	}
	data = EXTRACT_32BITS(&ap->userData);
	if (data != 0)
		(void)printf(" 0x%x", data);
}
Ejemplo n.º 3
0
static void
atp_print(netdissect_options *ndo,
          const struct atATP *ap, u_int length)
{
	uint8_t control;
	uint32_t data;

	if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
		/* Just bail if we don't have the whole chunk. */
		nd_print_trunc(ndo);
		return;
	}
	if (length < sizeof(*ap)) {
		ND_PRINT(" [|atp %u]", length);
		return;
	}
	length -= sizeof(*ap);
	control = EXTRACT_U_1(ap->control);
	switch (control & 0xc0) {

	case atpReqCode:
		ND_PRINT(" atp-req%s %u",
			     control & atpXO? " " : "*",
			     EXTRACT_BE_U_2(ap->transID));

		atp_bitmap_print(ndo, EXTRACT_U_1(ap->bitmap));

		if (length != 0)
			ND_PRINT(" [len=%u]", length);

		switch (control & (atpEOM|atpSTS)) {
		case atpEOM:
			ND_PRINT(" [EOM]");
			break;
		case atpSTS:
			ND_PRINT(" [STS]");
			break;
		case atpEOM|atpSTS:
			ND_PRINT(" [EOM,STS]");
			break;
		}
		break;

	case atpRspCode:
		ND_PRINT(" atp-resp%s%u:%u (%u)",
			     control & atpEOM? "*" : " ",
			     EXTRACT_BE_U_2(ap->transID), EXTRACT_U_1(ap->bitmap), length);
		switch (control & (atpXO|atpSTS)) {
		case atpXO:
			ND_PRINT(" [XO]");
			break;
		case atpSTS:
			ND_PRINT(" [STS]");
			break;
		case atpXO|atpSTS:
			ND_PRINT(" [XO,STS]");
			break;
		}
		break;

	case atpRelCode:
		ND_PRINT(" atp-rel  %u", EXTRACT_BE_U_2(ap->transID));

		atp_bitmap_print(ndo, EXTRACT_U_1(ap->bitmap));

		/* length should be zero */
		if (length)
			ND_PRINT(" [len=%u]", length);

		/* there shouldn't be any control flags */
		if (control & (atpXO|atpEOM|atpSTS)) {
			char c = '[';
			if (control & atpXO) {
				ND_PRINT("%cXO", c);
				c = ',';
			}
			if (control & atpEOM) {
				ND_PRINT("%cEOM", c);
				c = ',';
			}
			if (control & atpSTS) {
				ND_PRINT("%cSTS", c);
			}
			ND_PRINT("]");
		}
		break;

	default:
		ND_PRINT(" atp-0x%x  %u (%u)", control,
			     EXTRACT_BE_U_2(ap->transID), length);
		break;
	}
	data = EXTRACT_BE_U_4(ap->userData);
	if (data != 0)
		ND_PRINT(" 0x%x", data);
}