本文整理汇总了C++中NETTYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ NETTYPE函数的具体用法?C++ NETTYPE怎么用?C++ NETTYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NETTYPE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pipetapfd
static int pipetapfd(struct chan *chan, struct fd_tap *tap, int cmd)
{
int ret;
Pipe *p;
int which = 1;
uint64_t kludge;
p = chan->aux;
kludge = (uint64_t)p;
#define DEVPIPE_LEGAL_DATA_TAPS (FDTAP_FILT_READABLE | FDTAP_FILT_WRITABLE | \
FDTAP_FILT_HANGUP | FDTAP_FILT_ERROR)
switch (NETTYPE(chan->qid.path)) {
case Qdata0:
which = 0;
/* fall through */
case Qdata1:
kludge |= which;
if (tap->filter & ~DEVPIPE_LEGAL_DATA_TAPS) {
set_errno(ENOSYS);
set_errstr("Unsupported #%s data tap %p, must be %p", devname(),
tap->filter, DEVPIPE_LEGAL_DATA_TAPS);
return -1;
}
spin_lock(&p->tap_lock);
switch (cmd) {
case (FDTAP_CMD_ADD):
if (SLIST_EMPTY(&p->data_taps[which]))
qio_set_wake_cb(p->q[which], pipe_wake_cb, (void *)kludge);
SLIST_INSERT_HEAD(&p->data_taps[which], tap, link);
ret = 0;
break;
case (FDTAP_CMD_REM):
SLIST_REMOVE(&p->data_taps[which], tap, fd_tap, link);
if (SLIST_EMPTY(&p->data_taps[which]))
qio_set_wake_cb(p->q[which], 0, (void *)kludge);
ret = 0;
break;
default:
set_errno(ENOSYS);
set_errstr("Unsupported #%s data tap command %p", devname(), cmd);
ret = -1;
}
spin_unlock(&p->tap_lock);
return ret;
default:
set_errno(ENOSYS);
set_errstr("Can't tap #%s file type %d", devname(),
NETTYPE(chan->qid.path));
return -1;
}
}
开发者ID:GanShun,项目名称:akaros,代码行数:53,代码来源:pipe.c
示例2: netifread
long
netifread(struct netif *nif, struct chan *c, void *a, long n, uint32_t offset)
{
int i, j;
struct netfile *f;
char *p;
if (c->qid.type & QTDIR)
return devdirread(c, a, n, (struct dirtab *)nif, 0, netifgen);
switch (NETTYPE(c->qid.path)) {
case Ndataqid:
f = nif->f[NETID(c->qid.path)];
return qread(f->in, a, n);
case Nctlqid:
return readnum(offset, a, n, NETID(c->qid.path), NUMSIZE);
case Nstatqid:
p = kzmalloc(READSTR, 0);
if (p == NULL)
return 0;
j = snprintf(p, READSTR, "in: %d\n", nif->inpackets);
j += snprintf(p + j, READSTR - j, "link: %d\n", nif->link);
j += snprintf(p + j, READSTR - j, "out: %d\n", nif->outpackets);
j += snprintf(p + j, READSTR - j, "crc errs: %d\n", nif->crcs);
j += snprintf(p + j, READSTR - j, "overflows: %d\n",
nif->overflows);
j += snprintf(p + j, READSTR - j, "soft overflows: %d\n",
nif->soverflows);
j += snprintf(p + j, READSTR - j, "framing errs: %d\n",
nif->frames);
j += snprintf(p + j, READSTR - j, "buffer errs: %d\n", nif->buffs);
j += snprintf(p + j, READSTR - j, "output errs: %d\n", nif->oerrs);
j += snprintf(p + j, READSTR - j, "prom: %d\n", nif->prom);
j += snprintf(p + j, READSTR - j, "mbps: %d\n", nif->mbps);
j += snprintf(p + j, READSTR - j, "addr: ");
for (i = 0; i < nif->alen; i++)
j += snprintf(p + j, READSTR - j, "%02.2x", nif->addr[i]);
snprintf(p + j, READSTR - j, "\n");
n = readstr(offset, a, n, p);
kfree(p);
return n;
case Naddrqid:
p = kzmalloc(READSTR, 0);
if (p == NULL)
return 0;
j = 0;
for (i = 0; i < nif->alen; i++)
j += snprintf(p + j, READSTR - j, "%02.2x", nif->addr[i]);
n = readstr(offset, a, n, p);
kfree(p);
return n;
case Ntypeqid:
f = nif->f[NETID(c->qid.path)];
return readnum(offset, a, n, f->type, NUMSIZE);
case Nifstatqid:
return 0;
}
error(Ebadarg);
return -1; /* not reached */
}
开发者ID:alfongj,项目名称:akaros,代码行数:60,代码来源:netif.c
示例3: pipebwrite
static long pipebwrite(struct chan *c, struct block *bp, uint32_t junk)
{
long n;
Pipe *p;
//Prog *r;
p = c->aux;
switch (NETTYPE(c->qid.path)) {
case Qdata0:
if (c->flag & O_NONBLOCK)
n = qbwrite_nonblock(p->q[1], bp);
else
n = qbwrite(p->q[1], bp);
break;
case Qdata1:
if (c->flag & O_NONBLOCK)
n = qbwrite_nonblock(p->q[0], bp);
else
n = qbwrite(p->q[0], bp);
break;
default:
n = 0;
panic("pipebwrite");
}
return n;
}
开发者ID:GanShun,项目名称:akaros,代码行数:29,代码来源:pipe.c
示例4: piperead
static long piperead(struct chan *c, void *va, long n, int64_t ignored)
{
Pipe *p;
p = c->aux;
switch (NETTYPE(c->qid.path)) {
case Qdir:
return devdirread(c, va, n, p->pipedir, ARRAY_SIZE(pipedir),
pipegen);
case Qdata0:
if (c->flag & O_NONBLOCK)
return qread_nonblock(p->q[0], va, n);
else
return qread(p->q[0], va, n);
case Qdata1:
if (c->flag & O_NONBLOCK)
return qread_nonblock(p->q[1], va, n);
else
return qread(p->q[1], va, n);
default:
panic("piperead");
}
return -1; /* not reached */
}
开发者ID:GanShun,项目名称:akaros,代码行数:25,代码来源:pipe.c
示例5: pipewrite
/*
* A write to a closed pipe causes an EPIPE error to be thrown.
*/
static long pipewrite(struct chan *c, void *va, long n, int64_t ignored)
{
Pipe *p;
//Prog *r;
p = c->aux;
switch (NETTYPE(c->qid.path)) {
case Qdata0:
if (c->flag & O_NONBLOCK)
n = qwrite_nonblock(p->q[1], va, n);
else
n = qwrite(p->q[1], va, n);
break;
case Qdata1:
if (c->flag & O_NONBLOCK)
n = qwrite_nonblock(p->q[0], va, n);
else
n = qwrite(p->q[0], va, n);
break;
default:
panic("pipewrite");
}
return n;
}
开发者ID:GanShun,项目名称:akaros,代码行数:31,代码来源:pipe.c
示例6: devwalk
static struct walkqid *pipewalk(struct chan *c, struct chan *nc, char **name,
int nname)
{
struct walkqid *wq;
Pipe *p;
p = c->aux;
wq = devwalk(c, nc, name, nname, p->pipedir, ARRAY_SIZE(pipedir), pipegen);
if (wq != NULL && wq->clone != NULL && wq->clone != c) {
qlock(&p->qlock);
kref_get(&p->ref, 1);
if (c->flag & COPEN) {
switch (NETTYPE(c->qid.path)) {
case Qdata0:
p->qref[0]++;
break;
case Qdata1:
p->qref[1]++;
break;
}
}
qunlock(&p->qlock);
}
return wq;
}
开发者ID:GanShun,项目名称:akaros,代码行数:25,代码来源:pipe.c
示例7: pipestat
static int pipestat(struct chan *c, uint8_t * db, int n)
{
Pipe *p;
struct dir dir;
struct dirtab *tab;
int perm;
p = c->aux;
tab = p->pipedir;
switch (NETTYPE(c->qid.path)) {
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR | 0555, &dir);
break;
case Qdata0:
perm = tab[1].perm;
perm |= qreadable(p->q[0]) ? DMREADABLE : 0;
perm |= qwritable(p->q[0]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[1].name, qlen(p->q[0]), eve, perm, &dir);
break;
case Qdata1:
perm = tab[2].perm;
perm |= qreadable(p->q[1]) ? DMREADABLE : 0;
perm |= qwritable(p->q[1]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[2].name, qlen(p->q[1]), eve, perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if (n < BIT16SZ)
error(ENODATA, ERROR_FIXME);
return n;
}
开发者ID:GanShun,项目名称:akaros,代码行数:34,代码来源:pipe.c
示例8: uartstat
static int
uartstat(Chan *c, uchar *dp, int n)
{
if(NETTYPE(c->qid.path) == Ndataqid)
setlength(NETID(c->qid.path));
return devstat(c, dp, n, uartdir, ndir, devgen);
}
开发者ID:8l,项目名称:inferno,代码行数:7,代码来源:devuart.c
示例9: uartwrite
static long
uartwrite(Chan *c, void *buf, long n, vlong offset)
{
Uart *p;
char cmd[32];
USED(offset);
if(c->qid.type & QTDIR)
error(Eperm);
p = uart[NETID(c->qid.path)];
switch(NETTYPE(c->qid.path)){
case Ndataqid:
return qwrite(p->oq, buf, n);
case Nctlqid:
if(n >= sizeof(cmd))
n = sizeof(cmd)-1;
memmove(cmd, buf, n);
cmd[n] = 0;
uartctl(p, cmd);
return n;
}
}
开发者ID:8l,项目名称:inferno,代码行数:26,代码来源:devuart.c
示例10: netifbread
Block*
netifbread(Netif *nif, Chan *c, long n, vlong offset)
{
Netfile *f;
Block *bp;
if((c->qid.type & QTDIR) || NETTYPE(c->qid.path) != Ndataqid)
return devbread(c, n, offset);
f = nif->f[NETID(c->qid.path)];
if(f->fat){
/*
* Frame at a time (fat) allows us to provide
* non-blocking performance with blocking semantics
* for consumers that know ahead of time data is
* contained within a single frame. Once empty, we
* get in line with other blocking reads and wait our
* turn.
*/
for(;;){
if(bp = qget(f->iq))
return bp;
if(waserror())
return nil;
qsleep(f->iq);
poperror();
}
}
return qbread(f->iq, n);
}
开发者ID:0intro,项目名称:enhanced-plan9,代码行数:30,代码来源:netif.c
示例11: eiawrite
static long
eiawrite(Chan *c, void *buf, long n, vlong offset)
{
ssize_t cnt;
char cmd[Maxctl];
int port = NETID(c->qid.path);
USED(offset);
if(c->qid.type & QTDIR)
error(Eperm);
switch(NETTYPE(c->qid.path)) {
case Ndataqid:
osenter();
cnt = write(eia[port].fd, buf, n);
osleave();
if(cnt == -1)
oserror();
return cnt;
case Nctlqid:
if(n >= (long)sizeof(cmd))
n = sizeof(cmd)-1;
memmove(cmd, buf, n);
cmd[n] = 0;
wrctl(port, cmd);
return n;
}
return 0;
}
开发者ID:8l,项目名称:inferno,代码行数:30,代码来源:deveia-posix.c
示例12: eiaread
static long
eiaread(Chan *c, void *buf, long n, vlong offset)
{
ssize_t cnt;
int port = NETID(c->qid.path);
if(c->qid.type & QTDIR)
return devdirread(c, buf, n, eiadir, ndir, devgen);
switch(NETTYPE(c->qid.path)) {
case Ndataqid:
osenter();
cnt = read(eia[port].fd, buf, n);
osleave();
if(cnt == -1)
oserror();
return cnt;
case Nctlqid:
return readnum(offset, buf, n, port, NUMSIZE);
case Nstatqid:
return rdstat(port, buf, n, offset);
}
return 0;
}
开发者ID:8l,项目名称:inferno,代码行数:25,代码来源:deveia-posix.c
示例13: pipewstat
static int pipewstat(struct chan *c, uint8_t *dp, int n)
{
ERRSTACK(2);
struct dir *d;
Pipe *p;
int d1;
if (c->qid.type & QTDIR)
error(EPERM, ERROR_FIXME);
p = c->aux;
if (strcmp(current->user, p->user) != 0)
error(EPERM, ERROR_FIXME);
d = kzmalloc(sizeof(*d) + n, 0);
if (waserror()) {
kfree(d);
nexterror();
}
n = convM2D(dp, n, d, (char *)&d[1]);
if (n == 0)
error(ENODATA, ERROR_FIXME);
d1 = NETTYPE(c->qid.path) == Qdata1;
if (!emptystr(d->name)) {
validwstatname(d->name);
if (strlen(d->name) >= KNAMELEN)
error(ENAMETOOLONG, ERROR_FIXME);
if (strncmp(p->pipedir[1 + !d1].name, d->name, KNAMELEN) == 0)
error(EEXIST, ERROR_FIXME);
strncpy(p->pipedir[1 + d1].name, d->name, KNAMELEN);
}
if (d->mode != ~0UL)
p->pipedir[d1 + 1].perm = d->mode & 0777;
poperror();
kfree(d);
return n;
}
开发者ID:GanShun,项目名称:akaros,代码行数:35,代码来源:pipe.c
示例14: eiaread
static long
eiaread(Chan *c, void *buf, long n, vlong offset)
{
DWORD cnt;
int port = NETID(c->qid.path);
BOOL good;
if(c->qid.type & QTDIR)
return devdirread(c, buf, n, eiadir, ndir, devgen);
switch(NETTYPE(c->qid.path)) {
case Ndataqid:
cnt = 0;
// if ReadFile timeouts and cnt==0 then just re-read
// this will give osleave() a chance to detect an
// interruption (i.e. killprog)
while(cnt==0) {
osenter();
good = ReadFile(eia[port].comfh, buf, n, &cnt, NULL);
SleepEx(0,FALSE); //allow another thread access to port
osleave();
if(!good)
oserror();
}
return cnt;
case Nctlqid:
return readnum(offset, buf, n, eia[port].id, NUMSIZE);
case Nstatqid:
return rdstat(port, buf, n, offset);
}
return 0;
}
开发者ID:BGCX261,项目名称:znos-git,代码行数:33,代码来源:deveia.c
示例15: pipegen
static int
pipegen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
int id, len;
Qid qid;
Pipe *p;
USED(name);
if(i == DEVDOTDOT){
devdir(c, c->qid, "#|", 0, eve, 0555, dp);
return 1;
}
i++; /* skip . */
if(tab==0 || i>=ntab)
return -1;
tab += i;
p = c->aux;
switch(NETTYPE(tab->qid.path)){
case Qdata0:
len = qlen(p->q[0]);
break;
case Qdata1:
len = qlen(p->q[1]);
break;
default:
len = tab->length;
break;
}
id = NETID(c->qid.path);
qid.path = NETQID(id, tab->qid.path);
qid.vers = 0;
qid.type = QTFILE;
devdir(c, qid, tab->name, len, eve, tab->perm, dp);
return 1;
}
开发者ID:AndreasBriese,项目名称:node9,代码行数:35,代码来源:devpipe.c
示例16: pipebwrite
static long
pipebwrite(Chan *c, Block *bp, ulong)
{
long n;
Pipe *p;
if(waserror()) {
/* avoid notes when pipe is a mounted queue */
if((c->flag & CMSG) == 0)
postnote(up, 1, "sys: write on closed pipe", NUser);
nexterror();
}
p = c->aux;
switch(NETTYPE(c->qid.path)){
case Qdata0:
n = qbwrite(p->q[1], bp);
break;
case Qdata1:
n = qbwrite(p->q[0], bp);
break;
default:
n = 0;
panic("pipebwrite");
}
poperror();
return n;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:31,代码来源:devpipe.c
示例17: pipeopen
/*
* if the stream doesn't exist, create it
*/
static Chan*
pipeopen(Chan *c, int omode)
{
Pipe *p;
if(c->qid.type & QTDIR){
if(omode != OREAD)
error(Ebadarg);
c->mode = omode;
c->flag |= COPEN;
c->offset = 0;
return c;
}
p = c->aux;
qlock(p);
switch(NETTYPE(c->qid.path)){
case Qdata0:
p->qref[0]++;
break;
case Qdata1:
p->qref[1]++;
break;
}
qunlock(p);
c->mode = openmode(omode);
c->flag |= COPEN;
c->offset = 0;
c->iounit = qiomaxatomic;
return c;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:35,代码来源:devpipe.c
示例18: pipewrite
/*
* a write to a closed pipe causes a note to be sent to
* the process.
*/
static long
pipewrite(Chan *c, void *va, long n, vlong)
{
Pipe *p;
if(!islo())
print("pipewrite hi %#p\n", getcallerpc(&c));
if(waserror()) {
/* avoid notes when pipe is a mounted queue */
if((c->flag & CMSG) == 0)
postnote(up, 1, "sys: write on closed pipe", NUser);
nexterror();
}
p = c->aux;
switch(NETTYPE(c->qid.path)){
case Qdata0:
n = qwrite(p->q[1], va, n);
break;
case Qdata1:
n = qwrite(p->q[0], va, n);
break;
default:
panic("pipewrite");
}
poperror();
return n;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:36,代码来源:devpipe.c
示例19: pipestat
static int
pipestat(Chan *c, uchar *db, int n)
{
Pipe *p;
Dir dir;
p = c->aux;
switch(NETTYPE(c->qid.path)){
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR|0555, &dir);
break;
case Qdata0:
devdir(c, c->qid, "data", qlen(p->q[0]), eve, p->perm, &dir);
break;
case Qdata1:
devdir(c, c->qid, "data1", qlen(p->q[1]), eve, p->perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if(n < BIT16SZ)
error(Eshortstat);
return n;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:26,代码来源:devpipe.c
示例20: pipewstat
static int
pipewstat(Chan* c, uchar* db, int n)
{
int m;
Dir *dir;
Pipe *p;
p = c->aux;
if(strcmp(up->user, eve) != 0)
error(Eperm);
if(NETTYPE(c->qid.path) == Qdir)
error(Eisdir);
dir = smalloc(sizeof(Dir)+n);
if(waserror()){
free(dir);
nexterror();
}
m = convM2D(db, n, &dir[0], (char*)&dir[1]);
if(m == 0)
error(Eshortstat);
if(!emptystr(dir[0].uid))
error("can't change owner");
if(dir[0].mode != ~0UL)
p->perm = dir[0].mode;
poperror();
free(dir);
return m;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:29,代码来源:devpipe.c
注:本文中的NETTYPE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论