本文整理汇总了C++中MCLGET函数的典型用法代码示例。如果您正苦于以下问题:C++ MCLGET函数的具体用法?C++ MCLGET怎么用?C++ MCLGET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MCLGET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gss_verify_mic
OM_uint32
gss_verify_mic(OM_uint32 *minor_status,
const gss_ctx_id_t ctx,
const gss_buffer_t message_buffer,
const gss_buffer_t token_buffer,
gss_qop_t *qop_state)
{
OM_uint32 maj_stat;
struct mbuf *m, *mic;
if (!ctx) {
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
MGET(m, M_WAITOK, MT_DATA);
if (message_buffer->length > MLEN)
MCLGET(m, M_WAITOK);
m_append(m, message_buffer->length, message_buffer->value);
MGET(mic, M_WAITOK, MT_DATA);
if (token_buffer->length > MLEN)
MCLGET(mic, M_WAITOK);
m_append(mic, token_buffer->length, token_buffer->value);
maj_stat = KGSS_VERIFY_MIC(ctx, minor_status, m, mic, qop_state);
m_freem(m);
m_freem(mic);
return (maj_stat);
}
示例2: smb_mbuf_allocate
/*
* Allocate enough mbufs to accommodate the residual count in uio,
* and setup the uio_iov to point to them.
*
* This is used by the various SMB read code paths. That code is
* going to do a disk read into this buffer, so we'd like it to be
* large and contiguous. Use an external (M_EXT) buffer.
*/
struct mbuf *
smb_mbuf_allocate(struct uio *uio)
{
mbuf_t *m = 0;
int len = uio->uio_resid;
MGET(m, M_WAIT, MT_DATA);
if (len > MCLBYTES) {
/* Like MCLGET(), but bigger buf. */
m->m_ext.ext_buf = kmem_zalloc(len, KM_SLEEP);
m->m_data = m->m_ext.ext_buf;
m->m_flags |= M_EXT;
m->m_ext.ext_size = len;
m->m_ext.ext_ref = smb_mbuf_kmem_ref;
} else if (len > MLEN) {
/* Use the kmem cache. */
MCLGET(m, M_WAIT);
}
m->m_len = len;
uio->uio_iov->iov_base = m->m_data;
uio->uio_iov->iov_len = m->m_len;
uio->uio_iovcnt = 1;
return (m);
}
示例3: smb_mbuf_get
/*
* smb_mbuf_get
*
* Allocate mbufs to hold the amount of data specified.
* A pointer to the head of the mbuf list is returned.
*/
struct mbuf *
smb_mbuf_get(uchar_t *buf, int nbytes)
{
struct mbuf *mhead = 0;
struct mbuf *m = 0;
int count;
int offset = 0;
while (nbytes) {
count = (nbytes > MCLBYTES) ? MCLBYTES : nbytes;
nbytes -= count;
if (mhead == 0) {
MGET(mhead, M_WAIT, MT_DATA);
m = mhead;
} else {
MGET(m->m_next, M_WAIT, MT_DATA);
m = m->m_next;
}
if (count > MLEN) {
MCLGET(m, M_WAIT);
}
m->m_len = count;
bcopy(buf + offset, m->m_data, count);
offset += count;
}
return (mhead);
}
示例4: sbcreatecontrol
/*
* Create a "control" mbuf containing the specified data
* with the specified type for presentation on a socket buffer.
*/
struct mbuf *
sbcreatecontrol(caddr_t p, int size, int type, int level)
{
struct cmsghdr *cp;
struct mbuf *m;
if (CMSG_SPACE(size) > MCLBYTES) {
printf("sbcreatecontrol: message too large %d\n", size);
return NULL;
}
if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL)
return (NULL);
if (CMSG_SPACE(size) > MLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_free(m);
return NULL;
}
}
cp = mtod(m, struct cmsghdr *);
memset(cp, 0, CMSG_SPACE(size));
memcpy(CMSG_DATA(cp), p, size);
m->m_len = CMSG_SPACE(size);
cp->cmsg_len = CMSG_LEN(size);
cp->cmsg_level = level;
cp->cmsg_type = type;
return (m);
}
示例5: receive_packet
static void receive_packet(uint8_t *buffer, int length)
{
struct ifnet *ifp = &arpcom.ac_if;
struct mbuf *m;
struct ether_header *eh;
uint32_t computed_crc, net_crc;
if(length < 64) {
printk("Warning: Ethernet packet too short\n");
return;
}
length -= 4; /* strip CRC */
net_crc = ((uint32_t)buffer[length])
| ((uint32_t)buffer[length+1] << 8)
| ((uint32_t)buffer[length+2] << 16)
| ((uint32_t)buffer[length+3] << 24);
length -= 8; /* strip preamble */
computed_crc = ether_crc32_le(&buffer[8], length) ^ 0xffffffff;
if(computed_crc == net_crc) {
MGETHDR(m, M_WAIT, MT_DATA);
MCLGET(m, M_WAIT);
length -= sizeof(struct ether_header); /* strip Ethernet header */
memcpy(m->m_data, &buffer[8+sizeof(struct ether_header)], length);
m->m_len = m->m_pkthdr.len = length;
m->m_pkthdr.rcvif = ifp;
eh = (struct ether_header *)&buffer[8];
ether_input(ifp, eh, m);
} else
printk("Ethernet CRC error: got %08x expected %08x (len=%d)\n",
net_crc, computed_crc, length);
}
示例6: bsd_setsockopt
static int bsd_setsockopt( cyg_file *fp, int level, int optname,
const void *optval, socklen_t optlen)
{
int error;
struct mbuf *m = NULL;
if( optlen > MCLBYTES )
return EINVAL;
if (optval != NULL) {
m = m_get(M_WAIT, MT_SOOPTS);
if (optlen > MLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
return (ENOBUFS);
}
}
if (m == NULL)
return (ENOBUFS);
error = copyin(optval, mtod(m, caddr_t), optlen);
if (error) {
(void) m_free(m);
return (error);
}
m->m_len = optlen;
}
return (sosetopt((struct socket *)fp->f_data, level, optname, m));
}
示例7: alloc_rx_buffers
/*
* DON'T use free_sent_buffers to drop the queue!
*/
static void
alloc_rx_buffers(struct sbsh_softc *sc)
{
unsigned cur_rbd = sc->regs->LRDR & 0x7f;
struct mbuf *m;
while (sc->tail_rq != ((sc->head_rq - 1) & (RQLEN - 1))) {
MGETHDR(m, M_NOWAIT, MT_DATA);
if (!m) {
if_printf (&sc->arpcom.ac_if,
"unable to get mbuf.\n");
return;
}
if (SBNI16_MAX_FRAME > MHLEN) {
MCLGET(m, M_NOWAIT);
if (!(m->m_flags & M_EXT)) {
m_freem(m);
if_printf (&sc->arpcom.ac_if,
"unable to get mbuf cluster.\n");
return;
}
m->m_pkthdr.len = m->m_len = MCLBYTES;
}
m_adj(m, 2); /* align ip on longword boundaries */
sc->rq[sc->tail_rq++] = m;
sc->tail_rq &= (RQLEN - 1);
sc->rbd[cur_rbd].address = vtophys(mtod(m, vm_offset_t));
sc->rbd[cur_rbd].length = 0;
sc->regs->LRDR = cur_rbd = (cur_rbd + 1) & 0x7f;
}
}
示例8: gss_get_mic
OM_uint32
gss_get_mic(OM_uint32 *minor_status,
const gss_ctx_id_t ctx,
gss_qop_t qop_req,
const gss_buffer_t message_buffer,
gss_buffer_t message_token)
{
OM_uint32 maj_stat;
struct mbuf *m, *mic;
if (!ctx) {
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
MGET(m, M_WAITOK, MT_DATA);
if (message_buffer->length > MLEN)
MCLGET(m, M_WAITOK);
m_append(m, message_buffer->length, message_buffer->value);
maj_stat = KGSS_GET_MIC(ctx, minor_status, qop_req, m, &mic);
m_freem(m);
if (maj_stat == GSS_S_COMPLETE) {
message_token->length = m_length(mic, NULL);
message_token->value = malloc(message_token->length,
M_GSSAPI, M_WAITOK);
m_copydata(mic, 0, message_token->length,
message_token->value);
m_freem(mic);
}
return (maj_stat);
}
示例9: mcf548x_fec_rx_bd_init
/*
* Function: mcf548x_fec_rx_bd_init
*
* Description: Initialize the receive buffer descriptor ring.
*
* Returns: void
*
* Notes: Space for the buffers of rx BDs is allocated by the rx deamon
*
*/
static void mcf548x_fec_rx_bd_init(struct mcf548x_enet_struct *sc) {
int rxBdIndex;
struct mbuf *m;
struct ifnet *ifp = &sc->arpcom.ac_if;
/*
* Fill RX buffer descriptor ring.
*/
for( rxBdIndex = 0; rxBdIndex < sc->rxBdCount; rxBdIndex++ ) {
MGETHDR (m, M_WAIT, MT_DATA);
MCLGET (m, M_WAIT);
m->m_pkthdr.rcvif = ifp;
sc->rxMbuf[rxBdIndex] = m;
rtems_cache_invalidate_multiple_data_lines(mtod(m,const void *),
ETHER_MAX_LEN);
SET_BD_BUFFER(sc->rxBd+rxBdIndex,mtod(m, void *));
SET_BD_LENGTH(sc->rxBd+rxBdIndex,ETHER_MAX_LEN);
SET_BD_STATUS(sc->rxBd+rxBdIndex,
MCF548X_FEC_RBD_EMPTY
| MCF548X_FEC_RBD_INT
| ((rxBdIndex == sc->rxBdCount-1)
? MCF548X_FEC_RBD_WRAP
: 0));
}
}
示例10: repack
static struct mbuf *
repack(struct sbsh_softc *sc, struct mbuf *m)
{
struct mbuf *m_new;
MGETHDR(m_new, M_NOWAIT, MT_DATA);
if (!m_new) {
if_printf (&sc->arpcom.ac_if,
"unable to get mbuf.\n");
return (NULL);
}
if (m->m_pkthdr.len > MHLEN) {
MCLGET(m_new, M_NOWAIT);
if (!(m_new->m_flags & M_EXT)) {
m_freem(m_new);
if_printf (&sc->arpcom.ac_if,
"unable to get mbuf cluster.\n");
return (NULL);
}
}
m_copydata(m, 0, m->m_pkthdr.len, mtod(m_new, caddr_t));
m_new->m_pkthdr.len = m_new->m_len = m->m_pkthdr.len;
m_freem(m);
return (m_new);
}
示例11: nfs_rephead
/*
* Generate the rpc reply header
* siz arg. is used to decide if adding a cluster is worthwhile
*/
struct mbuf *
nfs_rephead(int siz, struct nfsrv_descript *nd, int err,
struct mbuf **mbp, caddr_t *bposp)
{
u_int32_t *tl;
struct mbuf *mreq;
caddr_t bpos;
struct mbuf *mb;
if (err == EBADRPC)
return (NULL);
nd->nd_repstat = err;
if (err && (nd->nd_flag & ND_NFSV3) == 0) /* XXX recheck */
siz = 0;
MGET(mreq, M_WAITOK, MT_DATA);
/*
* If this is a big reply, use a cluster
*/
mreq->m_len = 0;
if (siz >= MINCLSIZE) {
MCLGET(mreq, M_WAITOK);
}
mb = mreq;
bpos = mtod(mb, caddr_t);
if (err != NFSERR_RETVOID) {
tl = nfsm_build(u_int32_t *, NFSX_UNSIGNED);
if (err)
*tl = txdr_unsigned(nfsrv_errmap(nd, err));
else
*tl = 0;
}
示例12: Ecos_MemPool_Alloc
unsigned char* Ecos_MemPool_Alloc (
unsigned long Length,
int Type)
{
struct mbuf *pMBuf = NULL;
switch (Type)
{
case MemPool_TYPE_Header:
MGETHDR(pMBuf, M_DONTWAIT, MT_DATA);
break;
case MemPool_TYPE_CLUSTER:
MGETHDR(pMBuf, M_DONTWAIT, MT_DATA);
if (pMBuf== NULL)
return NULL;
MCLGET(pMBuf, M_DONTWAIT);
if ((pMBuf->m_flags & M_EXT) == 0)
{
m_freem(pMBuf);
return NULL;
}
break;
default:
DBGPRINT(RT_DEBUG_ERROR, ("%s: Unknown Type %d\n", __FUNCTION__, Type));
break;
}
return pMBuf;
}
示例13: bce_add_rxbuf
/* Add a receive buffer to the indiciated descriptor. */
int
bce_add_rxbuf(struct bce_softc *sc, int idx)
{
struct mbuf *m;
int error;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
return (ENOBUFS);
}
if (sc->bce_cdata.bce_rx_chain[idx] != NULL)
bus_dmamap_unload(sc->bce_dmatag,
sc->bce_cdata.bce_rx_map[idx]);
sc->bce_cdata.bce_rx_chain[idx] = m;
error = bus_dmamap_load(sc->bce_dmatag, sc->bce_cdata.bce_rx_map[idx],
m->m_ext.ext_buf, m->m_ext.ext_size, NULL,
BUS_DMA_READ | BUS_DMA_NOWAIT);
if (error)
return (error);
bus_dmamap_sync(sc->bce_dmatag, sc->bce_cdata.bce_rx_map[idx], 0,
sc->bce_cdata.bce_rx_map[idx]->dm_mapsize, BUS_DMASYNC_PREREAD);
BCE_INIT_RXDESC(sc, idx);
return (0);
}
示例14: ni_add_rxbuf
/*
* Add a receive buffer to the indicated descriptor.
*/
int
ni_add_rxbuf(struct ni_softc *sc, struct ni_dg *data, int idx)
{
struct ni_bbd *bd = &bbd[idx];
struct mbuf *m;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
return (ENOBUFS);
}
m->m_data += 2;
bd->nb_len = (m->m_ext.ext_size - 2);
bd->nb_pte = (long)kvtopte(m->m_ext.ext_buf);
bd->nb_status = 2 | NIBD_VALID;
bd->nb_key = 1;
data->bufs[0]._offset = 0;
data->bufs[0]._len = bd->nb_len;
data->bufs[0]._index = idx;
data->nd_cmdref = (long)m;
return (0);
}
示例15: m_pullup2
/*
* m_pullup2() works like m_pullup, save that len can be <= MCLBYTES.
* m_pullup2() only works on values of len such that MHLEN < len <= MCLBYTES,
* it calls m_pullup() for values <= MHLEN. It also only coagulates the
* reqested number of bytes. (For those of us who expect unwieldly option
* headers.
*
* KEBE SAYS: Remember that dtom() calls with data in clusters does not work!
*/
struct mbuf *
m_pullup2(struct mbuf *n, int len)
{
struct mbuf *m;
int count;
if (len <= MHLEN)
return m_pullup(n, len);
if ((n->m_flags & M_EXT) != 0 &&
n->m_data + len < &n->m_data[MCLBYTES] && n->m_next) {
if (n->m_len >= len)
return (n);
m = n;
n = n->m_next;
len -= m->m_len;
} else {
if (len > MCLBYTES)
goto bad;
MGET(m, M_DONTWAIT, n->m_type);
if (m == NULL)
goto bad;
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0)
goto bad;
m->m_len = 0;
if (n->m_flags & M_PKTHDR) {
/* Too many adverse side effects. */
/* M_MOVE_PKTHDR(m, n); */
m->m_flags = (n->m_flags & M_COPYFLAGS) |
M_EXT | M_CLUSTER;
M_MOVE_HDR(m, n);
/* n->m_data is cool. */
}
}
do {
count = min(len, n->m_len);
bcopy(mtod(n, caddr_t), mtod(m, caddr_t) + m->m_len,
(unsigned)count);
len -= count;
m->m_len += count;
n->m_len -= count;
if (n->m_len)
n->m_data += count;
else
n = m_free(n);
} while (len > 0 && n);
if (len > 0) {
(void)m_free(m);
goto bad;
}
m->m_next = n;
return (m);
bad:
m_freem(n);
MPFail++;
return (NULL);
}