*/
#ifndef lint
-static char rcsid[] = "$Id: sys-sunos4.c,v 1.14 1999/03/16 02:57:07 paulus Exp $";
+static char rcsid[] = "$Id: sys-sunos4.c,v 1.18 1999/03/22 05:55:39 paulus Exp $";
#endif
#include <stdio.h>
/*
* establish_ppp - Turn the serial port into a ppp interface.
*/
-void
+int
establish_ppp(fd)
int fd;
{
/* Link the serial port under the PPP multiplexor. */
if ((fdmuxid = ioctl(pppfd, I_LINK, fd)) < 0)
fatal("Can't link tty to PPP mux: %m");
+
+ return pppfd;
}
/*
/*
* open_loopback - open the device we use for getting packets
- * in demand mode. Under Solaris 2, we use our existing fd
+ * in demand mode. Under SunOS, we use our existing fd
* to the ppp driver.
*/
-void
+int
open_ppp_loopback()
{
+ return pppfd;
}
/*
fatal("poll: %m");
}
+/*
+ * add_fd - add an fd to the set that wait_input waits for.
+ */
+void add_fd(fd)
+ int fd;
+{
+ int n;
+
+ for (n = 0; n < n_pollfds; ++n)
+ if (pollfds[n].fd == fd)
+ return;
+ if (n_pollfds < MAX_POLLFDS) {
+ pollfds[n_pollfds].fd = fd;
+ pollfds[n_pollfds].events = POLLIN | POLLPRI | POLLHUP;
+ ++n_pollfds;
+ } else
+ error("Too many inputs!");
+}
+
+/*
+ * remove_fd - remove an fd from the set that wait_input waits for.
+ */
+void remove_fd(fd)
+ int fd;
+{
+ int n;
+
+ for (n = 0; n < n_pollfds; ++n) {
+ if (pollfds[n].fd == fd) {
+ while (++n < n_pollfds)
+ pollfds[n-1] = pollfds[n];
+ --n_pollfds;
+ break;
+ }
+ }
+}
+
+#if 0
/*
* wait_loop_output - wait until there is data available on the
* loopback, for the length of time specified by *timo (indefinite
if (n < 0 && errno != EINTR)
fatal("select: %m");
}
-
+#endif
/*
* read_packet - get a PPP packet from the serial device.
/* set mtu for ip as well */
memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_metric = link_mtu;
if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) {
error("Couldn't set IP MTU: %m");
return strioctl(pppfd, PPPIO_GIDLE, ip, 0, sizeof(struct ppp_idle)) >= 0;
}
+/*
+ * get_ppp_stats - return statistics for the link.
+ */
+int
+get_ppp_stats(u, stats)
+ int u;
+ struct pppd_stats *stats;
+{
+ struct ppp_stats s;
+
+ if (strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
+ error("Couldn't get link statistics: %m");
+ return 0;
+ }
+ stats->bytes_in = s.p.ppp_ibytes;
+ stats->bytes_out = s.p.ppp_obytes;
+ return 1;
+}
+
/*
* ccp_fatal_error - returns 1 if decompression was disabled as a
{
struct ifreq ifr;
- strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
error("Couldn't mark interface up (get): %m");
return 0;
{
struct ifreq ifr;
- strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
error("Couldn't mark interface down (get): %m");
return 0;
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_addr.sa_family = AF_INET;
INET_ADDR(ifr.ifr_addr) = m;
if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
* Check that the interface is up, and not point-to-point
* or loopback.
*/
- strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
+ strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
error("Couldn't open /dev/nit: %m");
return 0;
}
- strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
+ strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
if (ioctl(nit_fd, NIOCBIND, &ifreq) < 0
|| ioctl(nit_fd, SIOCGIFADDR, &ifreq) < 0) {
error("Couldn't get hardware address for %s: %m",
if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
return;
if (!fstat(fd, &buf)) {
- strlcpy(ut.ut_line, sizeof(ut.ut_line), line);
- strlcpy(ut.ut_name, sizeof(ut.ut_name), name);
- strlcpy(ut.ut_host, sizeof(ut.ut_host), host);
+ strlcpy(ut.ut_line, line, sizeof(ut.ut_line));
+ strlcpy(ut.ut_name, name, sizeof(ut.ut_name));
+ strlcpy(ut.ut_host, host, sizeof(ut.ut_host));
(void)time(&ut.ut_time);
if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
(void)ftruncate(fd, buf.st_size);
/*
* Check that the interface is up, and not point-to-point or loopback.
*/
- strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name);
+ strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))