• Home
  • Raw
  • Download

Lines Matching refs:p

166 physical_SetDescriptor(struct physical *p)  in physical_SetDescriptor()  argument
168 p->desc.type = PHYSICAL_DESCRIPTOR; in physical_SetDescriptor()
169 p->desc.UpdateSet = physical_UpdateSet; in physical_SetDescriptor()
170 p->desc.IsSet = physical_IsSet; in physical_SetDescriptor()
171 p->desc.Read = physical_DescriptorRead; in physical_SetDescriptor()
172 p->desc.Write = physical_DescriptorWrite; in physical_SetDescriptor()
178 struct physical *p; in physical_Create() local
180 p = (struct physical *)malloc(sizeof(struct physical)); in physical_Create()
181 if (!p) in physical_Create()
184 p->link.type = PHYSICAL_LINK; in physical_Create()
185 p->link.name = dl->name; in physical_Create()
186 p->link.len = sizeof *p; in physical_Create()
189 throughput_init(&p->link.stats.total, SAMPLE_PERIOD); in physical_Create()
190 p->link.stats.parent = dl->bundle->ncp.mp.active ? in physical_Create()
192 p->link.stats.gather = 1; in physical_Create()
194 memset(p->link.Queue, '\0', sizeof p->link.Queue); in physical_Create()
195 memset(p->link.proto_in, '\0', sizeof p->link.proto_in); in physical_Create()
196 memset(p->link.proto_out, '\0', sizeof p->link.proto_out); in physical_Create()
197 link_EmptyStack(&p->link); in physical_Create()
199 p->handler = NULL; in physical_Create()
200 physical_SetDescriptor(p); in physical_Create()
201 p->type = type; in physical_Create()
203 hdlc_Init(&p->hdlc, &p->link.lcp); in physical_Create()
204 async_Init(&p->async); in physical_Create()
206 p->fd = -1; in physical_Create()
207 p->out = NULL; in physical_Create()
208 p->connect_count = 0; in physical_Create()
209 p->dl = dl; in physical_Create()
210 p->input.sz = 0; in physical_Create()
211 *p->name.full = '\0'; in physical_Create()
212 p->name.base = p->name.full; in physical_Create()
214 p->Utmp = 0; in physical_Create()
215 p->session_owner = (pid_t)-1; in physical_Create()
217 p->cfg.rts_cts = MODEM_CTSRTS; in physical_Create()
218 p->cfg.speed = MODEM_SPEED; in physical_Create()
219 p->cfg.parity = CS8; in physical_Create()
220 memcpy(p->cfg.devlist, MODEM_LIST, sizeof MODEM_LIST); in physical_Create()
221 p->cfg.ndev = NMODEMS; in physical_Create()
222 p->cfg.cd.necessity = CD_DEFAULT; in physical_Create()
223 p->cfg.cd.delay = 0; /* reconfigured or device specific default */ in physical_Create()
225 lcp_Init(&p->link.lcp, dl->bundle, &p->link, &dl->fsmp); in physical_Create()
226 ccp_Init(&p->link.ccp, dl->bundle, &p->link, &dl->fsmp); in physical_Create()
228 return p; in physical_Create()
257 physical_SetParity(struct physical *p, const char *str) in physical_SetParity() argument
264 p->cfg.parity = val; in physical_SetParity()
265 if (p->fd >= 0) { in physical_SetParity()
266 tcgetattr(p->fd, &rstio); in physical_SetParity()
269 tcsetattr(p->fd, TCSADRAIN, &rstio); in physical_SetParity()
273 log_Printf(LogWARN, "%s: %s: Invalid parity\n", p->link.name, str); in physical_SetParity()
278 physical_GetSpeed(struct physical *p) in physical_GetSpeed() argument
280 if (p->handler && p->handler->speed) in physical_GetSpeed()
281 return (*p->handler->speed)(p); in physical_GetSpeed()
287 physical_SetSpeed(struct physical *p, unsigned speed) in physical_SetSpeed() argument
290 p->cfg.speed = speed; in physical_SetSpeed()
298 physical_Raw(struct physical *p) in physical_Raw() argument
300 if (p->handler && p->handler->raw) in physical_Raw()
301 return (*p->handler->raw)(p); in physical_Raw()
307 physical_Offline(struct physical *p) in physical_Offline() argument
309 if (p->handler && p->handler->offline) in physical_Offline()
310 (*p->handler->offline)(p); in physical_Offline()
311 log_Printf(LogPHASE, "%s: Disconnected!\n", p->link.name); in physical_Offline()
315 physical_Lock(struct physical *p) in physical_Lock() argument
319 if (*p->name.full == '/' && p->type != PHYS_DIRECT && in physical_Lock()
320 (res = ID0uu_lock(p->name.base)) != UU_LOCK_OK) { in physical_Lock()
322 log_Printf(LogPHASE, "%s: %s is in use\n", p->link.name, p->name.full); in physical_Lock()
325 p->link.name, p->name.full, uu_lockerr(res)); in physical_Lock()
333 physical_Unlock(struct physical *p) in physical_Unlock() argument
335 if (*p->name.full == '/' && p->type != PHYS_DIRECT && in physical_Unlock()
336 ID0uu_unlock(p->name.base) == -1) in physical_Unlock()
337 log_Printf(LogALERT, "%s: Can't uu_unlock %s\n", p->link.name, in physical_Unlock()
338 p->name.base); in physical_Unlock()
342 physical_Close(struct physical *p) in physical_Close() argument
347 if (p->fd < 0) in physical_Close()
350 log_Printf(LogDEBUG, "%s: Close\n", p->link.name); in physical_Close()
352 if (p->handler && p->handler->cooked) in physical_Close()
353 (*p->handler->cooked)(p); in physical_Close()
355 physical_StopDeviceTimer(p); in physical_Close()
356 if (p->Utmp) { in physical_Close()
357 if (p->handler && (p->handler->type == TCP_DEVICE || in physical_Close()
358 p->handler->type == UDP_DEVICE)) in physical_Close()
362 ID0logout(p->name.base, 0); in physical_Close()
363 p->Utmp = 0; in physical_Close()
365 newsid = tcgetpgrp(p->fd) == getpgrp(); in physical_Close()
366 close(p->fd); in physical_Close()
367 p->fd = -1; in physical_Close()
368 log_SetTtyCommandMode(p->dl); in physical_Close()
370 throughput_stop(&p->link.stats.total); in physical_Close()
371 throughput_log(&p->link.stats.total, LogPHASE, p->link.name); in physical_Close()
373 if (p->session_owner != (pid_t)-1) { in physical_Close()
374 log_Printf(LogPHASE, "%s: HUPing %ld\n", p->link.name, in physical_Close()
375 (long)p->session_owner); in physical_Close()
376 ID0kill(p->session_owner, SIGHUP); in physical_Close()
377 p->session_owner = (pid_t)-1; in physical_Close()
381 bundle_setsid(p->dl->bundle, 0); in physical_Close()
383 if (*p->name.full == '/') { in physical_Close()
384 snprintf(fn, sizeof fn, "%s%s.if", _PATH_VARRUN, p->name.base); in physical_Close()
388 p->link.name, fn, strerror(errno)); in physical_Close()
393 physical_Unlock(p); in physical_Close()
394 if (p->handler && p->handler->destroy) in physical_Close()
395 (*p->handler->destroy)(p); in physical_Close()
396 p->handler = NULL; in physical_Close()
397 p->name.base = p->name.full; in physical_Close()
398 *p->name.full = '\0'; in physical_Close()
402 physical_Destroy(struct physical *p) in physical_Destroy() argument
404 physical_Close(p); in physical_Destroy()
405 throughput_destroy(&p->link.stats.total); in physical_Destroy()
406 free(p); in physical_Destroy()
413 struct physical *p = descriptor2physical(d); in physical_DescriptorWrite() local
416 if (p->out == NULL) in physical_DescriptorWrite()
417 p->out = link_Dequeue(&p->link); in physical_DescriptorWrite()
419 if (p->out) { in physical_DescriptorWrite()
420 nw = physical_Write(p, MBUF_CTOP(p->out), p->out->m_len); in physical_DescriptorWrite()
422 p->link.name, nw, (unsigned long)p->out->m_len, p->fd); in physical_DescriptorWrite()
424 p->out->m_len -= nw; in physical_DescriptorWrite()
425 p->out->m_offset += nw; in physical_DescriptorWrite()
426 if (p->out->m_len == 0) in physical_DescriptorWrite()
427 p->out = m_free(p->out); in physical_DescriptorWrite()
433 log_Printf(LogPHASE, "%s: write (fd %d, len %zd): %s\n", p->link.name, in physical_DescriptorWrite()
434 p->fd, p->out->m_len, strerror(errno)); in physical_DescriptorWrite()
435 datalink_Down(p->dl, CLOSE_NORMAL); in physical_DescriptorWrite()
447 struct physical *p = arg->cx->physical; in physical_ShowStatus() local
452 prompt_Printf(arg->prompt, "Name: %s\n", p->link.name); in physical_ShowStatus()
454 if (p->fd < 0) in physical_ShowStatus()
457 slot = physical_Slot(p); in physical_ShowStatus()
458 if (p->handler && p->handler->openinfo) { in physical_ShowStatus()
460 prompt_Printf(arg->prompt, "open (%s)\n", (*p->handler->openinfo)(p)); in physical_ShowStatus()
463 (*p->handler->openinfo)(p), slot); in physical_ShowStatus()
471 *p->name.full ? p->name.full : in physical_ShowStatus()
472 p->type == PHYS_DIRECT ? "unknown" : "N/A"); in physical_ShowStatus()
473 if (p->session_owner != (pid_t)-1) in physical_ShowStatus()
474 prompt_Printf(arg->prompt, " (session owner: %ld)", (long)p->session_owner); in physical_ShowStatus()
476 prompt_Printf(arg->prompt, "\n Link Type: %s\n", mode2Nam(p->type)); in physical_ShowStatus()
477 prompt_Printf(arg->prompt, " Connect Count: %d\n", p->connect_count); in physical_ShowStatus()
479 if (p->fd >= 0 && ioctl(p->fd, TIOCOUTQ, &n) >= 0) in physical_ShowStatus()
484 (u_long)link_QueueLen(&p->link)); in physical_ShowStatus()
490 dev = p->cfg.devlist; in physical_ShowStatus()
491 for (n = 0; n < p->cfg.ndev; n++) { in physical_ShowStatus()
502 prompt_Printf(arg->prompt, "%dbps", p->cfg.speed); in physical_ShowStatus()
504 switch (p->cfg.parity & CSIZE) { in physical_ShowStatus()
512 if (p->cfg.parity & PARENB) { in physical_ShowStatus()
513 if (p->cfg.parity & PARODD) in physical_ShowStatus()
520 prompt_Printf(arg->prompt, ", CTS/RTS %s\n", (p->cfg.rts_cts ? "on" : "off")); in physical_ShowStatus()
523 cd = p->handler ? &p->handler->cd : &p->cfg.cd; in physical_ShowStatus()
526 else if (p->cfg.cd.necessity == CD_DEFAULT) { in physical_ShowStatus()
529 prompt_Printf(arg->prompt, "%d second%s", p->cfg.cd.delay, in physical_ShowStatus()
530 p->cfg.cd.delay == 1 ? "" : "s"); in physical_ShowStatus()
531 if (p->cfg.cd.necessity == CD_REQUIRED) in physical_ShowStatus()
536 throughput_disp(&p->link.stats.total, arg->prompt); in physical_ShowStatus()
545 struct physical *p = descriptor2physical(d); in physical_DescriptorRead() local
549 rbuff = p->input.buf + p->input.sz; in physical_DescriptorRead()
552 n = physical_Read(p, rbuff, sizeof p->input.buf - p->input.sz); in physical_DescriptorRead()
554 p->link.name, n, (int)(sizeof p->input.buf - p->input.sz), p->fd); in physical_DescriptorRead()
557 log_Printf(LogPHASE, "%s: read (%d): %s\n", p->link.name, p->fd, in physical_DescriptorRead()
561 p->link.name, p->fd); in physical_DescriptorRead()
562 datalink_Down(p->dl, CLOSE_NORMAL); in physical_DescriptorRead()
566 rbuff -= p->input.sz; in physical_DescriptorRead()
567 n += p->input.sz; in physical_DescriptorRead()
569 if (p->link.lcp.fsm.state <= ST_CLOSED) { in physical_DescriptorRead()
570 if (p->type != PHYS_DEDICATED) { in physical_DescriptorRead()
571 found = hdlc_Detect((u_char const **)&rbuff, n, physical_IsSync(p)); in physical_DescriptorRead()
572 if (rbuff != p->input.buf) in physical_DescriptorRead()
573 log_WritePrompts(p->dl, "%.*s", (int)(rbuff - p->input.buf), in physical_DescriptorRead()
574 p->input.buf); in physical_DescriptorRead()
575 p->input.sz = n - (rbuff - p->input.buf); in physical_DescriptorRead()
580 p->link.name); in physical_DescriptorRead()
581 log_SetTtyCommandMode(p->dl); in physical_DescriptorRead()
582 datalink_Up(p->dl, 0, 1); in physical_DescriptorRead()
583 link_PullPacket(&p->link, rbuff, p->input.sz, bundle); in physical_DescriptorRead()
584 p->input.sz = 0; in physical_DescriptorRead()
586 bcopy(rbuff, p->input.buf, p->input.sz); in physical_DescriptorRead()
589 p->input.sz = 0; in physical_DescriptorRead()
591 link_PullPacket(&p->link, rbuff, n, bundle); in physical_DescriptorRead()
598 struct physical *p; in iov2physical() local
602 p = (struct physical *)iov[(*niov)++].iov_base; in iov2physical()
603 p->link.name = dl->name; in iov2physical()
604 memset(p->link.Queue, '\0', sizeof p->link.Queue); in iov2physical()
606 p->desc.UpdateSet = physical_UpdateSet; in iov2physical()
607 p->desc.IsSet = physical_IsSet; in iov2physical()
608 p->desc.Read = physical_DescriptorRead; in iov2physical()
609 p->desc.Write = physical_DescriptorWrite; in iov2physical()
610 p->type = PHYS_DIRECT; in iov2physical()
611 p->dl = dl; in iov2physical()
613 p->out = NULL; in iov2physical()
614 p->connect_count = 1; in iov2physical()
616 physical_SetDevice(p, p->name.full); in iov2physical()
618 p->link.lcp.fsm.bundle = dl->bundle; in iov2physical()
619 p->link.lcp.fsm.link = &p->link; in iov2physical()
620 memset(&p->link.lcp.fsm.FsmTimer, '\0', sizeof p->link.lcp.fsm.FsmTimer); in iov2physical()
621 memset(&p->link.lcp.fsm.OpenTimer, '\0', sizeof p->link.lcp.fsm.OpenTimer); in iov2physical()
622 memset(&p->link.lcp.fsm.StoppedTimer, '\0', in iov2physical()
623 sizeof p->link.lcp.fsm.StoppedTimer); in iov2physical()
624 p->link.lcp.fsm.parent = &dl->fsmp; in iov2physical()
625 lcp_SetupCallbacks(&p->link.lcp); in iov2physical()
627 p->link.ccp.fsm.bundle = dl->bundle; in iov2physical()
628 p->link.ccp.fsm.link = &p->link; in iov2physical()
630 memset(&p->link.ccp.fsm.FsmTimer, '\0', sizeof p->link.ccp.fsm.FsmTimer); in iov2physical()
631 memset(&p->link.ccp.fsm.OpenTimer, '\0', sizeof p->link.ccp.fsm.OpenTimer); in iov2physical()
632 memset(&p->link.ccp.fsm.StoppedTimer, '\0', in iov2physical()
633 sizeof p->link.ccp.fsm.StoppedTimer); in iov2physical()
634 p->link.ccp.fsm.parent = &dl->fsmp; in iov2physical()
635 ccp_SetupCallbacks(&p->link.ccp); in iov2physical()
637 p->hdlc.lqm.owner = &p->link.lcp; in iov2physical()
638 p->hdlc.ReportTimer.state = TIMER_STOPPED; in iov2physical()
639 p->hdlc.lqm.timer.state = TIMER_STOPPED; in iov2physical()
641 p->fd = fd; in iov2physical()
642 p->link.stats.total.in.SampleOctets = (long long *)iov[(*niov)++].iov_base; in iov2physical()
643 p->link.stats.total.out.SampleOctets = (long long *)iov[(*niov)++].iov_base; in iov2physical()
644 p->link.stats.parent = dl->bundle->ncp.mp.active ? in iov2physical()
646 p->link.stats.gather = 1; in iov2physical()
648 type = (long)p->handler; in iov2physical()
649 p->handler = NULL; in iov2physical()
650 for (h = 0; h < NDEVICES && p->handler == NULL; h++) in iov2physical()
651 p->handler = (*devices[h].iov2device)(type, p, iov, niov, maxiov, in iov2physical()
653 if (p->handler == NULL) { in iov2physical()
654 log_Printf(LogPHASE, "%s: Unknown link type\n", p->link.name); in iov2physical()
656 physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE); in iov2physical()
659 p->link.name, p->name.full, p->handler->name); in iov2physical()
661 if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load) in iov2physical()
662 lqr_reStart(&p->link.lcp); in iov2physical()
663 hdlc_StartTimer(&p->hdlc); in iov2physical()
665 throughput_restart(&p->link.stats.total, "physical throughput", in iov2physical()
668 return p; in iov2physical()
688 physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov, in physical2iov() argument
695 if (p) { in physical2iov()
696 hdlc_StopTimer(&p->hdlc); in physical2iov()
697 lqr_StopTimer(p); in physical2iov()
698 timer_Stop(&p->link.lcp.fsm.FsmTimer); in physical2iov()
699 timer_Stop(&p->link.ccp.fsm.FsmTimer); in physical2iov()
700 timer_Stop(&p->link.lcp.fsm.OpenTimer); in physical2iov()
701 timer_Stop(&p->link.ccp.fsm.OpenTimer); in physical2iov()
702 timer_Stop(&p->link.lcp.fsm.StoppedTimer); in physical2iov()
703 timer_Stop(&p->link.ccp.fsm.StoppedTimer); in physical2iov()
704 if (p->handler) { in physical2iov()
705 h = p->handler; in physical2iov()
706 p->handler = (struct device *)(long)p->handler->type; in physical2iov()
709 if (Enabled(p->dl->bundle, OPT_KEEPSESSION) || in physical2iov()
710 tcgetpgrp(p->fd) == getpgrp()) in physical2iov()
711 p->session_owner = getpid(); /* So I'll eventually get HUP'd */ in physical2iov()
713 p->session_owner = (pid_t)-1; in physical2iov()
714 timer_Stop(&p->link.stats.total.Timer); in physical2iov()
720 if (p) in physical2iov()
721 free(p); in physical2iov()
725 iov[*niov].iov_base = (void *)p; in physical2iov()
726 iov[*niov].iov_len = sizeof *p; in physical2iov()
729 iov[*niov].iov_base = p ? (void *)p->link.stats.total.in.SampleOctets : NULL; in physical2iov()
732 iov[*niov].iov_base = p ? (void *)p->link.stats.total.out.SampleOctets : NULL; in physical2iov()
737 if (p) { in physical2iov()
756 return p ? p->fd : 0; in physical2iov()
760 physical_LockedDevice(struct physical *p) in physical_LockedDevice() argument
762 if (p->fd >= 0 && *p->name.full == '/' && p->type != PHYS_DIRECT) in physical_LockedDevice()
763 return p->name.base; in physical_LockedDevice()
769 physical_ChangedPid(struct physical *p, pid_t newpid) in physical_ChangedPid() argument
771 if (physical_LockedDevice(p)) { in physical_ChangedPid()
774 if ((res = ID0uu_lock_txfr(p->name.base, newpid)) != UU_LOCK_OK) in physical_ChangedPid()
780 physical_IsSync(struct physical *p) in physical_IsSync() argument
782 return p->cfg.speed == 0; in physical_IsSync()
786 physical_DeviceMTU(struct physical *p) in physical_DeviceMTU() argument
788 return p->handler ? p->handler->mtu : 0; in physical_DeviceMTU()
791 const char *physical_GetDevice(struct physical *p) in physical_GetDevice() argument
793 return p->name.full; in physical_GetDevice()
797 physical_SetDeviceList(struct physical *p, int argc, const char *const *argv) in physical_SetDeviceList() argument
802 p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0'; in physical_SetDeviceList()
803 for (f = 0, pos = 0; f < argc && pos < sizeof p->cfg.devlist - 1; f++) { in physical_SetDeviceList()
805 p->cfg.devlist[pos++] = '\0'; in physical_SetDeviceList()
806 strncpy(p->cfg.devlist + pos, argv[f], sizeof p->cfg.devlist - pos - 1); in physical_SetDeviceList()
807 pos += strlen(p->cfg.devlist + pos); in physical_SetDeviceList()
809 p->cfg.ndev = f; in physical_SetDeviceList()
813 physical_SetSync(struct physical *p) in physical_SetSync() argument
815 p->cfg.speed = 0; in physical_SetSync()
819 physical_SetRtsCts(struct physical *p, int enable) in physical_SetRtsCts() argument
821 p->cfg.rts_cts = enable ? 1 : 0; in physical_SetRtsCts()
826 physical_Read(struct physical *p, void *buf, size_t nbytes) in physical_Read() argument
830 if (p->handler && p->handler->read) in physical_Read()
831 ret = (*p->handler->read)(p, buf, nbytes); in physical_Read()
833 ret = read(p->fd, buf, nbytes); in physical_Read()
841 physical_Write(struct physical *p, const void *buf, size_t nbytes) in physical_Write() argument
845 if (p->handler && p->handler->write) in physical_Write()
846 return (*p->handler->write)(p, buf, nbytes); in physical_Write()
848 return write(p->fd, buf, nbytes); in physical_Write()
855 struct physical *p = descriptor2physical(d); in physical_doUpdateSet() local
859 if (p->fd >= 0) { in physical_doUpdateSet()
861 FD_SET(p->fd, r); in physical_doUpdateSet()
862 log_Printf(LogTIMER, "%s: fdset(r) %d\n", p->link.name, p->fd); in physical_doUpdateSet()
866 FD_SET(p->fd, e); in physical_doUpdateSet()
867 log_Printf(LogTIMER, "%s: fdset(e) %d\n", p->link.name, p->fd); in physical_doUpdateSet()
870 if (w && (force || link_QueueLen(&p->link) || p->out)) { in physical_doUpdateSet()
871 FD_SET(p->fd, w); in physical_doUpdateSet()
872 log_Printf(LogTIMER, "%s: fdset(w) %d\n", p->link.name, p->fd); in physical_doUpdateSet()
875 if (sets && *n < p->fd + 1) in physical_doUpdateSet()
876 *n = p->fd + 1; in physical_doUpdateSet()
883 physical_RemoveFromSet(struct physical *p, fd_set *r, fd_set *w, fd_set *e) in physical_RemoveFromSet() argument
885 if (p->handler && p->handler->removefromset) in physical_RemoveFromSet()
886 return (*p->handler->removefromset)(p, r, w, e); in physical_RemoveFromSet()
891 if (p->fd >= 0) { in physical_RemoveFromSet()
892 if (r && FD_ISSET(p->fd, r)) { in physical_RemoveFromSet()
893 FD_CLR(p->fd, r); in physical_RemoveFromSet()
894 log_Printf(LogTIMER, "%s: fdunset(r) %d\n", p->link.name, p->fd); in physical_RemoveFromSet()
897 if (e && FD_ISSET(p->fd, e)) { in physical_RemoveFromSet()
898 FD_CLR(p->fd, e); in physical_RemoveFromSet()
899 log_Printf(LogTIMER, "%s: fdunset(e) %d\n", p->link.name, p->fd); in physical_RemoveFromSet()
902 if (w && FD_ISSET(p->fd, w)) { in physical_RemoveFromSet()
903 FD_CLR(p->fd, w); in physical_RemoveFromSet()
904 log_Printf(LogTIMER, "%s: fdunset(w) %d\n", p->link.name, p->fd); in physical_RemoveFromSet()
916 struct physical *p = descriptor2physical(d); in physical_IsSet() local
917 return p->fd >= 0 && FD_ISSET(p->fd, fdset); in physical_IsSet()
921 physical_Login(struct physical *p, const char *name) in physical_Login() argument
923 if (p->type == PHYS_DIRECT && *p->name.base && !p->Utmp) { in physical_Login()
931 if (p->handler && (p->handler->type == TCP_DEVICE || in physical_Login()
932 p->handler->type == UDP_DEVICE)) { in physical_Login()
934 strncpy(ut.ut_host, p->name.base, sizeof ut.ut_host); in physical_Login()
939 strncpy(ut.ut_line, p->name.base, sizeof ut.ut_line); in physical_Login()
944 p->Utmp = ut.ut_time; in physical_Login()
949 physical_SetMode(struct physical *p, int mode) in physical_SetMode() argument
951 if ((p->type & (PHYS_DIRECT|PHYS_DEDICATED) || in physical_SetMode()
953 (!(p->type & PHYS_DIRECT) || !(mode & PHYS_BACKGROUND))) { in physical_SetMode()
955 log_Printf(LogWARN, "%s: Cannot change mode %s to %s\n", p->link.name, in physical_SetMode()
956 mode2Nam(p->type), mode2Nam(mode)); in physical_SetMode()
959 p->type = mode; in physical_SetMode()
964 physical_DeleteQueue(struct physical *p) in physical_DeleteQueue() argument
966 if (p->out) { in physical_DeleteQueue()
967 m_freem(p->out); in physical_DeleteQueue()
968 p->out = NULL; in physical_DeleteQueue()
970 link_DeleteQueue(&p->link); in physical_DeleteQueue()
974 physical_SetDevice(struct physical *p, const char *name) in physical_SetDevice() argument
978 if (name != p->name.full) { in physical_SetDevice()
979 strncpy(p->name.full, name, sizeof p->name.full - 1); in physical_SetDevice()
980 p->name.full[sizeof p->name.full - 1] = '\0'; in physical_SetDevice()
982 p->name.base = *p->name.full == '!' ? p->name.full + 1 : in physical_SetDevice()
983 strncmp(p->name.full, _PATH_DEV, len) ? in physical_SetDevice()
984 p->name.full : p->name.full + len; in physical_SetDevice()
988 physical_Found(struct physical *p) in physical_Found() argument
993 if (*p->name.full == '/') { in physical_Found()
994 snprintf(fn, sizeof fn, "%s%s.if", _PATH_VARRUN, p->name.base); in physical_Found()
997 fprintf(lockfile, "%s%d\n", TUN_NAME, p->dl->bundle->unit); in physical_Found()
1003 p->link.name, fn, strerror(errno)); in physical_Found()
1007 throughput_start(&p->link.stats.total, "physical throughput", in physical_Found()
1008 Enabled(p->dl->bundle, OPT_THROUGHPUT)); in physical_Found()
1009 p->connect_count++; in physical_Found()
1010 p->input.sz = 0; in physical_Found()
1012 log_Printf(LogPHASE, "%s: Connected!\n", p->link.name); in physical_Found()
1016 physical_Open(struct physical *p) in physical_Open() argument
1022 if (p->fd >= 0) in physical_Open()
1023 log_Printf(LogDEBUG, "%s: Open: Modem is already open!\n", p->link.name); in physical_Open()
1025 else if (p->type == PHYS_DIRECT) { in physical_Open()
1026 physical_SetDevice(p, ""); in physical_Open()
1027 p->fd = STDIN_FILENO; in physical_Open()
1028 for (h = 0; h < NDEVICES && p->handler == NULL && p->fd >= 0; h++) in physical_Open()
1029 p->handler = (*devices[h].create)(p); in physical_Open()
1031 if (p->fd >= 0) { in physical_Open()
1032 if (p->handler == NULL) { in physical_Open()
1033 physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE); in physical_Open()
1034 log_Printf(LogDEBUG, "%s: stdin is unidentified\n", p->link.name); in physical_Open()
1036 physical_Found(p); in physical_Open()
1039 dev = p->cfg.devlist; in physical_Open()
1041 while (devno < p->cfg.ndev && p->fd < 0) { in physical_Open()
1042 physical_SetDevice(p, dev); in physical_Open()
1043 if (physical_Lock(p)) { in physical_Open()
1046 if (*p->name.full == '/') { in physical_Open()
1047 p->fd = ID0open(p->name.full, O_RDWR | O_NONBLOCK); in physical_Open()
1048 if (p->fd < 0) in physical_Open()
1052 wasfd = p->fd; in physical_Open()
1053 for (h = 0; h < NDEVICES && p->handler == NULL; h++) in physical_Open()
1054 if ((p->handler = (*devices[h].create)(p)) == NULL && wasfd != p->fd) in physical_Open()
1057 if (p->fd < 0) { in physical_Open()
1060 log_Printf(LogWARN, "%s: %s: %s\n", p->link.name, p->name.full, in physical_Open()
1064 " a '!' or contain at least one ':'\n", p->link.name, in physical_Open()
1065 p->name.full); in physical_Open()
1067 physical_Unlock(p); in physical_Open()
1069 physical_Found(p); in physical_Open()
1076 return p->fd; in physical_Open()
1080 physical_SetupStack(struct physical *p, const char *who, int how) in physical_SetupStack() argument
1082 link_EmptyStack(&p->link); in physical_SetupStack()
1084 (how == PHYSICAL_NOFORCE && physical_IsSync(p))) in physical_SetupStack()
1085 link_Stack(&p->link, &synclayer); in physical_SetupStack()
1087 link_Stack(&p->link, &asynclayer); in physical_SetupStack()
1088 link_Stack(&p->link, &hdlclayer); in physical_SetupStack()
1091 link_Stack(&p->link, &acflayer); in physical_SetupStack()
1092 link_Stack(&p->link, &protolayer); in physical_SetupStack()
1093 link_Stack(&p->link, &lqrlayer); in physical_SetupStack()
1094 link_Stack(&p->link, &ccplayer); in physical_SetupStack()
1095 link_Stack(&p->link, &vjlayer); in physical_SetupStack()
1096 link_Stack(&p->link, &tcpmsslayer); in physical_SetupStack()
1098 link_Stack(&p->link, &natlayer); in physical_SetupStack()
1100 if (how == PHYSICAL_FORCE_ASYNC && physical_IsSync(p)) { in physical_SetupStack()
1102 p->cfg.speed = MODEM_SPEED; in physical_SetupStack()
1103 } else if (how == PHYSICAL_FORCE_SYNC && !physical_IsSync(p)) { in physical_SetupStack()
1106 physical_SetSync(p); in physical_SetupStack()
1111 physical_StopDeviceTimer(struct physical *p) in physical_StopDeviceTimer() argument
1113 if (p->handler && p->handler->stoptimer) in physical_StopDeviceTimer()
1114 (*p->handler->stoptimer)(p); in physical_StopDeviceTimer()
1118 physical_AwaitCarrier(struct physical *p) in physical_AwaitCarrier() argument
1120 if (p->handler && p->handler->awaitcarrier) in physical_AwaitCarrier()
1121 return (*p->handler->awaitcarrier)(p); in physical_AwaitCarrier()
1128 physical_SetAsyncParams(struct physical *p, u_int32_t mymap, u_int32_t hismap) in physical_SetAsyncParams() argument
1130 if (p->handler && p->handler->setasyncparams) in physical_SetAsyncParams()
1131 return (*p->handler->setasyncparams)(p, mymap, hismap); in physical_SetAsyncParams()
1133 async_SetLinkParams(&p->async, mymap, hismap); in physical_SetAsyncParams()
1137 physical_Slot(struct physical *p) in physical_Slot() argument
1139 if (p->handler && p->handler->slot) in physical_Slot()
1140 return (*p->handler->slot)(p); in physical_Slot()
1146 physical_SetPPPoEnonstandard(struct physical *p, int enable) in physical_SetPPPoEnonstandard() argument
1148 p->cfg.nonstandard_pppoe = enable ? 1 : 0; in physical_SetPPPoEnonstandard()
1149 p->cfg.pppoe_configured = 1; in physical_SetPPPoEnonstandard()