X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-osf.c;h=f487cda69de8f05729321f6b534c8f7a593eeb10;hp=d9bdd30b12e2068f960861f918bb64e80f5ab721;hb=bcfa20820fc9ff3b25bcf62308e3e737c1897dc6;hpb=e8be982dbc5c6c50dfc9f66737867570c8ed4973 diff --git a/pppd/sys-osf.c b/pppd/sys-osf.c index d9bdd30..f487cda 100644 --- a/pppd/sys-osf.c +++ b/pppd/sys-osf.c @@ -25,10 +25,9 @@ * OR MODIFICATIONS. */ -#ifndef lint -static char rcsid[] = "$Id: sys-osf.c,v 1.25 1999/04/12 06:24:50 paulus Exp $"; -#endif +#define RCSID "$Id: sys-osf.c,v 1.31 1999/12/23 01:35:28 paulus Exp $" +#include #include #include #include @@ -61,6 +60,8 @@ static char rcsid[] = "$Id: sys-osf.c,v 1.25 1999/04/12 06:24:50 paulus Exp $"; #include "pppd.h" +static const char rcsid[] = RCSID; + static int pppfd; static int fdmuxid = -1; static int iffd; @@ -375,6 +376,13 @@ establish_ppp(fd) if (i != fd && i != sockfd) close(i); closed_stdio = 1; + /* make sure 0, 1, 2 are open to /dev/null */ + while ((i = open("/dev/null", O_RDWR)) >= 0) { + if (i > 2) { + close(i); + break; + } + } } /* @@ -802,11 +810,13 @@ wait_loop_output(timo) wait_input(timo); } +#endif + /* * wait_time - wait for a given length of time or until a - * signal is received. + * signal is received. Called by ccp_test */ -void +static void wait_time(timo) struct timeval *timo; { @@ -816,7 +826,6 @@ wait_time(timo) if (n < 0 && errno != EINTR) fatal("select: %m"); } -#endif /* * read_packet - get a PPP packet from the serial device. @@ -837,7 +846,7 @@ read_packet(buf) flags = 0; len = getmsg(pppfd, &ctrl, &data, &flags); if (len < 0) { - if (errno = EAGAIN || errno == EWOULDBLOCK || errno == EINTR) + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) return -1; fatal("Error reading packet: %m"); } @@ -1113,6 +1122,7 @@ sifdown(u) { struct ifreq ifr; + bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface down (get): %m"); @@ -1205,7 +1215,8 @@ sifaddr(u, o, h, m) ret = 0; } - ifr.ifr_metric = link_mtu; + ifr.ifr_data = (caddr_t)&link_mtu; + if (ioctl(sockfd, SIOCSIPMTU, &ifr) < 0) { error("Couldn't set IP MTU: %m"); ret = 0; @@ -1524,61 +1535,7 @@ GetMask(addr) */ int have_route_to(u_int32_t addr) { - char buf[sizeof(struct rt_msghdr) + (sizeof(struct sockaddr_in))]; - int status; - int s, n; - struct rt_msghdr *rtm; - struct sockaddr_in *sin; - int msglen = sizeof(*rtm) + (sizeof(*sin)); - char *cp; - char msg[2048]; - - rtm = (struct rt_msghdr *)buf; - memset(rtm, 0, msglen); - rtm->rtm_msglen = msglen; - rtm->rtm_version = RTM_VERSION; - rtm->rtm_type = RTM_GET; - rtm->rtm_addrs = RTA_DST; - /* rtm->rtm_addrs, rtm_flags should be set on output */ - - sin = (struct sockaddr_in *)((u_char *)rtm + sizeof(*rtm)); - sin->sin_len = sizeof(*sin); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = addr; - - status = 0; - - if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) - return -1; - if (write(s, (char *)rtm, msglen) != msglen) { - close(s); - return status == ESRCH? 0: -1; - } - - n = read(s, msg, 2048); - close(s); - if (n <= 0) - return -1; - - rtm = (struct rt_msghdr *) msg; - if (rtm->rtm_version != RTM_VERSION) - return -1; - - /* here we try to work out if the route is through our own interface */ - cp = (char *)(rtm + 1); - if (rtm->rtm_addrs & RTA_DST) { - struct sockaddr *sa = (struct sockaddr *) cp; - cp = (char *)(((unsigned long)cp + sa->sa_len - + sizeof(long) - 1) & ~(sizeof(long) - 1)); - } - if (rtm->rtm_addrs & RTA_GATEWAY) { - sin = (struct sockaddr_in *) cp; - if (sin->sin_addr.s_addr == ifaddrs[0] - || sin->sin_addr.s_addr == ifaddrs[1]) - return 0; /* route is through our interface */ - } - - return 1; + return -1; } static int