]> git.ozlabs.org Git - ppp.git/commitdiff
Merge branch 'pppd_print_changes' of https://github.com/nlhintz/ppp into nlhintz...
authorPaul Mackerras <paulus@ozlabs.org>
Sat, 23 Jun 2018 10:36:22 +0000 (20:36 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 23 Jun 2018 10:36:22 +0000 (20:36 +1000)
22 files changed:
chat/Makefile.linux
pppd/Makefile.linux
pppd/auth.c
pppd/fsm.c
pppd/main.c
pppd/options.c
pppd/plugins/Makefile.linux
pppd/plugins/pppoatm/Makefile.linux
pppd/plugins/pppol2tp/Makefile.linux
pppd/plugins/radius/Makefile.linux
pppd/plugins/radius/radius.c
pppd/plugins/rp-pppoe/Makefile.linux
pppd/plugins/rp-pppoe/pppoe-discovery.c
pppd/plugins/rp-pppoe/pppoe.h
pppd/pppcrypt.c
pppd/pppd.8
pppd/pppd.h
pppd/sys-linux.c
pppdump/Makefile.linux
pppstats/Makefile.linux
pppstats/pppstats.c
scripts/plog

index 1065ac51957632606a777711f222887a5f6a98d8..0732ec80dc2736431b1ec9178411ff0bd9e3d100 100644 (file)
@@ -18,7 +18,7 @@ INSTALL= install
 all:   chat
 
 chat:  chat.o
-       $(CC) -o chat chat.o
+       $(CC) $(LDFLAGS) -o chat chat.o
 
 chat.o:        chat.c
        $(CC) -c $(CFLAGS) -o chat.o chat.c
index a74c914fd3acf84dbcaac360e6f5cabd3582f802..8d5ce99d92202c4326730393c0d9e56d327fbefe 100644 (file)
@@ -35,10 +35,10 @@ endif
 COPTS = -O2 -pipe -Wall -g
 LIBS =
 
-# Uncomment the next 2 lines to include support for Microsoft's
+# Uncomment the next line to include support for Microsoft's
 # MS-CHAP authentication protocol.  Also, edit plugins/radius/Makefile.linux.
 CHAPMS=y
-USE_CRYPT=y
+#USE_CRYPT=y
 # Don't use MSLANMAN unless you really know what you're doing.
 #MSLANMAN=y
 # Uncomment the next line to include support for MPPE.  CHAPMS (above) must
@@ -60,6 +60,11 @@ HAVE_MULTILINK=y
 # Linux distributions: Please leave TDB ENABLED in your builds.
 USE_TDB=y
 
+# Uncomment the next line to enable Type=notify services in systemd
+# If enabled, and the user sets the up_sdnotify option, then
+# pppd will not detach and will notify systemd when up.
+#SYSTEMD=y
+
 HAS_SHADOW=y
 #USE_PAM=y
 HAVE_INET6=y
@@ -132,7 +137,8 @@ endif
 
 ifdef NEEDDES
 ifndef USE_CRYPT
-LIBS     += -ldes $(LIBS)
+CFLAGS   += -I/usr/include/openssl
+LIBS     += -lcrypto
 else
 CFLAGS   += -DUSE_CRYPT=1
 endif
@@ -170,9 +176,14 @@ LIBS     += -llock
 CFLAGS   += -DLOCKLIB=1
 endif
 
+ifdef SYSTEMD
+LIBS += -lsystemd
+CFLAGS   += -DSYSTEMD=1
+endif
+
 ifdef PLUGIN
 CFLAGS += -DPLUGIN
-LDFLAGS        += -Wl,-E
+LDFLAGS_PLUGIN += -Wl,-E
 LIBS   += -ldl
 endif
 
@@ -214,7 +225,7 @@ install: pppd
        $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
 
 pppd: $(PPPDOBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_PLUGIN) -o pppd $(PPPDOBJS) $(LIBS)
 
 srp-entry:     srp-entry.c
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)
index 4271af687102dc62e3c2e3b47d3fc8ab1d70d0f8..7457eda227bf19c2d09b79dd4e0b031da6bc1bf9 100644 (file)
 #endif
 #include <time.h>
 
