Skip to content

Commit

Permalink
Merge branch 'net-scripts' of https://github.com/tpaukrt/ppp
Browse files Browse the repository at this point in the history
  • Loading branch information
paulusmack committed Sep 10, 2024
2 parents f190e3e + 6f3ee96 commit f891b35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pppd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ main(int argc, char *argv[])
strlcpy(path_upapfile, PPP_PATH_UPAPFILE, MAXPATHLEN);
strlcpy(path_chapfile, PPP_PATH_CHAPFILE, MAXPATHLEN);

strlcpy(path_net_init, PPP_PATH_NET_INIT, MAXPATHLEN);
strlcpy(path_net_preup, PPP_PATH_NET_PREUP, MAXPATHLEN);
strlcpy(path_net_down, PPP_PATH_NET_DOWN, MAXPATHLEN);

strlcpy(path_ipup, PPP_PATH_IPUP, MAXPATHLEN);
strlcpy(path_ipdown, PPP_PATH_IPDOWN, MAXPATHLEN);
strlcpy(path_ippreup, PPP_PATH_IPPREUP, MAXPATHLEN);
Expand Down Expand Up @@ -848,7 +852,7 @@ set_ifunit(int iskey)
create_pidfile(getpid()); /* write pid to file */
create_linkpidfile(getpid());
}
run_net_script(PPP_PATH_NET_INIT, 1);
run_net_script(path_net_init, 1);
}

/*
Expand Down Expand Up @@ -1256,15 +1260,15 @@ new_phase(ppp_phase_t p)
if (phase <= PHASE_NETWORK) {
char iftmpname[IFNAMSIZ];
int ifindex = if_nametoindex(ifname);
run_net_script(PPP_PATH_NET_PREUP, 1);
run_net_script(path_net_preup, 1);
if (if_indextoname(ifindex, iftmpname) && strcmp(iftmpname, ifname)) {
info("Detected interface name change from %s to %s.", ifname, iftmpname);
strcpy(ifname, iftmpname);
}
}
break;
case PHASE_DISCONNECT:
run_net_script(PPP_PATH_NET_DOWN, 0);
run_net_script(path_net_down, 0);
break;
}

Expand Down
13 changes: 13 additions & 0 deletions pppd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ 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 path_net_init[MAXPATHLEN]; /* pathname of net-init script */
char path_net_preup[MAXPATHLEN];/* pathname of net-pre-up script */
char path_net_down[MAXPATHLEN]; /* pathname of net-down script */
char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
char path_ippreup[MAXPATHLEN]; /* pathname of ip-pre-up script */
Expand Down Expand Up @@ -332,6 +335,16 @@ struct option general_options[] = {
"Metric to use for the default route (Linux only; -1 for default behavior)",
OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },

{ "net-init-script", o_string, path_net_init,
"Set pathname of net-init script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "net-pre-up-script", o_string, path_net_preup,
"Set pathname of net-preup script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
{ "net-down-script", o_string, path_net_down,
"Set pathname of net-down script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },

{ "ip-up-script", o_string, path_ipup,
"Set pathname of ip-up script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
Expand Down
3 changes: 3 additions & 0 deletions pppd/pppd-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ 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 path_net_init[]; /* pathname of net-init script */
extern char path_net_preup[];/* pathname of net-pre-up script */
extern char path_net_down[]; /* pathname of net-down script */
extern char path_ipup[]; /* pathname of ip-up script */
extern char path_ipdown[]; /* pathname of ip-down script */
extern char path_ippreup[]; /* pathname of ip-pre-up script */
Expand Down

0 comments on commit f891b35

Please sign in to comment.