当前位置: 首页>>代码示例>>C++>>正文


C++ TCHECK函数代码示例

本文整理汇总了C++中TCHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ TCHECK函数的具体用法?C++ TCHECK怎么用?C++ TCHECK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TCHECK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: blabel_print

/* print a <domain-name> */
static const u_char *
blabel_print(const u_char *cp)
{
	int bitlen, slen, b;
	const u_char *bitp, *lim;
	char tc;

	if (!TTEST2(*cp, 1))
		return(NULL);
	if ((bitlen = *cp) == 0)
		bitlen = 256;
	slen = (bitlen + 3) / 4;
	lim = cp + 1 + slen;

	/* print the bit string as a hex string */
	printf("\\[x");
	for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
		TCHECK(*bitp);
		printf("%02x", *bitp);
	}
	if (b > 4) {
		TCHECK(*bitp);
		tc = *bitp++;
		printf("%02x", tc & (0xff << (8 - b)));
	} else if (b > 0) {
		TCHECK(*bitp);
		tc = *bitp++;
		printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
	}
开发者ID:enukane,项目名称:netbsd-src,代码行数:30,代码来源:print-domain.c

示例2: parsereq

/*
 * Return a pointer to the first file handle in the packet.
 * If the packet was truncated, return 0.
 */
static const u_int32_t *
parsereq(register const struct sunrpc_msg *rp, register u_int length)
{
	register const u_int32_t *dp;
	register u_int len;

	/*
	 * find the start of the req data (if we captured it)
	 */
	dp = (u_int32_t *)&rp->rm_call.cb_cred;
	TCHECK(dp[1]);
	len = EXTRACT_32BITS(&dp[1]);
	if (len < length) {
		dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
		TCHECK(dp[1]);
		len = EXTRACT_32BITS(&dp[1]);
		if (len < length) {
			dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
			TCHECK2(dp[0], 0);
			return (dp);
		}
	}
trunc:
	return (NULL);
}
开发者ID:cherry-wb,项目名称:tcpdump,代码行数:29,代码来源:print-nfs.c

示例3: isakmp_sa_print

static const u_char *
isakmp_sa_print(const struct isakmp_gen *ext,
		u_int item_len _U_,
		const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
		u_int32_t proto0, int depth)
{
	const struct isakmp_pl_sa *p;
	struct isakmp_pl_sa sa;
	const u_int32_t *q;
	u_int32_t doi, sit, ident;
	const u_char *cp, *np;
	int t;

	printf("%s:", NPSTR(ISAKMP_NPTYPE_SA));

	p = (struct isakmp_pl_sa *)ext;
	TCHECK(*p);
	safememcpy(&sa, ext, sizeof(sa));
	doi = ntohl(sa.doi);
	sit = ntohl(sa.sit);
	if (doi != 1) {
		printf(" doi=%d", doi);
		printf(" situation=%u", (u_int32_t)ntohl(sa.sit));
		return (u_char *)(p + 1);
	}

	printf(" doi=ipsec");
	q = (u_int32_t *)&sa.sit;
	printf(" situation=");
	t = 0;
	if (sit & 0x01) {
		printf("identity");
		t++;
	}
	if (sit & 0x02) {
		printf("%ssecrecy", t ? "+" : "");
		t++;
	}
	if (sit & 0x04)
		printf("%sintegrity", t ? "+" : "");

	np = (u_char *)ext + sizeof(sa);
	if (sit != 0x01) {
		TCHECK2(*(ext + 1), sizeof(ident));
		safememcpy(&ident, ext + 1, sizeof(ident));
		printf(" ident=%u", (u_int32_t)ntohl(ident));
		np += sizeof(ident);
	}

	ext = (struct isakmp_gen *)np;
	TCHECK(*ext);

	cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0,
		depth);

	return cp;
trunc:
	printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SA));
	return NULL;
}
开发者ID:0omega,项目名称:platform_external_tcpdump,代码行数:60,代码来源:print-isakmp.c

示例4: ospf6_print

