Usefull if one only wants IPv6CP and no IPv4 support. We construct the
pppd command-line with "noip" if IPCP is disabled explicitly. We still
pass others IPCP options, but they shouldn't be taken into account as
long as "noip" is given.

Signed-off-by: Benjamin Cama <[email protected]>
---
 doc/l2tpconfig.1    |    2 ++
 l2tp_common.c       |   12 +++++++-----
 l2tp_config.c       |   20 +++++++++++++++++---
 l2tp_config_parse.y |    6 ++++++
 l2tp_config_token.l |    1 +
 l2tp_ppp.c          |   10 ++++++++++
 l2tp_rpc.x          |    3 +++
 plugins/ppp_unix.c  |    5 +++++
 8 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/doc/l2tpconfig.1 b/doc/l2tpconfig.1
index ae9f177..c77940f 100644
--- a/doc/l2tpconfig.1
+++ b/doc/l2tpconfig.1
@@ -452,6 +452,8 @@ pap_timeout              - Maximum time to wait for peer to 
authenticate
                            itself. Default=0 (no limit).
 idle_timeout             - Disconnect session if idle for more than N 
                            seconds. Default=0 (no limit).
+ipcp_enable              - Enable IPCP. IPCP may be disabled for
+                           IPv6-only sessions. Default: YES
 ipcp_max_cfg_reqs        - Maximum number of IPCP config-requests to 
                            transmit without successful acknowledgement
                            before declaring a failure. Default=10.
diff --git a/l2tp_common.c b/l2tp_common.c
index 944c4a9..2caf9a9 100644
--- a/l2tp_common.c
+++ b/l2tp_common.c
@@ -971,11 +971,13 @@ int l2tp_show_ppp_profile(FILE *file, struct 
l2tp_api_ppp_profile_msg_data *pp)
                       pp->lcp_echo_failure_count, pp->lcp_echo_interval,
                       pp->lcp_max_config_requests, pp->lcp_max_config_naks,
                       pp->lcp_max_terminate_requests, 
