From 42565475175bfbee657b03bea3c1a81905a68b93 Mon Sep 17 00:00:00 2001
From: Maxime Bizon <mbizon@freebox.fr>
Date: Fri, 17 Jan 2020 16:00:24 +0100
Subject: [PATCH 16/18] pppd: add ipv6 accept-remote option

---
 pppd/ipv6cp.c | 5 ++++-
 pppd/ipv6cp.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c
index bda91e9..0443bd5 100644
--- a/pppd/ipv6cp.c
+++ b/pppd/ipv6cp.c
@@ -245,6 +245,8 @@ static option_t ipv6cp_option_list[] = {
 
     { "ipv6cp-accept-local", o_bool, &ipv6cp_allowoptions[0].accept_local,
       "Accept peer's interface identifier for us", 1 },
+    { "ipv6cp-accept-remote", o_bool, &ipv6cp_allowoptions[0].accept_remote,
+      "Accept peer's interface identifier for itself", 1 },
 
     { "defaultroute6", o_bool, &ipv6cp_wantoptions[0].default_route,
       "Add default IPv6 route", OPT_ENABLE|1, &ipv6cp_allowoptions[0].default_route },
@@ -444,6 +446,7 @@ ipv6cp_init(unit)
     memset(ao, 0, sizeof(*ao));
 
     wo->accept_local = 1;
+    wo->accept_remote = 1;
     wo->neg_ifaceid = 1;
     ao->neg_ifaceid = 1;
 
@@ -973,7 +976,7 @@ ipv6cp_reqci(f, inp, len, reject_if_disagree)
 		orc = CONFREJ;		/* Reject CI */
 		break;
 	    }
-	    if (!eui64_iszero(wo->hisid) && 
+	    if (!eui64_iszero(wo->hisid) && !wo->accept_remote &&
 		!eui64_equals(ifaceid, wo->hisid) && 
 		eui64_iszero(go->hisid)) {
 		    
diff --git a/pppd/ipv6cp.h b/pppd/ipv6cp.h
index 25235d2..f484685 100644
--- a/pppd/ipv6cp.h
+++ b/pppd/ipv6cp.h
@@ -152,6 +152,7 @@ typedef struct ipv6cp_options {
     int req_ifaceid;		/* Ask peer to send interface identifier? */
     int default_route;		/* Assign default route through interface? */
     int accept_local;		/* accept peer's value for iface id? */
+    int accept_remote;		/* accept peer's value for his iface id? */
     int opt_local;		/* ourtoken set by option */
     int opt_remote;		/* histoken set by option */
     int use_ip;			/* use IP as interface identifier */
-- 
2.17.1