void
ospf6_print(register const u_char *bp, register u_int length)
{
	register const struct ospf6hdr *op;
	register const u_char *dataend;
	register const char *cp;

	op = (struct ospf6hdr *)bp;

	/* If the type is valid translate it, or just print the type */
	/* value.  If it's not valid, say so and return */
	TCHECK(op->ospf6_type);
	cp = tok2str(ospf6_type_values, "unknown LS-type", op->ospf6_type);
	printf("OSPFv%u, %s, length %d", op->ospf6_version, cp, length);
	if (*cp == 'u') {
		return;
        }

        if(!vflag) { /* non verbose - so lets bail out here */
                return;
        }

	TCHECK(op->ospf6_len);
	if (length != EXTRACT_16BITS(&op->ospf6_len)) {
		printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
		return;
	}
	dataend = bp + length;

	/* Print the routerid if it is not the same as the source */
	TCHECK(op->ospf6_routerid);
	printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf6_routerid));

	TCHECK(op->ospf6_areaid);
	if (op->ospf6_areaid != 0)
		printf(", Area %s", ipaddr_string(&op->ospf6_areaid));
	else
		printf(", Backbone Area");
	TCHECK(op->ospf6_instanceid);
	if (op->ospf6_instanceid)
		printf(", Instance %u", op->ospf6_instanceid);

	/* Do rest according to version.	 */
	switch (op->ospf6_version) {

	case 3:
		/* ospf version 3 */
		if (ospf6_decode_v3(op, dataend))
			goto trunc;
		break;

	default:
		printf(" ospf [version %d]", op->ospf6_version);
		break;
	}			/* end switch on version */

	return;
trunc:
	fputs(tstr, stdout);
}
开发者ID:gosudream,项目名称:netbsd-src,代码行数:60,代码来源:print-ospf6.c

示例5: carp_print

void
carp_print(register const u_char *bp, register u_int len, int ttl)
{
	int version, type;
	char *type_s;

	TCHECK(bp[0]);
	version = (bp[0] & 0xf0) >> 4;
	type = bp[0] & 0x0f;
	if (type == 1)
		type_s = "advertise";
	else
		type_s = "unknown";
	printf("CARPv%d-%s %d: ", version, type_s, len);
	if (ttl != 255)
		printf("[ttl=%d!] ", ttl);
	if (version != 2 || type != 1)
		return;
	TCHECK(bp[2]);
	TCHECK(bp[5]);
	printf("vhid=%d advbase=%d advskew=%d demote=%d",
	    bp[1], bp[5], bp[2], bp[4]);
	if (vflag) {
		if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
			printf(" (bad carp cksum %x!)",
				EXTRACT_16BITS(&bp[6]));
	}
	return;
trunc:
	printf("[|carp]");
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:31,代码来源:print-carp.c

示例6: isakmp_p_print

static const u_char *
isakmp_p_print(const struct isakmp_gen *ext, u_int item_len _U_,
	       const u_char *ep, u_int32_t phase, u_int32_t doi0,
	       u_int32_t proto0 _U_, int depth)
{
	const struct isakmp_pl_p *p;
	struct isakmp_pl_p prop;
	const u_char *cp;

	printf("%s:", NPSTR(ISAKMP_NPTYPE_P));

	p = (struct isakmp_pl_p *)ext;
	TCHECK(*p);
	safememcpy(&prop, ext, sizeof(prop));
	printf(" #%d protoid=%s transform=%d",
		prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t);
	if (prop.spi_size) {
		printf(" spi=");
		if (!rawprint((caddr_t)(p + 1), prop.spi_size))
			goto trunc;
	}

	ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
	TCHECK(*ext);

	cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
		prop.prot_id, depth);

	return cp;
trunc:
	printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_P));
	return NULL;
}
开发者ID:0omega,项目名称:platform_external_tcpdump,代码行数:33,代码来源:print-isakmp.c

示例7: ospf6_print

