您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ EXTRACT_16BITS函数代码示例

51自学网 2021-06-01 20:36:35
  C++
这篇教程C++ EXTRACT_16BITS函数代码示例写得很实用,希望能帮到您。

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

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

示例1: chdlc_print

u_intchdlc_print(netdissect_options *ndo, register const u_char *p, u_int length){	u_int proto;	const u_char *bp = p;	if (length < CHDLC_HDRLEN)		goto trunc;	ND_TCHECK2(*p, CHDLC_HDRLEN);	proto = EXTRACT_16BITS(&p[2]);	if (ndo->ndo_eflag) {                ND_PRINT((ndo, "%s, ethertype %s (0x%04x), length %u: ",                       tok2str(chdlc_cast_values, "0x%02x", p[0]),                       tok2str(ethertype_values, "Unknown", proto),                       proto,                       length));	}	length -= CHDLC_HDRLEN;	p += CHDLC_HDRLEN;	switch (proto) {	case ETHERTYPE_IP:		ip_print(ndo, p, length);		break;	case ETHERTYPE_IPV6:		ip6_print(ndo, p, length);		break;	case CHDLC_TYPE_SLARP:		chdlc_slarp_print(ndo, p, length);		break;#if 0	case CHDLC_TYPE_CDP:		chdlc_cdp_print(p, length);		break;#endif        case ETHERTYPE_MPLS:        case ETHERTYPE_MPLS_MULTI:                mpls_print(ndo, p, length);		break;        case ETHERTYPE_ISO:                /* is the fudge byte set ? lets verify by spotting ISO headers */                if (length < 2)                    goto trunc;                ND_TCHECK_16BITS(p);                if (*(p+1) == 0x81 ||                    *(p+1) == 0x82 ||                    *(p+1) == 0x83)                    isoclns_print(ndo, p + 1, length - 1);                else                    isoclns_print(ndo, p, length);                break;	default:                if (!ndo->ndo_eflag)                        ND_PRINT((ndo, "unknown CHDLC protocol (0x%04x)", proto));                break;	}	return (CHDLC_HDRLEN);trunc:	ND_PRINT((ndo, "[|chdlc]"));	return ndo->ndo_snapend - bp;}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:64,


示例2: dccp_print_option

static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen){	uint8_t optlen, i;	ND_TCHECK(*option);	if (*option >= 32) {		ND_TCHECK(*(option+1));		optlen = *(option +1);		if (optlen < 2) {			if (*option >= 128)				ND_PRINT((ndo, "CCID option %u optlen too short", *option));			else				ND_PRINT((ndo, "%s optlen too short",					  tok2str(dccp_option_values, "Option %u", *option)));			return 0;		}	} else		optlen = 1;	if (hlen < optlen) {		if (*option >= 128)			ND_PRINT((ndo, "CCID option %u optlen goes past header length",				  *option));		else			ND_PRINT((ndo, "%s optlen goes past header length",				  tok2str(dccp_option_values, "Option %u", *option)));		return 0;	}	ND_TCHECK2(*option, optlen);	if (*option >= 128) {		ND_PRINT((ndo, "CCID option %d", *option));		switch (optlen) {			case 4:				ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));				break;			case 6:				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));				break;			default:				break;		}	} else {		ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", *option)));		switch (*option) {		case 32:		case 33:		case 34:		case 35:			if (optlen < 3) {				ND_PRINT((ndo, " optlen too short"));				return optlen;			}			if (*(option + 2) < 10){				ND_PRINT((ndo, " %s", dccp_feature_nums[*(option + 2)]));				for (i = 0; i < optlen - 3; i++)					ND_PRINT((ndo, " %d", *(option + 3 + i)));			}			break;		case 36:			if (optlen > 2) {				ND_PRINT((ndo, " 0x"));				for (i = 0; i < optlen - 2; i++)					ND_PRINT((ndo, "%02x", *(option + 2 + i)));			}			break;		case 37:			for (i = 0; i < optlen - 2; i++)				ND_PRINT((ndo, " %d", *(option + 2 + i)));			break;		case 38:			if (optlen > 2) {				ND_PRINT((ndo, " 0x"));				for (i = 0; i < optlen - 2; i++)					ND_PRINT((ndo, "%02x", *(option + 2 + i)));			}			break;		case 39:			if (optlen > 2) {				ND_PRINT((ndo, " 0x"));				for (i = 0; i < optlen - 2; i++)					ND_PRINT((ndo, "%02x", *(option + 2 + i)));			}			break;		case 40:			if (optlen > 2) {				ND_PRINT((ndo, " 0x"));				for (i = 0; i < optlen - 2; i++)					ND_PRINT((ndo, "%02x", *(option + 2 + i)));			}			break;		case 41:			if (optlen == 4)				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));			else				ND_PRINT((ndo, " optlen != 4"));			break;		case 42:			if (optlen == 4)//.........这里部分代码省略.........
开发者ID:EliseuTorres,项目名称:tcpdump,代码行数:101,


示例3: token_print

u_inttoken_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen){	const struct token_header *trp;	int llc_hdrlen;	struct ether_header ehdr;	u_int route_len = 0, hdr_len = TOKEN_HDRLEN;	int seg;	trp = (const struct token_header *)p;	if (caplen < TOKEN_HDRLEN) {		ND_PRINT((ndo, "%s", tstr));		return hdr_len;	}	/*	 * Get the TR addresses into a canonical form	 */	extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));	/* Adjust for source routing information in the MAC header */	if (IS_SOURCE_ROUTED(trp)) {		/* Clear source-routed bit */		*ESRC(&ehdr) &= 0x7f;		if (ndo->ndo_eflag)			token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));		if (caplen < TOKEN_HDRLEN + 2) {			ND_PRINT((ndo, "%s", tstr));			return hdr_len;		}		route_len = RIF_LENGTH(trp);		hdr_len += route_len;		if (caplen < hdr_len) {			ND_PRINT((ndo, "%s", tstr));			return hdr_len;		}		if (ndo->ndo_vflag) {			ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));			ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));			for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)				ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),				    BRIDGE_NUMBER(trp, seg)));		} else {			ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));			for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)				ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));		}		ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));	} else {		if (ndo->ndo_eflag)			token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));	}	/* Skip over token ring MAC header and routing information */	length -= hdr_len;	p += hdr_len;	caplen -= hdr_len;	/* Frame Control field determines interpretation of packet */	if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {		/* Try to print the LLC-layer header & higher layers */		llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr),		    EDST(&ehdr));		if (llc_hdrlen < 0) {			/* packet type not known, print raw packet */			if (!ndo->ndo_suppress_default_print)				ND_DEFAULTPRINT(p, caplen);			llc_hdrlen = -llc_hdrlen;		}		hdr_len += llc_hdrlen;	} else {		/* Some kinds of TR packet we cannot handle intelligently */		/* XXX - dissect MAC packets if frame type is 0 */		if (!ndo->ndo_eflag)			token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,			    ESRC(&ehdr), EDST(&ehdr));		if (!ndo->ndo_suppress_default_print)			ND_DEFAULTPRINT(p, caplen);	}	return (hdr_len);}
开发者ID:EliseuTorres,项目名称:tcpdump,代码行数:86,


