コード例 #1
0
ファイル: print-dhcp6.c プロジェクト: bashow0316/tcpdump
/*
 * Print dhcp6 packets
 */
void
dhcp6_print(netdissect_options *ndo,
            const u_char *cp, u_int length)
{
	const struct dhcp6 *dh6;
	const struct dhcp6_relay *dh6relay;
	uint8_t msgtype;
	const u_char *ep;
	const u_char *extp;
	const char *name;

	ND_PRINT("dhcp6");

	ep = ndo->ndo_snapend;
	if (cp + length < ep)
		ep = cp + length;

	dh6 = (const struct dhcp6 *)cp;
	dh6relay = (const struct dhcp6_relay *)cp;
	ND_TCHECK_4(dh6->dh6_msgtypexid.xid);
	msgtype = EXTRACT_U_1(dh6->dh6_msgtypexid.msgtype);
	name = tok2str(dh6_msgtype_str, "msgtype-%u", msgtype);

	if (!ndo->ndo_vflag) {
		ND_PRINT(" %s", name);
		return;
	}

	/* XXX relay agent messages have to be handled differently */

	ND_PRINT(" %s (", name);	/*)*/
	if (msgtype != DH6_RELAY_FORW && msgtype != DH6_RELAY_REPLY) {
		ND_PRINT("xid=%x",
			 EXTRACT_BE_U_4(dh6->dh6_msgtypexid.xid) & DH6_XIDMASK);
		extp = (const u_char *)(dh6 + 1);
		dhcp6opt_print(ndo, extp, ep);
	} else {		/* relay messages */
		ND_TCHECK_16(dh6relay->dh6relay_peeraddr);

		ND_PRINT("linkaddr=%s", ip6addr_string(ndo, dh6relay->dh6relay_linkaddr));

		ND_PRINT(" peeraddr=%s", ip6addr_string(ndo, dh6relay->dh6relay_peeraddr));

		dhcp6opt_print(ndo, (const u_char *)(dh6relay + 1), ep);
	}
	/*(*/
	ND_PRINT(")");
	return;

trunc:
	ND_PRINT("[|dhcp6]");
}
コード例 #2
0
ファイル: print-radius.c プロジェクト: biot/tcpdump
static void
print_attr_address6(netdissect_options *ndo,
                   const u_char *data, u_int length, u_short attr_code _U_)
{
   if (length != 16)
   {
       ND_PRINT("ERROR: length %u != 16", length);
       return;
   }

   ND_TCHECK_16(data);

   ND_PRINT("%s", ip6addr_string(ndo, data));

   return;

   trunc:
     nd_print_trunc(ndo);
}
コード例 #3
0
ファイル: print-ahcp.c プロジェクト: biot/tcpdump
static int
ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
	const char *sep = ": ";

	while (cp < ep) {
		if (cp + 16 > ep)
			goto invalid;
		ND_TCHECK_16(cp);
		ND_PRINT("%s%s", sep, ip6addr_string(ndo, cp));
		cp += 16;
		sep = ", ";
	}
	return 0;

invalid:
	ND_PRINT("%s", istr);
	ND_TCHECK_LEN(cp, ep - cp);
	return 0;
trunc:
	nd_print_trunc(ndo);
	return -1;
}