void
ospf6_print(register const u_char *bp, register u_int length)
{
	register const struct ospf6hdr *op;
	register const u_char *dataend;
	register const char *cp;

	op = (struct ospf6hdr *)bp;

	/* If the type is valid translate it, or just print the type */
	/* value.  If it's not valid, say so and return */
	TCHECK(op->ospf6_type);
	cp = tok2str(type2str, "type%d", op->ospf6_type);
	printf("OSPFv%d-%s %d:", op->ospf6_version, cp, length);
	if (*cp == 't')
		return;

	TCHECK(op->ospf6_len);
	if (length != EXTRACT_16BITS(&op->ospf6_len)) {
		printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
		return;
	}
	dataend = bp + length;

	/* Print the routerid if it is not the same as the source */
	TCHECK(op->ospf6_routerid);
	printf(" rtrid %s", ipaddr_string(&op->ospf6_routerid));

	TCHECK(op->ospf6_areaid);
	if (op->ospf6_areaid != 0)
		printf(" area %s", ipaddr_string(&op->ospf6_areaid));
	else
		printf(" backbone");
	TCHECK(op->ospf6_instanceid);
	if (op->ospf6_instanceid)
		printf(" instance %u", op->ospf6_instanceid);

	/* Do rest according to version.	 */
	switch (op->ospf6_version) {

	case 3:
		/* ospf version 3 */
		if (ospf6_decode_v3(op, dataend))
			goto trunc;
		break;

	default:
		printf(" ospf [version %d]", op->ospf6_version);
		break;
	}			/* end switch on version */

	return;
trunc:
	fputs(tstr, stdout);
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:55,代码来源:print-ospf6.c

示例8: vrrp_print

void
vrrp_print(register const u_char *bp, register u_int len, int ttl)
{
    int version, type, auth_type;
    const char *type_s;

    TCHECK(bp[0]);
    version = (bp[0] & 0xf0) >> 4;
    type = bp[0] & 0x0f;
    type_s = tok2str(type2str, "unknown type (%u)", type);
    printf("VRRPv%u, %s", version, type_s);
    if (ttl != 255)
        printf(", (ttl %u)", ttl);
    if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
        return;
    TCHECK(bp[2]);
    printf(", vrid %u, prio %u", bp[1], bp[2]);
    TCHECK(bp[5]);
    auth_type = bp[4];
    printf(", authtype %s", tok2str(auth2str, NULL, auth_type));
    printf(", intvl %us, length %u", bp[5],len);
    if (vflag) {
        int naddrs = bp[3];
        int i;
        char c;

        if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
            printf(", (bad vrrp cksum %x)",
                   EXTRACT_16BITS(&bp[6]));
        printf(", addrs");
        if (naddrs > 1)
            printf("(%d)", naddrs);
        printf(":");
        c = ' ';
        bp += 8;
        for (i = 0; i < naddrs; i++) {
            TCHECK(bp[3]);
            printf("%c%s", c, ipaddr_string(bp));
            c = ',';
            bp += 4;
        }
        if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
            TCHECK(bp[7]);
            printf(" auth \"");
            if (fn_printn(bp, 8, snapend)) {
                printf("\"");
                goto trunc;
            }
            printf("\"");
        }
    }
    return;
trunc:
    printf("[|vrrp]");
}
开发者ID:GreggIndustries,项目名称:PF_RING,代码行数:55,代码来源:print-vrrp.c

示例9: ospf_print_lshdr

