diff --git a/pppd/main.c b/pppd/main.c index b638e6ba..b4b58f83 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -247,6 +247,7 @@ static void holdoff_end(void *); static void forget_child(int pid, int status); static int reap_kids(void); static void childwait_end(void *); +static void main_script(char* script, int wait); #ifdef PPP_WITH_TDB static void update_db_entry(void); @@ -739,6 +740,7 @@ set_ifunit(int iskey) else slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit); info("Using interface %s", ifname); + main_script(PPP_PATH_NET_INIT, 1); script_setenv("IFNAME", ifname, iskey); slprintf(ifkey, sizeof(ifkey), "%d", ifunit); script_setenv("UNIT", ifkey, iskey); @@ -748,6 +750,26 @@ set_ifunit(int iskey) } } +/* + * net-* scripts to be run come through here. + */ +static void main_script(char* script, int wait) +{ + char strspeed[32]; + char *argv[6]; + + slprintf(strspeed, sizeof(strspeed), "%d", baud_rate); + + argv[0] = script; + argv[1] = ifname; + argv[2] = devnam; + argv[3] = strspeed; + argv[4] = ipparam; + argv[5] = NULL; + + run_program(script, argv, 0, NULL, NULL, wait); +} + /* * set_ifup - called in order to set the ppp interface to up, if not already * brought up. @@ -761,8 +783,11 @@ set_ifup(const char* name) int i; const char** t; - if (!up_protos && !netif_set_up()) - return 0; + if (!up_protos) { + main_script(PPP_PATH_NET_PREUP, 1); + if (!netif_set_up()) + return 0; + } i = 0; while (up_protos && up_protos[i]) { @@ -822,6 +847,8 @@ set_ifdown(const char* name) free(up_protos); up_protos = NULL; + main_script(PPP_PATH_NET_DOWN, 0); + return netif_set_down(); } diff --git a/pppd/pathnames.h b/pppd/pathnames.h index de2fb688..fb2c8c88 100644 --- a/pppd/pathnames.h +++ b/pppd/pathnames.h @@ -106,6 +106,9 @@ #define PPP_PATH_TTYOPT PPP_PATH_CONFDIR "/options." #define PPP_PATH_PEERFILES PPP_PATH_CONFDIR "/peers/" #define PPP_PATH_RESOLV PPP_PATH_CONFDIR "/resolv.conf" +#define PPP_PATH_NET_INIT PPP_PATH_CONFDIR "/net-init" +#define PPP_PATH_NET_PREUP PPP_PATH_CONFDIR "/net-pre-up" +#define PPP_PATH_NET_DOWN PPP_PATH_CONFDIR "/net-down" #define PPP_PATH_CONNERRS PPP_PATH_VARLOG "/connect-errors"