Re: Support for L2TP/IPsec
- From: Vincent Bernat <bernat luffy cx>
- To: Dan Williams <dcbw redhat com>
- Cc: networkmanager-list gnome org
- Subject: Re: Support for L2TP/IPsec
- Date: Fri, 27 Jun 2008 21:55:36 +0200
OoO En ce doux début de matinée du samedi 24 mai 2008, vers 08:44, je
disais:
>> We might have to patch xl2tpd then; I understand why they did it, but
>> passing files around is just broken.
> Hi Dan!
> I will propose a patch for xl2tpd to be able to do anything from command
> line (for a client only) and I will try to push the patch upstream. I
> keep you in touch.
Hi Dan!
I have proposed a patch to upstream that would allow to use xl2tpd just
like pppd. I attach the patch to this message. xl2tpd should be invoked
like this:
xl2tpd --simple <hostname> <pppd args>
This patch needs more work. For example, if the host is incorrect,
xl2tpd will just wait forever but I think this is a good start for a
prototype.
diff --git a/doc/xl2tpd.8 b/doc/xl2tpd.8
index fa86355..b2b8f47 100644
--- a/doc/xl2tpd.8
+++ b/doc/xl2tpd.8
@@ -40,6 +40,12 @@ Tells xl2tpd to use an alternate pid file. Default is
Tells xl2tpd to use an alternate control file. Default is
/var/run/xl2tpd/l2tp-control
+.TP
+.B --simple host args
+Tells xl2tpd to connect to "host" and pass the given args to pppd.
+This mode prevents xl2tpd to daemonize itself. It is aimed at allowing
+LAC connection without any config file.
+
.SH "FILES"
diff --git a/file.c b/file.c
index 3072022..b84183c 100644
--- a/file.c
+++ b/file.c
@@ -33,6 +33,9 @@ struct global gconfig;
char filerr[STRLEN];
int parse_config (FILE *);
+struct lac *new_lac ();
+int set_lns (char *word, char *value, int context, void *item);
+int set_autodial (char *word, char *value, int context, void *item);
struct keyword words[];
int init_config ()
@@ -51,6 +54,14 @@ int init_config ()
laclist = NULL;
deflac = (struct lac *) malloc (sizeof (struct lac));
+ if (gconfig.simple)
+ {
+ laclist = new_lac();
+ strncpy(laclist->entname, gconfig.host, sizeof(laclist->entname));
+ set_lns("lns", gconfig.host, CONTEXT_LAC, laclist);
+ set_autodial("autodial", "yes", CONTEXT_LAC, laclist);
+ return 0;
+ }
f = fopen (gconfig.configfile, "r");
if (!f)
{
diff --git a/file.h b/file.h
index f5488e5..06074a7 100644
--- a/file.h
+++ b/file.h
@@ -153,6 +153,10 @@ struct global
int debug_tunnel; /* Print tunnel debugging info? */
int debug_state; /* Print FSM debugging info? */
int ipsecsaref;
+ int simple; /* Simple LAC mode */
+ char host[STRLEN]; /* Host to connect in simple LAC mode */
+ char **pppdargs; /* Args for pppd */
+ int pppdargs_c;
};
extern struct global gconfig; /* Global configuration options */
diff --git a/xl2tpd.c b/xl2tpd.c
index a423101..a3aef34 100644
--- a/xl2tpd.c
+++ b/xl2tpd.c
@@ -295,6 +295,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
char tty[512];
char *stropt[80];
struct ppp_opts *p;
+ char **q;
#ifdef USE_KERNEL
struct sockaddr_pppol2tp sax;
int flags;
@@ -317,6 +318,18 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
pos++;
p = p->next;
}
+ if (gconfig.simple)
+ {
+ q = gconfig.pppdargs;
+ while(gconfig.pppdargs_c)
+ {
+ stropt[pos] = (char *) malloc (strlen (*q) + 1);
+ strncpy (stropt[pos], *q, strlen (*q) + 1);
+ pos++;
+ q++;
+ gconfig.pppdargs_c--;
+ }
+ }
stropt[pos] = NULL;
if (c->pppd > 0)
{
@@ -1027,7 +1040,7 @@ void do_control ()
void usage(void) {
printf("\nxl2tpd version: %s\n",SERVER_VERSION);
- printf("Usage: xl2tpd [-c <config file>] [-s <secret file>] [-p <pid file>] \n [-C <control file>] [-D]\n");
+ printf("Usage: xl2tpd [--simple host args | [-c <config file>] [-s <secret file>] [-p <pid file>] \n [-C <control file>] [-D]]\n");
printf("\n");
exit(1);
}
@@ -1056,12 +1069,31 @@ void init_args(int argc, char *argv[])
strncpy(gconfig.controlfile,CONTROL_PIPE,
sizeof(gconfig.controlfile) - 1);
gconfig.ipsecsaref = 0;
+ gconfig.simple = 0;
+ memset(gconfig.host,0,STRLEN);
+ gconfig.pppdargs = NULL;
+ gconfig.pppdargs_c = 0;
for (i = 1; i < argc; i++) {
if (! strncmp(argv[i],"--version",9)) {
printf("\nxl2tpd version: %s\n",SERVER_VERSION);
exit(1);
}
+ if (! strncmp(argv[i],"--simple",6)) {
+ if (i != 1)
+ usage();
+ else if (++i == argc)
+ usage();
+ else {
+ strncpy(gconfig.host,argv[i],
+ sizeof(gconfig.host) - 1);
+ gconfig.pppdargs = &argv[++i];
+ gconfig.pppdargs_c = argc-3;
+ gconfig.daemon = 0;
+ gconfig.simple = 1;
+ break;
+ }
+ }
if(! strncmp(argv[i],"-c",2)) {
if(++i == argc)
--
Don't patch bad code - rewrite it.
- The Elements of Programming Style (Kernighan & Plauger)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]