X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fipv6cp.c;h=356ff84ead4103cb846c31c6e806786b166a33e5;hp=ce9b1385a444a90f7e2b5ba61edf547d83a31f04;hb=70a8ad3dbd8af3b52d624550fc3343d1849c3f76;hpb=ec27e67401c1e4031be2fa7f692d3d66d5bee586 diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c index ce9b138..356ff84 100644 --- a/pppd/ipv6cp.c +++ b/pppd/ipv6cp.c @@ -135,10 +135,10 @@ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: ipv6cp.c,v 1.20 2004/11/13 02:28:15 paulus Exp $ + * $Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $ */ -#define RCSID "$Id: ipv6cp.c,v 1.20 2004/11/13 02:28:15 paulus Exp $" +#define RCSID "$Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $" /* * TODO: @@ -151,6 +151,7 @@ */ #include +#include #include #include #include @@ -179,6 +180,16 @@ int no_ifaceid_neg = 0; /* local vars */ static int ipv6cp_is_up; +/* Hook for a plugin to know when IPv6 protocol has come up */ +void (*ipv6_up_hook) __P((void)) = NULL; + +/* Hook for a plugin to know when IPv6 protocol has come down */ +void (*ipv6_down_hook) __P((void)) = NULL; + +/* Notifiers for when IPCPv6 goes up and down */ +struct notifier *ipv6_up_notifier = NULL; +struct notifier *ipv6_down_notifier = NULL; + /* * Callbacks for fsm code. (CI = Configuration Information) */ @@ -238,10 +249,8 @@ static option_t ipv6cp_option_list[] = { { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip, "Use (default) IPv4 address as interface identifier", 1 }, -#if defined(SOL2) || defined(__linux__) { "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent, "Use uniquely-available persistent value for link local address", 1 }, -#endif /* defined(SOL2) */ { "ipv6cp-restart", o_int, &ipv6cp_fsm[0].timeouttime, "Set timeout for IPv6CP", OPT_PRIO }, @@ -1077,7 +1086,6 @@ ipv6_check_options() if (!ipv6cp_protent.enabled_flag) return; -#if defined(SOL2) || defined(__linux__) /* * Persistent link-local id is only used when user has not explicitly * configure/hard-code the id @@ -1097,7 +1105,6 @@ ipv6_check_options() wo->opt_local = 1; } } -#endif if (!wo->opt_local) { /* init interface identifier */ if (wo->use_ip && eui64_iszero(wo->ourid)) { @@ -1120,7 +1127,7 @@ ipv6_check_options() if (demand && (eui64_iszero(wo->ourid) || eui64_iszero(wo->hisid))) { option_error("local/remote LL address required for demand-dialling\n"); - exit(1); + exit(EXIT_OPTION_ERROR); } } @@ -1135,15 +1142,8 @@ ipv6_demand_conf(u) { ipv6cp_options *wo = &ipv6cp_wantoptions[u]; -#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__))) -#if defined(SOL2) if (!sif6up(u)) return 0; -#else - if (!sifup(u)) - return 0; -#endif /* defined(SOL2) */ -#endif if (!sif6addr(u, wo->ourid, wo->hisid)) return 0; #if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__))) @@ -1236,43 +1236,20 @@ ipv6cp_up(f) sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); } else { - /* - * Set LL addresses - */ -#if !defined(__linux__) && !defined(SOL2) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__))) - if (!sif6addr(f->unit, go->ourid, ho->hisid)) { - if (debug) - warn("sif6addr failed"); - ipv6cp_close(f->unit, "Interface configuration failed"); - return; - } -#endif - /* bring the interface up for IPv6 */ -#if defined(SOL2) if (!sif6up(f->unit)) { if (debug) - warn("sifup failed (IPV6)"); + warn("sif6up failed (IPV6)"); ipv6cp_close(f->unit, "Interface configuration failed"); return; } -#else - if (!sifup(f->unit)) { - if (debug) - warn("sifup failed (IPV6)"); - ipv6cp_close(f->unit, "Interface configuration failed"); - return; - } -#endif /* defined(SOL2) */ -#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__))) if (!sif6addr(f->unit, go->ourid, ho->hisid)) { if (debug) warn("sif6addr failed"); ipv6cp_close(f->unit, "Interface configuration failed"); return; } -#endif sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); notice("local LL address %s", llv6_ntoa(go->ourid)); @@ -1282,6 +1259,10 @@ ipv6cp_up(f) np_up(f->unit, PPP_IPV6); ipv6cp_is_up = 1; + notify(ipv6_up_notifier, 0); + if (ipv6_up_hook) + ipv6_up_hook(); + /* * Execute the ipv6-up script, like this: * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL @@ -1305,6 +1286,9 @@ ipv6cp_down(f) { IPV6CPDEBUG(("ipv6cp: down")); update_link_stats(f->unit); + notify(ipv6_down_notifier, 0); + if (ipv6_down_hook) + ipv6_down_hook(); if (ipv6cp_is_up) { ipv6cp_is_up = 0; np_down(f->unit, PPP_IPV6); @@ -1322,16 +1306,14 @@ ipv6cp_down(f) } else { sifnpmode(f->unit, PPP_IPV6, NPMODE_DROP); #if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC))) -#if defined(SOL2) sif6down(f->unit); -#else - sifdown(f->unit); -#endif /* defined(SOL2) */ #endif ipv6cp_clear_addrs(f->unit, ipv6cp_gotoptions[f->unit].ourid, ipv6cp_hisoptions[f->unit].hisid); -#if defined(__linux__) || (defined(SVR4) && (defined(SNI) || defined(__USLC))) +#if defined(__linux__) + sif6down(f->unit); +#elif defined(SVR4) && (defined(SNI) || defined(__USLC)) sifdown(f->unit); #endif } @@ -1419,7 +1401,8 @@ ipv6cp_script(script) argv[6] = ipparam; argv[7] = NULL; - ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done, NULL); + ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done, + NULL, 0); } /*