+#ifdef SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
+
 #include "pppd.h"
 #include "fsm.h"
 #include "lcp.h"
@@ -1099,8 +1103,15 @@ np_up(unit, proto)
        /*
         * Detach now, if the updetach option was given.
         */
-       if (updetach && !nodetach)
+       if (updetach && !nodetach) {
+           dbglog("updetach is set. Now detaching.");
            detach();
+#ifdef SYSTEMD
+       } else if (nodetach && up_sdnotify) {
+           dbglog("up_sdnotify is set. Now notifying systemd: READY=1");
+           sd_notify(0, "READY=1");
+#endif
+       }
     }
     ++num_np_up;
 }
index c200cc3a84387cefc952bdd37bac6650bf32161d..e9bd34f0e8f48fd0da69e4ffea3349691975f435 100644 (file)
@@ -468,7 +468,7 @@ fsm_rconfreq(f, id, inp, len)
        f->nakloops = 0;
 
     } else {
-       /* we sent CONFACK or CONFREJ */
+       /* we sent CONFNAK or CONFREJ */
        if (f->state != ACKRCVD)
            f->state = REQSENT;
        if( code == CONFNAK )
index 6d50d1bac1d998e7ad359a1ec4e35852e3739e1d..e09b6ffcce32bd06389d91da6276f24c1e009007 100644 (file)
 static const char rcsid[] = RCSID;
 
 /* interface vars */
-char ifname[32];               /* Interface name */
+char ifname[MAXIFNAMELEN];     /* Interface name */
 int ifunit;                    /* Interface unit number */
 
 struct channel *the_channel;
@@ -257,7 +257,6 @@ static void cleanup_db __P((void));
 static void handle_events __P((void));
 void print_link_stats __P((void));
 
-extern char    *ttyname __P((int));
 extern char    *getlogin __P((void));
 int main __P((int, char *[]));
 
@@ -298,13 +297,6 @@ struct protent *protocols[] = {
     NULL
 };
 
-/*
- * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
- */
-#if !defined(PPP_DRV_NAME)
-#define PPP_DRV_NAME   "ppp"
-#endif /* !defined(PPP_DRV_NAME) */
-
 int
 main(argc, argv)
     int argc;
@@ -737,8 +729,11 @@ void
 set_ifunit(iskey)
     int iskey;
 {
-    info("Using interface %s%d", PPP_DRV_NAME, ifunit);
-    slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
+    if (req_ifname[0] != '\0')
+       slprintf(ifname, sizeof(ifname), "%s", req_ifname);
+    else
+       slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
+    info("Using interface %s", ifname);
     script_setenv("IFNAME", ifname, iskey);
     if (iskey) {
        create_pidfile(getpid());       /* write pid to file */
@@ -1756,7 +1751,7 @@ update_script_environment()
                script_env[i] = newstring;
            else
                add_script_env(i, newstring);
-       } else {
+       } else if (p != NULL) {
            remove_script_env(i);
        }
     }
index 36cf47fb9338948fb225707c85c9b7ed7f280143..5db580a0e270c0628fb99d1400423599a1f0ce5e 100644 (file)
@@ -97,6 +97,9 @@ char  devnam[MAXPATHLEN];     /* Device name */
 bool   nodetach = 0;           /* Don't detach from controlling tty */
 bool   updetach = 0;           /* Detach once link is up */
 bool   master_detach;          /* Detach when we're (only) multilink master */
+#ifdef SYSTEMD
+bool   up_sdnotify = 0;        /* Notify systemd once link is up */
+#endif
 int    maxconnect = 0;         /* Maximum connect time */
 char   user[MAXNAMELEN];       /* Username for PAP */
 char   passwd[MAXSECRETLEN];   /* Password for PAP */
@@ -114,6 +117,7 @@ char        linkname[MAXPATHLEN];   /* logical name for link */
 bool   tune_kernel;            /* may alter kernel settings */
 int    connect_delay = 1000;   /* wait this many ms after connect script */
 int    req_unit = -1;          /* requested interface unit */
+char   req_ifname[MAXIFNAMELEN];       /* requested interface name */
 bool   multilink = 0;          /* Enable multilink operation */
 char   *bundle_name = NULL;    /* bundle name for multilink */
 bool   dump_options;           /* print out option values */
@@ -208,6 +212,11 @@ option_t general_options[] = {
       "Don't detach from controlling tty", OPT_PRIO | 1 },
     { "-detach", o_bool, &nodetach,
       "Don't detach from controlling tty", OPT_ALIAS | OPT_PRIOSUB | 1 },
+#ifdef SYSTEMD
+    { "up_sdnotify", o_bool, &up_sdnotify,
+      "Notify systemd once link is up (implies nodetach)",
+      OPT_PRIOSUB | OPT_A2COPY | 1, &nodetach },
+#endif
     { "updetach", o_bool, &updetach,
       "Detach from controlling tty once link is up",
       OPT_PRIOSUB | OPT_A2CLR | 1, &nodetach },
@@ -284,6 +293,10 @@ option_t general_options[] = {
       "PPP interface unit number to use if possible",
       OPT_PRIO | OPT_LLIMIT, 0, 0 },
 
+    { "ifname", o_string, req_ifname,
+      "Set PPP interface name",
+      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
+
     { "dump", o_bool, &dump_options,
       "Print out option values after parsing all options", 1 },
     { "dryrun", o_bool, &dryrun,
@@ -1740,7 +1753,7 @@ user_unsetenv(argv)
        option_error("unexpected = in name: %s", arg);
        return 0;
     }
-    if (arg == '\0') {
+    if (*arg == '\0') {
        option_error("missing variable name for unset");
        return 0;
     }
index 8a90e393a0578fd4885bfda0fabfd688735eeaf5..af5384381cb07c27fa4043824f80b6ab69807fa9 100644 (file)
@@ -1,7 +1,7 @@
 #CC    = gcc
 COPTS  = -O2 -g
 CFLAGS = $(COPTS) -I.. -I../../include -fPIC
-LDFLAGS        = -shared
+LDFLAGS_SHARED = -shared
 INSTALL        = install
 
 DESTDIR = $(INSTROOT)@DESTDIR@
@@ -30,7 +30,7 @@ all:  $(PLUGINS)
        for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d all || exit $$?; done
 
 %.so: %.c
-       $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^
+       $(CC) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) $(CFLAGS) $^
 
 VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)
 
index 20f62e631d23c18361ce3164c2fbe2179d0abe90..59dde0e1643266230057fbbb82eaa5e986d03d05 100644 (file)
@@ -1,7 +1,7 @@
 #CC    = gcc
 COPTS  = -O2 -g
 CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
-LDFLAGS        = -shared
+LDFLAGS_SHARED = -shared
 INSTALL        = install
 
 #***********************************************************************
@@ -33,7 +33,7 @@ endif
 all: $(PLUGIN)
 
 $(PLUGIN): $(PLUGIN_OBJS)
-       $(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)
 
 install: all
        $(INSTALL) -d -m 755 $(LIBDIR)
index ea3538e22d56a9299614d64094fbdb43a2eab004..7981a9549a4ad5f40d2a686dd909d6f976ace5b8 100644 (file)
@@ -1,7 +1,7 @@
 #CC    = gcc
 COPTS  = -O2 -g
 CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC
-LDFLAGS        = -shared
+LDFLAGS_SHARED = -shared
 INSTALL        = install
 
 #***********************************************************************
@@ -16,7 +16,7 @@ PLUGINS := pppol2tp.so openl2tp.so
 all: $(PLUGINS)
 
 %.so: %.o
-       $(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)
 
 install: all
        $(INSTALL) -d -m 755 $(LIBDIR)
index 24ed3e580c4db6aeca129dd22dbe6de5f2d1ff5f..e7022636906d8219d75165fda6ffccda695c9fe0 100644 (file)
@@ -43,13 +43,13 @@ install: all
        $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
 
 radius.so: radius.o libradiusclient.a
-       $(CC) -o radius.so -shared radius.o libradiusclient.a
+       $(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a
 
 radattr.so: radattr.o
-       $(CC) -o radattr.so -shared radattr.o
+       $(CC) $(LDFLAGS) -o radattr.so -shared radattr.o
 
 radrealms.so: radrealms.o
-       $(CC) -o radrealms.so -shared radrealms.o
+       $(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o
 
 CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \
        clientid.o sendserver.o lock.o util.o md5.o
index 4ba5f523ea0748af986aec1257ea9263e8fafe74..fbf872006005b59ca5472f73b1a5c1b69007bef4 100644 (file)
@@ -996,6 +996,10 @@ radius_acct_stop(void)
 
     rc_avpair_add(&send, PW_USER_NAME, rstate.user, 0, VENDOR_NONE);
 
+    if (rstate.class_len > 0)
+       rc_avpair_add(&send, PW_CLASS,
+                     rstate.class, rstate.class_len, VENDOR_NONE);
+
     av_type = PW_STATUS_STOP;
     rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0, VENDOR_NONE);
 
@@ -1140,6 +1144,10 @@ radius_acct_interim(void *ignored)
 
     rc_avpair_add(&send, PW_USER_NAME, rstate.user, 0, VENDOR_NONE);
 
+    if (rstate.class_len > 0)
+       rc_avpair_add(&send, PW_CLASS,
+                     rstate.class, rstate.class_len, VENDOR_NONE);
+
     av_type = PW_STATUS_ALIVE;
     rc_avpair_add(&send, PW_ACCT_STATUS_TYPE, &av_type, 0, VENDOR_NONE);
 
index 5d7a2719545d2e52f4f9b62ea51dff2697b736d6..9803aeb4ebbae07bb7d8a527f942b753eb5b404e 100644 (file)
@@ -30,7 +30,7 @@ CFLAGS=$(COPTS) -I../../../include '-DRP_VERSION="$(RP_VERSION)"'
 all: rp-pppoe.so pppoe-discovery
 
 pppoe-discovery: pppoe-discovery.o debug.o
-       $(CC) -o pppoe-discovery pppoe-discovery.o debug.o
+       $(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
 
 pppoe-discovery.o: pppoe-discovery.c
        $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c
@@ -39,7 +39,7 @@ debug.o: debug.c
        $(CC) $(CFLAGS) -c -o debug.o debug.c
 
 rp-pppoe.so: plugin.o discovery.o if.o common.o
-       $(CC) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
+       $(CC) $(LDFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
 
 install: all
        $(INSTALL) -d -m 755 $(LIBDIR)
index 3d3bf4eecc816c59aad3aee24b94944150593147..bce71fce04f459b02053cba4c4d95b10a0206f4b 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -55,6 +56,14 @@ void die(int status)
        exit(status);
 }
 
+void error(char *fmt, ...)
+{
+    va_list pvar;
+    va_start(pvar, fmt);
+    vfprintf(stderr, fmt, pvar);
+    va_end(pvar);
+}
+
 /* Initialize frame types to RFC 2516 values.  Some broken peers apparently
    use different frame types... sigh... */
 
@@ -378,7 +387,9 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data,
     switch(type) {
     case TAG_AC_NAME:
        pc->seenACName = 1;
-       printf("Access-Concentrator: %.*s\n", (int) len, data);
+       if (conn->printACNames) {
+           printf("Access-Concentrator: %.*s\n", (int) len, data);
+       }
        if (conn->acName && len == strlen(conn->acName) &&
            !strncmp((char *) data, conn->acName, len)) {
            pc->acNameOK = 1;
@@ -386,7 +397,7 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data,
        break;
     case TAG_SERVICE_NAME:
        pc->seenServiceName = 1;
-       if (len > 0) {
+       if (conn->printACNames && len > 0) {
            printf("       Service-Name: %.*s\n", (int) len, data);
        }
        if (conn->serviceName && len == strlen(conn->serviceName) &&
@@ -395,37 +406,47 @@ parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data,
        }
        break;
     case TAG_AC_COOKIE:
-       printf("Got a cookie:");
-       /* Print first 20 bytes of cookie */
-       for (i=0; i<len && i < 20; i++) {
-           printf(" %02x", (unsigned) data[i]);
+       if (conn->printACNames) {
+           printf("Got a cookie:");
+           /* Print first 20 bytes of cookie */
+           for (i=0; i<len && i < 20; i++) {
+               printf(" %02x", (unsigned) data[i]);
+           }
+           if (i < len) printf("...");
+           printf("\n");
        }
-       if (i < len) printf("...");
-       printf("\n");
        conn->cookie.type = htons(type);
        conn->cookie.length = htons(len);
        memcpy(conn->cookie.payload, data, len);
        break;
     case TAG_RELAY_SESSION_ID:
-       printf("Got a Relay-ID:");
-       /* Print first 20 bytes of relay ID */
-       for (i=0; i<len && i < 20; i++) {
-           printf(" %02x", (unsigned) data[i]);
+       if (conn->printACNames) {
+           printf("Got a Relay-ID:");
+           /* Print first 20 bytes of relay ID */
+           for (i=0; i<len && i < 20; i++) {
+               printf(" %02x", (unsigned) data[i]);
+           }
+           if (i < len) printf("...");
+           printf("\n");
        }
-       if (i < len) printf("...");
-       printf("\n");
        conn->relayId.type = htons(type);
        conn->relayId.length = htons(len);
        memcpy(conn->relayId.payload, data, len);
        break;
     case TAG_SERVICE_NAME_ERROR:
-       printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
+       if (conn->printACNames) {
+           printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
+       }
        break;
     case TAG_AC_SYSTEM_ERROR:
-       printf("Got a System-Error tag: %.*s\n", (int) len, data);
+       if (conn->printACNames) {
+           printf("Got a System-Error tag: %.*s\n", (int) len, data);
+       }
        break;
     case TAG_GENERIC_ERROR:
-       printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
+       if (conn->printACNames) {
+           printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
+       }
        break;
     }
 }
@@ -581,7 +602,6 @@ waitForPADO(PPPoEConnection *conn, int timeout)
                continue;
            }
            conn->numPADOs++;
-           printf("--------------------------------------------------\n");
            if (pc.acNameOK && pc.serviceNameOK) {
                memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN);
                if (conn->printACNames) {
@@ -592,6 +612,7 @@ waitForPADO(PPPoEConnection *conn, int timeout)
                           (unsigned) conn->peerEth[3],
                           (unsigned) conn->peerEth[4],
                           (unsigned) conn->peerEth[5]);
+                   printf("--------------------------------------------------\n");
                    continue;
                }
                conn->discoveryState = STATE_RECEIVED_PADO;
@@ -614,14 +635,14 @@ void
 discovery(PPPoEConnection *conn)
 {
     int padiAttempts = 0;
-    int timeout = PADI_TIMEOUT;
+    int timeout = conn->discoveryTimeout;
 
     conn->discoverySocket =
        openInterface(conn->ifName, Eth_PPPOE_Discovery, conn->myEth);
 
     do {
        padiAttempts++;
-       if (padiAttempts > MAX_PADI_ATTEMPTS) {
+       if (padiAttempts > conn->discoveryAttempts) {
            fprintf(stderr, "Timeout waiting for PADO packets\n");
            close(conn->discoverySocket);
            conn->discoverySocket = -1;
@@ -644,7 +665,11 @@ int main(int argc, char *argv[])
 
     memset(conn, 0, sizeof(PPPoEConnection));
 
-    while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
+    conn->printACNames = 1;
+    conn->discoveryTimeout = PADI_TIMEOUT;
+    conn->discoveryAttempts = MAX_PADI_ATTEMPTS;
+
+    while ((opt = getopt(argc, argv, "I:D:VUQS:C:t:a:h")) > 0) {
        switch(opt) {
        case 'S':
            conn->serviceName = xstrdup(optarg);
@@ -652,6 +677,24 @@ int main(int argc, char *argv[])
        case 'C':
            conn->acName = xstrdup(optarg);
            break;
+       case 't':
+           if (sscanf(optarg, "%d", &conn->discoveryTimeout) != 1) {
+               fprintf(stderr, "Illegal argument to -t: Should be -t timeout\n");
+               exit(EXIT_FAILURE);
+           }
+           if (conn->discoveryTimeout < 1) {
+               conn->discoveryTimeout = 1;
+           }
+           break;
+       case 'a':
+           if (sscanf(optarg, "%d", &conn->discoveryAttempts) != 1) {
+               fprintf(stderr, "Illegal argument to -a: Should be -a attempts\n");
+               exit(EXIT_FAILURE);
+           }
+           if (conn->discoveryAttempts < 1) {
+               conn->discoveryAttempts = 1;
+           }
+           break;
        case 'U':
            conn->useHostUniq = 1;
            break;
@@ -667,8 +710,8 @@ int main(int argc, char *argv[])
        case 'I':
            conn->ifName = xstrdup(optarg);
            break;
-       case 'A':
-           /* this is the default */
+       case 'Q':
+           conn->printACNames = 0;
            break;
        case 'V':
        case 'h':
@@ -686,10 +729,13 @@ int main(int argc, char *argv[])
 
     conn->discoverySocket = -1;
     conn->sessionSocket = -1;
-    conn->printACNames = 1;
 
     discovery(conn);
-    exit(0);
+
+    if (!conn->numPADOs)
+       exit(1);
+    else
+       exit(0);
 }
 
 void rp_fatal(char const *str)
@@ -720,5 +766,17 @@ char *xstrdup(const char *s)
 void usage(void)
 {
     fprintf(stderr, "Usage: pppoe-discovery [options]\n");
+    fprintf(stderr, "Options:\n");
+    fprintf(stderr, "   -I if_name     -- Specify interface (default eth0)\n");
+    fprintf(stderr, "   -D filename    -- Log debugging information in filename.\n");
+    fprintf(stderr,
+           "   -t timeout     -- Initial timeout for discovery packets in seconds\n"
+           "   -a attempts    -- Number of discovery attempts\n"
+           "   -V             -- Print version and exit.\n"
+           "   -Q             -- Quit Mode: Do not print access concentrator names\n"
+           "   -S name        -- Set desired service name.\n"
+           "   -C name        -- Set desired access concentrator name.\n"
+           "   -U             -- Use Host-Unique to allow multiple PPPoE sessions.\n"
+           "   -h             -- Print usage information.\n");
     fprintf(stderr, "\nVersion " RP_VERSION "\n");
 }
index 9ab2eee3914c3718daa055375f32095beaa8a8f5..813dcf368cf3369ff48a94db10b5e5b028716175 100644 (file)
 #include <sys/socket.h>
 #endif
 
+/* This has to be included before Linux 4.8's linux/in.h
+ * gets dragged in. */
+#include <netinet/in.h>
+
 /* Ugly header files on some Linux boxes... */
 #if defined(HAVE_LINUX_IF_H)
 #include <linux/if.h>
@@ -84,8 +88,6 @@ typedef unsigned long UINT32_t;
 #include <linux/if_ether.h>
 #endif
 
-#include <netinet/in.h>
-
 #ifdef HAVE_NETINET_IF_ETHER_H
 #include <sys/types.h>
 
@@ -98,7 +100,6 @@ typedef unsigned long UINT32_t;
 #endif
 
 
-
 /* Ethernet frame types according to RFC 2516 */
 #define ETH_PPPOE_DISCOVERY 0x8863
 #define ETH_PPPOE_SESSION   0x8864
@@ -244,6 +245,7 @@ typedef struct PPPoEConnectionStruct {
     int error;                 /* Error packet received */
     int debug;                 /* Set to log packets sent and received */
     int discoveryTimeout;       /* Timeout for discovery packets */
+    int discoveryAttempts;      /* Number of discovery attempts */
     int seenMaxPayload;
     int mtu;                   /* Stored MTU */
     int mru;                   /* Stored MRU */
index 8b85b13276ab30fd51a9ab7ad5352f605453acdb..6b35375edc5e4b1a02485c9630140b32b7de52b7 100644 (file)
@@ -64,7 +64,7 @@ u_char *des_key;      /* OUT 64 bit DES key with parity bits added */
        des_key[7] = Get7Bits(key, 49);
 
 #ifndef USE_CRYPT
-       des_set_odd_parity((des_cblock *)des_key);
+       DES_set_odd_parity((DES_cblock *)des_key);
 #endif
 }
 
@@ -158,25 +158,25 @@ u_char *clear;    /* OUT 8 octets */
 }
 
 #else /* USE_CRYPT */
-static des_key_schedule        key_schedule;
+static DES_key_schedule        key_schedule;
 
 bool
 DesSetkey(key)
 u_char *key;
 {
-       des_cblock des_key;
+       DES_cblock des_key;
        MakeKey(key, des_key);
-       des_set_key(&des_key, key_schedule);
+       DES_set_key(&des_key, &key_schedule);
        return (1);
 }
 
 bool
-DesEncrypt(clear, key, cipher)
+DesEncrypt(clear, cipher)
 u_char *clear; /* IN  8 octets */
 u_char *cipher;        /* OUT 8 octets */
 {
-       des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher,
-           key_schedule, 1);
+       DES_ecb_encrypt((DES_cblock *)clear, (DES_cblock *)cipher,
+           &key_schedule, 1);
        return (1);
 }
 
@@ -185,8 +185,8 @@ DesDecrypt(cipher, clear)
 u_char *cipher;        /* IN  8 octets */
 u_char *clear; /* OUT 8 octets */
 {
-       des_ecb_encrypt((des_cblock *)cipher, (des_cblock *)clear,
-           key_schedule, 0);
+       DES_ecb_encrypt((DES_cblock *)cipher, (DES_cblock *)clear,
+           &key_schedule, 0);
        return (1);
 }
 
index c508d277df3aa5539dd3c0d94787d97f71709956..76a209766f2afc89b8e43187d87c05271f740ae5 100644 (file)
@@ -1079,7 +1079,13 @@ under Linux and FreeBSD 2.2.8 and later.
 .TP
 .B unit \fInum
 Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound
-connections.
+connections.  If the unit is already in use a dynamically allocated number will
+be used.
+.TP
+.B ifname \fIstring
+Set the ppp interface name for outbound connections.  If the interface name is
+already in use, or if the name cannot be used for any other reason, pppd will
+terminate.
 .TP
 .B unset \fIname
 Remove a variable from the environment variable for scripts that are
@@ -1094,6 +1100,15 @@ it has successfully established the ppp connection (to the point where
 the first network control protocol, usually the IP control protocol,
 has come up).
 .TP
+.B up_sdnotify
+Use this option to run pppd in systemd service units of Type=notify
+(\fBup_sdnotify\fR implies \fBnodetach\fR).
+When \fBup_sdnotify\fR is enabled, pppd will notify systemd once
+it has successfully established the ppp connection (to the point where
+the first network control protocl, usually the IP control protocol,
+has come up). This option is only availble when pppd is compiled with
+systemd support.
+.TP
 .B usehostname
 Enforce the use of the hostname (with domain name appended, if given)
 as the name of the local system for authentication purposes (overrides
index 247fa153739b387d217719e6ac1beb8bf407d708..6e3743fd9c97de74caf9638e717aa60525bebabb 100644 (file)
 #define MAXARGS                1       /* max # args to a command */
 #define MAXNAMELEN     256     /* max length of hostname or name for auth */
 #define MAXSECRETLEN   256     /* max length of password or secret */
+#define MAXIFNAMELEN   32      /* max length of interface name; or use IFNAMSIZ, can we
+                                  always include net/if.h? */
+
+/*
+ * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
+ * Where should PPP_DRV_NAME come from? Do we include it here?
+ */
+#if !defined(PPP_DRV_NAME)
+#define PPP_DRV_NAME   "ppp"
+#endif /* !defined(PPP_DRV_NAME) */
 
 /*
  * Option descriptor structure.
@@ -285,6 +295,9 @@ extern int  inspeed;        /* Input/Output speed requested */
 extern u_int32_t netmask;      /* IP netmask to set on interface */
 extern bool    lockflag;       /* Create lock file to lock the serial dev */
 extern bool    nodetach;       /* Don't detach from controlling tty */
+#ifdef SYSTEMD
+extern bool    up_sdnotify;    /* Notify systemd once link is up (implies nodetach) */
+#endif
 extern bool    updetach;       /* Detach from controlling tty when link up */
 extern bool    master_detach;  /* Detach when multilink master without link */
 extern char    *initializer;   /* Script to initialize physical link */
@@ -318,6 +331,7 @@ extern bool tune_kernel;    /* May alter kernel settings as necessary */
 extern int     connect_delay;  /* Time to delay after connect script */
 extern int     max_data_rate;  /* max bytes/sec through charshunt */
 extern int     req_unit;       /* interface unit number to use */
+extern char    req_ifname[MAXIFNAMELEN]; /* interface name to use */
 extern bool    multilink;      /* enable multilink operation */
 extern bool    noendpoint;     /* don't send or accept endpt. discrim. */
 extern char    *bundle_name;   /* bundle name for multilink */
index b4a435d2a99368bdb48316c798961f1be8f08147..46e1ed419f4b494fb3d6f4781fdc0120ca808fab 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
-#include <sys/errno.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
 #include <sys/sysmacros.h>
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <syslog.h>
@@ -643,6 +643,21 @@ static int make_ppp_unit()
        }
        if (x < 0)
                error("Couldn't create new ppp unit: %m");
+
+       if (x == 0 && req_ifname[0] != '\0') {
+               struct ifreq ifr;
+               char t[MAXIFNAMELEN];
+               memset(&ifr, 0, sizeof(struct ifreq));
+               slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
+               strncpy(ifr.ifr_name, t, IF_NAMESIZE);
+               strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
+               x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
+               if (x < 0)
+                   error("Couldn't rename interface %s to %s: %m", t, req_ifname);
+               else
+                   info("Renamed interface %s to %s", t, req_ifname);
+       }
+
        return x;
 }
 
index ac028f6bf4f0d121f38ff1519ee2632c1a663df8..cdf7ac4341fb4859d105970bf53ff208cd06f7cd 100644 (file)
@@ -10,7 +10,7 @@ INSTALL= install
 all:   pppdump
 
 pppdump: $(OBJS)
-       $(CC) -o pppdump $(OBJS)
+       $(CC) $(LDFLAGS) -o pppdump $(OBJS)
 
 clean:
        rm -f pppdump $(OBJS) *~
index cca6f0f61d87f70016e903dbad7821dc87473249..71afbe67eff4916bfd70bb4ba9bf01b8d1c3d374 100644 (file)
@@ -26,7 +26,7 @@ install: pppstats
        $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
 
 pppstats: $(PPPSTATSRCS)
-       $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o pppstats pppstats.c $(LIBS)
 
 clean:
        rm -f pppstats *~ #* core
index 6367988eb96bf03c588b6228ee0c0fdf115f0fbb..46cb9c24942b5e6869fef31f463b514daefb99ba 100644 (file)
@@ -88,7 +88,6 @@ int   aflag;                  /* print absolute values, not deltas */
 int    dflag;                  /* print data rates, not bytes */
 int    interval, count;
 int    infinite;
-int    unit;
 int    s;                      /* socket or /dev/ppp file descriptor */
 int    signalled;              /* set if alarm goes off "early" */
 char   *progname;
@@ -449,6 +448,7 @@ main(argc, argv)
 {
     int c;
 #ifdef STREAMS
+    int unit;
     char *dev;
 #endif
 
@@ -506,11 +506,6 @@ main(argc, argv)
     if (argc > 0)
        interface = argv[0];
 
-    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
-       fprintf(stderr, "%s: invalid interface '%s' specified\n",
-               progname, interface);
-    }
-
 #ifndef STREAMS
     {
        struct ifreq ifr;
@@ -535,6 +530,11 @@ main(argc, argv)
     }
 
 #else  /* STREAMS */
+    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+       fprintf(stderr, "%s: invalid interface '%s' specified\n",
+               progname, interface);
+    }
+
 #ifdef __osf__
     dev = "/dev/streams/ppp";
 #else
index 84d2c7340cc64cd4f86ffa9af87504c8055b9c03..7cb53346413d7b52e8ecc6757be0e990bb4beecd 100644 (file)
@@ -3,5 +3,5 @@
 if [ -s /var/log/ppp.log ]; then
   exec tail "$@" /var/log/ppp.log
 else
-  exec tail "$@" /var/log/syslog | grep ' \(pppd\|chat\)\['
+  exec grep ' \(pppd\|chat\)\[' /var/log/syslog | tail "$@"
 fi