int physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov, int *auxfd, int *nauxfd) { struct device *h; int sz; h = NULL; if (p) { hdlc_StopTimer(&p->hdlc); lqr_StopTimer(p); timer_Stop(&p->link.lcp.fsm.FsmTimer); timer_Stop(&p->link.ccp.fsm.FsmTimer); timer_Stop(&p->link.lcp.fsm.OpenTimer); timer_Stop(&p->link.ccp.fsm.OpenTimer); timer_Stop(&p->link.lcp.fsm.StoppedTimer); timer_Stop(&p->link.ccp.fsm.StoppedTimer); if (p->handler) { h = p->handler; p->handler = (struct device *)(long)p->handler->type; } if (Enabled(p->dl->bundle, OPT_KEEPSESSION) || tcgetpgrp(p->fd) == getpgrp()) p->session_owner = getpid(); /* So I'll eventually get HUP'd */ else p->session_owner = (pid_t)-1; timer_Stop(&p->link.stats.total.Timer); } if (*niov + 2 >= maxiov) { log_Printf(LogERROR, "physical2iov: No room for physical + throughput" " + device !\n"); if (p) free(p); return -1; } iov[*niov].iov_base = (void *)p; iov[*niov].iov_len = sizeof *p; (*niov)++; iov[*niov].iov_base = p ? (void *)p->link.stats.total.in.SampleOctets : NULL; iov[*niov].iov_len = SAMPLE_PERIOD * sizeof(long long); (*niov)++; iov[*niov].iov_base = p ? (void *)p->link.stats.total.out.SampleOctets : NULL; iov[*niov].iov_len = SAMPLE_PERIOD * sizeof(long long); (*niov)++; sz = physical_MaxDeviceSize(); if (p) { if (h && h->device2iov) (*h->device2iov)(h, iov, niov, maxiov, auxfd, nauxfd); else { if ((iov[*niov].iov_base = malloc(sz)) == NULL) { log_Printf(LogALERT, "physical2iov: Out of memory (%d bytes)\n", sz); AbortProgram(EX_OSERR); } if (h) memcpy(iov[*niov].iov_base, h, sizeof *h); iov[*niov].iov_len = sz; (*niov)++; } } else { iov[*niov].iov_base = NULL; iov[*niov].iov_len = sz; (*niov)++; } return p ? p->fd : 0; }
return ret; } static void atm_Free(struct physical *p) { struct atmdevice *dev = device2atm(p->handler); free(dev); } static void atm_device2iov(struct device *d, struct iovec *iov, int *niov, int maxiov __unused, int *auxfd __unused, int *nauxfd __unused) { int sz = physical_MaxDeviceSize(); iov[*niov].iov_base = realloc(d, sz); if (iov[*niov].iov_base == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; } static const struct device baseatmdevice = { ATM_DEVICE, "atm", 0, { CD_NOTREQUIRED, 0 },