]> git.ozlabs.org Git - ppp.git/commitdiff
pppd: Add ipv6-{up,down}-script options (#321)
authorDaniel Barlow <dan@telent.net>
Sat, 20 Nov 2021 04:58:17 +0000 (04:58 +0000)
committerGitHub <noreply@github.com>
Sat, 20 Nov 2021 04:58:17 +0000 (15:58 +1100)
These allow a user to specify the paths to the scripts
usually located at /etc/ppp/ipv6-up and /etc/ppp/ipv6-down,
similarly to the existing ip-up-script and ip-down-script
options

Signed-off-by: Daniel Barlow <dan@telent.net>
NEWS
pppd/ipv6cp.c
pppd/main.c
pppd/options.c
pppd/pppd.h

diff --git a/NEWS b/NEWS
index 9d6c7fb76a3ab916e5f5b3588f377d998bf5dc3b..53a5e1a3bb8ccd58b72451ac7c42e3496cc0a9b4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+What's new since ppp-2.4.9 (unreleased)
+***************************************
+
+* New pppd options:
+  - ipv6-up-script
+  - ipv6-down-script
+
 What's new in ppp-2.4.9.
 ************************
 
index 8ab440a95f683015bcc2226c8a759173369c203c..cef1e389d0e117a0da012a56c7e7f003d0455e11 100644 (file)
@@ -1322,7 +1322,7 @@ ipv6cp_up(fsm *f)
      */
     if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
        ipv6cp_script_state = s_up;
-       ipv6cp_script(_PATH_IPV6UP);
+       ipv6cp_script(path_ipv6up);
     }
 }
 
@@ -1373,7 +1373,7 @@ ipv6cp_down(fsm *f)
     /* Execute the ipv6-down script */
     if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
        ipv6cp_script_state = s_down;
-       ipv6cp_script(_PATH_IPV6DOWN);
+       ipv6cp_script(path_ipv6down);
     }
 }
 
@@ -1411,13 +1411,13 @@ ipv6cp_script_done(void *arg)
     case s_up:
        if (ipv6cp_fsm[0].state != OPENED) {
            ipv6cp_script_state = s_down;
-           ipv6cp_script(_PATH_IPV6DOWN);
+           ipv6cp_script(path_ipv6down);
        }
        break;
     case s_down:
        if (ipv6cp_fsm[0].state == OPENED) {
            ipv6cp_script_state = s_up;
-           ipv6cp_script(_PATH_IPV6UP);
+           ipv6cp_script(path_ipv6up);
        }
        break;
     }
index b1ac8b4fd68087d54c1e6b9a6eeda87ca5130bc5..bdc6faadf543c5fb38ee4b441cb1a2977b02302f 100644 (file)
@@ -300,6 +300,10 @@ main(int argc, char *argv[])
     strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
     strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
 
+#ifdef INET6
+    strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up));
+    strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down));
+#endif
     link_stats_valid = 0;
     new_phase(PHASE_INITIALIZE);
 
index f3f5e25d6e7e9fb4b9ea5d70532c102e6a60826e..c9592837473b9becd62bf8fa5c998e2c73d21a52 100644 (file)
@@ -131,6 +131,11 @@ int        child_wait = 5;         /* # seconds to wait for children at exit */
 struct userenv *userenv_list;  /* user environment variables */
 int    dfl_route_metric = -1;  /* metric of the default route to set over the PPP link */
 
+#ifdef INET6
+char   path_ipv6up[MAXPATHLEN];   /* pathname of ipv6-up script */
+char   path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
+#endif
+
 #ifdef MAXOCTETS
 unsigned int  maxoctets = 0;    /* default - no limit */
 int maxoctets_dir = 0;       /* default - sum of traffic */
@@ -328,6 +333,15 @@ option_t general_options[] = {
       "Set pathname of ip-down script",
       OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
 
+#ifdef INET6
+    { "ipv6-up-script", o_string, path_ipv6up,
+      "Set pathname of ipv6-up script",
+      OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+    { "ipv6-down-script", o_string, path_ipv6down,
+      "Set pathname of ipv6-down script",
+      OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+#endif
+
 #ifdef HAVE_MULTILINK
     { "multilink", o_bool, &multilink,
       "Enable multilink operation", OPT_PRIO | 1 },
index ab8f674dda5e3901acab82d35b766e921fcbf4ac..ce43a28cac26846088d6fbab98bb299beed0ee25 100644 (file)
@@ -336,6 +336,11 @@ extern bool        dump_options;   /* print out option values */
 extern bool    dryrun;         /* check everything, print options, exit */
 extern int     child_wait;     /* # seconds to wait for children at end */
 
+#ifdef INET6
+extern char    path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
+extern char    path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
+#endif
+
 #if defined(USE_EAPTLS) || defined(USE_PEAP)
 
 #define TLS_VERIFY_NONE     "none"