Skip to content

Commit 7f8c1a1

Browse files
authored
pppd: Add ipv6-{up,down}-script options (#321)
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 <[email protected]>
1 parent 8193e53 commit 7f8c1a1

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

NEWS

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
What's new since ppp-2.4.9 (unreleased)
2+
***************************************
3+
4+
* New pppd options:
5+
- ipv6-up-script
6+
- ipv6-down-script
7+
18
What's new in ppp-2.4.9.
29
************************
310

pppd/ipv6cp.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ ipv6cp_up(fsm *f)
13221322
*/
13231323
if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
13241324
ipv6cp_script_state = s_up;
1325-
ipv6cp_script(_PATH_IPV6UP);
1325+
ipv6cp_script(path_ipv6up);
13261326
}
13271327
}
13281328

@@ -1373,7 +1373,7 @@ ipv6cp_down(fsm *f)
13731373
/* Execute the ipv6-down script */
13741374
if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
13751375
ipv6cp_script_state = s_down;
1376-
ipv6cp_script(_PATH_IPV6DOWN);
1376+
ipv6cp_script(path_ipv6down);
13771377
}
13781378
}
13791379

@@ -1411,13 +1411,13 @@ ipv6cp_script_done(void *arg)
14111411
case s_up:
14121412
if (ipv6cp_fsm[0].state != OPENED) {
14131413
ipv6cp_script_state = s_down;
1414-
ipv6cp_script(_PATH_IPV6DOWN);
1414+
ipv6cp_script(path_ipv6down);
14151415
}
14161416
break;
14171417
case s_down:
14181418
if (ipv6cp_fsm[0].state == OPENED) {
14191419
ipv6cp_script_state = s_up;
1420-
ipv6cp_script(_PATH_IPV6UP);
1420+
ipv6cp_script(path_ipv6up);
14211421
}
14221422
break;
14231423
}

pppd/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ main(int argc, char *argv[])
300300
strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
301301
strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
302302

303+
#ifdef INET6
304+
strlcpy(path_ipv6up, _PATH_IPV6UP, sizeof(path_ipv6up));
305+
strlcpy(path_ipv6down, _PATH_IPV6DOWN, sizeof(path_ipv6down));
306+
#endif
303307
link_stats_valid = 0;
304308
new_phase(PHASE_INITIALIZE);
305309

pppd/options.c

+14
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ int child_wait = 5; /* # seconds to wait for children at exit */
131131
struct userenv *userenv_list; /* user environment variables */
132132
int dfl_route_metric = -1; /* metric of the default route to set over the PPP link */
133133

134+
#ifdef INET6
135+
char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
136+
char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
137+
#endif
138+
134139
#ifdef MAXOCTETS
135140
unsigned int maxoctets = 0; /* default - no limit */
136141
int maxoctets_dir = 0; /* default - sum of traffic */
@@ -328,6 +333,15 @@ option_t general_options[] = {
328333
"Set pathname of ip-down script",
329334
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
330335

336+
#ifdef INET6
337+
{ "ipv6-up-script", o_string, path_ipv6up,
338+
"Set pathname of ipv6-up script",
339+
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
340+
{ "ipv6-down-script", o_string, path_ipv6down,
341+
"Set pathname of ipv6-down script",
342+
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
343+
#endif
344+
331345
#ifdef HAVE_MULTILINK
332346
{ "multilink", o_bool, &multilink,
333347
"Enable multilink operation", OPT_PRIO | 1 },

pppd/pppd.h

+5
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ extern bool dump_options; /* print out option values */
336336
extern bool dryrun; /* check everything, print options, exit */
337337
extern int child_wait; /* # seconds to wait for children at end */
338338

339+
#ifdef INET6
340+
extern char path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
341+
extern char path_ipv6down[MAXPATHLEN]; /* pathname of ipv6-down script */
342+
#endif
343+
339344
#if defined(USE_EAPTLS) || defined(USE_PEAP)
340345

341346
#define TLS_VERIFY_NONE "none"

0 commit comments

Comments
 (0)