Lines Matching refs:dev
102 struct device dev; /* What struct physical knows about */
122 struct etherdevice *dev = device2ether(p->handler);
124 return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : (ssize_t)n;
138 struct etherdevice *dev = device2ether(p->handler);
141 if (r && dev->cs >= 0 && FD_ISSET(dev->cs, r)) {
142 FD_CLR(dev->cs, r);
143 log_Printf(LogTIMER, "%s: fdunset(ctrl) %d\n", p->link.name, dev->cs);
160 struct etherdevice *dev = device2ether(p->handler);
163 if (dev->cs != -1)
164 close(dev->cs);
165 free(dev);
171 struct etherdevice *dev = device2ether(p->handler);
173 switch (dev->connected) {
186 struct etherdevice *dev = device2ether(p->handler);
188 return dev->slot;
196 struct etherdevice *dev;
207 dev = device2ether(d);
208 if (dev->cs >= 0) {
209 *auxfd = dev->cs;
215 ether_MessageIn(struct etherdevice *dev)
227 if (dev->cs < 0)
237 FD_SET(dev->cs, r);
239 ret = select(dev->cs + 1, r, NULL, NULL, &t);
244 if (NgRecvMsg(dev->cs, rep, sizeof msgbuf, NULL) <= 0)
284 dev->slot = slot;
300 dev->connected = CARRIER_OK;
304 dev->connected = CARRIER_LOST;
314 struct etherdevice *dev = device2ether(p->handler);
316 if (dev->connected != CARRIER_OK && !dev->timeout--)
317 dev->connected = CARRIER_LOST;
318 else if (dev->connected == CARRIER_PENDING)
319 ether_MessageIn(dev);
321 return dev->connected;
350 struct etherdevice *dev = (struct etherdevice *)iov[(*niov)++].iov_base;
352 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */
353 if (dev == NULL) {
355 (int)(sizeof *dev));
360 dev->cs = *auxfd;
363 dev->cs = -1;
366 memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
368 physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
369 return &dev->dev;
379 struct etherdevice *dev = device2ether(p->handler);
382 if (r && dev->cs >= 0) {
383 FD_SET(dev->cs, r);
384 log_Printf(LogTIMER, "%s(ctrl): fdset(r) %d\n", p->link.name, dev->cs);
398 struct etherdevice *dev = device2ether(p->handler);
401 result = dev->cs >= 0 && FD_ISSET(dev->cs, fdset);
412 struct etherdevice *dev = device2ether(p->handler);
414 if (dev->cs >= 0 && FD_ISSET(dev->cs, fdset)) {
415 ether_MessageIn(dev);
416 if (dev->connected == CARRIER_LOST) {
428 ether_Abandon(struct etherdevice *dev, struct physical *p)
431 close(dev->cs);
434 free(dev);
443 struct etherdevice *dev;
452 dev = NULL;
465 char connectpath[sizeof dev->hook + 2]; /* .:<hook> */
472 if ((dev = malloc(sizeof *dev)) == NULL)
493 * | <iface> | dev->cs
510 if (ID0NgMkSockNode(NULL, &dev->cs, &p->fd) == -1) {
513 free(dev);
524 if (NgSendMsg(dev->cs, path, NGM_GENERIC_COOKIE, NGM_LISTHOOKS,
528 return ether_Abandon(dev, p);
533 if (NgRecvMsg(dev->cs, resp, sizeof rbuf, NULL) <= 0) {
536 return ether_Abandon(dev, p);
547 return ether_Abandon(dev, p);
573 return ether_Abandon(dev, p);
592 if (NgSendMsg(dev->cs, etherid, NGM_GENERIC_COOKIE,
596 return ether_Abandon(dev, p);
602 snprintf(dev->hook, sizeof dev->hook, "%s%d",
609 snprintf(ngc.ourhook, sizeof ngc.ourhook, "%s", dev->hook);
614 if (NgSendMsg(dev->cs, ".:", NGM_GENERIC_COOKIE,
618 return ether_Abandon(dev, p);
627 snprintf(connectpath, sizeof connectpath, ".:%s", dev->hook);
632 if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE,
636 return ether_Abandon(dev, p);
643 snprintf(data->hook, sizeof data->hook, "%s", dev->hook);
648 if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE,
652 return ether_Abandon(dev, p);
655 /* Hook things up so that we monitor dev->cs */
660 memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
663 dev->dev.cd.delay = p->cfg.cd.delay;
666 dev->dev.cd = p->cfg.cd;
670 p->link.name, dev->dev.cd.delay);
675 dev->timeout = dev->dev.cd.delay;
676 dev->connected = CARRIER_PENDING;
678 dev->slot = GetIfIndex(path);
703 if ((dev = malloc(sizeof *dev)) == NULL) {
709 memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
710 dev->cs = -1;
711 dev->timeout = 0;
712 dev->connected = CARRIER_OK;
713 *dev->hook = '\0';
724 dev->slot = end != sessionid && *end == '\0' ? slot : 0;
726 dev->slot = 0;
731 if (dev) {
732 physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
733 return &dev->dev;