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


C++ PKTLEN函数代码示例

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


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

示例1: pktfrombuf

/* copy a buffer into a pkt buffer chain */
uint
pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf)
{
	uint n, ret = 0;

	/* skip 'offset' bytes */
	for (; p && offset; p = PKTNEXT(osh, p)) {
		if (offset < (uint)PKTLEN(osh, p))
			break;
		offset -= PKTLEN(osh, p);
	}

	if (!p)
		return 0;

	/* copy the data */
	for (; p && len; p = PKTNEXT(osh, p)) {
		n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len);
		bcopy(buf, PKTDATA(osh, p) + offset, n);
		buf += n;
		len -= n;
		ret += n;
		offset = 0;
	}

	return ret;
}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:28,代码来源:bcmutils.c

示例2: pktcopy

/* copy a pkt buffer chain into a buffer */
uint
pktcopy(void *drv, void *p, uint offset, int len, uchar *buf)
{
	uint n, ret = 0;

	if (len < 0)
		len = 4096;	/* "infinite" */

	/* skip 'offset' bytes */
	for (; p && offset; p = PKTNEXT(drv, p)) {
		if (offset < (uint)PKTLEN(drv, p))
			break;
		offset -= PKTLEN(drv, p);
	}

	if (!p)
		return 0;

	/* copy the data */
	for (; p && len; p = PKTNEXT(drv, p)) {
		n = MIN((uint)PKTLEN(drv, p) - offset, (uint)len);
		bcopy(PKTDATA(drv, p) + offset, buf, n);
		buf += n;
		len -= n;
		ret += n;
		offset = 0;
	}

	return ret;
}
开发者ID:ariavie,项目名称:bcm,代码行数:31,代码来源:bcmutils.c

示例3: dhd_prot_hdrpull

int
dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, void *pktbuf)
{
#ifdef BDC
	struct bdc_header *h;
#endif
	uint8 bdc_ver;

	DHD_TRACE(("%s: Enter\n", __FUNCTION__));

#ifdef BDC
	/* Pop BDC header used to convey priority for buses that don't */

	if (PKTLEN(dhd->osh, pktbuf) < BDC_HEADER_LEN) {
		DHD_ERROR(("%s: rx data too short (%d < %d)\n", __FUNCTION__,
		           PKTLEN(dhd->osh, pktbuf), BDC_HEADER_LEN));
		return BCME_ERROR;
	}

	h = (struct bdc_header *)PKTDATA(dhd->osh, pktbuf);

	if ((*ifidx = BDC_GET_IF_IDX(h)) >= DHD_MAX_IFS) {
		DHD_ERROR(("%s: rx data ifnum out of range (%d)\n",
		           __FUNCTION__, *ifidx));
		return BCME_ERROR;
	}

	bdc_ver = (h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT;

	if ((bdc_ver != BDC_PROTO_VER) && (bdc_ver != 2)) {
		DHD_ERROR(("%s: non-BDC packet received, flags 0x%x, BDC %d\n",
		           dhd_ifname(dhd, *ifidx), h->flags, bdc_ver));
		return BCME_ERROR;
	}

	if (h->flags & BDC_FLAG_SUM_GOOD) {
		DHD_INFO(("%s: BDC packet received with good rx-csum, flags 0x%x\n",
		          dhd_ifname(dhd, *ifidx), h->flags));
		PKTSETSUMGOOD(pktbuf, TRUE);
	}

	PKTSETPRIO(pktbuf, (h->priority & BDC_PRIORITY_MASK));

	PKTPULL(dhd->osh, pktbuf, BDC_HEADER_LEN);
#endif /* BDC */

	return 0;
}
开发者ID:angel12,项目名称:sch-i510_kernel,代码行数:48,代码来源:dhd_cdc.c

示例4: dhd_tcpack_check_xmit

inline int dhd_tcpack_check_xmit(dhd_pub_t *dhdp, void *pkt)
{
	uint8 i;
	tcpack_sup_module_t *tcpack_sup_mod;
	tcpack_info_t *tcpack_info_tbl;
	int tbl_cnt;
	int ret = BCME_OK;
	void *pdata;
	uint32 pktlen;
	unsigned long flags;

	if (dhdp->tcpack_sup_mode == TCPACK_SUP_OFF)
		goto exit;

	pdata = PKTDATA(dhdp->osh, pkt);
	pktlen = PKTLEN(dhdp->osh, pkt) - dhd_prot_hdrlen(dhdp, pdata);

	if (pktlen < TCPACKSZMIN || pktlen > TCPACKSZMAX) {
		DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n",
			__FUNCTION__, __LINE__, pktlen));
		goto exit;
	}

	flags = dhd_os_tcpacklock(dhdp);
	tcpack_sup_mod = dhdp->tcpack_sup_module;

	if (!tcpack_sup_mod) {
		DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n", __FUNCTION__, __LINE__));
		ret = BCME_ERROR;
		dhd_os_tcpackunlock(dhdp, flags);
		goto exit;
	}
	tbl_cnt = tcpack_sup_mod->tcpack_info_cnt;
	tcpack_info_tbl = tcpack_sup_mod->tcpack_info_tbl;

	ASSERT(tbl_cnt <= TCPACK_INFO_MAXNUM);

	for (i = 0; i < tbl_cnt; i++) {
		if (tcpack_info_tbl[i].pkt_in_q == pkt) {
			DHD_TRACE(("%s %d: pkt %p sent out. idx %d, tbl_cnt %d\n",
				__FUNCTION__, __LINE__, pkt, i, tbl_cnt));
			/* This pkt is being transmitted so remove the tcp_ack_info of it. */
			if (i < tbl_cnt - 1) {
				bcopy(&tcpack_info_tbl[tbl_cnt - 1],
					&tcpack_info_tbl[i], sizeof(tcpack_info_t));
			}
			bzero(&tcpack_info_tbl[tbl_cnt - 1], sizeof(tcpack_info_t));
			if (--tcpack_sup_mod->tcpack_info_cnt < 0) {
				DHD_ERROR(("%s %d: ERROR!!! tcp_ack_info_cnt %d\n",
					__FUNCTION__, __LINE__, tcpack_sup_mod->tcpack_info_cnt));
				ret = BCME_ERROR;
			}
			break;
		}
	}
	dhd_os_tcpackunlock(dhdp, flags);

