- /*
- * Save the old line discipline of fd, and set it to PPP.
- */
- if (ioctl(fd, TIOCGETD, &prevdisc) < 0) {
- syslog(LOG_ERR, "ioctl(TIOCGETD): %m");
- die(1);
- }
- x = PPPDISC;
- if (ioctl(fd, TIOCSETD, &x) < 0) {
- syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
- die(1);
- }
-
- /*
- * Set the old ppp device back to its previous discipline,
- */
- ioctl(ppp_fd, TIOCSETD, &initdisc);
- initdisc = prevdisc;
-
- /*
- * Check that we got the same unit again.
- */
- if (ioctl(fd, PPPIOCGUNIT, &x) < 0) {
- syslog(LOG_ERR, "ioctl(PPPIOCGUNIT): %m");
- die(1);
- }
- if (x != ifunit) {
- syslog(LOG_ERR, "transfer_ppp failed: wanted unit %d, got %d",
- ifunit, x);
- die(1);
- }
-
- ppp_fd = fd;
-
- /*
- * Set device for non-blocking reads.
- */
- if ((initfdflags = fcntl(fd, F_GETFL)) == -1
- || fcntl(fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) {
- syslog(LOG_WARNING, "Couldn't set device to non-blocking mode: %m");
- }