pp->lcp_retransmit_interval);
-       len += fprintf(file, "  IPCP parameters:-\n");
-       len += fprintf(file, "    max config requests: %d, max config naks: 
%d\n"
-                      "    max terminate requests: %d, retransmit interval: 
%d\n",
-                      pp->ipcp_max_config_requests, pp->ipcp_max_config_naks,
-                      pp->ipcp_max_terminate_requests, 
pp->ipcp_retransmit_interval);
+       if (pp->ipcp_enable) {
+               len += fprintf(file, "  IPCP parameters:-\n");
+               len += fprintf(file, "    max config requests: %d, max config 
naks: %d\n"
+                              "    max terminate requests: %d, retransmit 
interval: %d\n",
+                              pp->ipcp_max_config_requests, 
pp->ipcp_max_config_naks,
+                              pp->ipcp_max_terminate_requests, 
pp->ipcp_retransmit_interval);
+       }
        if (pp->ipv6cp_enable) {
                len += fprintf(file, "  IPv6CP parameters:-\n");
                len += fprintf(file, "    max config requests: %d, max config 
naks: %d\n"
diff --git a/l2tp_config.c b/l2tp_config.c
index f711b46..d1aec91 100644
--- a/l2tp_config.c
+++ b/l2tp_config.c
@@ -3128,6 +3128,7 @@ typedef enum {
        L2TP_PPP_ARGID_IPV6CP_MAX_CFG_NAKS,
        L2TP_PPP_ARGID_IPV6CP_MAX_TERM_REQS,
        L2TP_PPP_ARGID_IPV6CP_RETX_INTVL,
+       L2TP_PPP_ARGID_IPCP_ENABLE,
 } l2tp_ppp_arg_ids_t;
  
 #undef ARG
@@ -3199,7 +3200,8 @@ typedef enum {
        ARG(IPV6CP_MAX_CFG_NAKS,"ipv6cp_max_config_naks", 0,    int32,  
("Maximum number of IPv6CP config-naks to allow before starting to send "       
\
                                                                         
"config-rejects instead. Default=10.")),                                       \
        ARG(IPV6CP_MAX_TERM_REQS,"ipv6cp_max_terminate_requests", 0, int32, 
"Maximum number of IPv6CP term-requests to send. Default=3."),              \
-       ARG(IPV6CP_RETX_INTVL,  "ipv6cp_retransmit_interval", 0, int32, "IPv6CP 
retransmission timeout. Default=3.")
+       ARG(IPV6CP_RETX_INTVL,  "ipv6cp_retransmit_interval", 0, int32, "IPv6CP 
retransmission timeout. Default=3."),                                   \
+       ARG(IPCP_ENABLE,        "ipcp_enable",          0,      bool,   "Enable 
IPCP")
 
 
 static struct cli_arg_entry l2tp_args_ppp_profile_create[] = {
@@ -3285,7 +3287,8 @@ static struct cli_arg_entry l2tp_args_ppp_profile_unset[] 
= {
        FLG(IPV6CP_MAX_CFG_NAKS,"ipv6cp_max_config_naks", ("Maximum number of 
IPv6CP config-naks to allow before starting to send "     \
                                                           "config-rejects 
instead. Default=10.")), \
        FLG(IPV6CP_MAX_TERM_REQS,"ipv6cp_max_terminate_requests", "Maximum 
number of IPv6CP term-requests to send. Default=3."),        \
-       FLG(IPV6CP_RETX_INTVL,  "ipv6cp_retransmit_interval", "IPv6CP 
retransmission timeout. Default=3."),
+       FLG(IPV6CP_RETX_INTVL,  "ipv6cp_retransmit_interval", "IPv6CP 
retransmission timeout. Default=3."),                             \
+       FLG(IPCP_ENABLE,        "ipcp_enable",          "Enable IPCP"),         
                                                \
        { NULL, },
 };
 
@@ -3523,6 +3526,10 @@ static int l2tp_parse_ppp_profile_arg(l2tp_ppp_arg_ids_t 
arg_id, struct cli_node
        case L2TP_PPP_ARGID_IPV6CP_RETX_INTVL:
                L2TP_ACT_PARSE_ARG(arg, arg_value, 
msg->ipv6cp_retransmit_interval, msg->flags2, 
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL);
                break;
+       case L2TP_PPP_ARGID_IPCP_ENABLE:
+               L2TP_ACT_PARSE_ARG(arg, arg_value, ints[0], msg->flags2, 
L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE);
+               msg->ipcp_enable = ints[0];
+               break;
        }
 
        result = 0;
@@ -3906,6 +3913,9 @@ static int l2tp_act_ppp_profile_unset(struct cli_node 
*node, int argc, char *arg
                case L2TP_PPP_ARGID_IPV6CP_RETX_INTVL:
                        msg.flags2 |= 
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL;
                        break;
+               case L2TP_PPP_ARGID_IPCP_ENABLE:
+                       msg.flags2 |= L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE;
+                       break;
                }
        } L2TP_ACT_END();
 
@@ -4928,7 +4938,8 @@ static void l2tp_config_dump_ppp_profile(FILE *file, 
struct l2tp_api_ppp_profile
                            
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_CONFIG_REQUESTS |
                            L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_CONFIG_NAKS |
                            
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_TERMINATE_REQUESTS |
-                           
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL))) {
+                           
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL |
+                           L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE))) {
  
                fprintf(file, "ppp profile modify profile_name=%s \\\n", 
cfg->profile_name);
 
@@ -5098,6 +5109,9 @@ static void l2tp_config_dump_ppp_profile(FILE *file, 
struct l2tp_api_ppp_profile
                if (cfg->flags2 & 
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL) {
                        fprintf(file, "\tipv6cp_retransmit_interval=%d \\\n", 
cfg->ipv6cp_retransmit_interval);
                }
+               if (cfg->flags2 & L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE) {
+                       fprintf(file, "\tipcp_enable=%s \\\n", 
Y_OR_N(cfg->ipcp_enable));
+               }
                fprintf(file, "\n");
        }
 }
diff --git a/l2tp_config_parse.y b/l2tp_config_parse.y
index fdd7015..48fd2c3 100644
--- a/l2tp_config_parse.y
+++ b/l2tp_config_parse.y
@@ -148,6 +148,7 @@ extern void yyfatal(const char *s);
 %token IPV6CP_MAX_CONFIG_NAKS
 %token IPV6CP_MAX_TERMINATE_REQUESTS
 %token IPV6CP_RETRANSMIT_INTERVAL
+%token IPCP_ENABLE
 %token EOT
 %token SLASH
 %token BLCL
@@ -1197,6 +1198,11 @@ ppp_profile_statement
                        ppp_profile.flags2 |= 
L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL;
                        ppp_profile.ipv6cp_retransmit_interval = $3;
                }
+       |       IPCP_ENABLE EQUALS BOOL
+               {
+                       ppp_profile.flags2 |= 
L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE;
+                       ppp_profile.ipcp_enable = $3;
+               }
        ;
 
 tunnel_command
diff --git a/l2tp_config_token.l b/l2tp_config_token.l
index be522c9..af5f53b 100644
--- a/l2tp_config_token.l
+++ b/l2tp_config_token.l
@@ -196,6 +196,7 @@ ipv6cp_max_config_requests          { 
return(IPV6CP_MAX_CONFIG_REQUESTS); }
 ipv6cp_max_config_naks                 { return(IPV6CP_MAX_CONFIG_NAKS); }
 ipv6cp_max_terminate_requests          { 
return(IPV6CP_MAX_TERMINATE_REQUESTS); }
 ipv6cp_retransmit_interval             { return(IPV6CP_RETRANSMIT_INTERVAL); }
+ipcp_enable                            { return(IPCP_ENABLE); }
 
 {ws}           { }
 {linecont}     { lineno++; }
diff --git a/l2tp_ppp.c b/l2tp_ppp.c
index 39f299e..2bf6243 100644
--- a/l2tp_ppp.c
+++ b/l2tp_ppp.c
@@ -75,6 +75,7 @@ struct l2tp_ppp_profile {
        int                             auth_refuse_mschapv2:1;
        int                             auth_refuse_eap:1;
        int                             ipv6cp_enable:1;
+       int                             ipcp_enable:1;
 };
 
 static struct l2tp_ppp_profile *l2tp_ppp_defaults;
@@ -261,6 +262,9 @@ static int 
l2tp_ppp_profile_modify(l2tp_api_ppp_profile_msg_data *msg, struct l2
        if (msg->flags2 & L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL) 
{
                profile->ipv6cp_retransmit_interval = 
msg->ipv6cp_retransmit_interval;
        }
+       if (msg->flags2 & L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE) {
+               profile->ipcp_enable = msg->ipcp_enable;
+       }
 
 out:
        return result;
@@ -370,6 +374,7 @@ bool_t 
l2tp_ppp_profile_create_1_svc(l2tp_api_ppp_profile_msg_data msg, int *res
        profile->ipv6cp_max_config_naks = 
l2tp_ppp_defaults->ipv6cp_max_config_naks;
        profile->ipv6cp_max_terminate_requests = 
l2tp_ppp_defaults->ipv6cp_max_terminate_requests;
        profile->ipv6cp_retransmit_interval = 
l2tp_ppp_defaults->ipv6cp_retransmit_interval;
+       profile->ipcp_enable = l2tp_ppp_defaults->ipcp_enable;
 
        /* Override defaults by user-supplied params */
        *result = l2tp_ppp_profile_modify(&msg, profile);
@@ -608,6 +613,7 @@ int l2tp_ppp_profile_get(char *name, struct 
l2tp_api_ppp_profile_msg_data *resul
        result->ipv6cp_max_config_naks = profile->ipv6cp_max_config_naks;
        result->ipv6cp_max_terminate_requests = 
profile->ipv6cp_max_terminate_requests;
        result->ipv6cp_retransmit_interval = 
profile->ipv6cp_retransmit_interval;
+       result->ipcp_enable = profile->ipcp_enable;
 
 out:
        L2TP_DEBUG(L2TP_API, "%s: flags=%x/%x result=%d", __func__, 
result->flags, result->flags2, result->result_code);
@@ -888,6 +894,9 @@ bool_t 
l2tp_ppp_profile_unset_1_svc(l2tp_api_ppp_profile_unset_msg_data msg, int
        if (msg.flags2 & L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL) {
                profile->ipv6cp_retransmit_interval = 
L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_RETRANSMIT_INTERVAL;
        }
+       if (msg.flags2 & L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE) {
+               profile->ipcp_enable = L2TP_API_PPP_PROFILE_DEFAULT_IPCP_ENABLE;
+       }
 
        /* Clear all requested flags */
        profile->flags &= ~(msg.flags);
@@ -987,6 +996,7 @@ void l2tp_ppp_init(void)
        l2tp_ppp_defaults->ipv6cp_max_config_naks = 
L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_MAX_CONFIG_NAKS;
        l2tp_ppp_defaults->ipv6cp_max_terminate_requests = 
L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_MAX_TERMINATE_REQUESTS;
        l2tp_ppp_defaults->ipv6cp_retransmit_interval = 
L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_RETRANSMIT_INTERVAL;
+       l2tp_ppp_defaults->ipcp_enable = 
L2TP_API_PPP_PROFILE_DEFAULT_IPCP_ENABLE;
 
        USL_LIST_HEAD_INIT(&l2tp_ppp_defaults->list);
        usl_list_add(&l2tp_ppp_defaults->list, &l2tp_ppp_profile_list);
diff --git a/l2tp_rpc.x b/l2tp_rpc.x
index 9692bae..4d6d0aa 100644
--- a/l2tp_rpc.x
+++ b/l2tp_rpc.x
@@ -951,6 +951,7 @@ const L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_CONFIG_REQUESTS  
= 1048576;
 const L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_CONFIG_NAKS         = 2097152;
 const L2TP_API_PPP_PROFILE_FLAG_IPV6CP_MAX_TERMINATE_REQUESTS  = 4194304;
 const L2TP_API_PPP_PROFILE_FLAG_IPV6CP_RETRANSMIT_INTERVAL     = 8388608;
+const L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE                    = 16777216;
 
 /* Default values for PPP profile attributes.
  * These are used if an explicit value is not provided by the user.
@@ -1003,6 +1004,7 @@ const 
L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_MAX_CONFIG_REQUESTS     = 10;
 const L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_MAX_CONFIG_NAKS      = 10;
 const L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_MAX_TERMINATE_REQUESTS= 3;
 const L2TP_API_PPP_PROFILE_DEFAULT_IPV6CP_RETRANSMIT_INTERVAL  = 3;
+const L2TP_API_PPP_PROFILE_DEFAULT_IPCP_ENABLE                 = 1;
 
 enum l2tp_api_ppp_sync_mode {
        L2TP_API_PPP_SYNCMODE_SYNC_ASYNC,
@@ -1066,6 +1068,7 @@ struct l2tp_api_ppp_profile_msg_data {
        int                             ipv6cp_max_config_naks;
        int                             ipv6cp_max_terminate_requests;
        int                             ipv6cp_retransmit_interval;
+       bool                            ipcp_enable;
 };
 
 struct l2tp_api_ppp_profile_list_entry {
diff --git a/plugins/ppp_unix.c b/plugins/ppp_unix.c
index e946368..eae7ad3 100644
--- a/plugins/ppp_unix.c
+++ b/plugins/ppp_unix.c
@@ -381,6 +381,11 @@ static int ppp_unix_params_to_argv(struct ppp_context 
*ppp, struct l2tp_api_ppp_
             !params->ipv6cp_enable)) {
                argv[arg++] = "+ipv6";
        }
+       /* IPCP deactivation support */
+       if ((params->flags2 & L2TP_API_PPP_PROFILE_FLAG_IPCP_ENABLE) &&
+            !params->ipcp_enable) {
+               argv[arg++] = "noip";
+       }
 
        /* Now handle each parameter from our translation table. Only
         * add the arg if the ppp profile indicates that it's been
-- 
1.7.2.5


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Openl2tp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openl2tp-users

Reply via email to