- int i, ifd, x;
-#ifndef sun
- struct ifreq ifr;
- struct {
- union DL_primitives prim;
- char space[64];
- } reply;
-#endif
-
- if (default_device)
- tty_sid = getsid((pid_t)0);
-
- pppfd = open("/dev/ppp", O_RDWR | O_NONBLOCK, 0);
- if (pppfd < 0) {
- syslog(LOG_ERR, "Can't open /dev/ppp: %m");
- die(1);
- }
- if (kdebugflag) {
- x = PPPDBG_LOG + PPPDBG_DRIVER;
- strioctl(pppfd, PPPIO_DEBUG, &x, sizeof(int), 0);
- }
-
- /* Assign a new PPA and get its unit number. */
- if (strioctl(pppfd, PPPIO_NEWPPA, &ifunit, 0, sizeof(int)) < 0) {
- syslog(LOG_ERR, "Can't create new PPP interface: %m");
- die(1);
- }
-
- /*
- * Open the ppp device again and link it under the ip multiplexor.
- * IP will assign a unit number which hopefully is the same as ifunit.
- * I don't know any way to be certain they will be the same. :-(
- */
- ifd = open("/dev/ppp", O_RDWR, 0);
- if (ifd < 0) {
- syslog(LOG_ERR, "Can't open /dev/ppp (2): %m");
- die(1);
- }
- if (kdebugflag) {
- x = PPPDBG_LOG + PPPDBG_DRIVER;
- strioctl(ifd, PPPIO_DEBUG, &x, sizeof(int), 0);
- }
-#ifdef sun
- if (ioctl(ifd, I_PUSH, "ip") < 0) {
- syslog(LOG_ERR, "Can't push IP module: %m");
- close(ifd);
- die(1);
- }
-#else
- if (dlpi_attach(ifd, ifunit) < 0 ||
- dlpi_get_reply(ifd, &reply.prim, DL_OK_ACK, sizeof(reply)) < 0) {
- syslog(LOG_ERR, "Can't attach to ppp%d: %m", ifunit);
- close(ifd);
- die(1);
- }
-#endif
- ipmuxid = ioctl(ipfd, I_LINK, ifd);
- close(ifd);
- if (ipmuxid < 0) {
- syslog(LOG_ERR, "Can't link PPP device to IP: %m");
- die(1);
- }
-
-#ifndef sun
- /* Set the interface name for the link. */
- (void) sprintf (ifr.ifr_name, "ppp%d", ifunit);
- ifr.ifr_metric = ipmuxid;
- if (strioctl(ipfd, SIOCSIFNAME, (char *)&ifr, sizeof ifr, 0) < 0) {
- syslog(LOG_ERR, "Can't set interface name %s: %m", ifr.ifr_name);
- die(1);
- }
-#endif