exit:
	return ret;
}
开发者ID:tyler6389,项目名称:android_kernel_samsung_slte,代码行数:60,代码来源:dhd_ip.c

示例5: dhd_bta_flush_hcidata

static void
dhd_bta_flush_hcidata(dhd_pub_t *pub, uint16 llh)
{
	int prec;
	struct pktq *q;
	uint count = 0;

	q = dhd_bus_txq(pub->bus);
	if (q == NULL)
		return;

	DHD_BTA(("dhd: flushing HCI ACL data for logical link %u...\n", llh));

	dhd_os_sdlock_txq(pub);

	/* Walk through the txq and toss all HCI ACL data packets */
	PKTQ_PREC_ITER(q, prec) {
		void *head_pkt = NULL;

		while (pktq_ppeek(q, prec) != head_pkt) {
			void *pkt = pktq_pdeq(q, prec);
			int ifidx;

			PKTPULL(pub->osh, pkt, dhd_bus_hdrlen(pub->bus));
			dhd_prot_hdrpull(pub, &ifidx, pkt);

			if (PKTLEN(pub->osh, pkt) >= RFC1042_HDR_LEN) {
				struct ether_header *eh =
				        (struct ether_header *)PKTDATA(pub->osh, pkt);

				if (ntoh16(eh->ether_type) < ETHER_TYPE_MIN) {
					struct dot11_llc_snap_header *lsh =
					        (struct dot11_llc_snap_header *)&eh[1];

					if (bcmp(lsh, BT_SIG_SNAP_MPROT,
					         DOT11_LLC_SNAP_HDR_LEN - 2) == 0 &&
					    ntoh16(lsh->type) == BTA_PROT_L2CAP) {
						amp_hci_ACL_data_t *ACL_data =
						        (amp_hci_ACL_data_t *)&lsh[1];
						uint16 handle = ltoh16(ACL_data->handle);

						if (HCI_ACL_DATA_HANDLE(handle) == llh) {
							PKTFREE(pub->osh, pkt, TRUE);
							count ++;
							continue;
						}
					}
				}
			}

			dhd_prot_hdrpush(pub, ifidx, pkt);
			PKTPUSH(pub->osh, pkt, dhd_bus_hdrlen(pub->bus));

			if (head_pkt == NULL)
				head_pkt = pkt;
			pktq_penq(q, prec, pkt);
		}
	}
开发者ID:DooMLoRD,项目名称:android_hardware_broadcom_wlan,代码行数:58,代码来源:dhd_bta.c

示例6: pkttotlen

/* return total length of buffer chain */
uint pkttotlen(void *drv, void *p)
{
	uint total;

	total = 0;
	for (; p; p = PKTNEXT(drv, p))
		total += PKTLEN(drv, p);
	return (total);
}
开发者ID:prime5711,项目名称:blackbox,代码行数:10,代码来源:bcmutils.c

示例7: prpkt

/* pretty hex print a pkt buffer chain */
void prpkt(char *msg, void *drv, void *p0)
{
	void *p;

	if (msg && (msg[0] != '\0'))
		printf("%s: ", msg);

	for (p = p0; p; p = PKTNEXT(drv, p))
		prhex(NULL, PKTDATA(drv, p), PKTLEN(drv, p));
}
开发者ID:prime5711,项目名称:blackbox,代码行数:11,代码来源:bcmutils.c

示例8: etc_totlen

uint
etc_totlen(etc_info_t *etc, void *p)
{
	uint total;

	total = 0;
	for (; p; p = PKTNEXT(etc->et, p))
		total += PKTLEN(etc->et, p);
	return (total);
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:10,代码来源:etc.c

示例9: pkttotlen

/* return total length of buffer chain */
uint
pkttotlen(osl_t *osh, void *p)
{
	uint total;

	total = 0;
	for (; p; p = PKTNEXT(osh, p))
		total += PKTLEN(osh, p);
	return (total);
}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:11,代码来源:bcmutils.c

示例10: pkt2pktcopy

/* copy data from one pkt buffer (chain) to another */
uint
pkt2pktcopy(osl_t *osh, void *p1, uint offs1, void *p2, uint offs2, int maxlen)
{
	uint8 *dp1, *dp2;
	uint len1, len2, copylen, totallen;

	for (; p1 && offs; p1 = PKTNEXT(osh, p1)) {
		if (offs1 < (uint)PKTLEN(osh, p1))
			break;
		offs1 -= PKTLEN(osh, p1);
	}
	for (; p2 && offs; p2 = PKTNEXT(osh, p2)) {
		if (offs2 < (uint)PKTLEN(osh, p2))
			break;
		offs2 -= PKTLEN(osh, p2);
	}

	/* Heck w/it, only need the above for now */
}
开发者ID:ariavie,项目名称:bcm,代码行数:20,代码来源:bcmutils.c

示例11: dhd_proto_fcinfo

bool
dhd_proto_fcinfo(dhd_pub_t *dhd, void *pktbuf, uint8 *fcbits)
{
#ifdef BDC
	struct bdc_header *h;

	if (PKTLEN(dhd->osh, pktbuf) < BDC_HEADER_LEN) {
		DHD_ERROR(("%s: rx data too short (%d < %d)\n",
			__FUNCTION__, PKTLEN(dhd->osh, pktbuf), BDC_HEADER_LEN));
		return BCME_ERROR;
	}

	h = (struct bdc_header *)PKTDATA(dhd->osh, pktbuf);

	*fcbits = h->priority >> BDC_PRIORITY_FC_SHIFT;
	if ((h->flags2 & BDC_FLAG2_FC_FLAG) == BDC_FLAG2_FC_FLAG)
		return TRUE;
#endif
	return FALSE;
}
开发者ID:angel12,项目名称:sch-i510_kernel,代码行数:20,代码来源:dhd_cdc.c

示例12: osl_pktdup

/* Clone a packet.
 * The pkttag contents are NOT cloned.
 */
void *
osl_pktdup(osl_t *osh, void *skb)
{
	void * p;

	ASSERT(!PKTISCHAINED(skb));

	/* clear the CTFBUF flag if set and map the rest of the buffer
	 * before cloning.
	 */
	PKTCTFMAP(osh, skb);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
	if ((p = pskb_copy((struct sk_buff *)skb, GFP_ATOMIC)) == NULL)
#else
	if ((p = skb_clone((struct sk_buff *)skb, GFP_ATOMIC)) == NULL)
#endif
		return NULL;

#ifdef CTFPOOL
	if (PKTISFAST(osh, skb)) {
		ctfpool_t *ctfpool;

		/* if the buffer allocated from ctfpool is cloned then
		 * we can't be sure when it will be freed. since there
		 * is a chance that we will be losing a buffer
		 * from our pool, we increment the refill count for the
		 * object to be alloced later.
		 */
		ctfpool = (ctfpool_t *)CTFPOOLPTR(osh, skb);
		ASSERT(ctfpool != NULL);
		PKTCLRFAST(osh, p);
		PKTCLRFAST(osh, skb);
		ctfpool->refills++;
	}
#endif /* CTFPOOL */

	/* Clear PKTC  context */
	PKTSETCLINK(p, NULL);
	PKTCCLRFLAGS(p);
	PKTCSETCNT(p, 1);
	PKTCSETLEN(p, PKTLEN(osh, skb));

	/* skb_clone copies skb->cb.. we don't want that */
	if (osh->pub.pkttag)
		OSL_PKTTAG_CLEAR(p);

	/* Increment the packet counter */
	atomic_inc(&osh->pktalloced);
	return (p);
}
开发者ID:Fechinator,项目名称:FechdaKernel,代码行数:54,代码来源:linux_osl.c

示例13: dhd_tcpack_check_xmit

inline int dhd_tcpack_check_xmit(dhd_pub_t *dhdp, void *pkt)
{
    uint8 i;
    tcp_ack_info_t *tcp_ack_info = NULL;
    int tbl_cnt;
    uint pushed_len;
    int ret = BCME_OK;
    void *pdata;
    uint32 pktlen;

    if (!dhdp->tcpack_sup_enabled)
        return ret;

    pdata = PKTDATA(dhdp->osh, pkt);

    /* Length of BDC(+WLFC) headers pushed */
    pushed_len = BDC_HEADER_LEN + (((struct bdc_header *)pdata)->dataOffset * 4);
    pktlen = PKTLEN(dhdp->osh, pkt) - pushed_len;

    if (pktlen < TCPACKSZMIN || pktlen > TCPACKSZMAX) {
        DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n",
                   __FUNCTION__, __LINE__, pktlen));
        return ret;
    }

    dhd_os_tcpacklock(dhdp);
    tbl_cnt = dhdp->tcp_ack_info_cnt;
    for (i = 0; i < tbl_cnt; i++) {
        tcp_ack_info = &dhdp->tcp_ack_info_tbl[i];
        if (tcp_ack_info->pkt_in_q == pkt) {
            DHD_TRACE(("%s %d: pkt %p sent out. idx %d, tbl_cnt %d\n",
                       __FUNCTION__, __LINE__, pkt, i, tbl_cnt));
            /* This pkt is being transmitted so remove the tcp_ack_info of it. */
            if (i < tbl_cnt - 1) {
                bcopy(&dhdp->tcp_ack_info_tbl[tbl_cnt - 1],
                      &dhdp->tcp_ack_info_tbl[i], sizeof(struct tcp_ack_info));
            }
            bzero(&dhdp->tcp_ack_info_tbl[tbl_cnt - 1], sizeof(struct tcp_ack_info));
            if (--dhdp->tcp_ack_info_cnt < 0) {
                DHD_ERROR(("%s %d: ERROR!!! tcp_ack_info_cnt %d\n",
                           __FUNCTION__, __LINE__, dhdp->tcp_ack_info_cnt));
                ret = BCME_ERROR;
            }
            break;
        }
    }
    dhd_os_tcpackunlock(dhdp);
    return ret;
}
开发者ID:iTechnoguy,项目名称:kernel-nk1-negalite-lt02ltespr,代码行数:49,代码来源:dhd_ip.c