static int
ospf_print_lshdr(register const struct lsa_hdr *lshp)
{
        u_int ls_length;

        TCHECK(lshp->ls_length);
        ls_length = EXTRACT_16BITS(&lshp->ls_length);
        if (ls_length < sizeof(struct lsa_hdr)) {
                printf("\n\t    Bogus length %u < %lu", ls_length,
                    (unsigned long)sizeof(struct lsa_hdr));
                return(-1);
        }

        TCHECK(lshp->ls_seq);	/* XXX - ls_length check checked this */
	printf("\n\t  Advertising Router: %s, seq 0x%08x, age %us, length: %u",
	       ipaddr_string(&lshp->ls_router),
	       EXTRACT_32BITS(&lshp->ls_seq),
	       EXTRACT_16BITS(&lshp->ls_age),
               ls_length-(u_int)sizeof(struct lsa_hdr));

	TCHECK(lshp->ls_type);	/* XXX - ls_length check checked this */
        switch (lshp->ls_type) {
	/* the LSA header for opaque LSAs was slightly changed */
        case LS_TYPE_OPAQUE_LL:
        case LS_TYPE_OPAQUE_AL:
        case LS_TYPE_OPAQUE_DW:
            printf("\n\t    %s LSA (%d), Opaque-Type: %s LSA (%u), Opaque-ID: %u",
                   tok2str(lsa_values,"unknown",lshp->ls_type),
                   lshp->ls_type,

		   tok2str(lsa_opaque_values,
			   "unknown",
			   *(&lshp->un_lsa_id.opaque_field.opaque_type)),
		   *(&lshp->un_lsa_id.opaque_field.opaque_type),
		   EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
                   
                   );
            break;

	/* all other LSA types use regular style LSA headers */
	default:
            printf("\n\t    %s LSA (%d), LSA-ID: %s",
                   tok2str(lsa_values,"unknown",lshp->ls_type),
                   lshp->ls_type,
                   ipaddr_string(&lshp->un_lsa_id.lsa_id));
            break;
        }

	TCHECK(lshp->ls_options);	/* XXX - ls_length check checked this */
        printf("\n\t    Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options));

        return (ls_length);
trunc:
	return (-1);
}
开发者ID:hsluoyz,项目名称:WinDump,代码行数:55,代码来源:print-ospf.c

示例10: vrrp_print

/*
 * RFC 2338:
 *     0                   1                   2                   3
 *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |Version| Type  | Virtual Rtr ID|   Priority    | Count IP Addrs|
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |   Auth Type   |   Adver Int   |          Checksum             |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |                         IP Address (1)                        |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |                            .                                  |
 *    |                            .                                  |
 *    |                            .                                  |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |                         IP Address (n)                        |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |                     Authentication Data (1)                   |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *    |                     Authentication Data (2)                   |
 *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 */
void
vrrp_print(register const u_char *bp, register u_int len, int ttl)
{
	int version, type, auth_type;
	char *type_s;

	TCHECK(bp[0]);
	version = (bp[0] & 0xf0) >> 4;
	type = bp[0] & 0x0f;
	if (type == 1)
		type_s = "advertise";
	else
		type_s = "unknown";
	printf("VRRPv%d-%s %d: ", version, type_s, len);
	if (ttl != 255)
		printf("[ttl=%d!] ", ttl);
	if (version != 2 || type != 1)
		return;
	TCHECK(bp[2]);
	printf("vrid=%d prio=%d", bp[1], bp[2]);
	TCHECK(bp[5]);
	auth_type = bp[4];
	if (auth_type != 0)
		printf(" authtype=%d", auth_type);
	printf(" intvl=%d", bp[5]);
	if (vflag) {
		int naddrs = bp[3];
		int i;
		char c;

		if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
			printf(" (bad vrrp cksum %x!)",
				EXTRACT_16BITS(&bp[6]));
		printf(" addrs");
		if (naddrs > 1)
			printf("(%d)", naddrs);
		printf(":");
		c = ' ';
		bp += 8;
		for (i = 0; i < naddrs; i++) {
			TCHECK(bp[3]);
			printf("%c%s", c, ipaddr_string(bp));
			c = ',';
			bp += 4;
		}
		if (auth_type == 1) { /* simple text password */
			TCHECK(bp[7]);
			printf(" auth %.8s", bp);
		}
	}
	return;
trunc:
	printf("[|vrrp]");
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:76,代码来源:print-vrrp.c

示例11: ospf6_print_lsaprefix

static int
ospf6_print_lsaprefix(register const struct lsa6_prefix *lsapp)
{
	u_int wordlen;
	struct in6_addr prefix;

	TCHECK(*lsapp);
	wordlen = (lsapp->lsa_p_len + 31) / 32;
	if (wordlen * 4 > sizeof(struct in6_addr)) {
		printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
		goto trunc;
	}
	memset(&prefix, 0, sizeof(prefix));
	memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
	printf("\n\t\t%s/%d", ip6addr_string(&prefix),
		lsapp->lsa_p_len);
        if (lsapp->lsa_p_opt) {
            printf(", Options [%s]",
                   bittok2str(ospf6_lsa_prefix_option_values,
                              "none", lsapp->lsa_p_opt));
        }
        printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric));
	return sizeof(*lsapp) - 4 + wordlen * 4;

trunc:
	return -1;
}
开发者ID:gosudream,项目名称:netbsd-src,代码行数:27,代码来源:print-ospf6.c

