这篇教程C++ IF_DEQUEUE函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IF_DEQUEUE函数的典型用法代码示例。如果您正苦于以下问题:C++ IF_DEQUEUE函数的具体用法?C++ IF_DEQUEUE怎么用?C++ IF_DEQUEUE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IF_DEQUEUE函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pppdealloc/* * Deallocate a ppp unit. Must be called at splsoftnet or higher. */voidpppdealloc(struct ppp_softc *sc){ struct ppp_pkt *pkt; struct mbuf *m; splsoftassert(IPL_SOFTNET); if_down(&sc->sc_if); sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING); sc->sc_devp = NULL; sc->sc_xfer = 0; while ((pkt = ppp_pkt_dequeue(&sc->sc_rawq)) != NULL) ppp_pkt_free(pkt); while ((m = mq_dequeue(&sc->sc_inq)) != NULL) m_freem(m); for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) break; m_freem(m); } while ((m = sc->sc_npqueue) != NULL) { sc->sc_npqueue = m->m_nextpkt; m_freem(m); } m_freem(sc->sc_togo); sc->sc_togo = NULL;#ifdef PPP_COMPRESS ppp_ccp_closed(sc); sc->sc_xc_state = NULL; sc->sc_rc_state = NULL;#endif /* PPP_COMPRESS */#if NBPFILTER > 0 if (sc->sc_pass_filt.bf_insns != 0) { free(sc->sc_pass_filt.bf_insns, M_DEVBUF, 0); sc->sc_pass_filt.bf_insns = 0; sc->sc_pass_filt.bf_len = 0; } if (sc->sc_active_filt.bf_insns != 0) { free(sc->sc_active_filt.bf_insns, M_DEVBUF, 0); sc->sc_active_filt.bf_insns = 0; sc->sc_active_filt.bf_len = 0; }#endif#ifdef VJC if (sc->sc_comp != 0) { free(sc->sc_comp, M_DEVBUF, 0); sc->sc_comp = 0; }#endif}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:56,
示例2: iavc_start_txstatic void iavc_start_tx(iavc_softc_t *sc){ struct mbuf *m; u_int32_t txlen; /* If device has put us on hold, punt. */ if (sc->sc_blocked) { return; } /* If using DMA and transmitter busy, punt. */ if (sc->sc_dma && (sc->sc_csr & EN_TX_TC_INT)) { return; } /* Else, see if we have messages to send. */ IF_DEQUEUE(&sc->sc_txq, m); if (!m) { return; } /* Have message, will send. */ if (CAPIMSG_LEN(m->m_data)) { /* A proper CAPI message, possibly with B3 data */ txlen = iavc_tx_capimsg(sc, m); } else { /* A board control message to be sent as is */ txlen = iavc_tx_ctrlmsg(sc, m); } if (m->m_next) { i4b_Bfreembuf(m->m_next); m->m_next = NULL; } i4b_Dfreembuf(m); /* Kick DMA into motion if applicable */ if (sc->sc_dma) { txlen = (txlen + 3) & ~3; bus_dmamap_sync(sc->dmat, sc->tx_map, 0, txlen, BUS_DMASYNC_PREWRITE); AMCC_WRITE(sc, AMCC_TXPTR, sc->tx_map->dm_segs[0].ds_addr); AMCC_WRITE(sc, AMCC_TXLEN, txlen); sc->sc_csr |= EN_TX_TC_INT; if (!sc->sc_intr) AMCC_WRITE(sc, AMCC_INTCSR, sc->sc_csr); }}
开发者ID:Tommmster,项目名称:netbsd-avr32,代码行数:52,
示例3: snstart/* * Encapsulate a packet of type family for the local net. */static voidsnstart(struct ifnet *ifp){ struct sn_softc *sc = ifp->if_softc; struct mbuf *m; int mtd_next; if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) return;outloop: /* Check for room in the xmit buffer. */ if ((mtd_next = (sc->mtd_free + 1)) == NTDA) mtd_next = 0; if (mtd_next == sc->mtd_hw) { ifp->if_flags |= IFF_OACTIVE; return; } IF_DEQUEUE(&ifp->if_snd, m); if (m == 0) return; /* We need the header for m_pkthdr.len. */ if ((m->m_flags & M_PKTHDR) == 0) panic("%s: snstart: no header mbuf", device_xname(sc->sc_dev)); /* * If bpf is listening on this interface, let it * see the packet before we commit it to the wire. */ bpf_mtap(ifp, m); /* * If there is nothing in the o/p queue, and there is room in * the Tx ring, then send the packet directly. Otherwise append * it to the o/p queue. */ if ((sonicput(sc, m, mtd_next)) == 0) { IF_PREPEND(&ifp->if_snd, m); return; } sc->mtd_prev = sc->mtd_free; sc->mtd_free = mtd_next; ifp->if_opackets++; /* # of pkts */ /* Jump back for possibly more punishment. */ goto outloop;}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:55,
示例4: scestartvoidscestart(int unit){ sce_softc_t ssc = scegetssc(unit); scsit_return_t sr; struct ifnet *ifp; io_req_t ior; TR_DECL("scestart"); tr2("enter: unit = 0x%x", unit); assert(ssc != NULL_SSC); ifp = &ssc->sce_if; IF_DEQUEUE(&ifp->if_snd, ior); dequeued: while(ior) { struct ether_header *ehp = (struct ether_header *)ior->io_data; scsit_handle_t handle; bcopy((const char *)sce_fake_addr,(char *)&ehp->ether_shost,6); sr = scsit_handle_alloc(&handle); assert(sr == SCSIT_SUCCESS); tr1("sending"); sr = scsit_send(handle, ssc->node, sce_lun, (void *)ior, (char *)ehp, ior->io_count, FALSE); assert(sr == SCSIT_SUCCESS); IF_DEQUEUE(&ifp->if_snd, ior); } tr1("exit");}
开发者ID:rohsaini,项目名称:mkunity,代码行数:38,
示例5: hdintrhdintr (){ register struct mbuf *m; register struct hdcb *hdp; register struct ifnet *ifp; register int s; static struct ifnet *lastifp; static struct hdcb *lasthdp; for (;;) { s = splimp (); IF_DEQUEUE (&hdintrq, m); splx (s); if (m == 0) break; if (m->m_len < HDHEADERLN) { printf ("hdintr: packet too short (len=%d)/n", m->m_len); m_freem (m); continue; } if ((m->m_flags & M_PKTHDR) == 0) panic("hdintr"); ifp = m->m_pkthdr.rcvif; /* * look up the appropriate hdlc control block */ if (ifp == lastifp) hdp = lasthdp; else { for (hdp = hdcbhead; hdp; hdp = hdp->hd_next) if (hdp->hd_ifp == ifp) break; if (hdp == 0) { printf ("hdintr: unknown interface %x/n", ifp); m_freem (m); continue; } lastifp = ifp; lasthdp = hdp; } /* Process_rxframe returns FALSE if the frame was NOT queued for the next higher layers. */ if (process_rxframe (hdp, m) == FALSE) m_freem (m); }}
开发者ID:ShanghaiTimes,项目名称:original-bsd,代码行数:50,
示例6: xilTemacTxThreadSinglevoid xilTemacTxThreadSingle(struct ifnet* ifp){ struct XilTemac* xilTemac = ifp->if_softc; struct mbuf* m; uint32_t base = xilTemac->iAddr;#ifdef DEBUG printk("%s: tx send packet, interface '%s'/n", DRIVER_PREFIX, xilTemac->iUnitName );#endif /* Send packets till mbuf queue empty or tx fifo full */ for(;;) { uint32_t i = 0; /* 1) clear out any statuses from previously sent tx frames */ while( IN32(base + XTE_IPISR_OFFSET) & XTE_IPXR_XMIT_DONE_MASK ) { IN32(base + XTE_TSR_OFFSET); OUT32(base + XTE_IPISR_OFFSET, XTE_IPXR_XMIT_DONE_MASK); i++; } if( i > xilTemac->iStats.iTxMaxDrained ) { xilTemac->iStats.iTxMaxDrained = i; } /* 2) Check if enough space in tx data fifo _and_ tx tplr for an entire ethernet frame */ if( xilTemacTxFifoVacancyBytes( xilTemac->iAddr ) <= ifp->if_mtu ) { /* 2a) If not, enable transmit done interrupt and break out of loop to wait for space */ uint32_t ipier = IN32(base + XTE_IPIER_OFFSET); ipier |= (XTE_IPXR_XMIT_DONE_MASK); OUT32(base + XTE_IPIER_OFFSET, ipier); break; } /* 3) Contuine to dequeue mbuf chains till none left */ IF_DEQUEUE( &(ifp->if_snd), m); if( !m ) { break; } /* 4) Send dequeued mbuf chain */ xilTemacSendPacket( ifp, m ); /* 5) Free mbuf chain */ m_freem( m ); } ifp->if_flags &= ~IFF_OACTIVE;}
开发者ID:AlexShiLucky,项目名称:rtems,代码行数:49,
示例7: compat_readstatic status_tcompat_read(void *cookie, off_t position, void *buffer, size_t *numBytes){ struct ifnet *ifp = cookie; uint32 semFlags = B_CAN_INTERRUPT; status_t status; struct mbuf *mb; size_t length; //if_printf(ifp, "compat_read(%lld, %p, [%lu])/n", position, // buffer, *numBytes); if (ifp->flags & DEVICE_CLOSED) return B_INTERRUPTED; if (ifp->flags & DEVICE_NON_BLOCK) semFlags |= B_RELATIVE_TIMEOUT; do { status = acquire_sem_etc(ifp->receive_sem, 1, semFlags, 0); if (ifp->flags & DEVICE_CLOSED) return B_INTERRUPTED; if (status == B_WOULD_BLOCK) { *numBytes = 0; return B_OK; } else if (status < B_OK) return status; IF_DEQUEUE(&ifp->receive_queue, mb); } while (mb == NULL); length = min_c(max_c((size_t)mb->m_pkthdr.len, 0), *numBytes);#if 0 mb = m_defrag(mb, 0); if (mb == NULL) { *numBytes = 0; return B_NO_MEMORY; }#endif m_copydata(mb, 0, length, buffer); *numBytes = length; m_freem(mb); return B_OK;}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:48,
示例8: pflogstart/* * Start output on the pflog interface. */voidpflogstart(struct ifnet *ifp){ struct mbuf *m; int s; for (;;) { s = splnet(); IF_DROP(&ifp->if_snd); IF_DEQUEUE(&ifp->if_snd, m); splx(s); if (m == NULL) return; m_freem(m); }}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:20,
示例9: rbch_clrq/*---------------------------------------------------------------------------* * clear an hdlc rx queue for a rbch unit *---------------------------------------------------------------------------*/static voidrbch_clrq(void *softc){ struct rbch_softc *sc = softc; struct mbuf *m; int s; for(;;) { s = splnet(); IF_DEQUEUE(&sc->sc_hdlcq, m); splx(s); if(m) m_freem(m); else break; }}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:22,
示例10: ieee80211_drain_ifqvoidieee80211_drain_ifq(struct ifqueue* ifq){ struct ieee80211_node* ni; struct mbuf* m; for (;;) { IF_DEQUEUE(ifq, m); if (m == NULL) break; ni = (struct ieee80211_node*)m->m_pkthdr.rcvif; KASSERT(ni != NULL, ("frame w/o node")); ieee80211_free_node(ni); m->m_pkthdr.rcvif = NULL; m_freem(m); }}
开发者ID:sahil9912,项目名称:haiku,代码行数:19,
示例11: fwe_startstatic voidfwe_start(struct ifnet *ifp){ struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; int s; FWEDEBUG(ifp, "starting/n"); if (fwe->dma_ch < 0) { struct mbuf *m = NULL; FWEDEBUG(ifp, "not ready/n"); s = splimp(); do { IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) m_freem(m); ifp->if_oerrors ++; } while (m != NULL); splx(s); return; } s = splimp();#if defined(__FreeBSD__) ifp->if_drv_flags |= IFF_DRV_OACTIVE;#else ifp->if_flags |= IFF_OACTIVE;#endif if (ifp->if_snd.ifq_len != 0) fwe_as_output(fwe, ifp);#if defined(__FreeBSD__) ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;#else ifp->if_flags &= ~IFF_OACTIVE;#endif splx(s);}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:42,
示例12: isdntrcread/*---------------------------------------------------------------------------* * read from trace device *---------------------------------------------------------------------------*/PDEVSTATIC intisdntrcread(dev_t dev, struct uio * uio, int ioflag){ struct mbuf *m; int x; int error = 0; int unit = minor(dev); if(!(device_state[unit] & ST_ISOPEN)) return(EIO); x = splnet(); while(IF_QEMPTY(&trace_queue[unit]) && (device_state[unit] & ST_ISOPEN)) { device_state[unit] |= ST_WAITDATA; if((error = tsleep((caddr_t) &trace_queue[unit], TTIPRI | PCATCH, "bitrc", 0 )) != 0) { device_state[unit] &= ~ST_WAITDATA; splx(x); return(error); } } IF_DEQUEUE(&trace_queue[unit], m); if(m && m->m_len) error = uiomove(m->m_data, m->m_len, uio); else error = EIO; if(m) i4b_Bfreembuf(m); splx(x); return(error);}
开发者ID:MarginC,项目名称:kame,代码行数:44,
示例13: tx_daemonstatic void tx_daemon(void *arg){ struct ifnet *ifp = &arpcom.ac_if; rtems_event_set events; struct mbuf *m; while(1) { rtems_bsdnet_event_receive(START_TRANSMIT_EVENT, RTEMS_EVENT_ANY | RTEMS_WAIT, RTEMS_NO_TIMEOUT, &events); while(1) { IF_DEQUEUE(&ifp->if_snd, m); if(m == NULL) break; rtems_bsdnet_event_receive(CTS_EVENT, RTEMS_EVENT_ANY | RTEMS_WAIT, RTEMS_NO_TIMEOUT, &events); send_packet(ifp, m); m_freem(m); } ifp->if_flags &= ~IFF_OACTIVE; }}
开发者ID:RTEMS,项目名称:rtems,代码行数:21,
示例14: uether_rxflushvoiduether_rxflush(struct usb_ether *ue){ struct ifnet *ifp = uether_getifp(ue); struct mbuf *m; UE_LOCK_ASSERT(ue); for (;;) { IF_DEQUEUE(&ue->ue_rxq, m); if (m == NULL) break; /* * The USB xfer has been resubmitted so its safe to unlock now. */ UE_UNLOCK(ue); ifp->if_input(ifp, m, NULL, -1); UE_LOCK(ue); }}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:21,
示例15: cdce_startStatic voidcdce_start(struct ifnet *ifp){ struct cdce_softc *sc; struct mbuf *m_head = NULL; sc = ifp->if_softc; CDCE_LOCK(sc); if (sc->cdce_dying || ifp->if_flags & IFF_OACTIVE || !(ifp->if_flags & IFF_RUNNING)) { CDCE_UNLOCK(sc); return; } IF_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) { CDCE_UNLOCK(sc); return; } if (cdce_encap(sc, m_head, 0)) { IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; CDCE_UNLOCK(sc); return; } BPF_MTAP(ifp, m_head); ifp->if_flags |= IFF_OACTIVE; CDCE_UNLOCK(sc); return;}
开发者ID:MarginC,项目名称:kame,代码行数:38,
示例16: ieee80211_notify_dtim/* * This function shall be called by drivers immediately after every DTIM. * Transmit all group addressed MSDUs buffered at the AP. */voidieee80211_notify_dtim(struct ieee80211com *ic){ /* NB: group addressed MSDUs are buffered in ic_bss */ struct ieee80211_node *ni = ic->ic_bss; struct ifnet *ifp = &ic->ic_if; struct ieee80211_frame *wh; struct mbuf *m; KASSERT(ic->ic_opmode == IEEE80211_M_HOSTAP); for (;;) { IF_DEQUEUE(&ni->ni_savedq, m); if (m == NULL) break; if (!IF_IS_EMPTY(&ni->ni_savedq)) { /* more queued frames, set the more data bit */ wh = mtod(m, struct ieee80211_frame *); wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; } IF_ENQUEUE(&ic->ic_pwrsaveq, m); (*ifp->if_start)(ifp); }
开发者ID:SylvestreG,项目名称:bitrig,代码行数:27,
示例17: i4btelioctli4btelioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)#endif{ int error = 0; struct mbuf *m; int s; tel_sc_t *sc = &tel_sc[minor(dev)]; switch(cmd) { case I4B_TEL_GETAUDIOFMT: *(int *)data = sc->audiofmt; break; case I4B_TEL_SETAUDIOFMT: sc->audiofmt = *(int *)data; break; case I4B_TEL_EMPTYINPUTQUEUE: s = splimp(); while((sc->devstate & ST_CONNECTED) && (sc->devstate & ST_ISOPEN) && !IF_QEMPTY(sc->isdn_linktab->rx_queue)) { IF_DEQUEUE(sc->isdn_linktab->rx_queue, m); if(m) i4b_Bfreembuf(m); } splx(s); break; default: error = ENOTTY; break; } return(error);}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:37,
示例18: i4bputqueue_hipri/*---------------------------------------------------------------------------* * i4bputqueue_hipri - put message into front of queue to userland *---------------------------------------------------------------------------*/voidi4bputqueue_hipri(struct mbuf *m){ int x; if(!openflag) { i4b_Dfreembuf(m); return; } x = splimp(); if(IF_QFULL(&i4b_rdqueue)) { struct mbuf *m1; IF_DEQUEUE(&i4b_rdqueue, m1); i4b_Dfreembuf(m1); DBGL4(L4_ERR, "i4bputqueue", ("ERROR, queue full, removing entry!/n")); } IF_PREPEND(&i4b_rdqueue, m); splx(x); if(readflag) { readflag = 0; wakeup((caddr_t) &i4b_rdqueue); } if(selflag) { selflag = 0; selwakeup(&select_rd_info); }}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:40,
示例19: pppintr/* * Software interrupt routine, called at spl[soft]net. */static voidpppintr(netmsg_t msg){ struct mbuf *m; struct ppp_softc *sc; struct ifaltq_subque *ifsq; int i; /* * Packets are never sent to this netisr so the message must always * be replied. Interlock processing and notification by replying * the message first. */ lwkt_replymsg(&msg->lmsg, 0); get_mplock(); sc = ppp_softc; ifsq = ifq_get_subq_default(&sc->sc_if.if_snd); for (i = 0; i < NPPP; ++i, ++sc) { ifnet_serialize_all(&sc->sc_if); if (!(sc->sc_flags & SC_TBUSY) && (!ifsq_is_empty(ifsq) || !IF_QEMPTY(&sc->sc_fastq))) { sc->sc_flags |= SC_TBUSY; (*sc->sc_start)(sc); } for (;;) { IF_DEQUEUE(&sc->sc_rawq, m); if (m == NULL) break; ppp_inproc(sc, m); } ifnet_deserialize_all(&sc->sc_if); } rel_mplock();}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:40,
示例20: mplsintrvoidmplsintr(void){ struct mbuf *m; for (;;) { IFQ_LOCK(&mplsintrq); IF_DEQUEUE(&mplsintrq, m); IFQ_UNLOCK(&mplsintrq); if (!m) return; if (((m->m_flags & M_PKTHDR) == 0) || (m->m_pkthdr.rcvif_index == 0)) panic("mplsintr(): no pkthdr or rcvif");#ifdef MBUFTRACE m_claimm(m, &mpls_owner);#endif mpls_input(m_get_rcvif_NOMPSAFE(m), m); }}
开发者ID:ryo,项目名称:netbsd-src,代码行数:24,
示例21: fwe_startstatic voidfwe_start(struct ifnet *ifp){ struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe; int s;#if 1 FWEDEBUG("%s%d starting/n", ifp->if_name, ifp->if_unit); if (fwe->dma_ch < 0) { struct mbuf *m = NULL; FWEDEBUG("%s%d not ready./n", ifp->if_name, ifp->if_unit); s = splimp(); do { IF_DEQUEUE(&ifp->if_snd, m); if (m != NULL) m_freem(m); ifp->if_oerrors ++; } while (m != NULL); splx(s); return; }#endif s = splimp(); ifp->if_flags |= IFF_OACTIVE; if (ifp->if_snd.ifq_len != 0) fwe_as_output(fwe, ifp); ifp->if_flags &= ~IFF_OACTIVE; splx(s);}
开发者ID:MarginC,项目名称:kame,代码行数:36,
示例22: isic_bchannel_start/*---------------------------------------------------------------------------* * start transmission on a b channel *---------------------------------------------------------------------------*/static voidisic_bchannel_start(int unit, int h_chan){ struct l1_softc *sc = &l1_sc[unit]; l1_bchan_state_t *chan = &sc->sc_chan[h_chan]; int next_len; int len; int activity = -1; int cmd = 0; crit_enter(); if(chan->state & HSCX_TX_ACTIVE) /* already running ? */ { crit_exit(); return; /* yes, leave */ } /* get next mbuf from queue */ IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head); if(chan->out_mbuf_head == NULL) /* queue empty ? */ { crit_exit(); return; /* yes, exit */ } /* init current mbuf values */ chan->out_mbuf_cur = chan->out_mbuf_head; chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len; chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data; /* activity indicator for timeout handling */ if(chan->bprot == BPROT_NONE) { if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len))) activity = ACT_TX; } else { activity = ACT_TX; } chan->state |= HSCX_TX_ACTIVE; /* we start transmitting */ if(sc->sc_trace & TRACE_B_TX) /* if trace, send mbuf to trace dev */ { i4b_trace_hdr_t hdr; hdr.unit = L0ISICUNIT(unit); hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2); hdr.dir = FROM_TE; hdr.count = ++sc->sc_trace_bcount; MICROTIME(hdr.time); i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data); } len = 0; /* # of chars put into HSCX tx fifo this time */ /* * fill the HSCX tx fifo with data from the current mbuf. if * current mbuf holds less data than HSCX fifo length, try to * get the next mbuf from (a possible) mbuf chain. if there is * not enough data in a single mbuf or in a chain, then this * is the last mbuf and we tell the HSCX that it has to send * CRC and closing flag */ while((len < sc->sc_bfifolen) && chan->out_mbuf_cur) { /* * put as much data into the HSCX fifo as is * available from the current mbuf */ if((len + chan->out_mbuf_cur_len) >= sc->sc_bfifolen) next_len = sc->sc_bfifolen - len; else next_len = chan->out_mbuf_cur_len;#ifdef NOTDEF kprintf("b:mh=%x, mc=%x, mcp=%x, mcl=%d l=%d nl=%d # ", chan->out_mbuf_head, chan->out_mbuf_cur, chan->out_mbuf_cur_ptr, chan->out_mbuf_cur_len, len, next_len);#endif /* wait for tx fifo write enabled */ isic_hscx_waitxfw(sc, h_chan); /* write what we have from current mbuf to HSCX fifo *///.........这里部分代码省略.........
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:101,
示例23: ppp_dequeue/* * Get a packet to send. This procedure is intended to be called at * splsoftnet, since it may involve time-consuming operations such as * applying VJ compression, packet compression, address/control and/or * protocol field compression to the packet. */struct mbuf *ppp_dequeue(struct ppp_softc *sc){ struct mbuf *m, *mp; u_char *cp; int address, control, protocol; /* * Grab a packet to send: first try the fast queue, then the * normal queue. */ IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) m = ifsq_dequeue(ifq_get_subq_default(&sc->sc_if.if_snd)); if (m == NULL) return NULL; ++sc->sc_stats.ppp_opackets; /* * Extract the ppp header of the new packet. * The ppp header will be in one mbuf. */ cp = mtod(m, u_char *); address = PPP_ADDRESS(cp); control = PPP_CONTROL(cp); protocol = PPP_PROTOCOL(cp); switch (protocol) { case PPP_IP:#ifdef VJC /* * If the packet is a TCP/IP packet, see if we can compress it. */ if ((sc->sc_flags & SC_COMP_TCP) && sc->sc_comp != NULL) { struct ip *ip; int type; mp = m; ip = (struct ip *) (cp + PPP_HDRLEN); if (mp->m_len <= PPP_HDRLEN) { mp = mp->m_next; if (mp == NULL) break; ip = mtod(mp, struct ip *); } /* this code assumes the IP/TCP header is in one non-shared mbuf */ if (ip->ip_p == IPPROTO_TCP) { type = sl_compress_tcp(mp, ip, sc->sc_comp, !(sc->sc_flags & SC_NO_TCP_CCID)); switch (type) { case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; cp = mtod(m, u_char *); cp[0] = address; /* header has moved */ cp[1] = control; cp[2] = 0; break; } cp[3] = protocol; /* update protocol in PPP header */ } }
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:71,
示例24: ipxintr/* * IPX input routine. Pass to next level. */voidipxintr(){ register struct ipx *ipx; register struct mbuf *m; register struct ipxpcb *ipxp; struct ipx_ifaddr *ia; register int i; int len, s; char oddshortpacket = 0;next: /* * Get next datagram off input queue and get IPX header * in first mbuf. */ s = splimp(); IF_DEQUEUE(&ipxintrq, m); splx(s); if (m == NULL) return; /* * If no IPX addresses have been set yet but the interfaces * are receiving, can't do anything with incoming packets yet. */ if (ipx_ifaddr == NULL) goto bad; ipxstat.ipxs_total++; if ((m->m_flags & M_EXT || m->m_len < sizeof(struct ipx)) && (m = m_pullup(m, sizeof(struct ipx))) == 0) { ipxstat.ipxs_toosmall++; goto next; } /* * Give any raw listeners a crack at the packet */ for (ipxp = ipxrawpcb.ipxp_next; ipxp != &ipxrawpcb; ipxp = ipxp->ipxp_next) { struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); if (m1 != NULL) ipx_input(m1, ipxp); } ipx = mtod(m, struct ipx *); len = ntohs(ipx->ipx_len); if ((len < m->m_pkthdr.len) && (oddshortpacket = len & 1)) { /* * If this packet is of odd length, and the length * inside the header is less than the received packet * length, preserve garbage byte for possible checksum. */ len++; } /* * Check that the amount of data in the buffers * is as at least much as the IPX header would have us expect. * Trim mbufs if longer than we expect. * Drop packet if shorter than we expect. */ if (m->m_pkthdr.len < len) { ipxstat.ipxs_tooshort++; goto bad; } if (m->m_pkthdr.len > len) { if (m->m_len == m->m_pkthdr.len) { m->m_len = len; m->m_pkthdr.len = len; } else m_adj(m, len - m->m_pkthdr.len); } if (ipxcksum && ((i = ipx->ipx_sum) != 0xffff)) { ipx->ipx_sum = 0; if (i != (ipx->ipx_sum = ipx_cksum(m, len))) { ipxstat.ipxs_badsum++; goto bad; } } /* * Propagated (Netbios) packets (type 20) has to be handled * different. :-( */ if (ipx->ipx_pt == IPXPROTO_NETBIOS) { if (ipxnetbios) { ipx_output_type20(m); goto next; } else goto bad; } /* * Is this a directed broadcast? *///.........这里部分代码省略.........
开发者ID:kame,项目名称:kame,代码行数:101,
示例25: admsw_start/* * admsw_start: [ifnet interface function] * * Start packet transmission on the interface. */static voidadmsw_start(struct ifnet *ifp){ struct admsw_softc *sc = ifp->if_softc; struct mbuf *m0, *m; struct admsw_descsoft *ds; struct admsw_desc *desc; bus_dmamap_t dmamap; struct ether_header *eh; int error, nexttx, len, i; static int vlan = 0; /* * Loop through the send queues, setting up transmit descriptors * unitl we drain the queues, or use up all available transmit * descriptors. */ for (;;) { vlan++; if (vlan == SW_DEVS) vlan = 0; i = vlan; for (;;) { ifp = sc->sc_ifnet[i]; if ((ifp->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) == IFF_DRV_RUNNING) { /* Grab a packet off the queue. */ IF_DEQUEUE(&ifp->if_snd, m0); if (m0 != NULL) break; } i++; if (i == SW_DEVS) i = 0; if (i == vlan) return; } vlan = i; m = NULL; /* Get a spare descriptor. */ if (sc->sc_txfree == 0) { /* No more slots left; notify upper layer. */ ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; } nexttx = sc->sc_txnext; desc = &sc->sc_txldescs[nexttx]; ds = &sc->sc_txlsoft[nexttx]; dmamap = ds->ds_dmamap; /* * Load the DMA map. If this fails, the packet either * didn't fit in the alloted number of segments, or we * were short on resources. In this case, we'll copy * and try again. */ if (m0->m_pkthdr.len < ETHER_MIN_LEN || bus_dmamap_load_mbuf(sc->sc_bufs_dmat, dmamap, m0, admsw_mbuf_map_addr, ds, BUS_DMA_NOWAIT) != 0) { MGETHDR(m, M_NOWAIT, MT_DATA); if (m == NULL) { device_printf(sc->sc_dev, "unable to allocate Tx mbuf/n"); break; } if (m0->m_pkthdr.len > MHLEN) { MCLGET(m, M_NOWAIT); if ((m->m_flags & M_EXT) == 0) { device_printf(sc->sc_dev, "unable to allocate Tx cluster/n"); m_freem(m); break; } } m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags; m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, void *)); m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len; if (m->m_pkthdr.len < ETHER_MIN_LEN) { if (M_TRAILINGSPACE(m) < ETHER_MIN_LEN - m->m_pkthdr.len) panic("admsw_start: M_TRAILINGSPACE/n"); memset(mtod(m, uint8_t *) + m->m_pkthdr.len, 0, ETHER_MIN_LEN - ETHER_CRC_LEN - m->m_pkthdr.len); m->m_pkthdr.len = m->m_len = ETHER_MIN_LEN; } error = bus_dmamap_load_mbuf(sc->sc_bufs_dmat, dmamap, m, admsw_mbuf_map_addr, ds, BUS_DMA_NOWAIT); if (error) { device_printf(sc->sc_dev, "unable to load Tx buffer, error = %d/n", error); break; } }//.........这里部分代码省略.........
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:101,
示例26: fwe_as_output/* Async. stream output */static voidfwe_as_output(struct fwe_softc *fwe, struct ifnet *ifp){ struct mbuf *m; struct fw_xfer *xfer; struct fw_xferq *xferq; struct fw_pkt *fp; int i = 0; xfer = NULL; xferq = fwe->fd.fc->atq; while ((xferq->queued < xferq->maxq - 1) && (ifp->if_snd.ifq_head != NULL)) { FWE_LOCK(fwe); xfer = STAILQ_FIRST(&fwe->xferlist); if (xfer == NULL) {#if 0 printf("if_fwe: lack of xfer/n");#endif FWE_UNLOCK(fwe); break; } STAILQ_REMOVE_HEAD(&fwe->xferlist, link); FWE_UNLOCK(fwe); IF_DEQUEUE(&ifp->if_snd, m); if (m == NULL) { FWE_LOCK(fwe); STAILQ_INSERT_HEAD(&fwe->xferlist, xfer, link); FWE_UNLOCK(fwe); break; }#if defined(__DragonFly__) || __FreeBSD_version < 500000 if (ifp->if_bpf != NULL) bpf_mtap(ifp, m);#else BPF_MTAP(ifp, m);#endif /* keep ip packet alignment for alpha */ M_PREPEND(m, ETHER_ALIGN, M_NOWAIT); fp = &xfer->send.hdr; *(uint32_t *)&xfer->send.hdr = *(int32_t *)&fwe->pkt_hdr; fp->mode.stream.len = m->m_pkthdr.len; xfer->mbuf = m; xfer->send.pay_len = m->m_pkthdr.len; if (fw_asyreq(fwe->fd.fc, -1, xfer) != 0) { /* error */ ifp->if_oerrors ++; /* XXX set error code */ fwe_output_callback(xfer); } else { ifp->if_opackets ++; i++; } }#if 0 if (i > 1) printf("%d queued/n", i);#endif if (i > 0) xferq->start(fwe->fd.fc);}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:65,
注:本文中的IF_DEQUEUE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IF_FREE函数代码示例 C++ IF_DEBUG函数代码示例 |