示例14: osl_pktdup

void *
osl_pktdup(osl_t *osh, void *skb)
{
	void * p;

	ASSERT(!PKTISCHAINED(skb));

	
	PKTCTFMAP(osh, skb);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
	if ((p = pskb_copy((struct sk_buff *)skb, GFP_ATOMIC)) == NULL)
#else
	if ((p = skb_clone((struct sk_buff *)skb, GFP_ATOMIC)) == NULL)
#endif
		return NULL;

#ifdef CTFPOOL
	if (PKTISFAST(osh, skb)) {
		ctfpool_t *ctfpool;

		
		ctfpool = (ctfpool_t *)CTFPOOLPTR(osh, skb);
		ASSERT(ctfpool != NULL);
		PKTCLRFAST(osh, p);
		PKTCLRFAST(osh, skb);
		ctfpool->refills++;
	}
#endif 

	
	PKTSETCLINK(p, NULL);
	PKTCCLRFLAGS(p);
	PKTCSETCNT(p, 1);
	PKTCSETLEN(p, PKTLEN(osh, skb));

	
	if (osh->pub.pkttag)
		OSL_PKTTAG_CLEAR(p);

	
	atomic_inc(&osh->pktalloced);
	return (p);
}
开发者ID:LGaljo,项目名称:android_kernel_samsung_s3ve3g,代码行数:44,代码来源:linux_osl.c

示例15: pktpool_add

int
pktpool_add(pktpool_t *pktp, void *p)
{
	ASSERT(p != NULL);

	if (pktp->len == pktp->maxlen)
		return BCME_RANGE;

	/* pkts in pool have same length */
	ASSERT(pktp->plen == PKTLEN(OSH_NULL, p));
	PKTSETPOOL(OSH_NULL, p, TRUE, pktp);

	pktp->len++;
	pktpool_enq(pktp, p);

#ifdef BCMDBG_POOL
	pktp->dbg_q[pktp->dbg_qlen++].p = p;
#endif

	return 0;
}
开发者ID:MethHeadAlert,项目名称:M9,代码行数:21,代码来源:hnd_pktpool.c


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