]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-bsd.c
add log level arg for log_packet; added optional packet filtering
[ppp.git] / pppd / sys-bsd.c
index 12754a5d32c75623e8683db17293ea7e7e8d046e..0aee267b6b652fcbefddbbfbaf71b2fd38b8dc30 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #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.28 1997/04/30 05:57:46 paulus Exp $";
 #endif
 
 /*
@@ -42,6 +42,13 @@ static char rcsid[] = "$Id: sys-bsd.c,v 1.24 1996/04/04 04:05:34 paulus Exp $";
 #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>
@@ -55,6 +62,8 @@ static char rcsid[] = "$Id: sys-bsd.c,v 1.24 1996/04/04 04:05:34 paulus Exp $";
 #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 */
@@ -91,11 +100,6 @@ static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
 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");
@@ -124,7 +128,7 @@ sys_cleanup()
     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);
 }
@@ -140,7 +144,6 @@ sys_close()
        close(loop_slave);
        close(loop_master);
     }
-    closelog();
 }
 
 /*
@@ -151,21 +154,6 @@ 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));
-    }
-}
-
 /*
  * ppp_available - check whether the system has any ppp interfaces
  * (in fact we check whether we can do an ioctl on ppp0).
@@ -543,7 +531,7 @@ output(unit, p, len)
     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)
@@ -813,6 +801,7 @@ get_idle_time(u, ip)
 }
 
 
+#ifdef PPP_FILTER
 /*
  * set_filters - transfer the pass and active filters to the kernel.
  */
@@ -836,7 +825,7 @@ set_filters(pass, active)
     }
     return ret;
 }
-
+#endif
 
 /*
  * sifvjcomp - config tcp header compression
@@ -857,7 +846,7 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid)
        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;
     }
@@ -872,7 +861,6 @@ sifup(u)
     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) {
@@ -885,12 +873,6 @@ sifup(u)
        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;
 }
 
@@ -981,7 +963,8 @@ sifaddr(u, o, h, 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;
@@ -1018,9 +1001,9 @@ cifaddr(u, o, 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');
 }
@@ -1029,9 +1012,9 @@ sifdefaultroute(u, g)
  * 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');
 }