示例12: parsefn

/*
 * Print out a file name and return pointer to 32-bit word past it.
 * If packet was truncated, return 0.
 */
static const u_int32_t *
parsefn(register const u_int32_t *dp)
{
	register u_int32_t len;
	register const u_char *cp;

	/* Bail if we don't have the string length */
	TCHECK(*dp);

	/* Fetch string length; convert to host order */
	len = *dp++;
	NTOHL(len);

	TCHECK2(*dp, ((len + 3) & ~3));

	cp = (u_char *)dp;
	/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
	dp += ((len + 3) & ~3) / sizeof(*dp);
	putchar('"');
	if (fn_printn(cp, len, snapend)) {
		putchar('"');
		goto trunc;
	}
	putchar('"');

	return (dp);
trunc:
	return NULL;
}
开发者ID:cherry-wb,项目名称:tcpdump,代码行数:33,代码来源:print-nfs.c

示例13: parsepathconf

static int
parsepathconf(const u_int32_t *dp)
{
	int er;
	struct nfsv3_pathconf *spp;

	if (!(dp = parsestatus(dp, &er)))
		return (0);
	if (vflag)
		printf(" POST:");
	if (!(dp = parse_post_op_attr(dp, vflag)))
		return (0);
	if (er)
		return (1);

	spp = (struct nfsv3_pathconf *)dp;
	TCHECK(*spp);

	printf(" linkmax %u namemax %u %s %s %s %s",
	       EXTRACT_32BITS(&spp->pc_linkmax),
	       EXTRACT_32BITS(&spp->pc_namemax),
	       EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "",
	       EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "",
	       EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "",
	       EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "");
	return (1);
trunc:
	return (0);
}
开发者ID:cherry-wb,项目名称:tcpdump,代码行数:29,代码来源:print-nfs.c

示例14: parsecreateopres

static const u_int32_t *
parsecreateopres(const u_int32_t *dp, int verbose)
{
	int er;

	if (!(dp = parsestatus(dp, &er)))
		return (0);
	if (er)
		dp = parse_wcc_data(dp, verbose);
	else {
		TCHECK(dp[0]);
		if (!EXTRACT_32BITS(&dp[0]))
			return (dp + 1);
		dp++;
		if (!(dp = parsefh(dp, 1)))
			return (0);
		if (verbose) {
			if (!(dp = parse_post_op_attr(dp, verbose)))
				return (0);
			if (vflag > 1) {
				printf(" dir attr:");
				dp = parse_wcc_data(dp, verbose);
			}
		}
	}
	return (dp);
trunc:
	return (NULL);
}
开发者ID:cherry-wb,项目名称:tcpdump,代码行数:29,代码来源:print-nfs.c

示例15: ospf6_print_lshdr

static int
ospf6_print_lshdr(register const struct lsa_hdr *lshp)
{

	TCHECK(lshp->ls_type);
	printf(" {");						/* } (ctags) */

	TCHECK(lshp->ls_seq);
	ospf6_print_seqage(EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age));
	ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid,
		&lshp->ls_router, "ls_type %d");

	return (0);
trunc:
	return (1);
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:16,代码来源:print-ospf6.c


注:本文中的TCHECK函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。