*/
#ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.24 1996/04/04 04:05:34 paulus Exp $";
+static char rcsid[] = "$Id: sys-bsd.c,v 1.34 1998/11/07 06:59:30 paulus Exp $";
+/* $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */
#endif
/*
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/stat.h>
+#include <sys/param.h>
+#ifdef NetBSD1_2
+#include <util.h>
+#endif
+#ifdef PPP_FILTER
+#include <net/bpf.h>
+#endif
#include <net/if.h>
#include <net/ppp_defs.h>
#include <netinet/in.h>
#if RTM_VERSION >= 3
+#include <sys/param.h>
+#if defined(NetBSD) && (NetBSD >= 199703)
+#include <netinet/if_inarp.h>
+#else /* NetBSD 1.2D or later */
+#ifdef __FreeBSD__
#include <netinet/if_ether.h>
+#else
+#include <net/if_ether.h>
+#endif
+#endif
#endif
#include "pppd.h"
+#include "fsm.h"
+#include "ipcp.h"
static int initdisc = -1; /* Initial TTY discipline for ppp_fd */
static int initfdflags = -1; /* Initial file descriptor flags for ppp_fd */
void
sys_init()
{
- openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
- setlogmask(LOG_UPTO(LOG_INFO));
- if (debug)
- setlogmask(LOG_UPTO(LOG_DEBUG));
-
/* Get an internet socket for doing socket ioctl's on. */
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
syslog(LOG_ERR, "Couldn't create IP socket: %m");
if (ifaddrs[0] != 0)
cifaddr(0, ifaddrs[0], ifaddrs[1]);
if (default_route_gateway)
- cifdefaultroute(0, default_route_gateway);
+ cifdefaultroute(0, 0, default_route_gateway);
if (proxy_arp_addr)
cifproxyarp(0, proxy_arp_addr);
}
close(loop_slave);
close(loop_master);
}
- closelog();
}
/*
* sys_check_options - check the options that the user specified
*/
-void
+int
sys_check_options()
{
-}
-
-
-/*
- * note_debug_level - note a change in the debug level.
- */
-void
-note_debug_level()
-{
- if (debug) {
- syslog(LOG_INFO, "Debug turned ON, Level %d", debug);
- setlogmask(LOG_UPTO(LOG_DEBUG));
- } else {
- setlogmask(LOG_UPTO(LOG_WARNING));
+#ifndef CDTRCTS
+ if (crtscts == 2) {
+ syslog(LOG_WARNING, "DTR/CTS flow control is not supported on this system");
+ return 0;
}
+#endif
+ return 1;
}
/*
}
tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
- if (crtscts > 0 && !local)
- tios.c_cflag |= CRTSCTS;
- else if (crtscts < 0)
+ if (crtscts > 0 && !local) {
+ if (crtscts == 2) {
+#ifdef CDTRCTS
+ tios.c_cflag |= CDTRCTS;
+#endif
+ } else
+ tios.c_cflag |= CRTSCTS;
+ } else if (crtscts < 0) {
tios.c_cflag &= ~CRTSCTS;
+#ifdef CDTRCTS
+ tios.c_cflag &= ~CDTRCTS;
+#endif
+ }
tios.c_cflag |= CS8 | CREAD | HUPCL;
if (local || !modem)
int len;
{
if (debug)
- log_packet(p, len, "sent ");
+ log_packet(p, len, "sent ", LOG_DEBUG);
if (write(ttyfd, p, len) < 0) {
if (errno != EIO)
}
+#ifdef PPP_FILTER
/*
* set_filters - transfer the pass and active filters to the kernel.
*/
}
return ret;
}
-
+#endif
/*
* sifvjcomp - config tcp header compression
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
return 0;
}
- if (ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
+ if (vjcomp && ioctl(ppp_fd, PPPIOCSMAXCID, (caddr_t) &maxcid) < 0) {
syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
return 0;
}
int u;
{
struct ifreq ifr;
- struct npioctl npi;
strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
return 0;
}
if_is_up = 1;
- npi.protocol = PPP_IP;
- npi.mode = NPMODE_PASS;
- if (ioctl(ppp_fd, PPPIOCSNPMODE, &npi) < 0) {
- syslog(LOG_ERR, "ioctl(set IP mode to PASS): %m");
- return 0;
- }
return 1;
}
u_int32_t o, h, m;
{
struct ifaliasreq ifra;
+ struct ifreq ifr;
strncpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name));
SET_SA_FAMILY(ifra.ifra_addr, AF_INET);
((struct sockaddr_in *) &ifra.ifra_mask)->sin_addr.s_addr = m;
} else
BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
+ BZERO(&ifr, sizeof(ifr));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) {
+ if (errno != EADDRNOTAVAIL)
+ syslog(LOG_WARNING, "Couldn't remove interface address: %m");
+ }
if (ioctl(sockfd, SIOCAIFADDR, (caddr_t) &ifra) < 0) {
if (errno != EEXIST) {
syslog(LOG_ERR, "Couldn't set interface address: %m");
return 0;
}
syslog(LOG_WARNING,
- "Couldn't set interface address: Address already exists");
+ "Couldn't set interface address: Address %s already exists",
+ ip_ntoa(o));
}
ifaddrs[0] = o;
ifaddrs[1] = h;
* sifdefaultroute - assign a default route through the address given.
*/
int
-sifdefaultroute(u, g)
+sifdefaultroute(u, l, g)
int u;
- u_int32_t g;
+ u_int32_t l, g;
{
return dodefaultroute(g, 's');
}
* cifdefaultroute - delete a default route through the address given.
*/
int
-cifdefaultroute(u, g)
+cifdefaultroute(u, l, g)
int u;
- u_int32_t g;
+ u_int32_t l, g;
{
return dodefaultroute(g, 'c');
}
memset(&rtmsg, 0, sizeof(rtmsg));
rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE;
- rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY;
+ rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
rtmsg.hdr.rtm_version = RTM_VERSION;
rtmsg.hdr.rtm_seq = ++rtm_seq;
rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
return mask;
}
+/*
+ * Use the hostid as part of the random number seed.
+ */
+int
+get_host_seed()
+{
+ return gethostid();
+}
+
/*
* lock - create a lock file for the named lock device
*/