diff -brau openl2tp-1.8.o/doc/openl2tp_rpc.4 openl2tp-1.8/doc/openl2tp_rpc.4 --- openl2tp-1.8.o/doc/openl2tp_rpc.4 2010-11-09 16:50:58.000000000 +0200 +++ openl2tp-1.8/doc/openl2tp_rpc.4 2011-06-04 10:02:34.000000000 +0200 @@ -774,6 +774,10 @@ .B local_ip_addr The IP address to assign to the local end of the PPP link. .TP +.B optionsfile +Passes a file parameter to the pppd daemon, allowing for loading a custom +options file. See pppd(8) for more details. +.TP .B peer_ip_addr The IP address to assign to the remote (peer) end of the PPP link. .TP diff -brau openl2tp-1.8.o/l2tp_common.c openl2tp-1.8/l2tp_common.c --- openl2tp-1.8.o/l2tp_common.c 2008-01-08 19:23:51.000000000 +0200 +++ openl2tp-1.8/l2tp_common.c 2011-06-04 21:00:45.000000000 +0200 @@ -938,6 +938,10 @@ } len += fprintf(file, " multilink: %s, proxy arp: %s\n", pp->multilink ? "YES" : "NO", pp->proxy_arp ? "YES" : "NO"); + if (OPTSTRING_PTR(pp->optionsfile) != NULL) { + len += fprintf(file, " optionsfile: %s\n", OPTSTRING(pp->optionsfile)); + } + len += fprintf(file, " IP parameters:-\n"); ip_to_string(&local_ip[0], pp->local_ip_addr.s_addr); ip_to_string(&peer_ip[0], pp->peer_ip_addr.s_addr); diff -brau openl2tp-1.8.o/l2tp_config.c openl2tp-1.8/l2tp_config.c --- openl2tp-1.8.o/l2tp_config.c 2010-01-18 12:35:14.000000000 +0200 +++ openl2tp-1.8/l2tp_config.c 2011-06-04 11:43:03.000000000 +0200 @@ -3123,6 +3123,7 @@ L2TP_PPP_ARGID_LOCAL_NAME, L2TP_PPP_ARGID_REMOTE_NAME, L2TP_PPP_ARGID_PROXY_ARP, + L2TP_PPP_ARGID_OPTIONSFILE, } l2tp_ppp_arg_ids_t; #undef ARG @@ -3187,7 +3188,8 @@ ARG(REMOTE_NAME, "remote_name", 0, string, "Name to assume for the remote peer for authentication purposes"), \ ARG(USE_AS_DEFAULT_ROUTE, "default_route", 0, bool, "Use link as default route"), \ ARG(MULTILINK, "multilink", 0, bool, "Enable PPP multilink connections."), \ - ARG(PROXY_ARP, "proxy_arp", 0, bool, "Use proxy arp.") + ARG(PROXY_ARP, "proxy_arp", 0, bool, "Use proxy arp."), \ + ARG(OPTIONSFILE, "optionsfile", 0, string, "ppp options file to use") static struct cli_arg_entry l2tp_args_ppp_profile_create[] = { @@ -3267,6 +3269,7 @@ FLG(USE_AS_DEFAULT_ROUTE, "default_route", "Use link as default route"), \ FLG(MULTILINK, "multilink", "Enable PPP multilink connections."), \ FLG(PROXY_ARP, "proxy_arp", "Use proxy arp."), + FLG(OPTIONSFILE, "optionsfile", "ppp options file to use"), { NULL, }, }; @@ -3488,6 +3491,15 @@ msg->remote_name.valid = 1; msg->flags2 |= L2TP_API_PPP_PROFILE_FLAG_REMOTE_NAME; break; + case L2TP_PPP_ARGID_OPTIONSFILE: + OPTSTRING(msg->optionsfile) = strdup(arg_value); + if (OPTSTRING(msg->optionsfile) == NULL) { + result = -ENOMEM; + goto out; + } + msg->optionsfile.valid = 1; + msg->flags2 |= L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE; + break; } result = 0; @@ -3856,6 +3868,9 @@ case L2TP_PPP_ARGID_REMOTE_NAME: msg.flags2 |= L2TP_API_PPP_PROFILE_FLAG_REMOTE_NAME; break; + case L2TP_PPP_ARGID_OPTIONSFILE: + msg.flags2 |= L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE; + break; } } L2TP_ACT_END(); @@ -4867,6 +4882,7 @@ L2TP_API_PPP_PROFILE_FLAG_LOCAL_NAME | L2TP_API_PPP_PROFILE_FLAG_REMOTE_NAME | L2TP_API_PPP_PROFILE_FLAG_PROXY_ARP | + L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE | L2TP_API_PPP_PROFILE_FLAG_AUTH_NONE | L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_EAP | L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_MSCHAPV2 | @@ -5028,6 +5044,9 @@ if (cfg->flags2 & L2TP_API_PPP_PROFILE_FLAG_PROXY_ARP) { fprintf(file, "\tproxy_arp=%s \\\n", Y_OR_N(cfg->proxy_arp)); } + if ((cfg->flags2 & L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE) && (OPTSTRING_PTR(cfg->optionsfile) != NULL)) { + fprintf(file, "\toptionsfile=%s \\\n", OPTSTRING_PTR(cfg->optionsfile)); + } fprintf(file, "\n"); } } diff -brau openl2tp-1.8.o/l2tp_config_parse.y openl2tp-1.8/l2tp_config_parse.y --- openl2tp-1.8.o/l2tp_config_parse.y 2010-11-09 16:50:58.000000000 +0200 +++ openl2tp-1.8/l2tp_config_parse.y 2011-06-04 11:11:42.000000000 +0200 @@ -154,6 +154,7 @@ %token QUOTEDSTRING %token BOOL %token IPADDRESS +%token OPTIONSFILE %token INITIAL_RCVD_LCP_CONFREQ %token CALLING_NUMBER @@ -1167,6 +1168,18 @@ OPTSTRING(ppp_profile.remote_name) = $3.buf; ppp_profile.remote_name.valid = 1; } + | OPTIONSFILE EQUALS STRING + { + ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE; + OPTSTRING(ppp_profile.optionsfile) = $3.buf; + ppp_profile.optionsfile.valid = 1; + } + | OPTIONSFILE EQUALS QUOTEDSTRING + { + ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE; + OPTSTRING(ppp_profile.optionsfile) = $3.buf; + ppp_profile.optionsfile.valid = 1; + } ; tunnel_command diff -brau openl2tp-1.8.o/l2tp_config_token.l openl2tp-1.8/l2tp_config_token.l --- openl2tp-1.8.o/l2tp_config_token.l 2010-11-12 14:31:21.000000000 +0200 +++ openl2tp-1.8/l2tp_config_token.l 2011-06-04 11:08:31.000000000 +0200 @@ -191,6 +191,7 @@ auth_eap { return(AUTH_EAP); } auth_none { return(AUTH_NOAUTH); } auth_peer { return(AUTH_PEER); } +optionsfile { return(OPTIONSFILE); } {ws} { } {linecont} { lineno++; } diff -brau openl2tp-1.8.o/l2tp_ppp.c openl2tp-1.8/l2tp_ppp.c --- openl2tp-1.8.o/l2tp_ppp.c 2008-05-07 22:44:20.000000000 +0200 +++ openl2tp-1.8/l2tp_ppp.c 2011-06-04 16:08:25.000000000 +0200 @@ -70,6 +70,7 @@ int auth_refuse_mschap:1; int auth_refuse_mschapv2:1; int auth_refuse_eap:1; + char *optionsfile; }; static struct l2tp_ppp_profile *l2tp_ppp_defaults; @@ -241,6 +242,9 @@ if (msg->flags2 & L2TP_API_PPP_PROFILE_FLAG_REMOTE_NAME) { L2TP_SET_OPTSTRING_VAR(profile, remote_name); } + if (msg->flags2 & L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE) { + L2TP_SET_OPTSTRING_VAR(profile, optionsfile); + } out: return result; @@ -346,6 +350,14 @@ } } + if (l2tp_ppp_defaults->optionsfile != NULL) { + profile->optionsfile = strdup(l2tp_ppp_defaults->optionsfile); + if (profile->optionsfile == NULL) { + *result = -ENOMEM; + goto err; + } + } + /* Override defaults by user-supplied params */ *result = l2tp_ppp_profile_modify(&msg, profile); @@ -379,6 +391,24 @@ *result = -ENOMEM; goto out; err: + if (profile->radius_hint != NULL) { + free(profile->radius_hint); + } + if (profile->ip_pool_name != NULL) { + free(profile->ip_pool_name); + } + if (profile->profile_name != NULL) { + free(profile->profile_name); + } + if (profile->local_name != NULL) { + free(profile->local_name); + } + if (profile->remote_name != NULL) { + free(profile->remote_name); + } + if (profile->optionsfile != NULL) { + free(profile->optionsfile); + } free(profile); goto out; } @@ -430,6 +460,9 @@ if (profile->remote_name != NULL) { free(profile->remote_name); } + if (profile->optionsfile != NULL) { + free(profile->optionsfile); + } USL_POISON_MEMORY(profile, 0xe5, sizeof(*profile)); free(profile); *result = 0; @@ -578,6 +611,14 @@ } result->remote_name.valid = 1; } + if (profile->optionsfile != NULL) { + OPTSTRING(result->optionsfile) = strdup(profile->optionsfile); + if (OPTSTRING(result->optionsfile) == NULL) { + result->result_code = -ENOMEM; + goto out; + } + result->optionsfile.valid = 1; + } out: L2TP_DEBUG(L2TP_API, "%s: flags=%x/%x result=%d", __func__, result->flags, result->flags2, result->result_code); @@ -598,6 +639,9 @@ if (OPTSTRING_PTR(msg->remote_name) != NULL) { free(OPTSTRING(msg->remote_name)); } + if (OPTSTRING_PTR(msg->optionsfile) != NULL) { + free(OPTSTRING(msg->optionsfile)); + } if (msg->profile_name != NULL) { free(msg->profile_name); } @@ -843,6 +887,12 @@ } profile->remote_name = NULL; } + if (msg.flags2 & L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE) { + if (profile->optionsfile != NULL) { + free(profile->optionsfile); + } + profile->optionsfile = NULL; + } /* Clear all requested flags */ profile->flags &= ~(msg.flags); @@ -937,6 +987,12 @@ } l2tp_ppp_defaults->local_name = NULL; l2tp_ppp_defaults->remote_name = NULL; + if (strlen(L2TP_API_PPP_PROFILE_DEFAULT_OPTIONSFILE) > 0) { + l2tp_ppp_defaults->optionsfile = strdup(L2TP_API_PPP_PROFILE_DEFAULT_OPTIONSFILE); + if (l2tp_ppp_defaults->optionsfile == NULL) { + goto nomem; + } + } USL_LIST_HEAD_INIT(&l2tp_ppp_defaults->list); usl_list_add(&l2tp_ppp_defaults->list, &l2tp_ppp_profile_list); diff -brau openl2tp-1.8.o/l2tp_rpc.x openl2tp-1.8/l2tp_rpc.x --- openl2tp-1.8.o/l2tp_rpc.x 2010-11-04 18:30:36.000000000 +0200 +++ openl2tp-1.8/l2tp_rpc.x 2011-06-04 11:06:08.000000000 +0200 @@ -946,6 +946,7 @@ const L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_CHAP = 65536; const L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_PAP = 131072; const L2TP_API_PPP_PROFILE_FLAG_AUTH_PEER = 262144; +const L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE = 524288; /* Default values for PPP profile attributes. * These are used if an explicit value is not provided by the user. @@ -993,6 +994,7 @@ const L2TP_API_PPP_PROFILE_DEFAULT_USE_AS_DEFAULT_ROUTE = 0; const L2TP_API_PPP_PROFILE_DEFAULT_MULTILINK = 0; const L2TP_API_PPP_PROFILE_DEFAULT_PROXY_ARP = 0; +const L2TP_API_PPP_PROFILE_DEFAULT_OPTIONSFILE = ""; enum l2tp_api_ppp_sync_mode { L2TP_API_PPP_SYNCMODE_SYNC_ASYNC, @@ -1051,6 +1053,7 @@ optstring local_name; optstring remote_name; bool proxy_arp; + optstring optionsfile; }; struct l2tp_api_ppp_profile_list_entry { diff -brau openl2tp-1.8.o/plugins/ppp_unix.c openl2tp-1.8/plugins/ppp_unix.c --- openl2tp-1.8.o/plugins/ppp_unix.c 2010-11-22 16:03:48.000000000 +0200 +++ openl2tp-1.8/plugins/ppp_unix.c 2011-06-04 14:41:43.000000000 +0200 @@ -282,6 +282,11 @@ } } + if ((params->flags2 & L2TP_API_PPP_PROFILE_FLAG_OPTIONSFILE) && (OPTSTRING_PTR(params->optionsfile) != NULL)) { + argv[arg++] = "file"; + argv[arg++] = strdup(OPTSTRING(params->optionsfile)); + } + /* By default, use sync mode */ if (!((params->flags & L2TP_API_PPP_PROFILE_FLAG_SYNC_MODE) && (params->sync_mode == L2TP_API_PPP_SYNCMODE_ASYNC))) {