sys-solaris.c revision f53eecf557986dac6ededb388fedd6ca63be0350
29949e866e40b95795203f3ee46f44a197c946e4stevel * System-dependent procedures for pppd under Solaris 2.x (SunOS 5.x).
29949e866e40b95795203f3ee46f44a197c946e4stevel * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Use is subject to license terms.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Permission to use, copy, modify, and distribute this software and its
29949e866e40b95795203f3ee46f44a197c946e4stevel * documentation is hereby granted, provided that the above copyright
29949e866e40b95795203f3ee46f44a197c946e4stevel * notice appears in all copies.
29949e866e40b95795203f3ee46f44a197c946e4stevel * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
29949e866e40b95795203f3ee46f44a197c946e4stevel * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
29949e866e40b95795203f3ee46f44a197c946e4stevel * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
29949e866e40b95795203f3ee46f44a197c946e4stevel * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
29949e866e40b95795203f3ee46f44a197c946e4stevel * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
29949e866e40b95795203f3ee46f44a197c946e4stevel * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
29949e866e40b95795203f3ee46f44a197c946e4stevel * Copyright (c) 1994 The Australian National University.
29949e866e40b95795203f3ee46f44a197c946e4stevel * All rights reserved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Permission to use, copy, modify, and distribute this software and its
29949e866e40b95795203f3ee46f44a197c946e4stevel * documentation is hereby granted, provided that the above copyright
29949e866e40b95795203f3ee46f44a197c946e4stevel * notice appears in all copies. This software is provided without any
29949e866e40b95795203f3ee46f44a197c946e4stevel * warranty, express or implied. The Australian National University
29949e866e40b95795203f3ee46f44a197c946e4stevel * makes no representations about the suitability of this software for
29949e866e40b95795203f3ee46f44a197c946e4stevel * any purpose.
29949e866e40b95795203f3ee46f44a197c946e4stevel * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
29949e866e40b95795203f3ee46f44a197c946e4stevel * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
29949e866e40b95795203f3ee46f44a197c946e4stevel * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
29949e866e40b95795203f3ee46f44a197c946e4stevel * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
29949e866e40b95795203f3ee46f44a197c946e4stevel * OF SUCH DAMAGE.
29949e866e40b95795203f3ee46f44a197c946e4stevel * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
29949e866e40b95795203f3ee46f44a197c946e4stevel * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29949e866e40b95795203f3ee46f44a197c946e4stevel * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
29949e866e40b95795203f3ee46f44a197c946e4stevel * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
29949e866e40b95795203f3ee46f44a197c946e4stevel * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
29949e866e40b95795203f3ee46f44a197c946e4stevel * OR MODIFICATIONS.
29949e866e40b95795203f3ee46f44a197c946e4stevel#define RCSID "$Id: sys-solaris.c,v 1.2 2000/04/21 01:27:57 masputra Exp $"
#include <libdlpi.h>
#include "pppd.h"
#include "fsm.h"
#include "lcp.h"
#include "ipcp.h"
#ifdef INET6
#include "ipv6cp.h"
#include "ccp.h"
#ifndef MAXIFS
#ifdef INET6
#ifdef INET6
static bool integrated_driver = 0;
OPT_PRIV|0 },
{ NULL }
#ifdef INET6
static int open_ip6fd(void);
static int open_ipfd(void);
int retv;
errno = 0;
return (retv);
sys_check_options(void)
if (plumbed) {
ipmuxid = 0;
ip6muxid = 0;
sys_options(void)
sys_ifname(void)
const char *cp;
cp++;
ppp_available(void)
int fd;
open_ipfd(void)
if (ipfd < 0) {
return (ipfd);
#ifdef INET6
open_ip6fd(void)
if (ip6fd < 0) {
return (ip6fd);
#ifdef INET6
IPCP_ENABLED = 0;
#ifdef INET6
IPV6CP_ENABLED = 0;
uint32_t x;
if (open_as_user)
if (open_as_user)
(void) seteuid(0);
if (pppfd >= 0 &&
} else if (demand) {
if (pppfd < 0)
if (pppfd < 0) {
x = req_unit;
ifunit = x;
if (plumbed)
if (idle_time_limit > 0) {
if (plumbed) {
sys_ifname();
read_interface(0);
sys_extra_fd(void)
int fd;
return (fd);
open_udpfd(void)
int udpfd;
if (udpfd < 0) {
return (udpfd);
uint32_t x;
if (plumbed)
if (tmpfd < 0) {
goto err_ret;
goto err_ret;
if (use_plink) {
if (ipmuxid < 0) {
goto err_ret;
if (ipmuxid < 0) {
goto err_ret;
goto err_ret;
int id;
if (fd < 0) {
if (default_route_gateway != 0) {
if (proxy_arp_addr != 0) {
if (plumbed)
if (use_plink) {
(void) unplumb_ipif(0);
#ifdef INET6
(void) unplumb_ip6if(0);
int msize;
char *req;
if (fd < 0) {
found = 0;
return (found);
int retv;
return (physaddrlen);
int fd;
*retval = 0;
if (fd < 0) {
return (errno);
return (errno);
return (errno);
#ifdef INET6
any_compressions(void)
int fd;
uint32_t x;
if (integrated_driver)
return (pppfd);
tty_nmodules = i;
tty_npushed = 0;
if (any_compressions()) {
return (pppfd);
int fd;
if (!hungup) {
if (!hungup) {
--tty_npushed;
tty_modules[i]);
uint32_t x;
char *s = NULL;
if (sync_serial) {
case RCV_B7_0:
case RCV_B7_1:
case RCV_EVNP:
case RCV_ODDP:
if (s != NULL) {
struct speed {
int speed_int;
int speed_val;
} speeds [] = {
#ifdef B50
#ifdef B75
#ifdef B110
#ifdef B134
#ifdef B150
#ifdef B200
#ifdef B300
#ifdef B600
#ifdef B1200
#ifdef B1800
#ifdef B2000
#ifdef B2400
#ifdef B3600
#ifdef B4800
#ifdef B7200
#ifdef B9600
#ifdef B19200
#ifdef B38400
#ifdef EXTA
#ifdef EXTB
#ifdef B57600
#ifdef B76800
#ifdef B115200
#ifdef B153600
#ifdef B230400
#ifdef B307200
#ifdef B460800
#ifdef B921600
if (bps == 0) {
if (speed == 0) {
int speed;
if (already_ppp)
if (sync_serial) {
restore_term = 0;
baud_rate = 0;
sizeof (sm)) < 0) {
if (!restore_term) {
if (crtscts > 0) {
} else if (crtscts < 0) {
if (speed) {
int fd;
if (restore_term == 0) {
if (!default_device) {
restore_term = 0;
if (!already_ppp &&
#ifdef INET6
return (pppfd);
int unit;
uchar_t *p;
int len;
int retries, n;
if (--retries < 0 ||
sent_ok = 0;
int fd;
if (fd < 0) {
for (n = 0; n < n_pollfds; ++n) {
++n_pollfds;
int fd;
for (n = 0; n < n_pollfds; ++n) {
while (++n < n_pollfds) {
--n_pollfds;
const char *cp;
switch (proto) {
case PPP_IP:
proto);
case PPP_IPV6:
tostr);
proto);
switch (reason) {
case PPP_LINKSTAT_IPV4_BOUND:
#ifdef INET6
case PPP_LINKSTAT_IPV6_BOUND:
bool iff_up_isset;
int rc;
switch (reason) {
if (!iff_up_isset) {
if_is_up = 0;
#ifdef INET6
if (!iff_up_isset) {
if6_is_up = 0;
int flags;
int len;
int rc;
bool flushmode;
flushmode = 0;
flags = 0;
flags);
if (len < 0) {
if (flushmode)
if (flushmode)
case PPP_LINKSTAT_HANGUP:
case PPP_LINKSTAT_UP:
lcp_lowerdown(0);
lcp_lowerup(0);
case PPP_LINKSTAT_NEEDUP:
case PPP_LINKSTAT_IPV4_BOUND:
#ifdef INET6
case PPP_LINKSTAT_IPV6_BOUND:
int loops;
lastlink_status = 0;
loops = 0;
#ifdef MUX_FRAME
int unit;
int unit;
int unit;
int mtu;
int pcomp;
int accomp;
if (!sync_serial) {
sizeof (asyncmap), 0) < 0) {
int unit;
if (sync_serial) {
sizeof (ext_accm), 0) < 0) {
int unit;
int mru;
int pcomp;
int accomp;
if (!sync_serial) {
sizeof (asyncmap), 0) < 0) {
#ifdef NEGOTIATE_FCS
if (sync_serial) {
if (sync_serial) {
int unit;
int opt_len;
int for_transmit;
#ifdef COMP_TUNE
uint32_t x;
x = effort;
int rc;
if (rc < 0) {
struct ppp_stats s;
#if defined(FILTER_PACKETS)
sizeof (struct bpf_program), 0) < 0) {
ret = 0;
sizeof (struct bpf_program), 0) < 0) {
ret = 0;
return (ret);
int unit;
if (!any_compressions()) {
if (vjcomp) {
sizeof (maxcid), 0) < 0) {
if (vjcomp) {
u_int32_t f;
int set;
if (set) {
sifup(u)
if (if_is_up) {
} else if (!IPCP_ENABLED) {
sifdown(u)
if (!IPCP_ENABLED) {
if_is_up = 0;
int proto;
const char *cp;
static const struct npi_entry {
const char *ne_name;
} npi_list[] = {
int mtu;
mtu);
sifaddr(u, o, h, m)
u_int32_t o;
u_int32_t h;
u_int32_t m;
remote_addr = h;
cifaddr(u, o, h)
u_int32_t o;
u_int32_t h;
if (!IPCP_ENABLED) {
remote_addr = 0;
sifdefaultroute(u, l, g)
u_int32_t l;
u_int32_t g;
cifdefaultroute(u, l, g)
u_int32_t l;
u_int32_t g;
int unit;
int quietflag;
if (!quietflag)
str);
int unit;
proxy_arp_addr = 0;
if (nif <= 0)
if (!quietflag)
ipaddr);
retv = 0;
sizeof (struct sockaddr_dl));
(void) close(s);
return (retv);
const char *line;
const char *name;
const char *host;
int r, flags, i;
} req;
} ack;
int nroutes;
#ifdef T_CURRENT
flags = 0;
while (r == MOREDATA) {
int *master_fdp;
int *slave_fdp;
char *slave_name;
int uid;
int mfd;
int sfd;
char *pty_name;
if (mfd < 0) {
if (sfd < 0) {
#ifdef INET6
open_udp6fd(void)
int udp6fd;
if (udp6fd < 0) {
return (udp6fd);
uint32_t x;
if (plumbed)
if (tmpfd < 0) {
goto err_ret;
goto err_ret;
goto err_ret;
if (use_plink) {
if (ip6muxid < 0) {
goto err_ret;
if (ip6muxid < 0) {
goto err_ret;
goto err_ret;
int id;
if (fd < 0) {
if (plumbed)
if (use_plink) {
u_int32_t f;
int set;
int fd;
if (fd < 0) {
if (set) {
int unit;
if (if6_is_up) {
} else if (!IPV6CP_ENABLED) {
int unit;
if (!IPV6CP_ENABLED) {
if6_is_up = 0;
int mtu;
(void) close(s);
(void) close(s);
int unit;
int fd;
if (fd < 0) {
cif6addr(u, o, h)
eui64_t o;
eui64_t h;
if (!IPV6CP_ENABLED) {
struct bit_ent {
int val;
int nmods, i;
int mstate;
char *str;
if (nmods < 0) {
bool was_linked;
if (was_linked &&