tty.c (78410) | tty.c (93418) |
---|---|
1/*- 2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/tty.c 78410 2001-06-18 14:59:36Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/tty.c 93418 2002-03-30 12:30:09Z brian $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/un.h> 31#if defined(__OpenBSD__) || defined(__NetBSD__) 32#include <sys/ioctl.h> 33#endif 34 35#include <errno.h> 36#include <fcntl.h> | 27 */ 28 29#include <sys/param.h> 30#include <sys/un.h> 31#if defined(__OpenBSD__) || defined(__NetBSD__) 32#include <sys/ioctl.h> 33#endif 34 35#include <errno.h> 36#include <fcntl.h> |
37#include <stdio.h> |
|
37#include <stdlib.h> 38#include <string.h> 39#include <sysexits.h> 40#include <sys/uio.h> 41#include <termios.h> 42#include <unistd.h> | 38#include <stdlib.h> 39#include <string.h> 40#include <sysexits.h> 41#include <sys/uio.h> 42#include <termios.h> 43#include <unistd.h> |
44#include <netgraph.h> 45#include <netgraph/ng_async.h> 46#include <netgraph/ng_message.h> 47#include <netgraph/ng_ppp.h> 48#include <netgraph/ng_tty.h> |
|
43 44#include "layer.h" 45#include "defs.h" 46#include "mbuf.h" 47#include "log.h" 48#include "timer.h" 49#include "lqr.h" 50#include "hdlc.h" --- 7 unchanged lines hidden (view full) --- 58#include "physical.h" 59#include "mp.h" 60#include "chat.h" 61#include "auth.h" 62#include "chap.h" 63#include "cbcp.h" 64#include "datalink.h" 65#include "main.h" | 49 50#include "layer.h" 51#include "defs.h" 52#include "mbuf.h" 53#include "log.h" 54#include "timer.h" 55#include "lqr.h" 56#include "hdlc.h" --- 7 unchanged lines hidden (view full) --- 64#include "physical.h" 65#include "mp.h" 66#include "chat.h" 67#include "auth.h" 68#include "chap.h" 69#include "cbcp.h" 70#include "datalink.h" 71#include "main.h" |
72#include "id.h" |
|
66#include "tty.h" 67 68#if defined(__mac68k__) || defined(__macppc__) 69#undef CRTS_IFLOW 70#undef CCTS_OFLOW 71#define CRTS_IFLOW CDTRCTS 72#define CCTS_OFLOW CDTRCTS 73#endif 74 75#define Online(dev) ((dev)->mbits & TIOCM_CD) 76 77struct ttydevice { 78 struct device dev; /* What struct physical knows about */ 79 struct pppTimer Timer; /* CD checks */ 80 int mbits; /* Current DCD status */ 81 int carrier_seconds; /* seconds before CD is *required* */ | 73#include "tty.h" 74 75#if defined(__mac68k__) || defined(__macppc__) 76#undef CRTS_IFLOW 77#undef CCTS_OFLOW 78#define CRTS_IFLOW CDTRCTS 79#define CCTS_OFLOW CDTRCTS 80#endif 81 82#define Online(dev) ((dev)->mbits & TIOCM_CD) 83 84struct ttydevice { 85 struct device dev; /* What struct physical knows about */ 86 struct pppTimer Timer; /* CD checks */ 87 int mbits; /* Current DCD status */ 88 int carrier_seconds; /* seconds before CD is *required* */ |
89#ifndef NONETGRAPH 90 struct { 91 int speed; /* Pre-line-discipline speed */ 92 int fd; /* Pre-line-discipline fd */ 93 int disc; /* Old line-discipline */ 94 } real; 95 char hook[sizeof NG_ASYNC_HOOK_SYNC]; /* our ng_socket hook */ 96 int cs; /* A netgraph control socket (maybe) */ 97#endif |
|
82 struct termios ios; /* To be able to reset from raw mode */ 83}; 84 85#define device2tty(d) ((d)->type == TTY_DEVICE ? (struct ttydevice *)d : NULL) 86 87int 88tty_DeviceSize(void) 89{ --- 97 unchanged lines hidden (view full) --- 187 tty_StartTimer(p); 188 } 189 return CARRIER_PENDING; /* Not yet ! */ 190 } 191 192 return Online(dev) ? CARRIER_OK : CARRIER_LOST; 193} 194 | 98 struct termios ios; /* To be able to reset from raw mode */ 99}; 100 101#define device2tty(d) ((d)->type == TTY_DEVICE ? (struct ttydevice *)d : NULL) 102 103int 104tty_DeviceSize(void) 105{ --- 97 unchanged lines hidden (view full) --- 203 tty_StartTimer(p); 204 } 205 return CARRIER_PENDING; /* Not yet ! */ 206 } 207 208 return Online(dev) ? CARRIER_OK : CARRIER_LOST; 209} 210 |
211#ifdef NONETGRAPH 212#define tty_SetAsyncParams NULL 213#define tty_Write NULL 214#define tty_Read NULL 215#else 216 |
|
195static int | 217static int |
218isngtty(struct ttydevice *dev) 219{ 220 return dev->real.fd != -1; 221} 222 223static void 224tty_SetAsyncParams(struct physical *p, u_int32_t mymap, u_int32_t hismap) 225{ 226 struct ttydevice *dev = device2tty(p->handler); 227 char asyncpath[NG_PATHLEN + 1]; 228 struct ng_async_cfg cfg; 229 230 if (isngtty(dev)) { 231 /* Configure the async converter node */ 232 233 snprintf(asyncpath, sizeof asyncpath, ".:%s", dev->hook); 234 memset(&cfg, 0, sizeof cfg); 235 cfg.enabled = 1; 236 cfg.accm = mymap | hismap; 237 cfg.amru = MAX_MTU; 238 cfg.smru = MAX_MRU; 239 log_Printf(LogDEBUG, "Configure async node at %s\n", asyncpath); 240 if (NgSendMsg(dev->cs, asyncpath, NGM_ASYNC_COOKIE, 241 NGM_ASYNC_CMD_SET_CONFIG, &cfg, sizeof cfg) < 0) 242 log_Printf(LogWARN, "%s: Can't configure async node at %s\n", 243 p->link.name, asyncpath); 244 } else 245 /* No netgraph node, just config the async layer */ 246 async_SetLinkParams(&p->async, mymap, hismap); 247} 248 249static int 250LoadLineDiscipline(struct physical *p) 251{ 252 struct ttydevice *dev = device2tty(p->handler); 253 u_char rbuf[sizeof(struct ng_mesg) + sizeof(struct nodeinfo)]; 254 struct ng_mesg *reply; 255 struct nodeinfo *info; 256 char ttypath[NG_NODELEN + 1]; 257 struct ngm_mkpeer ngm; 258 struct ngm_connect ngc; 259 int ldisc, cs, ds, hot, speed; 260 261 reply = (struct ng_mesg *)rbuf; 262 info = (struct nodeinfo *)reply->data; 263 264 loadmodules(LOAD_VERBOSLY, "netgraph", "ng_tty", "ng_async", "ng_socket", 265 NULL); 266 267 /* Get the speed before loading the line discipline */ 268 speed = physical_GetSpeed(p); 269 270 if (ioctl(p->fd, TIOCGETD, &dev->real.disc) < 0) { 271 log_Printf(LogDEBUG, "%s: Couldn't get tty line discipline\n", 272 p->link.name); 273 return 0; 274 } 275 ldisc = NETGRAPHDISC; 276 if (ID0ioctl(p->fd, TIOCSETD, &ldisc) < 0) { 277 log_Printf(LogDEBUG, "%s: Couldn't set NETGRAPHDISC line discipline\n", 278 p->link.name); 279 return 0; 280 } 281 282 /* Get the name of the tty node */ 283 if (ioctl(p->fd, NGIOCGINFO, info) < 0) { 284 log_Printf(LogWARN, "%s: ioctl(NGIOCGINFO): %s\n", p->link.name, 285 strerror(errno)); 286 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); 287 return 0; 288 } 289 snprintf(ttypath, sizeof ttypath, "%s:", info->name); 290 291 /* Create a socket node for our endpoint (and to send messages via) */ 292 if (ID0NgMkSockNode(NULL, &cs, &ds) == -1) { 293 log_Printf(LogWARN, "%s: NgMkSockNode: %s\n", p->link.name, 294 strerror(errno)); 295 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); 296 return 0; 297 } 298 299 /* Set the ``hot char'' on the TTY node */ 300 hot = HDLC_SYN; 301 log_Printf(LogDEBUG, "%s: Set tty hotchar to 0x%02x\n", p->link.name, hot); 302 if (NgSendMsg(cs, ttypath, NGM_TTY_COOKIE, 303 NGM_TTY_SET_HOTCHAR, &hot, sizeof hot) < 0) { 304 log_Printf(LogWARN, "%s: Can't set hot char\n", p->link.name); 305 goto failed; 306 } 307 308 /* Attach an async converter node */ 309 snprintf(ngm.type, sizeof ngm.type, "%s", NG_ASYNC_NODE_TYPE); 310 snprintf(ngm.ourhook, sizeof ngm.ourhook, "%s", NG_TTY_HOOK); 311 snprintf(ngm.peerhook, sizeof ngm.peerhook, "%s", NG_ASYNC_HOOK_ASYNC); 312 log_Printf(LogDEBUG, "%s: Send mkpeer async:%s to %s:%s\n", p->link.name, 313 ngm.peerhook, ttypath, ngm.ourhook); 314 if (NgSendMsg(cs, ttypath, NGM_GENERIC_COOKIE, 315 NGM_MKPEER, &ngm, sizeof ngm) < 0) { 316 log_Printf(LogWARN, "%s: Can't create %s node\n", p->link.name, 317 NG_ASYNC_NODE_TYPE); 318 goto failed; 319 } 320 321 /* Connect the async node to our socket */ 322 snprintf(ngc.path, sizeof ngc.path, "%s%s", ttypath, NG_TTY_HOOK); 323 snprintf(ngc.peerhook, sizeof ngc.peerhook, "%s", NG_ASYNC_HOOK_SYNC); 324 memcpy(ngc.ourhook, ngc.peerhook, sizeof ngc.ourhook); 325 log_Printf(LogDEBUG, "%s: Send connect %s:%s to .:%s\n", p->link.name, 326 ngc.path, ngc.peerhook, ngc.ourhook); 327 if (NgSendMsg(cs, ".:", NGM_GENERIC_COOKIE, NGM_CONNECT, 328 &ngc, sizeof ngc) < 0) { 329 log_Printf(LogWARN, "%s: Can't connect .:%s -> %s.%s: %s\n", 330 p->link.name, ngc.ourhook, ngc.path, ngc.peerhook, 331 strerror(errno)); 332 goto failed; 333 } 334 335 /* Get the async node id */ 336 if (NgSendMsg(cs, ngc.path, NGM_GENERIC_COOKIE, NGM_NODEINFO, NULL, 0) < 0) { 337 log_Printf(LogWARN, "%s: Can't request async node info at %s: %s\n", 338 p->link.name, ngc.path, strerror(errno)); 339 goto failed; 340 } 341 if (NgRecvMsg(cs, reply, sizeof rbuf, NULL) < 0) { 342 log_Printf(LogWARN, "%s: Can't obtain async node info at %s: %s\n", 343 p->link.name, ngc.path, strerror(errno)); 344 goto failed; 345 } 346 347 /* All done, set up our device state */ 348 snprintf(dev->hook, sizeof dev->hook, "%s", ngc.ourhook); 349 dev->cs = cs; 350 dev->real.fd = p->fd; 351 p->fd = ds; 352 dev->real.speed = speed; 353 physical_SetSync(p); 354 355 tty_SetAsyncParams(p, 0xffffffff, 0xffffffff); 356 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); 357 log_Printf(LogPHASE, "%s: Loaded netgraph tty line discipline\n", 358 p->link.name); 359 360 return 1; 361 362failed: 363 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); 364 close(ds); 365 close(cs); 366 367 return 0; 368} 369 370static void 371UnloadLineDiscipline(struct physical *p) 372{ 373 struct ttydevice *dev = device2tty(p->handler); 374 375 if (isngtty(dev)) { 376log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed); 377 if (!physical_SetSpeed(p, dev->real.speed)) 378 log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed); 379 dev->real.speed = 0; 380 close(p->fd); 381 p->fd = dev->real.fd; 382 dev->real.fd = -1; 383 close(dev->cs); 384 dev->cs = -1; 385 *dev->hook = '\0'; 386 if (ID0ioctl(p->fd, TIOCSETD, &dev->real.disc) == 0) { 387 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); 388 log_Printf(LogPHASE, "%s: Unloaded netgraph tty line discipline\n", 389 p->link.name); 390 } else 391 log_Printf(LogWARN, "%s: Failed to unload netgraph tty line discipline\n", 392 p->link.name); 393 } 394} 395 396static ssize_t 397tty_Write(struct physical *p, const void *v, size_t n) 398{ 399 struct ttydevice *dev = device2tty(p->handler); 400 401 if (isngtty(dev)) 402 return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : n; 403 else 404 return write(p->fd, v, n); 405} 406 407static ssize_t 408tty_Read(struct physical *p, void *v, size_t n) 409{ 410 struct ttydevice *dev = device2tty(p->handler); 411 char hook[sizeof NG_ASYNC_HOOK_SYNC]; 412 413 if (isngtty(dev)) 414 return NgRecvData(p->fd, v, n, hook); 415 else 416 return read(p->fd, v, n); 417} 418 419#endif /* NETGRAPH */ 420 421static int |
|
196tty_Raw(struct physical *p) 197{ 198 struct ttydevice *dev = device2tty(p->handler); 199 struct termios ios; 200 int oldflag; 201 202 log_Printf(LogDEBUG, "%s: Entering tty_Raw\n", p->link.name); 203 204 if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(dev)) 205 log_Printf(LogDEBUG, "%s: Raw: descriptor = %d, mbits = %x\n", 206 p->link.name, p->fd, dev->mbits); 207 208 if (!physical_IsSync(p)) { | 422tty_Raw(struct physical *p) 423{ 424 struct ttydevice *dev = device2tty(p->handler); 425 struct termios ios; 426 int oldflag; 427 428 log_Printf(LogDEBUG, "%s: Entering tty_Raw\n", p->link.name); 429 430 if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(dev)) 431 log_Printf(LogDEBUG, "%s: Raw: descriptor = %d, mbits = %x\n", 432 p->link.name, p->fd, dev->mbits); 433 434 if (!physical_IsSync(p)) { |
209 tcgetattr(p->fd, &ios); 210 cfmakeraw(&ios); 211 if (p->cfg.rts_cts) 212 ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW; 213 else 214 ios.c_cflag |= CLOCAL; | 435#ifndef NONETGRAPH 436 if (!LoadLineDiscipline(p)) 437#endif 438 { 439 tcgetattr(p->fd, &ios); 440 cfmakeraw(&ios); 441 if (p->cfg.rts_cts) 442 ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW; 443 else 444 ios.c_cflag |= CLOCAL; |
215 | 445 |
216 if (p->type != PHYS_DEDICATED) 217 ios.c_cflag |= HUPCL; | 446 if (p->type != PHYS_DEDICATED) 447 ios.c_cflag |= HUPCL; |
218 | 448 |
219 if (tcsetattr(p->fd, TCSANOW, &ios) == -1) 220 log_Printf(LogWARN, "%s: tcsetattr: Failed configuring device\n", 221 p->link.name); | 449 if (tcsetattr(p->fd, TCSANOW, &ios) == -1) 450 log_Printf(LogWARN, "%s: tcsetattr: Failed configuring device\n", 451 p->link.name); 452 } |
222 } 223 224 oldflag = fcntl(p->fd, F_GETFL, 0); 225 if (oldflag < 0) 226 return 0; 227 fcntl(p->fd, F_SETFL, oldflag | O_NONBLOCK); 228 229 return 1; --- 27 unchanged lines hidden (view full) --- 257 tty_Offline(p); /* In case of emergency close()s */ 258 259 tcflush(p->fd, TCIOFLUSH); 260 261 if (!physical_IsSync(p) && tcsetattr(p->fd, TCSAFLUSH, &dev->ios) == -1) 262 log_Printf(LogWARN, "%s: tcsetattr: Unable to restore device settings\n", 263 p->link.name); 264 | 453 } 454 455 oldflag = fcntl(p->fd, F_GETFL, 0); 456 if (oldflag < 0) 457 return 0; 458 fcntl(p->fd, F_SETFL, oldflag | O_NONBLOCK); 459 460 return 1; --- 27 unchanged lines hidden (view full) --- 488 tty_Offline(p); /* In case of emergency close()s */ 489 490 tcflush(p->fd, TCIOFLUSH); 491 492 if (!physical_IsSync(p) && tcsetattr(p->fd, TCSAFLUSH, &dev->ios) == -1) 493 log_Printf(LogWARN, "%s: tcsetattr: Unable to restore device settings\n", 494 p->link.name); 495 |
496#ifndef NONETGRAPH 497 UnloadLineDiscipline(p); 498#endif 499 |
|
265 if ((oldflag = fcntl(p->fd, F_GETFL, 0)) != -1) 266 fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK); 267} 268 269static void 270tty_StopTimer(struct physical *p) 271{ 272 struct ttydevice *dev = device2tty(p->handler); --- 46 unchanged lines hidden (view full) --- 319 iov[*niov].iov_base = realloc(d, sz); 320 if (iov[*niov].iov_base == NULL) { 321 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 322 AbortProgram(EX_OSERR); 323 } 324 iov[*niov].iov_len = sz; 325 (*niov)++; 326 | 500 if ((oldflag = fcntl(p->fd, F_GETFL, 0)) != -1) 501 fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK); 502} 503 504static void 505tty_StopTimer(struct physical *p) 506{ 507 struct ttydevice *dev = device2tty(p->handler); --- 46 unchanged lines hidden (view full) --- 554 iov[*niov].iov_base = realloc(d, sz); 555 if (iov[*niov].iov_base == NULL) { 556 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 557 AbortProgram(EX_OSERR); 558 } 559 iov[*niov].iov_len = sz; 560 (*niov)++; 561 |
562#ifndef NONETGRAPH 563 if (dev->cs >= 0) { 564 *auxfd = dev->cs; 565 (*nauxfd)++; 566 } 567#endif 568 |
|
327 if (dev->Timer.state != TIMER_STOPPED) { 328 timer_Stop(&dev->Timer); 329 dev->Timer.state = TIMER_RUNNING; 330 } 331} 332 333static struct device basettydevice = { 334 TTY_DEVICE, 335 "tty", 336 0, 337 { CD_VARIABLE, DEF_TTYCDDELAY }, 338 tty_AwaitCarrier, 339 NULL, 340 tty_Raw, 341 tty_Offline, 342 tty_Cooked, | 569 if (dev->Timer.state != TIMER_STOPPED) { 570 timer_Stop(&dev->Timer); 571 dev->Timer.state = TIMER_RUNNING; 572 } 573} 574 575static struct device basettydevice = { 576 TTY_DEVICE, 577 "tty", 578 0, 579 { CD_VARIABLE, DEF_TTYCDDELAY }, 580 tty_AwaitCarrier, 581 NULL, 582 tty_Raw, 583 tty_Offline, 584 tty_Cooked, |
585 tty_SetAsyncParams, |
|
343 tty_StopTimer, 344 tty_Free, | 586 tty_StopTimer, 587 tty_Free, |
345 NULL, 346 NULL, | 588 tty_Read, 589 tty_Write, |
347 tty_device2iov, 348 tty_Speed, 349 tty_OpenInfo 350}; 351 352struct device * 353tty_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, 354 int maxiov, int *auxfd, int *nauxfd) 355{ 356 if (type == TTY_DEVICE) { 357 struct ttydevice *dev = (struct ttydevice *)iov[(*niov)++].iov_base; 358 359 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ 360 if (dev == NULL) { 361 log_Printf(LogALERT, "Failed to allocate memory: %d\n", 362 (int)(sizeof *dev)); 363 AbortProgram(EX_OSERR); 364 } 365 | 590 tty_device2iov, 591 tty_Speed, 592 tty_OpenInfo 593}; 594 595struct device * 596tty_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, 597 int maxiov, int *auxfd, int *nauxfd) 598{ 599 if (type == TTY_DEVICE) { 600 struct ttydevice *dev = (struct ttydevice *)iov[(*niov)++].iov_base; 601 602 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ 603 if (dev == NULL) { 604 log_Printf(LogALERT, "Failed to allocate memory: %d\n", 605 (int)(sizeof *dev)); 606 AbortProgram(EX_OSERR); 607 } 608 |
609#ifndef NONETGRAPH 610 if (*nauxfd) { 611 dev->cs = *auxfd; 612 (*nauxfd)--; 613 } else 614 dev->cs = -1; 615#endif 616 |
|
366 /* Refresh function pointers etc */ 367 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); 368 369 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); 370 if (dev->Timer.state != TIMER_STOPPED) { 371 dev->Timer.state = TIMER_STOPPED; 372 p->handler = &dev->dev; /* For the benefit of StartTimer */ 373 tty_StartTimer(p); --- 29 unchanged lines hidden (view full) --- 403 close(p->fd); 404 p->fd = -1; 405 return NULL; 406 } 407 408 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); 409 memset(&dev->Timer, '\0', sizeof dev->Timer); 410 dev->mbits = -1; | 617 /* Refresh function pointers etc */ 618 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); 619 620 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); 621 if (dev->Timer.state != TIMER_STOPPED) { 622 dev->Timer.state = TIMER_STOPPED; 623 p->handler = &dev->dev; /* For the benefit of StartTimer */ 624 tty_StartTimer(p); --- 29 unchanged lines hidden (view full) --- 654 close(p->fd); 655 p->fd = -1; 656 return NULL; 657 } 658 659 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); 660 memset(&dev->Timer, '\0', sizeof dev->Timer); 661 dev->mbits = -1; |
662#ifndef NONETGRAPH 663 dev->real.speed = 0; 664 dev->real.fd = -1; 665 dev->real.disc = -1; 666 *dev->hook = '\0'; 667#endif |
|
411 tcgetattr(p->fd, &ios); 412 dev->ios = ios; 413 414 if (p->cfg.cd.necessity != CD_DEFAULT) 415 /* Any override is ok for the tty device */ 416 dev->dev.cd = p->cfg.cd; 417 418 log_Printf(LogDEBUG, "%s: tty_Create: physical (get): fd = %d," --- 53 unchanged lines hidden --- | 668 tcgetattr(p->fd, &ios); 669 dev->ios = ios; 670 671 if (p->cfg.cd.necessity != CD_DEFAULT) 672 /* Any override is ok for the tty device */ 673 dev->dev.cd = p->cfg.cd; 674 675 log_Printf(LogDEBUG, "%s: tty_Create: physical (get): fd = %d," --- 53 unchanged lines hidden --- |