Root/package/network/services/ppp/patches/100-debian_ip-ip_option.patch

1pppd: Allow specifying ip-up and ip-down scripts
2
3This patch implements the "ip-up-script" and "ip-down-script" options which
4allow to specify the path of the ip-up and ip-down scripts to call.
5
6These options default to _PATH_IPUP and _PATH_IPDOWN to retain the
7existing behaviour.
8
9The patch originated from the Debian project.
10
11Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
12
13--- a/pppd/ipcp.c
14+++ b/pppd/ipcp.c
15@@ -1939,7 +1939,7 @@ ipcp_up(f)
16      */
17     if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
18     ipcp_script_state = s_up;
19- ipcp_script(_PATH_IPUP, 0);
20+ ipcp_script(path_ipup, 0);
21     }
22 }
23 
24@@ -1989,7 +1989,7 @@ ipcp_down(f)
25     /* Execute the ip-down script */
26     if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
27     ipcp_script_state = s_down;
28- ipcp_script(_PATH_IPDOWN, 0);
29+ ipcp_script(path_ipdown, 0);
30     }
31 }
32 
33@@ -2043,13 +2043,13 @@ ipcp_script_done(arg)
34     case s_up:
35     if (ipcp_fsm[0].state != OPENED) {
36         ipcp_script_state = s_down;
37- ipcp_script(_PATH_IPDOWN, 0);
38+ ipcp_script(path_ipdown, 0);
39     }
40     break;
41     case s_down:
42     if (ipcp_fsm[0].state == OPENED) {
43         ipcp_script_state = s_up;
44- ipcp_script(_PATH_IPUP, 0);
45+ ipcp_script(path_ipup, 0);
46     }
47     break;
48     }
49--- a/pppd/main.c
50+++ b/pppd/main.c
51@@ -316,6 +316,9 @@ main(argc, argv)
52     struct protent *protp;
53     char numbuf[16];
54 
55+ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
56+ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
57+
58     link_stats_valid = 0;
59     new_phase(PHASE_INITIALIZE);
60 
61--- a/pppd/options.c
62+++ b/pppd/options.c
63@@ -113,6 +113,8 @@ char linkname[MAXPATHLEN]; /* logical na
64 bool tune_kernel; /* may alter kernel settings */
65 int connect_delay = 1000; /* wait this many ms after connect script */
66 int req_unit = -1; /* requested interface unit */
67+char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
68+char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
69 bool multilink = 0; /* Enable multilink operation */
70 char *bundle_name = NULL; /* bundle name for multilink */
71 bool dump_options; /* print out option values */
72@@ -281,6 +283,13 @@ option_t general_options[] = {
73       "Number of seconds to wait for child processes at exit",
74       OPT_PRIO },
75 
76+ { "ip-up-script", o_string, path_ipup,
77+ "Set pathname of ip-up script",
78+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
79+ { "ip-down-script", o_string, path_ipdown,
80+ "Set pathname of ip-down script",
81+ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
82+
83 #ifdef HAVE_MULTILINK
84     { "multilink", o_bool, &multilink,
85       "Enable multilink operation", OPT_PRIO | 1 },
86--- a/pppd/pppd.h
87+++ b/pppd/pppd.h
88@@ -313,6 +313,8 @@ extern bool tune_kernel; /* May alter ke
89 extern int connect_delay; /* Time to delay after connect script */
90 extern int max_data_rate; /* max bytes/sec through charshunt */
91 extern int req_unit; /* interface unit number to use */
92+extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
93+extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
94 extern bool multilink; /* enable multilink operation */
95 extern bool noendpoint; /* don't send or accept endpt. discrim. */
96 extern char *bundle_name; /* bundle name for multilink */
97

Archive Download this file



interactive