本文整理汇总了C++中TCHECK2函数的典型用法代码示例。如果您正苦于以下问题:C++ TCHECK2函数的具体用法?C++ TCHECK2怎么用?C++ TCHECK2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TCHECK2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dccp_print_ack_no
static void dccp_print_ack_no(const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
const struct dccp_hdr_ack_bits *dh_ack =
(struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
u_int32_t ack_high;
u_int64_t ackno;
TCHECK2(*dh_ack,4);
ack_high = DCCPH_ACK(dh_ack);
ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;
if (DCCPH_X(dh) != 0) {
u_int32_t ack_low;
TCHECK2(*dh_ack,8);
ack_low = dh_ack->dccph_ack_nr_low;
ackno &= 0x00FFFF; /* clear reserved field */
ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
}
(void)printf("(ack=%" PRIu64 ") ", ackno);
trunc:
return;
}
示例2: of10_error_print
/* [OF10] Section 5.4.4 */
static const u_char *
of10_error_print(const u_char *cp, const u_char *ep, const u_int len) {
uint16_t type;
const struct tok *code_str;
/* type */
TCHECK2(*cp, 2);
type = EXTRACT_16BITS(cp);
cp += 2;
printf("\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type));
/* code */
TCHECK2(*cp, 2);
code_str =
type == OFPET_HELLO_FAILED ? ofphfc_str :
type == OFPET_BAD_REQUEST ? ofpbrc_str :
type == OFPET_BAD_ACTION ? ofpbac_str :
type == OFPET_FLOW_MOD_FAILED ? ofpfmfc_str :
type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
empty_str;
printf(", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp)));
cp += 2;
/* data */
return of10_data_print(cp, ep, len - sizeof(struct ofp_error_msg));
trunc:
printf(" [|openflow]");
return ep;
}
示例3: print_trans
static void
print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
const char *f1, *f2, *f3, *f4;
const u_char *data, *param;
const u_char *w = words + 1;
int datalen, paramlen;
if (request) {
TCHECK2(w[12 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
datalen = EXTRACT_LE_16BITS(w + 11 * 2);
data = buf + EXTRACT_LE_16BITS(w + 12 * 2);
f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
f2 = "|Name=[S]\n";
f3 = "|Param ";
f4 = "|Data ";
} else {
TCHECK2(w[7 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
datalen = EXTRACT_LE_16BITS(w + 6 * 2);
data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
f2 = "|Unknown ";
f3 = "|Param ";
f4 = "|Data ";
}
smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf),
unicodestr);
TCHECK2(*data1, 2);
bcc = EXTRACT_LE_16BITS(data1);
printf("smb_bcc=%u\n", bcc);
if (bcc > 0) {
smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
print_browse(param, paramlen, data, datalen);
return;
}
if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
print_ipc(param, paramlen, data, datalen);
return;
}
if (paramlen)
smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr);
if (datalen)
smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr);
}
return;
trunc:
printf("[|SMB]");
return;
}
示例4: ospf6_print_lsaprefix
static int
ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
{
const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
u_int wordlen;
struct in6_addr prefix;
if (lsa_length < sizeof (*lsapp) - 4)
goto trunc;
lsa_length -= sizeof (*lsapp) - 4;
TCHECK2(*lsapp, sizeof (*lsapp) - 4);
wordlen = (lsapp->lsa_p_len + 31) / 32;
if (wordlen * 4 > sizeof(struct in6_addr)) {
printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
goto trunc;
}
if (lsa_length < wordlen * 4)
goto trunc;
lsa_length -= wordlen * 4;
TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
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;
}
示例5: of10_packet_in_print
/* [OF10] Section 5.4.1 */
static const u_char *
of10_packet_in_print(const u_char *cp, const u_char *ep, const u_int len) {
/* buffer_id */
TCHECK2(*cp, 4);
printf("\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp)));
cp += 4;
/* total_len */
TCHECK2(*cp, 2);
printf(", total_len %u", EXTRACT_16BITS(cp));
cp += 2;
/* in_port */
TCHECK2(*cp, 2);
printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
cp += 2;
/* reason */
TCHECK2(*cp, 1);
printf(", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp));
cp += 1;
/* pad */
TCHECK2(*cp, 1);
cp += 1;
/* data */
/* 2 mock octets count in sizeof() but not in len */
return of10_data_print(cp, ep, len - (sizeof(struct ofp_packet_in) - 2));
trunc:
printf(" [|openflow]");
return ep;
}
示例6: of10_packet_out_print
/* [OF10] Section 5.3.6 */
static const u_char *
of10_packet_out_print(const u_char *cp, const u_char *ep, const u_int len) {
const u_char *cp0 = cp;
const u_int len0 = len;
uint16_t actions_len;
/* buffer_id */
TCHECK2(*cp, 4);
printf("\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp));
cp += 4;
/* in_port */
TCHECK2(*cp, 2);
printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
cp += 2;
/* actions_len */
TCHECK2(*cp, 2);
actions_len = EXTRACT_16BITS(cp);
cp += 2;
if (actions_len > len - sizeof(struct ofp_packet_out))
goto corrupt;
/* actions */
if (ep == (cp = of10_actions_print("\n\t ", cp, ep, actions_len)))
return ep; /* end of snapshot */
/* data */
return of10_data_print(cp, ep, len - sizeof(struct ofp_packet_out) - actions_len);
corrupt: /* skip the rest of the message body */
printf(" (corrupt)");
TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
printf(" [|openflow]");
return ep;
}
示例7: of10_aggregate_stats_reply_print
/* ibid */
static const u_char *
of10_aggregate_stats_reply_print(const u_char *cp, const u_char *ep,
const u_int len) {
if (len != sizeof(struct ofp_aggregate_stats_reply))
goto corrupt;
/* packet_count */
TCHECK2(*cp, 8);
printf("\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp));
cp += 8;
/* byte_count */
TCHECK2(*cp, 8);
printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
cp += 8;
/* flow_count */
TCHECK2(*cp, 4);
printf(", flow_count %u", EXTRACT_32BITS(cp));
cp += 4;
/* pad */
TCHECK2(*cp, 4);
return cp + 4;
corrupt: /* skip the message body */
printf(" (corrupt)");
TCHECK2(*cp, len);
return cp + len;
trunc:
printf(" [|openflow]");
return ep;
}
示例8: of10_table_stats_reply_print
/* ibid */
static const u_char *
of10_table_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
const u_char *cp0 = cp;
const u_int len0 = len;
while (len) {
if (len < sizeof(struct ofp_table_stats))
goto corrupt;
/* table_id */
TCHECK2(*cp, 1);
printf("\n\t table_id %s", tok2str(tableid_str, "%u", *cp));
cp += 1;
/* pad */
TCHECK2(*cp, 3);
cp += 3;
/* name */
TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
printf(", name '");
fn_print(cp, cp + OFP_MAX_TABLE_NAME_LEN);
printf("'");
cp += OFP_MAX_TABLE_NAME_LEN;
/* wildcards */
TCHECK2(*cp, 4);
printf("\n\t wildcards 0x%08x", EXTRACT_32BITS(cp));
of10_bitmap_print(ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
cp += 4;
/* max_entries */
TCHECK2(*cp, 4);
printf("\n\t max_entries %u", EXTRACT_32BITS(cp));
cp += 4;
/* active_count */
TCHECK2(*cp, 4);
printf(", active_count %u", EXTRACT_32BITS(cp));
cp += 4;
/* lookup_count */
TCHECK2(*cp, 8);
printf(", lookup_count %" PRIu64, EXTRACT_64BITS(cp));
cp += 8;
/* matched_count */
TCHECK2(*cp, 8);
printf(", matched_count %" PRIu64, EXTRACT_64BITS(cp));
cp += 8;
len -= sizeof(struct ofp_table_stats);
} /* while */
return cp;
corrupt: /* skip the undersized trailing data */
printf(" (corrupt)");
TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
printf(" [|openflow]");
return ep;
}
示例9: of10_flow_removed_print
/* [OF10] Section 5.4.2 */
static const u_char *
of10_flow_removed_print(const u_char *cp, const u_char *ep) {
/* match */
if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
return ep; /* end of snapshot */
/* cookie */
TCHECK2(*cp, 8);
printf("\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
cp += 8;
/* priority */
TCHECK2(*cp, 2);
if (EXTRACT_16BITS(cp))
printf(", priority %u", EXTRACT_16BITS(cp));
cp += 2;
/* reason */
TCHECK2(*cp, 1);
printf(", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp));
cp += 1;
/* pad */
TCHECK2(*cp, 1);
cp += 1;
/* duration_sec */
TCHECK2(*cp, 4);
printf(", duration_sec %u", EXTRACT_32BITS(cp));
cp += 4;
/* duration_nsec */
TCHECK2(*cp, 4);
printf(", duration_nsec %u", EXTRACT_32BITS(cp));
cp += 4;
/* idle_timeout */
TCHECK2(*cp, 2);
if (EXTRACT_16BITS(cp))
printf(", idle_timeout %u", EXTRACT_16BITS(cp));
cp += 2;
/* pad2 */
TCHECK2(*cp, 2);
cp += 2;
/* packet_count */
TCHECK2(*cp, 8);
printf(", packet_count %" PRIu64, EXTRACT_64BITS(cp));
cp += 8;
/* byte_count */
TCHECK2(*cp, 8);
printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
return cp + 8;
trunc:
printf(" [|openflow]");
return ep;
}
示例10: 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;
}
示例11: 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);
}
示例12: 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;
}
示例13: print_l2_routes
static int
print_l2_routes(const char *rp, u_int len)
{
int count;
int area;
int info;
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
rp += sizeof(short);
len -= sizeof(short);
area = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
(void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
RI_COST(info), RI_HOPS(info));
}
return (1);
trunc:
return (0);
}
示例14: babel_print
void
babel_print(const u_char *cp, u_int length) {
printf("babel");
TCHECK2(*cp, 4);
if(cp[0] != 42) {
printf(" malformed header");
return;
} else {
printf(" %d", cp[1]);
}
switch(cp[1]) {
case 2:
babel_print_v2(cp,length);
break;
default:
printf(" unknown version");
break;
}
return;
trunc:
printf(" [|babel]");
return;
}
示例15: rpki_rtr_print
void
rpki_rtr_print(register const u_char *pptr, register u_int len) {
u_int tlen, pdu_type, pdu_len;
const u_char *tptr;
const rpki_rtr_pdu *pdu_header;
tptr = pptr;
tlen = len;
if (!vflag) {
printf(", RPKI-RTR");
return;
}
while (tlen >= sizeof(rpki_rtr_pdu)) {
TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
pdu_header = (rpki_rtr_pdu *)tptr;
pdu_type = pdu_header->pdu_type;
pdu_len = EXTRACT_32BITS(pdu_header->length);
/* infinite loop check */
if (!pdu_type || !pdu_len) {
break;
}
TCHECK2(*tptr, pdu_len);
if (tlen < pdu_len) {
goto trunc;
}
/*
* Print the PDU.
*/
rpki_rtr_pdu_print(tptr, 8);
tlen -= pdu_len;
tptr += pdu_len;
}
return;
trunc:
printf("\n\t[|RPKI-RTR]");
}