示例4: slow_oam_print

static voidslow_oam_print(netdissect_options *ndo,               register const u_char *tptr, register u_int tlen) {    u_int hexdump;    struct slow_oam_common_header_t {        uint8_t flags[2];        uint8_t code;    };    struct slow_oam_tlv_header_t {        uint8_t type;        uint8_t length;    };    union {        const struct slow_oam_common_header_t *slow_oam_common_header;        const struct slow_oam_tlv_header_t *slow_oam_tlv_header;    } ptr;    union {	const struct slow_oam_info_t *slow_oam_info;        const struct slow_oam_link_event_t *slow_oam_link_event;        const struct slow_oam_variablerequest_t *slow_oam_variablerequest;        const struct slow_oam_variableresponse_t *slow_oam_variableresponse;        const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl;    } tlv;    ptr.slow_oam_common_header = (struct slow_oam_common_header_t *)tptr;    tptr += sizeof(struct slow_oam_common_header_t);    tlen -= sizeof(struct slow_oam_common_header_t);    ND_PRINT((ndo, "/n/tCode %s OAM PDU, Flags [%s]",           tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code),           bittok2str(slow_oam_flag_values,                      "none",                      EXTRACT_16BITS(&ptr.slow_oam_common_header->flags))));    switch (ptr.slow_oam_common_header->code) {    case SLOW_OAM_CODE_INFO:        while (tlen > 0) {            ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;            ND_PRINT((ndo, "/n/t  %s Information Type (%u), length %u",                   tok2str(slow_oam_info_type_values, "Reserved",                           ptr.slow_oam_tlv_header->type),                   ptr.slow_oam_tlv_header->type,                   ptr.slow_oam_tlv_header->length));            hexdump = FALSE;            switch (ptr.slow_oam_tlv_header->type) {            case SLOW_OAM_INFO_TYPE_END_OF_TLV:                if (ptr.slow_oam_tlv_header->length != 0) {                    ND_PRINT((ndo, "/n/t    ERROR: illegal length - should be 0"));                }                return;            case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */            case SLOW_OAM_INFO_TYPE_REMOTE:                tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;                if (tlv.slow_oam_info->info_length !=                    sizeof(struct slow_oam_info_t)) {                    ND_PRINT((ndo, "/n/t    ERROR: illegal length - should be %lu",                           (unsigned long) sizeof(struct slow_oam_info_t)));                    return;                }                ND_PRINT((ndo, "/n/t    OAM-Version %u, Revision %u",                       tlv.slow_oam_info->oam_version,                       EXTRACT_16BITS(&tlv.slow_oam_info->revision)));                ND_PRINT((ndo, "/n/t    State-Parser-Action %s, State-MUX-Action %s",                       tok2str(slow_oam_info_type_state_parser_values, "Reserved",                               tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK),                       tok2str(slow_oam_info_type_state_mux_values, "Reserved",                               tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));                ND_PRINT((ndo, "/n/t    OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",                       bittok2str(slow_oam_info_type_oam_config_values, "none",                                  tlv.slow_oam_info->oam_config),                       EXTRACT_16BITS(&tlv.slow_oam_info->oam_pdu_config) &                       OAM_INFO_TYPE_PDU_SIZE_MASK));                ND_PRINT((ndo, "/n/t    OUI %s (0x%06x), Vendor-Private 0x%08x",                       tok2str(oui_values, "Unknown",                               EXTRACT_24BITS(&tlv.slow_oam_info->oui)),                       EXTRACT_24BITS(&tlv.slow_oam_info->oui),                       EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)));                break;            case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:                hexdump = TRUE;                break;            default:                hexdump = TRUE;                break;            }            /* infinite loop check */            if (!ptr.slow_oam_tlv_header->length) {//.........这里部分代码省略.........
开发者ID:Danielweber7624,项目名称:tcpdump,代码行数:101,


示例5: babel_print_v2

static voidbabel_print_v2(netdissect_options *ndo,               const u_char *cp, u_int length) {    u_int i;    u_short bodylen;    u_char v4_prefix[16] =        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };    u_char v6_prefix[16] = {0};    ND_TCHECK2(*cp, 4);    if (length < 4)        goto corrupt;    bodylen = EXTRACT_16BITS(cp + 2);    ND_PRINT((ndo, " (%u)", bodylen));    /* Process the TLVs in the body */    i = 0;    while(i < bodylen) {        const u_char *message;        u_int type, len;        message = cp + 4 + i;        ND_TCHECK2(*message, 1);        if((type = message[0]) == MESSAGE_PAD1) {            ND_PRINT((ndo, ndo->ndo_vflag ? "/n/tPad 1" : " pad1"));            i += 1;            continue;        }        ND_TCHECK2(*message, 2);        ICHECK(i, 2);        len = message[1];        ND_TCHECK2(*message, 2 + len);        ICHECK(i, 2 + len);        switch(type) {        case MESSAGE_PADN: {            if (!ndo->ndo_vflag)                ND_PRINT((ndo, " padN"));            else                ND_PRINT((ndo, "/n/tPad %d", len + 2));        }            break;        case MESSAGE_ACK_REQ: {            u_short nonce, interval;            if (!ndo->ndo_vflag)                ND_PRINT((ndo, " ack-req"));            else {                ND_PRINT((ndo, "/n/tAcknowledgment Request "));                if(len < 6) goto corrupt;                nonce = EXTRACT_16BITS(message + 4);                interval = EXTRACT_16BITS(message + 6);                ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));            }        }            break;        case MESSAGE_ACK: {            u_short nonce;            if (!ndo->ndo_vflag)                ND_PRINT((ndo, " ack"));            else {                ND_PRINT((ndo, "/n/tAcknowledgment "));                if(len < 2) goto corrupt;                nonce = EXTRACT_16BITS(message + 2);                ND_PRINT((ndo, "%04x", nonce));            }        }            break;        case MESSAGE_HELLO:  {            u_short seqno, interval;            if (!ndo->ndo_vflag)                ND_PRINT((ndo, " hello"));            else {                ND_PRINT((ndo, "/n/tHello "));                if(len < 6) goto corrupt;                seqno = EXTRACT_16BITS(message + 4);                interval = EXTRACT_16BITS(message + 6);                ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));            }        }            break;        case MESSAGE_IHU: {            unsigned short txcost, interval;            if (!ndo->ndo_vflag)                ND_PRINT((ndo, " ihu"));            else {                u_char address[16];                int rc;                ND_PRINT((ndo, "/n/tIHU "));                if(len < 6) goto corrupt;                txcost = EXTRACT_16BITS(message + 4);                interval = EXTRACT_16BITS(message + 6);                rc = network_address(message[2], message + 8, len - 6, address);                if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }//.........这里部分代码省略.........
开发者ID:rwdxll,项目名称:tcpdump,代码行数:101,


示例6: tcp_print

voidtcp_print(register const u_char *bp, register u_int length,	  register const u_char *bp2, int fragmented){        register const struct tcphdr *tp;        register const struct ip *ip;        register u_char flags;        register u_int hlen;        register char ch;        u_int16_t sport, dport, win, urp;        u_int32_t seq, ack, thseq, thack;        u_int utoval;        u_int16_t magic;        register int rev;#ifdef INET6        register const struct ip6_hdr *ip6;#endif        tp = (struct tcphdr *)bp;        ip = (struct ip *)bp2;#ifdef INET6        if (IP_V(ip) == 6)                ip6 = (struct ip6_hdr *)bp2;        else                ip6 = NULL;#endif /*INET6*/        ch = '/0';        if (!TTEST(tp->th_dport)) {                (void)printf("%s > %s: [|tcp]",                             ipaddr_string(&ip->ip_src),                             ipaddr_string(&ip->ip_dst));                return;        }        sport = EXTRACT_16BITS(&tp->th_sport);        dport = EXTRACT_16BITS(&tp->th_dport);        hlen = TH_OFF(tp) * 4;#ifdef INET6        if (ip6) {                if (ip6->ip6_nxt == IPPROTO_TCP) {                        (void)printf("%s.%s > %s.%s: ",                                     ip6addr_string(&ip6->ip6_src),                                     tcpport_string(sport),                                     ip6addr_string(&ip6->ip6_dst),                                     tcpport_string(dport));                } else {                        (void)printf("%s > %s: ",                                     tcpport_string(sport), tcpport_string(dport));                }        } else#endif /*INET6*/        {                if (ip->ip_p == IPPROTO_TCP) {                        (void)printf("%s.%s > %s.%s: ",                                     ipaddr_string(&ip->ip_src),                                     tcpport_string(sport),                                     ipaddr_string(&ip->ip_dst),                                     tcpport_string(dport));                } else {                        (void)printf("%s > %s: ",                                     tcpport_string(sport), tcpport_string(dport));                }        }        if (hlen < sizeof(*tp)) {                (void)printf(" tcp %d [bad hdr length %u - too short, < %lu]",                             length - hlen, hlen, (unsigned long)sizeof(*tp));                return;        }        TCHECK(*tp);        seq = EXTRACT_32BITS(&tp->th_seq);        ack = EXTRACT_32BITS(&tp->th_ack);        win = EXTRACT_16BITS(&tp->th_win);        urp = EXTRACT_16BITS(&tp->th_urp);        if (qflag) {                (void)printf("tcp %d", length - hlen);                if (hlen > length) {                        (void)printf(" [bad hdr length %u - too long, > %u]",                                     hlen, length);                }                return;        }        flags = tp->th_flags;        printf("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags));        if (!Sflag && (flags & TH_ACK)) {                /*                 * Find (or record) the initial sequence numbers for                 * this conversation.  (we pick an arbitrary                 * collating order so there's only one entry for                 * both directions).                 */                rev = 0;#ifdef INET6//.........这里部分代码省略.........
开发者ID:anguscc,项目名称:tcpdump,代码行数:101,


示例7: tftp_print

/* * Print trivial file transfer program requests */voidtftp_print(register const u_char *bp, u_int length){	register const struct tftphdr *tp;	register const char *cp;	register const u_char *p;	register int opcode, i;	static char tstr[] = " [|tftp]";	tp = (const struct tftphdr *)bp;	/* Print length */	printf(" %d", length);	/* Print tftp request type */	TCHECK(tp->th_opcode);	opcode = EXTRACT_16BITS(&tp->th_opcode);	cp = tok2str(op2str, "tftp-#%d", opcode);	printf(" %s", cp);	/* Bail if bogus opcode */	if (*cp == 't')		return;	switch (opcode) {	case RRQ:	case WRQ:	case OACK:		/*		 * XXX Not all arpa/tftp.h's specify th_stuff as any		 * array; use address of th_block instead		 */#ifdef notdef		p = (u_char *)tp->th_stuff;#else		p = (u_char *)&tp->th_block;#endif		putchar(' ');		/* Print filename or first option */		if (opcode != OACK)			putchar('"');		i = fn_print(p, snapend);		if (opcode != OACK)			putchar('"');		/* Print the mode (RRQ and WRQ only) and any options */		while ((p = (const u_char *)strchr((const char *)p, '/0')) != NULL) {			if (length <= (u_int)(p - (const u_char *)&tp->th_block))				break;			p++;			if (*p != '/0') {				putchar(' ');				fn_print(p, snapend);			}		}				if (i)			goto trunc;		break;	case ACK:	case DATA:		TCHECK(tp->th_block);		printf(" block %d", EXTRACT_16BITS(&tp->th_block));		break;	case TFTP_ERROR:		/* Print error code string */		TCHECK(tp->th_code);		printf(" %s /"", tok2str(err2str, "tftp-err-#%d /"",				       EXTRACT_16BITS(&tp->th_code)));		/* Print error message string */		i = fn_print((const u_char *)tp->th_data, snapend);		putchar('"');		if (i)			goto trunc;		break;	default:		/* We shouldn't get here */		printf("(unknown #%d)", opcode);		break;	}	return;trunc:	fputs(tstr, stdout);	return;}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:91,


示例8: switch

/**************************************************************************** * * Function: TCPOptionValue(Options *o) * * Purpose: To return a string representing the value of an TCP option * * Arguments: An Options struct. * * Returns: char * -- You must free this char * when you are done with it. * ***************************************************************************/char *TCPOptionValue(Options *o){    char * rval;    char * rvalptr;    u_char tmp[5];    int x;    rval = (char *)malloc(SMALLBUFFER);    rvalptr = rval;    switch(o->code)    {        case TCPOPT_MAXSEG:            bzero((char *)tmp, 5);            strncpy(tmp, o->data, 2);             snprintf(rval, SMALLBUFFER, "%u", EXTRACT_16BITS(tmp));            break;        case TCPOPT_EOL:            rval[0] = '/0';            break;        case TCPOPT_NOP:            rval[0] = '/0';            break;        case TCPOPT_WSCALE:            snprintf(rval, SMALLBUFFER, "%u", o->data[0]);            break;        case TCPOPT_SACK:            bzero((char *)tmp, 5);            memcpy(tmp, o->data, 2);            snprintf(rval, SMALLBUFFER, "%[email
C++ EXTRACT_24BITS函数代码示例
C++ EXTRACT16函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。