]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/ipv6cp.c
ipv6cp: Add support for ipv6cp-nosend option
[ppp.git] / pppd / ipv6cp.c
index 8ab440a95f683015bcc2226c8a759173369c203c..decaa6705e6cf335e7271fd55d3a08712bb87736 100644 (file)
@@ -179,6 +179,7 @@ int no_ifaceid_neg = 0;
 /* local vars */
 static int default_route_set[NUM_PPP];         /* Have set up a default route */
 static int ipv6cp_is_up;
+static bool ipv6cp_noremote;
 
 /* Hook for a plugin to know when IPv6 protocol has come up */
 void (*ipv6_up_hook)(void) = NULL;
@@ -263,6 +264,13 @@ static option_t ipv6cp_option_list[] = {
     { "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent,
       "Use uniquely-available persistent value for link local address", 1 },
 
+#ifdef __linux__
+    { "ipv6cp-noremote", o_bool, &ipv6cp_noremote,
+      "Allow peer to have no interface identifier", 1 },
+#endif
+    { "ipv6cp-nosend", o_bool, &ipv6cp_wantoptions[0].neg_ifaceid,
+      "Don't send local interface identifier to peer", OPT_A2CLR },
+
     { "ipv6cp-restart", o_int, &ipv6cp_fsm[0].timeouttime,
       "Set timeout for IPv6CP", OPT_PRIO },
     { "ipv6cp-max-terminate", o_int, &ipv6cp_fsm[0].maxtermtransmits,
@@ -678,6 +686,7 @@ bad:
 static int
 ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
 {
+    ipv6cp_options *wo = &ipv6cp_wantoptions[f->unit];
     ipv6cp_options *go = &ipv6cp_gotoptions[f->unit];
     u_char citype, cilen, *next;
     u_short cishort;
@@ -726,7 +735,7 @@ ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
                     try.neg_ifaceid = 0;
                 } else if (go->accept_local && !eui64_iszero(ifaceid) && !eui64_equals(ifaceid, go->hisid)) {
                     try.ourid = ifaceid;
-                } else if (eui64_iszero(ifaceid) && !go->opt_local) {
+                } else if (eui64_iszero(ifaceid) && !go->opt_local && wo->neg_ifaceid) {
                     while (eui64_iszero(ifaceid) || 
                            eui64_equals(ifaceid, go->hisid)) /* bad luck */
                         eui64_magic(ifaceid);
@@ -780,7 +789,7 @@ ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
            eui64_get(ifaceid, p);
            if (go->accept_local && !eui64_iszero(ifaceid) && !eui64_equals(ifaceid, go->hisid)) {
                try.ourid = ifaceid;
-           } else if (eui64_iszero(ifaceid) && !go->opt_local) {
+           } else if (eui64_iszero(ifaceid) && !go->opt_local && wo->neg_ifaceid) {
                while (eui64_iszero(ifaceid) || 
                       eui64_equals(ifaceid, go->hisid)) /* bad luck */
                    eui64_magic(ifaceid);
@@ -1170,7 +1179,7 @@ ipv6_demand_conf(int u)
 {
     ipv6cp_options *wo = &ipv6cp_wantoptions[u];
 
-    if (eui64_iszero(wo->hisid)) {
+    if (eui64_iszero(wo->hisid) && !ipv6cp_noremote) {
        /* make up an arbitrary identifier for the peer */
        eui64_magic_nz(wo->hisid);
     }
@@ -1194,7 +1203,8 @@ ipv6_demand_conf(int u)
            default_route_set[u] = 1;
 
     notice("local  LL address %s", llv6_ntoa(wo->ourid));
-    notice("remote LL address %s", llv6_ntoa(wo->hisid));
+    if (!eui64_iszero(wo->hisid))
+       notice("remote LL address %s", llv6_ntoa(wo->hisid));
 
     return 1;
 }
@@ -1227,7 +1237,7 @@ ipv6cp_up(fsm *f)
        ho->hisid = wo->hisid;
 
     if(!no_ifaceid_neg) {
-       if (eui64_iszero(ho->hisid)) {
+       if (eui64_iszero(ho->hisid) && !ipv6cp_noremote) {
            error("Could not determine remote LL address");
            ipv6cp_close(f->unit, "Could not determine remote LL address");
            return;
@@ -1244,7 +1254,8 @@ ipv6cp_up(fsm *f)
        }
     }
     script_setenv("LLLOCAL", llv6_ntoa(go->ourid), 0);
-    script_setenv("LLREMOTE", llv6_ntoa(ho->hisid), 0);
+    if (!eui64_iszero(ho->hisid))
+        script_setenv("LLREMOTE", llv6_ntoa(ho->hisid), 0);
 
 #ifdef IPV6CP_COMP
     /* set tcp compression */
@@ -1306,7 +1317,8 @@ ipv6cp_up(fsm *f)
                default_route_set[f->unit] = 1;
 
        notice("local  LL address %s", llv6_ntoa(go->ourid));
-       notice("remote LL address %s", llv6_ntoa(ho->hisid));
+       if (!eui64_iszero(ho->hisid))
+           notice("remote LL address %s", llv6_ntoa(ho->hisid));
     }
 
     np_up(f->unit, PPP_IPV6);
@@ -1322,7 +1334,7 @@ ipv6cp_up(fsm *f)
      */
     if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
        ipv6cp_script_state = s_up;
-       ipv6cp_script(_PATH_IPV6UP);
+       ipv6cp_script(path_ipv6up);
     }
 }
 
@@ -1373,7 +1385,7 @@ ipv6cp_down(fsm *f)
     /* Execute the ipv6-down script */
     if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
        ipv6cp_script_state = s_down;
-       ipv6cp_script(_PATH_IPV6DOWN);
+       ipv6cp_script(path_ipv6down);
     }
 }
 
@@ -1411,13 +1423,13 @@ ipv6cp_script_done(void *arg)
     case s_up:
        if (ipv6cp_fsm[0].state != OPENED) {
            ipv6cp_script_state = s_down;
-           ipv6cp_script(_PATH_IPV6DOWN);
+           ipv6cp_script(path_ipv6down);
        }
        break;
     case s_down:
        if (ipv6cp_fsm[0].state == OPENED) {
            ipv6cp_script_state = s_up;
-           ipv6cp_script(_PATH_IPV6UP);
+           ipv6cp_script(path_ipv6up);
        }
        break;
     }